From 27a0ebb864c0d72a59a037fc2c7d7c178bb978da Mon Sep 17 00:00:00 2001 From: ramon Date: Tue, 30 Jan 2024 06:46:27 +1100 Subject: [PATCH] Core checks that the init hook is complete before trying to use the global $wp_locale value in wp_default_packages_inline_scripts, which is where the date settings are set for inline JS. This change backports that from Core. --- lib/compat/wordpress-6.4/script-loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.4/script-loader.php b/lib/compat/wordpress-6.4/script-loader.php index dd7042d54e179..217cdef053789 100644 --- a/lib/compat/wordpress-6.4/script-loader.php +++ b/lib/compat/wordpress-6.4/script-loader.php @@ -17,7 +17,7 @@ * @param WP_Scripts $scripts WP_Scripts object. */ function gutenberg_update_wp_date_settings( $scripts ) { - if ( $scripts->query( 'wp-date', 'registered' ) ) { + if ( did_action( 'init' ) && $scripts->query( 'wp-date', 'registered' ) ) { global $wp_locale; // Calculate the timezone abbr (EDT, PST) if possible. $timezone_string = get_option( 'timezone_string', 'UTC' );