Changeset 39441 for branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
- Timestamp:
- 12/02/2016 10:20:27 PM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r39353 r39441 149 149 } 150 150 151 // Ensure an include parameter is set in case the orderby is set to 'include'. 152 if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) { 153 return new WP_Error( 'rest_orderby_include_missing_include', sprintf( __( 'Missing parameter(s): %s' ), 'include' ), array( 'status' => 400 ) ); 154 } 155 151 156 // Retrieve the list of registered collection query parameters. 152 157 $registered = $this->get_collection_params(); … … 837 842 } 838 843 839 if ( 'include' === $query_args['orderby'] ) { 840 $query_args['orderby'] = 'post__in'; 844 // Map to proper WP_Query orderby param. 845 if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) { 846 $orderby_mappings = array( 847 'id' => 'ID', 848 'include' => 'post__in', 849 'slug' => 'post_name', 850 ); 851 852 if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) { 853 $query_args['orderby'] = $orderby_mappings[ $request['orderby'] ]; 854 } 841 855 } 842 856
Note: See TracChangeset
for help on using the changeset viewer.