WP_REST_Meta_Fields::get_empty_value_for_type( string $type )
Gets the empty value for a schema type.
Parameters
- $type
-
(string) (Required) The schema type.
Return
(mixed)
Source
File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
protected static function get_empty_value_for_type( $type ) {
switch ( $type ) {
case 'string':
return '';
case 'boolean':
return false;
case 'integer':
return 0;
case 'number':
return 0.0;
case 'array':
case 'object':
return array();
default:
return null;
}
} Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_meta_fields/get_empty_value_for_type