rest_find_matching_pattern_property_schema() WordPress Function

This function is used to find a matching property schema for a given post ID. It first tries to find a property schema that matches the post ID. If it doesn't find one, it tries to find a property schema that matches the post's parent ID. If a property schema is found, it is returned. Otherwise, an empty array is returned.

rest_find_matching_pattern_property_schema( string $property, array $args ) #

Finds the schema for a property using the patternProperties keyword.


Parameters

$property

(string)(Required)The property name to check.

$args

(array)(Required)The schema array to use.


Top ↑

Return

(array|null) The schema of matching pattern property, or null if no patterns match.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_find_matching_pattern_property_schema( $property, $args ) {
	if ( isset( $args['patternProperties'] ) ) {
		foreach ( $args['patternProperties'] as $pattern => $child_schema ) {
			if ( rest_validate_json_schema_pattern( $pattern, $property ) ) {
				return $child_schema;
			}
		}
	}

	return null;
}


Top ↑

Changelog

Changelog
VersionDescription
5.6.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.

Show More