Exemple #1
0
 public static function init()
 {
     parent::init();
     add_action('wp_ajax_meta_data_filter_add_item_to_data_group', array(__CLASS__, 'add_item_to_data_group'));
     self::$items_types = array('checkbox' => __("checkbox", 'meta-data-filter'), 'select' => __("drop-down", 'meta-data-filter'), 'slider' => __("range slider", 'meta-data-filter'), 'taxonomy' => __("taxonomy", 'meta-data-filter'), 'textinput' => __("textinput", 'meta-data-filter'), 'calendar' => __("calendar", 'meta-data-filter'), 'map' => __("map", 'meta-data-filter'));
     self::$tax_items_types = array('select' => __("drop-down", 'meta-data-filter'), 'checkbox' => __("checkbox", 'meta-data-filter'));
 }
Exemple #2
0
 function form($instance)
 {
     //Defaults
     $defaults = array('title' => __('Single Post Meta Data', 'meta-data-filter'), 'show_absent_items' => 'false', 'meta_data_filter_slug' => 'post');
     $instance = wp_parse_args((array) $instance, $defaults);
     $args = array();
     $args['instance'] = $instance;
     $args['widget'] = $this;
     wp_enqueue_script('meta_data_filter_widget', MetaDataFilterCore::get_application_uri() . 'js/widget_back.js', array('jquery'));
     echo MetaDataFilterHtml::render_html(MetaDataFilterCore::get_application_path() . 'views/widgets/post_data_form.php', $args);
 }
Exemple #3
0
 public static function mdtf_catalog_ordering($atts = array())
 {
     if (self::is_page_mdf_data()) {
         $page_meta_data_filter = self::get_page_mdf_data();
         list($meta_query_array, $filter_post_blocks_data, $widget_options) = MetaDataFilterHtml::get_meta_query_array($page_meta_data_filter);
         if (isset($widget_options['woo_search_panel_id']) and intval($widget_options['woo_search_panel_id']) > 0) {
             remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30);
             remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
             $post_id = intval($widget_options['woo_search_panel_id']);
             $data = array();
             $data['settings'] = self::get_woo_search_values($post_id);
             if (!empty($data['settings']) and is_array($data['settings'])) {
                 $data['order_by'] = isset($_REQUEST['order_by']) ? $_REQUEST['order_by'] : self::$default_order_by;
                 $data['order'] = isset($_REQUEST['order']) ? $_REQUEST['order'] : self::$default_order;
                 $panel_type = get_post_meta($post_id, 'panel_type', TRUE);
                 if (!$panel_type) {
                     $panel_type = 'select';
                 }
                 //***
                 if ($panel_type == 'select') {
                     echo self::render_html(self::get_application_path() . 'views/sort_panel/select_filter_panel.php', $data);
                 } else {
                     echo self::render_html(self::get_application_path() . 'views/sort_panel/button_filter_panel.php', $data);
                 }
                 //+++
                 $show_results_tax_navigation = get_post_meta($post_id, 'show_results_tax_navigation', true);
                 if ($show_results_tax_navigation) {
                     echo do_shortcode('[mdf_results_tax_navigation]');
                 }
             }
         }
     } else {
         $post_id = 0;
         if (isset($atts['panel_id'])) {
             $post_id = $atts['panel_id'];
         } else {
             $post_id = (int) self::get_setting('default_sort_panel');
         }
         if (isset($_REQUEST['mdf_panel_id']) and $_REQUEST['mdf_panel_id'] > 0) {
             $post_id = $_REQUEST['mdf_panel_id'];
         }
         //+++
         $data = array();
         $data['settings'] = self::get_woo_search_values($post_id);
         if (!empty($data['settings']) and is_array($data['settings'])) {
             $data['order_by'] = isset($_REQUEST['order_by']) ? $_REQUEST['order_by'] : self::$default_order_by;
             $data['order'] = isset($_REQUEST['order']) ? $_REQUEST['order'] : self::$default_order;
             $panel_type = get_post_meta($post_id, 'panel_type', TRUE);
             if (!$panel_type) {
                 $panel_type = 'select';
             }
             //***
             if ($panel_type == 'select') {
                 echo self::render_html(self::get_application_path() . 'views/sort_panel/select_filter_panel.php', $data);
             } else {
                 echo self::render_html(self::get_application_path() . 'views/sort_panel/button_filter_panel.php', $data);
             }
             //+++
             $show_results_tax_navigation = get_post_meta($post_id, 'show_results_tax_navigation', true);
             if ($show_results_tax_navigation) {
                 echo do_shortcode('[mdf_results_tax_navigation]');
             }
         }
     }
 }
Exemple #4
0
?>
";
    var mdf_lang_cancel = "<?php 
_e("Cancel", 'meta-data-filter');
?>
";
    var mdf_lang_close = "<?php 
_e("Close", 'meta-data-filter');
?>
";
    var mdf_lang_apply = "<?php 
_e("Apply", 'meta-data-filter');
?>
";
    var mdf_tax_loader = '<?php 
MetaDataFilterHtml::draw_tax_loader();
?>
';
    var mdf_week_first_day =<?php 
echo get_option('start_of_week');
?>
;
    var mdf_calendar_date_format = "<?php 
echo (isset($settings['calendar_date_format']) and !empty($settings['calendar_date_format'])) ? $settings['calendar_date_format'] : 'mm/dd/yy';
?>
";
    var mdf_site_url = "<?php 
echo site_url();
?>
";
    var mdf_plugin_url = "<?php 
                ?>
]" 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 
Exemple #6
0
 public static function results_tax_navigation()
 {
     if (self::is_page_mdf_data() and isset($_REQUEST['meta_data_filter_args']) and isset($_REQUEST['meta_data_filter_args']['tax_query'])) {
         $taxes = $_REQUEST['meta_data_filter_args']['tax_query'];
         unset($taxes['relation']);
         if (!empty($taxes)) {
             $tmp = array();
             foreach ($taxes as $tax) {
                 $tmp[$tax['taxonomy']] = $tax['terms'];
             }
             //+++
             $output_string = "";
             // and prepare our output buffer
             foreach ($tmp as $tax_name => $terms) {
                 $output = MetaDataFilterHtml::get_term_label_by_name($tax_name) . ": ";
                 // display the name followed by ":"
                 if (is_array($terms)) {
                     foreach ($terms as $term_id) {
                         // now loop through all the slugs
                         $term = get_term_by('id', $term_id, $tax_name);
                         // and based on that slug, get the term object
                         $output .= '<a target="_blank" href="' . get_term_link($term, $tax_name) . '">' . $term->name . '</a>&nbsp;&nbsp;';
                         // and add the term's name to our output buffer followed by a comma (,)
                     }
                 } else {
                     $term = get_term_by('id', $terms, $tax_name);
                     // and based on that slug, get the term object
                     //$output .= $term->name . ', '; // and add the term's name to our output buffer followed by a comma (,)
                     $parents = self::get_taxonomy_parents_all($term->term_id, $tax_name);
                     $buffer = array();
                     foreach ($parents as $term) {
                         $buffer[] = '<a target="_blank" href="' . get_term_link($term, $tax_name) . '">' . $term->name . '</a>&nbsp;&nbsp;';
                     }
                     $buffer = array_reverse($buffer);
                     $buffer = implode(" -> ", $buffer);
                     $output .= $buffer;
                 }
                 $output_string .= rtrim($output, ", ") . " + ";
                 // when we're finished with terms, remove the last comma
             }
             return rtrim($output_string, " + ");
             // when we're finished with taxonomies, remove the last '+'
         }
     }
 }
Exemple #7
0
?>
<script type="text/javascript">
    var mdf_current_post_id=<?php 
echo $post->ID;
?>
;
</script>
<ul id="data_group_items">
    <?php 
if (!empty($html_items) and is_array($html_items)) {
    ?>
        <?php 
    foreach ($html_items as $key => $value) {
        ?>
            <li class="admin-drag-holder mdf_filter_item"><?php 
        echo MetaDataFilterHtml::render_html(MetaDataFilter::get_application_path() . 'views/add_item_to_data_group.php', array('itemdata' => $value, 'uniqid' => $key));
        ?>
</li>
        <?php 
    }
    ?>
    <?php 
}
?>
</ul>

<br />
<a class="button button-primary button-medium add_item_to_data_group" data-add-to='bottom' href="#"><?php 
_e("Append Filter Item", 'meta-data-filter');
?>
</a><br />
Exemple #8
0
     if (!empty($page_meta_data_filter)) {
         $taxonomies = array();
         if (isset($page_meta_data_filter['taxonomy'])) {
             $taxonomies = $page_meta_data_filter['taxonomy'];
             unset($page_meta_data_filter['taxonomy']);
         }
         //+++
         list($meta_query_array, $filter_post_blocks_data, $widget_options) = MetaDataFilterHtml::get_meta_query_array($page_meta_data_filter);
         $meta_data_filter_bool = isset($_GET['meta_data_filter_bool']) ? $_GET['meta_data_filter_bool'] : 'AND';
     }
 } else {
     return;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 //Taxonomies in process ...
 $tax_query_array = MetaDataFilterHtml::get_tax_query_array($taxonomies);
 $mdf_tax_bool = 'AND';
 if (!empty($tax_query_array)) {
     $mdf_tax_bool = isset($_GET['mdf_tax_bool']) ? $_GET['mdf_tax_bool'] : 'AND';
 }
 //*** additional taxonomies for Pre-sale question:
 //I have woocommerce with brands plugin installed, each brand page shows the products of this brand,
 //can this plugin filter those products based on category?
 if (isset($widget_options['additional_taxonomies']) and !empty($widget_options['additional_taxonomies'])) {
     MetaDataFilter::add_additional_taxonomies($widget_options['additional_taxonomies']);
 }
 //***
 $tax_query_array = apply_filters('mdf_filter_taxonomies', $tax_query_array);
 //for 3 part scripts
 $tax_query_array = apply_filters('mdf_filter_taxonomies2', $tax_query_array);
 //for 3 part scripts