@@ 393-410 (lines=18) @@ | ||
390 | * @param WP_REST_Request $request Full details about the request. |
|
391 | * @return WP_Error|boolean |
|
392 | */ |
|
393 | public function update_item_permissions_check( $request ) { |
|
394 | ||
395 | if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) { |
|
396 | return false; |
|
397 | } |
|
398 | ||
399 | $term = get_term( (int) $request['id'], $this->taxonomy ); |
|
400 | if ( ! $term ) { |
|
401 | return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) ); |
|
402 | } |
|
403 | ||
404 | $taxonomy_obj = get_taxonomy( $this->taxonomy ); |
|
405 | if ( ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) { |
|
406 | return new WP_Error( 'rest_cannot_update', __( 'Sorry, you cannot update resource.' ), array( 'status' => rest_authorization_required_code() ) ); |
|
407 | } |
|
408 | ||
409 | return true; |
|
410 | } |
|
411 | ||
412 | /** |
|
413 | * Update a single term from a taxonomy |
|
@@ 464-481 (lines=18) @@ | ||
461 | * @param WP_REST_Request $request Full details about the request. |
|
462 | * @return WP_Error|boolean |
|
463 | */ |
|
464 | public function delete_item_permissions_check( $request ) { |
|
465 | if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) { |
|
466 | return false; |
|
467 | } |
|
468 | $term = get_term( (int) $request['id'], $this->taxonomy ); |
|
469 | if ( ! $term ) { |
|
470 | return new WP_Error( 'rest_term_invalid', __( "Resource doesn't exist." ), array( 'status' => 404 ) ); |
|
471 | } |
|
472 | $taxonomy_obj = get_taxonomy( $this->taxonomy ); |
|
473 | if ( ! current_user_can( $taxonomy_obj->cap->delete_terms ) ) { |
|
474 | return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you cannot delete resource.' ), array( 'status' => rest_authorization_required_code() ) ); |
|
475 | } |
|
476 | return true; |
|
477 | } |
|
478 | ||
479 | /** |
|
480 | * Delete a single term from a taxonomy |
|
481 | * |
|
482 | * @param WP_REST_Request $request Full details about the request |
|
483 | * @return WP_REST_Response|WP_Error |
|
484 | */ |