WP_REST_Meta_Fields::get_empty_value_for_type()protected staticWP 5.3.0

Gets the empty value for a schema type.

Method of the class: WP_REST_Meta_Fields{}

No Hooks.

Return

Mixed.

Usage

$result = WP_REST_Meta_Fields::get_empty_value_for_type( $type );
$type(string) (required)
The schema type.

Changelog

Since 5.3.0 Introduced.

WP_REST_Meta_Fields::get_empty_value_for_type() code WP 6.5.2

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