Inventory_Presser_Taxonomies::maybe_exclude_sold_vehicles( WP_Query $query )

Filter callback. Implements the “include sold vehicles” checkbox feature in vehicle archives and search results.


Parameters

$query

(WP_Query) (Required) The posts query object.


Return

(void)


Source

File: includes/class-taxonomies.php

	public function maybe_exclude_sold_vehicles( $query ) {
		if ( is_admin() || ! $query->is_main_query()
			|| ! ( is_search() || is_post_type_archive( INVP::POST_TYPE ) )
		) {
			return;
		}

		// If there is already a tax_query for taxonomy availability, abort.
		if ( $query->is_tax( 'availability' ) ) {
			return;
		}

		// If the checkbox to include sold vehicles is checked, abort.
		$plugin_settings = INVP::settings();
		if ( isset( $plugin_settings['include_sold_vehicles'] ) && $plugin_settings['include_sold_vehicles'] ) {
			return;
		}

		$query->set( 'tax_query', self::tax_query_exclude_sold() );
	}