[ 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: 587 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_default_for_type()

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.

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

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.

return: mixed Prepared value.
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.

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

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

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

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

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.

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

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

return: bool|WP_Error True if the meta field was updated, WP_Error otherwise.
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.

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.

return: mixed Value prepared for output. If a non-JsonSerializable object, null.
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.

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

return: WP_Error|string The meta array, if valid, otherwise an error.
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.

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.

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

get_default_for_type( $type )   X-Ref
Gets the default value for a schema type.

return: mixed
since: 5.3.0
param: string $type



Generated: Mon Sep 16 01:00:03 2019 Cross-referenced by PHPXref 0.7.1