WP_Theme_JSON::filter_slugs()protected staticWP 5.9.0

Removes the preset values whose slug is equal to any of given slugs.

Method of the class: WP_Theme_JSON{}

No Hooks.

Return

Array. The new node.

Usage

$result = WP_Theme_JSON::filter_slugs( $node, $slugs );
$node(array) (required)
The node with the presets to validate.
$slugs(array) (required)
The slugs that should not be overridden.

Changelog

Since 5.9.0 Introduced.

WP_Theme_JSON::filter_slugs() code WP 6.6.2

protected static function filter_slugs( $node, $slugs ) {
	if ( empty( $slugs ) ) {
		return $node;
	}

	$new_node = array();
	foreach ( $node as $value ) {
		if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) {
			$new_node[] = $value;
		}
	}

	return $new_node;
}