- Timestamp:
- 10/26/2016 09:36:29 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r38911 r38968 112 112 113 113 // Make sure a search string is set in case the orderby is set to 'relevance'. 114 if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) && empty( $request['filter']['s'] )) {114 if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) { 115 115 return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) ); 116 116 } … … 162 162 } 163 163 164 if ( isset( $registered['filter'] ) && is_array( $request['filter'] ) ) {165 $args = array_merge( $args, $request['filter'] );166 unset( $args['filter'] );167 }168 169 164 // Ensure our per_page parameter overrides any provided posts_per_page filter. 170 165 if ( isset( $registered['per_page'] ) ) { … … 270 265 } 271 266 272 $max_pages = ceil( $total_posts / (int) $ query_args['posts_per_page'] );267 $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); 273 268 274 269 $response = rest_ensure_response( $posts ); … … 277 272 278 273 $request_params = $request->get_query_params(); 279 if ( ! empty( $request_params['filter'] ) ) {280 // Normalize the pagination params.281 unset( $request_params['filter']['posts_per_page'], $request_params['filter']['paged'] );282 }283 274 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) ); 284 275 … … 1911 1902 'validate_callback' => array( $this, 'validate_user_can_query_private_statuses' ), 1912 1903 ); 1913 $params['filter'] = array(1914 'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.' ),1915 );1916 1904 1917 1905 $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
Note: See TracChangeset
for help on using the changeset viewer.