WC_REST_Posts_Controller::prepare_items_query PHP 메소드

prepare_items_query() 보호된 메소드

Determine the allowed query_vars for a get_items() response and prepare for WP_Query.
protected prepare_items_query ( array $prepared_args = [], WP_REST_Request $request = null ) : array
$prepared_args array
$request WP_REST_Request
리턴 array $query_args
    protected function prepare_items_query($prepared_args = array(), $request = null)
    {
        $valid_vars = array_flip($this->get_allowed_query_vars());
        $query_args = array();
        foreach ($valid_vars as $var => $index) {
            if (isset($prepared_args[$var])) {
                /**
                 * Filter the query_vars used in `get_items` for the constructed query.
                 *
                 * The dynamic portion of the hook name, $var, refers to the query_var key.
                 *
                 * @param mixed $prepared_args[ $var ] The query_var value.
                 *
                 */
                $query_args[$var] = apply_filters("woocommerce_rest_query_var-{$var}", $prepared_args[$var]);
            }
        }
        $query_args['ignore_sticky_posts'] = true;
        if ('include' === $query_args['orderby']) {
            $query_args['orderby'] = 'post__in';
        } elseif ('id' === $query_args['orderby']) {
            $query_args['orderby'] = 'ID';
            // ID must be capitalized
        }
        return $query_args;
    }