- Timestamp:
- 02/28/2025 06:19:21 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r59754 r59892 258 258 * 259 259 * @since 4.7.0 260 * @since 6.8.0 Added support for the search_columns query param. 260 261 * 261 262 * @param WP_REST_Request $request Full details about the request. … … 332 333 $prepared_args['search_columns'] = array( 'ID', 'user_login', 'user_nicename', 'display_name' ); 333 334 } 335 $search_columns = $request->get_param( 'search_columns' ); 336 $valid_columns = isset( $prepared_args['search_columns'] ) 337 ? $prepared_args['search_columns'] 338 : array( 'ID', 'user_login', 'user_nicename', 'user_email', 'display_name' ); 339 $search_columns_mapping = array( 340 'id' => 'ID', 341 'username' => 'user_login', 342 'slug' => 'user_nicename', 343 'email' => 'user_email', 344 'name' => 'display_name', 345 ); 346 $search_columns = array_map( 347 static function ( $column ) use ( $search_columns_mapping ) { 348 return $search_columns_mapping[ $column ]; 349 }, 350 $search_columns 351 ); 352 $search_columns = array_intersect( $search_columns, $valid_columns ); 353 if ( ! empty( $search_columns ) ) { 354 $prepared_args['search_columns'] = $search_columns; 355 } 334 356 $prepared_args['search'] = '*' . $prepared_args['search'] . '*'; 335 357 } … … 1614 1636 ); 1615 1637 1638 $query_params['search_columns'] = array( 1639 'default' => array(), 1640 'description' => __( 'Array of column names to be searched.' ), 1641 'type' => 'array', 1642 'items' => array( 1643 'enum' => array( 'email', 'name', 'id', 'username', 'slug' ), 1644 'type' => 'string', 1645 ), 1646 ); 1647 1616 1648 /** 1617 1649 * Filters REST API collection parameters for the users controller.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)