WC_API_Authentication::check_api_key_permissions() public WC 1.0
Check that the API keys provided have the proper key-specific permissions to either read or write API resources
{} Это метод класса: WC_API_Authentication{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WC_API_Authentication = new WC_API_Authentication(); $WC_API_Authentication->check_api_key_permissions( $key_permissions );
- $key_permissions(строка) (обязательный)
- -
Код WC_API_Authentication::check_api_key_permissions() WC API Authentication::check api key permissions WC 5.0.0
public function check_api_key_permissions( $key_permissions ) {
switch ( WC()->api->server->method ) {
case 'HEAD':
case 'GET':
if ( 'read' !== $key_permissions && 'read_write' !== $key_permissions ) {
throw new Exception( __( 'The API key provided does not have read permissions.', 'woocommerce' ), 401 );
}
break;
case 'POST':
case 'PUT':
case 'PATCH':
case 'DELETE':
if ( 'write' !== $key_permissions && 'read_write' !== $key_permissions ) {
throw new Exception( __( 'The API key provided does not have write permissions.', 'woocommerce' ), 401 );
}
break;
}
}