[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

REST API: WP_REST_Meta_Fields class

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

Defines 14 functions

  get_meta_subtype()
  register_field()
  get_value()
  prepare_value_for_response()
  update_value()
  delete_meta_value()
  update_multi_meta_value()
  update_meta_value()
  get_registered_fields()
  get_field_schema()
  prepare_value()
  check_meta_is_array()
  default_additional_properties_to_false()
  get_empty_value_for_type()

Functions
Functions that are not part of a class:

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

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

register_field()   X-Ref
Registers the meta field.

since: 4.7.0

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

since: 4.7.0
param: int             $object_id Object ID to fetch meta for.
param: WP_REST_Request $request   Full details about the request.
return: object|WP_Error Object containing the meta values by name, otherwise WP_Error object.

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.

since: 4.7.0
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.

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

since: 4.7.0
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.

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

since: 4.7.0
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: bool|WP_Error True if meta field is deleted, WP_Error otherwise.

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.

since: 4.7.0
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: bool|WP_Error True if meta fields are updated, WP_Error otherwise.

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

since: 4.7.0
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: mixed  $value     Updated value.
return: bool|WP_Error True if the meta field was updated, WP_Error otherwise.

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

since: 4.7.0
return: array Registered fields.

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

since: 4.7.0
return: array Field schema data.

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.

since: 4.7.0
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.

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

since: 4.7.0
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.

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
default.

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

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

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



Generated: Mon Nov 18 01:00:04 2019 Cross-referenced by PHPXref 0.7.1