Query::filter_empty_query_vars( array $vars )

Summary

Remove empty query vars from request vars


Description

The main purpose here is to avoid WP thinking we’re on a search page because the product archive filters left a “s=” in the URL.


Parameters

$vars

(array) (Required)


Return

(array)


Source

File: src/BigCommerce/Post_Types/Product/Query.php

	public function filter_empty_query_vars( $vars ) {
		foreach ( [ 's', 'bc-sort', Brand::NAME, Product_Category::NAME ] as $query_var ) {
			if ( isset( $vars[ $query_var ] ) && ( empty( $vars[ $query_var ] ) || $query_var === '0' ) ) {
				unset( $vars[ $query_var ] );
			}
		}

		return $vars;
	}

User Contributed Notes

You must log in before being able to contribute a note or feedback.