wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
rest_get_best_type_for_value › WordPress Function
Depuis5.5.0
Dépréciéen/a
› rest_get_best_type_for_value ( $value, $types )
Paramètres: (2) |
|
Retourne: |
|
Défini(e) dans: |
|
Codex: |
Gets the best type for a value.
Fonctions en relation: rest_get_route_for_term, rest_get_server, rest_get_route_for_post, rest_get_route_for_post_type_items, get_post_custom_values
Source
function rest_get_best_type_for_value( $value, $types ) { static $checks = array( 'array' => 'rest_is_array', 'object' => 'rest_is_object', 'integer' => 'rest_is_integer', 'number' => 'is_numeric', 'boolean' => 'rest_is_boolean', 'string' => 'is_string', 'null' => 'is_null', ); /* * Both arrays and objects allow empty strings to be converted to their types. * But the best answer for this type is a string. */ if ( '' === $value && in_array( 'string', $types, true ) ) { return 'string'; } foreach ( $types as $type ) { if ( isset( $checks[ $type ] ) && $checks[ $type ]( $value ) ) { return $type; } } return ''; }