wp/wp-includes/theme.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
--- a/wp/wp-includes/theme.php	Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/theme.php	Fri Sep 05 18:52:52 2025 +0200
@@ -14,7 +14,7 @@
  *
  * @since 3.4.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param array $args {
  *     Optional. The search arguments.
@@ -105,7 +105,7 @@
  *
  * @since 3.4.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param string $stylesheet Optional. Directory name for the theme. Defaults to active theme.
  * @param string $theme_root Optional. Absolute path of the theme root to look in.
@@ -380,7 +380,7 @@
  *
  * @since 2.9.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @return array|string An array of theme roots keyed by template/stylesheet
  *                      or a single theme root if all themes have the same root.
@@ -405,7 +405,7 @@
  *
  * @since 2.9.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param string $directory Either the full filesystem path to a theme folder
  *                          or a folder within WP_CONTENT_DIR.
@@ -441,7 +441,7 @@
  *
  * @since 2.9.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param bool $force Optional. Whether to force a new directory scan. Default false.
  * @return array|false Valid themes found on success, false on failure.
@@ -591,7 +591,7 @@
  *
  * @since 1.5.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param string $stylesheet_or_template Optional. The stylesheet or template name of the theme.
  *                                       Default is to leverage the main theme root.
@@ -636,7 +636,7 @@
  *
  * @since 1.5.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param string $stylesheet_or_template Optional. The stylesheet or template name of the theme.
  *                                       Default is to leverage the main theme root.
@@ -687,7 +687,7 @@
  *
  * @since 3.1.0
  *
- * @global array $wp_theme_directories
+ * @global string[] $wp_theme_directories
  *
  * @param string $stylesheet_or_template The stylesheet or template name of the theme.
  * @param bool   $skip_cache             Optional. Whether to skip the cache.
@@ -750,7 +750,7 @@
  *
  * @since 2.5.0
  *
- * @global array                $wp_theme_directories
+ * @global string[]             $wp_theme_directories
  * @global WP_Customize_Manager $wp_customize
  * @global array                $sidebars_widgets
  * @global array                $wp_registered_sidebars
@@ -786,7 +786,7 @@
 	}
 
 	$nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
-	update_option( 'theme_switch_menu_locations', $nav_menu_locations );
+	update_option( 'theme_switch_menu_locations', $nav_menu_locations, true );
 
 	if ( func_num_args() > 1 ) {
 		$stylesheet = func_get_arg( 1 );
@@ -1893,7 +1893,7 @@
 		return;
 	}
 
-	$style = $color ? "background-color: #$color;" : '';
+	$style = $color ? 'background-color: ' . maybe_hash_hex_color( $color ) . ';' : '';
 
 	if ( $background ) {
 		$image = ' background-image: url("' . sanitize_url( $background ) . '");';
@@ -3001,7 +3001,7 @@
 		<style id="custom-logo-css"<?php echo $type_attr; ?>>
 			<?php echo $classes; ?> {
 				position: absolute;
-				clip: rect(1px, 1px, 1px, 1px);
+				clip-path: inset(50%);
 			}
 		</style>
 		<?php
@@ -4352,6 +4352,11 @@
  * @return bool Whether the active theme is a block-based theme or not.
  */
 function wp_is_block_theme() {
+	if ( empty( $GLOBALS['wp_theme_directories'] ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'This function should not be called before the theme directory is registered.' ), '6.8.0' );
+		return false;
+	}
+
 	return wp_get_theme()->is_block_theme();
 }
 
@@ -4395,6 +4400,7 @@
 	add_theme_support( 'automatic-feed-links' );
 
 	add_filter( 'should_load_separate_core_block_assets', '__return_true' );
+	add_filter( 'should_load_block_assets_on_demand', '__return_true' );
 
 	/*
 	 * Remove the Customizer's Menus panel when block theme is active.