BP_REST_Media_Endpoint:: delete_item (WP_REST_Request美元的请求)
删除单个媒体。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)请求的全部细节。
返回
(WP_REST_Response)| WP_Error
源
文件:bp-media /类/ class-bp-rest-media-endpoint.php
Public function delete_item($request) {$id = $request['id'];$medias = $this->如果(空($medias['medias'])){返回新的WP_Error('bp_rest_media_id', __('无效的媒体ID。', 'buddyboss'), array('status' => 404,));} $previous = "; ";Foreach ($medias['medias'] as $media) {$previous = $this->prepare_response_for_collection($this->prepare_item_for_response($media, $request));} if (!bp_media_user_can_delete($id)) {return WP_Error('bp_rest_authorization_required', __('对不起,您不允许删除此媒体。', 'buddyboss'), array('status' => rest_authorization_required_code(),));} $status = bp_media_delete(array('id' => $id), true);//建立响应。$response = new WP_REST_Response(); $response->set_data( array( 'deleted' => $status, 'previous' => $previous, ) ); /** * Fires after a media is fetched via the REST API. * * @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_media_get_item', $response, $request ); return $response; }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |