Make WordPress Core

Changeset 57922


Ignore:
Timestamp:
04/04/2024 01:36:25 PM (10 months ago)
Author:
swissspidy
Message:

I18N: Always search for script translations in wp-content/languages/plugins.

Previously, when WP_PLUGIN_DIR was set to something other than wp-content/plugins, e.g. wp-content/mods, load_script_textdomain was searching for script translations in wp-content/languages/mods. However, that is incorrect, as WP_PLUGIN_DIR does not affect where translations are stored. The location is always wp-content/languages/plugins.

Props coreymckrill, swissspidy.
Fixes #60891.

Location:
trunk
Files:
2 edited

Legend:

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

    r57639 r57922  
    11901190        $relative = explode( '/', $relative );
    11911191
    1192         $languages_path = WP_LANG_DIR . '/' . $relative[0];
     1192        $languages_path = WP_LANG_DIR . '/plugins';
    11931193
    11941194        $relative = array_slice( $relative, 2 ); // Remove plugins/<plugin name> or themes/<theme name>.
  • trunk/tests/phpunit/tests/l10n/loadScriptTextdomain.php

    r55562 r57922  
    1414     * @ticket 46387
    1515     * @ticket 49145
     16     * @ticket 60891
    1617     *
    1718     * @dataProvider data_resolve_relative_path
     
    122123                ),
    123124            ),
     125            // @ticket 60891
     126            array(
     127                '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json',
     128                'plugin-in-custom-plugin-dir',
     129                '/wp-content/mods/my-plugin/js/script.js',
     130                'internationalized-plugin',
     131                array(
     132                    'plugins_url',
     133                    static function () {
     134                        return 'https://example.com/wp-content/mods';
     135                    },
     136                ),
     137            ),
    124138        );
    125139    }
Note: See TracChangeset for help on using the changeset viewer.