Test Failed
Push — master ( e72891...440de9 )
by Stiofan
25:52
created
geodirectory-functions/general_functions.php 1 patch
Braces   +272 added lines, -187 removed lines patch added patch discarded remove patch
@@ -30,8 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
     if (is_ssl()) :
32 32
         return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
-    else :
34
-        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
+    else {
34
+    	:
35
+        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
36
+    }
35 37
     endif;
36 38
 }
37 39
 
@@ -67,7 +69,9 @@  discard block
 block discarded – undo
67 69
 {
68 70
     $active_plugins = get_option('active_plugins');
69 71
     foreach ($active_plugins as $key => $active_plugin) {
70
-        if (strstr($active_plugin, $plugin)) return true;
72
+        if (strstr($active_plugin, $plugin)) {
73
+        	return true;
74
+        }
71 75
     }
72 76
     return false;
73 77
 }
@@ -118,12 +122,25 @@  discard block
 block discarded – undo
118 122
  */
119 123
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
120 124
 {
121
-    if ($use_existing_arguments) $params = $params + $_GET;
122
-    if (!$params) return $url;
125
+    if ($use_existing_arguments) {
126
+    	$params = $params + $_GET;
127
+    }
128
+    if (!$params) {
129
+    	return $url;
130
+    }
123 131
     $link = $url;
124
-    if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
-    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&'; //If there is no '&' at the END, add one.
126
-    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
132
+    if (strpos($link, '?') === false) {
133
+    	$link .= '?';
134
+    }
135
+    //If there is no '?' add one at the end
136
+    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) {
137
+    	$link .= '&';
138
+    }
139
+    //If there is no '&' at the END, add one.
140
+    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) {
141
+    	$link .= '&';
142
+    }
143
+    //If there is no '&' at the END, add one.
127 144
 
128 145
     $params_arr = array();
129 146
     foreach ($params as $key => $value) {
@@ -161,9 +178,10 @@  discard block
 block discarded – undo
161 178
         $add_listing_link = get_page_link(geodir_add_listing_page_id());
162 179
 
163 180
         return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
-    } else
165
-        return get_bloginfo('url');
166
-}
181
+    } else {
182
+            return get_bloginfo('url');
183
+    }
184
+    }
167 185
 
168 186
 /**
169 187
  * Get the current page URL.
@@ -268,24 +286,28 @@  discard block
 block discarded – undo
268 286
         case 'preview':
269 287
             if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270 288
                 && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
-            )
272
-                return true;
289
+            ) {
290
+                            return true;
291
+            }
273 292
             break;
274 293
         case 'listing-success':
275
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
-                return true;
294
+            if (is_page() && get_query_var('page_id') == geodir_success_page_id()) {
295
+                            return true;
296
+            }
277 297
             break;
278 298
         case 'detail':
279 299
             $post_type = get_query_var('post_type');
280 300
             if(is_array($post_type)){$post_type = reset($post_type);}
281
-            if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
-                return true;
301
+            if (is_single() && in_array($post_type, geodir_get_posttypes())) {
302
+                            return true;
303
+            }
283 304
             break;
284 305
         case 'pt':
285 306
             $post_type = get_query_var('post_type');
286 307
             if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
-                return true;
308
+            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) {
309
+                            return true;
310
+            }
289 311
 
290 312
             break;
291 313
         case 'listing':
@@ -296,23 +318,27 @@  discard block
 block discarded – undo
296 318
             }
297 319
             $post_type = get_query_var('post_type');
298 320
             if(is_array($post_type)){$post_type = reset($post_type);}
299
-            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
-                return true;
321
+            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) {
322
+                            return true;
323
+            }
301 324
 
302 325
             break;
303 326
         case 'home':
304 327
 
305
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
-                return true;
328
+            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) {
329
+                            return true;
330
+            }
307 331
 
308 332
             break;
309 333
         case 'location':
310
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
-                return true;
334
+            if (is_page() && get_query_var('page_id') == geodir_location_page_id()) {
335
+                            return true;
336
+            }
312 337
             break;
313 338
         case 'author':
314
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
-                return true;
339
+            if (is_author() && isset($_REQUEST['geodir_dashbord'])) {
340
+                            return true;
341
+            }
316 342
 			
317 343
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318 344
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
@@ -321,24 +347,29 @@  discard block
 block discarded – undo
321 347
 			}
322 348
             break;
323 349
         case 'search':
324
-            if (is_search() && isset($_REQUEST['geodir_search']))
325
-                return true;
350
+            if (is_search() && isset($_REQUEST['geodir_search'])) {
351
+                            return true;
352
+            }
326 353
             break;
327 354
         case 'info':
328
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
-                return true;
355
+            if (is_page() && get_query_var('page_id') == geodir_info_page_id()) {
356
+                            return true;
357
+            }
330 358
             break;
331 359
         case 'login':
332
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
-                return true;
360
+            if (is_page() && get_query_var('page_id') == geodir_login_page_id()) {
361
+                            return true;
362
+            }
334 363
             break;
335 364
         case 'checkout':
336
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
-                return true;
365
+            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) {
366
+                            return true;
367
+            }
338 368
             break;
339 369
         case 'invoices':
340
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
-                return true;
370
+            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) {
371
+                            return true;
372
+            }
342 373
             break;
343 374
         default:
344 375
             return false;
@@ -366,8 +397,9 @@  discard block
 block discarded – undo
366 397
         //$wp->query_vars['gd_is_geodir_page'] = false;
367 398
         //print_r()
368 399
         if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
-            if (get_option('geodir_set_as_home'))
370
-                $wp->query_vars['gd_is_geodir_page'] = true;
400
+            if (get_option('geodir_set_as_home')) {
401
+                            $wp->query_vars['gd_is_geodir_page'] = true;
402
+            }
371 403
             if(geodir_is_page('home')){
372 404
                 $wp->query_vars['gd_is_geodir_page'] = true;
373 405
             }
@@ -386,8 +418,9 @@  discard block
 block discarded – undo
386 418
                 || $wp->query_vars['page_id'] == geodir_login_page_id()
387 419
                 || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388 420
                 || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
-            )
390
-                $wp->query_vars['gd_is_geodir_page'] = true;
421
+            ) {
422
+                            $wp->query_vars['gd_is_geodir_page'] = true;
423
+            }
391 424
         }
392 425
 
393 426
         if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
@@ -404,8 +437,9 @@  discard block
 block discarded – undo
404 437
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405 438
                     || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406 439
                 )
407
-            )
408
-                $wp->query_vars['gd_is_geodir_page'] = true;
440
+            ) {
441
+                            $wp->query_vars['gd_is_geodir_page'] = true;
442
+            }
409 443
         }
410 444
 
411 445
 
@@ -431,12 +465,14 @@  discard block
 block discarded – undo
431 465
 
432 466
         }
433 467
 
434
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
-            $wp->query_vars['gd_is_geodir_page'] = true;
468
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) {
469
+                    $wp->query_vars['gd_is_geodir_page'] = true;
470
+        }
436 471
 
437 472
 
438
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
-            $wp->query_vars['gd_is_geodir_page'] = true;
473
+        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) {
474
+                    $wp->query_vars['gd_is_geodir_page'] = true;
475
+        }
440 476
 
441 477
 
442 478
 //check if homepage
@@ -466,11 +502,12 @@  discard block
 block discarded – undo
466 502
 function geodir_is_geodir_page()
467 503
 {
468 504
     global $wp;
469
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
-        return true;
471
-    else
472
-        return false;
473
-}
505
+    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) {
506
+            return true;
507
+    } else {
508
+            return false;
509
+    }
510
+    }
474 511
 
475 512
 if (!function_exists('geodir_get_imagesize')) {
476 513
     /**
@@ -848,20 +885,16 @@  discard block
 block discarded – undo
848 885
             $subject .= ' - ADMIN BCC COPY';
849 886
             $admin_bcc = true;
850 887
 
851
-        }
852
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
888
+        } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
853 889
             $subject .= ' - ADMIN BCC COPY';
854 890
             $admin_bcc = true;
855
-        }
856
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
891
+        } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
857 892
             $subject .= ' - ADMIN BCC COPY';
858 893
             $admin_bcc = true;
859
-        }
860
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
894
+        } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
861 895
             $subject .= ' - ADMIN BCC COPY';
862 896
             $admin_bcc = true;
863
-        }
864
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
897
+        } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
865 898
             $subject .= ' - ADMIN BCC COPY';
866 899
             $admin_bcc = true;
867 900
         }
@@ -1030,21 +1063,24 @@  discard block
 block discarded – undo
1030 1063
             $is_location_last = '';
1031 1064
             $is_taxonomy_last = '';
1032 1065
             $breadcrumb .= '<li>';
1033
-            if (get_query_var($gd_post_type . 'category'))
1034
-                $gd_taxonomy = $gd_post_type . 'category';
1035
-            elseif (get_query_var($gd_post_type . '_tags'))
1036
-                $gd_taxonomy = $gd_post_type . '_tags';
1066
+            if (get_query_var($gd_post_type . 'category')) {
1067
+                            $gd_taxonomy = $gd_post_type . 'category';
1068
+            } elseif (get_query_var($gd_post_type . '_tags')) {
1069
+                            $gd_taxonomy = $gd_post_type . '_tags';
1070
+            }
1037 1071
 
1038 1072
             $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1039
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040
-                $is_location_last = false;
1041
-            else
1042
-                $is_location_last = true;
1043
-
1044
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
1045
-                $is_taxonomy_last = true;
1046
-            else
1047
-                $is_taxonomy_last = false;
1073
+            if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
1074
+                            $is_location_last = false;
1075
+            } else {
1076
+                            $is_location_last = true;
1077
+            }
1078
+
1079
+            if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
1080
+                            $is_taxonomy_last = true;
1081
+            } else {
1082
+                            $is_taxonomy_last = false;
1083
+            }
1048 1084
 
1049 1085
             if (!empty($location_terms)) {
1050 1086
                 $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
@@ -1126,8 +1162,9 @@  discard block
 block discarded – undo
1126 1162
                 {
1127 1163
                     if (get_query_var($gd_post_type . '_tags')) {
1128 1164
                         $cat_link = $listing_link . 'tags/';
1129
-                    } else
1130
-                        $cat_link = $listing_link;
1165
+                    } else {
1166
+                                            $cat_link = $listing_link;
1167
+                    }
1131 1168
 
1132 1169
                     foreach ($location_terms as $key => $location_term) {
1133 1170
                         if ($location_manager && in_array($key, $hide_url_part)) {
@@ -1155,9 +1192,9 @@  discard block
 block discarded – undo
1155 1192
                             //$term_link_text = wp_strip_all_tags(geodir_ucwords(urldecode($term_link_text)));
1156 1193
                         }
1157 1194
 
1158
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1159
-                            $breadcrumb .= $separator . $term_link_text;
1160
-                        else {
1195
+                        if ($term_index == count($term_array) && $is_taxonomy_last) {
1196
+                                                    $breadcrumb .= $separator . $term_link_text;
1197
+                        } else {
1161 1198
                             $cat_link .= $term . '/';
1162 1199
                             $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1163 1200
                         }
@@ -1168,8 +1205,9 @@  discard block
 block discarded – undo
1168 1205
 
1169 1206
             }
1170 1207
 
1171
-            if (geodir_is_page('detail'))
1172
-                $breadcrumb .= $separator . get_the_title();
1208
+            if (geodir_is_page('detail')) {
1209
+                            $breadcrumb .= $separator . get_the_title();
1210
+            }
1173 1211
 
1174 1212
             $breadcrumb .= '</li>';
1175 1213
 
@@ -1206,8 +1244,9 @@  discard block
 block discarded – undo
1206 1244
 
1207 1245
                 $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1208 1246
                 $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1209
-            } else
1210
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1247
+            } else {
1248
+                            $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1249
+            }
1211 1250
 
1212 1251
             $breadcrumb .= '</li>';
1213 1252
         } elseif (is_category() || is_single()) {
@@ -1286,12 +1325,14 @@  discard block
 block discarded – undo
1286 1325
     function geodir_allow_wpadmin()
1287 1326
     {
1288 1327
         global $wpdb;
1289
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!defined( 'DOING_AJAX' )) ) // checking action in request to allow ajax request go through
1328
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!defined( 'DOING_AJAX' )) ) {
1329
+        	// checking action in request to allow ajax request go through
1290 1330
         {
1291 1331
             if (current_user_can('administrator')) {
1292 1332
             } else {
1293 1333
 
1294
-                wp_redirect(home_url());
1334
+                wp_redirect(home_url());
1335
+        }
1295 1336
                 exit;
1296 1337
             }
1297 1338
 
@@ -1339,8 +1380,9 @@  discard block
 block discarded – undo
1339 1380
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1340 1381
 
1341 1382
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1342
-    if ($upload['error'])
1343
-        return new WP_Error('upload_dir_error', $upload['error']);
1383
+    if ($upload['error']) {
1384
+            return new WP_Error('upload_dir_error', $upload['error']);
1385
+    }
1344 1386
 
1345 1387
 
1346 1388
     sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
@@ -1362,11 +1404,9 @@  discard block
 block discarded – undo
1362 1404
     // make sure the fetch was successful
1363 1405
     elseif ($headers['response']['code'] != '200') {
1364 1406
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1365
-    }
1366
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1407
+    } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1367 1408
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1368
-    }
1369
-    elseif (0 == $filesize) {
1409
+    } elseif (0 == $filesize) {
1370 1410
         $log_message = __('Zero size file downloaded', 'geodirectory');
1371 1411
     }
1372 1412
 
@@ -1378,10 +1418,11 @@  discard block
 block discarded – undo
1378 1418
 
1379 1419
     if ($dummy && $add_to_cache && is_array($upload)) {
1380 1420
         $images = get_transient('cached_dummy_images');
1381
-        if(is_array($images))
1382
-            $images[$key] = $upload;
1383
-        else
1384
-            $images = array($key => $upload);
1421
+        if(is_array($images)) {
1422
+                    $images[$key] = $upload;
1423
+        } else {
1424
+                    $images = array($key => $upload);
1425
+        }
1385 1426
 
1386 1427
         //setting the cache using the WP Transient API
1387 1428
         set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
@@ -1428,10 +1469,11 @@  discard block
 block discarded – undo
1428 1469
 function geodir_dummy_folder_exists()
1429 1470
 {
1430 1471
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1431
-    if (!is_dir($path))
1432
-        return false;
1433
-    else
1434
-        return true;
1472
+    if (!is_dir($path)) {
1473
+            return false;
1474
+    } else {
1475
+            return true;
1476
+    }
1435 1477
 
1436 1478
 }
1437 1479
 
@@ -1702,12 +1744,10 @@  discard block
 block discarded – undo
1702 1744
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1703 1745
             $subject .= ' - ADMIN BCC COPY';
1704 1746
             $admin_bcc = true;
1705
-        }
1706
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1747
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1707 1748
             $subject .= ' - ADMIN BCC COPY';
1708 1749
             $admin_bcc = true;
1709
-        }
1710
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1750
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1711 1751
             $subject .= ' - ADMIN BCC COPY';
1712 1752
             $admin_bcc = true;
1713 1753
         }
@@ -1751,7 +1791,9 @@  discard block
 block discarded – undo
1751 1791
         $res = array();
1752 1792
         foreach ($ids_array as $id) {
1753 1793
             $xlat = icl_object_id($id, $type, false);
1754
-            if (!is_null($xlat)) $res[] = $xlat;
1794
+            if (!is_null($xlat)) {
1795
+            	$res[] = $xlat;
1796
+            }
1755 1797
         }
1756 1798
         return $res;
1757 1799
     } else {
@@ -2092,8 +2134,9 @@  discard block
 block discarded – undo
2092 2134
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2093 2135
 
2094 2136
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2095
-        if ( !$page )
2096
-            $page = 1;
2137
+        if ( !$page ) {
2138
+                    $page = 1;
2139
+        }
2097 2140
 
2098 2141
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2099 2142
 
@@ -2419,7 +2462,7 @@  discard block
 block discarded – undo
2419 2462
     $home_url = str_replace("www.", "", $home_url);
2420 2463
     if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2421 2464
         return true;
2422
-    }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2465
+    } elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2423 2466
         return true;
2424 2467
     } else {
2425 2468
         return false;
@@ -2505,9 +2548,9 @@  discard block
 block discarded – undo
2505 2548
     $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2506 2549
     if(!empty($gd_post_type)){
2507 2550
         $default_post_type = $gd_post_type;
2508
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2551
+    } elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2509 2552
         $default_post_type = $instance['default_post_type'];
2510
-    }else{
2553
+    } else{
2511 2554
         $all_gd_post_type = geodir_get_posttypes();
2512 2555
         $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2513 2556
     }
@@ -2931,8 +2974,9 @@  discard block
 block discarded – undo
2931 2974
                         $name = $postobj->labels->name;
2932 2975
 
2933 2976
                         $selected = '';
2934
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2935
-                            $selected = 'selected="selected"';
2977
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2978
+                                                    $selected = 'selected="selected"';
2979
+                        }
2936 2980
 
2937 2981
                         /**
2938 2982
                          * Filter add listing link.
@@ -3399,8 +3443,9 @@  discard block
 block discarded – undo
3399 3443
             $geodir_is_widget_listing = false;
3400 3444
 
3401 3445
             $GLOBALS['post'] = $current_post;
3402
-            if (!empty($current_post))
3403
-                setup_postdata($current_post);
3446
+            if (!empty($current_post)) {
3447
+                            setup_postdata($current_post);
3448
+            }
3404 3449
             $map_jason = $current_map_jason;
3405 3450
             $map_canvas_arr = $current_map_canvas_arr;
3406 3451
             ?>
@@ -3778,11 +3823,15 @@  discard block
 block discarded – undo
3778 3823
 
3779 3824
     $language_file = geodir_plugin_path() . '/db-language.php';
3780 3825
 
3781
-    if(is_file($language_file) && !is_writable($language_file))
3782
-        return false; // Not possible to create.
3826
+    if(is_file($language_file) && !is_writable($language_file)) {
3827
+            return false;
3828
+    }
3829
+    // Not possible to create.
3783 3830
 
3784
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3785
-        return false; // Not possible to create.
3831
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3832
+            return false;
3833
+    }
3834
+    // Not possible to create.
3786 3835
 
3787 3836
     $contents_strings = array();
3788 3837
 
@@ -3825,8 +3874,10 @@  discard block
 block discarded – undo
3825 3874
 
3826 3875
     $contents .= implode(PHP_EOL, $contents_foot);
3827 3876
 
3828
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3829
-        return false; // Failure; could not write file.
3877
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3878
+            return false;
3879
+    }
3880
+    // Failure; could not write file.
3830 3881
 
3831 3882
     return true;
3832 3883
 }
@@ -3852,23 +3903,29 @@  discard block
 block discarded – undo
3852 3903
 
3853 3904
     if (!empty($rows)) {
3854 3905
         foreach($rows as $row) {
3855
-            if (!empty($row->admin_title))
3856
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3906
+            if (!empty($row->admin_title)) {
3907
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3908
+            }
3857 3909
 			
3858
-            if (!empty($row->admin_desc))
3859
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3910
+            if (!empty($row->admin_desc)) {
3911
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3912
+            }
3860 3913
 
3861
-            if (!empty($row->site_title))
3862
-                $translation_texts[] = stripslashes_deep($row->site_title);
3914
+            if (!empty($row->site_title)) {
3915
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3916
+            }
3863 3917
 
3864
-            if (!empty($row->clabels))
3865
-                $translation_texts[] = stripslashes_deep($row->clabels);
3918
+            if (!empty($row->clabels)) {
3919
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3920
+            }
3866 3921
 
3867
-            if (!empty($row->required_msg))
3868
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3922
+            if (!empty($row->required_msg)) {
3923
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3924
+            }
3869 3925
 			
3870
-			if (!empty($row->default_value))
3871
-                $translation_texts[] = stripslashes_deep($row->default_value);
3926
+			if (!empty($row->default_value)) {
3927
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3928
+			}
3872 3929
 			
3873 3930
 			if (!empty($row->option_values)) {
3874 3931
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3890,14 +3947,17 @@  discard block
 block discarded – undo
3890 3947
 
3891 3948
     if (!empty($rows)) {
3892 3949
         foreach($rows as $row) {
3893
-            if (!empty($row->site_title))
3894
-                $translation_texts[] = stripslashes_deep($row->site_title);
3950
+            if (!empty($row->site_title)) {
3951
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3952
+            }
3895 3953
 
3896
-            if (!empty($row->asc_title))
3897
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3954
+            if (!empty($row->asc_title)) {
3955
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3956
+            }
3898 3957
 
3899
-            if (!empty($row->desc_title))
3900
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3958
+            if (!empty($row->desc_title)) {
3959
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3960
+            }
3901 3961
         }
3902 3962
     }
3903 3963
 	
@@ -3908,14 +3968,17 @@  discard block
 block discarded – undo
3908 3968
 
3909 3969
 		if (!empty($rows)) {
3910 3970
 			foreach($rows as $row) {
3911
-				if (!empty($row->field_site_name))
3912
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3971
+				if (!empty($row->field_site_name)) {
3972
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3973
+				}
3913 3974
 
3914
-				if (!empty($row->front_search_title))
3915
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3975
+				if (!empty($row->front_search_title)) {
3976
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3977
+				}
3916 3978
 
3917
-				if (!empty($row->field_desc))
3918
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3979
+				if (!empty($row->field_desc)) {
3980
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3981
+				}
3919 3982
 			}
3920 3983
 		}
3921 3984
 	}
@@ -4511,38 +4574,54 @@  discard block
 block discarded – undo
4511 4574
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4512 4575
 
4513 4576
             if (!empty($labels)) {
4514
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4515
-                    $translation_texts[] = $labels['name'];
4516
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4517
-                    $translation_texts[] = $labels['singular_name'];
4518
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4519
-                    $translation_texts[] = $labels['add_new'];
4520
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4521
-                    $translation_texts[] = $labels['add_new_item'];
4522
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4523
-                    $translation_texts[] = $labels['edit_item'];
4524
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4525
-                    $translation_texts[] = $labels['new_item'];
4526
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4527
-                    $translation_texts[] = $labels['view_item'];
4528
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4529
-                    $translation_texts[] = $labels['search_items'];
4530
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4531
-                    $translation_texts[] = $labels['not_found'];
4532
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4533
-                    $translation_texts[] = $labels['not_found_in_trash'];
4534
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4535
-                    $translation_texts[] = $labels['label_post_profile'];
4536
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_post_info'];
4538
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_post_images'];
4540
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4541
-                    $translation_texts[] = $labels['label_post_map'];
4542
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4543
-                    $translation_texts[] = $labels['label_reviews'];
4544
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4545
-                    $translation_texts[] = $labels['label_related_listing'];
4577
+                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4578
+                                    $translation_texts[] = $labels['name'];
4579
+                }
4580
+                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4581
+                                    $translation_texts[] = $labels['singular_name'];
4582
+                }
4583
+                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4584
+                                    $translation_texts[] = $labels['add_new'];
4585
+                }
4586
+                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4587
+                                    $translation_texts[] = $labels['add_new_item'];
4588
+                }
4589
+                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4590
+                                    $translation_texts[] = $labels['edit_item'];
4591
+                }
4592
+                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4593
+                                    $translation_texts[] = $labels['new_item'];
4594
+                }
4595
+                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4596
+                                    $translation_texts[] = $labels['view_item'];
4597
+                }
4598
+                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4599
+                                    $translation_texts[] = $labels['search_items'];
4600
+                }
4601
+                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4602
+                                    $translation_texts[] = $labels['not_found'];
4603
+                }
4604
+                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4605
+                                    $translation_texts[] = $labels['not_found_in_trash'];
4606
+                }
4607
+                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4608
+                                    $translation_texts[] = $labels['label_post_profile'];
4609
+                }
4610
+                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4611
+                                    $translation_texts[] = $labels['label_post_info'];
4612
+                }
4613
+                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4614
+                                    $translation_texts[] = $labels['label_post_images'];
4615
+                }
4616
+                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4617
+                                    $translation_texts[] = $labels['label_post_map'];
4618
+                }
4619
+                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4620
+                                    $translation_texts[] = $labels['label_reviews'];
4621
+                }
4622
+                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4623
+                                    $translation_texts[] = $labels['label_related_listing'];
4624
+                }
4546 4625
             }
4547 4626
 
4548 4627
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4550,11 +4629,13 @@  discard block
 block discarded – undo
4550 4629
             }
4551 4630
 
4552 4631
             if (!empty($seo)) {
4553
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4554
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4632
+                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4633
+                                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4634
+                }
4555 4635
 
4556
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4557
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4636
+                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4637
+                                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4638
+                }
4558 4639
             }
4559 4640
         }
4560 4641
     }
@@ -4580,16 +4661,20 @@  discard block
 block discarded – undo
4580 4661
         $hide_region_part = get_option('geodir_location_hide_region_part');
4581 4662
 
4582 4663
         if ($hide_region_part && $hide_country_part) {
4583
-            if (isset($location_terms['gd_country']))
4584
-                unset($location_terms['gd_country']);
4585
-            if (isset($location_terms['gd_region']))
4586
-                unset($location_terms['gd_region']);
4664
+            if (isset($location_terms['gd_country'])) {
4665
+                            unset($location_terms['gd_country']);
4666
+            }
4667
+            if (isset($location_terms['gd_region'])) {
4668
+                            unset($location_terms['gd_region']);
4669
+            }
4587 4670
         } else if ($hide_region_part && !$hide_country_part) {
4588
-            if (isset($location_terms['gd_region']))
4589
-                unset($location_terms['gd_region']);
4671
+            if (isset($location_terms['gd_region'])) {
4672
+                            unset($location_terms['gd_region']);
4673
+            }
4590 4674
         } else if (!$hide_region_part && $hide_country_part) {
4591
-            if (isset($location_terms['gd_country']))
4592
-                unset($location_terms['gd_country']);
4675
+            if (isset($location_terms['gd_country'])) {
4676
+                            unset($location_terms['gd_country']);
4677
+            }
4593 4678
         }
4594 4679
     }
4595 4680
 
@@ -4782,7 +4867,7 @@  discard block
 block discarded – undo
4782 4867
     foreach ($terms as $term) {
4783 4868
         if (isset($term->count) && $term->count > 0) {
4784 4869
             $return[] = $term;
4785
-        }else{
4870
+        } else{
4786 4871
             /**
4787 4872
              * Allow to filter terms with no count.
4788 4873
              *
Please login to merge, or discard this patch.