Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: class-wp-theme-json.php
[2500] Fix | Delete
foreach ( $theme_json['settings']['blocks'] as $name => $node ) {
[2501] Fix | Delete
$selector = null;
[2502] Fix | Delete
if ( isset( $selectors[ $name ]['selector'] ) ) {
[2503] Fix | Delete
$selector = $selectors[ $name ]['selector'];
[2504] Fix | Delete
}
[2505] Fix | Delete
[2506] Fix | Delete
$nodes[] = array(
[2507] Fix | Delete
'path' => array( 'settings', 'blocks', $name ),
[2508] Fix | Delete
'selector' => $selector,
[2509] Fix | Delete
);
[2510] Fix | Delete
}
[2511] Fix | Delete
[2512] Fix | Delete
return $nodes;
[2513] Fix | Delete
}
[2514] Fix | Delete
[2515] Fix | Delete
/**
[2516] Fix | Delete
* Builds metadata for the style nodes, which returns in the form of:
[2517] Fix | Delete
*
[2518] Fix | Delete
* [
[2519] Fix | Delete
* [
[2520] Fix | Delete
* 'path' => [ 'path', 'to', 'some', 'node' ],
[2521] Fix | Delete
* 'selector' => 'CSS selector for some node',
[2522] Fix | Delete
* 'duotone' => 'CSS selector for duotone for some node'
[2523] Fix | Delete
* ],
[2524] Fix | Delete
* [
[2525] Fix | Delete
* 'path' => ['path', 'to', 'other', 'node' ],
[2526] Fix | Delete
* 'selector' => 'CSS selector for other node',
[2527] Fix | Delete
* 'duotone' => null
[2528] Fix | Delete
* ],
[2529] Fix | Delete
* ]
[2530] Fix | Delete
*
[2531] Fix | Delete
* @since 5.8.0
[2532] Fix | Delete
* @since 6.6.0 Added options array for modifying generated nodes.
[2533] Fix | Delete
*
[2534] Fix | Delete
* @param array $theme_json The tree to extract style nodes from.
[2535] Fix | Delete
* @param array $selectors List of selectors per block.
[2536] Fix | Delete
* @param array $options {
[2537] Fix | Delete
* Optional. An array of options for now used for internal purposes only (may change without notice).
[2538] Fix | Delete
*
[2539] Fix | Delete
* @type bool $include_block_style_variations Includes style nodes for block style variations. Default false.
[2540] Fix | Delete
* }
[2541] Fix | Delete
* @return array An array of style nodes metadata.
[2542] Fix | Delete
*/
[2543] Fix | Delete
protected static function get_style_nodes( $theme_json, $selectors = array(), $options = array() ) {
[2544] Fix | Delete
$nodes = array();
[2545] Fix | Delete
if ( ! isset( $theme_json['styles'] ) ) {
[2546] Fix | Delete
return $nodes;
[2547] Fix | Delete
}
[2548] Fix | Delete
[2549] Fix | Delete
// Top-level.
[2550] Fix | Delete
$nodes[] = array(
[2551] Fix | Delete
'path' => array( 'styles' ),
[2552] Fix | Delete
'selector' => static::ROOT_BLOCK_SELECTOR,
[2553] Fix | Delete
);
[2554] Fix | Delete
[2555] Fix | Delete
if ( isset( $theme_json['styles']['elements'] ) ) {
[2556] Fix | Delete
foreach ( self::ELEMENTS as $element => $selector ) {
[2557] Fix | Delete
if ( ! isset( $theme_json['styles']['elements'][ $element ] ) ) {
[2558] Fix | Delete
continue;
[2559] Fix | Delete
}
[2560] Fix | Delete
$nodes[] = array(
[2561] Fix | Delete
'path' => array( 'styles', 'elements', $element ),
[2562] Fix | Delete
'selector' => static::ELEMENTS[ $element ],
[2563] Fix | Delete
);
[2564] Fix | Delete
[2565] Fix | Delete
// Handle any pseudo selectors for the element.
[2566] Fix | Delete
if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] ) ) {
[2567] Fix | Delete
foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) {
[2568] Fix | Delete
[2569] Fix | Delete
if ( isset( $theme_json['styles']['elements'][ $element ][ $pseudo_selector ] ) ) {
[2570] Fix | Delete
$nodes[] = array(
[2571] Fix | Delete
'path' => array( 'styles', 'elements', $element ),
[2572] Fix | Delete
'selector' => static::append_to_selector( static::ELEMENTS[ $element ], $pseudo_selector ),
[2573] Fix | Delete
);
[2574] Fix | Delete
}
[2575] Fix | Delete
}
[2576] Fix | Delete
}
[2577] Fix | Delete
}
[2578] Fix | Delete
}
[2579] Fix | Delete
[2580] Fix | Delete
// Blocks.
[2581] Fix | Delete
if ( ! isset( $theme_json['styles']['blocks'] ) ) {
[2582] Fix | Delete
return $nodes;
[2583] Fix | Delete
}
[2584] Fix | Delete
[2585] Fix | Delete
$block_nodes = static::get_block_nodes( $theme_json, $selectors, $options );
[2586] Fix | Delete
foreach ( $block_nodes as $block_node ) {
[2587] Fix | Delete
$nodes[] = $block_node;
[2588] Fix | Delete
}
[2589] Fix | Delete
[2590] Fix | Delete
/**
[2591] Fix | Delete
* Filters the list of style nodes with metadata.
[2592] Fix | Delete
*
[2593] Fix | Delete
* This allows for things like loading block CSS independently.
[2594] Fix | Delete
*
[2595] Fix | Delete
* @since 6.1.0
[2596] Fix | Delete
*
[2597] Fix | Delete
* @param array $nodes Style nodes with metadata.
[2598] Fix | Delete
*/
[2599] Fix | Delete
return apply_filters( 'wp_theme_json_get_style_nodes', $nodes );
[2600] Fix | Delete
}
[2601] Fix | Delete
[2602] Fix | Delete
/**
[2603] Fix | Delete
* A public helper to get the block nodes from a theme.json file.
[2604] Fix | Delete
*
[2605] Fix | Delete
* @since 6.1.0
[2606] Fix | Delete
*
[2607] Fix | Delete
* @return array The block nodes in theme.json.
[2608] Fix | Delete
*/
[2609] Fix | Delete
public function get_styles_block_nodes() {
[2610] Fix | Delete
return static::get_block_nodes( $this->theme_json );
[2611] Fix | Delete
}
[2612] Fix | Delete
[2613] Fix | Delete
/**
[2614] Fix | Delete
* Returns a filtered declarations array if there is a separator block with only a background
[2615] Fix | Delete
* style defined in theme.json by adding a color attribute to reflect the changes in the front.
[2616] Fix | Delete
*
[2617] Fix | Delete
* @since 6.1.1
[2618] Fix | Delete
*
[2619] Fix | Delete
* @param array $declarations List of declarations.
[2620] Fix | Delete
* @return array $declarations List of declarations filtered.
[2621] Fix | Delete
*/
[2622] Fix | Delete
private static function update_separator_declarations( $declarations ) {
[2623] Fix | Delete
$background_color = '';
[2624] Fix | Delete
$border_color_matches = false;
[2625] Fix | Delete
$text_color_matches = false;
[2626] Fix | Delete
[2627] Fix | Delete
foreach ( $declarations as $declaration ) {
[2628] Fix | Delete
if ( 'background-color' === $declaration['name'] && ! $background_color && isset( $declaration['value'] ) ) {
[2629] Fix | Delete
$background_color = $declaration['value'];
[2630] Fix | Delete
} elseif ( 'border-color' === $declaration['name'] ) {
[2631] Fix | Delete
$border_color_matches = true;
[2632] Fix | Delete
} elseif ( 'color' === $declaration['name'] ) {
[2633] Fix | Delete
$text_color_matches = true;
[2634] Fix | Delete
}
[2635] Fix | Delete
[2636] Fix | Delete
if ( $background_color && $border_color_matches && $text_color_matches ) {
[2637] Fix | Delete
break;
[2638] Fix | Delete
}
[2639] Fix | Delete
}
[2640] Fix | Delete
[2641] Fix | Delete
if ( $background_color && ! $border_color_matches && ! $text_color_matches ) {
[2642] Fix | Delete
$declarations[] = array(
[2643] Fix | Delete
'name' => 'color',
[2644] Fix | Delete
'value' => $background_color,
[2645] Fix | Delete
);
[2646] Fix | Delete
}
[2647] Fix | Delete
[2648] Fix | Delete
return $declarations;
[2649] Fix | Delete
}
[2650] Fix | Delete
[2651] Fix | Delete
/**
[2652] Fix | Delete
* An internal method to get the block nodes from a theme.json file.
[2653] Fix | Delete
*
[2654] Fix | Delete
* @since 6.1.0
[2655] Fix | Delete
* @since 6.3.0 Refactored and stabilized selectors API.
[2656] Fix | Delete
* @since 6.6.0 Added optional selectors and options for generating block nodes.
[2657] Fix | Delete
*
[2658] Fix | Delete
* @param array $theme_json The theme.json converted to an array.
[2659] Fix | Delete
* @param array $selectors Optional list of selectors per block.
[2660] Fix | Delete
* @param array $options {
[2661] Fix | Delete
* Optional. An array of options for now used for internal purposes only (may change without notice).
[2662] Fix | Delete
*
[2663] Fix | Delete
* @type bool $include_block_style_variations Includes nodes for block style variations. Default false.
[2664] Fix | Delete
* }
[2665] Fix | Delete
* @return array The block nodes in theme.json.
[2666] Fix | Delete
*/
[2667] Fix | Delete
private static function get_block_nodes( $theme_json, $selectors = array(), $options = array() ) {
[2668] Fix | Delete
$selectors = empty( $selectors ) ? static::get_blocks_metadata() : $selectors;
[2669] Fix | Delete
$nodes = array();
[2670] Fix | Delete
if ( ! isset( $theme_json['styles'] ) ) {
[2671] Fix | Delete
return $nodes;
[2672] Fix | Delete
}
[2673] Fix | Delete
[2674] Fix | Delete
// Blocks.
[2675] Fix | Delete
if ( ! isset( $theme_json['styles']['blocks'] ) ) {
[2676] Fix | Delete
return $nodes;
[2677] Fix | Delete
}
[2678] Fix | Delete
[2679] Fix | Delete
foreach ( $theme_json['styles']['blocks'] as $name => $node ) {
[2680] Fix | Delete
$selector = null;
[2681] Fix | Delete
if ( isset( $selectors[ $name ]['selector'] ) ) {
[2682] Fix | Delete
$selector = $selectors[ $name ]['selector'];
[2683] Fix | Delete
}
[2684] Fix | Delete
[2685] Fix | Delete
$duotone_selector = null;
[2686] Fix | Delete
if ( isset( $selectors[ $name ]['duotone'] ) ) {
[2687] Fix | Delete
$duotone_selector = $selectors[ $name ]['duotone'];
[2688] Fix | Delete
}
[2689] Fix | Delete
[2690] Fix | Delete
$feature_selectors = null;
[2691] Fix | Delete
if ( isset( $selectors[ $name ]['selectors'] ) ) {
[2692] Fix | Delete
$feature_selectors = $selectors[ $name ]['selectors'];
[2693] Fix | Delete
}
[2694] Fix | Delete
[2695] Fix | Delete
$variation_selectors = array();
[2696] Fix | Delete
$include_variations = $options['include_block_style_variations'] ?? false;
[2697] Fix | Delete
if ( $include_variations && isset( $node['variations'] ) ) {
[2698] Fix | Delete
foreach ( $node['variations'] as $variation => $node ) {
[2699] Fix | Delete
$variation_selectors[] = array(
[2700] Fix | Delete
'path' => array( 'styles', 'blocks', $name, 'variations', $variation ),
[2701] Fix | Delete
'selector' => $selectors[ $name ]['styleVariations'][ $variation ],
[2702] Fix | Delete
);
[2703] Fix | Delete
}
[2704] Fix | Delete
}
[2705] Fix | Delete
[2706] Fix | Delete
$nodes[] = array(
[2707] Fix | Delete
'name' => $name,
[2708] Fix | Delete
'path' => array( 'styles', 'blocks', $name ),
[2709] Fix | Delete
'selector' => $selector,
[2710] Fix | Delete
'selectors' => $feature_selectors,
[2711] Fix | Delete
'duotone' => $duotone_selector,
[2712] Fix | Delete
'features' => $feature_selectors,
[2713] Fix | Delete
'variations' => $variation_selectors,
[2714] Fix | Delete
);
[2715] Fix | Delete
[2716] Fix | Delete
if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'] ) ) {
[2717] Fix | Delete
foreach ( $theme_json['styles']['blocks'][ $name ]['elements'] as $element => $node ) {
[2718] Fix | Delete
$nodes[] = array(
[2719] Fix | Delete
'path' => array( 'styles', 'blocks', $name, 'elements', $element ),
[2720] Fix | Delete
'selector' => $selectors[ $name ]['elements'][ $element ],
[2721] Fix | Delete
);
[2722] Fix | Delete
[2723] Fix | Delete
// Handle any pseudo selectors for the element.
[2724] Fix | Delete
if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] ) ) {
[2725] Fix | Delete
foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) {
[2726] Fix | Delete
if ( isset( $theme_json['styles']['blocks'][ $name ]['elements'][ $element ][ $pseudo_selector ] ) ) {
[2727] Fix | Delete
$nodes[] = array(
[2728] Fix | Delete
'path' => array( 'styles', 'blocks', $name, 'elements', $element ),
[2729] Fix | Delete
'selector' => static::append_to_selector( $selectors[ $name ]['elements'][ $element ], $pseudo_selector ),
[2730] Fix | Delete
);
[2731] Fix | Delete
}
[2732] Fix | Delete
}
[2733] Fix | Delete
}
[2734] Fix | Delete
}
[2735] Fix | Delete
}
[2736] Fix | Delete
}
[2737] Fix | Delete
[2738] Fix | Delete
return $nodes;
[2739] Fix | Delete
}
[2740] Fix | Delete
[2741] Fix | Delete
/**
[2742] Fix | Delete
* Gets the CSS rules for a particular block from theme.json.
[2743] Fix | Delete
*
[2744] Fix | Delete
* @since 6.1.0
[2745] Fix | Delete
* @since 6.6.0 Setting a min-height of HTML when root styles have a background gradient or image.
[2746] Fix | Delete
* Updated general global styles specificity to 0-1-0.
[2747] Fix | Delete
* Fixed custom CSS output in block style variations.
[2748] Fix | Delete
*
[2749] Fix | Delete
* @param array $block_metadata Metadata about the block to get styles for.
[2750] Fix | Delete
*
[2751] Fix | Delete
* @return string Styles for the block.
[2752] Fix | Delete
*/
[2753] Fix | Delete
public function get_styles_for_block( $block_metadata ) {
[2754] Fix | Delete
$node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() );
[2755] Fix | Delete
$use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments'];
[2756] Fix | Delete
$selector = $block_metadata['selector'];
[2757] Fix | Delete
$settings = isset( $this->theme_json['settings'] ) ? $this->theme_json['settings'] : array();
[2758] Fix | Delete
$feature_declarations = static::get_feature_declarations_for_node( $block_metadata, $node );
[2759] Fix | Delete
$is_root_selector = static::ROOT_BLOCK_SELECTOR === $selector;
[2760] Fix | Delete
[2761] Fix | Delete
// If there are style variations, generate the declarations for them, including any feature selectors the block may have.
[2762] Fix | Delete
$style_variation_declarations = array();
[2763] Fix | Delete
$style_variation_custom_css = array();
[2764] Fix | Delete
if ( ! empty( $block_metadata['variations'] ) ) {
[2765] Fix | Delete
foreach ( $block_metadata['variations'] as $style_variation ) {
[2766] Fix | Delete
$style_variation_node = _wp_array_get( $this->theme_json, $style_variation['path'], array() );
[2767] Fix | Delete
$clean_style_variation_selector = trim( $style_variation['selector'] );
[2768] Fix | Delete
[2769] Fix | Delete
// Generate any feature/subfeature style declarations for the current style variation.
[2770] Fix | Delete
$variation_declarations = static::get_feature_declarations_for_node( $block_metadata, $style_variation_node );
[2771] Fix | Delete
[2772] Fix | Delete
// Combine selectors with style variation's selector and add to overall style variation declarations.
[2773] Fix | Delete
foreach ( $variation_declarations as $current_selector => $new_declarations ) {
[2774] Fix | Delete
// If current selector includes block classname, remove it but leave the whitespace in.
[2775] Fix | Delete
$shortened_selector = str_replace( $block_metadata['selector'] . ' ', ' ', $current_selector );
[2776] Fix | Delete
[2777] Fix | Delete
// Prepend the variation selector to the current selector.
[2778] Fix | Delete
$split_selectors = explode( ',', $shortened_selector );
[2779] Fix | Delete
$updated_selectors = array_map(
[2780] Fix | Delete
static function ( $split_selector ) use ( $clean_style_variation_selector ) {
[2781] Fix | Delete
return $clean_style_variation_selector . $split_selector;
[2782] Fix | Delete
},
[2783] Fix | Delete
$split_selectors
[2784] Fix | Delete
);
[2785] Fix | Delete
$combined_selectors = implode( ',', $updated_selectors );
[2786] Fix | Delete
[2787] Fix | Delete
// Add the new declarations to the overall results under the modified selector.
[2788] Fix | Delete
$style_variation_declarations[ $combined_selectors ] = $new_declarations;
[2789] Fix | Delete
}
[2790] Fix | Delete
[2791] Fix | Delete
// Compute declarations for remaining styles not covered by feature level selectors.
[2792] Fix | Delete
$style_variation_declarations[ $style_variation['selector'] ] = static::compute_style_properties( $style_variation_node, $settings, null, $this->theme_json );
[2793] Fix | Delete
// Store custom CSS for the style variation.
[2794] Fix | Delete
if ( isset( $style_variation_node['css'] ) ) {
[2795] Fix | Delete
$style_variation_custom_css[ $style_variation['selector'] ] = $this->process_blocks_custom_css( $style_variation_node['css'], $style_variation['selector'] );
[2796] Fix | Delete
}
[2797] Fix | Delete
}
[2798] Fix | Delete
}
[2799] Fix | Delete
/*
[2800] Fix | Delete
* Get a reference to element name from path.
[2801] Fix | Delete
* $block_metadata['path'] = array( 'styles','elements','link' );
[2802] Fix | Delete
* Make sure that $block_metadata['path'] describes an element node, like [ 'styles', 'element', 'link' ].
[2803] Fix | Delete
* Skip non-element paths like just ['styles'].
[2804] Fix | Delete
*/
[2805] Fix | Delete
$is_processing_element = in_array( 'elements', $block_metadata['path'], true );
[2806] Fix | Delete
[2807] Fix | Delete
$current_element = $is_processing_element ? $block_metadata['path'][ count( $block_metadata['path'] ) - 1 ] : null;
[2808] Fix | Delete
[2809] Fix | Delete
$element_pseudo_allowed = array();
[2810] Fix | Delete
[2811] Fix | Delete
if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] ) ) {
[2812] Fix | Delete
$element_pseudo_allowed = static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ];
[2813] Fix | Delete
}
[2814] Fix | Delete
[2815] Fix | Delete
/*
[2816] Fix | Delete
* Check for allowed pseudo classes (e.g. ":hover") from the $selector ("a:hover").
[2817] Fix | Delete
* This also resets the array keys.
[2818] Fix | Delete
*/
[2819] Fix | Delete
$pseudo_matches = array_values(
[2820] Fix | Delete
array_filter(
[2821] Fix | Delete
$element_pseudo_allowed,
[2822] Fix | Delete
static function ( $pseudo_selector ) use ( $selector ) {
[2823] Fix | Delete
return str_contains( $selector, $pseudo_selector );
[2824] Fix | Delete
}
[2825] Fix | Delete
)
[2826] Fix | Delete
);
[2827] Fix | Delete
[2828] Fix | Delete
$pseudo_selector = isset( $pseudo_matches[0] ) ? $pseudo_matches[0] : null;
[2829] Fix | Delete
[2830] Fix | Delete
/*
[2831] Fix | Delete
* If the current selector is a pseudo selector that's defined in the allow list for the current
[2832] Fix | Delete
* element then compute the style properties for it.
[2833] Fix | Delete
* Otherwise just compute the styles for the default selector as normal.
[2834] Fix | Delete
*/
[2835] Fix | Delete
if ( $pseudo_selector && isset( $node[ $pseudo_selector ] ) &&
[2836] Fix | Delete
isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] )
[2837] Fix | Delete
&& in_array( $pseudo_selector, static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ], true )
[2838] Fix | Delete
) {
[2839] Fix | Delete
$declarations = static::compute_style_properties( $node[ $pseudo_selector ], $settings, null, $this->theme_json, $selector, $use_root_padding );
[2840] Fix | Delete
} else {
[2841] Fix | Delete
$declarations = static::compute_style_properties( $node, $settings, null, $this->theme_json, $selector, $use_root_padding );
[2842] Fix | Delete
}
[2843] Fix | Delete
[2844] Fix | Delete
$block_rules = '';
[2845] Fix | Delete
[2846] Fix | Delete
/*
[2847] Fix | Delete
* 1. Bespoke declaration modifiers:
[2848] Fix | Delete
* - 'filter': Separate the declarations that use the general selector
[2849] Fix | Delete
* from the ones using the duotone selector.
[2850] Fix | Delete
* - 'background|background-image': set the html min-height to 100%
[2851] Fix | Delete
* to ensure the background covers the entire viewport.
[2852] Fix | Delete
*/
[2853] Fix | Delete
$declarations_duotone = array();
[2854] Fix | Delete
$should_set_root_min_height = false;
[2855] Fix | Delete
[2856] Fix | Delete
foreach ( $declarations as $index => $declaration ) {
[2857] Fix | Delete
if ( 'filter' === $declaration['name'] ) {
[2858] Fix | Delete
/*
[2859] Fix | Delete
* 'unset' filters happen when a filter is unset
[2860] Fix | Delete
* in the site-editor UI. Because the 'unset' value
[2861] Fix | Delete
* in the user origin overrides the value in the
[2862] Fix | Delete
* theme origin, we can skip rendering anything
[2863] Fix | Delete
* here as no filter needs to be applied anymore.
[2864] Fix | Delete
* So only add declarations to with values other
[2865] Fix | Delete
* than 'unset'.
[2866] Fix | Delete
*/
[2867] Fix | Delete
if ( 'unset' !== $declaration['value'] ) {
[2868] Fix | Delete
$declarations_duotone[] = $declaration;
[2869] Fix | Delete
}
[2870] Fix | Delete
unset( $declarations[ $index ] );
[2871] Fix | Delete
}
[2872] Fix | Delete
[2873] Fix | Delete
if ( $is_root_selector && ( 'background-image' === $declaration['name'] || 'background' === $declaration['name'] ) ) {
[2874] Fix | Delete
$should_set_root_min_height = true;
[2875] Fix | Delete
}
[2876] Fix | Delete
}
[2877] Fix | Delete
[2878] Fix | Delete
/*
[2879] Fix | Delete
* If root styles has a background-image or a background (gradient) set,
[2880] Fix | Delete
* set the min-height to '100%'. Minus `--wp-admin--admin-bar--height` for logged-in view.
[2881] Fix | Delete
* Setting the CSS rule on the HTML tag ensures background gradients and images behave similarly,
[2882] Fix | Delete
* and matches the behavior of the site editor.
[2883] Fix | Delete
*/
[2884] Fix | Delete
if ( $should_set_root_min_height ) {
[2885] Fix | Delete
$block_rules .= static::to_ruleset(
[2886] Fix | Delete
'html',
[2887] Fix | Delete
array(
[2888] Fix | Delete
array(
[2889] Fix | Delete
'name' => 'min-height',
[2890] Fix | Delete
'value' => 'calc(100% - var(--wp-admin--admin-bar--height, 0px))',
[2891] Fix | Delete
),
[2892] Fix | Delete
)
[2893] Fix | Delete
);
[2894] Fix | Delete
}
[2895] Fix | Delete
[2896] Fix | Delete
// Update declarations if there are separators with only background color defined.
[2897] Fix | Delete
if ( '.wp-block-separator' === $selector ) {
[2898] Fix | Delete
$declarations = static::update_separator_declarations( $declarations );
[2899] Fix | Delete
}
[2900] Fix | Delete
[2901] Fix | Delete
/*
[2902] Fix | Delete
* Root selector (body) styles should not be wrapped in `:root where()` to keep
[2903] Fix | Delete
* specificity at (0,0,1) and maintain backwards compatibility.
[2904] Fix | Delete
*
[2905] Fix | Delete
* Top-level element styles using element-only specificity selectors should
[2906] Fix | Delete
* not get wrapped in `:root :where()` to maintain backwards compatibility.
[2907] Fix | Delete
*
[2908] Fix | Delete
* Pseudo classes, e.g. :hover, :focus etc., are a class-level selector so
[2909] Fix | Delete
* still need to be wrapped in `:root :where` to cap specificity for nested
[2910] Fix | Delete
* variations etc. Pseudo selectors won't match the ELEMENTS selector exactly.
[2911] Fix | Delete
*/
[2912] Fix | Delete
$element_only_selector = $is_root_selector || (
[2913] Fix | Delete
$current_element &&
[2914] Fix | Delete
isset( static::ELEMENTS[ $current_element ] ) &&
[2915] Fix | Delete
// buttons, captions etc. still need `:root :where()` as they are class based selectors.
[2916] Fix | Delete
! isset( static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES[ $current_element ] ) &&
[2917] Fix | Delete
static::ELEMENTS[ $current_element ] === $selector
[2918] Fix | Delete
);
[2919] Fix | Delete
[2920] Fix | Delete
// 2. Generate and append the rules that use the general selector.
[2921] Fix | Delete
$general_selector = $element_only_selector ? $selector : ":root :where($selector)";
[2922] Fix | Delete
$block_rules .= static::to_ruleset( $general_selector, $declarations );
[2923] Fix | Delete
[2924] Fix | Delete
// 3. Generate and append the rules that use the duotone selector.
[2925] Fix | Delete
if ( isset( $block_metadata['duotone'] ) && ! empty( $declarations_duotone ) ) {
[2926] Fix | Delete
$block_rules .= static::to_ruleset( $block_metadata['duotone'], $declarations_duotone );
[2927] Fix | Delete
}
[2928] Fix | Delete
[2929] Fix | Delete
// 4. Generate Layout block gap styles.
[2930] Fix | Delete
if (
[2931] Fix | Delete
! $is_root_selector &&
[2932] Fix | Delete
! empty( $block_metadata['name'] )
[2933] Fix | Delete
) {
[2934] Fix | Delete
$block_rules .= $this->get_layout_styles( $block_metadata );
[2935] Fix | Delete
}
[2936] Fix | Delete
[2937] Fix | Delete
// 5. Generate and append the feature level rulesets.
[2938] Fix | Delete
foreach ( $feature_declarations as $feature_selector => $individual_feature_declarations ) {
[2939] Fix | Delete
$block_rules .= static::to_ruleset( ":root :where($feature_selector)", $individual_feature_declarations );
[2940] Fix | Delete
}
[2941] Fix | Delete
[2942] Fix | Delete
// 6. Generate and append the style variation rulesets.
[2943] Fix | Delete
foreach ( $style_variation_declarations as $style_variation_selector => $individual_style_variation_declarations ) {
[2944] Fix | Delete
$block_rules .= static::to_ruleset( ":root :where($style_variation_selector)", $individual_style_variation_declarations );
[2945] Fix | Delete
if ( isset( $style_variation_custom_css[ $style_variation_selector ] ) ) {
[2946] Fix | Delete
$block_rules .= $style_variation_custom_css[ $style_variation_selector ];
[2947] Fix | Delete
}
[2948] Fix | Delete
}
[2949] Fix | Delete
[2950] Fix | Delete
// 7. Generate and append any custom CSS rules pertaining to nested block style variations.
[2951] Fix | Delete
if ( isset( $node['css'] ) && ! $is_root_selector ) {
[2952] Fix | Delete
$block_rules .= $this->process_blocks_custom_css( $node['css'], $selector );
[2953] Fix | Delete
}
[2954] Fix | Delete
[2955] Fix | Delete
return $block_rules;
[2956] Fix | Delete
}
[2957] Fix | Delete
[2958] Fix | Delete
/**
[2959] Fix | Delete
* Outputs the CSS for layout rules on the root.
[2960] Fix | Delete
*
[2961] Fix | Delete
* @since 6.1.0
[2962] Fix | Delete
* @since 6.6.0 Use `ROOT_CSS_PROPERTIES_SELECTOR` for CSS custom properties and improved consistency of root padding rules.
[2963] Fix | Delete
* Updated specificity of body margin reset and first/last child selectors.
[2964] Fix | Delete
*
[2965] Fix | Delete
* @param string $selector The root node selector.
[2966] Fix | Delete
* @param array $block_metadata The metadata for the root block.
[2967] Fix | Delete
* @return string The additional root rules CSS.
[2968] Fix | Delete
*/
[2969] Fix | Delete
public function get_root_layout_rules( $selector, $block_metadata ) {
[2970] Fix | Delete
$css = '';
[2971] Fix | Delete
$settings = isset( $this->theme_json['settings'] ) ? $this->theme_json['settings'] : array();
[2972] Fix | Delete
$use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments'];
[2973] Fix | Delete
[2974] Fix | Delete
/*
[2975] Fix | Delete
* If there are content and wide widths in theme.json, output them
[2976] Fix | Delete
* as custom properties on the body element so all blocks can use them.
[2977] Fix | Delete
*/
[2978] Fix | Delete
if ( isset( $settings['layout']['contentSize'] ) || isset( $settings['layout']['wideSize'] ) ) {
[2979] Fix | Delete
$content_size = isset( $settings['layout']['contentSize'] ) ? $settings['layout']['contentSize'] : $settings['layout']['wideSize'];
[2980] Fix | Delete
$content_size = static::is_safe_css_declaration( 'max-width', $content_size ) ? $content_size : 'initial';
[2981] Fix | Delete
$wide_size = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize'];
[2982] Fix | Delete
$wide_size = static::is_safe_css_declaration( 'max-width', $wide_size ) ? $wide_size : 'initial';
[2983] Fix | Delete
$css .= static::ROOT_CSS_PROPERTIES_SELECTOR . ' { --wp--style--global--content-size: ' . $content_size . ';';
[2984] Fix | Delete
$css .= '--wp--style--global--wide-size: ' . $wide_size . '; }';
[2985] Fix | Delete
}
[2986] Fix | Delete
[2987] Fix | Delete
/*
[2988] Fix | Delete
* Reset default browser margin on the body element.
[2989] Fix | Delete
* This is set on the body selector **before** generating the ruleset
[2990] Fix | Delete
* from the `theme.json`. This is to ensure that if the `theme.json` declares
[2991] Fix | Delete
* `margin` in its `spacing` declaration for the `body` element then these
[2992] Fix | Delete
* user-generated values take precedence in the CSS cascade.
[2993] Fix | Delete
* @link https://github.com/WordPress/gutenberg/issues/36147.
[2994] Fix | Delete
*/
[2995] Fix | Delete
$css .= ':where(body) { margin: 0; }';
[2996] Fix | Delete
[2997] Fix | Delete
if ( $use_root_padding ) {
[2998] Fix | Delete
// Top and bottom padding are applied to the outer block container.
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function