BP_REST_Media_Albums_Endpoint:: delete_item (WP_REST_Request美元的请求)
删除单个相册。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)请求的全部细节。
返回
(WP_REST_Response)| WP_Error
源
文件:bp-media /类/ class-bp-rest-media-albums-endpoint.php
Public function delete_item($request['id']) {$medias = $this->assemble_response_data(array('album_ids' => array($request['id']));if (empty($medias['albums'])) {return new WP_Error('bp_rest_album_invalid_id', __('无效的相册ID。', 'buddyboss'), array('status' => 404,));} $previous = array();Foreach ($medias['albums'] as $album) {$previous = $this->prepare_response_for_collection($this->prepare_item_for_response($album, $request));} if (!bp_album_user_can_delete($request['id']) {return WP_Error('bp_rest_authorization_required', __('对不起,您不允许删除此相册。', 'buddyboss'), array('status' => rest_authorization_required_code(),));} $status = bp_album_delete(array('id' => $request['id']));//建立响应。$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 | 介绍了。 |