WP_REST_Meta_Fields::get_empty_value_for_type( string $type )

Gets the empty value for a schema type.


Description Description


Parameters Parameters

$type

(string) (Required) The schema type.


Top ↑

Return Return

(mixed)


Top ↑

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

Top ↑

Changelog Changelog

Changelog
Version Description
5.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.