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