BP_REST_Blogs_Endpoint::prepare_item_for_response( stdClass $blog, WP_REST_Request $request )
Prepares blogs data for return as an object.
Parameters Parameters
- $blog
-
(stdClass) (Required) Blog object.
- $request
-
(WP_REST_Request) (Required) Full details about the request.
Return Return
(WP_REST_Response)
Source Source
File: bp-blogs/classes/class-bp-rest-blogs-endpoint.php
public function prepare_item_for_response( $blog, $request ) { $data = array( 'id' => $blog->blog_id, 'user_id' => $blog->admin_user_id, 'name' => $blog->name, 'domain' => $blog->domain, 'path' => $blog->path, 'permalink' => $this->get_blog_domain( $blog ), 'description' => stripslashes( $blog->description ), 'last_activity' => bp_rest_prepare_date_response( $blog->last_activity ), ); // Blog Avatars. if ( true === buddypress()->avatar->show_avatars ) { $data['avatar_urls'] = array( 'thumb' => bp_get_blog_avatar( array( 'type' => 'thumb', 'blog_id' => $blog->blog_id, 'admin_user_id' => $blog->admin_user_id, 'html' => false, ) ), 'full' => bp_get_blog_avatar( array( 'type' => 'full', 'blog_id' => $blog->blog_id, 'admin_user_id' => $blog->admin_user_id, 'html' => false, ) ), ); } $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 ); $response->add_links( $this->prepare_links( $blog ) ); /** * Filter a blog returned from the API. * * @since 6.0.0 * * @param WP_REST_Response $response Response generated by the request. * @param WP_REST_Request $request Request used to generate the response. * @param stdClass $blog The blog object. */ return apply_filters( 'bp_rest_blogs_prepare_value', $response, $request, $blog ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Introduced. |