Making WordPress.org


Ignore:
Timestamp:
05/26/2017 11:30:19 PM (9 years ago)
Author:
coreymckrill
Message:

WordCamp: Change timing of text domain load to allow usage of user locale

It turns out that wp_get_current_user, which is needed for get_user_locale
to work correctly, is not available when mu-plugin code runs. This defers the
text domain load until the plugins_loaded hook so that function is available,
which ensures that the wordcamporg text domain is loaded for the user locale
rather than the site locale.

Previous attempts to fix this issue, r5518 and r5520, failed because they didn't
take into account the wp_get_current_user dependency.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php

    r5520 r5521  
    226226 * `wordcamporg` is used by all the custom plugins and themes, so that translators only have to deal with a single
    227227 * GlotPress project, and we only have to install/update a single mofile per locale.
    228  *
    229  * There is no .mo file for en_US, so don't load the text domain if that is the specified user locale.
    230  */
    231 if ( 'en_US' !== get_user_locale() ) {
     228 */
     229add_action( 'plugins_loaded', function() {
    232230    load_textdomain( 'wordcamporg', sprintf( '%s/languages/wordcamporg/wordcamporg-%s.mo', WP_CONTENT_DIR, get_user_locale() ) );
    233 }
     231} );
    234232
    235233// WordCamp.org QBO Integration
Note: See TracChangeset for help on using the changeset viewer.