Пример #1
0
                            $section_max_height = isset($widget_options['taxonomies_options_checkbox_max_height'][$tax_name]) ? $widget_options['taxonomies_options_checkbox_max_height'][$tax_name] : 0;
                            ?>
                                                <input type="hidden" class="mdf_filter_post_blocks_toggles" name="mdf[filter_post_blocks_toggles_tax][<?php 
                            echo $tax_name;
                            ?>
]" value="<?php 
                            echo $section_tax_toggle;
                            ?>
" />

                                                <h4 class="data-filter-section-title"><?php 
                            $tax_title = "";
                            if (isset($widget_options['taxonomies_options_tax_title'][$tax_name]) and !empty($widget_options['taxonomies_options_tax_title'][$tax_name])) {
                                $tax_title = $widget_options['taxonomies_options_tax_title'][$tax_name];
                            } else {
                                $tax_title = __(MetaDataFilterHtml::get_term_label_by_name($tax_name));
                            }
                            echo $tax_title;
                            MetaDataFilter::draw_front_toggle($section_tax_toggle);
                            ?>
</h4>
                                                <div class="mdf_tax_filter_section mdf_tax_filter_section_<?php 
                            echo $tax_name;
                            ?>
 <?php 
                            if ($section_max_height) {
                                ?>
mdf_filter_section_scrolled<?php 
                            }
                            ?>
 <?php 
Пример #2
0
    private static function draw_term_childs_select($terms, $mdf_parent_id = 0, $selected_id = 0, $hide, $tax_name = 0, $is_ajax = true, $hide_string_ids = '', $widget_options = array())
    {
        if (!empty($terms)) {
            $select_size = isset($widget_options['taxonomies_options_select_size'][$tax_name]) ? (int) $widget_options['taxonomies_options_select_size'][$tax_name] : 1;
            ?>
            <select size="<?php 
            echo $select_size;
            ?>
" name="mdf[taxonomy][select][<?php 
            echo $tax_name;
            ?>
][]" class="mdf_taxonomy" data-tax-name="<?php 
            echo $tax_name;
            ?>
" data-hide="<?php 
            echo $hide_string_ids;
            ?>
">
                <option value="-1">
                    <?php 
            $tax_title = "";
            $tax_title_busy_key = 0;
            $tax_title_array = "";
            if (isset($widget_options['taxonomies_options_tax_title'][$tax_name]) and !empty($widget_options['taxonomies_options_tax_title'][$tax_name])) {
                $tax_title = $widget_options['taxonomies_options_tax_title'][$tax_name];
                if (substr_count($tax_title, '^')) {
                    $tax_title_array = explode('^', $tax_title);
                    $tax_title = explode('^', $tax_title);
                    if ($mdf_parent_id == 0) {
                        $tax_title = $tax_title[0];
                    } else {
                        $parent = get_term_by('id', $mdf_parent_id, $tax_name);
                        $index = 1;
                        while ($parent->parent != 0) {
                            $parent = get_term_by('id', $parent->parent, $tax_name);
                            $index++;
                        }
                        if (isset($tax_title[$index])) {
                            $tax_title = $tax_title[$index];
                            $tax_title_busy_key = $index;
                        } else {
                            $tax_title = __(MetaDataFilterHtml::get_term_label_by_name($tax_name));
                        }
                    }
                }
            } else {
                if (isset($widget_options['shortcode_taxonomies_title'][$tax_name]) and !empty($widget_options['shortcode_taxonomies_title'][$tax_name])) {
                    //for shortcodes
                    $tax_title = $widget_options['shortcode_taxonomies_title'][$tax_name];
                    if (substr_count($tax_title, '^')) {
                        $tax_title_array = explode('^', $tax_title);
                        $tax_title = explode('^', $tax_title);
                        if ($mdf_parent_id == 0) {
                            $tax_title = $tax_title[0];
                        } else {
                            $parent = get_term_by('id', $mdf_parent_id, $tax_name);
                            $index = 1;
                            while ($parent->parent != 0) {
                                $parent = get_term_by('id', $parent->parent, $tax_name);
                                $index++;
                            }
                            if (isset($tax_title[$index])) {
                                $tax_title = $tax_title[$index];
                                $tax_title_busy_key = $index;
                            } else {
                                $tax_title = __(MetaDataFilterHtml::get_term_label_by_name($tax_name));
                            }
                        }
                    }
                } else {
                    $tax_title = __(MetaDataFilterHtml::get_term_label_by_name($tax_name));
                }
            }
            echo $tax_title;
            ?>
                </option>
                <?php 
            foreach ($terms as $term_id => $term) {
                ?>
                    <?php 
                //do not output hidden terms
                if (in_array($term_id, $hide)) {
                    continue;
                }
                ?>
                    <?php 
                $tax_count = -1;
                $tax_count_strting = "";
                $show_option = true;
                if ($widget_options['taxonomies_options_show_count'] == 'true' or $widget_options['taxonomies_options_show_count'] == 1) {
                    $tax_count = self::get_tax_count($term, $tax_name, $widget_options, 'select');
                    $tax_count_strting = ' (' . $tax_count . ')';
                    if ($widget_options['taxonomies_options_post_recount_dyn'] == 'true' or $widget_options['taxonomies_options_post_recount_dyn'] == 1) {
                        if ($widget_options['taxonomies_options_hide_terms_0'] == 'true' or $widget_options['taxonomies_options_hide_terms_0'] == 1) {
                            if (!$tax_count) {
                                $show_option = false;
                            }
                        }
                    }
                }
                ?>

                    <?php 
                if ($show_option) {
                    ?>
                        <option <?php 
                    if ($tax_count == 0 and ($widget_options['taxonomies_options_show_count'] == 'true' or $widget_options['taxonomies_options_show_count'] == 1)) {
                        ?>
disabled<?php 
                    }
                    ?>
 value="<?php 
                    echo $term_id;
                    ?>
" <?php 
                    if ($selected_id == $term_id) {
                        ?>
selected<?php 
                    }
                    ?>
>
                            <?php 
                    _e($term['name']);
                    echo $tax_count_strting;
                    ?>
                        </option>
                    <?php 
                }
                ?>


                <?php 
            }
            ?>
            </select>


            <?php 
            $show_child_terms1 = (isset($widget_options['taxonomies_options_show_child_terms']) and $widget_options['taxonomies_options_show_child_terms'][$tax_name] == 1) ? true : false;
            $show_child_terms2 = (isset($widget_options['taxonomies_show_child_terms'][$tax_name]) and $widget_options['taxonomies_show_child_terms'][$tax_name] == 1) ? true : false;
            $show_child_terms = ($show_child_terms1 or $show_child_terms2);
            ?>

            <?php 
            if ($show_child_terms) {
                ?>

                <?php 
                //if($is_ajax):
                ?>
                <div class="mdf_taxonomy_child_container"><?php 
                MetaDataFilterHtml::draw_tax_loader();
                ?>
</div>
                <?php 
                //endif;
                ?>


                <?php 
                $show_butaforia = false;
                if (!empty($tax_title_array) and is_array($tax_title_array)) {
                    foreach ($tax_title_array as $key => $value) {
                        if ($key <= $tax_title_busy_key) {
                            unset($tax_title_array[$key]);
                        } else {
                            break;
                        }
                    }
                    if ($selected_id == -1 or $selected_id == 0) {
                        $show_butaforia = true;
                    }
                    if (count($tax_title_array) == 0) {
                        $show_butaforia = true;
                    }
                }
                ?>


                <?php 
                if ($show_butaforia) {
                    ?>
                    <?php 
                    foreach ($tax_title_array as $k => $title) {
                        ?>
                        <div class="mdf_taxonomy_child_container2">
                            <select data-level-id="<?php 
                        echo $k + 1;
                        ?>
" disabled="disabled">
                                <option value="-1"><?php 
                        echo $title;
                        ?>
</option>
                            </select>
                        </div>
                    <?php 
                    }
                    ?>
                <?php 
                }
                ?>


            <?php 
            } else {
                ?>
                <?php 
                if ($is_ajax) {
                    ?>
                    <div class="mdf_taxonomy_child_container"><?php 
                    MetaDataFilterHtml::draw_tax_loader();
                    ?>
</div>
                <?php 
                }
                ?>
            <?php 
            }
            ?>




            <?php 
        }
        if ($is_ajax) {
            exit;
        }
    }
Пример #3
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 '+'
         }
     }
 }