Skip to content

Commit e904637

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59466 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b72334e commit e904637

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/wp-settings.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,14 +679,15 @@
679679

680680
// Load the functions for the active theme, for both parent and child theme if applicable.
681681
foreach ( wp_get_active_and_valid_themes() as $theme ) {
682+
$wp_theme = wp_get_theme( basename( $theme ) );
683+
682684
if ( file_exists( $theme . '/functions.php' ) ) {
683685
include $theme . '/functions.php';
684686
}
685687

686-
$theme = wp_get_theme( basename( $theme ) );
687-
$theme->load_textdomain();
688+
$wp_theme->load_textdomain();
688689
}
689-
unset( $theme );
690+
unset( $theme, $wp_theme );
690691

691692
/**
692693
* Fires after the theme is loaded.

0 commit comments

Comments
 (0)