Changeset 54214 for trunk/src/wp-includes/script-loader.php
- Timestamp:
- 09/19/2022 08:54:20 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r54209 r54214 2968 2968 2969 2969 /** 2970 * Fetches, processes and compiles stored core styles, then combines and renders them to the page. 2971 * Styles are stored via the style engine API. 2972 * 2973 * @link https://developer.wordpress.org/block-editor/reference-guides/packages/packages-style-engine/ 2974 * 2975 * @since 6.1.0 2976 * 2977 * @param array $options { 2978 * Optional. An array of options to pass to wp_style_engine_get_stylesheet_from_context(). Default empty array. 2979 * 2980 * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`. 2981 * @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined. 2982 * } 2983 * 2984 * @return void 2985 */ 2986 function wp_enqueue_stored_styles( $options = array() ) { 2987 $is_block_theme = wp_is_block_theme(); 2988 $is_classic_theme = ! $is_block_theme; 2989 2990 /* 2991 * For block themes, this function prints stored styles in the header. 2992 * For classic themes, in the footer. 2993 */ 2994 if ( 2995 ( $is_block_theme && doing_action( 'wp_footer' ) ) || 2996 ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) ) 2997 ) { 2998 return; 2999 } 3000 3001 $core_styles_keys = array( 'block-supports' ); 3002 $compiled_core_stylesheet = ''; 3003 $style_tag_id = 'core'; 3004 // Adds comment if code is prettified to identify core styles sections in debugging. 3005 $should_prettify = isset( $options['prettify'] ) ? true === $options['prettify'] : defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; 3006 foreach ( $core_styles_keys as $style_key ) { 3007 if ( $should_prettify ) { 3008 $compiled_core_stylesheet .= "/**\n * Core styles: $style_key\n */\n"; 3009 } 3010 // Chains core store ids to signify what the styles contain. 3011 $style_tag_id .= '-' . $style_key; 3012 $compiled_core_stylesheet .= wp_style_engine_get_stylesheet_from_context( $style_key, $options ); 3013 } 3014 3015 // Combines Core styles. 3016 if ( ! empty( $compiled_core_stylesheet ) ) { 3017 wp_register_style( $style_tag_id, false, array(), true, true ); 3018 wp_add_inline_style( $style_tag_id, $compiled_core_stylesheet ); 3019 wp_enqueue_style( $style_tag_id ); 3020 } 3021 3022 // Prints out any other stores registered by themes or otherwise. 3023 $additional_stores = WP_Style_Engine_CSS_Rules_Store::get_stores(); 3024 foreach ( array_keys( $additional_stores ) as $store_name ) { 3025 if ( in_array( $store_name, $core_styles_keys, true ) ) { 3026 continue; 3027 } 3028 $styles = wp_style_engine_get_stylesheet_from_context( $store_name, $options ); 3029 if ( ! empty( $styles ) ) { 3030 $key = "wp-style-engine-$store_name"; 3031 wp_register_style( $key, false, array(), true, true ); 3032 wp_add_inline_style( $key, $styles ); 3033 wp_enqueue_style( $key ); 3034 } 3035 } 3036 } 3037 3038 /** 2970 3039 * Enqueues a stylesheet for a specific block. 2971 3040 *
Note: See TracChangeset
for help on using the changeset viewer.