I18N: Do not reuse `$theme` variable name after loading a theme's `functions.php` file.

The file could declare its own `$theme` variable, which would override the one used in the `foreach` loop.

To prevent this, call `wp_get_theme()` before loading the file and store the instance in a different variable.

Props neo2k23, swissspidy.
See #62244.
Built from https://develop.svn.wordpress.org/trunk@59466


git-svn-id: http://core.svn.wordpress.org/trunk@58852 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2024-11-27 14:30:20 +00:00
parent 001cc12b71
commit 42bd4e9761
2 changed files with 5 additions and 4 deletions

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59465';
$wp_version = '6.8-alpha-59466';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -679,14 +679,15 @@ $GLOBALS['wp_locale_switcher']->init();
// Load the functions for the active theme, for both parent and child theme if applicable.
foreach ( wp_get_active_and_valid_themes() as $theme ) {
$wp_theme = wp_get_theme( basename( $theme ) );
if ( file_exists( $theme . '/functions.php' ) ) {
include $theme . '/functions.php';
}
$theme = wp_get_theme( basename( $theme ) );
$theme->load_textdomain();
$wp_theme->load_textdomain();
}
unset( $theme );
unset( $theme, $wp_theme );
/**
* Fires after the theme is loaded.