function __construct($slug_mode = false, $format = false, $taxonomy = 'category', $selected_cats = array(), $style = '', $class = '', $label_style = '', $label_class = '' ) {
			global $WP_Views;
			$this->slug_mode = $slug_mode;
			$this->format = $format;
			$this->counters = ( $this->format && strpos( $this->format, '%%COUNT%%' ) !== false ) ? true : false;
			$view_settings = $WP_Views->get_view_settings();
			$this->dependant = false;
			$this->empty_action = 'none';
            $this->style = $style;
            $this->input_class = $class;
            $this->label_style = $label_style;
            $this->label_class = $label_class;
			if ( isset( $view_settings['dps'] ) && is_array( $view_settings['dps'] ) && isset( $view_settings['dps']['enable_dependency'] ) && $view_settings['dps']['enable_dependency'] == 'enable' ) {
				$this->dependant = true;
				$force_disable_dependant = $WP_Views->get_force_disable_dependant_parametric_search();
				if ( $force_disable_dependant ) {
					$this->dependant = false;
				} else {
					$this->empty_action = 'hide';
					if ( isset( $view_settings['dps']['empty_checkboxes'] ) && $view_settings['dps']['empty_checkboxes'] == 'disable' ) {
						$this->empty_action = 'disable';
					}
				}
			}
			$this->show = true;
			$this->posts_to_taxes = array();
			if ( $this->dependant || $this->counters ) {
				// Construct $this->posts_to_taxes
				$operator = isset( $view_settings['taxonomy-' . $taxonomy . '-attribute-operator'] ) ? $view_settings['taxonomy-' . $taxonomy . '-attribute-operator'] : 'IN';
				if ( empty( $selected_cats ) || $operator == 'AND' ) {
					// This is when there is no non-default selected
					global $wp_object_cache;
					$wpv_data_cache = isset( $wp_object_cache->cache ) ? $wp_object_cache->cache : array();
					if ( isset( $wpv_data_cache[$taxonomy . '_relationships'] ) && is_array( $wpv_data_cache[$taxonomy . '_relationships'] ) ) {
						foreach ( $wpv_data_cache[$taxonomy . '_relationships'] as $pid => $tax_array ) {
							if ( is_multisite() ) {
								$blog_id = get_current_blog_id();
								$pid = str_replace( $blog_id . ':', '', $pid );
							}
							if ( in_array( $pid, $WP_Views->returned_ids_for_parametric_search ) && is_array( $tax_array ) && count( $tax_array ) > 0 ) {
								$this_post_taxes = wp_list_pluck( $tax_array, 'term_id', 'term_id' );
								$this->posts_to_taxes[$pid] = $this_post_taxes;
							}
						}
					}
				} else {
					// When there is a selected value, create a pseudo-cache based on all the other filters
					$query = wpv_get_dependant_view_query_args();
					$aux_cache_query = null;
					if ( isset( $query['tax_query'] ) && is_array( $query['tax_query'] ) ) {
						foreach ( $query['tax_query'] as $qt_index => $qt_val ) {
							if ( is_array( $qt_val ) && isset( $qt_val['taxonomy'] ) && $qt_val['taxonomy'] == $taxonomy ) {
								unset( $query['tax_query'][$qt_index] );
							}
						}
					}
					$aux_cache_query = new WP_Query($query);
					if ( is_array( $aux_cache_query->posts ) && !empty( $aux_cache_query->posts ) ) {
						$f_taxes = array( $taxonomy );
						$wpv_data_cache = wpv_custom_cache_metadata( $aux_cache_query->posts, array( 'tax' => $f_taxes ) );
						if ( isset( $wpv_data_cache[$taxonomy . '_relationships'] ) && is_array( $wpv_data_cache[$taxonomy . '_relationships'] ) ) {
							foreach ( $wpv_data_cache[$taxonomy . '_relationships'] as $pid => $tax_array ) {
								if ( is_array( $tax_array ) && count( $tax_array ) > 0 ) {
									$this_post_taxes = wp_list_pluck( $tax_array, 'term_id', 'term_id' );
									$this->posts_to_taxes[$pid] = $this_post_taxes;
								}
							}
						}
					}
				}
			}
		}
function wpv_filter_extend_query_for_parametric_and_counters($post_query, $view_settings, $id)
{
    $dps_enabled = false;
    $counters_enabled = false;
    if (!isset($view_settings['dps']) || !is_array($view_settings['dps'])) {
        $view_settings['dps'] = array();
    }
    if (isset($view_settings['dps']['enable_dependency']) && $view_settings['dps']['enable_dependency'] == 'enable') {
        $dps_enabled = true;
        $controls_per_kind = wpv_count_filter_controls($view_settings);
        $controls_count = 0;
        $no_intersection = array();
        if (!isset($controls_per_kind['error'])) {
            //	$controls_count = array_sum( $controls_per_kind );
            $controls_count = $controls_per_kind['cf'] + $controls_per_kind['tax'] + $controls_per_kind['pr'] + $controls_per_kind['search'];
            if ($controls_per_kind['cf'] > 1 && (!isset($view_settings['custom_fields_relationship']) || $view_settings['custom_fields_relationship'] != 'AND')) {
                $no_intersection[] = __('custom field', 'wpv-views');
            }
            if ($controls_per_kind['tax'] > 1 && (!isset($view_settings['taxonomy_relationship']) || $view_settings['taxonomy_relationship'] != 'AND')) {
                $no_intersection[] = __('taxonomy', 'wpv-views');
            }
        } else {
            $dps_enabled = false;
        }
        if ($controls_count > 0) {
            if (count($no_intersection) > 0) {
                $dps_enabled = false;
            }
        } else {
            $dps_enabled = false;
        }
    }
    if (!isset($view_settings['filter_meta_html'])) {
        $view_settings['filter_meta_html'] = '';
    }
    if (strpos($view_settings['filter_meta_html'], '%%COUNT%%') !== false) {
        $counters_enabled = true;
    }
    global $WP_Views;
    if (!$dps_enabled && !$counters_enabled) {
        // Set the force value
        $WP_Views->set_force_disable_dependant_parametric_search(true);
        return $post_query;
    }
    // If after all we have dps, we need to populate the $wp_object_cache
    // Check if we need to create all the cache or just for the missing ones
    global $wp_object_cache;
    $cache_exclude_queried_posts = false;
    // we will only exclude already queried posts if there are any queried posts and the native cache exists (so they are already cached)
    $cache_use_native = true;
    if (is_object($wp_object_cache)) {
        if (isset($wp_object_cache->cache)) {
            // existing queried posts were already cached
            if (empty($post_query)) {
                $cache_exclude_queried_posts = false;
                // we passed an empty $post_query so there are no queried posts at all (surely coming from a form View shortcode)
            } else {
                $cache_exclude_queried_posts = true;
            }
        } else {
            $wp_object_cache->cache = array();
            $cache_exclude_queried_posts = false;
            // already queried posts were not cached where we need them
            $cache_use_native = false;
            // the native $wp_object_cache->cache property is not set, so we will recreate it instead of naturally caching metadata
        }
    }
    // In any case, we need to mimic the process that we used to generate the $query
    $view_settings_defaults = array('post_type' => 'any', 'orderby' => 'post-date', 'order' => 'DESC', 'paged' => '1', 'posts_per_page' => -1);
    extract($view_settings_defaults);
    $view_settings['view_id'] = $id;
    extract($view_settings, EXTR_OVERWRITE);
    $query = array('posts_per_page' => $posts_per_page, 'paged' => $paged, 'post_type' => $post_type, 'order' => $order, 'suppress_filters' => false, 'ignore_sticky_posts' => true);
    // Add special check for media (attachments) as their default status in not usually published
    if (sizeof($post_type) == 1 && $post_type[0] == 'attachment') {
        $query['post_status'] = 'any';
        // Note this can be overriden by adding a status filter.
    }
    $query = apply_filters('wpv_filter_query', $query, $view_settings, $id);
    // Now we have the $query as in the original one
    // We now need to overwrite the limit, offset, paged and pagination options
    // Also, we set it to just return the IDs
    $query['posts_per_page'] = -1;
    $query['ĺimit'] = -1;
    $query['paged'] = 1;
    $query['offset'] = 0;
    $query['fields'] = 'ids';
    if ($cache_exclude_queried_posts) {
        // do not query again already queried and cached posts
        $already = array();
        if (isset($post_query->posts) && !empty($post_query->posts)) {
            foreach ((array) $post_query->posts as $post_object) {
                $already[] = $post_object->ID;
            }
        }
        $WP_Views->returned_ids_for_parametric_search = $already;
        if (isset($query['pr_filter_post__in'])) {
            $query['post__in'] = $query['pr_filter_post__in'];
        } else {
            // If just for the missing ones, generate the post__not_in argument
            if (isset($query['post__not_in'])) {
                $query['post__not_in'] = array_merge((array) $query['post__not_in'], (array) $already);
            } else {
                $query['post__not_in'] = (array) $already;
            }
            // And adjust on the post__in argument
            if (isset($query['post__in'])) {
                $query['post__in'] = array_diff((array) $query['post__in'], (array) $query['post__not_in']);
                //unset( $query['post__in'] );
            }
        }
    }
    // Perform the query
    $aux_cache_query = new WP_Query($query);
    // In case we need to recreate our own cache object, we do not need to load there all the postmeta and taxonomy data, just for the elements involved in parametric search controls
    $filter_c_mode = isset($view_settings['filter_controls_mode']) && is_array($view_settings['filter_controls_mode']) ? $view_settings['filter_controls_mode'] : array();
    $filter_c_name = isset($view_settings['filter_controls_field_name']) && is_array($view_settings['filter_controls_field_name']) ? $view_settings['filter_controls_field_name'] : array();
    $f_taxes = array();
    $f_fields = array();
    foreach ($filter_c_mode as $f_index => $f_mode) {
        if (isset($filter_c_name[$f_index])) {
            switch ($f_mode) {
                case 'slug':
                    $f_taxes[] = $filter_c_name[$f_index];
                    break;
                case 'cf':
                    $f_fields[] = $filter_c_name[$f_index];
                    break;
                case 'rel':
                    if (function_exists('wpcf_pr_get_belongs')) {
                        $returned_post_types = $view_settings['post_type'];
                        $returned_post_type_parents = array();
                        if (empty($returned_post_types)) {
                            $returned_post_types = array('any');
                        }
                        foreach ($returned_post_types as $returned_post_type_slug) {
                            $parent_parents_array = wpcf_pr_get_belongs($returned_post_type_slug);
                            if ($parent_parents_array != false && is_array($parent_parents_array)) {
                                $returned_post_type_parents = array_merge($returned_post_type_parents, array_values(array_keys($parent_parents_array)));
                            }
                        }
                        foreach ($returned_post_type_parents as $parent_to_cache) {
                            $f_fields[] = '_wpcf_belongs_' . $parent_to_cache . '_id';
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
    // If we are using the native caching, update the cache for the posts returned by the aux query
    if (is_array($aux_cache_query->posts) && !empty($aux_cache_query->posts)) {
        $WP_Views->returned_ids_for_parametric_search = array_merge($WP_Views->returned_ids_for_parametric_search, $aux_cache_query->posts);
        $WP_Views->returned_ids_for_parametric_search = array_unique($WP_Views->returned_ids_for_parametric_search);
        if ($cache_use_native) {
            // If we are using the native caching, update the cache for the posts returned by the aux query
            update_postmeta_cache($aux_cache_query->posts);
            update_object_term_cache($aux_cache_query->posts, $view_settings['post_type']);
        } else {
            // Else, we need to fake an $wp_object_cache->cache
            $f_data = array('cf' => $f_fields, 'tax' => $f_taxes);
            $cache_combined = wpv_custom_cache_metadata($aux_cache_query->posts, $f_data);
            $wp_object_cache->cache = $cache_combined;
        }
    }
    return $post_query;
}