Summery Summery
Adds the values from additional fields to a data object.
Syntax Syntax
Parameters Parameters
- $prepared
-
(Required) Prepared response array.
- $request
-
(Required) Full details about the request.
Return Return
(array) Modified data object with additional fields.
Source Source
File: wp-includes/rest-api/endpoints/class-wp-rest-controller.php
* * @param object $object Data model like WP_Term or WP_Post. * @param WP_REST_Request $request Full details about the request. * @return bool|WP_Error True on success, WP_Error object if a field cannot be updated. */ protected function update_additional_fields_for_object( $object, $request ) { $additional_fields = $this->get_additional_fields(); foreach ( $additional_fields as $field_name => $field_options ) { if ( ! $field_options['update_callback'] ) { continue; } // Don't run the update callbacks if the data wasn't passed in the request. if ( ! isset( $request[ $field_name ] ) ) { continue; } $result = call_user_func( $field_options['update_callback'], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() );
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |