public static function prepare_value( $value, $request, $args ) {
		$type = $args['schema']['type'];

		// For multi-value fields, check the item type instead.
		if ( 'array' === $type && ! empty( $args['schema']['items']['type'] ) ) {
			$type = $args['schema']['items']['type'];
		}

		switch ( $type ) {
			case 'string':
				$value = (string) $value;
				break;
			case 'number':
				$value = (float) $value;
				break;
			case 'boolean':
				$value = (bool) $value;
				break;
		}

		// Don't allow objects to be output.
		if ( is_object( $value ) && ! ( $value instanceof JsonSerializable ) ) {
			return null;
		}

		return $value;
	}
public static function prepare_value( $value, $request, $args ) {
		$type = $args['schema']['type'];

		// For multi-value fields, check the item type instead.
		if ( 'array' === $type && ! empty( $args['schema']['items']['type'] ) ) {
			$type = $args['schema']['items']['type'];
		}

		switch ( $type ) {
			case 'string':
				$value = (string) $value;
				break;
			case 'number':
				$value = (float) $value;
				break;
			case 'boolean':
				$value = (bool) $value;
				break;
		}

		// Don't allow objects to be output.
		if ( is_object( $value ) && ! ( $value instanceof JsonSerializable ) ) {
			return null;
		}

		return $value;
	}
public static function prepare_value ( $ value , $ request , $ args ) { $ type = $ args [ 'schema' ] [ 'type' ] ; // For multi-value fields, check the item type instead. if ( 'array' === $ type && ! empty ( $ args [ 'schema' ] [ 'items' ] [ 'type' ] ) ) { $ type = $ args [ 'schema' ] [ 'items' ] [ 'type' ] ; } switch ( $ type ) { case 'string' : $ value = ( string ) $ value ; break ; case 'number' : $ value = ( float ) $ value ; break ; case 'boolean' : $ value = ( bool ) $ value ; break ; } // Don't allow objects to be output. if ( is_object ( $ value ) && ! ( $ value instanceof JsonSerializable ) ) { return null ; } return $ value ; }
Prepare a meta value for output.

Default preparation for meta fields. Override by passing the
`prepare_callback` in your `show_in_rest` options.

@param mixed           $value   Meta value from the database.
@param WP_REST_Request $request Request object.
@param array           $args    REST-specific options for the meta key.
@return mixed Value prepared for output.
Prepare a meta value for output .