Test Failed
Pull Request — master (#437)
by Kiran
22:03
created
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("′", "⁄", "–", "“", '');
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("′", "⁄", "–", "“", '');
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("'", "/", "-", '"', '\\', ''');
228
-    $replarr = array("′", "⁄", "–", "“", '', "′");
227
+	$srcharr = array("'", "/", "-", '"', '\\', ''');
228
+	$replarr = array("′", "⁄", "–", "“", '', "′");
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.