rest_find_matching_pattern_property_schema

函数


rest_find_matching_pattern_property_schema ( $property, $args )
参数
  • (string)
    $property
    The property name to check.
    Required:
  • (array)
    $args
    The schema array to use.
    Required:
返回值
  • (array|null) The schema of matching pattern property, or null if no patterns match.
定义位置
  • wp-includes/rest-api.php
    , line 1735
引入
5.6.0
弃用

Finds the schema for a property using the patternProperties keyword.

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