Automattic\WooCommerce\Internal\Admin\Settings
PaymentsRestController::check_permissions()
General permissions check for payments settings REST API endpoint.
Метод класса: PaymentsRestController{}
Хуков нет.
Возвращает
true|false|WP_Error
. True if the current user has the capability, otherwise an "Unauthorized" error or False if no error is available for the request method.
Использование
// private - только в коде основоного (родительского) класса $result = $this->check_permissions( $request );
- $request(WP_REST_Request) (обязательный)
- The request for which the permission is checked.
Код PaymentsRestController::check_permissions() PaymentsRestController::check permissions WC 9.6.1
private function check_permissions( WP_REST_Request $request ) { $context = 'read'; if ( 'POST' === $request->get_method() ) { $context = 'edit'; } elseif ( 'DELETE' === $request->get_method() ) { $context = 'delete'; } if ( wc_rest_check_manager_permissions( 'payment_gateways', $context ) ) { return true; } $error_information = $this->get_authentication_error_by_method( $request->get_method() ); if ( is_null( $error_information ) ) { return false; } return new WP_Error( $error_information['code'], $error_information['message'], array( 'status' => rest_authorization_required_code() ) ); }