Function Reference: home_map_taxonomy_walker
Summary
Home map Taxonomy walker.
Global Values
- $gd_session
- (object) (required) GeoDirectory Session object.
- Default: None
Package
GeoDirectory
Parameters
- $cat_taxonomy
- (string) (required) Name of the taxonomy e. g place_category.
- Default: None
- $cat_parent
- (int) (optional) Parent term ID to retrieve its child terms.
- Default: 0
- $hide_empty
- (bool) (optional) Do you want to hide the terms that has no posts.
- Default: true
- $pading
- (int) (optional) CSS padding value in pixels. e. g: 12 will be considers as 12px.
- Default: None
- $map_canvas_name
- (string) (required) Unique canvas name for your map.
- Default: None
- $child_collapse
- (bool) (required) Do you want to collapse child terms by default?.
- Default: None
- $is_home_map
- (bool) (optional) Is this a home page map? Default: false.
- Default: None
Return Values
- (string|void)
Change Log
Since: 1.0.0
1.6.16 Fix: Category are not unticked on page refresh for map post type other than default.
Source File
home_map_taxonomy_walker() is located in geodirectory-functions/map-functions/map_functions.php [Line: 208]
Source Code
function home_map_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = true, $pading = 0, $map_canvas_name = '', $child_collapse, $is_home_map = false) { global $cat_count, $geodir_cat_icons, $gd_session; $exclude_categories = get_option('geodir_exclude_cat_on_map'); $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade'); // check if exclude categories saved before fix of categories identical names if ($exclude_categories_new) { $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); } $exclude_cat_str = implode(',', $exclude_categories); if ($exclude_cat_str == '') { $exclude_cat_str = '0'; } $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty)); if ($hide_empty) { $cat_terms = geodir_filter_empty_terms($cat_terms); } $main_list_class = ''; //If there are terms, start displaying if (count($cat_terms) > 0) { //Displaying as a list $p = $pading * 15; $pading++; if ($cat_parent == 0) { $list_class = 'main_list'; $display = ''; } else { $list_class = 'sub_list'; $display = !$child_collapse ? '' : 'display:none'; } $out = '
- ';
$geodir_cat_icons = geodir_get_term_icon();
$geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) {
$geodir_default_map_search_pt = $homemap_catlist_ptype;
}
$post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt);
foreach ($cat_terms as $cat_term):
$icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : '';
if (!in_array($cat_term->term_id, $exclude_categories)):
//Secret sauce. Function calls itself to display child elements, if any
$checked = 'checked="checked"';
// Untick the category by default on home map
if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
if (geodir_wpml_is_taxonomy_translated($post_type . 'category')) { // if WPML
global $sitepress;
$default_lang = $sitepress->get_default_language();
$term_id = geodir_wpml_object_id($cat_term->term_id, $post_type.'category', true, $default_lang);
}else{
$term_id = $cat_term->term_id;
}
if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) {
$checked = '';
}
}
$term_check = 'name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">';
$term_img = '';
$out .= '
- ' . $term_check . ''; endif; // get sub category by recursion $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); $out .= ' '; endforeach; $out .= '