WP_Theme_JSON::filter_slugs() WordPress Method

The WP_Theme_JSON::filter_slugs() method is used to filter theme slugs from a list of provided slugs. This is useful for ensuring that only valid theme slugs are returned from a list of slugs.

WP_Theme_JSON::filter_slugs( array $node, array $slugs ) #

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


Parameters

$node

(array)(Required)The node with the presets to validate.

$slugs

(array)(Required)The slugs that should not be overridden.


Top ↑

Return

(array) The new node.


Top ↑

Source

File: wp-includes/class-wp-theme-json.php

	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;
	}

Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.