@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function geodir_init_map_jason() |
| 17 | 17 | {
|
| 18 | - global $map_jason; |
|
| 19 | - $map_jason = array(); |
|
| 18 | + global $map_jason; |
|
| 19 | + $map_jason = array(); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function geodir_init_map_canvas_array() |
| 30 | 30 | {
|
| 31 | - global $map_canvas_arr; |
|
| 32 | - $map_canvas_arr = array(); |
|
| 31 | + global $map_canvas_arr; |
|
| 32 | + $map_canvas_arr = array(); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -50,63 +50,63 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function create_marker_jason_of_posts($post) |
| 52 | 52 | {
|
| 53 | - global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; |
|
| 53 | + global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; |
|
| 54 | 54 | |
| 55 | - if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
|
|
| 55 | + if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') {
|
|
| 56 | 56 | |
| 57 | - if(isset($map_jason[$post->ID])){return null;}
|
|
| 57 | + if(isset($map_jason[$post->ID])){return null;}
|
|
| 58 | 58 | |
| 59 | - $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 60 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 59 | + $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 60 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
| 64 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; |
|
| 63 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
| 64 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; |
|
| 65 | 65 | |
| 66 | - $post_title = $post->post_title; |
|
| 67 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
| 66 | + $post_title = $post->post_title; |
|
| 67 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
| 68 | 68 | |
| 69 | - if (is_ssl()) {
|
|
| 70 | - $icon = str_replace("http:","https:",$icon );
|
|
| 71 | - } |
|
| 69 | + if (is_ssl()) {
|
|
| 70 | + $icon = str_replace("http:","https:",$icon );
|
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if ($icon != '') {
|
|
| 74 | - $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
| 73 | + if ($icon != '') {
|
|
| 74 | + $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
| 75 | 75 | |
| 76 | - if (isset($gd_marker_sizes[$icon])) {
|
|
| 77 | - $icon_size = $gd_marker_sizes[$icon]; |
|
| 78 | - } else {
|
|
| 79 | - $icon_size = geodir_get_marker_size($icon); |
|
| 80 | - $gd_marker_sizes[$icon] = $icon_size; |
|
| 81 | - } |
|
| 82 | - } else {
|
|
| 83 | - $icon_size = array('w' => 36, 'h' => 45);
|
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $post_json = '{"id":"' . $post->ID
|
|
| 87 | - . '","t": "' . $title |
|
| 88 | - . '","lt": "' . $post->post_latitude |
|
| 89 | - . '","ln": "' . $post->post_longitude |
|
| 90 | - . '","mk_id":"' . $post->ID . '_' . $post->default_category |
|
| 91 | - . '","i":"' . $icon |
|
| 92 | - . '","w":"' . $icon_size['w'] |
|
| 93 | - . '","h":"' . $icon_size['h'] . '"}'; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Filter the json data when creating output for post json marker.. |
|
| 97 | - * |
|
| 98 | - * @since 1.5.7 |
|
| 99 | - * @param string $post_json JSON representation of the post marker info. |
|
| 100 | - * @param object $post The post object. |
|
| 101 | - */ |
|
| 102 | - $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
|
|
| 103 | - |
|
| 104 | - // only assign it if it has a value |
|
| 105 | - if($post_map_json){
|
|
| 106 | - $map_jason[$post->ID] = $post_map_json; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - } |
|
| 76 | + if (isset($gd_marker_sizes[$icon])) {
|
|
| 77 | + $icon_size = $gd_marker_sizes[$icon]; |
|
| 78 | + } else {
|
|
| 79 | + $icon_size = geodir_get_marker_size($icon); |
|
| 80 | + $gd_marker_sizes[$icon] = $icon_size; |
|
| 81 | + } |
|
| 82 | + } else {
|
|
| 83 | + $icon_size = array('w' => 36, 'h' => 45);
|
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $post_json = '{"id":"' . $post->ID
|
|
| 87 | + . '","t": "' . $title |
|
| 88 | + . '","lt": "' . $post->post_latitude |
|
| 89 | + . '","ln": "' . $post->post_longitude |
|
| 90 | + . '","mk_id":"' . $post->ID . '_' . $post->default_category |
|
| 91 | + . '","i":"' . $icon |
|
| 92 | + . '","w":"' . $icon_size['w'] |
|
| 93 | + . '","h":"' . $icon_size['h'] . '"}'; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Filter the json data when creating output for post json marker.. |
|
| 97 | + * |
|
| 98 | + * @since 1.5.7 |
|
| 99 | + * @param string $post_json JSON representation of the post marker info. |
|
| 100 | + * @param object $post The post object. |
|
| 101 | + */ |
|
| 102 | + $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post);
|
|
| 103 | + |
|
| 104 | + // only assign it if it has a value |
|
| 105 | + if($post_map_json){
|
|
| 106 | + $map_jason[$post->ID] = $post_map_json; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -119,67 +119,67 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function send_marker_jason_to_js() |
| 121 | 121 | {
|
| 122 | - global $map_jason, $map_canvas_arr; |
|
| 123 | - |
|
| 124 | - if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) {
|
|
| 125 | - foreach ($map_canvas_arr as $canvas => $jason) {
|
|
| 126 | - if (is_array($map_jason) && !empty($map_jason)) {
|
|
| 127 | - |
|
| 128 | - // on details page only show the main marker on the map |
|
| 129 | - if(geodir_is_page('detail')){
|
|
| 130 | - global $post; |
|
| 131 | - if(isset($map_jason[$post->ID])){
|
|
| 132 | - $map_jason = array($map_jason[$post->ID]); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - $canvas_jason = $canvas . "_jason"; |
|
| 136 | - $map_canvas_arr[$canvas] = array_unique($map_jason); |
|
| 137 | - unset($cat_content_info); |
|
| 138 | - $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
|
|
| 139 | - $totalcount = count(array_unique($map_jason)); |
|
| 140 | - if (!empty($cat_content_info)) {
|
|
| 141 | - $json_content = substr(implode(',', $cat_content_info), 1);
|
|
| 142 | - $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
|
|
| 143 | - $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
| 144 | - $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
|
|
| 145 | - } else {
|
|
| 146 | - $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 147 | - } |
|
| 148 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 152 | - * |
|
| 153 | - * You can use this filter to modify map canvas json args. |
|
| 154 | - * |
|
| 155 | - * @since 1.0.0 |
|
| 156 | - * @package GeoDirectory |
|
| 157 | - * @param string $canvas Map canvas array key. |
|
| 158 | - * @param array $map_canvas_jason_args Map canvas args. |
|
| 159 | - */ |
|
| 160 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 161 | - |
|
| 162 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 163 | - } else {
|
|
| 164 | - $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 165 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 169 | - * |
|
| 170 | - * You can use this filter to modify map canvas json args. |
|
| 171 | - * |
|
| 172 | - * @since 1.0.0 |
|
| 173 | - * @package GeoDirectory |
|
| 174 | - * @param string $canvas Map canvas array key. |
|
| 175 | - * @param array $map_canvas_jason_args Map canvas args. |
|
| 176 | - */ |
|
| 177 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 178 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - } |
|
| 122 | + global $map_jason, $map_canvas_arr; |
|
| 123 | + |
|
| 124 | + if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) {
|
|
| 125 | + foreach ($map_canvas_arr as $canvas => $jason) {
|
|
| 126 | + if (is_array($map_jason) && !empty($map_jason)) {
|
|
| 127 | + |
|
| 128 | + // on details page only show the main marker on the map |
|
| 129 | + if(geodir_is_page('detail')){
|
|
| 130 | + global $post; |
|
| 131 | + if(isset($map_jason[$post->ID])){
|
|
| 132 | + $map_jason = array($map_jason[$post->ID]); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + $canvas_jason = $canvas . "_jason"; |
|
| 136 | + $map_canvas_arr[$canvas] = array_unique($map_jason); |
|
| 137 | + unset($cat_content_info); |
|
| 138 | + $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]);
|
|
| 139 | + $totalcount = count(array_unique($map_jason)); |
|
| 140 | + if (!empty($cat_content_info)) {
|
|
| 141 | + $json_content = substr(implode(',', $cat_content_info), 1);
|
|
| 142 | + $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016
|
|
| 143 | + $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
| 144 | + $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']';
|
|
| 145 | + } else {
|
|
| 146 | + $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 147 | + } |
|
| 148 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 152 | + * |
|
| 153 | + * You can use this filter to modify map canvas json args. |
|
| 154 | + * |
|
| 155 | + * @since 1.0.0 |
|
| 156 | + * @package GeoDirectory |
|
| 157 | + * @param string $canvas Map canvas array key. |
|
| 158 | + * @param array $map_canvas_jason_args Map canvas args. |
|
| 159 | + */ |
|
| 160 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 161 | + |
|
| 162 | + wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 163 | + } else {
|
|
| 164 | + $canvas_jason = '[{"totalcount":"0"}]';
|
|
| 165 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Filter the send_marker_jason_to_js() function map canvas json args. |
|
| 169 | + * |
|
| 170 | + * You can use this filter to modify map canvas json args. |
|
| 171 | + * |
|
| 172 | + * @since 1.0.0 |
|
| 173 | + * @package GeoDirectory |
|
| 174 | + * @param string $canvas Map canvas array key. |
|
| 175 | + * @param array $map_canvas_jason_args Map canvas args. |
|
| 176 | + */ |
|
| 177 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args);
|
|
| 178 | + wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args);
|
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + } |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -202,99 +202,99 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | function home_map_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = true, $pading = 0, $map_canvas_name = '', $child_collapse, $is_home_map = false) |
| 204 | 204 | {
|
| 205 | - global $cat_count, $geodir_cat_icons, $gd_session; |
|
| 205 | + global $cat_count, $geodir_cat_icons, $gd_session; |
|
| 206 | 206 | |
| 207 | - $exclude_categories = get_option('geodir_exclude_cat_on_map');
|
|
| 208 | - $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 207 | + $exclude_categories = get_option('geodir_exclude_cat_on_map');
|
|
| 208 | + $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 209 | 209 | |
| 210 | - // check if exclude categories saved before fix of categories identical names |
|
| 211 | - if ($exclude_categories_new) {
|
|
| 212 | - $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; |
|
| 213 | - $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); |
|
| 214 | - } |
|
| 210 | + // check if exclude categories saved before fix of categories identical names |
|
| 211 | + if ($exclude_categories_new) {
|
|
| 212 | + $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; |
|
| 213 | + $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - $exclude_cat_str = implode(',', $exclude_categories);
|
|
| 216 | + $exclude_cat_str = implode(',', $exclude_categories);
|
|
| 217 | 217 | |
| 218 | - if ($exclude_cat_str == '') {
|
|
| 219 | - $exclude_cat_str = '0'; |
|
| 220 | - } |
|
| 218 | + if ($exclude_cat_str == '') {
|
|
| 219 | + $exclude_cat_str = '0'; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty));
|
|
| 222 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty));
|
|
| 223 | 223 | |
| 224 | - if ($hide_empty) {
|
|
| 225 | - $cat_terms = geodir_filter_empty_terms($cat_terms); |
|
| 226 | - } |
|
| 224 | + if ($hide_empty) {
|
|
| 225 | + $cat_terms = geodir_filter_empty_terms($cat_terms); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - $main_list_class = ''; |
|
| 229 | - //If there are terms, start displaying |
|
| 230 | - if (count($cat_terms) > 0) {
|
|
| 231 | - //Displaying as a list |
|
| 232 | - $p = $pading * 15; |
|
| 233 | - $pading++; |
|
| 228 | + $main_list_class = ''; |
|
| 229 | + //If there are terms, start displaying |
|
| 230 | + if (count($cat_terms) > 0) {
|
|
| 231 | + //Displaying as a list |
|
| 232 | + $p = $pading * 15; |
|
| 233 | + $pading++; |
|
| 234 | 234 | |
| 235 | - if ($cat_parent == 0) {
|
|
| 236 | - $list_class = 'main_list'; |
|
| 237 | - $display = ''; |
|
| 238 | - } else {
|
|
| 239 | - $list_class = 'sub_list'; |
|
| 240 | - $display = !$child_collapse ? '' : 'display:none'; |
|
| 241 | - } |
|
| 235 | + if ($cat_parent == 0) {
|
|
| 236 | + $list_class = 'main_list'; |
|
| 237 | + $display = ''; |
|
| 238 | + } else {
|
|
| 239 | + $list_class = 'sub_list'; |
|
| 240 | + $display = !$child_collapse ? '' : 'display:none'; |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 243 | + $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
| 244 | 244 | |
| 245 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
| 245 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
| 246 | 246 | |
| 247 | - $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
|
|
| 248 | - if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) {
|
|
| 249 | - $geodir_default_map_search_pt = $homemap_catlist_ptype; |
|
| 250 | - } |
|
| 251 | - $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt); |
|
| 247 | + $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place';
|
|
| 248 | + if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) {
|
|
| 249 | + $geodir_default_map_search_pt = $homemap_catlist_ptype; |
|
| 250 | + } |
|
| 251 | + $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt); |
|
| 252 | 252 | |
| 253 | - foreach ($cat_terms as $cat_term): |
|
| 254 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; |
|
| 255 | - |
|
| 256 | - if (!in_array($cat_term->term_id, $exclude_categories)): |
|
| 257 | - //Secret sauce. Function calls itself to display child elements, if any |
|
| 258 | - $checked = 'checked="checked"'; |
|
| 259 | - |
|
| 260 | - // Untick the category by default on home map |
|
| 261 | - if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
|
|
| 262 | - if (function_exists('icl_object_id')) { // if WPML
|
|
| 263 | - global $sitepress; |
|
| 264 | - $default_lang = $sitepress->get_default_language(); |
|
| 265 | - $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
|
| 266 | - }else{
|
|
| 267 | - $term_id = $cat_term->term_id; |
|
| 268 | - } |
|
| 269 | - if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) {
|
|
| 270 | - $checked = ''; |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
| 275 | - $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
| 276 | - $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
| 277 | - $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
| 278 | - $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
| 279 | - |
|
| 280 | - endif; |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - // get sub category by recursion |
|
| 284 | - $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); |
|
| 285 | - |
|
| 286 | - $out .= '</li>'; |
|
| 287 | - |
|
| 288 | - endforeach; |
|
| 289 | - |
|
| 290 | - $out .= '</ul>'; |
|
| 291 | - |
|
| 292 | - return $out; |
|
| 293 | - } else {
|
|
| 294 | - if ($cat_parent == 0) |
|
| 295 | - return _e('No category', 'geodirectory');
|
|
| 296 | - } |
|
| 297 | - return; |
|
| 253 | + foreach ($cat_terms as $cat_term): |
|
| 254 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; |
|
| 255 | + |
|
| 256 | + if (!in_array($cat_term->term_id, $exclude_categories)): |
|
| 257 | + //Secret sauce. Function calls itself to display child elements, if any |
|
| 258 | + $checked = 'checked="checked"'; |
|
| 259 | + |
|
| 260 | + // Untick the category by default on home map |
|
| 261 | + if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) {
|
|
| 262 | + if (function_exists('icl_object_id')) { // if WPML
|
|
| 263 | + global $sitepress; |
|
| 264 | + $default_lang = $sitepress->get_default_language(); |
|
| 265 | + $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
|
| 266 | + }else{
|
|
| 267 | + $term_id = $cat_term->term_id; |
|
| 268 | + } |
|
| 269 | + if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) {
|
|
| 270 | + $checked = ''; |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
| 275 | + $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
| 276 | + $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
| 277 | + $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
| 278 | + $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
| 279 | + |
|
| 280 | + endif; |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + // get sub category by recursion |
|
| 284 | + $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); |
|
| 285 | + |
|
| 286 | + $out .= '</li>'; |
|
| 287 | + |
|
| 288 | + endforeach; |
|
| 289 | + |
|
| 290 | + $out .= '</ul>'; |
|
| 291 | + |
|
| 292 | + return $out; |
|
| 293 | + } else {
|
|
| 294 | + if ($cat_parent == 0) |
|
| 295 | + return _e('No category', 'geodirectory');
|
|
| 296 | + } |
|
| 297 | + return; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -306,19 +306,19 @@ discard block |
||
| 306 | 306 | * @return string The map API provider name. |
| 307 | 307 | */ |
| 308 | 308 | function geodir_map_name() {
|
| 309 | - $geodir_map_name = get_option('geodir_load_map', 'google');
|
|
| 309 | + $geodir_map_name = get_option('geodir_load_map', 'google');
|
|
| 310 | 310 | |
| 311 | - if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) {
|
|
| 312 | - $geodir_map_name = 'auto'; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Filter the map JS API provider name. |
|
| 317 | - * |
|
| 318 | - * @since 1.6.1 |
|
| 319 | - * @param string $geodir_map_name The map API provider name. |
|
| 320 | - */ |
|
| 321 | - return apply_filters('geodir_map_name', $geodir_map_name);
|
|
| 311 | + if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) {
|
|
| 312 | + $geodir_map_name = 'auto'; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Filter the map JS API provider name. |
|
| 317 | + * |
|
| 318 | + * @since 1.6.1 |
|
| 319 | + * @param string $geodir_map_name The map API provider name. |
|
| 320 | + */ |
|
| 321 | + return apply_filters('geodir_map_name', $geodir_map_name);
|
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -334,48 +334,48 @@ discard block |
||
| 334 | 334 | * @return array The icon size. |
| 335 | 335 | */ |
| 336 | 336 | function geodir_get_marker_size($icon, $default_size = array('w' => 36, 'h' => 45)) {
|
| 337 | - global $gd_marker_sizes; |
|
| 337 | + global $gd_marker_sizes; |
|
| 338 | 338 | |
| 339 | - if (empty($gd_marker_sizes)) {
|
|
| 340 | - $gd_marker_sizes = array(); |
|
| 341 | - } |
|
| 339 | + if (empty($gd_marker_sizes)) {
|
|
| 340 | + $gd_marker_sizes = array(); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - if (!empty($gd_marker_sizes[$icon])) {
|
|
| 344 | - return $gd_marker_sizes[$icon]; |
|
| 345 | - } |
|
| 343 | + if (!empty($gd_marker_sizes[$icon])) {
|
|
| 344 | + return $gd_marker_sizes[$icon]; |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - if (empty($icon)) {
|
|
| 348 | - $gd_marker_sizes[$icon] = $default_size; |
|
| 347 | + if (empty($icon)) {
|
|
| 348 | + $gd_marker_sizes[$icon] = $default_size; |
|
| 349 | 349 | |
| 350 | - return $default_size; |
|
| 351 | - } |
|
| 350 | + return $default_size; |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | - $icon_url = $icon; |
|
| 353 | + $icon_url = $icon; |
|
| 354 | 354 | |
| 355 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 355 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 356 | 356 | |
| 357 | - if (!path_is_absolute($icon)) {
|
|
| 358 | - $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); |
|
| 359 | - } |
|
| 357 | + if (!path_is_absolute($icon)) {
|
|
| 358 | + $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) {
|
|
| 362 | - $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); |
|
| 363 | - } |
|
| 361 | + if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) {
|
|
| 362 | + $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - $sizes = array(); |
|
| 366 | - if (is_file($icon) && file_exists($icon)) {
|
|
| 367 | - $size = getimagesize(trim($icon)); |
|
| 365 | + $sizes = array(); |
|
| 366 | + if (is_file($icon) && file_exists($icon)) {
|
|
| 367 | + $size = getimagesize(trim($icon)); |
|
| 368 | 368 | |
| 369 | - if (!empty($size[0]) && !empty($size[1])) {
|
|
| 370 | - $sizes = array('w' => $size[0], 'h' => $size[1]);
|
|
| 371 | - } |
|
| 372 | - } |
|
| 369 | + if (!empty($size[0]) && !empty($size[1])) {
|
|
| 370 | + $sizes = array('w' => $size[0], 'h' => $size[1]);
|
|
| 371 | + } |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - $sizes = !empty($sizes) ? $sizes : $default_size; |
|
| 374 | + $sizes = !empty($sizes) ? $sizes : $default_size; |
|
| 375 | 375 | |
| 376 | - $gd_marker_sizes[$icon_url] = $sizes; |
|
| 376 | + $gd_marker_sizes[$icon_url] = $sizes; |
|
| 377 | 377 | |
| 378 | - return $sizes; |
|
| 378 | + return $sizes; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | add_action('wp_footer', 'geodir_map_load_script', 10);
|
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | * @package GeoDirectory |
| 388 | 388 | */ |
| 389 | 389 | function geodir_map_load_script() {
|
| 390 | - if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
|
|
| 391 | - $plugin_url = geodir_plugin_url(); |
|
| 390 | + if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) {
|
|
| 391 | + $plugin_url = geodir_plugin_url(); |
|
| 392 | 392 | ?> |
| 393 | 393 | <script type="text/javascript"> |
| 394 | 394 | if (!(window.google && typeof google.maps !== 'undefined')) {
|
@@ -403,5 +403,5 @@ discard block |
||
| 403 | 403 | } |
| 404 | 404 | </script> |
| 405 | 405 | <?php |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | } |
| 408 | 408 | \ No newline at end of file |