WP_REST_Meta_Fields::get_field_schema() WordPress Method
The WP_REST_Meta_Fields::get_field_schema() method is used to retrieve the schema for a given meta field. This can be used to validate a meta value before it is saved or updated.
WP_REST_Meta_Fields::get_field_schema() #
Retrieves the object’s meta schema, conforming to JSON Schema.
Return
(array) Field schema data.
Source
File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
public function get_field_schema() { $fields = $this->get_registered_fields(); $schema = array( 'description' => __( 'Meta fields.' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), 'properties' => array(), 'arg_options' => array( 'sanitize_callback' => null, 'validate_callback' => array( $this, 'check_meta_is_array' ), ), ); foreach ( $fields as $args ) { $schema['properties'][ $args['name'] ] = $args['schema']; } return $schema; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |