Make WordPress Core

Ticket #40213: 40213.diff

File 40213.diff, 1.5 KB (added by MatheusGimenez, 8 years ago)

Added support to array and comma-separated to slug param

  • src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

     
    221221                        'per_page' => 'number',
    222222                        'search'   => 'search',
    223223                        'roles'    => 'role__in',
     224                        'slug'     => 'nicename__in'
    224225                );
    225226
    226227                $prepared_args = array();
     
    261262                if ( ! empty( $prepared_args['search'] ) ) {
    262263                        $prepared_args['search'] = '*' . $prepared_args['search'] . '*';
    263264                }
    264 
    265                 if ( isset( $registered['slug'] ) && ! empty( $request['slug'] ) ) {
    266                         $prepared_args['search'] = $request['slug'];
    267                         $prepared_args['search_columns'] = array( 'user_nicename' );
    268                 }
    269 
    270265                /**
    271266                 * Filters WP_User_Query arguments when querying users via the REST API.
    272267                 *
     
    278273                 * @param WP_REST_Request $request       The current request.
    279274                 */
    280275                $prepared_args = apply_filters( 'rest_user_query', $prepared_args, $request );
    281 
    282276                $query = new WP_User_Query( $prepared_args );
    283277
    284278                $users = array();
     
    13631357                );
    13641358
    13651359                $query_params['slug']    = array(
    1366                         'description'        => __( 'Limit result set to users with a specific slug.' ),
    1367                         'type'               => 'string',
     1360                        'description'           => __( 'Limit result set to users with a specific slug.' ),
     1361                        'type'                          => 'array',
     1362                        'items'                         => array(
     1363                                'type'                  => 'string',
     1364                        )
    13681365                );
    13691366
    13701367                $query_params['roles']   = array(