WP_REST_Revisions_Controller::prepare_items_query()
Determines the allowed query_vars for a get_items() response and prepares them for WP_Query.
Метод класса: WP_REST_Revisions_Controller{}
Хуки из метода
Возвращает
Массив
. Items query arguments.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->prepare_items_query( $prepared_args, $request );
- $prepared_args(массив)
- Prepared WP_Query arguments.
По умолчанию: empty array - $request(WP_REST_Request)
- Full details about the request.
По умолчанию: null
Список изменений
С версии 5.0.0 | Введена. |
Код WP_REST_Revisions_Controller::prepare_items_query() WP REST Revisions Controller::prepare items query WP 6.6.1
protected function prepare_items_query( $prepared_args = array(), $request = null ) { $query_args = array(); foreach ( $prepared_args as $key => $value ) { /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */ $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } // Map to proper WP_Query orderby param. if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) { $orderby_mappings = array( 'id' => 'ID', 'include' => 'post__in', 'slug' => 'post_name', 'include_slugs' => 'post_name__in', ); if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) { $query_args['orderby'] = $orderby_mappings[ $request['orderby'] ]; } } return $query_args; }