woocommerce_rest_query_vars filter-hookWC 1.0

Filter allowed query vars for the REST API.

This filter allows you to add or remove query vars from the final allowed list for all requests, including unauthenticated ones. To alter the vars for editors only.

Usage

add_filter( 'woocommerce_rest_query_vars', 'wp_kama_woocommerce_rest_query_vars_filter' );

/**
 * Function for `woocommerce_rest_query_vars` filter-hook.
 * 
 * @param array $valid_vars { Array of allowed WP_Query query vars.

```php
@param string $allowed_query_var The query var to allow.

}
*

  • @return array
    */
    function wp_kama_woocommerce_rest_query_vars_filter( $valid_vars ){

    // filter...
    return $valid_vars;
    }

    
    
$valid_vars(array)
{ Array of allowed WP_Query query vars.
@param string $allowed_query_var The query var to allow.

}

Where the hook is called

WC_REST_Posts_Controller::get_allowed_query_vars()
woocommerce_rest_query_vars
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-posts-controller.php 608
$valid_vars = apply_filters( 'woocommerce_rest_query_vars', $valid_vars );

Where the hook is used in WooCommerce

Usage not found.