Automattic\WooCommerce\Admin\API
Options::get_item_permissions_check()
Check if a given request has access to get options.
Method of the class: Options{}
No Hooks.
Return
WP_Error|true|false
.
Usage
$Options = new Options(); $Options->get_item_permissions_check( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Options::get_item_permissions_check() Options::get item permissions check code WC 9.6.0
public function get_item_permissions_check( $request ) { $params = ( isset( $request['options'] ) && is_string( $request['options'] ) ) ? explode( ',', $request['options'] ) : array(); if ( ! $params ) { return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'You must supply an array of options.', 'woocommerce' ), 500 ); } foreach ( $params as $option ) { if ( ! $this->user_has_permission( $option, $request ) ) { if ( 'production' !== wp_get_environment_type() ) { return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view these options, please remember to update the option permissions in Options API to allow viewing these options in non-production environments.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); } return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view these options.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); } } return true; }