BP_REST_Group_Settings_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-groups/classes/class-bp-rest-group-settings-endpoint.php
public function prepare_item_for_response( $field, $request ) { $data = array( 'label' => ( isset( $field['label'] ) && ! empty( $field['label'] ) ? $field['label'] : '' ), 'name' => ( isset( $field['name'] ) && ! empty( $field['name'] ) ? $field['name'] : '' ), 'description' => ( isset( $field['description'] ) && ! empty( $field['description'] ) ? $field['description'] : '' ), '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() ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); /** * Filter a group settings 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_group_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.