/**
  * Check whether a given request has permission to view system status.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return WP_Error|boolean
  */
 public function get_items_permissions_check($request)
 {
     if (!wc_rest_check_manager_permissions('system_status', 'read')) {
         return new WP_Error('woocommerce_rest_cannot_view', __('Sorry, you cannot list resources.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
 /**
  * Check whether a given request has permission to execute a specific system status tool.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return WP_Error|boolean
  */
 public function update_item_permissions_check($request)
 {
     if (!wc_rest_check_manager_permissions('system_status', 'edit')) {
         return new WP_Error('woocommerce_rest_cannot_update', __('Sorry, you cannot update resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
 /**
  * Check whether a given request has permission to edit payment gateways.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return WP_Error|boolean
  */
 public function update_items_permissions_check($request)
 {
     if (!wc_rest_check_manager_permissions('payment_gateways', 'edit')) {
         return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you are not allowed to edit this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
 /**
  * Check if a given request has access delete a tax.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return boolean
  */
 public function delete_item_permissions_check($request)
 {
     if (!wc_rest_check_manager_permissions('settings', 'delete')) {
         return new WP_Error('woocommerce_rest_cannot_delete', __('Sorry, you are not allowed to delete this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
 /**
  * Check if a given request has access batch create, update and delete items.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return boolean
  */
 public function batch_items_permissions_check($request)
 {
     if (!wc_rest_check_manager_permissions('attributes', 'batch')) {
         return new WP_Error('woocommerce_rest_cannot_batch', __('Sorry, you are not allowed to batch manipulate this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
 /**
  * Check if a given request has access to delete a attribute.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return WP_Error|boolean
  */
 public function delete_item_permissions_check($request)
 {
     if (!$this->get_taxonomy($request)) {
         return new WP_Error("woocommerce_rest_taxonomy_invalid", __("Resource doesn't exist.", 'woocommerce'), array('status' => 404));
     }
     if (!wc_rest_check_manager_permissions('attributes', 'delete')) {
         return new WP_Error('woocommerce_rest_cannot_delete', __('Sorry, you cannot delete resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
 /**
  * Check whether a given request has permission to delete Shipping Zones.
  *
  * @param  WP_REST_Request $request Full details about the request.
  * @return WP_Error|boolean
  */
 public function delete_items_permissions_check($request)
 {
     if (!wc_shipping_enabled()) {
         return new WP_Error('rest_no_route', __('Shipping is disabled.', 'woocommerce'), array('status' => 404));
     }
     if (!wc_rest_check_manager_permissions('settings', 'delete')) {
         return new WP_Error('woocommerce_rest_cannot_edit', __('Sorry, you are not allowed to delete this resource.', 'woocommerce'), array('status' => rest_authorization_required_code()));
     }
     return true;
 }
Exemplo n.º 8
0
 /**
  * Test wc_rest_check_manager_permissions().
  *
  * @since 2.6.0
  */
 public function test_wc_rest_check_manager_permissions()
 {
     $this->isFalse(wc_rest_check_manager_permissions('reports'));
 }