Test Failed
Pull Request — master (#435)
by Kiran
19:26
created
geodirectory-functions/taxonomy_functions.php 3 patches
Indentation   +1256 added lines, -1256 removed lines patch added patch discarded remove patch
@@ -33,265 +33,265 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_add_nav_menu_items()
35 35
 {
36
-    $items = '';
37
-    // apply filter to add more navigations // -Filter-Location-Manager
38
-
39
-    if (get_option('geodir_show_listing_nav')) {
40
-
41
-        $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
44
-
45
-
46
-        //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
-        $post_types = geodir_get_posttypes('object');
48
-        $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
-        if (!empty($post_types)) {
50
-            foreach ($post_types as $post_type => $args) {
51
-                if (!empty($show_post_type_main_nav)) {
52
-                    if (in_array($post_type, $show_post_type_main_nav)) {
53
-                        if (get_post_type_archive_link($post_type)) {
54
-                            $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
57
-                            /**
58
-                             * Filter the menu li class.
59
-                             *
60
-                             * @since 1.0.0
61
-                             * @param string $menu_class The menu HTML class.
62
-                             */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
-                            /**
65
-                             * Filter the menu a class.
66
-                             *
67
-                             * @since 1.0.0
68
-                             */
69
-                            $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
36
+	$items = '';
37
+	// apply filter to add more navigations // -Filter-Location-Manager
38
+
39
+	if (get_option('geodir_show_listing_nav')) {
40
+
41
+		$menu_class = '';
42
+		if (geodir_is_page('listing'))
43
+			$menu_class = 'current-menu-item';
44
+
45
+
46
+		//SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
+		$post_types = geodir_get_posttypes('object');
48
+		$show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
+		if (!empty($post_types)) {
50
+			foreach ($post_types as $post_type => $args) {
51
+				if (!empty($show_post_type_main_nav)) {
52
+					if (in_array($post_type, $show_post_type_main_nav)) {
53
+						if (get_post_type_archive_link($post_type)) {
54
+							$menu_class = '';
55
+							if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
+								$menu_class = 'current-menu-item';
57
+							/**
58
+							 * Filter the menu li class.
59
+							 *
60
+							 * @since 1.0.0
61
+							 * @param string $menu_class The menu HTML class.
62
+							 */
63
+							$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
+							/**
65
+							 * Filter the menu a class.
66
+							 *
67
+							 * @since 1.0.0
68
+							 */
69
+							$a_class = apply_filters('geodir_menu_a_class', '');
70
+							$items .= '<li class="' . $li_class . '">
71 71
 									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72 72
 										' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
73 73
 									</a>
74 74
 								</li>';
75
-                        }
76
-                    }
77
-                }
78
-            }
79
-        }
80
-        //END LISTING OF POST TYPE IN MAIN NAVIGATION
81
-
82
-        $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
-        $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
-        if ($is_listing_sub_meny_exists) {
85
-            /**
86
-             * Filter the menu li class.
87
-             *
88
-             * @since 1.0.0
89
-             * @param string $menu_class The menu HTML class.
90
-             */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
-            /**
93
-             * Filter the sub menu li class.
94
-             *
95
-             * @since 1.0.0
96
-             * @param string $menu_class The menu HTML class.
97
-             */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
-            /**
100
-             * Filter the sub menu ul class.
101
-             *
102
-             * @since 1.0.0
103
-             */
104
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
-            /**
106
-             * Filter the menu a class.
107
-             *
108
-             * @since 1.0.0
109
-             */
110
-            $a_class = apply_filters('geodir_menu_a_class', '');
111
-            /**
112
-             * Filter the sub menu a class.
113
-             *
114
-             * @since 1.0.0
115
-             */
116
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
75
+						}
76
+					}
77
+				}
78
+			}
79
+		}
80
+		//END LISTING OF POST TYPE IN MAIN NAVIGATION
81
+
82
+		$view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
+		$is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
+		if ($is_listing_sub_meny_exists) {
85
+			/**
86
+			 * Filter the menu li class.
87
+			 *
88
+			 * @since 1.0.0
89
+			 * @param string $menu_class The menu HTML class.
90
+			 */
91
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
+			/**
93
+			 * Filter the sub menu li class.
94
+			 *
95
+			 * @since 1.0.0
96
+			 * @param string $menu_class The menu HTML class.
97
+			 */
98
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
+			/**
100
+			 * Filter the sub menu ul class.
101
+			 *
102
+			 * @since 1.0.0
103
+			 */
104
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
+			/**
106
+			 * Filter the menu a class.
107
+			 *
108
+			 * @since 1.0.0
109
+			 */
110
+			$a_class = apply_filters('geodir_menu_a_class', '');
111
+			/**
112
+			 * Filter the sub menu a class.
113
+			 *
114
+			 * @since 1.0.0
115
+			 */
116
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
+			$items .= '<li class="' . $li_class . '">
118 118
 					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119 119
 					<ul class="' . $sub_ul_class . '">';
120
-            $post_types = geodir_get_posttypes('object');
120
+			$post_types = geodir_get_posttypes('object');
121 121
 
122
-            $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
122
+			$show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
123 123
 
124
-            if (!empty($post_types)) {
125
-                global $geodir_add_location_url;
126
-                $geodir_add_location_url = true;
127
-                foreach ($post_types as $post_type => $args) {
128
-                    if (!empty($show_listing_post_types)) {
129
-                        if (in_array($post_type, $show_listing_post_types)) {
130
-                            if (get_post_type_archive_link($post_type)) {
124
+			if (!empty($post_types)) {
125
+				global $geodir_add_location_url;
126
+				$geodir_add_location_url = true;
127
+				foreach ($post_types as $post_type => $args) {
128
+					if (!empty($show_listing_post_types)) {
129
+						if (in_array($post_type, $show_listing_post_types)) {
130
+							if (get_post_type_archive_link($post_type)) {
131 131
 
132
-                                $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
132
+								$menu_class = '';
133
+								if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
+									$menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
136
+								$items .= '<li class="' . $sub_li_class . '">
137 137
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138 138
 															' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
139 139
 														</a>
140 140
 													</li>';
141
-                            }
142
-                        }
143
-                    }
144
-                }
145
-                $geodir_add_location_url = NULL;
146
-            }
141
+							}
142
+						}
143
+					}
144
+				}
145
+				$geodir_add_location_url = NULL;
146
+			}
147
+
148
+			$items .= '	</ul> ';
149
+			/**
150
+			 * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
+			 *
152
+			 * @since 1.5.9
153
+			 */
154
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
155
+			$items .= '</li>';
156
+		}
157
+	}
147 158
 
148
-            $items .= '	</ul> ';
149
-            /**
150
-             * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
-             *
152
-             * @since 1.5.9
153
-             */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
155
-            $items .= '</li>';
156
-        }
157
-    }
158
-
159
-    if (get_option('geodir_show_addlisting_nav')) {
160
-
161
-        $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
164
-
165
-        //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
-        $post_types = geodir_get_posttypes('object');
167
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
-
170
-        if (!empty($post_types)) {
171
-            foreach ($post_types as $post_type => $args) {
172
-                if (!empty($geodir_allow_posttype_frontend)) {
173
-                    if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
-                        if (!empty($show_add_listing_post_types_main_nav)) {
175
-                            if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
-                                if (geodir_get_addlisting_link($post_type)) {
177
-
178
-                                    $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
181
-                                    /**
182
-                                     * Filter the menu li class.
183
-                                     *
184
-                                     * @since 1.0.0
185
-                                     * @param string $menu_class The menu HTML class.
186
-                                     */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
-                                    /**
189
-                                     * Filter the menu a class.
190
-                                     *
191
-                                     * @since 1.0.0
192
-                                     */
193
-                                    $a_class = apply_filters('geodir_menu_a_class', '');
194
-                                    $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
159
+	if (get_option('geodir_show_addlisting_nav')) {
160
+
161
+		$menu_class = '';
162
+		if (geodir_is_page('add-listing'))
163
+			$menu_class = 'current-menu-item';
164
+
165
+		//SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
+		$post_types = geodir_get_posttypes('object');
167
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
+
170
+		if (!empty($post_types)) {
171
+			foreach ($post_types as $post_type => $args) {
172
+				if (!empty($geodir_allow_posttype_frontend)) {
173
+					if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
+						if (!empty($show_add_listing_post_types_main_nav)) {
175
+							if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
+								if (geodir_get_addlisting_link($post_type)) {
177
+
178
+									$menu_class = '';
179
+									if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
+										$menu_class = 'current-menu-item';
181
+									/**
182
+									 * Filter the menu li class.
183
+									 *
184
+									 * @since 1.0.0
185
+									 * @param string $menu_class The menu HTML class.
186
+									 */
187
+									$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
+									/**
189
+									 * Filter the menu a class.
190
+									 *
191
+									 * @since 1.0.0
192
+									 */
193
+									$a_class = apply_filters('geodir_menu_a_class', '');
194
+									$cpt_name = __($args->labels->singular_name, 'geodirectory');
195
+									$items .= '<li class="' . $li_class . '">
196 196
 											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197 197
 												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
198 198
 											</a>
199 199
 										</li>';
200
-                                }
201
-                            }
202
-                        }
203
-                    }
204
-                }
205
-            }
206
-        }
207
-        //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
-    }
209
-
210
-    $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
-    $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
-    if ($is_add_listing_sub_meny_exists) {
213
-
214
-        if (get_option('geodir_show_addlisting_nav')) {
215
-            /**
216
-             * Filter the menu li class.
217
-             *
218
-             * @since 1.0.0
219
-             * @param string $menu_class The menu HTML class.
220
-             */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
-            /**
223
-             * Filter the sub menu li class.
224
-             *
225
-             * @since 1.0.0
226
-             * @param string $menu_class The menu HTML class.
227
-             */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
-            /**
230
-             * Filter the sub menu ul class.
231
-             *
232
-             * @since 1.0.0
233
-             */
234
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
-            /**
236
-             * Filter the menu a class.
237
-             *
238
-             * @since 1.0.0
239
-             */
240
-            $a_class = apply_filters('geodir_menu_a_class', '');
241
-            /**
242
-             * Filter the sub menu a class.
243
-             *
244
-             * @since 1.0.0
245
-             */
246
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
200
+								}
201
+							}
202
+						}
203
+					}
204
+				}
205
+			}
206
+		}
207
+		//END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
+	}
209
+
210
+	$view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
+	$is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
+	if ($is_add_listing_sub_meny_exists) {
213
+
214
+		if (get_option('geodir_show_addlisting_nav')) {
215
+			/**
216
+			 * Filter the menu li class.
217
+			 *
218
+			 * @since 1.0.0
219
+			 * @param string $menu_class The menu HTML class.
220
+			 */
221
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
+			/**
223
+			 * Filter the sub menu li class.
224
+			 *
225
+			 * @since 1.0.0
226
+			 * @param string $menu_class The menu HTML class.
227
+			 */
228
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
+			/**
230
+			 * Filter the sub menu ul class.
231
+			 *
232
+			 * @since 1.0.0
233
+			 */
234
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
+			/**
236
+			 * Filter the menu a class.
237
+			 *
238
+			 * @since 1.0.0
239
+			 */
240
+			$a_class = apply_filters('geodir_menu_a_class', '');
241
+			/**
242
+			 * Filter the sub menu a class.
243
+			 *
244
+			 * @since 1.0.0
245
+			 */
246
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
+			$items .= '<li  class="' . $li_class . '">
248 248
 					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249 249
 					<ul class="' . $sub_ul_class . '">';
250 250
 
251
-            $post_types = geodir_get_posttypes('object');
252
-
253
-            $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
-
255
-            if (!empty($post_types)) {
256
-                foreach ($post_types as $post_type => $args) {
257
-                    if (!empty($geodir_allow_posttype_frontend)) {
258
-                        if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
-                            if (!empty($show_add_listing_post_types)) {
260
-                                if (in_array($post_type, $show_add_listing_post_types)) {
261
-                                    if (geodir_get_addlisting_link($post_type)) {
262
-
263
-                                        $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
266
-                                        /**
267
-                                         * Filter the menu li class.
268
-                                         *
269
-                                         * @since 1.0.0
270
-                                         * @param string $menu_class The menu HTML class.
271
-                                         */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
-                                        $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $sub_li_class . '">
251
+			$post_types = geodir_get_posttypes('object');
252
+
253
+			$show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
+
255
+			if (!empty($post_types)) {
256
+				foreach ($post_types as $post_type => $args) {
257
+					if (!empty($geodir_allow_posttype_frontend)) {
258
+						if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
+							if (!empty($show_add_listing_post_types)) {
260
+								if (in_array($post_type, $show_add_listing_post_types)) {
261
+									if (geodir_get_addlisting_link($post_type)) {
262
+
263
+										$menu_class = '';
264
+										if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
+											$menu_class = 'current-menu-item';
266
+										/**
267
+										 * Filter the menu li class.
268
+										 *
269
+										 * @since 1.0.0
270
+										 * @param string $menu_class The menu HTML class.
271
+										 */
272
+										$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
+										$cpt_name = __($args->labels->singular_name, 'geodirectory');
274
+										$items .= '<li class="' . $sub_li_class . '">
275 275
 														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276 276
 															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
277 277
 														</a>
278 278
 													</li>';
279
-                                    }
280
-                                }
281
-                            }
282
-                        }
283
-                    }
284
-                }
285
-            }
279
+									}
280
+								}
281
+							}
282
+						}
283
+					}
284
+				}
285
+			}
286 286
 
287
-            $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
289
-            $items .= '</li>';
287
+			$items .= '	</ul> ';
288
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
289
+			$items .= '</li>';
290 290
 
291
-        }
292
-    }
293
-    // apply filter to add more navigations // -Filter-Location-Manager
294
-    return $items;
291
+		}
292
+	}
293
+	// apply filter to add more navigations // -Filter-Location-Manager
294
+	return $items;
295 295
 }
296 296
 
297 297
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function geodir_pagemenu_items($menu, $args)
311 311
 {
312
-    $locations = get_nav_menu_locations();
313
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
314
-    $geodir_theme_location_nav = array();
315
-    if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
-        $geodir_theme_location_nav[] = $args['theme_location'];
318
-        update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
-    }
320
-    //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
312
+	$locations = get_nav_menu_locations();
313
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
314
+	$geodir_theme_location_nav = array();
315
+	if (empty($locations) && empty($geodir_theme_location)) {
316
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
+		$geodir_theme_location_nav[] = $args['theme_location'];
318
+		update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
+	}
320
+	//else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
322
+	else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
324 324
 
325
-    return $menu;
325
+	return $menu;
326 326
 
327 327
 }
328 328
 
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
 function geodir_menu_items($items, $args)
343 343
 {
344 344
 
345
-    $location = $args->theme_location;
345
+	$location = $args->theme_location;
346 346
 
347
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
347
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
348 348
 
349
-    if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
349
+	if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
352
-        return $items;
351
+		$items = $items . geodir_add_nav_menu_items();
352
+		return $items;
353 353
 
354
-    } else {
355
-        return $items;
356
-    }
354
+	} else {
355
+		return $items;
356
+	}
357 357
 }
358 358
 
359 359
 /**
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function geodir_get_category_all_array()
370 370
 {
371
-    global $wpdb;
372
-    $return_array = array();
373
-
374
-    $taxonomies = geodir_get_taxonomies();
375
-    $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
377
-
378
-    $pn_categories = $wpdb->get_results(
379
-        $wpdb->prepare(
380
-            "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
382
-        )
383
-    );
384
-
385
-    foreach ($pn_categories as $pn_categories_obj) {
386
-        $return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
-            "title" => $pn_categories_obj->name,);
388
-    }
389
-    return $return_array;
371
+	global $wpdb;
372
+	$return_array = array();
373
+
374
+	$taxonomies = geodir_get_taxonomies();
375
+	$taxonomies = implode("','", $taxonomies);
376
+	$taxonomies = "'" . $taxonomies . "'";
377
+
378
+	$pn_categories = $wpdb->get_results(
379
+		$wpdb->prepare(
380
+			"SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
+			array($wpdb->terms . term_id)
382
+		)
383
+	);
384
+
385
+	foreach ($pn_categories as $pn_categories_obj) {
386
+		$return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
+			"title" => $pn_categories_obj->name,);
388
+	}
389
+	return $return_array;
390 390
 }
391 391
 
392 392
 
@@ -402,49 +402,49 @@  discard block
 block discarded – undo
402 402
  * @return string The post type.
403 403
  */
404 404
 function geodir_get_current_posttype() {
405
-    global $wp_query, $post, $geodir_post_type;
405
+	global $wp_query, $post, $geodir_post_type;
406 406
 
407
-    $geodir_post_type = get_query_var('post_type');
407
+	$geodir_post_type = get_query_var('post_type');
408 408
 
409
-    if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
-    }
409
+	if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
+			$geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
+		elseif (isset($_REQUEST['listing_type']))
413
+			$geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
+	}
415 415
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
416
+	if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
418 418
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
419
+	if (is_tax())
420
+		$geodir_post_type = geodir_get_taxonomy_posttype();
421 421
 
422
-    // Retrive post type for map marker html ajax request on preview page.
423
-    if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
-        if (!empty($post->post_type)) {
425
-            $geodir_post_type = $post->post_type;
426
-        } else if (!empty($post->listing_type)) {
427
-            $geodir_post_type = $post->listing_type;
428
-        }
429
-    }
422
+	// Retrive post type for map marker html ajax request on preview page.
423
+	if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
+		if (!empty($post->post_type)) {
425
+			$geodir_post_type = $post->post_type;
426
+		} else if (!empty($post->listing_type)) {
427
+			$geodir_post_type = $post->listing_type;
428
+		}
429
+	}
430 430
 
431
-    $all_postypes = geodir_get_posttypes();
432
-    $all_postypes = stripslashes_deep($all_postypes);
431
+	$all_postypes = geodir_get_posttypes();
432
+	$all_postypes = stripslashes_deep($all_postypes);
433 433
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
434
+	if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
+		$geodir_post_type = '';
436 436
 
437
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
-    }
437
+	if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
+	}
440 440
 
441 441
 
442
-    /**
443
-     * Filter the default CPT return.
444
-     *
445
-     * @since 1.6.9
446
-     */
447
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
442
+	/**
443
+	 * Filter the default CPT return.
444
+	 *
445
+	 * @since 1.6.9
446
+	 */
447
+	return apply_filters('geodir_get_current_posttype',$geodir_post_type);
448 448
 }
449 449
 
450 450
 /**
@@ -458,22 +458,22 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_get_default_posttype()
460 460
 {
461
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
-
463
-    $stype = false;
464
-    foreach ( $post_types as $post_type => $info ) {
465
-        global $wpdb;
466
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
-        if ( $has_posts ) {
468
-            $stype = $post_type; break;
469
-        }
470
-    }
471
-
472
-    if(!$stype){
473
-        $stype = 'gd_place';
474
-    }
475
-
476
-    return $stype;
461
+	$post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
+
463
+	$stype = false;
464
+	foreach ( $post_types as $post_type => $info ) {
465
+		global $wpdb;
466
+		$has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
+		if ( $has_posts ) {
468
+			$stype = $post_type; break;
469
+		}
470
+	}
471
+
472
+	if(!$stype){
473
+		$stype = 'gd_place';
474
+	}
475
+
476
+	return $stype;
477 477
 }
478 478
 
479 479
 /**
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
  */
488 488
 function geodir_get_posttypes($output = 'names')
489 489
 {
490
-    $post_types = array();
491
-    $post_types = get_option('geodir_post_types');
492
-    $post_types = stripslashes_deep($post_types);
493
-    if (!empty($post_types)) {
494
-        switch ($output):
495
-            case 'object':
496
-            case 'Object':
497
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
-                break;
499
-            case 'array':
500
-            case 'Array':
501
-                $post_types = (array)$post_types;
502
-                break;
490
+	$post_types = array();
491
+	$post_types = get_option('geodir_post_types');
492
+	$post_types = stripslashes_deep($post_types);
493
+	if (!empty($post_types)) {
494
+		switch ($output):
495
+			case 'object':
496
+			case 'Object':
497
+				$post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
+				break;
499
+			case 'array':
500
+			case 'Array':
501
+				$post_types = (array)$post_types;
502
+				break;
503 503
 			case 'options':
504
-                $post_types = (array)$post_types;
504
+				$post_types = (array)$post_types;
505 505
 				
506 506
 				$options = array();
507 507
 				if (!empty($post_types)) {
@@ -510,17 +510,17 @@  discard block
 block discarded – undo
510 510
 					}
511 511
 				}
512 512
 				$post_types = $options;
513
-                break;
514
-            default:
515
-                $post_types = array_keys($post_types);
516
-                break;
517
-        endswitch;
518
-    }
519
-
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
513
+				break;
514
+			default:
515
+				$post_types = array_keys($post_types);
516
+				break;
517
+		endswitch;
518
+	}
519
+
520
+	if (!empty($post_types))
521
+		return $post_types;
522
+	else
523
+		return array();
524 524
 }
525 525
 
526 526
 /**
@@ -533,104 +533,104 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function geodir_get_posttype_info($post_type = '')
535 535
 {
536
-    $post_types = array();
537
-    $post_types = get_option('geodir_post_types');
538
-    $post_types = stripslashes_deep($post_types);
539
-    if (!empty($post_types) && $post_type != '') {
540
-        return $post_types[$post_type];
541
-    } else
542
-        return false;
536
+	$post_types = array();
537
+	$post_types = get_option('geodir_post_types');
538
+	$post_types = stripslashes_deep($post_types);
539
+	if (!empty($post_types) && $post_type != '') {
540
+		return $post_types[$post_type];
541
+	} else
542
+		return false;
543 543
 }
544 544
 
545 545
 if (!function_exists('geodir_get_taxonomies')) {
546
-    /**
547
-     * Get all custom taxonomies.
548
-     *
549
-     * @since 1.0.0
550
-     * @package GeoDirectory
551
-     * @param string $post_type The post type.
552
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
-     * @return array|bool Taxonomies on success. false on failure.
554
-     */
555
-    function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) {
556
-        $taxonomies = array();
557
-        $gd_taxonomies = array();
558
-
559
-        if ($taxonomies = get_option('geodir_taxonomies')) {
560
-            $gd_taxonomies = array_keys($taxonomies);
561
-
562
-            if ($post_type != '') {
563
-                $gd_taxonomies = array();
564
-            }
546
+	/**
547
+	 * Get all custom taxonomies.
548
+	 *
549
+	 * @since 1.0.0
550
+	 * @package GeoDirectory
551
+	 * @param string $post_type The post type.
552
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
+	 * @return array|bool Taxonomies on success. false on failure.
554
+	 */
555
+	function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) {
556
+		$taxonomies = array();
557
+		$gd_taxonomies = array();
558
+
559
+		if ($taxonomies = get_option('geodir_taxonomies')) {
560
+			$gd_taxonomies = array_keys($taxonomies);
561
+
562
+			if ($post_type != '') {
563
+				$gd_taxonomies = array();
564
+			}
565 565
 
566
-            $i = 0;
567
-            foreach ($taxonomies as $taxonomy => $args) {
568
-                if ($post_type != '' && $args['object_type'] == $post_type) {
569
-                    $gd_taxonomies[] = $taxonomy;
570
-                }
566
+			$i = 0;
567
+			foreach ($taxonomies as $taxonomy => $args) {
568
+				if ($post_type != '' && $args['object_type'] == $post_type) {
569
+					$gd_taxonomies[] = $taxonomy;
570
+				}
571 571
 
572
-                if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
573
-                    if (array_search($taxonomy, $gd_taxonomies) !== false) {
574
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
575
-                    }
576
-                }
577
-            }
572
+				if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
573
+					if (array_search($taxonomy, $gd_taxonomies) !== false) {
574
+						unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
575
+					}
576
+				}
577
+			}
578
+
579
+			$gd_taxonomies = array_values($gd_taxonomies);
580
+		}
578 581
 
579
-            $gd_taxonomies = array_values($gd_taxonomies);
580
-        }
581
-
582
-        /**
583
-         * Filter the taxonomies.
584
-         *
585
-         * @since 1.0.0
586
-         * @param array $gd_taxonomies The taxonomy array.
587
-         */
588
-        $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
589
-
590
-        if (!empty($taxonomies)) {
591
-            return $taxonomies;
592
-        } else {
593
-            return false;
594
-        }
595
-    }
582
+		/**
583
+		 * Filter the taxonomies.
584
+		 *
585
+		 * @since 1.0.0
586
+		 * @param array $gd_taxonomies The taxonomy array.
587
+		 */
588
+		$taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
589
+
590
+		if (!empty($taxonomies)) {
591
+			return $taxonomies;
592
+		} else {
593
+			return false;
594
+		}
595
+	}
596 596
 }
597 597
 
598 598
 if (!function_exists(' geodir_get_categories_dl')) {
599
-    /**
600
-     * Get categories dropdown HTML.
601
-     *
602
-     * @since 1.0.0
603
-     * @package GeoDirectory
604
-     * @param string $post_type The post type.
605
-     * @param string $selected The selected value.
606
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
607
-     * @param bool $echo Prints the HTML when set to true. Default: true.
608
-     * @return void|string Dropdown HTML.
609
-     */
610
-    function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
611
-    {
612
-
613
-        $html = '';
614
-        $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
615
-
616
-        $categories = get_terms($taxonomies);
617
-
618
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
619
-
620
-        foreach ($categories as $category_obj) {
621
-            $select_opt = '';
622
-            if ($selected == $category_obj->term_id) {
623
-                $select_opt = 'selected="selected"';
624
-            }
625
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
626
-                . geodir_utf8_ucfirst($category_obj->name) . '</option>';
627
-        }
628
-
629
-        if ($echo)
630
-            echo $html;
631
-        else
632
-            return $html;
633
-    }
599
+	/**
600
+	 * Get categories dropdown HTML.
601
+	 *
602
+	 * @since 1.0.0
603
+	 * @package GeoDirectory
604
+	 * @param string $post_type The post type.
605
+	 * @param string $selected The selected value.
606
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
607
+	 * @param bool $echo Prints the HTML when set to true. Default: true.
608
+	 * @return void|string Dropdown HTML.
609
+	 */
610
+	function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
611
+	{
612
+
613
+		$html = '';
614
+		$taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
615
+
616
+		$categories = get_terms($taxonomies);
617
+
618
+		$html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
619
+
620
+		foreach ($categories as $category_obj) {
621
+			$select_opt = '';
622
+			if ($selected == $category_obj->term_id) {
623
+				$select_opt = 'selected="selected"';
624
+			}
625
+			$html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
626
+				. geodir_utf8_ucfirst($category_obj->name) . '</option>';
627
+		}
628
+
629
+		if ($echo)
630
+			echo $html;
631
+		else
632
+			return $html;
633
+	}
634 634
 }
635 635
 
636 636
 
@@ -645,28 +645,28 @@  discard block
 block discarded – undo
645 645
 function geodir_get_listing_slug($object_type = '')
646 646
 {
647 647
 
648
-    $listing_slug = '';
648
+	$listing_slug = '';
649 649
 
650
-    $post_types = get_option('geodir_post_types');
651
-    $taxonomies = get_option('geodir_taxonomies');
650
+	$post_types = get_option('geodir_post_types');
651
+	$taxonomies = get_option('geodir_taxonomies');
652 652
 
653 653
 
654
-    if ($object_type != '') {
655
-        if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
654
+	if ($object_type != '') {
655
+		if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
656 656
 
657
-            $object_info = $post_types[$object_type];
658
-            $listing_slug = $object_info['listing_slug'];
659
-        } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
660
-            $object_info = $taxonomies[$object_type];
661
-            $listing_slug = $object_info['listing_slug'];
662
-        }
657
+			$object_info = $post_types[$object_type];
658
+			$listing_slug = $object_info['listing_slug'];
659
+		} elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
660
+			$object_info = $taxonomies[$object_type];
661
+			$listing_slug = $object_info['listing_slug'];
662
+		}
663 663
 
664
-    }
664
+	}
665 665
 
666
-    if (!empty($listing_slug))
667
-        return $listing_slug;
668
-    else
669
-        return false;
666
+	if (!empty($listing_slug))
667
+		return $listing_slug;
668
+	else
669
+		return false;
670 670
 }
671 671
 
672 672
 
@@ -681,212 +681,212 @@  discard block
 block discarded – undo
681 681
  */
682 682
 function geodir_get_taxonomy_posttype($taxonomy = '')
683 683
 {
684
-    global $wp_query;
685
-
686
-    $post_type = array();
687
-    $taxonomies = array();
688
-
689
-    if (!empty($taxonomy)) {
690
-        $taxonomies[] = $taxonomy;
691
-    } elseif (isset($wp_query->tax_query->queries)) {
692
-        $tax_arr = $wp_query->tax_query->queries;
693
-        //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
694
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
695
-        $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
696
-    }
697
-
698
-    if (!empty($taxonomies)) {
699
-        foreach (geodir_get_posttypes() as $pt) {
700
-            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
701
-            if (array_intersect($taxonomies, $object_taxonomies))
702
-                $post_type[] = $pt;
703
-        }
704
-    }
705
-
706
-    if (!empty($post_type))
707
-        return $post_type[0];
708
-    else
709
-        return false;
684
+	global $wp_query;
685
+
686
+	$post_type = array();
687
+	$taxonomies = array();
688
+
689
+	if (!empty($taxonomy)) {
690
+		$taxonomies[] = $taxonomy;
691
+	} elseif (isset($wp_query->tax_query->queries)) {
692
+		$tax_arr = $wp_query->tax_query->queries;
693
+		//if tax query has 'relation' set then it will break wp_list_pluck so we remove it
694
+		if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
695
+		$taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
696
+	}
697
+
698
+	if (!empty($taxonomies)) {
699
+		foreach (geodir_get_posttypes() as $pt) {
700
+			$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
701
+			if (array_intersect($taxonomies, $object_taxonomies))
702
+				$post_type[] = $pt;
703
+		}
704
+	}
705
+
706
+	if (!empty($post_type))
707
+		return $post_type[0];
708
+	else
709
+		return false;
710 710
 }
711 711
 
712 712
 if (!function_exists('geodir_custom_taxonomy_walker')) {
713
-    /**
714
-     * Custom taxonomy walker function.
715
-     *
716
-     * @since 1.0.0
717
-     * @package GeoDirectory
718
-     * @param string $cat_taxonomy The taxonomy name.
719
-     * @param int $cat_parent The parent term ID.
720
-     * @param bool $hide_empty Hide empty taxonomies? Default: false.
721
-     * @param int $pading CSS padding in pixels.
722
-     * @return string|void taxonomy HTML.
723
-     */
724
-    function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
725
-    {
726
-        global $cat_display, $post_cat, $exclude_cats;
727
-
728
-        $search_terms = trim($post_cat, ",");
729
-
730
-        $search_terms = explode(",", $search_terms);
731
-
732
-        $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
733
-
734
-        $display = '';
735
-        $onchange = '';
736
-        $term_check = '';
737
-        $main_list_class = '';
738
-        $out = '';
739
-        //If there are terms, start displaying
740
-        if (count($cat_terms) > 0) {
741
-            //Displaying as a list
742
-            $p = $pading * 20;
743
-            $pading++;
744
-
745
-
746
-            if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
747
-                if ($cat_parent == 0) {
748
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
749
-                    $main_list_class = 'class="main_list_selecter"';
750
-                } else {
751
-                    //$display = 'display:none';
752
-                    $list_class = 'sub_list gd-sub-cats-list';
753
-                }
754
-            }
713
+	/**
714
+	 * Custom taxonomy walker function.
715
+	 *
716
+	 * @since 1.0.0
717
+	 * @package GeoDirectory
718
+	 * @param string $cat_taxonomy The taxonomy name.
719
+	 * @param int $cat_parent The parent term ID.
720
+	 * @param bool $hide_empty Hide empty taxonomies? Default: false.
721
+	 * @param int $pading CSS padding in pixels.
722
+	 * @return string|void taxonomy HTML.
723
+	 */
724
+	function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
725
+	{
726
+		global $cat_display, $post_cat, $exclude_cats;
727
+
728
+		$search_terms = trim($post_cat, ",");
729
+
730
+		$search_terms = explode(",", $search_terms);
731
+
732
+		$cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
733
+
734
+		$display = '';
735
+		$onchange = '';
736
+		$term_check = '';
737
+		$main_list_class = '';
738
+		$out = '';
739
+		//If there are terms, start displaying
740
+		if (count($cat_terms) > 0) {
741
+			//Displaying as a list
742
+			$p = $pading * 20;
743
+			$pading++;
744
+
745
+
746
+			if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
747
+				if ($cat_parent == 0) {
748
+					$list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
749
+					$main_list_class = 'class="main_list_selecter"';
750
+				} else {
751
+					//$display = 'display:none';
752
+					$list_class = 'sub_list gd-sub-cats-list';
753
+				}
754
+			}
755 755
 
756
-            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
757
-                $p = 0;
758
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
759
-            }
756
+			if ($cat_display == 'checkbox' || $cat_display == 'radio') {
757
+				$p = 0;
758
+				$out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
759
+			}
760 760
 
761
-            foreach ($cat_terms as $cat_term) {
761
+			foreach ($cat_terms as $cat_term) {
762 762
 
763
-                $checked = '';
763
+				$checked = '';
764 764
 
765
-                if (in_array($cat_term->term_id, $search_terms)) {
766
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
767
-                        $checked = 'selected="selected"';
768
-                    else
769
-                        $checked = 'checked="checked"';
770
-                }
765
+				if (in_array($cat_term->term_id, $search_terms)) {
766
+					if ($cat_display == 'select' || $cat_display == 'multiselect')
767
+						$checked = 'selected="selected"';
768
+					else
769
+						$checked = 'checked="checked"';
770
+				}
771 771
 
772
-                if ($cat_display == 'radio')
773
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
774
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
775
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
772
+				if ($cat_display == 'radio')
773
+					$out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
774
+				elseif ($cat_display == 'select' || $cat_display == 'multiselect')
775
+					$out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
776 776
 
777
-                else {
778
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
779
-                }
777
+				else {
778
+					$out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
779
+				}
780 780
 
781
-                // Call recurson to print sub cats
782
-                $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
781
+				// Call recurson to print sub cats
782
+				$out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
783 783
 
784
-            }
784
+			}
785 785
 
786
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
787
-                $out .= '</div>';
786
+			if ($cat_display == 'checkbox' || $cat_display == 'radio')
787
+				$out .= '</div>';
788 788
 
789
-            return $out;
790
-        }
791
-        return;
792
-    }
789
+			return $out;
790
+		}
791
+		return;
792
+	}
793 793
 }
794 794
 
795 795
 if (!function_exists('geodir_custom_taxonomy_walker2')) {
796
-    /**
797
-     * Custom taxonomy walker function.
798
-     *
799
-     * @since 1.0.0
800
-     * @package GeoDirectory
801
-     * @global object $post WordPress Post object.
802
-     * @global object $gd_session GeoDirectory Session object.
803
-     * @param string $cat_taxonomy The taxonomy name.
804
-     * @param string $cat_limit Number of categories to display.
805
-     */
806
-    function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
807
-    {
808
-        $post_category = '';
809
-        $post_category_str = '';
810
-        global $exclude_cats, $gd_session;
811
-
812
-        $cat_exclude = '';
813
-        if (is_array($exclude_cats) && !empty($exclude_cats))
814
-            $cat_exclude = serialize($exclude_cats);
815
-
816
-        if (isset($_REQUEST['backandedit'])) {
817
-            $post = (object)$gd_session->get('listing');
818
-
819
-            if (!is_array($post->post_category[$cat_taxonomy]))
820
-                $post_category = $post->post_category[$cat_taxonomy];
821
-
822
-            $post_categories = $post->post_category_str;
823
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
824
-                $post_category_str = $post_categories[$cat_taxonomy];
825
-
826
-        } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
827
-            global $post;
828
-
829
-            $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
830
-            if (empty($post_category) && isset($post->{$cat_taxonomy})) {
831
-                $post_category = $post->{$cat_taxonomy};
832
-            }
796
+	/**
797
+	 * Custom taxonomy walker function.
798
+	 *
799
+	 * @since 1.0.0
800
+	 * @package GeoDirectory
801
+	 * @global object $post WordPress Post object.
802
+	 * @global object $gd_session GeoDirectory Session object.
803
+	 * @param string $cat_taxonomy The taxonomy name.
804
+	 * @param string $cat_limit Number of categories to display.
805
+	 */
806
+	function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
807
+	{
808
+		$post_category = '';
809
+		$post_category_str = '';
810
+		global $exclude_cats, $gd_session;
811
+
812
+		$cat_exclude = '';
813
+		if (is_array($exclude_cats) && !empty($exclude_cats))
814
+			$cat_exclude = serialize($exclude_cats);
815
+
816
+		if (isset($_REQUEST['backandedit'])) {
817
+			$post = (object)$gd_session->get('listing');
818
+
819
+			if (!is_array($post->post_category[$cat_taxonomy]))
820
+				$post_category = $post->post_category[$cat_taxonomy];
821
+
822
+			$post_categories = $post->post_category_str;
823
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
824
+				$post_category_str = $post_categories[$cat_taxonomy];
825
+
826
+		} elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
827
+			global $post;
828
+
829
+			$post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
830
+			if (empty($post_category) && isset($post->{$cat_taxonomy})) {
831
+				$post_category = $post->{$cat_taxonomy};
832
+			}
833 833
 
834
-            $post_categories = get_post_meta($post->ID, 'post_categories', true);
834
+			$post_categories = get_post_meta($post->ID, 'post_categories', true);
835 835
 
836
-            if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
837
-                foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
838
-                    if (is_numeric($cat_part)) {
839
-                        $cat_part_arr[] = $cat_part;
840
-                    }
841
-                }
842
-                if (is_array($cat_part_arr)) {
843
-                    $post_category = implode(',', $cat_part_arr);
844
-                }
845
-            }
836
+			if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
837
+				foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
838
+					if (is_numeric($cat_part)) {
839
+						$cat_part_arr[] = $cat_part;
840
+					}
841
+				}
842
+				if (is_array($cat_part_arr)) {
843
+					$post_category = implode(',', $cat_part_arr);
844
+				}
845
+			}
846 846
 
847
-            if (!empty($post_category)) {
848
-                $cat1 = array_filter(explode(',', $post_category));
849
-                $post_category = ',' . implode(',', $cat1) . ',';
847
+			if (!empty($post_category)) {
848
+				$cat1 = array_filter(explode(',', $post_category));
849
+				$post_category = ',' . implode(',', $cat1) . ',';
850 850
 
851
-            }
851
+			}
852 852
 
853
-            if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
853
+			if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
854 854
 
855
-                $post_category_upd = explode(',', $post_category);
856
-                $post_category_change = '';
857
-                foreach ($post_category_upd as $cat) {
855
+				$post_category_upd = explode(',', $post_category);
856
+				$post_category_change = '';
857
+				foreach ($post_category_upd as $cat) {
858 858
 
859
-                    if (!in_array($cat, $exclude_cats) && $cat != '') {
860
-                        $post_category_change .= ',' . $cat;
861
-                    }
862
-                }
863
-                $post_category = $post_category_change;
864
-            }
859
+					if (!in_array($cat, $exclude_cats) && $cat != '') {
860
+						$post_category_change .= ',' . $cat;
861
+					}
862
+				}
863
+				$post_category = $post_category_change;
864
+			}
865 865
 
866 866
 
867
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
868
-                $post_category_str = $post_categories[$cat_taxonomy];
869
-            }
870
-        }
867
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
868
+				$post_category_str = $post_categories[$cat_taxonomy];
869
+			}
870
+		}
871 871
 
872
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
872
+		echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
873 873
 
874
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
874
+		echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
875 875
 
876
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
876
+		echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
877 877
 
878 878
 
879
-        ?>
879
+		?>
880 880
         <div class="cat_sublist">
881 881
             <?php
882 882
 
883
-            $post_id = isset($post->ID) ? $post->ID : '';
883
+			$post_id = isset($post->ID) ? $post->ID : '';
884 884
 
885
-            if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
885
+			if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
886 886
 
887
-                geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
888
-            }
889
-            ?>
887
+				geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
888
+			}
889
+			?>
890 890
         </div>
891 891
         <script type="text/javascript">
892 892
 
@@ -1009,22 +1009,22 @@  discard block
 block discarded – undo
1009 1009
 
1010 1010
         </script>
1011 1011
         <?php
1012
-        if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1013
-            $post_cat_str = $post_categories[$cat_taxonomy];
1014
-            $post_cat_array = explode("#", $post_cat_str);
1015
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1016
-                $style = "display:none;";
1017
-        }
1018
-        ?>
1012
+		if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1013
+			$post_cat_str = $post_categories[$cat_taxonomy];
1014
+			$post_cat_array = explode("#", $post_cat_str);
1015
+			if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1016
+				$style = "display:none;";
1017
+		}
1018
+		?>
1019 1019
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1020
-            echo $style;
1021
-        }?> ">
1020
+			echo $style;
1021
+		}?> ">
1022 1022
             <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1023
-            ?>
1023
+			?>
1024 1024
         </div>
1025 1025
     <?php
1026 1026
 
1027
-    }
1027
+	}
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1041,23 +1041,23 @@  discard block
 block discarded – undo
1041 1041
  */
1042 1042
 function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '')
1043 1043
 {
1044
-    global $exclude_cats;
1044
+	global $exclude_cats;
1045 1045
 
1046
-    if ($exclude != '') {
1047
-        $exclude_cats = maybe_unserialize(base64_decode($exclude));
1046
+	if ($exclude != '') {
1047
+		$exclude_cats = maybe_unserialize(base64_decode($exclude));
1048 1048
 
1049
-        if(is_array( $exclude_cats)){
1050
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1051
-        }else{
1052
-            $exclude_cats = intval($exclude_cats);
1053
-        }
1049
+		if(is_array( $exclude_cats)){
1050
+			$exclude_cats = array_map( 'intval', $exclude_cats );
1051
+		}else{
1052
+			$exclude_cats = intval($exclude_cats);
1053
+		}
1054 1054
 
1055
-    }
1055
+	}
1056 1056
 
1057
-    if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1058
-        (!is_array($exclude_cats) || empty($exclude_cats))
1059
-    ) {
1060
-        ?>
1057
+	if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1058
+		(!is_array($exclude_cats) || empty($exclude_cats))
1059
+	) {
1060
+		?>
1061 1061
 
1062 1062
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1063 1063
 
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
 
1087 1087
             <br/>
1088 1088
             <?php
1089
-            $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1090
-            if (!empty($cat_terms)) { ?>
1089
+			$cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1090
+			if (!empty($cat_terms)) { ?>
1091 1091
                 <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
1092 1092
                 <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?>
1093 1093
             <?php } ?>
@@ -1109,53 +1109,53 @@  discard block
 block discarded – undo
1109 1109
 function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories)
1110 1110
 {
1111 1111
 
1112
-    if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1113
-        $post_cat_str = $post_categories[$request_taxonomy];
1114
-        $post_cat_array = explode("#", $post_cat_str);
1115
-        if (is_array($post_cat_array)) {
1116
-            $post_cat_array = array_unique( $post_cat_array );
1112
+	if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1113
+		$post_cat_str = $post_categories[$request_taxonomy];
1114
+		$post_cat_array = explode("#", $post_cat_str);
1115
+		if (is_array($post_cat_array)) {
1116
+			$post_cat_array = array_unique( $post_cat_array );
1117 1117
 
1118 1118
 			foreach ($post_cat_array as $post_cat_html) {
1119 1119
 
1120
-                $post_cat_info = explode(":", $post_cat_html);
1121
-                $post_maincat_str = $post_cat_info[0];
1120
+				$post_cat_info = explode(":", $post_cat_html);
1121
+				$post_maincat_str = $post_cat_info[0];
1122 1122
 
1123
-                if (!empty($post_maincat_str)) {
1124
-                    $post_maincat_info = explode(",", $post_maincat_str);
1125
-                    $post_maincat_id = $post_maincat_info[0];
1126
-                    ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1127
-                    (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1128
-                }
1129
-                $post_sub_catid = '';
1130
-                if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1131
-                    $post_sub_catid = (int)$post_cat_info[1];
1132
-                }
1123
+				if (!empty($post_maincat_str)) {
1124
+					$post_maincat_info = explode(",", $post_maincat_str);
1125
+					$post_maincat_id = $post_maincat_info[0];
1126
+					($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1127
+					(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1128
+				}
1129
+				$post_sub_catid = '';
1130
+				if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1131
+					$post_sub_catid = (int)$post_cat_info[1];
1132
+				}
1133 1133
 
1134
-                geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1134
+				geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1135 1135
 
1136
-            }
1137
-        } else {
1136
+			}
1137
+		} else {
1138 1138
 
1139
-            $post_cat_info = explode(":", $post_cat_str);
1140
-            $post_maincat_str = $post_cat_info[0];
1139
+			$post_cat_info = explode(":", $post_cat_str);
1140
+			$post_maincat_str = $post_cat_info[0];
1141 1141
 
1142
-            $post_sub_catid = '';
1142
+			$post_sub_catid = '';
1143 1143
 
1144
-            if (!empty($post_maincat_str)) {
1145
-                $post_maincat_info = explode(",", $post_maincat_str);
1146
-                $post_maincat_id = $post_maincat_info[0];
1147
-                ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1148
-                (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1149
-            }
1144
+			if (!empty($post_maincat_str)) {
1145
+				$post_maincat_info = explode(",", $post_maincat_str);
1146
+				$post_maincat_id = $post_maincat_info[0];
1147
+				($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1148
+				(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1149
+			}
1150 1150
 
1151
-            if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1152
-                $post_sub_catid = (int)$post_cat_info[1];
1153
-            }
1151
+			if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1152
+				$post_sub_catid = (int)$post_cat_info[1];
1153
+			}
1154 1154
 
1155
-            geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1155
+			geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1156 1156
 
1157
-        }
1158
-    }
1157
+		}
1158
+	}
1159 1159
 }
1160 1160
 
1161 1161
 /**
@@ -1169,35 +1169,35 @@  discard block
 block discarded – undo
1169 1169
  */
1170 1170
 function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false)
1171 1171
 {
1172
-    global $exclude_cats;
1172
+	global $exclude_cats;
1173 1173
 
1174
-    $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1174
+	$cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1175 1175
 
1176
-    if (!empty($cat_terms)) {
1177
-        $onchange = '';
1178
-        $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1176
+	if (!empty($cat_terms)) {
1177
+		$onchange = '';
1178
+		$onchange = ' onchange="show_subcatlist(this.value, this)" ';
1179 1179
 
1180
-        $option_selected = '';
1181
-        if (!$selected)
1182
-            $option_slected = ' selected="selected" ';
1180
+		$option_selected = '';
1181
+		if (!$selected)
1182
+			$option_slected = ' selected="selected" ';
1183 1183
 
1184
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1184
+		echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1185 1185
 
1186
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1186
+		echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1187 1187
 
1188
-        foreach ($cat_terms as $cat_term) {
1189
-            $option_selected = '';
1190
-            if ($selected == $cat_term->term_id)
1191
-                $option_selected = ' selected="selected" ';
1188
+		foreach ($cat_terms as $cat_term) {
1189
+			$option_selected = '';
1190
+			if ($selected == $cat_term->term_id)
1191
+				$option_selected = ' selected="selected" ';
1192 1192
 
1193
-            // Count child terms
1194
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1195
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1193
+			// Count child terms
1194
+			$child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1195
+			$has_child = !empty( $child_terms ) ? 't' : 'f';
1196 1196
 
1197
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1198
-        }
1199
-        echo '</select>';
1200
-    }
1197
+			echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1198
+		}
1199
+		echo '</select>';
1200
+	}
1201 1201
 }
1202 1202
 
1203 1203
 /**
@@ -1213,28 +1213,28 @@  discard block
 block discarded – undo
1213 1213
  */
1214 1214
 function geodir_custom_update_messages($messages)
1215 1215
 {
1216
-    global $post, $post_ID;
1217
-
1218
-    $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1219
-
1220
-    foreach ($post_types as $post_type => $post_object) {
1221
-
1222
-        $messages[$post_type] = array(
1223
-            0 => '', // Unused. Messages start at index 1.
1224
-            1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225
-            2 => __('Custom field updated.', 'geodirectory'),
1226
-            3 => __('Custom field deleted.', 'geodirectory'),
1227
-            4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1228
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1229
-            6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1230
-            7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1231
-            8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1232
-            9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1233
-            10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1234
-        );
1235
-    }
1236
-
1237
-    return $messages;
1216
+	global $post, $post_ID;
1217
+
1218
+	$post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1219
+
1220
+	foreach ($post_types as $post_type => $post_object) {
1221
+
1222
+		$messages[$post_type] = array(
1223
+			0 => '', // Unused. Messages start at index 1.
1224
+			1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225
+			2 => __('Custom field updated.', 'geodirectory'),
1226
+			3 => __('Custom field deleted.', 'geodirectory'),
1227
+			4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1228
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1229
+			6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1230
+			7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1231
+			8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1232
+			9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1233
+			10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1234
+		);
1235
+	}
1236
+
1237
+	return $messages;
1238 1238
 }
1239 1239
 
1240 1240
 
@@ -1249,182 +1249,182 @@  discard block
 block discarded – undo
1249 1249
 function geodir_register_defaults()
1250 1250
 {
1251 1251
 
1252
-    global $wpdb;
1253
-
1254
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1255
-
1256
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1257
-        $listing_slug = 'places';
1258
-
1259
-    /**
1260
-     * Taxonomies
1261
-     **/
1262
-    //if ( ! taxonomy_exists('gd_place_tags') )
1263
-    {
1264
-
1265
-        $gd_placetags = array();
1266
-        $gd_placetags['object_type'] = 'gd_place';
1267
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1268
-        $gd_placetags['args'] = array(
1269
-            'public' => true,
1270
-            'hierarchical' => false,
1271
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1272
-            'query_var' => true,
1273
-
1274
-            'labels' => array(
1275
-                'name' => __('Place Tags', 'geodirectory'),
1276
-                'singular_name' => __('Place Tag', 'geodirectory'),
1277
-                'search_items' => __('Search Place Tags', 'geodirectory'),
1278
-                'popular_items' => __('Popular Place Tags', 'geodirectory'),
1279
-                'all_items' => __('All Place Tags', 'geodirectory'),
1280
-                'edit_item' => __('Edit Place Tag', 'geodirectory'),
1281
-                'update_item' => __('Update Place Tag', 'geodirectory'),
1282
-                'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1283
-                'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1284
-                'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1285
-                'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1286
-                'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1287
-            ),
1288
-        );
1289
-
1290
-
1291
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1292
-        $geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1293
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1294
-
1295
-
1296
-        // Update post types and delete tmp options
1297
-        flush_rewrite_rules();
1298
-
1299
-    }
1300
-
1301
-    //if ( ! taxonomy_exists('gd_placecategory') )
1302
-    {
1303
-
1304
-        $gd_placecategory = array();
1305
-        $gd_placecategory['object_type'] = 'gd_place';
1306
-        $gd_placecategory['listing_slug'] = $listing_slug;
1307
-        $gd_placecategory['args'] = array(
1308
-            'public' => true,
1309
-            'hierarchical' => true,
1310
-            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1311
-            'query_var' => true,
1312
-            'labels' => array(
1313
-                'name' => __('Place Categories', 'geodirectory'),
1314
-                'singular_name' => __('Place Category', 'geodirectory'),
1315
-                'search_items' => __('Search Place Categories', 'geodirectory'),
1316
-                'popular_items' => __('Popular Place Categories', 'geodirectory'),
1317
-                'all_items' => __('All Place Categories', 'geodirectory'),
1318
-                'edit_item' => __('Edit Place Category', 'geodirectory'),
1319
-                'update_item' => __('Update Place Category', 'geodirectory'),
1320
-                'add_new_item' => __('Add New Place Category', 'geodirectory'),
1321
-                'new_item_name' => __('New Place Category', 'geodirectory'),
1322
-                'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1323
-            ),
1324
-        );
1325
-
1326
-
1327
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1328
-        $geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1329
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1330
-
1331
-
1332
-        flush_rewrite_rules();
1333
-    }
1334
-
1335
-    /**
1336
-     * Post Types
1337
-     **/
1338
-
1339
-    //if ( ! post_type_exists('gd_place') )
1340
-    {
1341
-
1342
-        $labels = array(
1343
-            'name' => __('Places', 'geodirectory'),
1344
-            'singular_name' => __('Place', 'geodirectory'),
1345
-            'add_new' => __('Add New', 'geodirectory'),
1346
-            'add_new_item' => __('Add New Place', 'geodirectory'),
1347
-            'edit_item' => __('Edit Place', 'geodirectory'),
1348
-            'new_item' => __('New Place', 'geodirectory'),
1349
-            'view_item' => __('View Place', 'geodirectory'),
1350
-            'search_items' => __('Search Places', 'geodirectory'),
1351
-            'not_found' => __('No Place Found', 'geodirectory'),
1352
-            'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1353
-
1354
-        $place_default = array(
1355
-            'labels' => $labels,
1356
-            'can_export' => true,
1357
-            'capability_type' => 'post',
1358
-            'description' => 'Place post type.',
1359
-            'has_archive' => $listing_slug,
1360
-            'hierarchical' => false,
1361
-            'map_meta_cap' => true,
1362
-            'menu_icon' => $menu_icon,
1363
-            'public' => true,
1364
-            'query_var' => true,
1365
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1366
-            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1367
-            'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1368
-
1369
-        //Update custom post types
1370
-        $geodir_post_types = get_option('geodir_post_types');
1371
-        $geodir_post_types['gd_place'] = $place_default;
1372
-        update_option('geodir_post_types', $geodir_post_types);
1373
-
1374
-        // Update post types and delete tmp options
1375
-        flush_rewrite_rules();
1376
-    }
1377
-
1378
-
1379
-    geodir_register_taxonomies();
1380
-    geodir_register_post_types();
1381
-
1382
-    //die;
1252
+	global $wpdb;
1253
+
1254
+	$menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1255
+
1256
+	if (!$listing_slug = get_option('geodir_listing_prefix'))
1257
+		$listing_slug = 'places';
1258
+
1259
+	/**
1260
+	 * Taxonomies
1261
+	 **/
1262
+	//if ( ! taxonomy_exists('gd_place_tags') )
1263
+	{
1264
+
1265
+		$gd_placetags = array();
1266
+		$gd_placetags['object_type'] = 'gd_place';
1267
+		$gd_placetags['listing_slug'] = $listing_slug . '/tags';
1268
+		$gd_placetags['args'] = array(
1269
+			'public' => true,
1270
+			'hierarchical' => false,
1271
+			'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1272
+			'query_var' => true,
1273
+
1274
+			'labels' => array(
1275
+				'name' => __('Place Tags', 'geodirectory'),
1276
+				'singular_name' => __('Place Tag', 'geodirectory'),
1277
+				'search_items' => __('Search Place Tags', 'geodirectory'),
1278
+				'popular_items' => __('Popular Place Tags', 'geodirectory'),
1279
+				'all_items' => __('All Place Tags', 'geodirectory'),
1280
+				'edit_item' => __('Edit Place Tag', 'geodirectory'),
1281
+				'update_item' => __('Update Place Tag', 'geodirectory'),
1282
+				'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1283
+				'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1284
+				'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1285
+				'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1286
+				'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1287
+			),
1288
+		);
1289
+
1290
+
1291
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1292
+		$geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1293
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1294
+
1295
+
1296
+		// Update post types and delete tmp options
1297
+		flush_rewrite_rules();
1298
+
1299
+	}
1300
+
1301
+	//if ( ! taxonomy_exists('gd_placecategory') )
1302
+	{
1303
+
1304
+		$gd_placecategory = array();
1305
+		$gd_placecategory['object_type'] = 'gd_place';
1306
+		$gd_placecategory['listing_slug'] = $listing_slug;
1307
+		$gd_placecategory['args'] = array(
1308
+			'public' => true,
1309
+			'hierarchical' => true,
1310
+			'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1311
+			'query_var' => true,
1312
+			'labels' => array(
1313
+				'name' => __('Place Categories', 'geodirectory'),
1314
+				'singular_name' => __('Place Category', 'geodirectory'),
1315
+				'search_items' => __('Search Place Categories', 'geodirectory'),
1316
+				'popular_items' => __('Popular Place Categories', 'geodirectory'),
1317
+				'all_items' => __('All Place Categories', 'geodirectory'),
1318
+				'edit_item' => __('Edit Place Category', 'geodirectory'),
1319
+				'update_item' => __('Update Place Category', 'geodirectory'),
1320
+				'add_new_item' => __('Add New Place Category', 'geodirectory'),
1321
+				'new_item_name' => __('New Place Category', 'geodirectory'),
1322
+				'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1323
+			),
1324
+		);
1325
+
1326
+
1327
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1328
+		$geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1329
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1330
+
1331
+
1332
+		flush_rewrite_rules();
1333
+	}
1334
+
1335
+	/**
1336
+	 * Post Types
1337
+	 **/
1338
+
1339
+	//if ( ! post_type_exists('gd_place') )
1340
+	{
1341
+
1342
+		$labels = array(
1343
+			'name' => __('Places', 'geodirectory'),
1344
+			'singular_name' => __('Place', 'geodirectory'),
1345
+			'add_new' => __('Add New', 'geodirectory'),
1346
+			'add_new_item' => __('Add New Place', 'geodirectory'),
1347
+			'edit_item' => __('Edit Place', 'geodirectory'),
1348
+			'new_item' => __('New Place', 'geodirectory'),
1349
+			'view_item' => __('View Place', 'geodirectory'),
1350
+			'search_items' => __('Search Places', 'geodirectory'),
1351
+			'not_found' => __('No Place Found', 'geodirectory'),
1352
+			'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1353
+
1354
+		$place_default = array(
1355
+			'labels' => $labels,
1356
+			'can_export' => true,
1357
+			'capability_type' => 'post',
1358
+			'description' => 'Place post type.',
1359
+			'has_archive' => $listing_slug,
1360
+			'hierarchical' => false,
1361
+			'map_meta_cap' => true,
1362
+			'menu_icon' => $menu_icon,
1363
+			'public' => true,
1364
+			'query_var' => true,
1365
+			'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1366
+			'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1367
+			'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1368
+
1369
+		//Update custom post types
1370
+		$geodir_post_types = get_option('geodir_post_types');
1371
+		$geodir_post_types['gd_place'] = $place_default;
1372
+		update_option('geodir_post_types', $geodir_post_types);
1373
+
1374
+		// Update post types and delete tmp options
1375
+		flush_rewrite_rules();
1376
+	}
1377
+
1378
+
1379
+	geodir_register_taxonomies();
1380
+	geodir_register_post_types();
1381
+
1382
+	//die;
1383 1383
 
1384 1384
 }
1385 1385
 
1386 1386
 $gd_wpml_get_languages = "";
1387 1387
 function gd_wpml_get_lang_from_url($url) {
1388
-    global $sitepress, $gd_wpml_get_languages;
1388
+	global $sitepress, $gd_wpml_get_languages;
1389 1389
     
1390
-    if (geodir_is_wpml()) {
1391
-        return $sitepress->get_language_from_url($url);
1392
-    }
1390
+	if (geodir_is_wpml()) {
1391
+		return $sitepress->get_language_from_url($url);
1392
+	}
1393 1393
     
1394
-    if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1395
-        return $_REQUEST['lang'];
1396
-    }
1394
+	if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1395
+		return $_REQUEST['lang'];
1396
+	}
1397 1397
 
1398
-    $url = str_replace(array("http://","https://"),"",$url);
1398
+	$url = str_replace(array("http://","https://"),"",$url);
1399 1399
 
1400
-    // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1401
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1400
+	// site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1401
+	$site_url = str_replace(array("http://","https://"),"",site_url());
1402 1402
 
1403
-    $url = str_replace($site_url,"",$url);
1403
+	$url = str_replace($site_url,"",$url);
1404 1404
 
1405
-    $segments = explode('/', trim($url, '/'));
1405
+	$segments = explode('/', trim($url, '/'));
1406 1406
 
1407
-    if ($gd_wpml_get_languages) {
1408
-        $langs = $gd_wpml_get_languages;
1409
-    } else {
1410
-        $gd_wpml_get_languages = $sitepress->get_active_languages();
1411
-    }
1407
+	if ($gd_wpml_get_languages) {
1408
+		$langs = $gd_wpml_get_languages;
1409
+	} else {
1410
+		$gd_wpml_get_languages = $sitepress->get_active_languages();
1411
+	}
1412 1412
 
1413
-    if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1414
-        return $segments[0];
1415
-    }
1413
+	if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1414
+		return $segments[0];
1415
+	}
1416 1416
 
1417
-    return false;
1417
+	return false;
1418 1418
 }
1419 1419
 
1420 1420
 function gd_wpml_slug_translation_turned_on($post_type) {
1421 1421
 
1422
-    global $sitepress;
1423
-    $settings = $sitepress->get_settings();
1424
-    return isset($settings['posts_slug_translation']['types'][$post_type])
1425
-    && $settings['posts_slug_translation']['types'][$post_type]
1426
-    && isset($settings['posts_slug_translation']['on'])
1427
-    && $settings['posts_slug_translation']['on'];
1422
+	global $sitepress;
1423
+	$settings = $sitepress->get_settings();
1424
+	return isset($settings['posts_slug_translation']['types'][$post_type])
1425
+	&& $settings['posts_slug_translation']['types'][$post_type]
1426
+	&& isset($settings['posts_slug_translation']['on'])
1427
+	&& $settings['posts_slug_translation']['on'];
1428 1428
 }
1429 1429
 
1430 1430
 
@@ -1451,158 +1451,158 @@  discard block
 block discarded – undo
1451 1451
  */
1452 1452
 function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample)
1453 1453
 {
1454
-    //echo $post_link."<br />".$sample ;
1454
+	//echo $post_link."<br />".$sample ;
1455 1455
 
1456 1456
 
1457
-    global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1458
-    if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1459
-    } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1460
-        return $post_link;
1461
-    } else {
1462
-        $orig_post = $post;
1463
-        $post = $post_obj;
1464
-    }
1457
+	global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1458
+	if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1459
+	} elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1460
+		return $post_link;
1461
+	} else {
1462
+		$orig_post = $post;
1463
+		$post = $post_obj;
1464
+	}
1465 1465
 
1466
-    if (in_array($post->post_type, geodir_get_posttypes())) {
1466
+	if (in_array($post->post_type, geodir_get_posttypes())) {
1467 1467
 
1468
-        // if we dont have a GD post then try to grab it
1469
-        if(!isset($post->default_category)){
1470
-            $gd_post = geodir_get_post_info($post->ID);
1471
-            if(!empty($gd_post)){
1472
-                $post = $gd_post;
1473
-            }
1474
-        }
1468
+		// if we dont have a GD post then try to grab it
1469
+		if(!isset($post->default_category)){
1470
+			$gd_post = geodir_get_post_info($post->ID);
1471
+			if(!empty($gd_post)){
1472
+				$post = $gd_post;
1473
+			}
1474
+		}
1475 1475
 
1476 1476
 
1477
-        $post_types = get_option('geodir_post_types');
1478
-        $slug = $post_types[$post->post_type]['rewrite']['slug'];
1477
+		$post_types = get_option('geodir_post_types');
1478
+		$slug = $post_types[$post->post_type]['rewrite']['slug'];
1479 1479
 
1480
-        // Alter the CPT slug if WPML is set to do so
1481
-        if(geodir_wpml_is_post_type_translated($post->post_type)){
1482
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1480
+		// Alter the CPT slug if WPML is set to do so
1481
+		if(geodir_wpml_is_post_type_translated($post->post_type)){
1482
+			if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1483 1483
 
1484
-                $org_slug = $slug;
1485
-                $slug = apply_filters( 'wpml_translate_single_string',
1486
-                    $slug,
1487
-                    'WordPress',
1488
-                    'URL slug: ' . $slug,
1489
-                    $language_code);
1484
+				$org_slug = $slug;
1485
+				$slug = apply_filters( 'wpml_translate_single_string',
1486
+					$slug,
1487
+					'WordPress',
1488
+					'URL slug: ' . $slug,
1489
+					$language_code);
1490 1490
 
1491
-                if(!$slug){$slug = $org_slug;}
1491
+				if(!$slug){$slug = $org_slug;}
1492 1492
 
1493
-            }
1494
-        }
1493
+			}
1494
+		}
1495 1495
 
1496
-        if (function_exists('geodir_location_geo_home_link')) {
1497
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1498
-        }
1496
+		if (function_exists('geodir_location_geo_home_link')) {
1497
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1498
+		}
1499 1499
         
1500
-        // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1501
-        $site_url = trailingslashit(get_bloginfo('url'));
1500
+		// Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1501
+		$site_url = trailingslashit(get_bloginfo('url'));
1502 1502
         
1503
-        if (function_exists('geodir_location_geo_home_link')) {
1504
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1505
-        }
1506
-
1507
-        $fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1508
-        if ($fix_url) {
1509
-            $post_link = str_replace($site_url, '', $post_link);
1510
-        }
1511
-
1512
-        $post_link = trailingslashit(
1513
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1514
-        );
1515
-
1516
-        if ($fix_url) {
1517
-            $post_link = $site_url . $post_link;
1518
-        }
1519
-
1520
-        if (isset($comment_post_cache[$post->ID])) {
1521
-            $post = $comment_post_cache[$post->ID];
1522
-        }
1523
-        if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1524
-            $post_id = $post->ID;
1525
-            if (isset($orig_post)) {
1526
-                $post = $orig_post;
1527
-            }
1528
-            return $gd_permalink_cache[$post_id];
1529
-        }
1503
+		if (function_exists('geodir_location_geo_home_link')) {
1504
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1505
+		}
1506
+
1507
+		$fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1508
+		if ($fix_url) {
1509
+			$post_link = str_replace($site_url, '', $post_link);
1510
+		}
1530 1511
 
1531
-        if (!isset($post->post_locations)) {
1532
-            $post_type = $post->post_type;
1533
-            $ID = $post->ID;
1534
-            $post2 = $wpdb->get_row(
1535
-                $wpdb->prepare(
1536
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1537
-                    array($post->ID)
1538
-                )
1539
-            );
1512
+		$post_link = trailingslashit(
1513
+			preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1514
+		);
1515
+
1516
+		if ($fix_url) {
1517
+			$post_link = $site_url . $post_link;
1518
+		}
1519
+
1520
+		if (isset($comment_post_cache[$post->ID])) {
1521
+			$post = $comment_post_cache[$post->ID];
1522
+		}
1523
+		if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1524
+			$post_id = $post->ID;
1525
+			if (isset($orig_post)) {
1526
+				$post = $orig_post;
1527
+			}
1528
+			return $gd_permalink_cache[$post_id];
1529
+		}
1540 1530
 
1541
-            $post = (object)array_merge((array)$post, (array)$post2);
1531
+		if (!isset($post->post_locations)) {
1532
+			$post_type = $post->post_type;
1533
+			$ID = $post->ID;
1534
+			$post2 = $wpdb->get_row(
1535
+				$wpdb->prepare(
1536
+					"SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1537
+					array($post->ID)
1538
+				)
1539
+			);
1542 1540
 
1543
-            $comment_post_cache[$post->ID] = $post;
1544
-        }
1541
+			$post = (object)array_merge((array)$post, (array)$post2);
1545 1542
 
1543
+			$comment_post_cache[$post->ID] = $post;
1544
+		}
1546 1545
 
1547 1546
 
1548
-        if (false !== strpos($post_link, '%gd_taxonomy%')) {
1549 1547
 
1550
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1551
-                $location_request = '';
1548
+		if (false !== strpos($post_link, '%gd_taxonomy%')) {
1552 1549
 
1550
+			if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1551
+				$location_request = '';
1553 1552
 
1554
-                if (!empty($post->post_locations)) {
1555
-                    $geodir_arr_locations = explode(',', $post->post_locations);
1556
-                    if (count($geodir_arr_locations) == 3) {
1557
-                        $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1558
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1559
-                        $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1560
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1561
-                        $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1562
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1563 1553
 
1564
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1565
-                            'region_slug' => $post->region_slug,
1566
-                            'city_slug' => $post->city_slug
1567
-                        );
1554
+				if (!empty($post->post_locations)) {
1555
+					$geodir_arr_locations = explode(',', $post->post_locations);
1556
+					if (count($geodir_arr_locations) == 3) {
1557
+						$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1558
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1559
+						$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1560
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1561
+						$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1562
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1568 1563
 
1569
-                    } else
1570
-                        $post_location = geodir_get_location();
1564
+						$post_location = (object)array('country_slug' => $post->country_slug,
1565
+							'region_slug' => $post->region_slug,
1566
+							'city_slug' => $post->city_slug
1567
+						);
1571 1568
 
1569
+					} else
1570
+						$post_location = geodir_get_location();
1572 1571
 
1573
-                } else {
1574 1572
 
1575
-                    $post_location_sql = $wpdb->get_results(
1576
-                        $wpdb->prepare(
1577
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1578
-                            array($post->ID)
1579
-                        )
1580
-                    );
1581
-
1582
-                    if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1583
-
1584
-                        $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1585
-                        if (count($geodir_arr_locations) == 3) {
1586
-                            $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1587
-                            $post->city_slug = str_replace(']', '', $post->city_slug);
1588
-                            $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1589
-                            $post->region_slug = str_replace(']', '', $post->region_slug);
1590
-                            $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1591
-                            $post->country_slug = str_replace(']', '', $post->country_slug);
1592
-
1593
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1594
-                                'region_slug' => $post->region_slug,
1595
-                                'city_slug' => $post->city_slug
1596
-                            );
1573
+				} else {
1597 1574
 
1598
-                        }
1599
-                    } else
1600
-                        $post_location = geodir_get_location();
1601
-                }
1575
+					$post_location_sql = $wpdb->get_results(
1576
+						$wpdb->prepare(
1577
+							"SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1578
+							array($post->ID)
1579
+						)
1580
+					);
1581
+
1582
+					if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1583
+
1584
+						$geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1585
+						if (count($geodir_arr_locations) == 3) {
1586
+							$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1587
+							$post->city_slug = str_replace(']', '', $post->city_slug);
1588
+							$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1589
+							$post->region_slug = str_replace(']', '', $post->region_slug);
1590
+							$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1591
+							$post->country_slug = str_replace(']', '', $post->country_slug);
1592
+
1593
+							$post_location = (object)array('country_slug' => $post->country_slug,
1594
+								'region_slug' => $post->region_slug,
1595
+								'city_slug' => $post->city_slug
1596
+							);
1597
+
1598
+						}
1599
+					} else
1600
+						$post_location = geodir_get_location();
1601
+				}
1602 1602
 
1603 1603
 
1604
-                if (!empty($post_location)) {
1605
-                    $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1604
+				if (!empty($post_location)) {
1605
+					$country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1606 1606
 					$region_slug = isset($post_location->region_slug) ? $post_location->region_slug : '';
1607 1607
 					$city_slug = isset($post_location->city_slug) ? $post_location->city_slug : '';
1608 1608
 					
@@ -1620,88 +1620,88 @@  discard block
 block discarded – undo
1620 1620
 					$location_slug[] = $city_slug;
1621 1621
 					
1622 1622
 					$location_request .= implode('/', $location_slug) . '/';
1623
-                }
1624
-            }
1623
+				}
1624
+			}
1625 1625
 
1626
-            if (get_option('geodir_add_categories_url')) {
1626
+			if (get_option('geodir_add_categories_url')) {
1627 1627
 
1628
-                $term_request = '';
1629
-                $taxonomies = geodir_get_taxonomies($post->post_type);
1630
-                $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : '';
1628
+				$term_request = '';
1629
+				$taxonomies = geodir_get_taxonomies($post->post_type);
1630
+				$taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : '';
1631 1631
 
1632
-                if (!empty($post->default_category)) {
1633
-                    $post_terms = $post->default_category;
1634
-                } else {
1635
-                    $post_terms = '';
1636
-
1637
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1638
-                        $post_terms = absint($_POST['post_default_category']);
1639
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1640
-                        $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1641
-                        $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1642
-                    }elseif (isset($post->{$taxonomies})) {
1643
-                        $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1644
-                        $post_terms = $post_terms[0];
1645
-                    }
1632
+				if (!empty($post->default_category)) {
1633
+					$post_terms = $post->default_category;
1634
+				} else {
1635
+					$post_terms = '';
1636
+
1637
+					if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1638
+						$post_terms = absint($_POST['post_default_category']);
1639
+					}elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1640
+						$post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1641
+						$post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1642
+					}elseif (isset($post->{$taxonomies})) {
1643
+						$post_terms = explode(",", trim($post->{$taxonomies}, ","));
1644
+						$post_terms = $post_terms[0];
1645
+					}
1646 1646
 
1647
-                    if (!$post_terms)
1648
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1647
+					if (!$post_terms)
1648
+						$post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1649 1649
 
1650
-                    if (!$post_terms) {
1651
-                        $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1650
+					if (!$post_terms) {
1651
+						$post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1652 1652
 
1653
-                        if ($post_terms) {
1654
-                            $post_terms = explode(",", trim($post_terms, ","));
1655
-                            $post_terms = $post_terms[0];
1656
-                        }
1657
-                    }
1658
-                }
1653
+						if ($post_terms) {
1654
+							$post_terms = explode(",", trim($post_terms, ","));
1655
+							$post_terms = $post_terms[0];
1656
+						}
1657
+					}
1658
+				}
1659 1659
 
1660
-                $term = get_term_by('id', $post_terms, $taxonomies);
1660
+				$term = get_term_by('id', $post_terms, $taxonomies);
1661 1661
 
1662
-                if (!empty($term))
1663
-                    $term_request = $term->slug;
1664
-                //$term_request = $term->slug.'/';
1665
-            }
1662
+				if (!empty($term))
1663
+					$term_request = $term->slug;
1664
+				//$term_request = $term->slug.'/';
1665
+			}
1666 1666
 
1667
-            $request_term = '';
1668
-            $listingurl_separator = '';
1669
-            //$detailurl_separator = get_option('geodir_detailurl_separator');
1670
-            $detailurl_separator = '';
1671
-            if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1672
-                $request_term = $location_request;
1673
-                //$listingurl_separator = get_option('geodir_listingurl_separator');
1674
-                //$request_term .= $listingurl_separator.'/'.$term_request;
1675
-                $request_term .= $term_request;
1667
+			$request_term = '';
1668
+			$listingurl_separator = '';
1669
+			//$detailurl_separator = get_option('geodir_detailurl_separator');
1670
+			$detailurl_separator = '';
1671
+			if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1672
+				$request_term = $location_request;
1673
+				//$listingurl_separator = get_option('geodir_listingurl_separator');
1674
+				//$request_term .= $listingurl_separator.'/'.$term_request;
1675
+				$request_term .= $term_request;
1676 1676
 
1677
-            } else {
1678
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1677
+			} else {
1678
+				if (isset($location_request) && $location_request != '') $request_term = $location_request;
1679 1679
 
1680
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1681
-            }
1682
-            $request_term = trim($request_term, '/');
1680
+				if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1681
+			}
1682
+			$request_term = trim($request_term, '/');
1683 1683
             
1684
-            // Fix with WPML the location terms added twice when CPT slug is translated.
1685
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1686
-                $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1687
-            }
1684
+			// Fix with WPML the location terms added twice when CPT slug is translated.
1685
+			if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1686
+				$post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1687
+			}
1688 1688
             
1689
-            if (!empty($request_term))
1690
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1691
-            else
1692
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1693
-            //echo $post_link ;
1694
-        }
1695
-        // temp cache the permalink
1696
-        if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1697
-            $gd_permalink_cache[$post->ID] = $post_link;
1698
-        }
1699
-    }
1700
-    if (isset($orig_post)) {
1701
-        $post = $orig_post;
1702
-    }
1703
-
1704
-    return $post_link;
1689
+			if (!empty($request_term))
1690
+				$post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1691
+			else
1692
+				$post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1693
+			//echo $post_link ;
1694
+		}
1695
+		// temp cache the permalink
1696
+		if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1697
+			$gd_permalink_cache[$post->ID] = $post_link;
1698
+		}
1699
+	}
1700
+	if (isset($orig_post)) {
1701
+		$post = $orig_post;
1702
+	}
1703
+
1704
+	return $post_link;
1705 1705
 }
1706 1706
 
1707 1707
 /**
@@ -1717,99 +1717,99 @@  discard block
 block discarded – undo
1717 1717
  * @return string The term link.
1718 1718
  */
1719 1719
 function geodir_term_link($termlink, $term, $taxonomy) {
1720
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1720
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1721 1721
 
1722
-    if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1723
-        global $geodir_add_location_url, $gd_session;
1724
-        $include_location = false;
1725
-        $request_term = array();
1726
-        $add_location_url = get_option('geodir_add_location_url');
1727
-        $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1722
+	if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1723
+		global $geodir_add_location_url, $gd_session;
1724
+		$include_location = false;
1725
+		$request_term = array();
1726
+		$add_location_url = get_option('geodir_add_location_url');
1727
+		$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1728 1728
 
1729
-        $listing_slug = geodir_get_listing_slug($taxonomy);
1729
+		$listing_slug = geodir_get_listing_slug($taxonomy);
1730 1730
 
1731
-        if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1732
-            if ($geodir_add_location_url && $add_location_url) {
1733
-                $include_location = true;
1734
-            }
1735
-        } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1736
-            $include_location = true;
1737
-        } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1738
-            $include_location = true;
1739
-        }
1740
-
1741
-        if ($include_location) {
1742
-            global $post;
1731
+		if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1732
+			if ($geodir_add_location_url && $add_location_url) {
1733
+				$include_location = true;
1734
+			}
1735
+		} elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1736
+			$include_location = true;
1737
+		} elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1738
+			$include_location = true;
1739
+		}
1740
+
1741
+		if ($include_location) {
1742
+			global $post;
1743 1743
             
1744
-            $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1744
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1745 1745
             
1746
-            if (geodir_is_page('detail') && isset($post->country_slug)) {
1747
-                $location_terms = array(
1748
-                    'gd_country' => $post->country_slug,
1749
-                    'gd_region' => $post->region_slug,
1750
-                    'gd_city' => $post->city_slug
1751
-                );
1746
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
1747
+				$location_terms = array(
1748
+					'gd_country' => $post->country_slug,
1749
+					'gd_region' => $post->region_slug,
1750
+					'gd_city' => $post->city_slug
1751
+				);
1752 1752
                 
1753
-                if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1754
-                    $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1755
-                }
1756
-            } else {
1757
-                $location_terms = geodir_get_current_location_terms('query_vars');
1758
-            }
1753
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1754
+					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1755
+				}
1756
+			} else {
1757
+				$location_terms = geodir_get_current_location_terms('query_vars');
1758
+			}
1759 1759
 
1760
-            $geodir_show_location_url = get_option('geodir_show_location_url');
1761
-            $location_terms = geodir_remove_location_terms($location_terms);
1760
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1761
+			$location_terms = geodir_remove_location_terms($location_terms);
1762 1762
 
1763
-            if (!empty($location_terms)) {
1764
-                $url_separator = '';
1763
+			if (!empty($location_terms)) {
1764
+				$url_separator = '';
1765 1765
 
1766
-                if (get_option('permalink_structure') != '') {
1767
-                    $old_listing_slug = '/' . $listing_slug . '/';
1768
-                    $request_term = implode("/", $location_terms);
1769
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1766
+				if (get_option('permalink_structure') != '') {
1767
+					$old_listing_slug = '/' . $listing_slug . '/';
1768
+					$request_term = implode("/", $location_terms);
1769
+					$new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1770 1770
 
1771
-                    $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1772
-                } else {
1773
-                    $termlink = geodir_getlink($termlink, $request_term);
1774
-                }
1775
-            }
1776
-        }
1771
+					$termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1772
+				} else {
1773
+					$termlink = geodir_getlink($termlink, $request_term);
1774
+				}
1775
+			}
1776
+		}
1777 1777
 
1778
-        // Alter the CPT slug is WPML is set to do so
1779
-        /* we can replace this with the below function
1778
+		// Alter the CPT slug is WPML is set to do so
1779
+		/* we can replace this with the below function
1780 1780
         if(geodir_is_wpml()){
1781 1781
             global $sitepress;
1782 1782
             $post_type = str_replace("category","",$taxonomy);
1783 1783
             $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type);
1784 1784
         }*/
1785 1785
 
1786
-        // Alter the CPT slug if WPML is set to do so
1787
-        if (geodir_is_wpml()) {
1788
-            $post_types = get_option('geodir_post_types');
1789
-            $post_type = str_replace("category","",$taxonomy);
1790
-            $post_type = str_replace("_tags","",$post_type);
1791
-            $slug = $post_types[$post_type]['rewrite']['slug'];
1792
-            if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1793
-                global $sitepress;
1794
-                $default_lang = $sitepress->get_default_language();
1795
-                $language_code = gd_wpml_get_lang_from_url($termlink);
1796
-                if (!$language_code ) {
1797
-                    $language_code  = $default_lang;
1798
-                }
1786
+		// Alter the CPT slug if WPML is set to do so
1787
+		if (geodir_is_wpml()) {
1788
+			$post_types = get_option('geodir_post_types');
1789
+			$post_type = str_replace("category","",$taxonomy);
1790
+			$post_type = str_replace("_tags","",$post_type);
1791
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1792
+			if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1793
+				global $sitepress;
1794
+				$default_lang = $sitepress->get_default_language();
1795
+				$language_code = gd_wpml_get_lang_from_url($termlink);
1796
+				if (!$language_code ) {
1797
+					$language_code  = $default_lang;
1798
+				}
1799 1799
 
1800
-                $org_slug = $slug;
1801
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1800
+				$org_slug = $slug;
1801
+				$slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1802 1802
 
1803
-                if (!$slug) {
1804
-                    $slug = $org_slug;
1805
-                }
1803
+				if (!$slug) {
1804
+					$slug = $org_slug;
1805
+				}
1806 1806
 
1807
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1808
-            }
1809
-        }
1810
-    }
1807
+				$termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1808
+			}
1809
+		}
1810
+	}
1811 1811
     
1812
-    return $termlink;
1812
+	return $termlink;
1813 1813
 }
1814 1814
 
1815 1815
 /**
@@ -1835,14 +1835,14 @@  discard block
 block discarded – undo
1835 1835
 	if (in_array($post_type, geodir_get_posttypes())) {
1836 1836
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1837 1837
 			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1838
-                $location_terms = array(
1839
-                    'gd_country' => $post->country_slug,
1840
-                    'gd_region' => $post->region_slug,
1841
-                    'gd_city' => $post->city_slug
1842
-                );
1843
-            } else {
1844
-                $location_terms = geodir_get_current_location_terms('query_vars');
1845
-            }
1838
+				$location_terms = array(
1839
+					'gd_country' => $post->country_slug,
1840
+					'gd_region' => $post->region_slug,
1841
+					'gd_city' => $post->city_slug
1842
+				);
1843
+			} else {
1844
+				$location_terms = geodir_get_current_location_terms('query_vars');
1845
+			}
1846 1846
 			
1847 1847
 			$location_terms = geodir_remove_location_terms($location_terms);
1848 1848
 			
@@ -1874,17 +1874,17 @@  discard block
 block discarded – undo
1874 1874
  * @return void|string Label.
1875 1875
  */
1876 1876
 function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
1877
-    $obj_post_type = get_post_type_object($post_type);
1878
-    if (!is_object($obj_post_type)) {
1879
-        return;
1880
-    }
1877
+	$obj_post_type = get_post_type_object($post_type);
1878
+	if (!is_object($obj_post_type)) {
1879
+		return;
1880
+	}
1881 1881
     
1882
-    $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1882
+	$label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1883 1883
     
1884
-    if ($echo)
1885
-        echo $label;
1886
-    else
1887
-        return $label;
1884
+	if ($echo)
1885
+		echo $label;
1886
+	else
1887
+		return $label;
1888 1888
 }
1889 1889
 
1890 1890
 /**
@@ -1899,19 +1899,19 @@  discard block
 block discarded – undo
1899 1899
  * @return void|string Label.
1900 1900
  */
1901 1901
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1902
-    $all_postypes = geodir_get_posttypes();
1902
+	$all_postypes = geodir_get_posttypes();
1903 1903
 
1904
-    if (!in_array($post_type, $all_postypes))
1905
-        return false;
1904
+	if (!in_array($post_type, $all_postypes))
1905
+		return false;
1906 1906
 
1907
-    $obj_post_type = get_post_type_object($post_type);
1907
+	$obj_post_type = get_post_type_object($post_type);
1908 1908
     
1909
-    $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1909
+	$label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1910 1910
     
1911
-    if ($echo)
1912
-        echo $label;
1913
-    else
1914
-        return $label;
1911
+	if ($echo)
1912
+		echo $label;
1913
+	else
1914
+		return $label;
1915 1915
 }
1916 1916
 
1917 1917
 /**
@@ -1929,51 +1929,51 @@  discard block
 block discarded – undo
1929 1929
  */
1930 1930
 function geodir_term_exists($term, $taxonomy = '', $parent = 0)
1931 1931
 {
1932
-    global $wpdb;
1933
-
1934
-    $select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1935
-    $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1936
-
1937
-    if (is_int($term)) {
1938
-        if (0 == $term)
1939
-            return 0;
1940
-        $where = 't.term_id = %d';
1941
-        if (!empty($taxonomy))
1942
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1943
-        else
1944
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1945
-    }
1932
+	global $wpdb;
1933
+
1934
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1935
+	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1936
+
1937
+	if (is_int($term)) {
1938
+		if (0 == $term)
1939
+			return 0;
1940
+		$where = 't.term_id = %d';
1941
+		if (!empty($taxonomy))
1942
+			return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1943
+		else
1944
+			return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1945
+	}
1946 1946
 
1947
-    $term = trim(wp_unslash($term));
1947
+	$term = trim(wp_unslash($term));
1948 1948
 
1949
-    if ('' === $slug = sanitize_title($term))
1950
-        return 0;
1949
+	if ('' === $slug = sanitize_title($term))
1950
+		return 0;
1951 1951
 
1952
-    $where = 't.slug = %s';
1952
+	$where = 't.slug = %s';
1953 1953
 
1954
-    $where_fields = array($slug);
1955
-    if (!empty($taxonomy)) {
1956
-        $parent = (int)$parent;
1957
-        if ($parent > 0) {
1958
-            $where_fields[] = $parent;
1959
-            $else_where_fields[] = $parent;
1960
-            $where .= ' AND tt.parent = %d';
1954
+	$where_fields = array($slug);
1955
+	if (!empty($taxonomy)) {
1956
+		$parent = (int)$parent;
1957
+		if ($parent > 0) {
1958
+			$where_fields[] = $parent;
1959
+			$else_where_fields[] = $parent;
1960
+			$where .= ' AND tt.parent = %d';
1961 1961
 
1962
-        }
1962
+		}
1963 1963
 
1964
-        $where_fields[] = $taxonomy;
1964
+		$where_fields[] = $taxonomy;
1965 1965
 
1966 1966
 
1967
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1968
-            return $result;
1967
+		if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1968
+			return $result;
1969 1969
 
1970
-        return false;
1971
-    }
1970
+		return false;
1971
+	}
1972 1972
 
1973
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1974
-        return $result;
1973
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1974
+		return $result;
1975 1975
 
1976
-    return false;
1976
+	return false;
1977 1977
 }
1978 1978
 
1979 1979
 /**
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
 function geodir_get_term_icon_rebuild()
1986 1986
 {
1987 1987
 
1988
-    update_option('gd_term_icons', '');
1988
+	update_option('gd_term_icons', '');
1989 1989
 
1990 1990
 }
1991 1991
 
@@ -2003,61 +2003,61 @@  discard block
 block discarded – undo
2003 2003
  */
2004 2004
 function geodir_get_term_icon($term_id = false, $rebuild = false)
2005 2005
 {
2006
-    global $wpdb;
2007
-    if (!$rebuild) {
2008
-        $terms_icons = get_option('gd_term_icons');
2009
-    } else {
2010
-        $terms_icons = array();
2011
-    }
2012
-
2013
-    if (empty($terms_icons)) {
2014
-        $terms_icons = array();
2015
-        $default_icon_url = get_option('geodir_default_marker_icon');
2016
-        $taxonomy = geodir_get_taxonomies();
2017
-        $post_types = geodir_get_posttypes();
2018
-        $tax_arr = array();
2019
-        foreach ($post_types as $post_type) {
2020
-            $tax_arr[] = "'" . $post_type . "category'";
2021
-        }
2022
-        $tax_c = implode(',', $tax_arr);
2023
-        $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2024
-        //$terms = get_terms( $taxonomy );
2025
-
2026
-        if($terms) {
2027
-            foreach ($terms as $term) {
2028
-                $post_type = str_replace("category", "", $term->taxonomy);
2029
-                $a_terms[$post_type][] = $term;
2006
+	global $wpdb;
2007
+	if (!$rebuild) {
2008
+		$terms_icons = get_option('gd_term_icons');
2009
+	} else {
2010
+		$terms_icons = array();
2011
+	}
2030 2012
 
2031
-            }
2032
-        }
2013
+	if (empty($terms_icons)) {
2014
+		$terms_icons = array();
2015
+		$default_icon_url = get_option('geodir_default_marker_icon');
2016
+		$taxonomy = geodir_get_taxonomies();
2017
+		$post_types = geodir_get_posttypes();
2018
+		$tax_arr = array();
2019
+		foreach ($post_types as $post_type) {
2020
+			$tax_arr[] = "'" . $post_type . "category'";
2021
+		}
2022
+		$tax_c = implode(',', $tax_arr);
2023
+		$terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2024
+		//$terms = get_terms( $taxonomy );
2033 2025
 
2034
-        if($a_terms) {
2035
-            foreach ($a_terms as $pt => $t2) {
2026
+		if($terms) {
2027
+			foreach ($terms as $term) {
2028
+				$post_type = str_replace("category", "", $term->taxonomy);
2029
+				$a_terms[$post_type][] = $term;
2036 2030
 
2037
-                foreach ($t2 as $term) {
2038
-                    $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2039
-                    if ($term_icon) {
2040
-                        $term_icon_url = $term_icon["src"];
2041
-                    } else {
2042
-                        $term_icon_url = $default_icon_url;
2043
-                    }
2044
-                    $terms_icons[$term->term_id] = $term_icon_url;
2045
-                }
2046
-            }
2047
-        }
2031
+			}
2032
+		}
2048 2033
 
2049
-        update_option('gd_term_icons', $terms_icons);
2050
-    }
2034
+		if($a_terms) {
2035
+			foreach ($a_terms as $pt => $t2) {
2051 2036
 
2052
-    if ($term_id && isset($terms_icons[$term_id])) {
2053
-        return $terms_icons[$term_id];
2054
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2055
-        return get_option('geodir_default_marker_icon');
2056
-    }
2037
+				foreach ($t2 as $term) {
2038
+					$term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2039
+					if ($term_icon) {
2040
+						$term_icon_url = $term_icon["src"];
2041
+					} else {
2042
+						$term_icon_url = $default_icon_url;
2043
+					}
2044
+					$terms_icons[$term->term_id] = $term_icon_url;
2045
+				}
2046
+			}
2047
+		}
2048
+
2049
+		update_option('gd_term_icons', $terms_icons);
2050
+	}
2057 2051
 
2058
-    if (is_ssl()) {
2059
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2060
-    }
2052
+	if ($term_id && isset($terms_icons[$term_id])) {
2053
+		return $terms_icons[$term_id];
2054
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2055
+		return get_option('geodir_default_marker_icon');
2056
+	}
2057
+
2058
+	if (is_ssl()) {
2059
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2060
+	}
2061 2061
 
2062
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2062
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2063 2063
 }
2064 2064
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
                              * @since 1.0.0
61 61
                              * @param string $menu_class The menu HTML class.
62 62
                              */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
63
+                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
64 64
                             /**
65 65
                              * Filter the menu a class.
66 66
                              *
67 67
                              * @since 1.0.0
68 68
                              */
69 69
                             $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
71
-									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72
-										' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
70
+                            $items .= '<li class="'.$li_class.'">
71
+									<a href="' . get_post_type_archive_link($post_type).'" class="'.$a_class.'">
72
+										' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').'
73 73
 									</a>
74 74
 								</li>';
75 75
                         }
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
              * @since 1.0.0
89 89
              * @param string $menu_class The menu HTML class.
90 90
              */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
91
+            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings '.$menu_class);
92 92
             /**
93 93
              * Filter the sub menu li class.
94 94
              *
95 95
              * @since 1.0.0
96 96
              * @param string $menu_class The menu HTML class.
97 97
              */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
98
+            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
99 99
             /**
100 100
              * Filter the sub menu ul class.
101 101
              *
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
              * @since 1.0.0
115 115
              */
116 116
             $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
118
-					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119
-					<ul class="' . $sub_ul_class . '">';
117
+            $items .= '<li class="'.$li_class.'">
118
+					<a href="#" class="' . $a_class.'">'.__('Listing', 'geodirectory').'</a>
119
+					<ul class="' . $sub_ul_class.'">';
120 120
             $post_types = geodir_get_posttypes('object');
121 121
 
122 122
             $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
                                 if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134 134
                                     $menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
137
-														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138
-															' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
136
+                                $items .= '<li class="'.$sub_li_class.'">
137
+														<a href="' . get_post_type_archive_link($post_type).'" class="'.$sub_a_class.'">
138
+															' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').'
139 139
 														</a>
140 140
 													</li>';
141 141
                             }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
              *
152 152
              * @since 1.5.9
153 153
              */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
154
+            $items .= apply_filters('geodir_menu_after_sub_ul', '');
155 155
             $items .= '</li>';
156 156
         }
157 157
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                                      * @since 1.0.0
185 185
                                      * @param string $menu_class The menu HTML class.
186 186
                                      */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
187
+                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
188 188
                                     /**
189 189
                                      * Filter the menu a class.
190 190
                                      *
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
                                      */
193 193
                                     $a_class = apply_filters('geodir_menu_a_class', '');
194 194
                                     $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
196
-											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197
-												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
195
+                                    $items .= '<li class="'.$li_class.'">
196
+											<a href="' . geodir_get_addlisting_link($post_type).'" class="'.$a_class.'">
197
+												' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
198 198
 											</a>
199 199
 										</li>';
200 200
                                 }
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
              * @since 1.0.0
219 219
              * @param string $menu_class The menu HTML class.
220 220
              */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
221
+            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing '.$menu_class);
222 222
             /**
223 223
              * Filter the sub menu li class.
224 224
              *
225 225
              * @since 1.0.0
226 226
              * @param string $menu_class The menu HTML class.
227 227
              */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
228
+            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
229 229
             /**
230 230
              * Filter the sub menu ul class.
231 231
              *
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
              * @since 1.0.0
245 245
              */
246 246
             $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
248
-					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249
-					<ul class="' . $sub_ul_class . '">';
247
+            $items .= '<li  class="'.$li_class.'">
248
+					<a href="#" class="' . $a_class.'">'.__('Add Listing', 'geodirectory').'</a>
249
+					<ul class="' . $sub_ul_class.'">';
250 250
 
251 251
             $post_types = geodir_get_posttypes('object');
252 252
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
                                          * @since 1.0.0
270 270
                                          * @param string $menu_class The menu HTML class.
271 271
                                          */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
272
+                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
273 273
                                         $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $sub_li_class . '">
275
-														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276
-															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
274
+                                        $items .= '<li class="'.$sub_li_class.'">
275
+														<a href="' . geodir_get_addlisting_link($post_type).'" class="'.$sub_a_class.'">
276
+															' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
277 277
 														</a>
278 278
 													</li>';
279 279
                                     }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             }
286 286
 
287 287
             $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
288
+            $items .= apply_filters('geodir_menu_after_sub_ul', '');
289 289
             $items .= '</li>';
290 290
 
291 291
         }
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
     $geodir_theme_location = get_option('geodir_theme_location_nav');
314 314
     $geodir_theme_location_nav = array();
315 315
     if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
316
+        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
317 317
         $geodir_theme_location_nav[] = $args['theme_location'];
318 318
         update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319 319
     }
320 320
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322 322
     else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
323
+        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
324 324
 
325 325
     return $menu;
326 326
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
     if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
351
+        $items = $items.geodir_add_nav_menu_items();
352 352
         return $items;
353 353
 
354 354
     } else {
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
 
374 374
     $taxonomies = geodir_get_taxonomies();
375 375
     $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
376
+    $taxonomies = "'".$taxonomies."'";
377 377
 
378 378
     $pn_categories = $wpdb->get_results(
379 379
         $wpdb->prepare(
380 380
             "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
381
+            array($wpdb->terms.term_id)
382 382
         )
383 383
     );
384 384
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410 410
         if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
411
+            $geodir_post_type = get_post_type((int) $_REQUEST['pid']);
412 412
         elseif (isset($_REQUEST['listing_type']))
413 413
             $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414 414
     }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435 435
         $geodir_post_type = '';
436 436
 
437
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
437
+    if (defined('DOING_AJAX') && isset($_REQUEST['stype'])) {
438 438
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439 439
     }
440 440
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
      *
445 445
      * @since 1.6.9
446 446
      */
447
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
447
+    return apply_filters('geodir_get_current_posttype', $geodir_post_type);
448 448
 }
449 449
 
450 450
 /**
@@ -458,18 +458,18 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_get_default_posttype()
460 460
 {
461
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
461
+    $post_types = apply_filters('geodir_get_default_posttype', geodir_get_posttypes('object'));
462 462
 
463 463
     $stype = false;
464
-    foreach ( $post_types as $post_type => $info ) {
464
+    foreach ($post_types as $post_type => $info) {
465 465
         global $wpdb;
466
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
-        if ( $has_posts ) {
466
+        $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
467
+        if ($has_posts) {
468 468
             $stype = $post_type; break;
469 469
         }
470 470
     }
471 471
 
472
-    if(!$stype){
472
+    if (!$stype) {
473 473
         $stype = 'gd_place';
474 474
     }
475 475
 
@@ -494,14 +494,14 @@  discard block
 block discarded – undo
494 494
         switch ($output):
495 495
             case 'object':
496 496
             case 'Object':
497
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
497
+                $post_types = json_decode(json_encode($post_types), FALSE); //(object)$post_types;
498 498
                 break;
499 499
             case 'array':
500 500
             case 'Array':
501
-                $post_types = (array)$post_types;
501
+                $post_types = (array) $post_types;
502 502
                 break;
503 503
 			case 'options':
504
-                $post_types = (array)$post_types;
504
+                $post_types = (array) $post_types;
505 505
 				
506 506
 				$options = array();
507 507
 				if (!empty($post_types)) {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                     $gd_taxonomies[] = $taxonomy;
570 570
                 }
571 571
 
572
-                if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') {
572
+                if ($tages_taxonomies === false && substr($taxonomy, -5) == '_tags') {
573 573
                     if (array_search($taxonomy, $gd_taxonomies) !== false) {
574 574
                         unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
575 575
                     }
@@ -615,15 +615,15 @@  discard block
 block discarded – undo
615 615
 
616 616
         $categories = get_terms($taxonomies);
617 617
 
618
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
618
+        $html .= '<option value="0">'.__('All', 'geodirectory').'</option>';
619 619
 
620 620
         foreach ($categories as $category_obj) {
621 621
             $select_opt = '';
622 622
             if ($selected == $category_obj->term_id) {
623 623
                 $select_opt = 'selected="selected"';
624 624
             }
625
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
626
-                . geodir_utf8_ucfirst($category_obj->name) . '</option>';
625
+            $html .= '<option '.$select_opt.' value="'.$category_obj->term_id.'">'
626
+                . geodir_utf8_ucfirst($category_obj->name).'</option>';
627 627
         }
628 628
 
629 629
         if ($echo)
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     } elseif (isset($wp_query->tax_query->queries)) {
692 692
         $tax_arr = $wp_query->tax_query->queries;
693 693
         //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
694
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
694
+        if (isset($tax_arr['relation'])) {unset($tax_arr['relation']); }
695 695
         $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
696 696
     }
697 697
 
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 
746 746
             if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
747 747
                 if ($cat_parent == 0) {
748
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
748
+                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-'.$cat_display;
749 749
                     $main_list_class = 'class="main_list_selecter"';
750 750
                 } else {
751 751
                     //$display = 'display:none';
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 
756 756
             if ($cat_display == 'checkbox' || $cat_display == 'radio') {
757 757
                 $p = 0;
758
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
758
+                $out = '<div class="'.$list_class.' gd-cat-row-'.$cat_parent.'" style="margin-left:'.$p.'px;'.$display.';">';
759 759
             }
760 760
 
761 761
             foreach ($cat_terms as $cat_term) {
@@ -770,12 +770,12 @@  discard block
 block discarded – undo
770 770
                 }
771 771
 
772 772
                 if ($cat_display == 'radio')
773
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
773
+                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>';
774 774
                 elseif ($cat_display == 'select' || $cat_display == 'multiselect')
775
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
775
+                    $out .= '<option '.$main_list_class.' style="margin-left:'.$p.'px;" alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</option>';
776 776
 
777 777
                 else {
778
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
+                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>';
779 779
                 }
780 780
 
781 781
                 // Call recurson to print sub cats
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
             $cat_exclude = serialize($exclude_cats);
815 815
 
816 816
         if (isset($_REQUEST['backandedit'])) {
817
-            $post = (object)$gd_session->get('listing');
817
+            $post = (object) $gd_session->get('listing');
818 818
 
819 819
             if (!is_array($post->post_category[$cat_taxonomy]))
820 820
                 $post_category = $post->post_category[$cat_taxonomy];
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 
847 847
             if (!empty($post_category)) {
848 848
                 $cat1 = array_filter(explode(',', $post_category));
849
-                $post_category = ',' . implode(',', $cat1) . ',';
849
+                $post_category = ','.implode(',', $cat1).',';
850 850
 
851 851
             }
852 852
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
                 foreach ($post_category_upd as $cat) {
858 858
 
859 859
                     if (!in_array($cat, $exclude_cats) && $cat != '') {
860
-                        $post_category_change .= ',' . $cat;
860
+                        $post_category_change .= ','.$cat;
861 861
                     }
862 862
                 }
863 863
                 $post_category = $post_category_change;
@@ -869,11 +869,11 @@  discard block
 block discarded – undo
869 869
             }
870 870
         }
871 871
 
872
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
872
+        echo '<input type="hidden" id="cat_limit" value="'.$cat_limit.'" name="cat_limit['.$cat_taxonomy.']"  />';
873 873
 
874
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
874
+        echo '<input type="hidden" id="post_category" value="'.$post_category.'" name="post_category['.$cat_taxonomy.']"  />';
875 875
 
876
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
876
+        echo '<input type="hidden" id="post_category_str" value="'.$post_category_str.'" name="post_category_str['.$cat_taxonomy.']"  />';
877 877
 
878 878
 
879 879
         ?>
@@ -892,14 +892,14 @@  discard block
 block discarded – undo
892 892
 
893 893
             function show_subcatlist(main_cat, catObj) {
894 894
                 if (main_cat != '') {
895
-					var url = '<?php echo geodir_get_ajax_url();?>';
896
-                    var cat_taxonomy = '<?php echo $cat_taxonomy;?>';
897
-                    var cat_exclude = '<?php echo base64_encode($cat_exclude);?>';
895
+					var url = '<?php echo geodir_get_ajax_url(); ?>';
896
+                    var cat_taxonomy = '<?php echo $cat_taxonomy; ?>';
897
+                    var cat_exclude = '<?php echo base64_encode($cat_exclude); ?>';
898 898
                     var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val();
899
-					<?php if ((int)$cat_limit > 0) { ?>
899
+					<?php if ((int) $cat_limit > 0) { ?>
900 900
 					var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length);
901 901
 					if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) {
902
-						alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int)$cat_limit));?>");
902
+						alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int) $cat_limit)); ?>");
903 903
 						return false;
904 904
 					}
905 905
 					<?php } ?>
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             }
939 939
 
940 940
             function update_listing_cat(el) {
941
-                var cat_taxonomy = '<?php echo $cat_taxonomy;?>';
941
+                var cat_taxonomy = '<?php echo $cat_taxonomy; ?>';
942 942
                 var cat_ids = '';
943 943
                 var main_cat = '';
944 944
                 var sub_cat = '';
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1020 1020
             echo $style;
1021 1021
         }?> ">
1022
-            <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1022
+            <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list
1023 1023
             ?>
1024 1024
         </div>
1025 1025
     <?php
@@ -1046,9 +1046,9 @@  discard block
 block discarded – undo
1046 1046
     if ($exclude != '') {
1047 1047
         $exclude_cats = maybe_unserialize(base64_decode($exclude));
1048 1048
 
1049
-        if(is_array( $exclude_cats)){
1050
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1051
-        }else{
1049
+        if (is_array($exclude_cats)) {
1050
+            $exclude_cats = array_map('intval', $exclude_cats);
1051
+        } else {
1052 1052
             $exclude_cats = intval($exclude_cats);
1053 1053
         }
1054 1054
 
@@ -1062,25 +1062,25 @@  discard block
 block discarded – undo
1062 1062
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1063 1063
 
1064 1064
         <div class="post_catlist_item" style="border:1px solid #CCCCCC; margin:5px auto; padding:5px;">
1065
-            <img alt="move icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/move.png';?>"
1065
+            <img alt="move icon" src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png'; ?>"
1066 1066
                  onclick="jQuery(this).closest('div').remove();update_listing_cat(this);" align="right"/>
1067 1067
             <?php /* ?>
1068 1068
 		<img src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png';?>" onclick="jQuery(this).closest('div').remove();show_subcatlist();" align="right" /> 
1069 1069
 		<?php */ ?>
1070 1070
 
1071
-            <input type="checkbox" value="<?php echo $main_cat->term_id;?>" class="listing_main_cat"
1071
+            <input type="checkbox" value="<?php echo $main_cat->term_id; ?>" class="listing_main_cat"
1072 1072
                    onchange="if(jQuery(this).is(':checked')){jQuery(this).closest('div').find('.post_default_category').prop('checked',false).show();}else{jQuery(this).closest('div').find('.post_default_category').prop('checked',false).hide();};update_listing_cat()"
1073 1073
                    checked="checked" disabled="disabled"/>
1074 1074
        <span> 
1075
-        <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1075
+        <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
1076 1076
         </span>
1077 1077
             <br/>
1078 1078
 
1079 1079
             <div class="post_default_category">
1080
-                <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1081
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1080
+                <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id; ?>"
1081
+                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" '; ?>   />
1082 1082
         <span> 
1083
-        <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1083
+        <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
1084 1084
         </span>
1085 1085
             </div>
1086 1086
 
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
         $post_cat_str = $post_categories[$request_taxonomy];
1114 1114
         $post_cat_array = explode("#", $post_cat_str);
1115 1115
         if (is_array($post_cat_array)) {
1116
-            $post_cat_array = array_unique( $post_cat_array );
1116
+            $post_cat_array = array_unique($post_cat_array);
1117 1117
 
1118 1118
 			foreach ($post_cat_array as $post_cat_html) {
1119 1119
 
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
                 }
1129 1129
                 $post_sub_catid = '';
1130 1130
                 if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1131
-                    $post_sub_catid = (int)$post_cat_info[1];
1131
+                    $post_sub_catid = (int) $post_cat_info[1];
1132 1132
                 }
1133 1133
 
1134 1134
                 geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
             }
1150 1150
 
1151 1151
             if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1152
-                $post_sub_catid = (int)$post_cat_info[1];
1152
+                $post_sub_catid = (int) $post_cat_info[1];
1153 1153
             }
1154 1154
 
1155 1155
             geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
         if (!$selected)
1182 1182
             $option_slected = ' selected="selected" ';
1183 1183
 
1184
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1184
+        echo '<select field_type="select" id="'.sanitize_text_field($cat_taxonomy).'" class="chosen_select" '.$onchange.' option-ajaxChosen="false" >';
1185 1185
 
1186
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1186
+        echo '<option value="" '.$option_selected.' >'.__('Select Category', 'geodirectory').'</option>';
1187 1187
 
1188 1188
         foreach ($cat_terms as $cat_term) {
1189 1189
             $option_selected = '';
@@ -1191,10 +1191,10 @@  discard block
 block discarded – undo
1191 1191
                 $option_selected = ' selected="selected" ';
1192 1192
 
1193 1193
             // Count child terms
1194
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1195
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1194
+            $child_terms = get_terms($cat_taxonomy, array('parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1));
1195
+            $has_child = !empty($child_terms) ? 't' : 'f';
1196 1196
 
1197
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1197
+            echo '<option  '.$option_selected.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" _hc="'.$has_child.'" >'.geodir_utf8_ucfirst($cat_term->name).'</option>';
1198 1198
         }
1199 1199
         echo '</select>';
1200 1200
     }
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
             2 => __('Custom field updated.', 'geodirectory'),
1226 1226
             3 => __('Custom field deleted.', 'geodirectory'),
1227 1227
             4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1228
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1228
+            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false,
1229 1229
             6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1230 1230
             7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1231 1231
             8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 
1252 1252
     global $wpdb;
1253 1253
 
1254
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1254
+    $menu_icon = geodir_plugin_url().'/geodirectory-assets/images/favicon.ico';
1255 1255
 
1256 1256
     if (!$listing_slug = get_option('geodir_listing_prefix'))
1257 1257
         $listing_slug = 'places';
@@ -1264,11 +1264,11 @@  discard block
 block discarded – undo
1264 1264
 
1265 1265
         $gd_placetags = array();
1266 1266
         $gd_placetags['object_type'] = 'gd_place';
1267
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1267
+        $gd_placetags['listing_slug'] = $listing_slug.'/tags';
1268 1268
         $gd_placetags['args'] = array(
1269 1269
             'public' => true,
1270 1270
             'hierarchical' => false,
1271
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1271
+            'rewrite' => array('slug' => $listing_slug.'/tags', 'with_front' => false, 'hierarchical' => true),
1272 1272
             'query_var' => true,
1273 1273
 
1274 1274
             'labels' => array(
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
             'menu_icon' => $menu_icon,
1363 1363
             'public' => true,
1364 1364
             'query_var' => true,
1365
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1365
+            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1366 1366
             'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1367 1367
             'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1368 1368
 
@@ -1395,12 +1395,12 @@  discard block
 block discarded – undo
1395 1395
         return $_REQUEST['lang'];
1396 1396
     }
1397 1397
 
1398
-    $url = str_replace(array("http://","https://"),"",$url);
1398
+    $url = str_replace(array("http://", "https://"), "", $url);
1399 1399
 
1400 1400
     // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1401
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1401
+    $site_url = str_replace(array("http://", "https://"), "", site_url());
1402 1402
 
1403
-    $url = str_replace($site_url,"",$url);
1403
+    $url = str_replace($site_url, "", $url);
1404 1404
 
1405 1405
     $segments = explode('/', trim($url, '/'));
1406 1406
 
@@ -1466,9 +1466,9 @@  discard block
 block discarded – undo
1466 1466
     if (in_array($post->post_type, geodir_get_posttypes())) {
1467 1467
 
1468 1468
         // if we dont have a GD post then try to grab it
1469
-        if(!isset($post->default_category)){
1469
+        if (!isset($post->default_category)) {
1470 1470
             $gd_post = geodir_get_post_info($post->ID);
1471
-            if(!empty($gd_post)){
1471
+            if (!empty($gd_post)) {
1472 1472
                 $post = $gd_post;
1473 1473
             }
1474 1474
         }
@@ -1478,17 +1478,17 @@  discard block
 block discarded – undo
1478 1478
         $slug = $post_types[$post->post_type]['rewrite']['slug'];
1479 1479
 
1480 1480
         // Alter the CPT slug if WPML is set to do so
1481
-        if(geodir_wpml_is_post_type_translated($post->post_type)){
1482
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1481
+        if (geodir_wpml_is_post_type_translated($post->post_type)) {
1482
+            if (gd_wpml_slug_translation_turned_on($post->post_type) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1483 1483
 
1484 1484
                 $org_slug = $slug;
1485
-                $slug = apply_filters( 'wpml_translate_single_string',
1485
+                $slug = apply_filters('wpml_translate_single_string',
1486 1486
                     $slug,
1487 1487
                     'WordPress',
1488
-                    'URL slug: ' . $slug,
1488
+                    'URL slug: '.$slug,
1489 1489
                     $language_code);
1490 1490
 
1491
-                if(!$slug){$slug = $org_slug;}
1491
+                if (!$slug) {$slug = $org_slug; }
1492 1492
 
1493 1493
             }
1494 1494
         }
@@ -1510,11 +1510,11 @@  discard block
 block discarded – undo
1510 1510
         }
1511 1511
 
1512 1512
         $post_link = trailingslashit(
1513
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1513
+            preg_replace("/".preg_quote($slug, "/")."/", $slug."/%gd_taxonomy%", $post_link, 1)
1514 1514
         );
1515 1515
 
1516 1516
         if ($fix_url) {
1517
-            $post_link = $site_url . $post_link;
1517
+            $post_link = $site_url.$post_link;
1518 1518
         }
1519 1519
 
1520 1520
         if (isset($comment_post_cache[$post->ID])) {
@@ -1533,12 +1533,12 @@  discard block
 block discarded – undo
1533 1533
             $ID = $post->ID;
1534 1534
             $post2 = $wpdb->get_row(
1535 1535
                 $wpdb->prepare(
1536
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1536
+                    "SELECT * from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ",
1537 1537
                     array($post->ID)
1538 1538
                 )
1539 1539
             );
1540 1540
 
1541
-            $post = (object)array_merge((array)$post, (array)$post2);
1541
+            $post = (object) array_merge((array) $post, (array) $post2);
1542 1542
 
1543 1543
             $comment_post_cache[$post->ID] = $post;
1544 1544
         }
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 
1548 1548
         if (false !== strpos($post_link, '%gd_taxonomy%')) {
1549 1549
 
1550
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1550
+            if (apply_filters("geodir_add_location_url_to_url", get_option('geodir_add_location_url'), $post->post_type, $post)) {
1551 1551
                 $location_request = '';
1552 1552
 
1553 1553
 
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
                         $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1562 1562
                         $post->country_slug = str_replace(']', '', $post->country_slug);
1563 1563
 
1564
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1564
+                        $post_location = (object) array('country_slug' => $post->country_slug,
1565 1565
                             'region_slug' => $post->region_slug,
1566 1566
                             'city_slug' => $post->city_slug
1567 1567
                         );
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
 
1575 1575
                     $post_location_sql = $wpdb->get_results(
1576 1576
                         $wpdb->prepare(
1577
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1577
+                            "SELECT post_locations from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ",
1578 1578
                             array($post->ID)
1579 1579
                         )
1580 1580
                     );
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
                             $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1591 1591
                             $post->country_slug = str_replace(']', '', $post->country_slug);
1592 1592
 
1593
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1593
+                            $post_location = (object) array('country_slug' => $post->country_slug,
1594 1594
                                 'region_slug' => $post->region_slug,
1595 1595
                                 'city_slug' => $post->city_slug
1596 1596
                             );
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 					}
1620 1620
 					$location_slug[] = $city_slug;
1621 1621
 					
1622
-					$location_request .= implode('/', $location_slug) . '/';
1622
+					$location_request .= implode('/', $location_slug).'/';
1623 1623
                 }
1624 1624
             }
1625 1625
 
@@ -1634,9 +1634,9 @@  discard block
 block discarded – undo
1634 1634
                 } else {
1635 1635
                     $post_terms = '';
1636 1636
 
1637
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1637
+                    if (isset($_POST['post_default_category']) && $_POST['post_default_category']) {
1638 1638
                         $post_terms = absint($_POST['post_default_category']);
1639
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1639
+                    }elseif (isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1640 1640
                         $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1641 1641
                         $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1642 1642
                     }elseif (isset($post->{$taxonomies})) {
@@ -1682,14 +1682,14 @@  discard block
 block discarded – undo
1682 1682
             $request_term = trim($request_term, '/');
1683 1683
             
1684 1684
             // Fix with WPML the location terms added twice when CPT slug is translated.
1685
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1685
+            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/'.$request_term.$detailurl_separator) !== false) {
1686 1686
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1687 1687
             }
1688 1688
             
1689 1689
             if (!empty($request_term))
1690
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1690
+                $post_link = str_replace('%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
1691 1691
             else
1692
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1692
+                $post_link = str_replace('/%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
1693 1693
             //echo $post_link ;
1694 1694
         }
1695 1695
         // temp cache the permalink
@@ -1764,9 +1764,9 @@  discard block
 block discarded – undo
1764 1764
                 $url_separator = '';
1765 1765
 
1766 1766
                 if (get_option('permalink_structure') != '') {
1767
-                    $old_listing_slug = '/' . $listing_slug . '/';
1767
+                    $old_listing_slug = '/'.$listing_slug.'/';
1768 1768
                     $request_term = implode("/", $location_terms);
1769
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1769
+                    $new_listing_slug = '/'.$listing_slug.'/'.$request_term.'/';
1770 1770
 
1771 1771
                     $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1772 1772
                 } else {
@@ -1786,25 +1786,25 @@  discard block
 block discarded – undo
1786 1786
         // Alter the CPT slug if WPML is set to do so
1787 1787
         if (geodir_is_wpml()) {
1788 1788
             $post_types = get_option('geodir_post_types');
1789
-            $post_type = str_replace("category","",$taxonomy);
1790
-            $post_type = str_replace("_tags","",$post_type);
1789
+            $post_type = str_replace("category", "", $taxonomy);
1790
+            $post_type = str_replace("_tags", "", $post_type);
1791 1791
             $slug = $post_types[$post_type]['rewrite']['slug'];
1792 1792
             if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) {
1793 1793
                 global $sitepress;
1794 1794
                 $default_lang = $sitepress->get_default_language();
1795 1795
                 $language_code = gd_wpml_get_lang_from_url($termlink);
1796
-                if (!$language_code ) {
1797
-                    $language_code  = $default_lang;
1796
+                if (!$language_code) {
1797
+                    $language_code = $default_lang;
1798 1798
                 }
1799 1799
 
1800 1800
                 $org_slug = $slug;
1801
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1801
+                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: '.$slug, $language_code);
1802 1802
 
1803 1803
                 if (!$slug) {
1804 1804
                     $slug = $org_slug;
1805 1805
                 }
1806 1806
 
1807
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1807
+                $termlink = trailingslashit(preg_replace("/".preg_quote($org_slug, "/")."/", $slug, $termlink, 1));
1808 1808
             }
1809 1809
         }
1810 1810
     }
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 	
1835 1835
 	if (in_array($post_type, geodir_get_posttypes())) {
1836 1836
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1837
-			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1837
+			if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1838 1838
                 $location_terms = array(
1839 1839
                     'gd_country' => $post->country_slug,
1840 1840
                     'gd_region' => $post->region_slug,
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 					$location_terms = implode("/", $location_terms);
1852 1852
 					$location_terms = rtrim($location_terms, '/');
1853 1853
 					
1854
-					$link .= urldecode($location_terms) . '/';
1854
+					$link .= urldecode($location_terms).'/';
1855 1855
 				} else {
1856 1856
 					$link = geodir_getlink($link, $location_terms);
1857 1857
 				}
@@ -1939,9 +1939,9 @@  discard block
 block discarded – undo
1939 1939
             return 0;
1940 1940
         $where = 't.term_id = %d';
1941 1941
         if (!empty($taxonomy))
1942
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1942
+            return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1943 1943
         else
1944
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1944
+            return $wpdb->get_var($wpdb->prepare($select.$where, $term));
1945 1945
     }
1946 1946
 
1947 1947
     $term = trim(wp_unslash($term));
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
 
1954 1954
     $where_fields = array($slug);
1955 1955
     if (!empty($taxonomy)) {
1956
-        $parent = (int)$parent;
1956
+        $parent = (int) $parent;
1957 1957
         if ($parent > 0) {
1958 1958
             $where_fields[] = $parent;
1959 1959
             $else_where_fields[] = $parent;
@@ -2017,13 +2017,13 @@  discard block
 block discarded – undo
2017 2017
         $post_types = geodir_get_posttypes();
2018 2018
         $tax_arr = array();
2019 2019
         foreach ($post_types as $post_type) {
2020
-            $tax_arr[] = "'" . $post_type . "category'";
2020
+            $tax_arr[] = "'".$post_type."category'";
2021 2021
         }
2022 2022
         $tax_c = implode(',', $tax_arr);
2023 2023
         $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2024 2024
         //$terms = get_terms( $taxonomy );
2025 2025
 
2026
-        if($terms) {
2026
+        if ($terms) {
2027 2027
             foreach ($terms as $term) {
2028 2028
                 $post_type = str_replace("category", "", $term->taxonomy);
2029 2029
                 $a_terms[$post_type][] = $term;
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
             }
2032 2032
         }
2033 2033
 
2034
-        if($a_terms) {
2034
+        if ($a_terms) {
2035 2035
             foreach ($a_terms as $pt => $t2) {
2036 2036
 
2037 2037
                 foreach ($t2 as $term) {
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
     }
2057 2057
 
2058 2058
     if (is_ssl()) {
2059
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2059
+        $terms_icons = str_replace("http:", "https:", $terms_icons);
2060 2060
     }
2061 2061
 
2062 2062
     return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
Please login to merge, or discard this patch.
Braces   +161 added lines, -116 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
     if (get_option('geodir_show_listing_nav')) {
40 40
 
41 41
         $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
42
+        if (geodir_is_page('listing')) {
43
+                    $menu_class = 'current-menu-item';
44
+        }
44 45
 
45 46
 
46 47
         //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
                     if (in_array($post_type, $show_post_type_main_nav)) {
53 54
                         if (get_post_type_archive_link($post_type)) {
54 55
                             $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
56
+                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
57
+                                                            $menu_class = 'current-menu-item';
58
+                            }
57 59
                             /**
58 60
                              * Filter the menu li class.
59 61
                              *
@@ -130,8 +132,9 @@  discard block
 block discarded – undo
130 132
                             if (get_post_type_archive_link($post_type)) {
131 133
 
132 134
                                 $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
135
+                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
136
+                                                                    $menu_class = 'current-menu-item';
137
+                                }
135 138
 
136 139
                                 $items .= '<li class="' . $sub_li_class . '">
137 140
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
@@ -159,8 +162,9 @@  discard block
 block discarded – undo
159 162
     if (get_option('geodir_show_addlisting_nav')) {
160 163
 
161 164
         $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
165
+        if (geodir_is_page('add-listing')) {
166
+                    $menu_class = 'current-menu-item';
167
+        }
164 168
 
165 169
         //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166 170
         $post_types = geodir_get_posttypes('object');
@@ -176,8 +180,9 @@  discard block
 block discarded – undo
176 180
                                 if (geodir_get_addlisting_link($post_type)) {
177 181
 
178 182
                                     $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
183
+                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
184
+                                                                            $menu_class = 'current-menu-item';
185
+                                    }
181 186
                                     /**
182 187
                                      * Filter the menu li class.
183 188
                                      *
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
                                     if (geodir_get_addlisting_link($post_type)) {
262 267
 
263 268
                                         $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
269
+                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
270
+                                                                                    $menu_class = 'current-menu-item';
271
+                                        }
266 272
                                         /**
267 273
                                          * Filter the menu li class.
268 274
                                          *
@@ -319,8 +325,9 @@  discard block
 block discarded – undo
319 325
     }
320 326
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 327
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
328
+    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) {
329
+            $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
330
+    }
324 331
 
325 332
     return $menu;
326 333
 
@@ -407,17 +414,20 @@  discard block
 block discarded – undo
407 414
     $geodir_post_type = get_query_var('post_type');
408 415
 
409 416
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
417
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
418
+                    $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
419
+        } elseif (isset($_REQUEST['listing_type'])) {
420
+                    $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
421
+        }
414 422
     }
415 423
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
424
+    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) {
425
+            $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
426
+    }
418 427
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
428
+    if (is_tax()) {
429
+            $geodir_post_type = geodir_get_taxonomy_posttype();
430
+    }
421 431
 
422 432
     // Retrive post type for map marker html ajax request on preview page.
423 433
     if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
@@ -431,8 +441,9 @@  discard block
 block discarded – undo
431 441
     $all_postypes = geodir_get_posttypes();
432 442
     $all_postypes = stripslashes_deep($all_postypes);
433 443
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
444
+    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) {
445
+            $geodir_post_type = '';
446
+    }
436 447
 
437 448
     if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438 449
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
@@ -517,11 +528,12 @@  discard block
 block discarded – undo
517 528
         endswitch;
518 529
     }
519 530
 
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
524
-}
531
+    if (!empty($post_types)) {
532
+            return $post_types;
533
+    } else {
534
+            return array();
535
+    }
536
+    }
525 537
 
526 538
 /**
527 539
  * Get Custom Post Type info.
@@ -538,9 +550,10 @@  discard block
 block discarded – undo
538 550
     $post_types = stripslashes_deep($post_types);
539 551
     if (!empty($post_types) && $post_type != '') {
540 552
         return $post_types[$post_type];
541
-    } else
542
-        return false;
543
-}
553
+    } else {
554
+            return false;
555
+    }
556
+    }
544 557
 
545 558
 if (!function_exists('geodir_get_taxonomies')) {
546 559
     /**
@@ -626,10 +639,11 @@  discard block
 block discarded – undo
626 639
                 . geodir_utf8_ucfirst($category_obj->name) . '</option>';
627 640
         }
628 641
 
629
-        if ($echo)
630
-            echo $html;
631
-        else
632
-            return $html;
642
+        if ($echo) {
643
+                    echo $html;
644
+        } else {
645
+                    return $html;
646
+        }
633 647
     }
634 648
 }
635 649
 
@@ -663,11 +677,12 @@  discard block
 block discarded – undo
663 677
 
664 678
     }
665 679
 
666
-    if (!empty($listing_slug))
667
-        return $listing_slug;
668
-    else
669
-        return false;
670
-}
680
+    if (!empty($listing_slug)) {
681
+            return $listing_slug;
682
+    } else {
683
+            return false;
684
+    }
685
+    }
671 686
 
672 687
 
673 688
 /**
@@ -698,16 +713,18 @@  discard block
 block discarded – undo
698 713
     if (!empty($taxonomies)) {
699 714
         foreach (geodir_get_posttypes() as $pt) {
700 715
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
701
-            if (array_intersect($taxonomies, $object_taxonomies))
702
-                $post_type[] = $pt;
716
+            if (array_intersect($taxonomies, $object_taxonomies)) {
717
+                            $post_type[] = $pt;
718
+            }
703 719
         }
704 720
     }
705 721
 
706
-    if (!empty($post_type))
707
-        return $post_type[0];
708
-    else
709
-        return false;
710
-}
722
+    if (!empty($post_type)) {
723
+            return $post_type[0];
724
+    } else {
725
+            return false;
726
+    }
727
+    }
711 728
 
712 729
 if (!function_exists('geodir_custom_taxonomy_walker')) {
713 730
     /**
@@ -763,18 +780,18 @@  discard block
 block discarded – undo
763 780
                 $checked = '';
764 781
 
765 782
                 if (in_array($cat_term->term_id, $search_terms)) {
766
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
767
-                        $checked = 'selected="selected"';
768
-                    else
769
-                        $checked = 'checked="checked"';
783
+                    if ($cat_display == 'select' || $cat_display == 'multiselect') {
784
+                                            $checked = 'selected="selected"';
785
+                    } else {
786
+                                            $checked = 'checked="checked"';
787
+                    }
770 788
                 }
771 789
 
772
-                if ($cat_display == 'radio')
773
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
774
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
775
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
776
-
777
-                else {
790
+                if ($cat_display == 'radio') {
791
+                                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
792
+                } elseif ($cat_display == 'select' || $cat_display == 'multiselect') {
793
+                                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
794
+                } else {
778 795
                     $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
779 796
                 }
780 797
 
@@ -783,8 +800,9 @@  discard block
 block discarded – undo
783 800
 
784 801
             }
785 802
 
786
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
787
-                $out .= '</div>';
803
+            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
804
+                            $out .= '</div>';
805
+            }
788 806
 
789 807
             return $out;
790 808
         }
@@ -810,18 +828,21 @@  discard block
 block discarded – undo
810 828
         global $exclude_cats, $gd_session;
811 829
 
812 830
         $cat_exclude = '';
813
-        if (is_array($exclude_cats) && !empty($exclude_cats))
814
-            $cat_exclude = serialize($exclude_cats);
831
+        if (is_array($exclude_cats) && !empty($exclude_cats)) {
832
+                    $cat_exclude = serialize($exclude_cats);
833
+        }
815 834
 
816 835
         if (isset($_REQUEST['backandedit'])) {
817 836
             $post = (object)$gd_session->get('listing');
818 837
 
819
-            if (!is_array($post->post_category[$cat_taxonomy]))
820
-                $post_category = $post->post_category[$cat_taxonomy];
838
+            if (!is_array($post->post_category[$cat_taxonomy])) {
839
+                            $post_category = $post->post_category[$cat_taxonomy];
840
+            }
821 841
 
822 842
             $post_categories = $post->post_category_str;
823
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
824
-                $post_category_str = $post_categories[$cat_taxonomy];
843
+            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
844
+                            $post_category_str = $post_categories[$cat_taxonomy];
845
+            }
825 846
 
826 847
         } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
827 848
             global $post;
@@ -1012,8 +1033,9 @@  discard block
 block discarded – undo
1012 1033
         if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1013 1034
             $post_cat_str = $post_categories[$cat_taxonomy];
1014 1035
             $post_cat_array = explode("#", $post_cat_str);
1015
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1016
-                $style = "display:none;";
1036
+            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) {
1037
+                            $style = "display:none;";
1038
+            }
1017 1039
         }
1018 1040
         ?>
1019 1041
         <div class="main_cat_list" style=" <?php if (isset($style)) {
@@ -1048,7 +1070,7 @@  discard block
 block discarded – undo
1048 1070
 
1049 1071
         if(is_array( $exclude_cats)){
1050 1072
             $exclude_cats = array_map( 'intval', $exclude_cats );
1051
-        }else{
1073
+        } else{
1052 1074
             $exclude_cats = intval($exclude_cats);
1053 1075
         }
1054 1076
 
@@ -1078,7 +1100,10 @@  discard block
 block discarded – undo
1078 1100
 
1079 1101
             <div class="post_default_category">
1080 1102
                 <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1081
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1103
+                       onchange="update_listing_cat()" <?php if ($default) {
1104
+	echo ' checked="checked" ';
1105
+}
1106
+?>   />
1082 1107
         <span> 
1083 1108
         <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1084 1109
         </span>
@@ -1178,8 +1203,9 @@  discard block
 block discarded – undo
1178 1203
         $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1179 1204
 
1180 1205
         $option_selected = '';
1181
-        if (!$selected)
1182
-            $option_slected = ' selected="selected" ';
1206
+        if (!$selected) {
1207
+                    $option_slected = ' selected="selected" ';
1208
+        }
1183 1209
 
1184 1210
         echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1185 1211
 
@@ -1187,8 +1213,9 @@  discard block
 block discarded – undo
1187 1213
 
1188 1214
         foreach ($cat_terms as $cat_term) {
1189 1215
             $option_selected = '';
1190
-            if ($selected == $cat_term->term_id)
1191
-                $option_selected = ' selected="selected" ';
1216
+            if ($selected == $cat_term->term_id) {
1217
+                            $option_selected = ' selected="selected" ';
1218
+            }
1192 1219
 
1193 1220
             // Count child terms
1194 1221
             $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
@@ -1253,8 +1280,9 @@  discard block
 block discarded – undo
1253 1280
 
1254 1281
     $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1255 1282
 
1256
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1257
-        $listing_slug = 'places';
1283
+    if (!$listing_slug = get_option('geodir_listing_prefix')) {
1284
+            $listing_slug = 'places';
1285
+    }
1258 1286
 
1259 1287
     /**
1260 1288
      * Taxonomies
@@ -1566,8 +1594,9 @@  discard block
 block discarded – undo
1566 1594
                             'city_slug' => $post->city_slug
1567 1595
                         );
1568 1596
 
1569
-                    } else
1570
-                        $post_location = geodir_get_location();
1597
+                    } else {
1598
+                                            $post_location = geodir_get_location();
1599
+                    }
1571 1600
 
1572 1601
 
1573 1602
                 } else {
@@ -1596,8 +1625,9 @@  discard block
 block discarded – undo
1596 1625
                             );
1597 1626
 
1598 1627
                         }
1599
-                    } else
1600
-                        $post_location = geodir_get_location();
1628
+                    } else {
1629
+                                            $post_location = geodir_get_location();
1630
+                    }
1601 1631
                 }
1602 1632
 
1603 1633
 
@@ -1636,16 +1666,17 @@  discard block
 block discarded – undo
1636 1666
 
1637 1667
                     if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1638 1668
                         $post_terms = absint($_POST['post_default_category']);
1639
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1669
+                    } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1640 1670
                         $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1641 1671
                         $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1642
-                    }elseif (isset($post->{$taxonomies})) {
1672
+                    } elseif (isset($post->{$taxonomies})) {
1643 1673
                         $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1644 1674
                         $post_terms = $post_terms[0];
1645 1675
                     }
1646 1676
 
1647
-                    if (!$post_terms)
1648
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1677
+                    if (!$post_terms) {
1678
+                                            $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1679
+                    }
1649 1680
 
1650 1681
                     if (!$post_terms) {
1651 1682
                         $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
@@ -1659,8 +1690,9 @@  discard block
 block discarded – undo
1659 1690
 
1660 1691
                 $term = get_term_by('id', $post_terms, $taxonomies);
1661 1692
 
1662
-                if (!empty($term))
1663
-                    $term_request = $term->slug;
1693
+                if (!empty($term)) {
1694
+                                    $term_request = $term->slug;
1695
+                }
1664 1696
                 //$term_request = $term->slug.'/';
1665 1697
             }
1666 1698
 
@@ -1675,9 +1707,13 @@  discard block
 block discarded – undo
1675 1707
                 $request_term .= $term_request;
1676 1708
 
1677 1709
             } else {
1678
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1710
+                if (isset($location_request) && $location_request != '') {
1711
+                	$request_term = $location_request;
1712
+                }
1679 1713
 
1680
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1714
+                if (isset($term_request) && $term_request != '') {
1715
+                	$request_term .= $term_request;
1716
+                }
1681 1717
             }
1682 1718
             $request_term = trim($request_term, '/');
1683 1719
             
@@ -1686,10 +1722,11 @@  discard block
 block discarded – undo
1686 1722
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1687 1723
             }
1688 1724
             
1689
-            if (!empty($request_term))
1690
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1691
-            else
1692
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1725
+            if (!empty($request_term)) {
1726
+                            $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1727
+            } else {
1728
+                            $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1729
+            }
1693 1730
             //echo $post_link ;
1694 1731
         }
1695 1732
         // temp cache the permalink
@@ -1881,11 +1918,12 @@  discard block
 block discarded – undo
1881 1918
     
1882 1919
     $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1883 1920
     
1884
-    if ($echo)
1885
-        echo $label;
1886
-    else
1887
-        return $label;
1888
-}
1921
+    if ($echo) {
1922
+            echo $label;
1923
+    } else {
1924
+            return $label;
1925
+    }
1926
+    }
1889 1927
 
1890 1928
 /**
1891 1929
  * Print or Get post type plural label.
@@ -1901,18 +1939,20 @@  discard block
 block discarded – undo
1901 1939
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1902 1940
     $all_postypes = geodir_get_posttypes();
1903 1941
 
1904
-    if (!in_array($post_type, $all_postypes))
1905
-        return false;
1942
+    if (!in_array($post_type, $all_postypes)) {
1943
+            return false;
1944
+    }
1906 1945
 
1907 1946
     $obj_post_type = get_post_type_object($post_type);
1908 1947
     
1909 1948
     $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1910 1949
     
1911
-    if ($echo)
1912
-        echo $label;
1913
-    else
1914
-        return $label;
1915
-}
1950
+    if ($echo) {
1951
+            echo $label;
1952
+    } else {
1953
+            return $label;
1954
+    }
1955
+    }
1916 1956
 
1917 1957
 /**
1918 1958
  * Checks whether a term exists or not.
@@ -1935,19 +1975,22 @@  discard block
 block discarded – undo
1935 1975
     $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1936 1976
 
1937 1977
     if (is_int($term)) {
1938
-        if (0 == $term)
1939
-            return 0;
1978
+        if (0 == $term) {
1979
+                    return 0;
1980
+        }
1940 1981
         $where = 't.term_id = %d';
1941
-        if (!empty($taxonomy))
1942
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1943
-        else
1944
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1982
+        if (!empty($taxonomy)) {
1983
+                    return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1984
+        } else {
1985
+                    return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1986
+        }
1945 1987
     }
1946 1988
 
1947 1989
     $term = trim(wp_unslash($term));
1948 1990
 
1949
-    if ('' === $slug = sanitize_title($term))
1950
-        return 0;
1991
+    if ('' === $slug = sanitize_title($term)) {
1992
+            return 0;
1993
+    }
1951 1994
 
1952 1995
     $where = 't.slug = %s';
1953 1996
 
@@ -1964,14 +2007,16 @@  discard block
 block discarded – undo
1964 2007
         $where_fields[] = $taxonomy;
1965 2008
 
1966 2009
 
1967
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1968
-            return $result;
2010
+        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) {
2011
+                    return $result;
2012
+        }
1969 2013
 
1970 2014
         return false;
1971 2015
     }
1972 2016
 
1973
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1974
-        return $result;
2017
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) {
2018
+            return $result;
2019
+    }
1975 2020
 
1976 2021
     return false;
1977 2022
 }
Please login to merge, or discard this patch.
geodirectory-functions/map-functions/get_markers.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
  *
82 82
  * @param string $map_json The map marker json.
83 83
  * @since 1.6.22
84
- * @return mixed
84
+ * @return string
85 85
  */
86 86
 function geodir_save_map_cache($map_json){
87 87
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -247,11 +247,13 @@  discard block
 block discarded – undo
247 247
         }
248 248
     }
249 249
 
250
-    if (!empty($field_default_cat))
251
-        $field_default_cat = '';
250
+    if (!empty($field_default_cat)) {
251
+            $field_default_cat = '';
252
+    }
252 253
 
253
-    if (!empty($cat_find_array))
254
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
254
+    if (!empty($cat_find_array)) {
255
+            $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
256
+    }
255 257
 
256 258
     $main_query_array = $map_cat_ids_array;
257 259
   
@@ -283,8 +285,9 @@  discard block
 block discarded – undo
283 285
         $gd_posttype = " AND p.post_type = %s";
284 286
         $main_query_array[] = $_REQUEST['gd_posttype'];
285 287
 
286
-    } else
287
-        $table = $plugin_prefix . 'gd_place_detail';
288
+    } else {
289
+            $table = $plugin_prefix . 'gd_place_detail';
290
+    }
288 291
 
289 292
     $join = ", " . $table . " AS pd ";
290 293
 
@@ -606,8 +609,7 @@  discard block
 block discarded – undo
606 609
 
607 610
     if (!empty($cat_content_info)) {
608 611
         $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
609
-    }
610
-    else {
612
+    } else {
611 613
         $map_json =  '[{"totalcount":"0"}]';
612 614
     }
613 615
 
Please login to merge, or discard this patch.
Indentation   +445 added lines, -445 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 
9 9
 // Enable map cache if set
10 10
 if(get_option('geodir_enable_map_cache')){
11
-    add_filter('geodir_get_markers_cache','geodir_get_map_cache');
12
-    add_filter('geodir_markers_json','geodir_save_map_cache',10);
11
+	add_filter('geodir_get_markers_cache','geodir_get_map_cache');
12
+	add_filter('geodir_markers_json','geodir_save_map_cache',10);
13 13
 }
14 14
 
15 15
 
@@ -23,56 +23,56 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function geodir_get_map_cache($cache){
25 25
 
26
-    // if a search is going on then dont even try to check for cache.
27
-    if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
28
-        return $cache;
29
-    }
26
+	// if a search is going on then dont even try to check for cache.
27
+	if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
28
+		return $cache;
29
+	}
30 30
 
31
-    $url_params = array();
32
-    $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : '';
33
-    $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : '';
34
-    $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : '';
35
-    $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : '';
36
-    $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : '';
37
-    $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : '';
38
-    $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : '';
39
-    $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : '';
40
-    $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : '';
41
-    $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : '';
42
-    $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : '';
43
-    $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : '';
44
-    $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : '';
31
+	$url_params = array();
32
+	$url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : '';
33
+	$url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : '';
34
+	$url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : '';
35
+	$url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : '';
36
+	$url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : '';
37
+	$url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : '';
38
+	$url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : '';
39
+	$url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : '';
40
+	$url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : '';
41
+	$url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : '';
42
+	$url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : '';
43
+	$url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : '';
44
+	$url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : '';
45 45
 
46
-    $file_name = sanitize_file_name( md5( implode("-",$url_params) )  );
46
+	$file_name = sanitize_file_name( md5( implode("-",$url_params) )  );
47 47
 
48
-    $blog_id = get_current_blog_id();
49
-    if($blog_id>1){
50
-        $file_name = $blog_id."_".$file_name;
51
-    }
48
+	$blog_id = get_current_blog_id();
49
+	if($blog_id>1){
50
+		$file_name = $blog_id."_".$file_name;
51
+	}
52 52
 
53
-    $file_path = realpath(dirname(__FILE__))."/map-cache/";
53
+	$file_path = realpath(dirname(__FILE__))."/map-cache/";
54 54
 
55 55
 
56
-    if(file_exists($file_path.$file_name.".json")){
56
+	if(file_exists($file_path.$file_name.".json")){
57 57
 
58 58
 
59
-        // do the cache delete stuff
60
-        $cache_time = get_option('geodir_map_cache');
61
-        if(!$cache_time){
62
-            $cache_time = time();
63
-            update_option('geodir_map_cache', $cache_time);
64
-        }
59
+		// do the cache delete stuff
60
+		$cache_time = get_option('geodir_map_cache');
61
+		if(!$cache_time){
62
+			$cache_time = time();
63
+			update_option('geodir_map_cache', $cache_time);
64
+		}
65 65
 
66
-        if((time() - $cache_time) > 86400){ // delete the cache every 24 hours
67
-            geodir_delete_map_cache();
68
-        }
66
+		if((time() - $cache_time) > 86400){ // delete the cache every 24 hours
67
+			geodir_delete_map_cache();
68
+		}
69 69
 
70
-        ob_start();
71
-        readfile($file_path.$file_name.".json"); // readfile is quicker then file get contents
72
-        return ob_get_clean();
73
-    }
70
+		ob_start();
71
+		readfile($file_path.$file_name.".json"); // readfile is quicker then file get contents
72
+		return ob_get_clean();
73
+	}
74 74
 
75
-    return $cache;
75
+	return $cache;
76 76
 }
77 77
 
78 78
 
@@ -85,109 +85,109 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_save_map_cache($map_json){
87 87
 
88
-    // if a search is going on then dont even try to check for cache.
89
-    if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
90
-        return $map_json;
91
-    }
92
-
93
-    $url_params = array();
94
-    $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : '';
95
-    $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : '';
96
-    $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : '';
97
-    $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : '';
98
-    $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : '';
99
-    $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : '';
100
-    $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : '';
101
-    $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : '';
102
-    $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : '';
103
-    $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : '';
104
-    $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : '';
105
-    $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : '';
106
-    $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : '';
107
-
108
-    $file_name = sanitize_file_name( md5( implode("-",$url_params) )  );
109
-
110
-    $blog_id = get_current_blog_id();
111
-    if($blog_id>1){
112
-        $file_name = $blog_id."_".$file_name;
113
-    }
114
-
115
-    $file_path = realpath(dirname(__FILE__))."/map-cache/";
116
-
117
-
118
-    global $wp_filesystem;
119
-    if (empty($wp_filesystem)) {
120
-        require_once (ABSPATH . '/wp-admin/includes/file.php');
121
-        WP_Filesystem();
122
-    }
123
-    $wp_filesystem->put_contents(
124
-        $file_path.$file_name.".json",
125
-        $map_json,
126
-        FS_CHMOD_FILE // predefined mode settings for WP files
127
-    );
128
-
129
-
130
-    return $map_json;
88
+	// if a search is going on then dont even try to check for cache.
89
+	if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
90
+		return $map_json;
91
+	}
92
+
93
+	$url_params = array();
94
+	$url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : '';
95
+	$url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : '';
96
+	$url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : '';
97
+	$url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : '';
98
+	$url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : '';
99
+	$url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : '';
100
+	$url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : '';
101
+	$url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : '';
102
+	$url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : '';
103
+	$url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : '';
104
+	$url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : '';
105
+	$url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : '';
106
+	$url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : '';
107
+
108
+	$file_name = sanitize_file_name( md5( implode("-",$url_params) )  );
109
+
110
+	$blog_id = get_current_blog_id();
111
+	if($blog_id>1){
112
+		$file_name = $blog_id."_".$file_name;
113
+	}
114
+
115
+	$file_path = realpath(dirname(__FILE__))."/map-cache/";
116
+
117
+
118
+	global $wp_filesystem;
119
+	if (empty($wp_filesystem)) {
120
+		require_once (ABSPATH . '/wp-admin/includes/file.php');
121
+		WP_Filesystem();
122
+	}
123
+	$wp_filesystem->put_contents(
124
+		$file_path.$file_name.".json",
125
+		$map_json,
126
+		FS_CHMOD_FILE // predefined mode settings for WP files
127
+	);
128
+
129
+
130
+	return $map_json;
131 131
 
132 132
 }
133 133
 
134 134
 
135 135
 if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'homemap_catlist') {
136
-    global $gd_session;
137
-    $gd_post_type = sanitize_text_field($_REQUEST['post_type']);
138
-    $gd_session->set('homemap_catlist_ptype', $gd_post_type);
139
-    $post_taxonomy = geodir_get_taxonomies($gd_post_type);
140
-    $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
141
-    $child_collapse = (bool)$_REQUEST['child_collapse'];
142
-    echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
143
-    die;
136
+	global $gd_session;
137
+	$gd_post_type = sanitize_text_field($_REQUEST['post_type']);
138
+	$gd_session->set('homemap_catlist_ptype', $gd_post_type);
139
+	$post_taxonomy = geodir_get_taxonomies($gd_post_type);
140
+	$map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
141
+	$child_collapse = (bool)$_REQUEST['child_collapse'];
142
+	echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
143
+	die;
144 144
 }
145 145
 
146 146
 // Send the content-type header with correct encoding
147 147
 header("Content-type: text/javascript; charset=utf-8");
148 148
 
149 149
 if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'cat') { // Retrives markers data for categories
150
-    echo get_markers();
151
-    exit;
150
+	echo get_markers();
151
+	exit;
152 152
 } else if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'info') { // Retrives marker info window html
153
-    /**
154
-     * @global object $wpdb WordPress Database object.
155
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
156
-     * @global object $gd_session GeoDirectory Session object.
157
-     */
158
-    global $wpdb, $plugin_prefix, $gd_session;
159
-
160
-    if ($_REQUEST['m_id'] != '') {
161
-        $pid = (int)$_REQUEST['m_id'];
162
-    } else {
163
-        echo __('No marker data found', 'geodirectory');
164
-        exit;
165
-    }
166
-
167
-    if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
168
-        $post = (object)$gd_ses_listing;
169
-        echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
170
-    } else {
171
-        $geodir_post_type = get_post_type($pid);
172
-
173
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
174
-
175
-        $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
176
-
177
-        $postinfo = $wpdb->get_results($sql);
178
-
179
-        $data_arr = array();
180
-
181
-        if ($postinfo) {
182
-            $srcharr = array("'", "/", "-", '"', '\\');
183
-            $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
184
-
185
-            foreach ($postinfo as $postinfo_obj) {
186
-                echo geodir_get_infowindow_html($postinfo_obj);
187
-            }
188
-        }
189
-    }
190
-    exit;
153
+	/**
154
+	 * @global object $wpdb WordPress Database object.
155
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
156
+	 * @global object $gd_session GeoDirectory Session object.
157
+	 */
158
+	global $wpdb, $plugin_prefix, $gd_session;
159
+
160
+	if ($_REQUEST['m_id'] != '') {
161
+		$pid = (int)$_REQUEST['m_id'];
162
+	} else {
163
+		echo __('No marker data found', 'geodirectory');
164
+		exit;
165
+	}
166
+
167
+	if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
168
+		$post = (object)$gd_ses_listing;
169
+		echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
170
+	} else {
171
+		$geodir_post_type = get_post_type($pid);
172
+
173
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
174
+
175
+		$sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
176
+
177
+		$postinfo = $wpdb->get_results($sql);
178
+
179
+		$data_arr = array();
180
+
181
+		if ($postinfo) {
182
+			$srcharr = array("'", "/", "-", '"', '\\');
183
+			$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
184
+
185
+			foreach ($postinfo as $postinfo_obj) {
186
+				echo geodir_get_infowindow_html($postinfo_obj);
187
+			}
188
+		}
189
+	}
190
+	exit;
191 191
 }
192 192
 
193 193
 /**
@@ -206,93 +206,93 @@  discard block
 block discarded – undo
206 206
  */
207 207
 function get_markers() {
208 208
     
209
-    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session;
209
+	global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session;
210 210
 
211 211
 
212
-    /**
213
-     * Filter to allow for any map caching to be output before queries.
214
-     *
215
-     * @since 1.6.22
216
-     */
217
-    $map_cache = apply_filters('geodir_get_markers_cache','');
218
-    if($map_cache){
219
-        return $map_cache;
220
-        wp_die();
221
-    }
212
+	/**
213
+	 * Filter to allow for any map caching to be output before queries.
214
+	 *
215
+	 * @since 1.6.22
216
+	 */
217
+	$map_cache = apply_filters('geodir_get_markers_cache','');
218
+	if($map_cache){
219
+		return $map_cache;
220
+		wp_die();
221
+	}
222 222
 
223 223
 
224 224
 
225
-    $search = '';
225
+	$search = '';
226 226
 
227
-    $srcharr = array("'", "/", "-", '"', '\\', '&#39;');
228
-    $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '', "&prime;");
227
+	$srcharr = array("'", "/", "-", '"', '\\', '&#39;');
228
+	$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '', "&prime;");
229 229
 
230
-    $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
230
+	$post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
231 231
 
232
-    $map_cat_ids_array = array('0');
233
-    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
232
+	$map_cat_ids_array = array('0');
233
+	$cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
234 234
 
235 235
 
236
-    $field_default_cat = '';
237
-    if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
238
-        $map_cat_arr = trim($_REQUEST['cat_id'], ',');
236
+	$field_default_cat = '';
237
+	if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
238
+		$map_cat_arr = trim($_REQUEST['cat_id'], ',');
239 239
 
240
-        if (!empty($map_cat_arr)) {
241
-            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
240
+		if (!empty($map_cat_arr)) {
241
+			$field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
242 242
 
243
-            $map_cat_ids_array = explode(',', $map_cat_arr);
244
-            $cat_find_array = array();
245
-            foreach ($map_cat_ids_array as $cat_id) {
246
-                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
247
-                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
248
-                $main_query_array[] = $cat_id;
249
-            }
243
+			$map_cat_ids_array = explode(',', $map_cat_arr);
244
+			$cat_find_array = array();
245
+			foreach ($map_cat_ids_array as $cat_id) {
246
+				$field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
247
+				$cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
248
+				$main_query_array[] = $cat_id;
249
+			}
250 250
 
251
-        }
252
-    }
251
+		}
252
+	}
253 253
 
254
-    if (!empty($field_default_cat))
255
-        $field_default_cat = '';
254
+	if (!empty($field_default_cat))
255
+		$field_default_cat = '';
256 256
 
257
-    if (!empty($cat_find_array))
258
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
257
+	if (!empty($cat_find_array))
258
+		$search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
259 259
 
260
-    $main_query_array = $map_cat_ids_array;
260
+	$main_query_array = $map_cat_ids_array;
261 261
   
262
-    if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
263
-        $search .= " AND p.post_title LIKE %s";
264
-        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
265
-    }
266
-
267
-    /**
268
-     * Filter the marker query search SQL, values are replaces with %s or %d.
269
-     *
270
-     * @since 1.5.3
271
-     *
272
-     * @param string $search The SQL query for search/where.
273
-     */
274
-    $search = apply_filters('geodir_marker_search', $search);
275
-    /**
276
-     * Filter the marker query search SQL values %s and %d, this is an array of values.
277
-     *
278
-     * @since 1.5.3
279
-     *
280
-     * @param array $main_query_array The SQL query values for search/where.
281
-     */
282
-    $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
283
-
284
-    $gd_posttype = '';
285
-    if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
286
-        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
287
-        $gd_posttype = " AND p.post_type = %s";
288
-        $main_query_array[] = $_REQUEST['gd_posttype'];
289
-
290
-    } else
291
-        $table = $plugin_prefix . 'gd_place_detail';
292
-
293
-    $join = ", " . $table . " AS pd ";
294
-
295
-    /**
262
+	if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
263
+		$search .= " AND p.post_title LIKE %s";
264
+		$main_query_array[] = "%" . $_REQUEST['search'] . "%";
265
+	}
266
+
267
+	/**
268
+	 * Filter the marker query search SQL, values are replaces with %s or %d.
269
+	 *
270
+	 * @since 1.5.3
271
+	 *
272
+	 * @param string $search The SQL query for search/where.
273
+	 */
274
+	$search = apply_filters('geodir_marker_search', $search);
275
+	/**
276
+	 * Filter the marker query search SQL values %s and %d, this is an array of values.
277
+	 *
278
+	 * @since 1.5.3
279
+	 *
280
+	 * @param array $main_query_array The SQL query values for search/where.
281
+	 */
282
+	$main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
283
+
284
+	$gd_posttype = '';
285
+	if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
286
+		$table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
287
+		$gd_posttype = " AND p.post_type = %s";
288
+		$main_query_array[] = $_REQUEST['gd_posttype'];
289
+
290
+	} else
291
+		$table = $plugin_prefix . 'gd_place_detail';
292
+
293
+	$join = ", " . $table . " AS pd ";
294
+
295
+	/**
296 296
 	 * Filter the SQL JOIN clause for the markers data
297 297
 	 *
298 298
 	 * @since 1.0.0
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 	 * @param string $search Row of searched fields to use in WHERE clause.
310 310
 	 */
311 311
 	$search = apply_filters('geodir_home_map_listing_where', $search);
312
-    $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
313
-    $cat_type = $post_type . 'category';
314
-    if ($post_type == 'gd_event') {
315
-        $event_select = ", pd.recurring_dates, pd.is_recurring";
316
-    } else {
317
-        $event_select = "";
318
-    }
319
-
320
-    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
321
-    /**
312
+	$search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
313
+	$cat_type = $post_type . 'category';
314
+	if ($post_type == 'gd_event') {
315
+		$event_select = ", pd.recurring_dates, pd.is_recurring";
316
+	} else {
317
+		$event_select = "";
318
+	}
319
+
320
+	$sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
321
+	/**
322 322
 	 * Filter the SQL SELECT clause to retrive fields data
323 323
 	 *
324 324
 	 * @since 1.0.0
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	$groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
339 339
 
340
-    $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
340
+	$catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
341 341
     
342 342
 	/**
343 343
 	 * Filter the SQL query to retrive markers data
@@ -353,276 +353,276 @@  discard block
 block discarded – undo
353 353
 //    print_r($gd_session);
354 354
 //    print_r($_SESSION);
355 355
 
356
-    $catinfo = $wpdb->get_results($catsql);
356
+	$catinfo = $wpdb->get_results($catsql);
357 357
 	
358
-    $cat_content_info = array();
359
-    $content_data = array();
360
-    $post_ids = array();
361
-
362
-    /**
363
-     * Called before marker data is processed into JSON.
364
-     *
365
-     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
366
-     *
367
-     * @since 1.5.3
368
-     * @param object $catinfo The posts object containing all marker data.
369
-     * @see 'geodir_after_marker_post_process'
370
-     */
371
-    $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
372
-
373
-    /**
374
-     * Called before marker data is processed into JSON.
375
-     *
376
-     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
377
-     *
378
-     * @since 1.4.9
379
-     * @param object $catinfo The posts object containing all marker data.
380
-     * @see 'geodir_after_marker_post_process'
381
-     */
382
-    do_action('geodir_before_marker_post_process_action', $catinfo);
383
-
384
-    // Sort any posts into a ajax array
385
-    if (!empty($catinfo)) {
386
-        $geodir_cat_icons = geodir_get_term_icon();
387
-        global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
388
-
389
-        $today = strtotime(date_i18n('Y-m-d'));
390
-        $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
358
+	$cat_content_info = array();
359
+	$content_data = array();
360
+	$post_ids = array();
361
+
362
+	/**
363
+	 * Called before marker data is processed into JSON.
364
+	 *
365
+	 * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
366
+	 *
367
+	 * @since 1.5.3
368
+	 * @param object $catinfo The posts object containing all marker data.
369
+	 * @see 'geodir_after_marker_post_process'
370
+	 */
371
+	$catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
372
+
373
+	/**
374
+	 * Called before marker data is processed into JSON.
375
+	 *
376
+	 * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
377
+	 *
378
+	 * @since 1.4.9
379
+	 * @param object $catinfo The posts object containing all marker data.
380
+	 * @see 'geodir_after_marker_post_process'
381
+	 */
382
+	do_action('geodir_before_marker_post_process_action', $catinfo);
383
+
384
+	// Sort any posts into a ajax array
385
+	if (!empty($catinfo)) {
386
+		$geodir_cat_icons = geodir_get_term_icon();
387
+		global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
388
+
389
+		$today = strtotime(date_i18n('Y-m-d'));
390
+		$show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
391 391
         
392
-        foreach ($catinfo as $catinfo_obj) {
393
-            $post_title = $catinfo_obj->post_title;
392
+		foreach ($catinfo as $catinfo_obj) {
393
+			$post_title = $catinfo_obj->post_title;
394 394
             
395
-            if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
396
-                $event_dates = '';
397
-                $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
395
+			if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) {
396
+				$event_dates = '';
397
+				$recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
398 398
 
399
-                $post_info = geodir_get_post_info($catinfo_obj->post_id);
399
+				$post_info = geodir_get_post_info($catinfo_obj->post_id);
400 400
                 
401
-                if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
402
-                    $starttimes = '';
403
-                    $endtimes = '';
404
-                    $astarttimes = array();
405
-                    $aendtimes = array();
406
-                    if ( !isset( $recurring_data['repeat_type'] ) ) {
407
-                        $recurring_data['repeat_type'] = 'custom';
408
-                    }
409
-                    $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
410
-                    $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
401
+				if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
402
+					$starttimes = '';
403
+					$endtimes = '';
404
+					$astarttimes = array();
405
+					$aendtimes = array();
406
+					if ( !isset( $recurring_data['repeat_type'] ) ) {
407
+						$recurring_data['repeat_type'] = 'custom';
408
+					}
409
+					$repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
410
+					$different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
411 411
         
412
-                    $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
412
+					$recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
413 413
                     
414
-                    if ( !empty( $recurring_dates ) ) {
415
-                        if ( empty( $recurring_data['all_day'] ) ) {
416
-                            if ( $repeat_type == 'custom' && $different_times ) {
417
-                                $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
418
-                                $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
419
-                            } else {
420
-                                $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
421
-                                $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
422
-                            }
423
-                        }
414
+					if ( !empty( $recurring_dates ) ) {
415
+						if ( empty( $recurring_data['all_day'] ) ) {
416
+							if ( $repeat_type == 'custom' && $different_times ) {
417
+								$astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
418
+								$aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
419
+							} else {
420
+								$starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
421
+								$endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
422
+							}
423
+						}
424 424
                         
425
-                        $e = 0;
426
-                        foreach( $recurring_dates as $key => $date ) {
427
-                            if ( $repeat_type == 'custom' && $different_times ) {
428
-                                if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
429
-                                    $starttimes = $astarttimes[$key];
430
-                                    $endtimes = $aendtimes[$key];
431
-                                } else {
432
-                                    $starttimes = '';
433
-                                    $endtimes = '';
434
-                                }
435
-                            }
425
+						$e = 0;
426
+						foreach( $recurring_dates as $key => $date ) {
427
+							if ( $repeat_type == 'custom' && $different_times ) {
428
+								if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
429
+									$starttimes = $astarttimes[$key];
430
+									$endtimes = $aendtimes[$key];
431
+								} else {
432
+									$starttimes = '';
433
+									$endtimes = '';
434
+								}
435
+							}
436 436
                             
437
-                            $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
438
-                            $duration--;
439
-                            $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
437
+							$duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
438
+							$duration--;
439
+							$enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
440 440
                             
441
-                            // Hide past dates
442
-                            if ( strtotime( $enddate ) < $today ) {
443
-                                continue;
444
-                            }
441
+							// Hide past dates
442
+							if ( strtotime( $enddate ) < $today ) {
443
+								continue;
444
+							}
445 445
                                     
446
-                            $sdate = strtotime( $date . ' ' . $starttimes );
447
-                            $edate = strtotime( $enddate . ' ' . $endtimes );
446
+							$sdate = strtotime( $date . ' ' . $starttimes );
447
+							$edate = strtotime( $enddate . ' ' . $endtimes );
448 448
                                         
449
-                            $start_date = date_i18n( $geodir_date_time_format, $sdate );
450
-                            $end_date = date_i18n( $geodir_date_time_format, $edate );
449
+							$start_date = date_i18n( $geodir_date_time_format, $sdate );
450
+							$end_date = date_i18n( $geodir_date_time_format, $edate );
451 451
                             
452
-                            $same_day = false;
453
-                            $full_day = false;
454
-                            $same_datetime = false;
452
+							$same_day = false;
453
+							$full_day = false;
454
+							$same_datetime = false;
455 455
                             
456
-                            if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
457
-                                $full_day = true;
458
-                            }
456
+							if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
457
+								$full_day = true;
458
+							}
459 459
                             
460
-                            if ( $start_date == $end_date && $full_day ) {
461
-                                $same_datetime = true;
462
-                            }
463
-
464
-                            $link_date = date_i18n( 'Y-m-d', $sdate );
465
-                            $title_date = date_i18n( $geodir_date_format, $sdate );
466
-                            if ( $full_day ) {
467
-                                $start_date = $title_date;
468
-                                $end_date = date_i18n( $geodir_date_format, $edate );
469
-                            }
460
+							if ( $start_date == $end_date && $full_day ) {
461
+								$same_datetime = true;
462
+							}
463
+
464
+							$link_date = date_i18n( 'Y-m-d', $sdate );
465
+							$title_date = date_i18n( $geodir_date_format, $sdate );
466
+							if ( $full_day ) {
467
+								$start_date = $title_date;
468
+								$end_date = date_i18n( $geodir_date_format, $edate );
469
+							}
470 470
                             
471
-                            if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
472
-                                $same_day = true;
471
+							if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
472
+								$same_day = true;
473 473
                                 
474
-                                $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
475
-                            }
474
+								$start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
475
+							}
476 476
                             
477
-                            $event_dates .= ' :: ' . $start_date;
477
+							$event_dates .= ' :: ' . $start_date;
478 478
                         
479
-                            if ( !$same_day && !$same_datetime ) {
480
-                                $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
481
-                            }
479
+							if ( !$same_day && !$same_datetime ) {
480
+								$event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
481
+							}
482 482
                             
483
-                            $e++;
483
+							$e++;
484 484
                             
485
-                            if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
486
-                                break;
487
-                            }
488
-                        }
489
-                    }
490
-                } else {
491
-                    $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
492
-                    $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
493
-                    $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
494
-                    $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
495
-                    $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
485
+							if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates
486
+								break;
487
+							}
488
+						}
489
+					}
490
+				} else {
491
+					$start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
492
+					$end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
493
+					$all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
494
+					$starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
495
+					$endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
496 496
                 
497
-                    $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
498
-                    $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
499
-                    $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
497
+					$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
498
+					$starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
499
+					$endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
500 500
                     
501
-                    if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
502
-                        $start_date = $event_recurring_dates[0];
503
-                    }
501
+					if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
502
+						$start_date = $event_recurring_dates[0];
503
+					}
504 504
                                 
505
-                    if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
506
-                        $end_date = $start_date;
507
-                    }
505
+					if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
506
+						$end_date = $start_date;
507
+					}
508 508
                     
509
-                    if ($end_date != '' && strtotime($end_date) >= $today) {
510
-                        if ( $starttime == '' && !empty( $starttimes ) ) {
511
-                            $starttime = $starttimes[0];
512
-                            $endtime = $endtimes[0];
513
-                        }
509
+					if ($end_date != '' && strtotime($end_date) >= $today) {
510
+						if ( $starttime == '' && !empty( $starttimes ) ) {
511
+							$starttime = $starttimes[0];
512
+							$endtime = $endtimes[0];
513
+						}
514 514
                         
515
-                        $same_day = false;
516
-                        $one_day = false;
517
-                        if ( $start_date == $end_date && $all_day ) {
518
-                            $one_day = true;
519
-                        }
520
-
521
-                        if ( $all_day ) {
522
-                            $start_datetime = strtotime( $start_date );
523
-                            $end_datetime = strtotime( $end_date );
515
+						$same_day = false;
516
+						$one_day = false;
517
+						if ( $start_date == $end_date && $all_day ) {
518
+							$one_day = true;
519
+						}
520
+
521
+						if ( $all_day ) {
522
+							$start_datetime = strtotime( $start_date );
523
+							$end_datetime = strtotime( $end_date );
524 524
                             
525
-                            $start_date = date_i18n( $geodir_date_format, $start_datetime );
526
-                            $end_date = date_i18n( $geodir_date_format, $end_datetime );
527
-                            if ( $start_date == $end_date ) {
528
-                                $one_day = true;
529
-                            }
530
-                        } else {
531
-                            if ( $start_date == $end_date && $starttime == $endtime ) {
532
-                                $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
533
-                                $one_day = false;
534
-                            }
535
-                            $start_datetime = strtotime( $start_date . ' ' . $starttime );
536
-                            $end_datetime = strtotime( $end_date . ' ' . $endtime );
525
+							$start_date = date_i18n( $geodir_date_format, $start_datetime );
526
+							$end_date = date_i18n( $geodir_date_format, $end_datetime );
527
+							if ( $start_date == $end_date ) {
528
+								$one_day = true;
529
+							}
530
+						} else {
531
+							if ( $start_date == $end_date && $starttime == $endtime ) {
532
+								$end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
533
+								$one_day = false;
534
+							}
535
+							$start_datetime = strtotime( $start_date . ' ' . $starttime );
536
+							$end_datetime = strtotime( $end_date . ' ' . $endtime );
537 537
                             
538
-                            $start_date = date_i18n( $geodir_date_time_format, $start_datetime );
539
-                            $end_date = date_i18n( $geodir_date_time_format, $end_datetime );
540
-                        }
538
+							$start_date = date_i18n( $geodir_date_time_format, $start_datetime );
539
+							$end_date = date_i18n( $geodir_date_time_format, $end_datetime );
540
+						}
541 541
 
542
-                        if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
543
-                            $same_day = true;
542
+						if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
543
+							$same_day = true;
544 544
                             
545
-                            $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
546
-                        }
545
+							$start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
546
+						}
547 547
                         
548
-                        $event_dates .= ' :: ' . $start_date;
548
+						$event_dates .= ' :: ' . $start_date;
549 549
                         
550
-                        if ( !$same_day && !$one_day ) {
551
-                            $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
552
-                        }
553
-                    }
554
-                }
555
-
556
-                if (empty($event_dates)) {
557
-                    continue;
558
-                }
550
+						if ( !$same_day && !$one_day ) {
551
+							$event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
552
+						}
553
+					}
554
+				}
555
+
556
+				if (empty($event_dates)) {
557
+					continue;
558
+				}
559 559
                 
560
-                $post_title .= $event_dates;
561
-            }
560
+				$post_title .= $event_dates;
561
+			}
562 562
 
563
-            $map_cat_ids_array;
564
-            $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
563
+			$map_cat_ids_array;
564
+			$default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
565 565
 
566
-            // if single cat lets just show that icon
567
-            if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
568
-                $default_cat = (int)$map_cat_ids_array[0];
569
-            }
566
+			// if single cat lets just show that icon
567
+			if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
568
+				$default_cat = (int)$map_cat_ids_array[0];
569
+			}
570 570
 
571
-            $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
572
-            $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : '';
573
-            $title = str_replace($srcharr, $replarr, $post_title);
571
+			$icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
572
+			$mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : '';
573
+			$title = str_replace($srcharr, $replarr, $post_title);
574 574
             
575
-            if ($icon != '') {
576
-                $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes;
575
+			if ($icon != '') {
576
+				$gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes;
577 577
                 
578
-                if (isset($gd_marker_sizes[$icon])) {
579
-                    $icon_size = $gd_marker_sizes[$icon];
580
-                } else {
581
-                    $icon_size = geodir_get_marker_size($icon);
582
-                    $gd_marker_sizes[$icon] = $icon_size;
583
-                }               
584
-            } else {
585
-                $icon_size = array('w' => 36, 'h' => 45);
586
-            }
587
-
588
-            $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
589
-            $post_ids[] = $catinfo_obj->post_id;
590
-        }
591
-    }
592
-
593
-    /**
594
-     * Called after marker data is processed into JSON.
595
-     *
596
-     * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
597
-     *
598
-     * @since 1.4.9
599
-     * @param array $content_data The array containing all markers in JSON format.
600
-     * @param object $catinfo The posts object containing all marker data.
601
-     * @see 'geodir_before_marker_post_process'
602
-     */
603
-    do_action('geodir_after_marker_post_process', $content_data, $catinfo);
604
-
605
-    if (!empty($content_data)) {
606
-        $cat_content_info[] = implode(',', $content_data);
607
-    }
608
-
609
-    $totalcount = count(array_unique($post_ids));
610
-
611
-    if (!empty($cat_content_info)) {
612
-        $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
613
-    }
614
-    else {
615
-        $map_json =  '[{"totalcount":"0"}]';
616
-    }
617
-
618
-
619
-    /**
620
-     * Filter the marker json return.
621
-     *
622
-     * @since 1.6.22
623
-     * @param string $map_json The JSON string of the map markers results.
624
-     */
625
-    return apply_filters('geodir_markers_json',$map_json);
578
+				if (isset($gd_marker_sizes[$icon])) {
579
+					$icon_size = $gd_marker_sizes[$icon];
580
+				} else {
581
+					$icon_size = geodir_get_marker_size($icon);
582
+					$gd_marker_sizes[$icon] = $icon_size;
583
+				}               
584
+			} else {
585
+				$icon_size = array('w' => 36, 'h' => 45);
586
+			}
587
+
588
+			$content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
589
+			$post_ids[] = $catinfo_obj->post_id;
590
+		}
591
+	}
592
+
593
+	/**
594
+	 * Called after marker data is processed into JSON.
595
+	 *
596
+	 * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
597
+	 *
598
+	 * @since 1.4.9
599
+	 * @param array $content_data The array containing all markers in JSON format.
600
+	 * @param object $catinfo The posts object containing all marker data.
601
+	 * @see 'geodir_before_marker_post_process'
602
+	 */
603
+	do_action('geodir_after_marker_post_process', $content_data, $catinfo);
604
+
605
+	if (!empty($content_data)) {
606
+		$cat_content_info[] = implode(',', $content_data);
607
+	}
608
+
609
+	$totalcount = count(array_unique($post_ids));
610
+
611
+	if (!empty($cat_content_info)) {
612
+		$map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
613
+	}
614
+	else {
615
+		$map_json =  '[{"totalcount":"0"}]';
616
+	}
617
+
618
+
619
+	/**
620
+	 * Filter the marker json return.
621
+	 *
622
+	 * @since 1.6.22
623
+	 * @param string $map_json The JSON string of the map markers results.
624
+	 */
625
+	return apply_filters('geodir_markers_json',$map_json);
626 626
 }
627 627
 
628 628
 
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Enable map cache if set
10
-if(get_option('geodir_enable_map_cache')){
11
-    add_filter('geodir_get_markers_cache','geodir_get_map_cache');
12
-    add_filter('geodir_markers_json','geodir_save_map_cache',10);
10
+if (get_option('geodir_enable_map_cache')) {
11
+    add_filter('geodir_get_markers_cache', 'geodir_get_map_cache');
12
+    add_filter('geodir_markers_json', 'geodir_save_map_cache', 10);
13 13
 }
14 14
 
15 15
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  * @since 1.6.22
22 22
  * @return string
23 23
  */
24
-function geodir_get_map_cache($cache){
24
+function geodir_get_map_cache($cache) {
25 25
 
26 26
     // if a search is going on then dont even try to check for cache.
27
-    if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
27
+    if (isset($_REQUEST['search']) && !empty($_REQUEST['search'])) {
28 28
         return $cache;
29 29
     }
30 30
 
@@ -43,27 +43,27 @@  discard block
 block discarded – undo
43 43
     $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : '';
44 44
     $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : '';
45 45
 
46
-    $file_name = sanitize_file_name( md5( implode("-",$url_params) )  );
46
+    $file_name = sanitize_file_name(md5(implode("-", $url_params)));
47 47
 
48 48
     $blog_id = get_current_blog_id();
49
-    if($blog_id>1){
49
+    if ($blog_id > 1) {
50 50
         $file_name = $blog_id."_".$file_name;
51 51
     }
52 52
 
53 53
     $file_path = realpath(dirname(__FILE__))."/map-cache/";
54 54
 
55 55
 
56
-    if(file_exists($file_path.$file_name.".json")){
56
+    if (file_exists($file_path.$file_name.".json")) {
57 57
 
58 58
 
59 59
         // do the cache delete stuff
60 60
         $cache_time = get_option('geodir_map_cache');
61
-        if(!$cache_time){
61
+        if (!$cache_time) {
62 62
             $cache_time = time();
63 63
             update_option('geodir_map_cache', $cache_time);
64 64
         }
65 65
 
66
-        if((time() - $cache_time) > 86400){ // delete the cache every 24 hours
66
+        if ((time() - $cache_time) > 86400) { // delete the cache every 24 hours
67 67
             geodir_delete_map_cache();
68 68
         }
69 69
 
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
  * @since 1.6.22
84 84
  * @return mixed
85 85
  */
86
-function geodir_save_map_cache($map_json){
86
+function geodir_save_map_cache($map_json) {
87 87
 
88 88
     // if a search is going on then dont even try to check for cache.
89
-    if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){
89
+    if (isset($_REQUEST['search']) && !empty($_REQUEST['search'])) {
90 90
         return $map_json;
91 91
     }
92 92
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
     $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : '';
106 106
     $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : '';
107 107
 
108
-    $file_name = sanitize_file_name( md5( implode("-",$url_params) )  );
108
+    $file_name = sanitize_file_name(md5(implode("-", $url_params)));
109 109
 
110 110
     $blog_id = get_current_blog_id();
111
-    if($blog_id>1){
111
+    if ($blog_id > 1) {
112 112
         $file_name = $blog_id."_".$file_name;
113 113
     }
114 114
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
     global $wp_filesystem;
119 119
     if (empty($wp_filesystem)) {
120
-        require_once (ABSPATH . '/wp-admin/includes/file.php');
120
+        require_once (ABSPATH.'/wp-admin/includes/file.php');
121 121
         WP_Filesystem();
122 122
     }
123 123
     $wp_filesystem->put_contents(
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     $gd_session->set('homemap_catlist_ptype', $gd_post_type);
139 139
     $post_taxonomy = geodir_get_taxonomies($gd_post_type);
140 140
     $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
141
-    $child_collapse = (bool)$_REQUEST['child_collapse'];
141
+    $child_collapse = (bool) $_REQUEST['child_collapse'];
142 142
     echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
143 143
     die;
144 144
 }
@@ -158,21 +158,21 @@  discard block
 block discarded – undo
158 158
     global $wpdb, $plugin_prefix, $gd_session;
159 159
 
160 160
     if ($_REQUEST['m_id'] != '') {
161
-        $pid = (int)$_REQUEST['m_id'];
161
+        $pid = (int) $_REQUEST['m_id'];
162 162
     } else {
163 163
         echo __('No marker data found', 'geodirectory');
164 164
         exit;
165 165
     }
166 166
 
167 167
     if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
168
-        $post = (object)$gd_ses_listing;
168
+        $post = (object) $gd_ses_listing;
169 169
         echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
170 170
     } else {
171 171
         $geodir_post_type = get_post_type($pid);
172 172
 
173
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
173
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
174 174
 
175
-        $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
175
+        $sql = $wpdb->prepare("SELECT * FROM ".$table." WHERE post_id = %d", array($pid));
176 176
 
177 177
         $postinfo = $wpdb->get_results($sql);
178 178
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
  */
207 207
 function get_markers() {
208 208
     
209
-    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session;
209
+    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes, $gd_session;
210 210
 
211 211
 
212 212
     /**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
      *
215 215
      * @since 1.6.22
216 216
      */
217
-    $map_cache = apply_filters('geodir_get_markers_cache','');
218
-    if($map_cache){
217
+    $map_cache = apply_filters('geodir_get_markers_cache', '');
218
+    if ($map_cache) {
219 219
         return $map_cache;
220 220
         wp_die();
221 221
     }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
231 231
 
232 232
     $map_cat_ids_array = array('0');
233
-    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
233
+    $cat_find_array = array(" FIND_IN_SET(%d, pd.".$post_type."category)");
234 234
 
235 235
 
236 236
     $field_default_cat = '';
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
         $map_cat_arr = trim($_REQUEST['cat_id'], ',');
239 239
 
240 240
         if (!empty($map_cat_arr)) {
241
-            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
241
+            $field_default_cat .= "WHEN (default_category IN (".$map_cat_arr.")) THEN default_category ";
242 242
 
243 243
             $map_cat_ids_array = explode(',', $map_cat_arr);
244 244
             $cat_find_array = array();
245 245
             foreach ($map_cat_ids_array as $cat_id) {
246
-                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
247
-                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
246
+                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `".$post_type."category`) > 0) THEN $cat_id ";
247
+                $cat_find_array[] = " FIND_IN_SET(%d, pd.".$post_type."category)";
248 248
                 $main_query_array[] = $cat_id;
249 249
             }
250 250
 
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
         $field_default_cat = '';
256 256
 
257 257
     if (!empty($cat_find_array))
258
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
258
+        $search .= "AND (".implode(' OR ', $cat_find_array).")";
259 259
 
260 260
     $main_query_array = $map_cat_ids_array;
261 261
   
262 262
     if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
263 263
         $search .= " AND p.post_title LIKE %s";
264
-        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
264
+        $main_query_array[] = "%".$_REQUEST['search']."%";
265 265
     }
266 266
 
267 267
     /**
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
 
284 284
     $gd_posttype = '';
285 285
     if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
286
-        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
286
+        $table = $plugin_prefix.$_REQUEST['gd_posttype'].'_detail';
287 287
         $gd_posttype = " AND p.post_type = %s";
288 288
         $main_query_array[] = $_REQUEST['gd_posttype'];
289 289
 
290 290
     } else
291
-        $table = $plugin_prefix . 'gd_place_detail';
291
+        $table = $plugin_prefix.'gd_place_detail';
292 292
 
293
-    $join = ", " . $table . " AS pd ";
293
+    $join = ", ".$table." AS pd ";
294 294
 
295 295
     /**
296 296
 	 * Filter the SQL JOIN clause for the markers data
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	$search = apply_filters('geodir_home_map_listing_where', $search);
312 312
     $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
313
-    $cat_type = $post_type . 'category';
313
+    $cat_type = $post_type.'category';
314 314
     if ($post_type == 'gd_event') {
315 315
         $event_select = ", pd.recurring_dates, pd.is_recurring";
316 316
     } else {
317 317
         $event_select = "";
318 318
     }
319 319
 
320
-    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
320
+    $sql_select = 'SELECT pd.default_category, pd.'.$cat_type.', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude'.$event_select;
321 321
     /**
322 322
 	 * Filter the SQL SELECT clause to retrive fields data
323 323
 	 *
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	$groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
339 339
 
340
-    $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array);
340
+    $catsql = $wpdb->prepare("$select $field_default_cat FROM ".$wpdb->posts." as p".$join." WHERE p.ID = pd.post_id AND p.post_status = 'publish' ".$search.$gd_posttype.$groupby, $main_query_array);
341 341
     
342 342
 	/**
343 343
 	 * Filter the SQL query to retrive markers data
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
388 388
 
389 389
         $today = strtotime(date_i18n('Y-m-d'));
390
-        $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
390
+        $show_dates = $post_type == 'gd_event' ? (int) get_option('geodir_event_infowindow_dates_count', 1) : 0;
391 391
         
392 392
         foreach ($catinfo as $catinfo_obj) {
393 393
             $post_title = $catinfo_obj->post_title;
@@ -403,29 +403,29 @@  discard block
 block discarded – undo
403 403
                     $endtimes = '';
404 404
                     $astarttimes = array();
405 405
                     $aendtimes = array();
406
-                    if ( !isset( $recurring_data['repeat_type'] ) ) {
406
+                    if (!isset($recurring_data['repeat_type'])) {
407 407
                         $recurring_data['repeat_type'] = 'custom';
408 408
                     }
409
-                    $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
410
-                    $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
409
+                    $repeat_type = isset($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom
410
+                    $different_times = isset($recurring_data['different_times']) && !empty($recurring_data['different_times']) ? true : false;
411 411
         
412 412
                     $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
413 413
                     
414
-                    if ( !empty( $recurring_dates ) ) {
415
-                        if ( empty( $recurring_data['all_day'] ) ) {
416
-                            if ( $repeat_type == 'custom' && $different_times ) {
417
-                                $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
418
-                                $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
414
+                    if (!empty($recurring_dates)) {
415
+                        if (empty($recurring_data['all_day'])) {
416
+                            if ($repeat_type == 'custom' && $different_times) {
417
+                                $astarttimes = isset($recurring_data['starttimes']) ? $recurring_data['starttimes'] : array();
418
+                                $aendtimes = isset($recurring_data['endtimes']) ? $recurring_data['endtimes'] : array();
419 419
                             } else {
420
-                                $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
421
-                                $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
420
+                                $starttimes = isset($recurring_data['starttime']) ? $recurring_data['starttime'] : '';
421
+                                $endtimes = isset($recurring_data['endtime']) ? $recurring_data['endtime'] : '';
422 422
                             }
423 423
                         }
424 424
                         
425 425
                         $e = 0;
426
-                        foreach( $recurring_dates as $key => $date ) {
427
-                            if ( $repeat_type == 'custom' && $different_times ) {
428
-                                if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
426
+                        foreach ($recurring_dates as $key => $date) {
427
+                            if ($repeat_type == 'custom' && $different_times) {
428
+                                if (!empty($astarttimes) && isset($astarttimes[$key])) {
429 429
                                     $starttimes = $astarttimes[$key];
430 430
                                     $endtimes = $aendtimes[$key];
431 431
                                 } else {
@@ -434,50 +434,50 @@  discard block
 block discarded – undo
434 434
                                 }
435 435
                             }
436 436
                             
437
-                            $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
437
+                            $duration = isset($recurring_data['duration_x']) && (int) $recurring_data['duration_x'] > 0 ? (int) $recurring_data['duration_x'] : 1;
438 438
                             $duration--;
439
-                            $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
439
+                            $enddate = date_i18n('Y-m-d', strtotime($date.' + '.$duration.' day'));
440 440
                             
441 441
                             // Hide past dates
442
-                            if ( strtotime( $enddate ) < $today ) {
442
+                            if (strtotime($enddate) < $today) {
443 443
                                 continue;
444 444
                             }
445 445
                                     
446
-                            $sdate = strtotime( $date . ' ' . $starttimes );
447
-                            $edate = strtotime( $enddate . ' ' . $endtimes );
446
+                            $sdate = strtotime($date.' '.$starttimes);
447
+                            $edate = strtotime($enddate.' '.$endtimes);
448 448
                                         
449
-                            $start_date = date_i18n( $geodir_date_time_format, $sdate );
450
-                            $end_date = date_i18n( $geodir_date_time_format, $edate );
449
+                            $start_date = date_i18n($geodir_date_time_format, $sdate);
450
+                            $end_date = date_i18n($geodir_date_time_format, $edate);
451 451
                             
452 452
                             $same_day = false;
453 453
                             $full_day = false;
454 454
                             $same_datetime = false;
455 455
                             
456
-                            if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
456
+                            if ($starttimes == $endtimes && ($starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00')) {
457 457
                                 $full_day = true;
458 458
                             }
459 459
                             
460
-                            if ( $start_date == $end_date && $full_day ) {
460
+                            if ($start_date == $end_date && $full_day) {
461 461
                                 $same_datetime = true;
462 462
                             }
463 463
 
464
-                            $link_date = date_i18n( 'Y-m-d', $sdate );
465
-                            $title_date = date_i18n( $geodir_date_format, $sdate );
466
-                            if ( $full_day ) {
464
+                            $link_date = date_i18n('Y-m-d', $sdate);
465
+                            $title_date = date_i18n($geodir_date_format, $sdate);
466
+                            if ($full_day) {
467 467
                                 $start_date = $title_date;
468
-                                $end_date = date_i18n( $geodir_date_format, $edate );
468
+                                $end_date = date_i18n($geodir_date_format, $edate);
469 469
                             }
470 470
                             
471
-                            if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
471
+                            if (!$same_datetime && !$full_day && date_i18n('Y-m-d', $sdate) == date_i18n('Y-m-d', $edate)) {
472 472
                                 $same_day = true;
473 473
                                 
474
-                                $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
474
+                                $start_date .= ' - '.date_i18n($geodir_time_format, $edate);
475 475
                             }
476 476
                             
477
-                            $event_dates .= ' :: ' . $start_date;
477
+                            $event_dates .= ' :: '.$start_date;
478 478
                         
479
-                            if ( !$same_day && !$same_datetime ) {
480
-                                $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
479
+                            if (!$same_day && !$same_datetime) {
480
+                                $event_dates .= ' '.__('to', 'geodirectory').' '.$end_date;
481 481
                             }
482 482
                             
483 483
                             $e++;
@@ -488,67 +488,67 @@  discard block
 block discarded – undo
488 488
                         }
489 489
                     }
490 490
                 } else {
491
-                    $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
492
-                    $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
493
-                    $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
494
-                    $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
495
-                    $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
491
+                    $start_date = isset($recurring_data['event_start']) ? $recurring_data['event_start'] : '';
492
+                    $end_date = isset($recurring_data['event_end']) ? $recurring_data['event_end'] : $start_date;
493
+                    $all_day = isset($recurring_data['all_day']) && !empty($recurring_data['all_day']) ? true : false;
494
+                    $starttime = isset($recurring_data['starttime']) ? $recurring_data['starttime'] : '';
495
+                    $endtime = isset($recurring_data['endtime']) ? $recurring_data['endtime'] : '';
496 496
                 
497
-                    $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
498
-                    $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
499
-                    $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
497
+                    $event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
498
+                    $starttimes = isset($recurring_data['starttimes']) && !empty($recurring_data['starttimes']) ? $recurring_data['starttimes'] : array();
499
+                    $endtimes = isset($recurring_data['endtimes']) && !empty($recurring_data['endtimes']) ? $recurring_data['endtimes'] : array();
500 500
                     
501
-                    if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
501
+                    if (!geodir_event_is_date($start_date) && !empty($event_recurring_dates)) {
502 502
                         $start_date = $event_recurring_dates[0];
503 503
                     }
504 504
                                 
505
-                    if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
505
+                    if (strtotime($end_date) < strtotime($start_date)) {
506 506
                         $end_date = $start_date;
507 507
                     }
508 508
                     
509 509
                     if ($end_date != '' && strtotime($end_date) >= $today) {
510
-                        if ( $starttime == '' && !empty( $starttimes ) ) {
510
+                        if ($starttime == '' && !empty($starttimes)) {
511 511
                             $starttime = $starttimes[0];
512 512
                             $endtime = $endtimes[0];
513 513
                         }
514 514
                         
515 515
                         $same_day = false;
516 516
                         $one_day = false;
517
-                        if ( $start_date == $end_date && $all_day ) {
517
+                        if ($start_date == $end_date && $all_day) {
518 518
                             $one_day = true;
519 519
                         }
520 520
 
521
-                        if ( $all_day ) {
522
-                            $start_datetime = strtotime( $start_date );
523
-                            $end_datetime = strtotime( $end_date );
521
+                        if ($all_day) {
522
+                            $start_datetime = strtotime($start_date);
523
+                            $end_datetime = strtotime($end_date);
524 524
                             
525
-                            $start_date = date_i18n( $geodir_date_format, $start_datetime );
526
-                            $end_date = date_i18n( $geodir_date_format, $end_datetime );
527
-                            if ( $start_date == $end_date ) {
525
+                            $start_date = date_i18n($geodir_date_format, $start_datetime);
526
+                            $end_date = date_i18n($geodir_date_format, $end_datetime);
527
+                            if ($start_date == $end_date) {
528 528
                                 $one_day = true;
529 529
                             }
530 530
                         } else {
531
-                            if ( $start_date == $end_date && $starttime == $endtime ) {
532
-                                $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
531
+                            if ($start_date == $end_date && $starttime == $endtime) {
532
+                                $end_date = date_i18n('Y-m-d', strtotime($start_date.' '.$starttime.' +1 day'));
533 533
                                 $one_day = false;
534 534
                             }
535
-                            $start_datetime = strtotime( $start_date . ' ' . $starttime );
536
-                            $end_datetime = strtotime( $end_date . ' ' . $endtime );
535
+                            $start_datetime = strtotime($start_date.' '.$starttime);
536
+                            $end_datetime = strtotime($end_date.' '.$endtime);
537 537
                             
538
-                            $start_date = date_i18n( $geodir_date_time_format, $start_datetime );
539
-                            $end_date = date_i18n( $geodir_date_time_format, $end_datetime );
538
+                            $start_date = date_i18n($geodir_date_time_format, $start_datetime);
539
+                            $end_date = date_i18n($geodir_date_time_format, $end_datetime);
540 540
                         }
541 541
 
542
-                        if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
542
+                        if (!$one_day && date_i18n('Y-m-d', $start_datetime) == date_i18n('Y-m-d', $end_datetime)) {
543 543
                             $same_day = true;
544 544
                             
545
-                            $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
545
+                            $start_date .= ' - '.date_i18n($geodir_time_format, $end_datetime);
546 546
                         }
547 547
                         
548
-                        $event_dates .= ' :: ' . $start_date;
548
+                        $event_dates .= ' :: '.$start_date;
549 549
                         
550
-                        if ( !$same_day && !$one_day ) {
551
-                            $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
550
+                        if (!$same_day && !$one_day) {
551
+                            $event_dates .= ' '.__('to', 'geodirectory').' '.$end_date;
552 552
                         }
553 553
                     }
554 554
                 }
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
             $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
565 565
 
566 566
             // if single cat lets just show that icon
567
-            if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
568
-                $default_cat = (int)$map_cat_ids_array[0];
567
+            if (is_array($map_cat_ids_array) && count($map_cat_ids_array) == 1) {
568
+                $default_cat = (int) $map_cat_ids_array[0];
569 569
             }
570 570
 
571 571
             $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                 $icon_size = array('w' => 36, 'h' => 45);
586 586
             }
587 587
 
588
-            $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}';
588
+            $content_data[] = '{"id":"'.$catinfo_obj->post_id.'","t": "'.$title.'","lt": "'.$catinfo_obj->post_latitude.'","ln": "'.$catinfo_obj->post_longitude.'","mk_id":"'.$catinfo_obj->post_id.'_'.$default_cat.'","i":"'.$icon.'","w":"'.$icon_size['w'].'","h":"'.$icon_size['h'].'"'.$mark_extra.'}';
589 589
             $post_ids[] = $catinfo_obj->post_id;
590 590
         }
591 591
     }
@@ -609,10 +609,10 @@  discard block
 block discarded – undo
609 609
     $totalcount = count(array_unique($post_ids));
610 610
 
611 611
     if (!empty($cat_content_info)) {
612
-        $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
612
+        $map_json = '[{"totalcount":"'.$totalcount.'",'.substr(implode(',', $cat_content_info), 1).']';
613 613
     }
614 614
     else {
615
-        $map_json =  '[{"totalcount":"0"}]';
615
+        $map_json = '[{"totalcount":"0"}]';
616 616
     }
617 617
 
618 618
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
      * @since 1.6.22
623 623
      * @param string $map_json The JSON string of the map markers results.
624 624
      */
625
-    return apply_filters('geodir_markers_json',$map_json);
625
+    return apply_filters('geodir_markers_json', $map_json);
626 626
 }
627 627
 
628 628
 
Please login to merge, or discard this patch.