BP_REST_Account_Settings_Options_Endpoint::prepare_item_for_response( object $field, WP_REST_Request $request )
Prepares account settings data for return as an object.
Description
Parameters
- $field
-
(Required) Field object.
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response)
Source
File: bp-settings/classes/class-bp-rest-account-settings-options-endpoint.php
public function prepare_item_for_response( $field, $request ) { $data = array( 'name' => ( isset( $field['name'] ) && ! empty( $field['name'] ) ? $field['name'] : '' ), 'label' => ( isset( $field['label'] ) && ! empty( $field['label'] ) ? $field['label'] : '' ), 'type' => ( isset( $field['field'] ) && ! empty( $field['field'] ) ? $field['field'] : '' ), 'value' => ( isset( $field['value'] ) && ! empty( $field['value'] ) ? $field['value'] : '' ), 'options' => ( isset( $field['options'] ) && ! empty( $field['options'] ) ? $field['options'] : array() ), 'headline' => ( isset( $field['group_label'] ) && ! empty( $field['group_label'] ) ? $field['group_label'] : '' ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); // @todo add prepare_links $response = rest_ensure_response( $data ); /** * Filter a notification value returned from the API. * * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request Request used to generate the response. * @param object $field Field object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_account_setting_prepare_value', $response, $request, $field ); }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.