WP_Theme_JSON::remove_keys_not_in_schema( array $tree, array $schema ): array

In this article

Given a tree, removes the keys that are not present in the schema.

Description

It is recursive and modifies the input in-place.

Parameters

$treearrayrequired
Input to process.
$schemaarrayrequired
Schema to adhere to.

Return

array The modified $tree.

Source

	if ( array_key_exists( $section, $styles_non_top_level ) && is_array( $styles_non_top_level[ $section ] ) ) {
		foreach ( array_keys( $styles_non_top_level[ $section ] ) as $prop ) {
			if ( 'top' === $styles_non_top_level[ $section ][ $prop ] ) {
				unset( $styles_non_top_level[ $section ][ $prop ] );
			}
		}
	}
}

// Build the schema based on valid block & element names.
$schema                 = array();
$schema_styles_elements = array();

/*
 * Set allowed element pseudo selectors based on per element allow list.
 * Target data structure in schema:
 * e.g.
 * - top level elements: `$schema['styles']['elements']['link'][':hover']`.
 * - block level elements: `$schema['styles']['blocks']['core/button']['elements']['link'][':hover']`.
 */
foreach ( $valid_element_names as $element ) {

Changelog

VersionDescription
5.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.