Required permissions to list or get shipping classes

This commit is contained in:
Claudio Sanches 2016-03-03 18:09:37 -03:00
parent cbdddd99cc
commit a7b1393955
1 changed files with 25 additions and 0 deletions

View File

@ -36,6 +36,31 @@ class WC_REST_Product_Shipping_Classes_Controller extends WC_REST_Terms_Controll
*/
protected $taxonomy = 'product_shipping_class';
/**
* Check if a given request has access to read the terms.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
$taxonomy = get_taxonomy( $this->taxonomy );
return current_user_can( $taxonomy->cap->edit_terms );
}
/**
* Check if a given request has access to read a term.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_item_permissions_check( $request ) {
$id = (int) $request['id'];
$taxonomy = get_taxonomy( $this->taxonomy );
return current_user_can( $taxonomy->cap->edit_terms, $id );
}
/**
* Prepare a single product shipping class output for response.
*