diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index 0122f9a..966fec8 100644
|
a
|
b
|
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 148 | 148 | |
| 149 | 149 | // Retrieve the list of registered collection query parameters. |
| 150 | 150 | $registered = $this->get_collection_params(); |
| 151 | | $args = array(); |
| 152 | | |
| 153 | | /* |
| 154 | | * This array defines mappings between public API query parameters whose |
| 155 | | * values are accepted as-passed, and their internal WP_Query parameter |
| 156 | | * name equivalents (some are the same). Only values which are also |
| 157 | | * present in $registered will be set. |
| 158 | | */ |
| 159 | | $parameter_mappings = array( |
| 160 | | 'author' => 'author__in', |
| 161 | | 'author_exclude' => 'author__not_in', |
| 162 | | 'exclude' => 'post__not_in', |
| 163 | | 'include' => 'post__in', |
| 164 | | 'menu_order' => 'menu_order', |
| 165 | | 'offset' => 'offset', |
| 166 | | 'order' => 'order', |
| 167 | | 'orderby' => 'orderby', |
| 168 | | 'page' => 'paged', |
| 169 | | 'parent' => 'post_parent__in', |
| 170 | | 'parent_exclude' => 'post_parent__not_in', |
| 171 | | 'search' => 's', |
| 172 | | 'slug' => 'post_name__in', |
| 173 | | 'status' => 'post_status', |
| 174 | | ); |
| 175 | 151 | |
| 176 | 152 | /* |
| 177 | 153 | * For each known parameter which is both registered and present in the request, |
| 178 | 154 | * set the parameter's value on the query $args. |
| 179 | 155 | */ |
| 180 | | foreach ( $parameter_mappings as $api_param => $wp_param ) { |
| 181 | | if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) { |
| | 156 | $args = array(); |
| | 157 | foreach( $registered as $api_param => $meta ) { |
| | 158 | if ( isset( $request[ $api_param ] ) ) { |
| | 159 | $wp_param = isset( $meta['query_var'] ) ? $meta['query_var'] : $api_param; |
| 182 | 160 | $args[ $wp_param ] = $request[ $api_param ]; |
| 183 | 161 | } |
| 184 | 162 | } |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2022 | 2000 | 'type' => 'array', |
| 2023 | 2001 | 'default' => array(), |
| 2024 | 2002 | 'sanitize_callback' => 'wp_parse_id_list', |
| | 2003 | 'query_var' => 'author__in', |
| 2025 | 2004 | ); |
| 2026 | 2005 | $params['author_exclude'] = array( |
| 2027 | 2006 | 'description' => __( 'Ensure result set excludes posts assigned to specific authors.' ), |
| 2028 | 2007 | 'type' => 'array', |
| 2029 | 2008 | 'default' => array(), |
| 2030 | 2009 | 'sanitize_callback' => 'wp_parse_id_list', |
| | 2010 | 'query_var' => 'author__not_in', |
| 2031 | 2011 | ); |
| 2032 | 2012 | } |
| 2033 | 2013 | |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2043 | 2023 | 'type' => 'array', |
| 2044 | 2024 | 'default' => array(), |
| 2045 | 2025 | 'sanitize_callback' => 'wp_parse_id_list', |
| | 2026 | 'query_var' => 'post__not_in', |
| 2046 | 2027 | ); |
| 2047 | 2028 | |
| 2048 | 2029 | $params['include'] = array( |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2050 | 2031 | 'type' => 'array', |
| 2051 | 2032 | 'default' => array(), |
| 2052 | 2033 | 'sanitize_callback' => 'wp_parse_id_list', |
| | 2034 | 'query_var' => 'post__in', |
| 2053 | 2035 | ); |
| 2054 | 2036 | |
| 2055 | 2037 | if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) { |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2095 | 2077 | $params['orderby']['enum'][] = 'menu_order'; |
| 2096 | 2078 | } |
| 2097 | 2079 | |
| | 2080 | // Defined by the parent class. |
| | 2081 | $params['page']['query_var'] = 'paged'; |
| | 2082 | |
| 2098 | 2083 | $post_type_obj = get_post_type_object( $this->post_type ); |
| 2099 | 2084 | |
| 2100 | 2085 | if ( $post_type_obj->hierarchical || 'attachment' === $this->post_type ) { |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2103 | 2088 | 'type' => 'array', |
| 2104 | 2089 | 'sanitize_callback' => 'wp_parse_id_list', |
| 2105 | 2090 | 'default' => array(), |
| | 2091 | 'query_var' => 'post_parent__in', |
| 2106 | 2092 | ); |
| 2107 | 2093 | $params['parent_exclude'] = array( |
| 2108 | 2094 | 'description' => __( 'Limit result set to all items except those of a particular parent id.' ), |
| 2109 | 2095 | 'type' => 'array', |
| 2110 | 2096 | 'sanitize_callback' => 'wp_parse_id_list', |
| 2111 | 2097 | 'default' => array(), |
| | 2098 | 'query_var' => 'post_parent__not_in', |
| 2112 | 2099 | ); |
| 2113 | 2100 | } |
| 2114 | 2101 | |
| | 2102 | // Defined by the parent class. |
| | 2103 | $params['search']['query_var'] = 's'; |
| | 2104 | |
| 2115 | 2105 | $params['slug'] = array( |
| 2116 | 2106 | 'description' => __( 'Limit result set to posts with one or more specific slugs.' ), |
| 2117 | 2107 | 'type' => 'array', |
| 2118 | 2108 | 'sanitize_callback' => 'wp_parse_slug_list', |
| | 2109 | 'query_var' => 'post_name__in', |
| 2119 | 2110 | ); |
| 2120 | 2111 | |
| 2121 | 2112 | $params['status'] = array( |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2125 | 2116 | 'sanitize_callback' => 'sanitize_key', |
| 2126 | 2117 | 'type' => 'string', |
| 2127 | 2118 | 'validate_callback' => array( $this, 'validate_user_can_query_private_statuses' ), |
| | 2119 | 'query_var' => 'post_status', |
| 2128 | 2120 | ); |
| 2129 | 2121 | |
| 2130 | 2122 | $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); |
| … |
… |
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
| 2148 | 2140 | ); |
| 2149 | 2141 | } |
| 2150 | 2142 | |
| | 2143 | /** |
| | 2144 | * Filters the collection parameters for the controller. |
| | 2145 | * |
| | 2146 | * Enables adding or removing collection parameters from the endpoint. |
| | 2147 | * |
| | 2148 | * @since 4.7.0 |
| | 2149 | * |
| | 2150 | * @param array $params Key value array of the collection params. |
| | 2151 | */ |
| | 2152 | $params = apply_filters( "rest_{$this->post_type}_collection_params", $params ); |
| 2151 | 2153 | return $params; |
| 2152 | 2154 | } |
| 2153 | 2155 | |