Making WordPress.org


Ignore:
Timestamp:
02/16/2019 12:57:49 AM (8 years ago)
Author:
coreymckrill
Message:

WordCamp Post Type: Ensure status change logs are in English

WCPT's status labels are translatable, but they're also used in logs
when a WordCamp application status changes. Since not all application
reviewers use en_US for their locale, this ensures that the logs are still
readable by everyone.

The WordCamp Reports plugin also relies on status changes being in English.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php

    r8235 r8262  
    251251
    252252        /**
     253         * Filter: Set the locale to en_US.
     254         *
     255         * For some purposes, such as internal logging, strings that would normally be translated to the
     256         * current user's locale should be in English, so that other users who may not share the same
     257         * locale can read them.
     258         *
     259         * @return string
     260         */
     261        public function set_locale_to_en_US() {
     262                return 'en_US';
     263        }
     264
     265        /**
    253266         * Log when the post status changes
    254267         *
    … …  
    265278                        return;
    266279                }
     280
     281                // Ensure status labels are in English.
     282                add_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
    267283
    268284                $old_status = get_post_status_object( $old_status );
    … …  
    278294                        )
    279295                );
     296
    280297                // Encoding $post_type and status_change meta ID in key so that we can fetch it if needed while simultaneously be able to have a where clause on value.
    281298                // Because of the way MySQL works, it will still be able to use index on meta_key when searching, as long as we are querying just the prefix.
    … …  
    283300                        add_post_meta( $post->ID, "_status_change_log_$post->post_type $log_id", time() );
    284301                }
     302
     303                // Remove the temporary locale change.
     304                remove_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
    285305        }
    286306
Note: See TracChangeset for help on using the changeset viewer.