Given a tree, removes the keys that are not present in the schema.
Description
It is recursive and modifies the input in-place.
Parameters
$tree
arrayrequired- Input to process.
$schema
arrayrequired- Schema to adhere to.
Source
$styles_non_top_level = static::VALID_STYLES;
foreach ( array_keys( $styles_non_top_level ) as $section ) {
// array_key_exists() needs to be used instead of isset() because the value can be null.
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']`.
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.