BP_REST_Activity_Endpoint:: get_item (WP_REST_Request美元的请求)
检索活动。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)请求的全部细节。
返回
(WP_REST_Response)| WP_Error
源
文件:bp-activity /类/ class-bp-rest-activity-endpoint.php
公共函数get_item(请求){$ args =阵列(“排除”= > $请求“排除”,“在”= > $请求“包括”,“页面”= > $请求(“页”),“per_page”= > $请求(“per_page”),“search_term”= > $请求“搜索”,“排序”= > $请求(“订单”),“垃圾邮件”= > $请求“状态”,“display_comments”= > $请求(“display_comments”),“site_id”= > $请求(“site_id”),“group_id”= > $请求(“group_id”),“范围”= > $请求(“范围”),“隐私”= > (!空($request['privacy']) ?(is_array($request['privacy'])) ?$request['privacy']: (array) $request['privacy']): "), 'count_total' => true, 'fields' => 'all', 'show_hidden' => false, 'update_meta_cache' => true, 'filter' => false,);If (empty($args['display_comments']) || 'false' === $args['display_comments']) {$args['display_comments'] = false;} if(空($request['exclude'])) {$args['exclude'] = false;} if(空($request['include'])) {$args['in'] = false;}如果(收取($请求['之后 '] ) ) { $ args(“因为”)= $请求(“后”);}如果(收取($请求[' user_id '] ) ) { $ args(“过滤器”)(“user_id”)= $请求(“user_id”); } $item_id = 0; if ( ! empty( $args['group_id'] ) ) { $args['filter']['object'] = 'groups'; $args['filter']['primary_id'] = $args['group_id']; $item_id = $args['group_id']; } if ( ! empty( $args['site_id'] ) ) { $args['filter']['object'] = 'blogs'; $args['filter']['primary_id'] = $args['site_id']; $item_id = $args['site_id']; } if ( empty( $args['group_id'] ) && empty( $args['site_id'] ) ) { if ( isset( $request['component'] ) ) { $args['filter']['object'] = $request['component']; } if ( ! empty( $request['primary_id'] ) ) { $item_id = $request['primary_id']; $args['filter']['primary_id'] = $item_id; } } if ( empty( $request['scope'] ) ) { $args['scope'] = false; } if ( isset( $request['type'] ) ) { $args['filter']['action'] = $request['type']; } if ( ! empty( $request['secondary_id'] ) ) { $args['filter']['secondary_id'] = $request['secondary_id']; } if ( $args['in'] ) { $args['count_total'] = false; } if ( $this->show_hidden( $request['component'], $item_id ) ) { $args['show_hidden'] = true; } $args['scope'] = $this->bp_rest_activity_default_scope( $args['scope'], ( $request['user_id'] ? $request['user_id'] : 0 ), $args['group_id'] ); if ( empty( $args['scope'] ) ) { $args['privacy'] = 'public'; } /** * Filter the query arguments for the request. * * @param array $args Key value array of query var to query value. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ $args = apply_filters( 'bp_rest_activity_get_items_query_args', $args, $request ); // Actually, query it. $activities = bp_activity_get( $args ); $retval = array(); foreach ( $activities['activities'] as $activity ) { $retval[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $activity, $request ) ); } $response = rest_ensure_response( $retval ); $response = bp_rest_response_add_total_headers( $response, $activities['total'], $args['per_page'] ); /** * Fires after a list of activities is fetched via the REST API. * * @param array $activities Fetched activities. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_activity_get_items', $activities, $response, $request ); return $response; }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |