<?php if (!defined('ABSPATH')) { die('No direct access allowed'); } ?> <?php wp_dropdown_categories(array('hide_empty' => 1, 'orderby' => 'name', 'taxonomy' => MetaDataFilterCore::$slug_cat, 'id' => MetaDataFilterCore::$slug_cat, 'show_option_none' => __('category is not selected', 'meta-data-filter'), 'name' => MetaDataFilterCore::$slug_cat, 'selected' => $cat_id)); ?> <div id="meta_data_filter_area"><?php echo MetaDataFilterPage::draw_back_page_items($cat_id, $post_id); ?> </div>
public static function get_meta_query_array($page_meta_data_filter) { if (isset($_GLOBALS['MDF_META_QUERY_ARRAY'])) { return $_GLOBALS['MDF_META_QUERY_ARRAY']; //query array is cached already } //+++ $meta_query_array = array(); if (!empty($page_meta_data_filter)) { //here we get all data about meta keys in constructor!!! $filter_post_blocks = array(); if (isset($page_meta_data_filter['filter_post_blocks'])) { $filter_post_blocks = $page_meta_data_filter['filter_post_blocks']; unset($page_meta_data_filter['filter_post_blocks']); unset($page_meta_data_filter['filter_post_blocks_toggles']); unset($page_meta_data_filter['filter_post_blocks_toggles_tax']); } $filter_post_blocks_data = array(); if (!empty($filter_post_blocks) and is_array($filter_post_blocks)) { foreach ($filter_post_blocks as $p_id) { $html_items = MetaDataFilterPage::get_html_items($p_id); if (is_array($html_items)) { $filter_post_blocks_data = array_merge($filter_post_blocks_data, $html_items); } } } //+++get widget options $widget_options = array(); if (isset($page_meta_data_filter['mdf_widget_options'])) { $widget_options = $page_meta_data_filter['mdf_widget_options']; unset($page_meta_data_filter['mdf_widget_options']); } //+++ if (isset($page_meta_data_filter['taxonomy'])) { unset($page_meta_data_filter['taxonomy']); } $meta_data_filter_bool = isset($_REQUEST['meta_data_filter_bool']) ? $_REQUEST['meta_data_filter_bool'] : 'AND'; //+++ if (is_array($page_meta_data_filter)) { foreach ($page_meta_data_filter as $key => $value) { if ($value and !empty($value)) { $html_item_data = array(); if (isset($filter_post_blocks_data[$key])) { $html_item_data = $filter_post_blocks_data[$key]; } //+++ $search_key = $key; if (isset($html_item_data['is_reflected']) and $html_item_data['is_reflected'] == 1) { $search_key = $html_item_data['reflected_key']; } if (!empty($html_item_data)) { switch ($html_item_data['type']) { case 'textinput': if (!empty($value)) { $textinput_target = isset($html_item_data['textinput_target']) ? $html_item_data['textinput_target'] : 'self'; $textinput_mode = isset($html_item_data['textinput_mode']) ? $html_item_data['textinput_mode'] : 'like'; $compare = 'LIKE'; if ($textinput_mode == 'exact') { $compare = '='; } switch ($textinput_target) { case 'self': $meta_query_array[] = array('key' => "{$search_key}", 'value' => "{$value}", 'compare' => $compare); break; case 'title': $_REQUEST['mdf_post_title_request'] = $compare . '^' . $search_key . '^' . $value; break; case 'content': $_REQUEST['mdf_post_content_request'] = $compare . '^' . $search_key . '^' . $value; break; case 'title_or_content': $_REQUEST['mdf_post_title_or_content_request'] = $compare . '^' . $search_key . '^' . $value; break; case 'title_and_content': $_REQUEST['mdf_post_title_and_content_request'] = $compare . '^' . $search_key . '^' . $value; break; } } break; case 'calendar': $from = 0; $to = 0; if (!empty($value) and is_array($value) and (!empty($value['from']) or !empty($value['to']))) { $from = intval($value['from']); $to = intval($value['to']); } if ($from > 0 or $to > 0) { if ($from == 0 and $to > 0) { $meta_query_array[] = array('key' => $search_key . "_to", 'value' => $to, 'compare' => "<="); } //+++ if ($from > 0 and $to == 0) { $meta_query_array[] = array('key' => $search_key . "_from", 'value' => $from, 'compare' => ">="); } //+++ if ($from == $to) { $meta_query_array[] = array('key' => $search_key . "_from", 'value' => $from, 'compare' => "<="); $meta_query_array[] = array('key' => $search_key . "_to", 'value' => $to, 'compare' => ">="); } //+++ //fixed 08-10-2014 if ($from < $to and $from > 0 and $to > 0) { /* $meta_query_array[] = array( 'key' => $search_key . "_from", 'value' => $from, 'compare' => ">=" ); $meta_query_array[] = array( 'key' => $search_key . "_to", 'value' => $to, 'compare' => "<=" ); */ $meta_query_array[] = array('key' => $search_key . "_from", 'value' => array($from, $to), 'compare' => "BETWEEN"); } } break; case 'slider': //slider if ($meta_data_filter_bool != 'OR') { //IMPORTANT! THIS IS FUSE! WITHOUT this: MODE 'OR' BREAK SQL EXEC if (!isset($html_item_data['slider_range_value'])) { $html_item_data['slider_range_value'] = 0; } if ($html_item_data['slider_range_value'] == 1) { //double value slider slider list($single_val, $f) = explode('^', $value); if ($single_val != 0) { $meta_query_array[] = array('key' => $search_key, 'value' => $single_val, 'type' => 'DECIMAL', 'compare' => '<='); $meta_query_array[] = array('key' => $search_key . '_to', 'value' => $single_val, 'type' => 'DECIMAL', 'compare' => '>='); } //print_r($meta_query_array);exit; } else { //usual 1 value slider list($s, $f) = explode('^', $value); //+++ list($min, $max) = explode('^', $html_item_data['slider']); if (floatval($max) === floatval($s)) { //to make range + $f = self::$max_int; } if (floatval($f) === floatval($max)) { $f = self::$max_int; } //+++ //http://codex.wordpress.org/Class_Reference/WP_Meta_Query /* $meta_query_array[] = array( 'key'=>$search_key, 'value'=>array( (float) $s, (float) $f ), 'type'=>'DECIMAL', 'compare'=>'BETWEEN' ); */ $meta_query_array[] = self::range_slider_multicontroller($widget_options['slug'], $search_key, (double) $s, (double) $f); } } break; case 'select': if (!isset($html_item_data['select_range_value'])) { $html_item_data['select_range_value'] = 0; } if ($html_item_data['select_range_value'] == 1) { //look in range (0-500, 501-1000, 1001-2000 and etc...) list($from, $to) = explode('-', $value); $meta_query_array[] = array('key' => $search_key, 'value' => array(floatval($from), floatval($to)), 'compare' => "BETWEEN", 'type' => 'DECIMAL'); } else { if ($value != '~') { $meta_query_array[] = array('key' => "{$search_key}", 'value' => "{$value}", 'compare' => '='); } } //~ - mean ANY in select and checkbox break; default: //checkbox if ($value != '~') { $meta_query_array[] = array('key' => "{$search_key}", 'value' => "{$value}", 'compare' => '='); } //~ - mean ANY in select and checkbox break; } } } } } } //lets cache it $_GLOBALS['MDF_META_QUERY_ARRAY'] = array($meta_query_array, $filter_post_blocks_data, $widget_options); return $_GLOBALS['MDF_META_QUERY_ARRAY']; }
function wpsm_specification_shortcode($atts, $content = null) { extract(shortcode_atts(array('id' => ''), $atts)); if (class_exists('MetaDataFilter')) { global $post; if (!isset($atts['id']) || $atts['id'] == '') { $id = get_the_ID(); } ob_start(); echo '<div class="rehub_specification"><div class="title_specification">' . __('Specification', 'rehub_framework') . '</div>'; MetaDataFilterPage::draw_single_page_items($id, false); echo '</div>'; $output = ob_get_contents(); ob_end_clean(); return $output; } }
public static function add_filter_item_to_widget($val = '') { $res = MetaDataFilterPage::get_html_sliders_by_filter_cat($_REQUEST['filter_cat']); ?> <?php if (!empty($res)) { ?> <li><select class="widefat" style="width: 90%; margin-bottom: 9px;" name="<?php echo $_REQUEST['field_name']; ?> []"> <?php foreach ($res as $key => $name) { ?> <option value="<?php echo $key; ?> " <?php if ($key == $val) { ?> selected=""<?php } ?> class="level-0"><?php _e($name); ?> </option> <?php } ?> </select> <a href="#" class="button mdf_delete_filter_item">x</a></li> <?php } ?> <?php if (isset($_REQUEST['action']) and $_REQUEST['action'] == 'mdf_add_filter_item_to_widget') { exit; } return; }
?> mdf_ajax_content_redraw<?php } ?> "> <div class="mdf_one_moment_txt"> <span><?php MetaDataFilterHtml::draw_tax_loader(); ?> </span> </div> <h6>Wordpress Meta Data and Taxonomies Filter</h6> <?php //+++ echo MetaDataFilterPage::draw_front_page_items($instance, $uniqid); $meta_data_filter_bool = 'AND'; if (isset($_GET['meta_data_filter_bool'])) { $meta_data_filter_bool = $_GET['meta_data_filter_bool']; } ?> <?php if ($instance['and_or'] == 'BOTH') { ?> <input type="radio" name="meta_data_filter_bool" value="OR" <?php if ($meta_data_filter_bool == 'OR') { ?> checked<?php } ?>
public static function post_features_panel() { $panel = ""; global $post; $post_id = 0; if (is_object($post)) { $post_id = $post->ID; } if (isset($_REQUEST['current_post_id'])) { $post_id = $_REQUEST['current_post_id']; } if ($post_id > 0) { static $title_collector = array(); if (in_array($post_id, $title_collector)) { return ""; } //+++ $data = array(); $data['cat_id'] = get_post_meta($post_id, self::$slug_cat, TRUE); $data['post_id'] = $post_id; //caching queries data while loop titles if (!isset(self::$cached_filter_posts[$data['cat_id']])) { self::$cached_filter_posts[$data['cat_id']] = MetaDataFilterPage::get_fiters_posts($data['cat_id']); } $data['filter_posts'] = self::$cached_filter_posts[$data['cat_id']]; $data['page_meta_data_filter'] = $data['cat_id'] > 0 ? get_post_meta($post_id, 'page_meta_data_filter', true) : array(); $title_collector[] = $post_id; $panel = self::render_html(self::get_application_path() . 'views/shortcode/post_features_panel.php', $data); } return $panel; }
<?php if (!defined('ABSPATH')) { die('No direct access allowed'); } if (is_singular($instance['meta_data_filter_slug'])) { ?> <div class="widget widget-meta-data-filter widget-meta-data-single"> <h3><?php echo $instance['title']; ?> </h3> <?php global $post; MetaDataFilterPage::draw_single_page_items($post->ID, $instance['show_absent_items']); ?> </div> <?php }
public static function get_ajax_auto_recount_data() { //for qtranslate if (!empty($_REQUEST['mdf_front_qtrans_lang'])) { if (function_exists('qtrans_enableLanguage')) { $GLOBALS['q_config']['language'] = $_REQUEST['mdf_front_qtrans_lang']; } } //+++ //for WPML if (!empty($_REQUEST['mdf_front_wpml_lang'])) { if (class_exists('SitePress')) { global $sitepress; $sitepress->switch_lang($_REQUEST['mdf_front_wpml_lang']); } } //+++ //when we do sort before searching if ((int) $_REQUEST['mdf_is_search_going'] == 0) { if ($_REQUEST['mdf_tmp_order'] != '0' and $_REQUEST['mdf_tmp_orderby'] != '0') { $_REQUEST['order'] = self::$default_order = $_REQUEST['mdf_tmp_order']; $_REQUEST['order_by'] = self::$default_order_by = $_REQUEST['mdf_tmp_orderby']; } } //+++ $_REQUEST['no_wp_die'] = TRUE; $_REQUEST['mdf_ajax_request'] = TRUE; $link_data = explode('&', self::encode_search_get_params()); $data = array(); if (!empty($link_data)) { foreach ($link_data as $pair) { $tmp = explode('=', $pair); $data[$tmp[0]] = $tmp[1]; } } //+++ $_REQUEST['mdf_cat'] = $data['mdf_cat']; $_REQUEST['page_mdf'] = $data['page_mdf']; $slug = $_REQUEST['slug']; //print_r($_REQUEST); $mdf_data = self::get_page_mdf_data(); //+++ set_query_var('paged', 0); $_GET['slg'] = $slug; $_REQUEST['mdf_do_not_render_shortcode_tpl'] = TRUE; //*** do_shortcode('[meta_data_filter_results]'); $result = array(); if ($_REQUEST['type'] == 'shortcode') { $result['form'] = do_shortcode('[mdf_search_form id="' . $_REQUEST['shortcode_id'] . '"]'); } else { ob_start(); self::dynamic_sidebar($_REQUEST['widget_id'], $_REQUEST['sidebar_id']); $result['form'] = ob_get_clean(); } //return data if we use ajax content redrawing if ($_REQUEST['mdf_ajax_content_redraw'] and isset($_REQUEST['shortcode_txt'])) { $result['content'] = do_shortcode("[" . $_REQUEST['shortcode_txt'] . "]"); } echo json_encode($result); exit; }
<?php if (!defined('ABSPATH')) { die('No direct access allowed'); } ?> <?php $res = array(); if (!empty($filter_posts)) { if (is_array($filter_posts)) { foreach ($filter_posts as $pid) { $tmp = MetaDataFilterPage::get_html_items($pid); if (!empty($tmp)) { if (is_array($tmp)) { foreach ($tmp as $key => $value) { $res[$key] = $value; } } } } } } ?> <?php if (isset($_REQUEST['in_essentil_block'])) { ?> <?php