wp_get_root_state_style()WP 7.1.0

Returns a style object with nested state keys removed.

No Hooks.

Returns

array. Root-only style object.

Usage

wp_get_root_state_style( $state_style, $nested_keys );
$state_style(array) (required)
State style object.
$nested_keys(array) (required)
Keys to remove from the root style object.

Changelog

Since 7.1.0 Introduced.

wp_get_root_state_style() code WP 7.1

function wp_get_root_state_style( $state_style, $nested_keys ) {
	if ( ! is_array( $state_style ) ) {
		return $state_style;
	}

	$root_style = $state_style;
	foreach ( $nested_keys as $key ) {
		unset( $root_style[ $key ] );
	}

	return $root_style;
}