- Timestamp:
- 12/20/2016 01:36:47 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r39620 r39621 1986 1986 */ 1987 1987 public function get_collection_params() { 1988 $ params = parent::get_collection_params();1989 1990 $ params['context']['default'] = 'view';1991 1992 $ params['after'] = array(1988 $query_params = parent::get_collection_params(); 1989 1990 $query_params['context']['default'] = 'view'; 1991 1992 $query_params['after'] = array( 1993 1993 'description' => __( 'Limit response to posts published after a given ISO8601 compliant date.' ), 1994 1994 'type' => 'string', … … 1997 1997 1998 1998 if ( post_type_supports( $this->post_type, 'author' ) ) { 1999 $ params['author'] = array(1999 $query_params['author'] = array( 2000 2000 'description' => __( 'Limit result set to posts assigned to specific authors.' ), 2001 2001 'type' => 'array', … … 2005 2005 'default' => array(), 2006 2006 ); 2007 $ params['author_exclude'] = array(2007 $query_params['author_exclude'] = array( 2008 2008 'description' => __( 'Ensure result set excludes posts assigned to specific authors.' ), 2009 2009 'type' => 'array', … … 2015 2015 } 2016 2016 2017 $ params['before'] = array(2017 $query_params['before'] = array( 2018 2018 'description' => __( 'Limit response to posts published before a given ISO8601 compliant date.' ), 2019 2019 'type' => 'string', … … 2021 2021 ); 2022 2022 2023 $ params['exclude'] = array(2023 $query_params['exclude'] = array( 2024 2024 'description' => __( 'Ensure result set excludes specific IDs.' ), 2025 2025 'type' => 'array', … … 2030 2030 ); 2031 2031 2032 $ params['include'] = array(2032 $query_params['include'] = array( 2033 2033 'description' => __( 'Limit result set to specific IDs.' ), 2034 2034 'type' => 'array', … … 2040 2040 2041 2041 if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) { 2042 $ params['menu_order'] = array(2042 $query_params['menu_order'] = array( 2043 2043 'description' => __( 'Limit result set to posts with a specific menu_order value.' ), 2044 2044 'type' => 'integer', … … 2046 2046 } 2047 2047 2048 $ params['offset'] = array(2048 $query_params['offset'] = array( 2049 2049 'description' => __( 'Offset the result set by a specific number of items.' ), 2050 2050 'type' => 'integer', 2051 2051 ); 2052 2052 2053 $ params['order'] = array(2053 $query_params['order'] = array( 2054 2054 'description' => __( 'Order sort attribute ascending or descending.' ), 2055 2055 'type' => 'string', … … 2058 2058 ); 2059 2059 2060 $ params['orderby'] = array(2060 $query_params['orderby'] = array( 2061 2061 'description' => __( 'Sort collection by object attribute.' ), 2062 2062 'type' => 'string', … … 2073 2073 2074 2074 if ( 'page' === $this->post_type || post_type_supports( $this->post_type, 'page-attributes' ) ) { 2075 $ params['orderby']['enum'][] = 'menu_order';2076 } 2077 2078 $post_type _obj= get_post_type_object( $this->post_type );2079 2080 if ( $post_type _obj->hierarchical || 'attachment' === $this->post_type ) {2081 $ params['parent'] = array(2075 $query_params['orderby']['enum'][] = 'menu_order'; 2076 } 2077 2078 $post_type = get_post_type_object( $this->post_type ); 2079 2080 if ( $post_type->hierarchical || 'attachment' === $this->post_type ) { 2081 $query_params['parent'] = array( 2082 2082 'description' => __( 'Limit result set to those of particular parent IDs.' ), 2083 2083 'type' => 'array', … … 2087 2087 'default' => array(), 2088 2088 ); 2089 $ params['parent_exclude'] = array(2089 $query_params['parent_exclude'] = array( 2090 2090 'description' => __( 'Limit result set to all items except those of a particular parent ID.' ), 2091 2091 'type' => 'array', … … 2097 2097 } 2098 2098 2099 $ params['slug'] = array(2099 $query_params['slug'] = array( 2100 2100 'description' => __( 'Limit result set to posts with one or more specific slugs.' ), 2101 2101 'type' => 'array', … … 2106 2106 ); 2107 2107 2108 $ params['status'] = array(2108 $query_params['status'] = array( 2109 2109 'default' => 'publish', 2110 2110 'description' => __( 'Limit result set to posts assigned one or more statuses.' ), … … 2122 2122 $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; 2123 2123 2124 $ params[ $base ] = array(2124 $query_params[ $base ] = array( 2125 2125 /* translators: %s: taxonomy name */ 2126 2126 'description' => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ), … … 2132 2132 ); 2133 2133 2134 $ params[ $base . '_exclude' ] = array(2134 $query_params[ $base . '_exclude' ] = array( 2135 2135 /* translators: %s: taxonomy name */ 2136 2136 'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ), … … 2144 2144 2145 2145 if ( 'post' === $this->post_type ) { 2146 $ params['sticky'] = array(2146 $query_params['sticky'] = array( 2147 2147 'description' => __( 'Limit result set to items that are sticky.' ), 2148 2148 'type' => 'boolean', … … 2162 2162 * @since 4.7.0 2163 2163 * 2164 * @param $params JSON Schema-formatted collection parameters.2165 * @param WP_Post_Type $post_type _objPost type object.2164 * @param array $query_params JSON Schema-formatted collection parameters. 2165 * @param WP_Post_Type $post_type Post type object. 2166 2166 */ 2167 return apply_filters( "rest_{$this->post_type}_collection_params", $ params, $post_type_obj);2167 return apply_filters( "rest_{$this->post_type}_collection_params", $query_params, $post_type ); 2168 2168 } 2169 2169
Note: See TracChangeset
for help on using the changeset viewer.