Make WordPress Core

Changeset 59466


Ignore:
Timestamp:
11/27/2024 02:28:55 PM (15 months ago)
Author:
swissspidy
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-settings.php

    r59461 r59466  
    680680// Load the functions for the active theme, for both parent and child theme if applicable.
    681681foreach ( 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 }
    689 unset( $theme );
     688    $wp_theme->load_textdomain();
     689}
     690unset( $theme, $wp_theme );
    690691
    691692/**
Note: See TracChangeset for help on using the changeset viewer.