?> ]" id="<?php echo $key; ?> " class="mdf_filter_select"> <option value="~"><?php echo $select_option_title; ?> </option> <?php foreach ($item['select'] as $value) { ?> <?php $items_count = -1; if ($widget_options['show_select_items_count']) { $items_count = MetaDataFilterHtml::get_item_posts_count($page_meta_data_filter, $search_key, sanitize_title($value), $slug, 'select'); if (!$items_count) { if ($widget_options['hide_items_where_count_0']) { continue; //IF NO ONE ITEM WHY NOT TO HIDE THIS?! } } } ?> <option <?php if ($items_count == 0 and $widget_options['show_select_items_count']) { ?> disabled<?php } ?> value="<?php
private static function get_tax_count($term, $tax_name, $widget_options, $html_type) { $count = 0; if (!$widget_options['taxonomies_options_show_count']) { return 0; } $slug = $widget_options['meta_data_filter_slug']; if ($widget_options['taxonomies_options_show_count']) { if ($widget_options['taxonomies_options_post_recount_dyn'] and self::is_page_mdf_data()) { //isset($_REQUEST['page_mdf']) instead of isset($_GET['page_mdf']) for ajax requests $_GLOBALS['MDF_TAX_USE_CACHE_ARRAY'] = false; $page_meta_data_filter = self::get_page_mdf_data(); if (isset($page_meta_data_filter['taxonomy'])) { $taxonomies = $page_meta_data_filter['taxonomy']; } if (!isset($taxonomies[$html_type])) { $taxonomies[$html_type] = array(); } if (!isset($taxonomies[$html_type][$tax_name]) or !is_array($taxonomies[$html_type][$tax_name])) { $taxonomies[$html_type][$tax_name] = array(); } if ($html_type == 'select') { if (!in_array($term['term_id'], $taxonomies[$html_type][$tax_name])) { $taxonomies[$html_type][$tax_name][] = $term['term_id']; } /* foreach ($taxonomies[$html_type][$tax_name] as $k => $v) { if($v == -1){ unset($taxonomies[$html_type][$tax_name][$k]); } } */ } if ($html_type == 'checkbox') { //if (!in_array($term['term_id'], $taxonomies[$html_type][$tax_name])) { $taxonomies[$html_type][$tax_name] = array(); $taxonomies[$html_type][$tax_name][] = $term['term_id']; //} //ATTENTION //look all taxes in selects and leave only last one for each tax name. Reason: http://clip2net.com/s/73w4a2 /* if (isset($taxonomies['select'])) { if (!empty($taxonomies['select']) AND is_array($taxonomies['select'])) { foreach ($taxonomies['select'] as $t_name => $tax_ids) { if (is_array($tax_ids) AND count($tax_ids) > 1) { foreach ($taxonomies['select'][$t_name] as $k => $id) { if (!$id) { unset($taxonomies['select'][$t_name][$k]); } } if (count($taxonomies['select'][$t_name]) > 1) { $last_tax_id = end($taxonomies['select'][$t_name]); $taxonomies['select'][$t_name] = array($last_tax_id); } } } } } * */ //************************************************ } $page_meta_data_filter['taxonomy'] = $taxonomies; $count = MetaDataFilterHtml::get_item_posts_count($page_meta_data_filter, 0, 0, $slug, 'tax_item'); $_GLOBALS['MDF_TAX_USE_CACHE_ARRAY'] = true; //!!!important, another way logic error $_GLOBALS['MDF_TAX_QUERY_ARRAY'] = array(); //!!!important, another way logic error } else { $tax_query_array = array(); $tax_query_array[] = array('taxonomy' => $tax_name, 'field' => 'term_id', 'terms' => array($term['term_id'])); $tax_query_array = apply_filters('mdf_filter_taxonomies2', $tax_query_array); //+++ $meta_query_array = array(); //for WOOCOMMERCE hidden products *** if ($slug == 'product' and class_exists('WooCommerce')) { $meta_query_array[] = array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'); //for out stock products if (self::get_setting('exclude_out_stock_products')) { $meta_query_array[] = array('key' => '_stock_status', 'value' => array('instock'), 'compare' => 'IN'); } //*** } //+++ //Trick - how to hide post from search $meta_query_array[] = array('key' => 'mdf_hide_post', 'value' => 'out', 'compare' => 'NOT EXISTS'); //*** fixed 20-10-2014 //print_r($widget_options);exit; //if (isset($widget_options['hide_meta_filter_values']) AND $widget_options['hide_meta_filter_values'] != 'true') { if ($widget_options['meta_data_filter_cat'] > 0) { $meta_query_array[] = array('key' => 'meta_data_filter_cat', 'value' => (int) $widget_options['meta_data_filter_cat'], 'compare' => '='); } //*** $args = array('post_type' => $slug, 'meta_query' => $meta_query_array, 'tax_query' => $tax_query_array, 'post_status' => array('publish'), 'nopaging' => true, 'fields' => 'ids', 'ignore_sticky_posts' => self::get_setting('ignore_sticky_posts'), 'suppress_filters' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'cache_results' => false, 'showposts' => false, 'comments_popup' => false); //WPML compatibility if (class_exists('SitePress')) { $args['lang'] = ICL_LANGUAGE_CODE; } $counter_obj = new WP_QueryMDFCounter($args); $count = $counter_obj->post_count; } } return $count; }
} ?> </option> <?php } ?> </select> </div> <?php } break; case 'checkbox': $shortcode_has_meta++; $items_count = -1; if ($widget_options['show_checkbox_items_count'] and !$this_item_is_hidden) { $items_count = MetaDataFilterHtml::get_item_posts_count($page_meta_data_filter, $search_key, 1, $slug, 'checkbox'); if (!$items_count) { if ($widget_options['hide_items_where_count_0']) { continue; //IF NO ONE ITEM WHY NOT TO HIDE THIS?! } } } //+++ $is_checked = isset($page_meta_data_filter[$meta_key]) ? (int) $page_meta_data_filter[$meta_key] : '~'; ?> <div class="mdf_input_container" <?php if ($this_item_is_hidden) { ?> style="display: none;"<?php