rest_handle_multi_type_schema
函数
rest_handle_multi_type_schema ( $value, $args, $param = '' )
- 参数
-
-
(mixed)
$value
The value to check.- Required: 是
-
(array)
$args
The schema array to use.- Required: 是
-
(string)
$param
The parameter name, used in error messages.- Required: 否
- Default: (empty)
-
(mixed)
- 返回值
-
- (string)
- 定义位置
-
-
wp-includes/rest-api.php
, line 1627
-
wp-includes/rest-api.php
- 引入
- 5.5.0
- 弃用
- –
Handles getting the best type for a multi-type schema.
This is a wrapper for {@see} that handles
backward compatibility for schemas that use invalid types.
function rest_handle_multi_type_schema( $value, $args, $param = '' ) { $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' ); $invalid_types = array_diff( $args['type'], $allowed_types ); if ( $invalid_types ) { _doing_it_wrong( __FUNCTION__, /* translators: 1: Parameter, 2: List of allowed types. */ wp_sprintf( __( 'The "type" schema keyword for %1$s can only contain the built-in types: %2$l.' ), $param, $allowed_types ), '5.5.0' ); } $best_type = rest_get_best_type_for_value( $value, $args['type'] ); if ( ! $best_type ) { if ( ! $invalid_types ) { return ''; } // Backward compatibility for previous behavior which allowed the value if there was an invalid type used. $best_type = reset( $invalid_types ); } return $best_type; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。