WordPress.org

Make WordPress Core

Ticket #34213: 34213.diff

File 34213.diff, 2.7 KB (added by swissspidy, 3 years ago)
  • src/wp-includes/l10n.php

    diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php
    index 4bfb989..5282a38 100644
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    683683                $path = WP_PLUGIN_DIR;
    684684        }
    685685
    686         // Load the textdomain according to the plugin first
     686        /*
     687         * Load the plugin textdomain.
     688         *
     689         * Load from the languages directory first,
     690         * otherwise, load the textdomain according to the plugin.
     691         */
    687692        $mofile = $domain . '-' . $locale . '.mo';
    688         if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) )
    689                 return $loaded;
     693        $loaded = load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile );
    690694
    691         // Otherwise, load from the languages directory
    692         $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    693         return load_textdomain( $domain, $mofile );
     695        return ( $loaded ) ? $loaded : load_textdomain( $domain, $path . '/' . $mofile );
    694696}
    695697
    696698/**
    function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { 
    708710        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
    709711        $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) );
    710712
    711         // Load the textdomain according to the plugin first
     713        /*
     714         * Load the plugin textdomain.
     715         *
     716         * Load from the languages directory first,
     717         * otherwise, load the textdomain according to the plugin.
     718         */
    712719        $mofile = $domain . '-' . $locale . '.mo';
    713         if ( $loaded = load_textdomain( $domain, $path . $mofile ) )
    714                 return $loaded;
     720        $loaded = load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile );
    715721
    716         // Otherwise, load from the languages directory
    717         $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
    718         return load_textdomain( $domain, $mofile );
     722        return ( $loaded ) ? $loaded : load_textdomain( $domain, $path . '/' . $mofile );
    719723}
    720724
    721725/**
    function load_theme_textdomain( $domain, $path = false ) { 
    745749         */
    746750        $locale = apply_filters( 'theme_locale', $locale, $domain );
    747751
    748         if ( ! $path )
     752        if ( ! $path ) {
    749753                $path = get_template_directory();
     754        }
    750755
    751         // Load the textdomain according to the theme
    752         $mofile = untrailingslashit( $path ) . "/{$locale}.mo";
    753         if ( $loaded = load_textdomain( $domain, $mofile ) )
    754                 return $loaded;
     756        /*
     757         * Load the theme textdomain.
     758         *
     759         * Load from the languages directory first,
     760         * otherwise, load the textdomain according to the theme.
     761         */
     762        $mofile = $domain . '-' . $locale . '.mo';
     763        $loaded = load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile );
    755764
    756         // Otherwise, load from the languages directory
    757         $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
    758         return load_textdomain( $domain, $mofile );
     765        return ( $loaded ) ? $loaded : load_textdomain( $domain, $path . '/' . $mofile );
    759766}
    760767
    761768/**