Skip to content

Commit fb27297

Browse files
author
Mohamed Khaled
committed
Revert REST controller changes - use simple has_permission() call as intended
1 parent b32a898 commit fb27297

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

includes/rest-api/endpoints/class-wp-rest-abilities-run-controller.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,8 @@ public function run_ability_permissions_check( $request ) {
162162
);
163163
}
164164

165-
$input = $this->get_input_from_request( $request );
166-
$permission_status = $ability->get_permission_status( $input );
167-
if ( true !== $permission_status ) {
168-
// Handle input validation errors as 400 Bad Request
169-
if ( is_wp_error( $permission_status ) && 'ability_invalid_input' === $permission_status->get_error_code() ) {
170-
return $permission_status; // Let WordPress handle as 400 Bad Request
171-
}
172-
173-
// Handle actual permission errors as 403 Forbidden
165+
$input = $this->get_input_from_request( $request );
166+
if ( ! $ability->has_permission( $input ) ) {
174167
return new \WP_Error(
175168
'rest_ability_cannot_execute',
176169
__( 'Sorry, you are not allowed to execute this ability.' ),

0 commit comments

Comments
 (0)