wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_get_block_state_style_rules › WordPress Function

Da7.1.0
Deprecaton/a
› wp_get_block_state_style_rules ( $state_styles, $block_type, $rules_group = null, $base_style = null )
Parametri: (4)
  • (array<string,mixed>) $state_styles Map of state to style array.
    Richiesto: Sì
  • (WP_Block_Type) $block_type Block type.
    Richiesto: Sì
  • (string|null) $rules_group Optional CSS grouping rule, e.g. a media query.
    Richiesto: No
    Default: null
  • (array<string,mixed>|null) $base_style Optional styles the state layers over.
    Richiesto: No
    Default: null
Ritorna:
  • (array[]) State style rules.
Definito a:
Codex:
ChangeLog:
  • 7.2.0

Builds compiled state style rules, preserving the selector each rule targets.



Sorgenti

function wp_get_block_state_style_rules( $state_styles, $block_type, $rules_group = null, $base_style = null ) {
	// Only a block that supports the clip can sit under a text clip to escape.
	if ( ! block_has_support( $block_type, array( 'background', 'backgroundClip' ), false ) ) {
		$base_style = null;
	}

	$css_rules       = array();
	$block_selectors = is_array( $block_type->selectors )
		? $block_type->selectors
		: array();

	foreach ( $state_styles as $state => $state_style ) {
		if ( empty( $state_style ) || ! is_array( $state_style ) ) {
			continue;
		}

		foreach ( wp_get_state_style_groups( $state_style, $block_selectors ) as $group ) {
			wp_add_block_state_style_rule(
				$css_rules,
				$state,
				$group['selector'],
				$group['style'],
				$rules_group,
				$base_style
			);
		}
	}

	return $css_rules;
}