@@ -57,7 +57,7 @@ public function register_routes(): void {
5757 array (
5858 'methods ' => WP_REST_Server::READABLE ,
5959 'callback ' => array ( $ this , 'get_items ' ),
60- 'permission_callback ' => array ( $ this , 'get_permissions_check ' ),
60+ 'permission_callback ' => array ( $ this , 'get_items_permissions_check ' ),
6161 'args ' => $ this ->get_collection_params (),
6262 ),
6363 'schema ' => array ( $ this , 'get_public_item_schema ' ),
@@ -78,7 +78,7 @@ public function register_routes(): void {
7878 array (
7979 'methods ' => WP_REST_Server::READABLE ,
8080 'callback ' => array ( $ this , 'get_item ' ),
81- 'permission_callback ' => array ( $ this , 'get_permissions_check ' ),
81+ 'permission_callback ' => array ( $ this , 'get_item_permissions_check ' ),
8282 ),
8383 'schema ' => array ( $ this , 'get_public_item_schema ' ),
8484 )
@@ -102,7 +102,7 @@ static function ( $ability ) {
102102 );
103103
104104 // Filter by ability category if specified.
105- $ category = $ request-> get_param ( 'category ' ) ;
105+ $ category = $ request[ 'category ' ] ;
106106 if ( ! empty ( $ category ) ) {
107107 $ abilities = array_filter (
108108 $ abilities ,
@@ -114,10 +114,8 @@ static function ( $ability ) use ( $category ) {
114114 $ abilities = array_values ( $ abilities );
115115 }
116116
117- // Handle pagination with explicit defaults.
118- $ params = $ request ->get_params ();
119- $ page = $ params ['page ' ] ?? 1 ;
120- $ per_page = $ params ['per_page ' ] ?? self ::DEFAULT_PER_PAGE ;
117+ $ page = $ request ['page ' ];
118+ $ per_page = $ request ['per_page ' ];
121119 $ offset = ( $ page - 1 ) * $ per_page ;
122120
123121 $ total_abilities = count ( $ abilities );
@@ -167,7 +165,7 @@ static function ( $ability ) use ( $category ) {
167165 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
168166 */
169167 public function get_item ( $ request ) {
170- $ ability = wp_get_ability ( $ request-> get_param ( 'name ' ) );
168+ $ ability = wp_get_ability ( $ request[ 'name ' ] );
171169 if ( ! $ ability || ! $ ability ->get_meta_item ( 'show_in_rest ' ) ) {
172170 return new WP_Error (
173171 'rest_ability_not_found ' ,
@@ -185,7 +183,7 @@ public function get_item( $request ) {
185183 *
186184 * @since 6.9.0
187185 *
188- * @param WP_REST_Request<array<string, mixed>> $request Full details about the request.
186+ * @param WP_REST_Request $request Full details about the request.
189187 * @return bool True if the request has read access.
190188 */
191189 public function get_permissions_check ( $ request ) {
@@ -212,7 +210,7 @@ public function prepare_item_for_response( $ability, $request ) {
212210 'meta ' => $ ability ->get_meta (),
213211 );
214212
215- $ context = $ request-> get_param ( 'context ' ) ?? ' view ' ;
213+ $ context = $ request[ 'context ' ] ;
216214 $ data = $ this ->add_additional_fields_to_object ( $ data , $ request );
217215 $ data = $ this ->filter_response_by_context ( $ data , $ context );
218216
@@ -295,7 +293,6 @@ public function get_item_schema(): array {
295293 'readonly ' => true ,
296294 ),
297295 ),
298- 'required ' => array ( 'name ' , 'label ' , 'meta ' , 'description ' , 'category ' , 'input_schema ' , 'output_schema ' ),
299296 );
300297
301298 return $ this ->add_additional_fields_schema ( $ schema );
0 commit comments