Test Setup Failed
Pull Request — master (#454)
by Kiran
29:40
created
geodirectory-functions/map-functions/get_markers.php 1 patch
Spacing   +104 added lines, -104 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,29 +43,29 @@  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
-    $file = $file_path . $file_name . ".json";
54
+    $file = $file_path.$file_name.".json";
55 55
 
56
-    if(file_exists($file)){
56
+    if (file_exists($file)) {
57 57
         // do the cache delete stuff
58 58
         $cache_time = get_option('geodir_map_cache');
59
-        if(!$cache_time){
59
+        if (!$cache_time) {
60 60
             $cache_time = time();
61 61
             update_option('geodir_map_cache', $cache_time);
62 62
         }
63 63
 
64
-        if((time() - $cache_time) > 86400){ // delete the cache every 24 hours
64
+        if ((time() - $cache_time) > 86400) { // delete the cache every 24 hours
65 65
             geodir_delete_map_cache();
66 66
         }
67 67
 
68
-        if(file_exists($file) && is_readable($file)){
68
+        if (file_exists($file) && is_readable($file)) {
69 69
             ob_start();
70 70
             readfile($file); // readfile is quicker then file get contents
71 71
             return ob_get_clean();
@@ -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.
geodirectory-functions/compatibility/Genesis.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@
 block discarded – undo
142 142
 
143 143
     if ($remove_class) {
144 144
         $classes = array_diff($classes, array('content-sidebar', 'sidebar-content', 'content-sidebar-sidebar', 'sidebar-sidebar-content', 'sidebar-content-sidebar', 'full-width-content'));
145
-        if ( $new_class == 'content' ) {
145
+        if ($new_class == 'content') {
146 146
             $new_class = 'content-no-sidebar';
147 147
             $classes[] = 'full-width-content';
148 148
         }
Please login to merge, or discard this patch.
geodirectory-functions/user_functions.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
  * @global string $plugin_prefix Geodirectory plugin table prefix.
12 12
  * @return array User listing count for each post type.
13 13
  */
14
-function geodir_user_favourite_listing_count($user_id=false)
14
+function geodir_user_favourite_listing_count($user_id = false)
15 15
 {
16 16
     global $wpdb, $plugin_prefix, $current_user;
17 17
 
18
-    if(!$user_id){$user_id = $current_user->ID;}
19
-    if(!$user_id){return array();}
18
+    if (!$user_id) {$user_id = $current_user->ID; }
19
+    if (!$user_id) {return array(); }
20 20
 
21 21
     $site_id = '';
22
-    if ( is_multisite() ) {
22
+    if (is_multisite()) {
23 23
         $blog_id = get_current_blog_id();
24
-        if($blog_id && $blog_id!='1'){$site_id  = '_' . $blog_id ;}
24
+        if ($blog_id && $blog_id != '1') {$site_id = '_'.$blog_id; }
25 25
     }
26 26
 
27 27
     $user_favorites = geodir_get_user_favourites($user_id);
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 
30 30
     $user_listing = array();
31 31
     if (is_array($all_posts) && !empty($all_posts) && is_array($user_favorites) && !empty($user_favorites)) {
32
-        $user_favorites = "'" . implode("','", $user_favorites) . "'";
32
+        $user_favorites = "'".implode("','", $user_favorites)."'";
33 33
 
34 34
         foreach ($all_posts as $ptype) {
35
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE  post_type='" . $ptype . "' AND post_status = 'publish' AND ID IN (" . $user_favorites . ")");
35
+            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM ".$wpdb->prefix."posts WHERE  post_type='".$ptype."' AND post_status = 'publish' AND ID IN (".$user_favorites.")");
36 36
 
37 37
             if ($total_posts > 0) {
38 38
                 $user_listing[$ptype] = $total_posts;
@@ -49,22 +49,22 @@  discard block
 block discarded – undo
49 49
  * @since 1.5.9
50 50
  * @package GeoDirectory
51 51
  */
52
-function geodir_user_show_favourites( $user_id = '', $output_type = 'select' ) {
52
+function geodir_user_show_favourites($user_id = '', $output_type = 'select') {
53 53
     // My Favourites in Dashboard
54
-    $show_favorite_link_user_dashboard = get_option( 'geodir_favorite_link_user_dashboard' );
55
-    $user_favourite = geodir_user_favourite_listing_count( $user_id );
54
+    $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
55
+    $user_favourite = geodir_user_favourite_listing_count($user_id);
56 56
 
57
-    if ( ! empty( $show_favorite_link_user_dashboard ) && ! empty( $user_favourite ) ) {
57
+    if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
58 58
         $favourite_links = $output_type == 'link' ? array() : '';
59
-        $post_types = geodir_get_posttypes( 'object' );
59
+        $post_types = geodir_get_posttypes('object');
60 60
 
61
-        $author_link = get_author_posts_url( $user_id );
62
-        $author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true' ), false );
61
+        $author_link = get_author_posts_url($user_id);
62
+        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
63 63
 
64
-        foreach ( $post_types as $key => $postobj ) {
65
-            if ( in_array( $key, $show_favorite_link_user_dashboard ) && array_key_exists( $key, $user_favourite ) ) {
66
-                $name = __( $postobj->labels->name, 'geodirectory' );
67
-                $post_type_link = geodir_getlink( $author_link, array( 'stype' => $key, 'list' => 'favourite' ), false );
64
+        foreach ($post_types as $key => $postobj) {
65
+            if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
66
+                $name = __($postobj->labels->name, 'geodirectory');
67
+                $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
68 68
 
69 69
                 /**
70 70
                  * Filter favorite listing link.
@@ -74,54 +74,54 @@  discard block
 block discarded – undo
74 74
                  * @param string $key Favorite listing array key.
75 75
                  * @param int $current_user->ID Current user ID.
76 76
                  */
77
-                $post_type_link = apply_filters( 'geodir_dashboard_link_favorite_listing', $post_type_link, $key, $user_id );
77
+                $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $user_id);
78 78
 
79
-                if ( $output_type == 'select' ) {
79
+                if ($output_type == 'select') {
80 80
                     $selected = '';
81
-                    if ( isset( $_REQUEST['list'] ) && $_REQUEST['list'] == 'favourite' && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key && isset( $_REQUEST['geodir_dashbord'] ) ) {
81
+                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
82 82
                         $selected = 'selected="selected"';
83 83
                     }
84 84
 
85
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . $name . '</option>';
86
-                } elseif ( $output_type == 'link' ) {
87
-                    $favourite_links[] = '<a href="' . $post_type_link . '">' . $name . '</a>';
85
+                    $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.$name.'</option>';
86
+                } elseif ($output_type == 'link') {
87
+                    $favourite_links[] = '<a href="'.$post_type_link.'">'.$name.'</a>';
88 88
                 }
89 89
             }
90 90
         }
91 91
 
92
-        if ( ! empty( $favourite_links ) ) {
93
-            if ( $output_type == 'select' ) {
92
+        if (!empty($favourite_links)) {
93
+            if ($output_type == 'select') {
94 94
                 ?>
95 95
                 <li>
96
-                    <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr__( 'My Favorites', 'geodirectory' ); ?>">
97
-                        <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr( wp_sprintf( __( "%s's Favorites", 'geodirectory' ), geodir_get_client_name( $user_id ) ) ); ?></option>
96
+                    <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr__('My Favorites', 'geodirectory'); ?>">
97
+                        <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr(wp_sprintf(__("%s's Favorites", 'geodirectory'), geodir_get_client_name($user_id))); ?></option>
98 98
                         <?php echo $favourite_links; ?>
99 99
                     </select>
100 100
                 </li>
101 101
             <?php
102
-            } elseif ( $output_type == 'link' ) {
103
-                echo implode( " | ", $favourite_links );
102
+            } elseif ($output_type == 'link') {
103
+                echo implode(" | ", $favourite_links);
104 104
             }
105 105
         }
106 106
     }
107 107
 }
108 108
 
109
-function geodir_user_show_listings( $user_id = '', $output_type = 'select' ) {
110
-    $show_listing_link_user_dashboard = get_option( 'geodir_listing_link_user_dashboard' );
111
-    $user_listing = geodir_user_post_listing_count( $user_id );
109
+function geodir_user_show_listings($user_id = '', $output_type = 'select') {
110
+    $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
111
+    $user_listing = geodir_user_post_listing_count($user_id);
112 112
 
113
-    if ( ! empty( $show_listing_link_user_dashboard ) && ! empty( $user_listing ) ) {
113
+    if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
114 114
         $listing_links = $output_type == 'link' ? array() : '';
115 115
 
116
-        $post_types = geodir_get_posttypes( 'object' );
116
+        $post_types = geodir_get_posttypes('object');
117 117
 
118
-        $author_link = get_author_posts_url( $user_id );
119
-        $author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true' ), false );
118
+        $author_link = get_author_posts_url($user_id);
119
+        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
120 120
 
121
-        foreach ( $post_types as $key => $postobj ) {
122
-            if ( in_array( $key, $show_listing_link_user_dashboard ) && array_key_exists( $key, $user_listing ) ) {
123
-                $name = __( $postobj->labels->name, 'geodirectory' );
124
-                $listing_link = geodir_getlink( $author_link, array( 'stype' => $key ), false );
121
+        foreach ($post_types as $key => $postobj) {
122
+            if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
123
+                $name = __($postobj->labels->name, 'geodirectory');
124
+                $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
125 125
 
126 126
                 /**
127 127
                  * Filter my listing link.
@@ -131,32 +131,32 @@  discard block
 block discarded – undo
131 131
                  * @param string $key My listing array key.
132 132
                  * @param int $current_user->ID Current user ID.
133 133
                  */
134
-                $listing_link = apply_filters( 'geodir_dashboard_link_my_listing', $listing_link, $key, $user_id );
135
-                if ( $output_type == 'select' ) {
134
+                $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $user_id);
135
+                if ($output_type == 'select') {
136 136
                     $selected = '';
137
-                    if ( ! isset( $_REQUEST['list'] ) && isset( $_REQUEST['geodir_dashbord'] ) && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key ) {
137
+                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
138 138
                         $selected = 'selected="selected"';
139 139
                     }
140 140
 
141
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . $name . '</option>';
142
-                } elseif ( $output_type == 'link' ) {
143
-                    $listing_links[] = '<a href="' . $listing_link . '">' . $name . '</a>';
141
+                    $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.$name.'</option>';
142
+                } elseif ($output_type == 'link') {
143
+                    $listing_links[] = '<a href="'.$listing_link.'">'.$name.'</a>';
144 144
                 }
145 145
             }
146 146
         }
147 147
 
148
-        if ( ! empty( $listing_links ) ) {
149
-            if ( $output_type == 'select' ) {
148
+        if (!empty($listing_links)) {
149
+            if ($output_type == 'select') {
150 150
                 ?>
151 151
                 <li>
152
-                    <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr__( 'My Listings', 'geodirectory' ); ?>">
153
-                        <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr( wp_sprintf( __( "%s's Listings", 'geodirectory' ), geodir_get_client_name( $user_id ) ) ); ?></option>
152
+                    <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" data-placeholder="<?php echo esc_attr__('My Listings', 'geodirectory'); ?>">
153
+                        <option value="" disabled="disabled" selected="selected" style='display:none;'><?php echo esc_attr(wp_sprintf(__("%s's Listings", 'geodirectory'), geodir_get_client_name($user_id))); ?></option>
154 154
                         <?php echo $listing_links; ?>
155 155
                     </select>
156 156
                 </li>
157 157
             <?php
158
-            } elseif ( $output_type == 'link' ) {
159
-                echo implode( " | ", $listing_links );
158
+            } elseif ($output_type == 'link') {
159
+                echo implode(" | ", $listing_links);
160 160
             }
161 161
         }
162 162
     }
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
  * @since 1.6.24
170 170
  * @return mixed
171 171
  */
172
-function geodir_get_user_favourites($user_id=''){
173
-    if(!$user_id){$user_id = get_current_user_id();}
172
+function geodir_get_user_favourites($user_id = '') {
173
+    if (!$user_id) {$user_id = get_current_user_id(); }
174 174
     $site_id = '';
175
-    if ( is_multisite() ) {
175
+    if (is_multisite()) {
176 176
         $blog_id = get_current_blog_id();
177
-        if($blog_id && $blog_id!='1'){$site_id  = '_' . $blog_id ;}
177
+        if ($blog_id && $blog_id != '1') {$site_id = '_'.$blog_id; }
178 178
     }
179 179
 
180 180
     return get_user_meta($user_id, 'gd_user_favourite_post'.$site_id, true);
Please login to merge, or discard this patch.