Inventory_Presser_Additional_Listings_Pages::get_current_matched_rule( WP_Query $query = null )
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.
Parameters Parameters
- $query
-
(WP_Query) (Optional)
Default value: null
Return Return
(array|false)
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 and active? if ( ! self::is_valid_rule( $additional_listing ) || ! self::is_active_rule( $additional_listing ) ) { continue; } // our URL path will match the beginning of the rewrite rule. if ( substr( $wp->matched_rule, 0, strlen( $additional_listing['url_path'] ) ) === $additional_listing['url_path'] ) { return $additional_listing; } } return false; }
Expand full source codeCollapse full source codeView on Github