Changeset 35687
- Timestamp:
- 11/18/2015 08:38:25 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/rest-functions.php
r35651 r35687 65 65 66 66 /** 67 * Registers a new field on an existing WordPress object type.68 *69 * @since 4.4.070 *71 * @global array $wp_rest_additional_fields Holds registered fields, organized72 * by object type.73 *74 * @param string|array $object_type Object(s) the field is being registered75 * to, "post"|"term"|"comment" etc.76 * @param string $attribute The attribute name.77 * @param array $args {78 * Optional. An array of arguments used to handle the registered field.79 *80 * @type string|array|null $get_callback Optional. The callback function used to retrieve the field81 * value. Default is 'null', the field will not be returned in82 * the response.83 * @type string|array|null $update_callback Optional. The callback function used to set and update the84 * field value. Default is 'null', the value cannot be set or85 * updated.86 * @type string|array|null $schema Optional. The callback function used to create the schema for87 * this field. Default is 'null', no schema entry will be returned.88 * }89 */90 function register_api_field( $object_type, $attribute, $args = array() ) {91 $defaults = array(92 'get_callback' => null,93 'update_callback' => null,94 'schema' => null,95 );96 97 $args = wp_parse_args( $args, $defaults );98 99 global $wp_rest_additional_fields;100 101 $object_types = (array) $object_type;102 103 foreach ( $object_types as $object_type ) {104 $wp_rest_additional_fields[ $object_type ][ $attribute ] = $args;105 }106 }107 108 /**109 67 * Registers rewrite rules for the API. 110 68 *
Note: See TracChangeset
for help on using the changeset viewer.