Make WordPress Core


Ignore:
Timestamp:
02/16/2016 09:14:45 PM (9 years ago)
Author:
ocean90
Message:

i18n: Prevent is_textdomain_loaded() from returning true even if there are no translations for the domain.

In get_translations_for_domain() don't fill the global $l10n with NOOP_Translations instances, return a NOOP_Translations instance instead.

Props nacin, jrf.
Fixes #21319.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r36290 r36538  
    794794function get_translations_for_domain( $domain ) {
    795795    global $l10n;
    796     if ( !isset( $l10n[$domain] ) ) {
    797         $l10n[$domain] = new NOOP_Translations;
    798     }
    799     return $l10n[$domain];
     796    if ( isset( $l10n[ $domain ] ) ) {
     797        return $l10n[ $domain ];
     798    }
     799
     800    static $noop_translations = null;
     801    if ( null === $noop_translations ) {
     802        $noop_translations = new NOOP_Translations;
     803    }
     804
     805    return $noop_translations;
    800806}
    801807
     
    812818function is_textdomain_loaded( $domain ) {
    813819    global $l10n;
    814     return isset( $l10n[$domain] );
     820    return isset( $l10n[ $domain ] );
    815821}
    816822
Note: See TracChangeset for help on using the changeset viewer.