function widget($args, $instance) { extract($args); echo $before_widget; if ($instance['title']) { echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title; } $loc_per_row = $instance['loc_per_row']; $widget_id = $args['widget_id']; $nr_rows = $instance['nr_rows']; $only_these = $instance['only_these']; $only_parents = $instance['only_parents']; if ($only_parents == "on") { $only_parents = true; } else { $only_parents = false; } $nr = 4; if (!empty($loc_per_row)) { $nr = $loc_per_row; } echo '<style>#' . $widget_id . ' #location-stuff li>ul { width: ' . (round(100 / $nr) - 0.5) . '%}</style>'; if ($nr_rows > 0) { $jk = "&number=" . $nr_rows * $loc_per_row; } $terms_k = get_terms("project_location", "parent=0&hide_empty=0"); $terms = get_terms("project_location", "parent=0&hide_empty=0" . $jk); //$term = get_term( $term_id, $taxonomy ); if ($only_these == "1") { $terms = array(); foreach ($terms_k as $trm) { if ($instance['term_' . $trm->term_id] == $trm->term_id) { array_push($terms, $trm); } } } //----------------------------- if (count($terms) < count($terms_k)) { $disp_btn = 1; } else { $disp_btn = 0; } $count = count($terms); $i = 0; if ($count > 0) { echo "<ul id='location-stuff'>"; foreach ($terms as $term) { if ($i % $nr == 0) { echo "<li>"; } $total_ads = 0; $terms2 = ''; $terms2 = get_terms("project_location", "parent=" . $term->term_id . "&hide_empty=0"); $mese = ''; $mese .= '<ul>'; $mese .= "<img src=\"" . get_bloginfo('template_url') . "/images/location.png\" width=\"20\" height=\"20\" /> \r\n\t\t \t\t<h3><a href='" . get_term_link($term->slug, "project_location") . "'>" . $term->name; //."</a></h3>"; $total_ads = ProjectTheme_get_custom_taxonomy_count('project', $term->slug); $mese2 = ''; if ($terms2 && $only_parents == false) { foreach ($terms2 as $term2) { $tt = ProjectTheme_get_custom_taxonomy_count('project', $term2->slug); $total_ads += $tt; $mese2 .= "<li><a href='" . get_term_link($term2->slug, "project_location") . "'>" . $term2->name . " (" . $tt . ")</a></li>"; } } echo $mese . "(" . $total_ads . ")</a></h3>"; echo $mese2; echo '</ul>'; if (($i + 1) % $nr == 0) { echo "</li>"; } $i++; } //if(($i+1) % $nr != 0) echo "</li>"; echo "</ul>"; } if ($disp_btn == 1) { echo '<br/><b><a href="' . get_permalink(get_option('ProjectTheme_all_locations_page_id')) . '">' . __('See More Locations', 'ProjectTheme') . '</a></b>'; } echo $after_widget; }
function ProjectTheme_all_locations_area_main_function() { ?> <div id="content" style="width:100%"> <div class="my_box3"> <div class="padd10"> <div class="box_title"><?php _e("All Locations", "ProjectTheme"); ?> </div> <div class="box_content"> <script> $(document).ready(function() { $('.parent_taxe').click(function () { var rels = $(this).attr('rel'); $("#" + rels).toggle(); $("#img_" + rels).attr("src","<?php bloginfo('template_url'); ?> /images/posted1.png"); return false; }); }); </script> <?php $opt = get_option('ProjectTheme_show_subcats_enbl'); if ($opt == 'no') { $smk_closed = "smk_closed_disp_none"; } else { $smk_closed = ''; } $arr = array(); global $wpdb; $nr = 4; $terms = get_terms("project_location", "parent=0&hide_empty=0"); $count = count($terms); $i = 0; if ($count > 0) { foreach ($terms as $term) { // if($i%$nr == 0) echo "<li>"; $stuffy = ''; $stuffy .= "<ul id='location-stuff'><li>"; $terms2 = get_terms("project_location", "parent=" . $term->term_id . "&hide_empty=0"); $mese = ''; $mese .= '<ul>'; $mese .= "<a href='#' class='parent_taxe' rel='taxe_project_cat_" . $term->term_id . "' ><img alt='location' src=\"" . get_bloginfo('template_url') . "/images/posted.png\" width=\"20\" height=\"20\" /></a> \r\n\t\t \t\t<h3><a href='" . get_term_link($term->slug, "project_location") . "'>" . $term->name; //."</a></h3>"; $total_ads = ProjectTheme_get_custom_taxonomy_count('project', $term->slug); if ($terms2) { $mese2 = '<ul class="' . $smk_closed . '" id="taxe_project_cat_' . $term->term_id . '">'; foreach ($terms2 as $term2) { $tt = ProjectTheme_get_custom_taxonomy_count('project', $term2->slug); $total_ads += $tt; $mese2 .= "<li><a href='" . get_term_link($term2->slug, "project_location") . "'>" . $term2->name . " (" . $tt . ")</a></li>"; $terms3 = get_terms("project_location", "parent=" . $term2->term_id . "&hide_empty=0"); if ($terms3) { $mese2 .= '<ul class="baca_loc">'; foreach ($terms3 as $term3) { $tt = ProjectTheme_get_custom_taxonomy_count('project', $term3->slug); $total_ads += $tt; $mese2 .= "<li><a href='" . get_term_link($term3->slug, "project_location") . "'>" . $term3->name . " (" . $tt . ")</a></li>"; } $mese2 .= '</ul>'; } } $mese2 .= '</ul>'; } $stuffy .= $mese . "(" . $total_ads . ")</a></h3>"; $stuffy .= $mese2; $mese2 = ''; $stuffy .= '</ul></li>'; $stuffy .= '</ul>'; // if(($i+1) % $nr == 0) echo "</li>"; $i++; $arr[] = $stuffy; } //if(($i+1) % $nr != 0) echo "</li>"; // echo "</ul>"; } //======================================= $xx = count($arr); $tz = floor($xx / $nr); $i = 0; if ($xx < $nr) { $tz = $nr - $xx; } foreach ($arr as $category) { if ($i % $tz == 0) { echo "<div class='stuffa'>\r\n\t\t\t\t"; } echo $category; if (($i + 1) % $tz == 0) { echo "</div>\r\n\t\t\t\t"; } $i++; } if (($i + 2) % $tz != 0) { echo "</div>\r\n\t\t "; } ?> </div> </div> </div> </div> <?php }