Make WordPress Core


Ignore:
Timestamp:
09/30/2024 02:57:32 PM (7 months ago)
Author:
swissspidy
Message:

I18N: Fix script languages path for themes.

Remove hardcoded path added in [57922] which ignored the fact that themes can also use script translations.
They should not be affected even if plugins are installed outside the typical wp-content/plugins location.

Props itapress, swissspidy.
Fixes #62016.

File:
1 edited

Legend:

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

    r59029 r59126  
    12081208        $relative = explode( '/', $relative );
    12091209
    1210         $languages_path = WP_LANG_DIR . '/plugins';
     1210        /*
     1211         * Ensure correct languages path when using a custom `WP_PLUGIN_DIR` / `WP_PLUGIN_URL` configuration.
     1212         * See https://core.trac.wordpress.org/ticket/60891 and https://core.trac.wordpress.org/ticket/62016.
     1213         */
     1214        $plugins_dir = array_slice( explode( '/', $plugins_url['path'] ), 2 );
     1215        $plugins_dir = trim( $plugins_dir[0], '/' );
     1216        $dirname     = $plugins_dir === $relative[0] ? 'plugins' : 'themes';
     1217
     1218        $languages_path = WP_LANG_DIR . '/' . $dirname;
    12111219
    12121220        $relative = array_slice( $relative, 2 ); // Remove plugins/<plugin name> or themes/<theme name>.
Note: See TracChangeset for help on using the changeset viewer.