BP_REST_Messages_Endpoint:: prepare_recipient_for_response (对象接受美元,WP_REST_Request美元的请求)
为REST响应准备接收方数据。
描述
参数
- 接受美元
-
(对象)(必需)收件人对象。
- 美元的请求
-
(WP_REST_Request)(必需)请求的全部细节。
返回
(数组)REST响应的接收方数据。
源
文件:bp-messages /类/ class-bp-rest-messages-endpoint.php
Public function prepare_recipient_for_response($ receiver, $request) {$data = array('id' => (int) $ receiver ->id, 'user_id' => (int) $ receiver ->user_id, 'user_link' => esc_url(bp_core_get_user_domain($ receiver ->user_id)), 'name' => bp_core_get_user_displayname($ receiver ->user_id),);//获取用户头像url (Full & thumb)。If (true === buddypress()->avatar->show_avatars) {foreach (array('full', 'thumb') as $type) {$data['user_avatars'][$type] = bp_core_fetch_avatar(array('item_id' => $ receive ->user_id, 'html' => false, 'type' => $type,));}} $data_query = array('thread_id' => (int) $ receiver ->thread_id, 'unread_count' => (int) $ receiver ->unread_count, 'sender_only' => (int) $ receiver ->sender_only, 'is_deleted' => (int) $ receiver ->is_deleted,);If (isset($ receiver ->is_hidden)) {$data_query['is_hidden'] = (int) (isset($ receiver ->is_hidden)) ?$接收者->is_hidden: 0);} $data = array_merge($data, $data_query);$data['current_user_permissions'] = $this->get_current_user_permissions($收件人,$请求);/** *过滤从API返回的接收值。* * @param array $data REST响应的接收方值。 * @param object $recipient The recipient object. * @param WP_REST_Request $request Request used to generate the response. * * @since 0.1.0 */ return apply_filters( 'bp_rest_messages_prepare_recipient_value', $data, $recipient, $request ); }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |