本文整理汇总了PHP中wc_rest_check_manager_permissions函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_rest_check_manager_permissions函数的具体用法?PHP wc_rest_check_manager_permissions怎么用?PHP wc_rest_check_manager_permissions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_rest_check_manager_permissions函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_items_permissions_check
/**
* 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;
}
示例2: update_item_permissions_check
/**
* 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;
}
示例3: update_items_permissions_check
/**
* 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;
}
示例4: delete_item_permissions_check
/**
* 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;
}
示例5: batch_items_permissions_check
/**
* 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;
}
示例6: delete_item_permissions_check
/**
* 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;
}
示例7: delete_items_permissions_check
/**
* 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;
}
示例8: test_wc_rest_check_manager_permissions
/**
* 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'));
}