Inventory_Presser_Additional_Listings_Pages::get_current_matched_rule( WP_Query $query = null )

get_current_matched_rule


Description Description

If the current request is for one of our additional listing pages, return that listings page rule so it's easy to extract or replicate the meta query.


Top ↑

Parameters Parameters

$query

(WP_Query) (Optional)

Default value: null


Top ↑

Return Return

(array|false)


Top ↑

Source Source

File: includes/class-additional-listings-pages.php

	public static function get_current_matched_rule( $query = null )
	{
		if( null === $query )
		{
			global $wp_query;
			$query = $wp_query;
		}

		//Must be the main query on a vehicle archive request
		if ( ! $query->is_main_query() || ! is_post_type_archive( INVP::POST_TYPE ) )
		{
			return false;
		}

		global $wp;
		foreach( self::additional_listings_pages_array() as $additional_listing )
		{
			//is this rule valid?
			if( ! self::is_valid_rule( $additional_listing ) )
			{
				continue;
			}

			//our URL path will match the beginning of the rewrite rule
			if( $additional_listing['url_path'] == substr( $wp->matched_rule, 0, strlen( $additional_listing['url_path'] ) ) )
			{
				return $additional_listing;
			}
		}
		return false;
	}