Make WordPress Core

Changeset 59670


Ignore:
Timestamp:
01/21/2025 11:42:19 AM (3 months ago)
Author:
swissspidy
Message:

I18N: Set textdomain registry information before loading plugins/theme.

This way, warnings for early translation calls can be emitted that aren't attached to any hook.

Follow-up to [59461].

Props swissspidy.
Fixes #62244.See #44937.

File:
1 edited

Legend:

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

    r59488 r59670  
    526526    wp_register_plugin_realpath( $plugin );
    527527
     528    $plugin_data = get_plugin_data( $plugin, false, false );
     529
     530    $textdomain = $plugin_data['TextDomain'];
     531    if ( $textdomain ) {
     532        if ( $plugin_data['DomainPath'] ) {
     533            $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] );
     534        } else {
     535            $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) );
     536        }
     537    }
     538
    528539    $_wp_plugin_file = $plugin;
    529540    include_once $plugin;
     
    538549     */
    539550    do_action( 'plugin_loaded', $plugin );
    540 
    541     $plugin_data = get_plugin_data( $plugin, false, false );
    542 
    543     $textdomain = $plugin_data['TextDomain'];
    544     if ( $textdomain ) {
    545         if ( $plugin_data['DomainPath'] ) {
    546             $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) . $plugin_data['DomainPath'] );
    547         } else {
    548             $GLOBALS['wp_textdomain_registry']->set_custom_path( $textdomain, dirname( $plugin ) );
    549         }
    550     }
    551551}
    552552unset( $plugin, $_wp_plugin_file, $plugin_data, $textdomain );
     
    685685    $wp_theme = wp_get_theme( basename( $theme ) );
    686686
     687    $wp_theme->load_textdomain();
     688
    687689    if ( file_exists( $theme . '/functions.php' ) ) {
    688690        include $theme . '/functions.php';
    689691    }
    690 
    691     $wp_theme->load_textdomain();
    692692}
    693693unset( $theme, $wp_theme );
Note: See TracChangeset for help on using the changeset viewer.