Passed
Pull Request — master (#249)
by Viruthagiri
10:31
created
geodirectory-functions/general_functions.php 1 patch
Braces   +277 added lines, -194 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)) {
@@ -1154,9 +1191,9 @@  discard block
 block discarded – undo
1154 1191
                             $term_link_text = geodir_ucwords(urldecode($term_link_text));
1155 1192
                         }
1156 1193
 
1157
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1158
-                            $breadcrumb .= $separator . $term_link_text;
1159
-                        else {
1194
+                        if ($term_index == count($term_array) && $is_taxonomy_last) {
1195
+                                                    $breadcrumb .= $separator . $term_link_text;
1196
+                        } else {
1160 1197
                             $cat_link .= $term . '/';
1161 1198
                             $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1162 1199
                         }
@@ -1167,8 +1204,9 @@  discard block
 block discarded – undo
1167 1204
 
1168 1205
             }
1169 1206
 
1170
-            if (geodir_is_page('detail'))
1171
-                $breadcrumb .= $separator . get_the_title();
1207
+            if (geodir_is_page('detail')) {
1208
+                            $breadcrumb .= $separator . get_the_title();
1209
+            }
1172 1210
 
1173 1211
             $breadcrumb .= '</li>';
1174 1212
 
@@ -1205,8 +1243,9 @@  discard block
 block discarded – undo
1205 1243
 
1206 1244
                 $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207 1245
                 $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1208
-            } else
1209
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1246
+            } else {
1247
+                            $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1248
+            }
1210 1249
 
1211 1250
             $breadcrumb .= '</li>';
1212 1251
         } elseif (is_category() || is_single()) {
@@ -1281,12 +1320,14 @@  discard block
 block discarded – undo
1281 1320
     function geodir_allow_wpadmin()
1282 1321
     {
1283 1322
         global $wpdb;
1284
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1323
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) {
1324
+        	// checking action in request to allow ajax request go through
1285 1325
         {
1286 1326
             if (current_user_can('manage_options')) {
1287 1327
             } else {
1288 1328
 
1289
-                wp_redirect(home_url());
1329
+                wp_redirect(home_url());
1330
+        }
1290 1331
                 exit;
1291 1332
             }
1292 1333
 
@@ -1334,8 +1375,9 @@  discard block
 block discarded – undo
1334 1375
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1335 1376
 
1336 1377
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1337
-    if ($upload['error'])
1338
-        return new WP_Error('upload_dir_error', $upload['error']);
1378
+    if ($upload['error']) {
1379
+            return new WP_Error('upload_dir_error', $upload['error']);
1380
+    }
1339 1381
 
1340 1382
     // fetch the remote url and write it to the placeholder file
1341 1383
     $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
@@ -1349,11 +1391,9 @@  discard block
 block discarded – undo
1349 1391
     // make sure the fetch was successful
1350 1392
     elseif ($headers['response']['code'] != '200') {
1351 1393
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1352
-    }
1353
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1394
+    } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1354 1395
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1355
-    }
1356
-    elseif (0 == $filesize) {
1396
+    } elseif (0 == $filesize) {
1357 1397
         $log_message = __('Zero size file downloaded', 'geodirectory');
1358 1398
     }
1359 1399
 
@@ -1365,10 +1405,11 @@  discard block
 block discarded – undo
1365 1405
 
1366 1406
     if ($dummy && $add_to_cache && is_array($upload)) {
1367 1407
         $images = get_transient('cached_dummy_images');
1368
-        if(is_array($images))
1369
-            $images[$key] = $upload;
1370
-        else
1371
-            $images = array($key => $upload);
1408
+        if(is_array($images)) {
1409
+                    $images[$key] = $upload;
1410
+        } else {
1411
+                    $images = array($key => $upload);
1412
+        }
1372 1413
 
1373 1414
         //setting the cache using the WP Transient API
1374 1415
         set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
@@ -1415,10 +1456,11 @@  discard block
 block discarded – undo
1415 1456
 function geodir_dummy_folder_exists()
1416 1457
 {
1417 1458
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1418
-    if (!is_dir($path))
1419
-        return false;
1420
-    else
1421
-        return true;
1459
+    if (!is_dir($path)) {
1460
+            return false;
1461
+    } else {
1462
+            return true;
1463
+    }
1422 1464
 
1423 1465
 }
1424 1466
 
@@ -1689,12 +1731,10 @@  discard block
 block discarded – undo
1689 1731
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1690 1732
             $subject .= ' - ADMIN BCC COPY';
1691 1733
             $admin_bcc = true;
1692
-        }
1693
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1734
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1694 1735
             $subject .= ' - ADMIN BCC COPY';
1695 1736
             $admin_bcc = true;
1696
-        }
1697
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1737
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1698 1738
             $subject .= ' - ADMIN BCC COPY';
1699 1739
             $admin_bcc = true;
1700 1740
         }
@@ -1738,7 +1778,9 @@  discard block
 block discarded – undo
1738 1778
         $res = array();
1739 1779
         foreach ($ids_array as $id) {
1740 1780
             $xlat = icl_object_id($id, $type, false);
1741
-            if (!is_null($xlat)) $res[] = $xlat;
1781
+            if (!is_null($xlat)) {
1782
+            	$res[] = $xlat;
1783
+            }
1742 1784
         }
1743 1785
         return $res;
1744 1786
     } else {
@@ -2079,8 +2121,9 @@  discard block
 block discarded – undo
2079 2121
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2080 2122
 
2081 2123
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2082
-        if ( !$page )
2083
-            $page = 1;
2124
+        if ( !$page ) {
2125
+                    $page = 1;
2126
+        }
2084 2127
 
2085 2128
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2086 2129
 
@@ -2406,7 +2449,7 @@  discard block
 block discarded – undo
2406 2449
     $home_url = str_replace("www.", "", $home_url);
2407 2450
     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')) ) {
2408 2451
         return true;
2409
-    }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')){
2452
+    } 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')){
2410 2453
         return true;
2411 2454
     } else {
2412 2455
         return false;
@@ -2492,9 +2535,9 @@  discard block
 block discarded – undo
2492 2535
     $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2493 2536
     if(!empty($gd_post_type)){
2494 2537
         $default_post_type = $gd_post_type;
2495
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2538
+    } elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2496 2539
         $default_post_type = $instance['default_post_type'];
2497
-    }else{
2540
+    } else{
2498 2541
         $all_gd_post_type = geodir_get_posttypes();
2499 2542
         $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2500 2543
     }
@@ -2918,8 +2961,9 @@  discard block
 block discarded – undo
2918 2961
                         $name = $postobj->labels->name;
2919 2962
 
2920 2963
                         $selected = '';
2921
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2922
-                            $selected = 'selected="selected"';
2964
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2965
+                                                    $selected = 'selected="selected"';
2966
+                        }
2923 2967
 
2924 2968
                         /**
2925 2969
                          * Filter add listing link.
@@ -3386,8 +3430,9 @@  discard block
 block discarded – undo
3386 3430
             $geodir_is_widget_listing = false;
3387 3431
 
3388 3432
             $GLOBALS['post'] = $current_post;
3389
-            if (!empty($current_post))
3390
-                setup_postdata($current_post);
3433
+            if (!empty($current_post)) {
3434
+                            setup_postdata($current_post);
3435
+            }
3391 3436
             $map_jason = $current_map_jason;
3392 3437
             $map_canvas_arr = $current_map_canvas_arr;
3393 3438
             ?>
@@ -3765,11 +3810,15 @@  discard block
 block discarded – undo
3765 3810
 
3766 3811
     $language_file = geodir_plugin_path() . '/db-language.php';
3767 3812
 
3768
-    if(is_file($language_file) && !is_writable($language_file))
3769
-        return false; // Not possible to create.
3813
+    if(is_file($language_file) && !is_writable($language_file)) {
3814
+            return false;
3815
+    }
3816
+    // Not possible to create.
3770 3817
 
3771
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3772
-        return false; // Not possible to create.
3818
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3819
+            return false;
3820
+    }
3821
+    // Not possible to create.
3773 3822
 
3774 3823
     $contents_strings = array();
3775 3824
 
@@ -3812,8 +3861,10 @@  discard block
 block discarded – undo
3812 3861
 
3813 3862
     $contents .= implode(PHP_EOL, $contents_foot);
3814 3863
 
3815
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3816
-        return false; // Failure; could not write file.
3864
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3865
+            return false;
3866
+    }
3867
+    // Failure; could not write file.
3817 3868
 
3818 3869
     return true;
3819 3870
 }
@@ -3839,23 +3890,29 @@  discard block
 block discarded – undo
3839 3890
 
3840 3891
     if (!empty($rows)) {
3841 3892
         foreach($rows as $row) {
3842
-            if (!empty($row->admin_title))
3843
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3893
+            if (!empty($row->admin_title)) {
3894
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3895
+            }
3844 3896
 			
3845
-            if (!empty($row->admin_desc))
3846
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3897
+            if (!empty($row->admin_desc)) {
3898
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3899
+            }
3847 3900
 
3848
-            if (!empty($row->site_title))
3849
-                $translation_texts[] = stripslashes_deep($row->site_title);
3901
+            if (!empty($row->site_title)) {
3902
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3903
+            }
3850 3904
 
3851
-            if (!empty($row->clabels))
3852
-                $translation_texts[] = stripslashes_deep($row->clabels);
3905
+            if (!empty($row->clabels)) {
3906
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3907
+            }
3853 3908
 
3854
-            if (!empty($row->required_msg))
3855
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3909
+            if (!empty($row->required_msg)) {
3910
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3911
+            }
3856 3912
 			
3857
-			if (!empty($row->default_value))
3858
-                $translation_texts[] = stripslashes_deep($row->default_value);
3913
+			if (!empty($row->default_value)) {
3914
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3915
+			}
3859 3916
 			
3860 3917
 			if (!empty($row->option_values)) {
3861 3918
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3877,14 +3934,17 @@  discard block
 block discarded – undo
3877 3934
 
3878 3935
     if (!empty($rows)) {
3879 3936
         foreach($rows as $row) {
3880
-            if (!empty($row->site_title))
3881
-                $translation_texts[] = stripslashes_deep($row->site_title);
3937
+            if (!empty($row->site_title)) {
3938
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3939
+            }
3882 3940
 
3883
-            if (!empty($row->asc_title))
3884
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3941
+            if (!empty($row->asc_title)) {
3942
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3943
+            }
3885 3944
 
3886
-            if (!empty($row->desc_title))
3887
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3945
+            if (!empty($row->desc_title)) {
3946
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3947
+            }
3888 3948
         }
3889 3949
     }
3890 3950
 	
@@ -3895,14 +3955,17 @@  discard block
 block discarded – undo
3895 3955
 
3896 3956
 		if (!empty($rows)) {
3897 3957
 			foreach($rows as $row) {
3898
-				if (!empty($row->field_site_name))
3899
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3958
+				if (!empty($row->field_site_name)) {
3959
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3960
+				}
3900 3961
 
3901
-				if (!empty($row->front_search_title))
3902
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3962
+				if (!empty($row->front_search_title)) {
3963
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3964
+				}
3903 3965
 
3904
-				if (!empty($row->field_desc))
3905
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3966
+				if (!empty($row->field_desc)) {
3967
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3968
+				}
3906 3969
 			}
3907 3970
 		}
3908 3971
 	}
@@ -4220,7 +4283,7 @@  discard block
 block discarded – undo
4220 4283
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4221 4284
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4222 4285
             }
4223
-        }elseif($gd_page=='add-listing'){
4286
+        } elseif($gd_page=='add-listing'){
4224 4287
             $geodir_post_types = get_option('geodir_post_types');
4225 4288
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4226 4289
             if(!$spt && isset($_REQUEST['pid'])){
@@ -4230,8 +4293,7 @@  discard block
 block discarded – undo
4230 4293
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4231 4294
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4232 4295
             }
4233
-        }
4234
-        elseif($post->post_type){
4296
+        } elseif($post->post_type){
4235 4297
             $geodir_post_types = get_option('geodir_post_types');
4236 4298
             if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4237 4299
                 $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
@@ -4250,15 +4312,14 @@  discard block
 block discarded – undo
4250 4312
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4251 4313
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4252 4314
             }
4253
-        }elseif($gd_page=='add-listing'){
4315
+        } elseif($gd_page=='add-listing'){
4254 4316
             $geodir_post_types = get_option('geodir_post_types');
4255 4317
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4256 4318
             if(!$spt){$spt='gd_place';}
4257 4319
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4258 4320
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4259 4321
             }
4260
-        }
4261
-        elseif(isset($post->post_type) && $post->post_type){
4322
+        } elseif(isset($post->post_type) && $post->post_type){
4262 4323
             $geodir_post_types = get_option('geodir_post_types');
4263 4324
             if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4264 4325
                 $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
@@ -4278,7 +4339,7 @@  discard block
 block discarded – undo
4278 4339
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4279 4340
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4280 4341
             }
4281
-        }elseif($gd_page=='listing'){
4342
+        } elseif($gd_page=='listing'){
4282 4343
             $queried_object = get_queried_object();
4283 4344
             if(isset($queried_object->name)){
4284 4345
                 $cat_name = $queried_object->name;
@@ -4295,7 +4356,7 @@  discard block
 block discarded – undo
4295 4356
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4296 4357
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4297 4358
             }
4298
-        }elseif($gd_page=='listing'){
4359
+        } elseif($gd_page=='listing'){
4299 4360
             $queried_object = get_queried_object();
4300 4361
             if(isset($queried_object->name)){
4301 4362
                 $cat_name = $queried_object->name;
@@ -4513,38 +4574,54 @@  discard block
 block discarded – undo
4513 4574
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4514 4575
 
4515 4576
             if (!empty($labels)) {
4516
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4517
-                    $translation_texts[] = $labels['name'];
4518
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4519
-                    $translation_texts[] = $labels['singular_name'];
4520
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4521
-                    $translation_texts[] = $labels['add_new'];
4522
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4523
-                    $translation_texts[] = $labels['add_new_item'];
4524
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4525
-                    $translation_texts[] = $labels['edit_item'];
4526
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4527
-                    $translation_texts[] = $labels['new_item'];
4528
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4529
-                    $translation_texts[] = $labels['view_item'];
4530
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4531
-                    $translation_texts[] = $labels['search_items'];
4532
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4533
-                    $translation_texts[] = $labels['not_found'];
4534
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4535
-                    $translation_texts[] = $labels['not_found_in_trash'];
4536
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_post_profile'];
4538
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_post_info'];
4540
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4541
-                    $translation_texts[] = $labels['label_post_images'];
4542
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4543
-                    $translation_texts[] = $labels['label_post_map'];
4544
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4545
-                    $translation_texts[] = $labels['label_reviews'];
4546
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4547
-                    $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
+                }
4548 4625
             }
4549 4626
 
4550 4627
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4552,11 +4629,13 @@  discard block
 block discarded – undo
4552 4629
             }
4553 4630
 
4554 4631
             if (!empty($seo)) {
4555
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4556
-                    $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
+                }
4557 4635
 
4558
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4559
-                    $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
+                }
4560 4639
             }
4561 4640
         }
4562 4641
     }
@@ -4582,16 +4661,20 @@  discard block
 block discarded – undo
4582 4661
         $hide_region_part = get_option('geodir_location_hide_region_part');
4583 4662
 
4584 4663
         if ($hide_region_part && $hide_country_part) {
4585
-            if (isset($location_terms['gd_country']))
4586
-                unset($location_terms['gd_country']);
4587
-            if (isset($location_terms['gd_region']))
4588
-                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
+            }
4589 4670
         } else if ($hide_region_part && !$hide_country_part) {
4590
-            if (isset($location_terms['gd_region']))
4591
-                unset($location_terms['gd_region']);
4671
+            if (isset($location_terms['gd_region'])) {
4672
+                            unset($location_terms['gd_region']);
4673
+            }
4592 4674
         } else if (!$hide_region_part && $hide_country_part) {
4593
-            if (isset($location_terms['gd_country']))
4594
-                unset($location_terms['gd_country']);
4675
+            if (isset($location_terms['gd_country'])) {
4676
+                            unset($location_terms['gd_country']);
4677
+            }
4595 4678
         }
4596 4679
     }
4597 4680
 
Please login to merge, or discard this patch.