@@ 133-146 (lines=14) @@ | ||
130 | * @param WP_REST_Request $request Full details about the request. |
|
131 | * @return WP_Error|boolean |
|
132 | */ |
|
133 | public function delete_item_permissions_check( $request ) { |
|
134 | ||
135 | $response = $this->get_items_permissions_check( $request ); |
|
136 | if ( ! $response || is_wp_error( $response ) ) { |
|
137 | return $response; |
|
138 | } |
|
139 | ||
140 | $post = $this->get_post( $request['id'] ); |
|
141 | if ( ! $post ) { |
|
142 | return new WP_Error( 'rest_post_invalid_id', __( 'Invalid revision id.' ), array( 'status' => 404 ) ); |
|
143 | } |
|
144 | $post_type = get_post_type_object( 'revision' ); |
|
145 | return current_user_can( $post_type->cap->delete_post, $post->ID ); |
|
146 | } |
|
147 | ||
148 | /** |
|
149 | * Delete a single revision |
@@ 293-306 (lines=14) @@ | ||
290 | * @param WP_REST_Request $request Full details about the request |
|
291 | * @return WP_REST_Request|WP_Error |
|
292 | */ |
|
293 | public function get_item( $request ) { |
|
294 | ||
295 | $term = get_term( (int) $request['id'], $this->taxonomy ); |
|
296 | if ( ! $term || $term->taxonomy !== $this->taxonomy ) { |
|
297 | return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) ); |
|
298 | } |
|
299 | if ( is_wp_error( $term ) ) { |
|
300 | return $term; |
|
301 | } |
|
302 | ||
303 | $response = $this->prepare_item_for_response( $term, $request ); |
|
304 | ||
305 | return rest_ensure_response( $response ); |
|
306 | } |
|
307 | ||
308 | /** |
|
309 | * Check if a given request has access to create a term |