wp_get_block_state_style_rules() │ WP 7.1.0

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

Хуков нет.

Возвращает

array[]. State style rules.

Использование

wp_get_block_state_style_rules( $state_styles, $block_type, $rules_group );
$state_styles(массив) (обязательный)
Map of state to style array.
$block_type(WP_Block_Type) (обязательный)
Block type.
$rules_group(строка|null)
Optional CSS grouping rule, e.g. a media query.
По умолчанию: null

Список изменений

С версии 7.1.0 Введена.

Код wp_get_block_state_style_rules() WP 7.1.2

function wp_get_block_state_style_rules( $state_styles, $block_type, $rules_group = null ) {
	$css_rules       = array();
	$block_selectors = isset( $block_type->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
			);
		}
	}

	return $css_rules;
}