Changeset 54408
- Timestamp:
- 10/07/2022 09:38:15 AM (2 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json-resolver.php
r54399 r54408 296 296 * @param WP_Theme_JSON_Data Class to access and update the underlying data. 297 297 */ 298 $theme_json = apply_filters( 'theme_json_blocks', new WP_Theme_JSON_Data( $config, ' core' ) );298 $theme_json = apply_filters( 'theme_json_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) ); 299 299 $config = $theme_json->get_data(); 300 300 301 // Core here means it's the lower level part of the styles chain. 302 // It can be a core or a third-party block. 303 return new WP_Theme_JSON( $config, 'core' ); 301 return new WP_Theme_JSON( $config, 'blocks' ); 304 302 } 305 303 -
trunk/src/wp-includes/class-wp-theme-json.php
r54398 r54408 51 51 * 52 52 * @since 5.8.0 53 * @since 6.1.0 Added 'blocks'. 53 54 * @var string[] 54 55 */ 55 56 const VALID_ORIGINS = array( 56 57 'default', 58 'blocks', 57 59 'theme', 58 60 'custom', -
trunk/src/wp-includes/global-styles-and-settings.php
r54162 r54408 114 114 115 115 /* 116 * If variables are part of the stylesheet, 117 * we add them for all origins (default, theme, user). 116 * If variables are part of the stylesheet, then add them. 118 117 * This is so themes without a theme.json still work as before 5.9: 119 118 * they can override the default presets. … … 122 121 $styles_variables = ''; 123 122 if ( in_array( 'variables', $types, true ) ) { 124 $styles_variables = $tree->get_stylesheet( array( 'variables' ) ); 123 /* 124 * Only use the default, theme, and custom origins. Why? 125 * Because styles for `blocks` origin are added at a later phase 126 * (i.e. in the render cycle). Here, only the ones in use are rendered. 127 * @see wp_add_global_styles_for_blocks 128 */ 129 $origins = array( 'default', 'theme', 'custom' ); 130 $styles_variables = $tree->get_stylesheet( array( 'variables' ), $origins ); 125 131 $types = array_diff( $types, array( 'variables' ) ); 126 132 } … … 134 140 $styles_rest = ''; 135 141 if ( ! empty( $types ) ) { 142 /* 143 * Only use the default, theme, and custom origins. Why? 144 * Because styles for `blocks` origin are added at a later phase 145 * (i.e. in the render cycle). Here, only the ones in use are rendered. 146 * @see wp_add_global_styles_for_blocks 147 */ 136 148 $origins = array( 'default', 'theme', 'custom' ); 137 149 if ( ! $supports_theme_json ) { … … 204 216 foreach ( $block_nodes as $metadata ) { 205 217 $block_css = $tree->get_styles_for_block( $metadata ); 218 219 if ( ! wp_should_load_separate_core_block_assets() ) { 220 wp_add_inline_style( 'global-styles', $block_css ); 221 continue; 222 } 206 223 207 224 if ( isset( $metadata['name'] ) ) { -
trunk/src/wp-includes/script-loader.php
r54386 r54408 2410 2410 2411 2411 /* 2412 * If we are loading CSS for each block separately, then we can load the theme.json CSS conditionally.2412 * If loading the CSS for each block separately, then load the theme.json CSS conditionally. 2413 2413 * This removes the CSS from the global-styles stylesheet and adds it to the inline CSS for each block. 2414 * This filter must be registered before calling wp_get_global_stylesheet(); 2414 2415 */ 2415 if ( $separate_assets ) { 2416 add_filter( 'theme_json_get_style_nodes', 'wp_filter_out_block_nodes' ); 2417 // Add each block as an inline css. 2418 wp_add_global_styles_for_blocks(); 2419 } 2416 add_filter( 'theme_json_get_style_nodes', 'wp_filter_out_block_nodes' ); 2420 2417 2421 2418 $stylesheet = wp_get_global_stylesheet(); … … 2428 2425 wp_add_inline_style( 'global-styles', $stylesheet ); 2429 2426 wp_enqueue_style( 'global-styles' ); 2427 2428 // Add each block as an inline css. 2429 wp_add_global_styles_for_blocks(); 2430 2430 } 2431 2431
Note: See TracChangeset
for help on using the changeset viewer.