[ Index ]

PHP Cross Reference of WordPress




/wp-includes/rest-api/fields/ -> class-wp-rest-meta-fields.php (summary)

REST API: WP_REST_Meta_Fields class

File Size: 612 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 15 functions


Functions that are not part of a class:

get_meta_subtype()   X-Ref
Retrieves the object meta subtype.

return: string Subtype for the meta type, or empty string if no specific subtype.
since: 4.9.8

register_field()   X-Ref
Registers the meta field.

since: 4.7.0

get_value( $object_id, $request )   X-Ref
Retrieves the meta field value.

param: int             $object_id Object ID to fetch meta for.
param: WP_REST_Request $request   Full details about the request.
return: array Array containing the meta values keyed by name.
since: 4.7.0

prepare_value_for_response( $value, $request, $args )   X-Ref
Prepares a meta value for a response.

This is required because some native types cannot be stored correctly
in the database, such as booleans. We need to cast back to the relevant
type before passing back to JSON.

param: mixed           $value   Meta value to prepare.
param: WP_REST_Request $request Current request object.
param: array           $args    Options for the field.
return: mixed Prepared value.
since: 4.7.0

update_value( $meta, $object_id )   X-Ref
Updates meta values.

param: array $meta      Array of meta parsed from the request.
param: int   $object_id Object ID to fetch meta for.
return: null|WP_Error Null on success, WP_Error object on failure.
since: 4.7.0

delete_meta_value( $object_id, $meta_key, $name )   X-Ref
Deletes a meta value for an object.

param: int    $object_id Object ID the field belongs to.
param: string $meta_key  Key for the field.
param: string $name      Name for the field that is exposed in the REST API.
return: true|WP_Error True if meta field is deleted, WP_Error otherwise.
since: 4.7.0

update_multi_meta_value( $object_id, $meta_key, $name, $values )   X-Ref
Updates multiple meta values for an object.

Alters the list of values in the database to match the list of provided values.

param: int    $object_id Object ID to update.
param: string $meta_key  Key for the custom field.
param: string $name      Name for the field that is exposed in the REST API.
param: array  $values    List of values to update to.
return: true|WP_Error True if meta fields are updated, WP_Error otherwise.
since: 4.7.0

update_meta_value( $object_id, $meta_key, $name, $value )   X-Ref
No description

is_meta_value_same_as_stored_value( $meta_key, $subtype, $stored_value, $user_value )   X-Ref
Checks if the user provided value is equivalent to a stored value for the given meta key.

param: string $meta_key     The meta key being checked.
param: string $subtype      The object subtype.
param: mixed  $stored_value The currently stored value retrieved from get_metadata().
param: mixed  $user_value   The value provided by the user.
return: bool
since: 5.5.0

get_registered_fields()   X-Ref
Retrieves all the registered meta fields.

return: array Registered fields.
since: 4.7.0

get_field_schema()   X-Ref
Retrieves the object's meta schema, conforming to JSON Schema.

return: array Field schema data.
since: 4.7.0

prepare_value( $value, $request, $args )   X-Ref
Prepares 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. If a non-JsonSerializable object, null.
since: 4.7.0

check_meta_is_array( $value, $request, $param )   X-Ref
Check the 'meta' value of a request is an associative array.

param: mixed           $value   The meta value submitted in the request.
param: WP_REST_Request $request Full details about the request.
param: string          $param   The parameter name.
return: array|false The meta array, if valid, false otherwise.
since: 4.7.0

default_additional_properties_to_false( $schema )   X-Ref
Recursively add additionalProperties = false to all objects in a schema if no additionalProperties setting
is specified.

This is needed to restrict properties of objects in meta values to only
registered items, as the REST API will allow additional properties by

param: array $schema The schema array.
return: array
since: 5.3.0

get_empty_value_for_type( $type )   X-Ref
Gets the empty value for a schema type.

param: string $type The schema type.
return: mixed
since: 5.3.0

Generated: Wed Jan 27 01:00:08 2021 Cross-referenced by PHPXref 0.7.1