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.
定义位置
相关方法
rest_find_any_matching_schemarest_find_one_matching_schemarest_validate_string_value_from_schemarest_handle_multi_type_schemarest_get_endpoint_args_for_schema
引入
5.6.0
弃用
-

rest_find_matching_pattern_property_schema: 该函数用于查找与模式属性相匹配的模式。它接收一个数据对象、属性名称和一个模式对象的数组,并返回与模式属性相匹配的第一个模式对象。

使用patternProperties关键字查找一个属性的模式。

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

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-29 17:09:52

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: