Test Failed
Push — master ( 3e14b5...dec562 )
by Stiofan
30:21 queued 13:35
created
geodirectory-functions/map-functions/get_markers.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     $gd_session->set('homemap_catlist_ptype', $gd_post_type);
13 13
     $post_taxonomy = geodir_get_taxonomies($gd_post_type);
14 14
     $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']);
15
-    $child_collapse = (bool)$_REQUEST['child_collapse'];
15
+    $child_collapse = (bool) $_REQUEST['child_collapse'];
16 16
     echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true);
17 17
     die;
18 18
 }
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
     global $wpdb, $plugin_prefix, $gd_session;
33 33
 
34 34
     if ($_REQUEST['m_id'] != '') {
35
-        $pid = (int)$_REQUEST['m_id'];
35
+        $pid = (int) $_REQUEST['m_id'];
36 36
     } else {
37 37
         echo __('No marker data found', 'geodirectory');
38 38
         exit;
39 39
     }
40 40
 
41 41
     if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) {
42
-        $post = (object)$gd_ses_listing;
42
+        $post = (object) $gd_ses_listing;
43 43
         echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']);
44 44
     } else {
45 45
         $geodir_post_type = get_post_type($pid);
46 46
 
47
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
47
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
48 48
 
49
-        $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid));
49
+        $sql = $wpdb->prepare("SELECT * FROM ".$table." WHERE post_id = %d", array($pid));
50 50
 
51 51
         $postinfo = $wpdb->get_results($sql);
52 52
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  */
81 81
 function get_markers() {
82 82
 
83
-    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session;
83
+    global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes, $gd_session;
84 84
 
85 85
     $search = '';
86 86
     $main_query_array;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
92 92
 
93 93
     $map_cat_ids_array = array('0');
94
-    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
94
+    $cat_find_array = array(" FIND_IN_SET(%d, pd.".$post_type."category)");
95 95
 
96 96
 
97 97
     $field_default_cat = '';
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
         $map_cat_arr = trim($_REQUEST['cat_id'], ',');
100 100
 
101 101
         if (!empty($map_cat_arr)) {
102
-            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
102
+            $field_default_cat .= "WHEN (default_category IN (".$map_cat_arr.")) THEN default_category ";
103 103
 
104 104
             $map_cat_ids_array = explode(',', $map_cat_arr);
105 105
             $cat_find_array = array();
106 106
             foreach ($map_cat_ids_array as $cat_id) {
107
-                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id ";
108
-                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
107
+                $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `".$post_type."category`) > 0) THEN $cat_id ";
108
+                $cat_find_array[] = " FIND_IN_SET(%d, pd.".$post_type."category)";
109 109
                 $main_query_array[] = $cat_id;
110 110
             }
111 111
 
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
         $field_default_cat = '';
117 117
 
118 118
     if (!empty($cat_find_array))
119
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
119
+        $search .= "AND (".implode(' OR ', $cat_find_array).")";
120 120
 
121 121
     $main_query_array = $map_cat_ids_array;
122 122
   
123 123
     if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
124 124
         $search .= " AND p.post_title LIKE %s";
125
-        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
125
+        $main_query_array[] = "%".$_REQUEST['search']."%";
126 126
     }
127 127
 
128 128
     /**
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 
145 145
     $gd_posttype = '';
146 146
     if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
147
-        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
147
+        $table = $plugin_prefix.$_REQUEST['gd_posttype'].'_detail';
148 148
         $gd_posttype = " AND p.post_type = %s";
149 149
         $main_query_array[] = $_REQUEST['gd_posttype'];
150 150
 
151 151
     } else
152
-        $table = $plugin_prefix . 'gd_place_detail';
152
+        $table = $plugin_prefix.'gd_place_detail';
153 153
 
154
-    $join = ", " . $table . " AS pd ";
154
+    $join = ", ".$table." AS pd ";
155 155
 
156 156
     /**
157 157
 	 * Filter the SQL JOIN clause for the markers data
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	$search = apply_filters('geodir_home_map_listing_where', $search);
173 173
     $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
174
-    $cat_type = $post_type . 'category';
174
+    $cat_type = $post_type.'category';
175 175
     if ($post_type == 'gd_event') {
176 176
         $event_select = ", pd.recurring_dates, pd.is_recurring";
177 177
     } else {
178 178
         $event_select = "";
179 179
     }
180 180
 
181
-    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
181
+    $sql_select = 'SELECT pd.default_category, pd.'.$cat_type.', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude'.$event_select;
182 182
     /**
183 183
 	 * Filter the SQL SELECT clause to retrive fields data
184 184
 	 *
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	$groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
200 200
 
201
-    $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);
201
+    $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);
202 202
     
203 203
 	/**
204 204
 	 * Filter the SQL query to retrive markers data
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         global $geodir_date_time_format, $geodir_date_format, $geodir_time_format;
249 249
 
250 250
         $today = strtotime(date_i18n('Y-m-d'));
251
-        $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0;
251
+        $show_dates = $post_type == 'gd_event' ? (int) get_option('geodir_event_infowindow_dates_count', 1) : 0;
252 252
         
253 253
         foreach ($catinfo as $catinfo_obj) {
254 254
             $post_title = $catinfo_obj->post_title;
@@ -264,29 +264,29 @@  discard block
 block discarded – undo
264 264
                     $endtimes = '';
265 265
                     $astarttimes = array();
266 266
                     $aendtimes = array();
267
-                    if ( !isset( $recurring_data['repeat_type'] ) ) {
267
+                    if (!isset($recurring_data['repeat_type'])) {
268 268
                         $recurring_data['repeat_type'] = 'custom';
269 269
                     }
270
-                    $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
271
-                    $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false;
270
+                    $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
271
+                    $different_times = isset($recurring_data['different_times']) && !empty($recurring_data['different_times']) ? true : false;
272 272
         
273 273
                     $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
274 274
                     
275
-                    if ( !empty( $recurring_dates ) ) {
276
-                        if ( empty( $recurring_data['all_day'] ) ) {
277
-                            if ( $repeat_type == 'custom' && $different_times ) {
278
-                                $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
279
-                                $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
275
+                    if (!empty($recurring_dates)) {
276
+                        if (empty($recurring_data['all_day'])) {
277
+                            if ($repeat_type == 'custom' && $different_times) {
278
+                                $astarttimes = isset($recurring_data['starttimes']) ? $recurring_data['starttimes'] : array();
279
+                                $aendtimes = isset($recurring_data['endtimes']) ? $recurring_data['endtimes'] : array();
280 280
                             } else {
281
-                                $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
282
-                                $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
281
+                                $starttimes = isset($recurring_data['starttime']) ? $recurring_data['starttime'] : '';
282
+                                $endtimes = isset($recurring_data['endtime']) ? $recurring_data['endtime'] : '';
283 283
                             }
284 284
                         }
285 285
                         
286 286
                         $e = 0;
287
-                        foreach( $recurring_dates as $key => $date ) {
288
-                            if ( $repeat_type == 'custom' && $different_times ) {
289
-                                if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) {
287
+                        foreach ($recurring_dates as $key => $date) {
288
+                            if ($repeat_type == 'custom' && $different_times) {
289
+                                if (!empty($astarttimes) && isset($astarttimes[$key])) {
290 290
                                     $starttimes = $astarttimes[$key];
291 291
                                     $endtimes = $aendtimes[$key];
292 292
                                 } else {
@@ -295,50 +295,50 @@  discard block
 block discarded – undo
295 295
                                 }
296 296
                             }
297 297
                             
298
-                            $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1;
298
+                            $duration = isset($recurring_data['duration_x']) && (int) $recurring_data['duration_x'] > 0 ? (int) $recurring_data['duration_x'] : 1;
299 299
                             $duration--;
300
-                            $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) );
300
+                            $enddate = date_i18n('Y-m-d', strtotime($date.' + '.$duration.' day'));
301 301
                             
302 302
                             // Hide past dates
303
-                            if ( strtotime( $enddate ) < $today ) {
303
+                            if (strtotime($enddate) < $today) {
304 304
                                 continue;
305 305
                             }
306 306
                                     
307
-                            $sdate = strtotime( $date . ' ' . $starttimes );
308
-                            $edate = strtotime( $enddate . ' ' . $endtimes );
307
+                            $sdate = strtotime($date.' '.$starttimes);
308
+                            $edate = strtotime($enddate.' '.$endtimes);
309 309
                                         
310
-                            $start_date = date_i18n( $geodir_date_time_format, $sdate );
311
-                            $end_date = date_i18n( $geodir_date_time_format, $edate );
310
+                            $start_date = date_i18n($geodir_date_time_format, $sdate);
311
+                            $end_date = date_i18n($geodir_date_time_format, $edate);
312 312
                             
313 313
                             $same_day = false;
314 314
                             $full_day = false;
315 315
                             $same_datetime = false;
316 316
                             
317
-                            if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) {
317
+                            if ($starttimes == $endtimes && ($starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00')) {
318 318
                                 $full_day = true;
319 319
                             }
320 320
                             
321
-                            if ( $start_date == $end_date && $full_day ) {
321
+                            if ($start_date == $end_date && $full_day) {
322 322
                                 $same_datetime = true;
323 323
                             }
324 324
 
325
-                            $link_date = date_i18n( 'Y-m-d', $sdate );
326
-                            $title_date = date_i18n( $geodir_date_format, $sdate );
327
-                            if ( $full_day ) {
325
+                            $link_date = date_i18n('Y-m-d', $sdate);
326
+                            $title_date = date_i18n($geodir_date_format, $sdate);
327
+                            if ($full_day) {
328 328
                                 $start_date = $title_date;
329
-                                $end_date = date_i18n( $geodir_date_format, $edate );
329
+                                $end_date = date_i18n($geodir_date_format, $edate);
330 330
                             }
331 331
                             
332
-                            if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) {
332
+                            if (!$same_datetime && !$full_day && date_i18n('Y-m-d', $sdate) == date_i18n('Y-m-d', $edate)) {
333 333
                                 $same_day = true;
334 334
                                 
335
-                                $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate );
335
+                                $start_date .= ' - '.date_i18n($geodir_time_format, $edate);
336 336
                             }
337 337
                             
338
-                            $event_dates .= ' :: ' . $start_date;
338
+                            $event_dates .= ' :: '.$start_date;
339 339
                         
340
-                            if ( !$same_day && !$same_datetime ) {
341
-                                $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
340
+                            if (!$same_day && !$same_datetime) {
341
+                                $event_dates .= ' '.__('to', 'geodirectory').' '.$end_date;
342 342
                             }
343 343
                             
344 344
                             $e++;
@@ -349,67 +349,67 @@  discard block
 block discarded – undo
349 349
                         }
350 350
                     }
351 351
                 } else {
352
-                    $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : '';
353
-                    $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date;
354
-                    $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false;
355
-                    $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : '';
356
-                    $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : '';
352
+                    $start_date = isset($recurring_data['event_start']) ? $recurring_data['event_start'] : '';
353
+                    $end_date = isset($recurring_data['event_end']) ? $recurring_data['event_end'] : $start_date;
354
+                    $all_day = isset($recurring_data['all_day']) && !empty($recurring_data['all_day']) ? true : false;
355
+                    $starttime = isset($recurring_data['starttime']) ? $recurring_data['starttime'] : '';
356
+                    $endtime = isset($recurring_data['endtime']) ? $recurring_data['endtime'] : '';
357 357
                 
358
-                    $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
359
-                    $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array();
360
-                    $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array();
358
+                    $event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
359
+                    $starttimes = isset($recurring_data['starttimes']) && !empty($recurring_data['starttimes']) ? $recurring_data['starttimes'] : array();
360
+                    $endtimes = isset($recurring_data['endtimes']) && !empty($recurring_data['endtimes']) ? $recurring_data['endtimes'] : array();
361 361
                     
362
-                    if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) {
362
+                    if (!geodir_event_is_date($start_date) && !empty($event_recurring_dates)) {
363 363
                         $start_date = $event_recurring_dates[0];
364 364
                     }
365 365
                                 
366
-                    if ( strtotime( $end_date ) < strtotime( $start_date ) ) {
366
+                    if (strtotime($end_date) < strtotime($start_date)) {
367 367
                         $end_date = $start_date;
368 368
                     }
369 369
                     
370 370
                     if ($end_date != '' && strtotime($end_date) >= $today) {
371
-                        if ( $starttime == '' && !empty( $starttimes ) ) {
371
+                        if ($starttime == '' && !empty($starttimes)) {
372 372
                             $starttime = $starttimes[0];
373 373
                             $endtime = $endtimes[0];
374 374
                         }
375 375
                         
376 376
                         $same_day = false;
377 377
                         $one_day = false;
378
-                        if ( $start_date == $end_date && $all_day ) {
378
+                        if ($start_date == $end_date && $all_day) {
379 379
                             $one_day = true;
380 380
                         }
381 381
 
382
-                        if ( $all_day ) {
383
-                            $start_datetime = strtotime( $start_date );
384
-                            $end_datetime = strtotime( $end_date );
382
+                        if ($all_day) {
383
+                            $start_datetime = strtotime($start_date);
384
+                            $end_datetime = strtotime($end_date);
385 385
                             
386
-                            $start_date = date_i18n( $geodir_date_format, $start_datetime );
387
-                            $end_date = date_i18n( $geodir_date_format, $end_datetime );
388
-                            if ( $start_date == $end_date ) {
386
+                            $start_date = date_i18n($geodir_date_format, $start_datetime);
387
+                            $end_date = date_i18n($geodir_date_format, $end_datetime);
388
+                            if ($start_date == $end_date) {
389 389
                                 $one_day = true;
390 390
                             }
391 391
                         } else {
392
-                            if ( $start_date == $end_date && $starttime == $endtime ) {
393
-                                $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) );
392
+                            if ($start_date == $end_date && $starttime == $endtime) {
393
+                                $end_date = date_i18n('Y-m-d', strtotime($start_date.' '.$starttime.' +1 day'));
394 394
                                 $one_day = false;
395 395
                             }
396
-                            $start_datetime = strtotime( $start_date . ' ' . $starttime );
397
-                            $end_datetime = strtotime( $end_date . ' ' . $endtime );
396
+                            $start_datetime = strtotime($start_date.' '.$starttime);
397
+                            $end_datetime = strtotime($end_date.' '.$endtime);
398 398
                             
399
-                            $start_date = date_i18n( $geodir_date_time_format, $start_datetime );
400
-                            $end_date = date_i18n( $geodir_date_time_format, $end_datetime );
399
+                            $start_date = date_i18n($geodir_date_time_format, $start_datetime);
400
+                            $end_date = date_i18n($geodir_date_time_format, $end_datetime);
401 401
                         }
402 402
 
403
-                        if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) {
403
+                        if (!$one_day && date_i18n('Y-m-d', $start_datetime) == date_i18n('Y-m-d', $end_datetime)) {
404 404
                             $same_day = true;
405 405
                             
406
-                            $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime );
406
+                            $start_date .= ' - '.date_i18n($geodir_time_format, $end_datetime);
407 407
                         }
408 408
                         
409
-                        $event_dates .= ' :: ' . $start_date;
409
+                        $event_dates .= ' :: '.$start_date;
410 410
                         
411
-                        if ( !$same_day && !$one_day ) {
412
-                            $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date;
411
+                        if (!$same_day && !$one_day) {
412
+                            $event_dates .= ' '.__('to', 'geodirectory').' '.$end_date;
413 413
                         }
414 414
                     }
415 415
                 }
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
             $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : '';
426 426
 
427 427
             // if single cat lets just show that icon
428
-            if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){
429
-                $default_cat = (int)$map_cat_ids_array[0];
428
+            if (is_array($map_cat_ids_array) && count($map_cat_ids_array) == 1) {
429
+                $default_cat = (int) $map_cat_ids_array[0];
430 430
             }
431 431
 
432 432
             $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : '';
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
                 $icon_size = array('w' => 36, 'h' => 45);
447 447
             }
448 448
 
449
-            $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.'}';
449
+            $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.'}';
450 450
             $post_ids[] = $catinfo_obj->post_id;
451 451
         }
452 452
     }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     $totalcount = count(array_unique($post_ids));
471 471
 
472 472
     if (!empty($cat_content_info)) {
473
-        return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
473
+        return '[{"totalcount":"'.$totalcount.'",'.substr(implode(',', $cat_content_info), 1).']';
474 474
     }
475 475
     else {
476 476
         return '[{"totalcount":"0"}]';
Please login to merge, or discard this patch.