Test Setup Failed
Push — master ( 2261e5...599f56 )
by Stiofan
02:03
created
geodirectory-functions/custom_field_html.php 3 patches
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 global $post_type;
19 19
 
20 20
 if (!isset($field_info->post_type)) {
21
-    $post_type = sanitize_text_field($_REQUEST['listing_type']);
21
+	$post_type = sanitize_text_field($_REQUEST['listing_type']);
22 22
 } else
23
-    $post_type = $field_info->post_type;
23
+	$post_type = $field_info->post_type;
24 24
 
25 25
 //if(isset($_REQUEST['custom_type']) && $_REQUEST['custom_type']=='predefined'){
26 26
 //    $cf_arr = geodir_custom_fields_predefined($post_type);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 $field_admin_title = '';
50 50
 if (isset($field_info->admin_title))
51
-    $field_admin_title = $field_info->admin_title;
51
+	$field_admin_title = $field_info->admin_title;
52 52
 
53 53
 $default = isset($field_info->is_admin) ? $field_info->is_admin : '';
54 54
 
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 //print_r($field_info);
69 69
 
70 70
 if (isset($cf['icon']) && strpos($cf['icon'], ' fa-') !== false) {
71
-    $field_icon = '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
71
+	$field_icon = '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
72 72
 }elseif(isset($cf['icon']) && $cf['icon']){
73
-    $field_icon = '<b class="gd-cf-icon" style="background-image: url(\''.$cf['icon'].'\')"></b>';
73
+	$field_icon = '<b class="gd-cf-icon" style="background-image: url(\''.$cf['icon'].'\')"></b>';
74 74
 }else{
75
-    $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>';
75
+	$field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>';
76 76
 }
77 77
 
78 78
 if(isset($cf['name']) && $cf['name']){
79
-    $field_type_name = $cf['name'];
79
+	$field_type_name = $cf['name'];
80 80
 }else{
81
-    $field_type_name = $field_type;
81
+	$field_type_name = $field_type;
82 82
 }
83 83
 
84 84
 if (isset($field_info->data_type) && $field_info->data_type == 'VARCHAR') {
85
-    $field_info->data_type = 'XVARCHAR';
85
+	$field_info->data_type = 'XVARCHAR';
86 86
 }
87 87
 
88 88
 ?>
@@ -92,45 +92,45 @@  discard block
 block discarded – undo
92 92
          ondblclick="show_hide('field_frm<?php echo $result_str; ?>')" >
93 93
         <?php
94 94
 
95
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
96
-        ?>
95
+		$nonce = wp_create_nonce('custom_fields_' . $result_str);
96
+		?>
97 97
 
98 98
         <?php if (!$default): ?>
99 99
             <div title="<?php _e('Click to remove field', 'geodirectory'); ?>"
100 100
                  onclick="delete_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>')"
101 101
                  class="handlediv close"><i class="fas fa-times" aria-hidden="true"></i></div>
102 102
         <?php endif;
103
-        if ($field_type == 'fieldset') {
104
-            ?>
103
+		if ($field_type == 'fieldset') {
104
+			?>
105 105
             <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i>
106 106
             <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i>
107 107
             <b style="cursor:pointer;"
108 108
                onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(__('Fieldset:', 'geodirectory') . ' ' . $field_admin_title);?></b>
109 109
         <?php
110
-        } else {echo $field_icon;
111
-            ?>
110
+		} else {echo $field_icon;
111
+			?>
112 112
             <b style="cursor:pointer;"
113 113
                onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(' ' . $field_admin_title . ' (' . $field_type_name . ')');?></b>
114 114
         <?php
115
-        }
116
-        ?>
115
+		}
116
+		?>
117 117
     </div>
118 118
 
119 119
     <form><!-- we need to wrap in a fom so we can use radio buttons with same name -->
120 120
     <div id="field_frm<?php echo $result_str; ?>" class="field_frm"
121 121
          style="display:<?php if ($field_ins_upd == 'submit') {
122
-             echo 'block;';
123
-         } else {
124
-             echo 'none;';
125
-         } ?>">
122
+			 echo 'block;';
123
+		 } else {
124
+			 echo 'none;';
125
+		 } ?>">
126 126
         <input type="hidden" name="_wpnonce" value="<?php echo esc_attr($nonce); ?>"/>
127 127
         <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type; ?>"/>
128 128
         <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/>
129 129
         <input type="hidden" name="field_type_key" id="field_type_key" value="<?php echo $field_type_key; ?>"/>
130 130
         <input type="hidden" name="field_id" id="field_id" value="<?php echo esc_attr($result_str); ?>"/>
131 131
         <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
132
-            echo $field_info->data_type;
133
-        } ?>"/>
132
+			echo $field_info->data_type;
133
+		} ?>"/>
134 134
         <input type="hidden" name="is_active" id="is_active" value="1"/>
135 135
 
136 136
         <input type="hidden" name="is_default" value="<?php echo isset($field_info->is_default) ? $field_info->is_default : '';?>" /><?php // show in sidebar value?>
@@ -142,37 +142,37 @@  discard block
 block discarded – undo
142 142
 
143 143
             <?php
144 144
 
145
-            // data_type
146
-            if(has_filter("geodir_cfa_data_type_{$field_type}")){
145
+			// data_type
146
+			if(has_filter("geodir_cfa_data_type_{$field_type}")){
147 147
 
148
-                echo apply_filters("geodir_cfa_data_type_{$field_type}",'',$result_str,$cf,$field_info);
148
+				echo apply_filters("geodir_cfa_data_type_{$field_type}",'',$result_str,$cf,$field_info);
149 149
 
150
-            }else{
151
-                $value = '';
152
-                if (isset($field_info->data_type)) {
153
-                    $value = esc_attr($field_info->data_type);
154
-                }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
155
-                    $value = $cf['defaults']['data_type'];
156
-                }
157
-                ?>
150
+			}else{
151
+				$value = '';
152
+				if (isset($field_info->data_type)) {
153
+					$value = esc_attr($field_info->data_type);
154
+				}elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
155
+					$value = $cf['defaults']['data_type'];
156
+				}
157
+				?>
158 158
                 <input type="hidden" name="data_type" id="data_type" value="<?php echo $value;?>"/>
159 159
             <?php
160
-            }
160
+			}
161 161
 
162 162
 
163
-            // admin_title
164
-            if(has_filter("geodir_cfa_admin_title_{$field_type}")){
163
+			// admin_title
164
+			if(has_filter("geodir_cfa_admin_title_{$field_type}")){
165 165
 
166
-                echo apply_filters("geodir_cfa_admin_title_{$field_type}",'',$result_str,$cf,$field_info);
166
+				echo apply_filters("geodir_cfa_admin_title_{$field_type}",'',$result_str,$cf,$field_info);
167 167
 
168
-            }else{
169
-                $value = '';
170
-                if (isset($field_info->admin_title)) {
171
-                    $value = esc_attr($field_info->admin_title);
172
-                }elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
173
-                    $value = $cf['defaults']['admin_title'];
174
-                }
175
-                ?>
168
+			}else{
169
+				$value = '';
170
+				if (isset($field_info->admin_title)) {
171
+					$value = esc_attr($field_info->admin_title);
172
+				}elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
173
+					$value = $cf['defaults']['admin_title'];
174
+				}
175
+				?>
176 176
                 <li>
177 177
                     <label for="admin_title" class="gd-cf-tooltip-wrap">
178 178
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Admin title :', 'geodirectory'); ?>
@@ -186,22 +186,22 @@  discard block
 block discarded – undo
186 186
                     </div>
187 187
                 </li>
188 188
                 <?php
189
-            }
189
+			}
190 190
 
191 191
 
192
-            // site_title
193
-            if(has_filter("geodir_cfa_site_title_{$field_type}")){
192
+			// site_title
193
+			if(has_filter("geodir_cfa_site_title_{$field_type}")){
194 194
 
195
-                echo apply_filters("geodir_cfa_site_title_{$field_type}",'',$result_str,$cf,$field_info);
195
+				echo apply_filters("geodir_cfa_site_title_{$field_type}",'',$result_str,$cf,$field_info);
196 196
 
197
-            }else{
198
-                $value = '';
199
-                if (isset($field_info->site_title)) {
200
-                    $value = esc_attr($field_info->site_title);
201
-                }elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
202
-                    $value = $cf['defaults']['site_title'];
203
-                }
204
-                ?>
197
+			}else{
198
+				$value = '';
199
+				if (isset($field_info->site_title)) {
200
+					$value = esc_attr($field_info->site_title);
201
+				}elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
202
+					$value = $cf['defaults']['site_title'];
203
+				}
204
+				?>
205 205
                 <li>
206 206
                     <label for="site_title" class="gd-cf-tooltip-wrap"> <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Frontend title :', 'geodirectory'); ?>
207 207
                         <div class="gdcf-tooltip">
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
                     </div>
215 215
                 </li>
216 216
                 <?php
217
-            }
217
+			}
218 218
 
219 219
 
220
-            // admin_desc
221
-            if(has_filter("geodir_cfa_admin_desc_{$field_type}")){
220
+			// admin_desc
221
+			if(has_filter("geodir_cfa_admin_desc_{$field_type}")){
222 222
 
223
-                echo apply_filters("geodir_cfa_admin_desc_{$field_type}",'',$result_str,$cf,$field_info);
223
+				echo apply_filters("geodir_cfa_admin_desc_{$field_type}",'',$result_str,$cf,$field_info);
224 224
 
225
-            }else{
226
-                $value = '';
227
-                if (isset($field_info->admin_desc)) {
228
-                    $value = esc_attr($field_info->admin_desc);
229
-                }elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
230
-                    $value = $cf['defaults']['admin_desc'];
231
-                }
232
-                ?>
225
+			}else{
226
+				$value = '';
227
+				if (isset($field_info->admin_desc)) {
228
+					$value = esc_attr($field_info->admin_desc);
229
+				}elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
230
+					$value = $cf['defaults']['admin_desc'];
231
+				}
232
+				?>
233 233
                 <li>
234 234
                     <label for="admin_desc" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Frontend description :', 'geodirectory'); ?>
235 235
                         <div class="gdcf-tooltip">
@@ -241,23 +241,23 @@  discard block
 block discarded – undo
241 241
                     </div>
242 242
                 </li>
243 243
                 <?php
244
-            }
244
+			}
245 245
 
246 246
 
247 247
 
248
-            // htmlvar_name
249
-            if(has_filter("geodir_cfa_htmlvar_name_{$field_type}")){
248
+			// htmlvar_name
249
+			if(has_filter("geodir_cfa_htmlvar_name_{$field_type}")){
250 250
 
251
-                echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info);
251
+				echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info);
252 252
 
253
-            }else{
254
-                $value = '';
255
-                if (isset($field_info->htmlvar_name)) {
256
-                    $value = esc_attr($field_info->htmlvar_name);
257
-                }elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
258
-                    $value = $cf['defaults']['htmlvar_name'];
259
-                }
260
-                ?>
253
+			}else{
254
+				$value = '';
255
+				if (isset($field_info->htmlvar_name)) {
256
+					$value = esc_attr($field_info->htmlvar_name);
257
+				}elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
258
+					$value = $cf['defaults']['htmlvar_name'];
259
+				}
260
+				?>
261 261
                 <li>
262 262
                     <label for="htmlvar_name" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('HTML variable name :', 'geodirectory');?>
263 263
                         <div class="gdcf-tooltip">
@@ -267,29 +267,29 @@  discard block
 block discarded – undo
267 267
                     <div class="gd-cf-input-wrap">
268 268
                         <input type="text" name="htmlvar_name" id="htmlvar_name" pattern="[a-zA-Z0-9]+" title="<?php _e('Must not contain spaces or special characters', 'geodirectory');?>"
269 269
                                value="<?php if ($value) {
270
-                                   echo preg_replace('/geodir_/', '', $value, 1);
271
-                               }?>" <?php if ($default) {
272
-                            echo 'readonly="readonly"';
273
-                        }?> />
270
+								   echo preg_replace('/geodir_/', '', $value, 1);
271
+							   }?>" <?php if ($default) {
272
+							echo 'readonly="readonly"';
273
+						}?> />
274 274
                     </div>
275 275
                 </li>
276 276
                 <?php
277
-            }
277
+			}
278 278
 
279 279
 
280
-            // is_active
281
-            if(has_filter("geodir_cfa_is_active_{$field_type}")){
280
+			// is_active
281
+			if(has_filter("geodir_cfa_is_active_{$field_type}")){
282 282
 
283
-                echo apply_filters("geodir_cfa_is_active_{$field_type}",'',$result_str,$cf,$field_info);
283
+				echo apply_filters("geodir_cfa_is_active_{$field_type}",'',$result_str,$cf,$field_info);
284 284
 
285
-            }else{
286
-                $value = '';
287
-                if (isset($field_info->is_active)) {
288
-                    $value = esc_attr($field_info->is_active);
289
-                }elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
290
-                    $value = $cf['defaults']['is_active'];
291
-                }
292
-                ?>
285
+			}else{
286
+				$value = '';
287
+				if (isset($field_info->is_active)) {
288
+					$value = esc_attr($field_info->is_active);
289
+				}elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
290
+					$value = $cf['defaults']['is_active'];
291
+				}
292
+				?>
293 293
                 <li <?php echo $field_display; ?>>
294 294
                     <label for="is_active" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Is active :', 'geodirectory'); ?>
295 295
                         <div class="gdcf-tooltip">
@@ -300,35 +300,35 @@  discard block
 block discarded – undo
300 300
 
301 301
                         <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled"  value="1"
302 302
                             <?php if ($value == '1') {
303
-                                echo 'checked';
304
-                            } ?>/>
303
+								echo 'checked';
304
+							} ?>/>
305 305
                         <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
306 306
 
307 307
                         <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0"
308 308
                             <?php if ($value == '0' || !$value) {
309
-                                echo 'checked';
310
-                            } ?>/>
309
+								echo 'checked';
310
+							} ?>/>
311 311
                         <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
312 312
 
313 313
                     </div>
314 314
                 </li>
315 315
                 <?php
316
-            }
316
+			}
317 317
 
318 318
 
319
-            // for_admin_use
320
-            if(has_filter("geodir_cfa_for_admin_use_{$field_type}")){
319
+			// for_admin_use
320
+			if(has_filter("geodir_cfa_for_admin_use_{$field_type}")){
321 321
 
322
-                echo apply_filters("geodir_cfa_for_admin_use_{$field_type}",'',$result_str,$cf,$field_info);
322
+				echo apply_filters("geodir_cfa_for_admin_use_{$field_type}",'',$result_str,$cf,$field_info);
323 323
 
324
-            }else{
325
-                $value = '';
326
-                if (isset($field_info->for_admin_use)) {
327
-                    $value = esc_attr($field_info->for_admin_use);
328
-                }elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
329
-                    $value = $cf['defaults']['for_admin_use'];
330
-                }
331
-                ?>
324
+			}else{
325
+				$value = '';
326
+				if (isset($field_info->for_admin_use)) {
327
+					$value = esc_attr($field_info->for_admin_use);
328
+				}elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
329
+					$value = $cf['defaults']['for_admin_use'];
330
+				}
331
+				?>
332 332
                 <li>
333 333
                     <label for="for_admin_use" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('For admin use only? :', 'geodirectory'); ?>
334 334
                         <div class="gdcf-tooltip">
@@ -339,47 +339,47 @@  discard block
 block discarded – undo
339 339
 
340 340
                         <input type="radio" id="for_admin_use_yes<?php echo $radio_id;?>" name="for_admin_use" class="gdri-enabled"  value="1"
341 341
                             <?php if ($value == '1') {
342
-                                echo 'checked';
343
-                            } ?>/>
342
+								echo 'checked';
343
+							} ?>/>
344 344
                         <label for="for_admin_use_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
345 345
 
346 346
                         <input type="radio" id="for_admin_use_no<?php echo $radio_id;?>" name="for_admin_use" class="gdri-disabled" value="0"
347 347
                             <?php if ($value == '0' || !$value) {
348
-                                echo 'checked';
349
-                            } ?>/>
348
+								echo 'checked';
349
+							} ?>/>
350 350
                         <label for="for_admin_use_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
351 351
 
352 352
                     </div>
353 353
                 </li>
354 354
                 <?php
355
-            }
355
+			}
356 356
 
357 357
 
358
-            // default_value
359
-            if(has_filter("geodir_cfa_default_value_{$field_type}")){
358
+			// default_value
359
+			if(has_filter("geodir_cfa_default_value_{$field_type}")){
360 360
 
361
-                echo apply_filters("geodir_cfa_default_value_{$field_type}",'',$result_str,$cf,$field_info);
361
+				echo apply_filters("geodir_cfa_default_value_{$field_type}",'',$result_str,$cf,$field_info);
362 362
 
363
-            }else{
364
-                $value = '';
365
-                if (isset($field_info->default_value)) {
366
-                    $value = esc_attr($field_info->default_value);
367
-                }elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
368
-                    $value = $cf['defaults']['default_value'];
369
-                }
370
-                ?>
363
+			}else{
364
+				$value = '';
365
+				if (isset($field_info->default_value)) {
366
+					$value = esc_attr($field_info->default_value);
367
+				}elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
368
+					$value = $cf['defaults']['default_value'];
369
+				}
370
+				?>
371 371
                 <li>
372 372
                     <label for="default_value" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Default value :', 'geodirectory');?>
373 373
                         <div class="gdcf-tooltip">
374 374
                             <?php
375
-                            if ($field_type == 'checkbox') {
376
-                                _e('Should the checkbox be checked by default?', 'geodirectory');
377
-                            } else if ($field_type == 'email') {
378
-                                _e('A default value for the field, usually blank. Ex: [email protected]', 'geodirectory');
379
-                            } else {
380
-                                _e('A default value for the field, usually blank. (for "link" this will be used as the link text)', 'geodirectory');
381
-                            }
382
-                            ?>
375
+							if ($field_type == 'checkbox') {
376
+								_e('Should the checkbox be checked by default?', 'geodirectory');
377
+							} else if ($field_type == 'email') {
378
+								_e('A default value for the field, usually blank. Ex: [email protected]', 'geodirectory');
379
+							} else {
380
+								_e('A default value for the field, usually blank. (for "link" this will be used as the link text)', 'geodirectory');
381
+							}
382
+							?>
383 383
                         </div>
384 384
                     </label>
385 385
                     <div class="gd-cf-input-wrap">
@@ -396,22 +396,22 @@  discard block
 block discarded – undo
396 396
                     </div>
397 397
                 </li>
398 398
                 <?php
399
-            }
399
+			}
400 400
 
401 401
 
402
-            // show_in
403
-            if(has_filter("geodir_cfa_show_in_{$field_type}")){
402
+			// show_in
403
+			if(has_filter("geodir_cfa_show_in_{$field_type}")){
404 404
 
405
-                echo apply_filters("geodir_cfa_show_in_{$field_type}",'',$result_str,$cf,$field_info);
405
+				echo apply_filters("geodir_cfa_show_in_{$field_type}",'',$result_str,$cf,$field_info);
406 406
 
407
-            }else{
408
-                $value = '';
409
-                if (isset($field_info->show_in)) {
410
-                    $value = esc_attr($field_info->show_in);
411
-                }elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
412
-                    $value = esc_attr($cf['defaults']['show_in']);
413
-                }
414
-                ?>
407
+			}else{
408
+				$value = '';
409
+				if (isset($field_info->show_in)) {
410
+					$value = esc_attr($field_info->show_in);
411
+				}elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
412
+					$value = esc_attr($cf['defaults']['show_in']);
413
+				}
414
+				?>
415 415
                 <li>
416 416
                     <label for="show_in" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Show in what locations?:', 'geodirectory'); ?>
417 417
                         <div class="gdcf-tooltip">
@@ -422,41 +422,41 @@  discard block
 block discarded – undo
422 422
 
423 423
                         <?php
424 424
 
425
-                        /*
425
+						/*
426 426
 						 * We wrap the key values in [] so we can search the DB easier with a LIKE query.
427 427
 						 */
428
-                        $show_in_locations = array(
429
-                            "[detail]" => __("Details page sidebar", 'geodirectory'),
430
-                            "[moreinfo]" => __("More info tab", 'geodirectory'),
431
-                            "[listing]" => __("Listings page", 'geodirectory'),
432
-                            "[owntab]" => __("Details page own tab", 'geodirectory'),
433
-                            "[mapbubble]" => __("Map bubble", 'geodirectory'),
434
-                        );
435
-
436
-                        /**
437
-                         * Filter the locations array for where to display custom fields.
438
-                         *
439
-                         * @since 1.6.6
440
-                         * @param array $show_in_locations The array of locations and descriptions.
441
-                         * @param object $field_info The field being displayed info.
442
-                         * @param string $field_info The type of field.
443
-                         */
444
-                        $show_in_locations = apply_filters('geodir_show_in_locations',$show_in_locations,$field_info,$field_type);
445
-
446
-
447
-                        // remove some locations for some field types
448
-
449
-                        // don't show new tab option for some types
450
-                        if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
451
-                        }else{
452
-                            unset($show_in_locations['[owntab]']);
453
-                        }
454
-
455
-                        if(!$display_on_listing){
456
-                            unset($show_in_locations['[listings]']);
457
-                        }
458
-
459
-                        ?>
428
+						$show_in_locations = array(
429
+							"[detail]" => __("Details page sidebar", 'geodirectory'),
430
+							"[moreinfo]" => __("More info tab", 'geodirectory'),
431
+							"[listing]" => __("Listings page", 'geodirectory'),
432
+							"[owntab]" => __("Details page own tab", 'geodirectory'),
433
+							"[mapbubble]" => __("Map bubble", 'geodirectory'),
434
+						);
435
+
436
+						/**
437
+						 * Filter the locations array for where to display custom fields.
438
+						 *
439
+						 * @since 1.6.6
440
+						 * @param array $show_in_locations The array of locations and descriptions.
441
+						 * @param object $field_info The field being displayed info.
442
+						 * @param string $field_info The type of field.
443
+						 */
444
+						$show_in_locations = apply_filters('geodir_show_in_locations',$show_in_locations,$field_info,$field_type);
445
+
446
+
447
+						// remove some locations for some field types
448
+
449
+						// don't show new tab option for some types
450
+						if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
451
+						}else{
452
+							unset($show_in_locations['[owntab]']);
453
+						}
454
+
455
+						if(!$display_on_listing){
456
+							unset($show_in_locations['[listings]']);
457
+						}
458
+
459
+						?>
460 460
 
461 461
                         <select multiple="multiple" name="show_in[]"
462 462
                                 id="show_in"
@@ -466,38 +466,38 @@  discard block
 block discarded – undo
466 466
                                 option-ajaxchosen="false">
467 467
                             <?php
468 468
 
469
-                            $show_in_values = explode(',',$value);
469
+							$show_in_values = explode(',',$value);
470 470
 
471
-                            foreach( $show_in_locations as $key => $val){
472
-                                $selected = '';
471
+							foreach( $show_in_locations as $key => $val){
472
+								$selected = '';
473 473
 
474
-                                if(is_array($show_in_values) && in_array($key,$show_in_values ) ){
475
-                                    $selected = 'selected';
476
-                                }
474
+								if(is_array($show_in_values) && in_array($key,$show_in_values ) ){
475
+									$selected = 'selected';
476
+								}
477 477
 
478
-                                ?>
478
+								?>
479 479
                                 <option  value="<?php echo $key;?>" <?php echo $selected;?>><?php echo $val;?></option>
480 480
                                 <?php
481
-                            }
482
-                            ?>
481
+							}
482
+							?>
483 483
                         </select>
484 484
                     </div>
485 485
                 </li>
486 486
                 <?php
487
-            }
487
+			}
488 488
 
489 489
 
490
-            // advanced_editor
491
-            if(has_filter("geodir_cfa_advanced_editor_{$field_type}")){
490
+			// advanced_editor
491
+			if(has_filter("geodir_cfa_advanced_editor_{$field_type}")){
492 492
 
493
-                echo apply_filters("geodir_cfa_advanced_editor_{$field_type}",'',$result_str,$cf,$field_info);
493
+				echo apply_filters("geodir_cfa_advanced_editor_{$field_type}",'',$result_str,$cf,$field_info);
494 494
 
495
-            }
495
+			}
496 496
 
497 497
 
498 498
 
499 499
 
500
-            ?>
500
+			?>
501 501
 
502 502
 
503 503
             <?php // @todo this does not seem to be used for anything, it can be removed or replaced ?>
@@ -510,38 +510,38 @@  discard block
 block discarded – undo
510 510
 
511 511
             <?php
512 512
 
513
-            $pricearr = array();
514
-            if (isset($field_info->packages) && $field_info->packages != '') {
515
-                $pricearr = explode(',', trim($field_info->packages, ','));
516
-            } else {
517
-                $package_info = array();
513
+			$pricearr = array();
514
+			if (isset($field_info->packages) && $field_info->packages != '') {
515
+				$pricearr = explode(',', trim($field_info->packages, ','));
516
+			} else {
517
+				$package_info = array();
518 518
 
519
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
520
-                $pricearr[] = $package_info->pid;
521
-            }
519
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
520
+				$pricearr[] = $package_info->pid;
521
+			}
522 522
 
523
-            ob_start()
524
-            ?>
523
+			ob_start()
524
+			?>
525 525
 
526 526
             <select style="display:none" name="show_on_pkg[]" id="show_on_pkg" multiple="multiple">
527 527
                 <?php
528
-                if (!empty($pricearr)) {
529
-                    foreach ($pricearr as $val) {
530
-                        ?>
528
+				if (!empty($pricearr)) {
529
+					foreach ($pricearr as $val) {
530
+						?>
531 531
                         <option selected="selected" value="<?php echo esc_attr($val); ?>" ><?php echo $val; ?></option><?php
532
-                    }
533
-                }
534
-                ?>
532
+					}
533
+				}
534
+				?>
535 535
             </select>
536 536
 
537 537
             <?php
538
-            $html = ob_get_clean();
538
+			$html = ob_get_clean();
539 539
 
540 540
 			/**
541 541
 			 * Filter the price packages list.
542 542
 			 *
543 543
 			 * Filter the price packages list in custom field form in admin
544
-             * custom fields settings.
544
+			 * custom fields settings.
545 545
 			 *
546 546
 			 * @since 1.0.0
547 547
 			 *
@@ -550,25 +550,25 @@  discard block
 block discarded – undo
550 550
 			 */
551 551
 			echo $html = apply_filters('geodir_packages_list_on_custom_fields', $html, $field_info);
552 552
 
553
-            ?>
553
+			?>
554 554
 
555 555
 
556 556
 
557 557
             <?php
558 558
 
559
-            // is_required
560
-            if(has_filter("geodir_cfa_is_required_{$field_type}")){
559
+			// is_required
560
+			if(has_filter("geodir_cfa_is_required_{$field_type}")){
561 561
 
562
-                echo apply_filters("geodir_cfa_is_required_{$field_type}",'',$result_str,$cf,$field_info);
562
+				echo apply_filters("geodir_cfa_is_required_{$field_type}",'',$result_str,$cf,$field_info);
563 563
 
564
-            }else{
565
-                $value = '';
566
-                if (isset($field_info->is_required)) {
567
-                    $value = esc_attr($field_info->is_required);
568
-                }elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
569
-                    $value = $cf['defaults']['is_required'];
570
-                }
571
-                ?>
564
+			}else{
565
+				$value = '';
566
+				if (isset($field_info->is_required)) {
567
+					$value = esc_attr($field_info->is_required);
568
+				}elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
569
+					$value = $cf['defaults']['is_required'];
570
+				}
571
+				?>
572 572
                 <li>
573 573
                     <label for="is_required" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Is required :', 'geodirectory'); ?>
574 574
                         <div class="gdcf-tooltip">
@@ -580,14 +580,14 @@  discard block
 block discarded – undo
580 580
 
581 581
                         <input type="radio" id="is_required_yes<?php echo $radio_id;?>" name="is_required" class="gdri-enabled"  value="1"
582 582
                             <?php if ($value == '1') {
583
-                                echo 'checked';
584
-                            } ?>/>
583
+								echo 'checked';
584
+							} ?>/>
585 585
                         <label onclick="show_hide_radio(this,'show','cf-is-required-msg');" for="is_required_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
586 586
 
587 587
                         <input type="radio" id="is_required_no<?php echo $radio_id;?>" name="is_required" class="gdri-disabled" value="0"
588 588
                             <?php if ($value == '0' || !$value) {
589
-                                echo 'checked';
590
-                            } ?>/>
589
+								echo 'checked';
590
+							} ?>/>
591 591
                         <label onclick="show_hide_radio(this,'hide','cf-is-required-msg');" for="is_required_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
592 592
 
593 593
                     </div>
@@ -595,21 +595,21 @@  discard block
 block discarded – undo
595 595
                 </li>
596 596
 
597 597
                 <?php
598
-            }
598
+			}
599 599
 
600
-            // required_msg
601
-            if(has_filter("geodir_cfa_required_msg_{$field_type}")){
600
+			// required_msg
601
+			if(has_filter("geodir_cfa_required_msg_{$field_type}")){
602 602
 
603
-                echo apply_filters("geodir_cfa_required_msg_{$field_type}",'',$result_str,$cf,$field_info);
603
+				echo apply_filters("geodir_cfa_required_msg_{$field_type}",'',$result_str,$cf,$field_info);
604 604
 
605
-            }else{
606
-                $value = '';
607
-                if (isset($field_info->required_msg)) {
608
-                    $value = esc_attr($field_info->required_msg);
609
-                }elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
610
-                    $value = $cf['defaults']['required_msg'];
611
-                }
612
-                ?>
605
+			}else{
606
+				$value = '';
607
+				if (isset($field_info->required_msg)) {
608
+					$value = esc_attr($field_info->required_msg);
609
+				}elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
610
+					$value = $cf['defaults']['required_msg'];
611
+				}
612
+				?>
613 613
                 <li class="cf-is-required-msg" <?php if ((isset($field_info->is_required) && $field_info->is_required == '0') || !isset($field_info->is_required)) {echo "style='display:none;'";}?>>
614 614
                     <label for="required_msg" class="gd-cf-tooltip-wrap">
615 615
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Required message:', 'geodirectory'); ?>
@@ -623,38 +623,38 @@  discard block
 block discarded – undo
623 623
                     </div>
624 624
                 </li>
625 625
                 <?php
626
-            }
626
+			}
627 627
 
628 628
 
629
-            // required_msg
630
-            if(has_filter("geodir_cfa_validation_pattern_{$field_type}")){
629
+			// required_msg
630
+			if(has_filter("geodir_cfa_validation_pattern_{$field_type}")){
631 631
 
632
-                echo apply_filters("geodir_cfa_validation_pattern_{$field_type}",'',$result_str,$cf,$field_info);
632
+				echo apply_filters("geodir_cfa_validation_pattern_{$field_type}",'',$result_str,$cf,$field_info);
633 633
 
634
-            }
634
+			}
635 635
 
636 636
 
637
-            // extra_fields
638
-            if(has_filter("geodir_cfa_extra_fields_{$field_type}")){
637
+			// extra_fields
638
+			if(has_filter("geodir_cfa_extra_fields_{$field_type}")){
639 639
 
640
-                echo apply_filters("geodir_cfa_extra_fields_{$field_type}",'',$result_str,$cf,$field_info);
640
+				echo apply_filters("geodir_cfa_extra_fields_{$field_type}",'',$result_str,$cf,$field_info);
641 641
 
642
-            }
642
+			}
643 643
 
644 644
 
645
-            // field_icon
646
-            if(has_filter("geodir_cfa_field_icon_{$field_type}")){
645
+			// field_icon
646
+			if(has_filter("geodir_cfa_field_icon_{$field_type}")){
647 647
 
648
-                echo apply_filters("geodir_cfa_field_icon_{$field_type}",'',$result_str,$cf,$field_info);
648
+				echo apply_filters("geodir_cfa_field_icon_{$field_type}",'',$result_str,$cf,$field_info);
649 649
 
650
-            }else{
651
-                $value = '';
652
-                if (isset($field_info->field_icon)) {
653
-                    $value = esc_attr($field_info->field_icon);
654
-                }elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
655
-                    $value = $cf['defaults']['field_icon'];
656
-                }
657
-                ?>
650
+			}else{
651
+				$value = '';
652
+				if (isset($field_info->field_icon)) {
653
+					$value = esc_attr($field_info->field_icon);
654
+				}elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
655
+					$value = $cf['defaults']['field_icon'];
656
+				}
657
+				?>
658 658
                 <li>
659 659
                     <h3><?php echo __('Custom css', 'geodirectory'); ?></h3>
660 660
 
@@ -672,22 +672,22 @@  discard block
 block discarded – undo
672 672
 
673 673
                 </li>
674 674
                 <?php
675
-            }
675
+			}
676 676
 
677 677
 
678
-            // css_class
679
-            if(has_filter("geodir_cfa_css_class_{$field_type}")){
678
+			// css_class
679
+			if(has_filter("geodir_cfa_css_class_{$field_type}")){
680 680
 
681
-                echo apply_filters("geodir_cfa_css_class_{$field_type}",'',$result_str,$cf,$field_info);
681
+				echo apply_filters("geodir_cfa_css_class_{$field_type}",'',$result_str,$cf,$field_info);
682 682
 
683
-            }else{
684
-                $value = '';
685
-                if (isset($field_info->css_class)) {
686
-                    $value = esc_attr($field_info->css_class);
687
-                }elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
688
-                    $value = $cf['defaults']['css_class'];
689
-                }
690
-                ?>
683
+			}else{
684
+				$value = '';
685
+				if (isset($field_info->css_class)) {
686
+					$value = esc_attr($field_info->css_class);
687
+				}elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
688
+					$value = $cf['defaults']['css_class'];
689
+				}
690
+				?>
691 691
                 <li>
692 692
 
693 693
                     <label for="css_class" class="gd-cf-tooltip-wrap">
@@ -700,47 +700,47 @@  discard block
 block discarded – undo
700 700
                     <div class="gd-cf-input-wrap">
701 701
                         <input type="text" name="css_class" id="css_class"
702 702
                                value="<?php if (isset($field_info->css_class)) {
703
-                                   echo esc_attr($field_info->css_class);
704
-                               }?>"/>
703
+								   echo esc_attr($field_info->css_class);
704
+							   }?>"/>
705 705
                     </div>
706 706
                 </li>
707 707
                 <?php
708
-            }
708
+			}
709 709
 
710 710
 
711
-            // cat_sort
712
-            if(has_filter("geodir_cfa_cat_sort_{$field_type}")){
711
+			// cat_sort
712
+			if(has_filter("geodir_cfa_cat_sort_{$field_type}")){
713 713
 
714
-                echo apply_filters("geodir_cfa_cat_sort_{$field_type}",'',$result_str,$cf,$field_info);
714
+				echo apply_filters("geodir_cfa_cat_sort_{$field_type}",'',$result_str,$cf,$field_info);
715 715
 
716
-            }else{
717
-                $value = '';
718
-                $hide_cat_sort  ='';
719
-                if (isset($field_info->cat_sort)) {
720
-                    $value = esc_attr($field_info->cat_sort);
721
-                }elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
722
-                    $value = $cf['defaults']['cat_sort'];
723
-                    $hide_cat_sort = ($value===false) ? "style='display:none;'" : '';
724
-                }
716
+			}else{
717
+				$value = '';
718
+				$hide_cat_sort  ='';
719
+				if (isset($field_info->cat_sort)) {
720
+					$value = esc_attr($field_info->cat_sort);
721
+				}elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
722
+					$value = $cf['defaults']['cat_sort'];
723
+					$hide_cat_sort = ($value===false) ? "style='display:none;'" : '';
724
+				}
725 725
 
726
-                $hide_cat_sort = (isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']===false) ? "style='display:none;'" : '';
727
-                ?>
726
+				$hide_cat_sort = (isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']===false) ? "style='display:none;'" : '';
727
+				?>
728 728
                 <li <?php echo $hide_cat_sort ;?>>
729 729
                     <h3><?php
730
-                        /**
731
-                         * Filter the section title.
732
-                         *
733
-                         * Filter the section title in custom field form in admin
734
-                         * custom fields settings.
735
-                         *
736
-                         * @since 1.0.0
737
-                         *
738
-                         * @param string $title Title of the section.
739
-                         * @param string $field_type Current field type.
740
-                         */
741
-                        echo apply_filters('geodir_advance_custom_fields_heading', __('Posts sort options', 'geodirectory'), $field_type);
742
-
743
-                        ?></h3>
730
+						/**
731
+						 * Filter the section title.
732
+						 *
733
+						 * Filter the section title in custom field form in admin
734
+						 * custom fields settings.
735
+						 *
736
+						 * @since 1.0.0
737
+						 *
738
+						 * @param string $title Title of the section.
739
+						 * @param string $field_type Current field type.
740
+						 */
741
+						echo apply_filters('geodir_advance_custom_fields_heading', __('Posts sort options', 'geodirectory'), $field_type);
742
+
743
+						?></h3>
744 744
                     <label for="cat_sort" class="gd-cf-tooltip-wrap">
745 745
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Include this field in sorting options :', 'geodirectory'); ?>
746 746
                         <div class="gdcf-tooltip">
@@ -752,42 +752,42 @@  discard block
 block discarded – undo
752 752
 
753 753
                         <input type="radio" id="cat_sort_yes<?php echo $radio_id;?>" name="cat_sort" class="gdri-enabled"  value="1"
754 754
                             <?php if ($value == '1') {
755
-                                echo 'checked';
756
-                            } ?>/>
755
+								echo 'checked';
756
+							} ?>/>
757 757
                         <label for="cat_sort_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
758 758
 
759 759
                         <input type="radio" id="cat_sort_no<?php echo $radio_id;?>" name="cat_sort" class="gdri-disabled" value="0"
760 760
                             <?php if (!$value) {
761
-                                echo 'checked';
762
-                            } ?>/>
761
+								echo 'checked';
762
+							} ?>/>
763 763
                         <label for="cat_sort_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
764 764
 
765 765
                     </div>
766 766
                 </li>
767 767
                 <?php
768
-            }
769
-
770
-
771
-
772
-            switch ($field_type):
773
-                case 'html':
774
-                case 'file':
775
-                case 'url':
776
-                case 'fieldset':
777
-                    break;
778
-                default:
779
-
780
-                    /**
781
-                     * Called at the end of the advanced custom fields settings page loop.
782
-                     *
783
-                     * Can be used to add or deal with different settings types.
784
-                     *
785
-                     * @since 1.0.0
786
-                     * @since 1.6.6 $cf param added.
787
-                     * @param object $field_info The current fields info.
788
-                     * @param array $cf The custom field settings
789
-                     */
790
-                    do_action('geodir_advance_custom_fields', $field_info,$cf);?>
768
+			}
769
+
770
+
771
+
772
+			switch ($field_type):
773
+				case 'html':
774
+				case 'file':
775
+				case 'url':
776
+				case 'fieldset':
777
+					break;
778
+				default:
779
+
780
+					/**
781
+					 * Called at the end of the advanced custom fields settings page loop.
782
+					 *
783
+					 * Can be used to add or deal with different settings types.
784
+					 *
785
+					 * @since 1.0.0
786
+					 * @since 1.6.6 $cf param added.
787
+					 * @param object $field_info The current fields info.
788
+					 * @param array $cf The custom field settings
789
+					 */
790
+					do_action('geodir_advance_custom_fields', $field_info,$cf);?>
791 791
 
792 792
 
793 793
                 <?php endswitch; ?>
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 $cf = (isset($cf_arr[$field_type_key])) ? $cf_arr[$field_type_key] : '';
40 40
 
41 41
 
42
-if(isset($field_info->extra_fields)){$extra_fields = $field_info->extra_fields;}
42
+if (isset($field_info->extra_fields)) {$extra_fields = $field_info->extra_fields; }
43 43
 $field_info = stripslashes_deep($field_info); // strip slashes from labels
44
-if(isset($field_info->extra_fields)){$field_info->extra_fields = $extra_fields;}
44
+if (isset($field_info->extra_fields)) {$field_info->extra_fields = $extra_fields; }
45 45
 
46 46
 
47
-$nonce = wp_create_nonce('custom_fields_' . $result_str);
47
+$nonce = wp_create_nonce('custom_fields_'.$result_str);
48 48
 
49 49
 $field_admin_title = '';
50 50
 if (isset($field_info->admin_title))
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 
70 70
 if (isset($cf['icon']) && strpos($cf['icon'], ' fa-') !== false) {
71 71
     $field_icon = '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
72
-}elseif(isset($cf['icon']) && $cf['icon']){
72
+}elseif (isset($cf['icon']) && $cf['icon']) {
73 73
     $field_icon = '<b class="gd-cf-icon" style="background-image: url(\''.$cf['icon'].'\')"></b>';
74
-}else{
74
+} else {
75 75
     $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>';
76 76
 }
77 77
 
78
-if(isset($cf['name']) && $cf['name']){
78
+if (isset($cf['name']) && $cf['name']) {
79 79
     $field_type_name = $cf['name'];
80
-}else{
80
+} else {
81 81
     $field_type_name = $field_type;
82 82
 }
83 83
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
          ondblclick="show_hide('field_frm<?php echo $result_str; ?>')" >
93 93
         <?php
94 94
 
95
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
95
+        $nonce = wp_create_nonce('custom_fields_'.$result_str);
96 96
         ?>
97 97
 
98 98
         <?php if (!$default): ?>
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
             <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i>
106 106
             <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i>
107 107
             <b style="cursor:pointer;"
108
-               onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(__('Fieldset:', 'geodirectory') . ' ' . $field_admin_title);?></b>
108
+               onclick="show_hide('field_frm<?php echo $result_str; ?>')"><?php echo geodir_ucwords(__('Fieldset:', 'geodirectory').' '.$field_admin_title); ?></b>
109 109
         <?php
110 110
         } else {echo $field_icon;
111 111
             ?>
112 112
             <b style="cursor:pointer;"
113
-               onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(' ' . $field_admin_title . ' (' . $field_type_name . ')');?></b>
113
+               onclick="show_hide('field_frm<?php echo $result_str; ?>')"><?php echo geodir_ucwords(' '.$field_admin_title.' ('.$field_type_name.')'); ?></b>
114 114
         <?php
115 115
         }
116 116
         ?>
@@ -133,43 +133,43 @@  discard block
 block discarded – undo
133 133
         } ?>"/>
134 134
         <input type="hidden" name="is_active" id="is_active" value="1"/>
135 135
 
136
-        <input type="hidden" name="is_default" value="<?php echo isset($field_info->is_default) ? $field_info->is_default : '';?>" /><?php // show in sidebar value?>
137
-        <input type="hidden" name="show_on_listing" value="<?php echo isset($field_info->show_on_listing) ? $field_info->show_on_listing : '';?>" />
138
-        <input type="hidden" name="show_on_detail" value="<?php echo isset($field_info->show_on_listing) ? $field_info->show_on_listing : '';?>" />
139
-        <input type="hidden" name="show_as_tab" value="<?php echo isset($field_info->show_as_tab) ? $field_info->show_as_tab : '';?>" />
136
+        <input type="hidden" name="is_default" value="<?php echo isset($field_info->is_default) ? $field_info->is_default : ''; ?>" /><?php // show in sidebar value?>
137
+        <input type="hidden" name="show_on_listing" value="<?php echo isset($field_info->show_on_listing) ? $field_info->show_on_listing : ''; ?>" />
138
+        <input type="hidden" name="show_on_detail" value="<?php echo isset($field_info->show_on_listing) ? $field_info->show_on_listing : ''; ?>" />
139
+        <input type="hidden" name="show_as_tab" value="<?php echo isset($field_info->show_as_tab) ? $field_info->show_as_tab : ''; ?>" />
140 140
 
141 141
         <ul class="widefat post fixed" border="0" style="width:100%;">
142 142
 
143 143
             <?php
144 144
 
145 145
             // data_type
146
-            if(has_filter("geodir_cfa_data_type_{$field_type}")){
146
+            if (has_filter("geodir_cfa_data_type_{$field_type}")) {
147 147
 
148
-                echo apply_filters("geodir_cfa_data_type_{$field_type}",'',$result_str,$cf,$field_info);
148
+                echo apply_filters("geodir_cfa_data_type_{$field_type}", '', $result_str, $cf, $field_info);
149 149
 
150
-            }else{
150
+            } else {
151 151
                 $value = '';
152 152
                 if (isset($field_info->data_type)) {
153 153
                     $value = esc_attr($field_info->data_type);
154
-                }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
154
+                }elseif (isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']) {
155 155
                     $value = $cf['defaults']['data_type'];
156 156
                 }
157 157
                 ?>
158
-                <input type="hidden" name="data_type" id="data_type" value="<?php echo $value;?>"/>
158
+                <input type="hidden" name="data_type" id="data_type" value="<?php echo $value; ?>"/>
159 159
             <?php
160 160
             }
161 161
 
162 162
 
163 163
             // admin_title
164
-            if(has_filter("geodir_cfa_admin_title_{$field_type}")){
164
+            if (has_filter("geodir_cfa_admin_title_{$field_type}")) {
165 165
 
166
-                echo apply_filters("geodir_cfa_admin_title_{$field_type}",'',$result_str,$cf,$field_info);
166
+                echo apply_filters("geodir_cfa_admin_title_{$field_type}", '', $result_str, $cf, $field_info);
167 167
 
168
-            }else{
168
+            } else {
169 169
                 $value = '';
170 170
                 if (isset($field_info->admin_title)) {
171 171
                     $value = esc_attr($field_info->admin_title);
172
-                }elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
172
+                }elseif (isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']) {
173 173
                     $value = $cf['defaults']['admin_title'];
174 174
                 }
175 175
                 ?>
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                     </label>
183 183
                     <div class="gd-cf-input-wrap">
184 184
                         <input type="text" name="admin_title" id="admin_title"
185
-                               value="<?php echo $value;?>"/>
185
+                               value="<?php echo $value; ?>"/>
186 186
                     </div>
187 187
                 </li>
188 188
                 <?php
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 
191 191
 
192 192
             // site_title
193
-            if(has_filter("geodir_cfa_site_title_{$field_type}")){
193
+            if (has_filter("geodir_cfa_site_title_{$field_type}")) {
194 194
 
195
-                echo apply_filters("geodir_cfa_site_title_{$field_type}",'',$result_str,$cf,$field_info);
195
+                echo apply_filters("geodir_cfa_site_title_{$field_type}", '', $result_str, $cf, $field_info);
196 196
 
197
-            }else{
197
+            } else {
198 198
                 $value = '';
199 199
                 if (isset($field_info->site_title)) {
200 200
                     $value = esc_attr($field_info->site_title);
201
-                }elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
201
+                }elseif (isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']) {
202 202
                     $value = $cf['defaults']['site_title'];
203 203
                 }
204 204
                 ?>
@@ -218,15 +218,15 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
             // admin_desc
221
-            if(has_filter("geodir_cfa_admin_desc_{$field_type}")){
221
+            if (has_filter("geodir_cfa_admin_desc_{$field_type}")) {
222 222
 
223
-                echo apply_filters("geodir_cfa_admin_desc_{$field_type}",'',$result_str,$cf,$field_info);
223
+                echo apply_filters("geodir_cfa_admin_desc_{$field_type}", '', $result_str, $cf, $field_info);
224 224
 
225
-            }else{
225
+            } else {
226 226
                 $value = '';
227 227
                 if (isset($field_info->admin_desc)) {
228 228
                     $value = esc_attr($field_info->admin_desc);
229
-                }elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
229
+                }elseif (isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']) {
230 230
                     $value = $cf['defaults']['admin_desc'];
231 231
                 }
232 232
                 ?>
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                         </div>
238 238
                     </label>
239 239
                     <div class="gd-cf-input-wrap">
240
-                        <input type="text" name="admin_desc" id="admin_desc" value="<?php echo $value;?>"/>
240
+                        <input type="text" name="admin_desc" id="admin_desc" value="<?php echo $value; ?>"/>
241 241
                     </div>
242 242
                 </li>
243 243
                 <?php
@@ -246,26 +246,26 @@  discard block
 block discarded – undo
246 246
 
247 247
 
248 248
             // htmlvar_name
249
-            if(has_filter("geodir_cfa_htmlvar_name_{$field_type}")){
249
+            if (has_filter("geodir_cfa_htmlvar_name_{$field_type}")) {
250 250
 
251
-                echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info);
251
+                echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}", '', $result_str, $cf, $field_info);
252 252
 
253
-            }else{
253
+            } else {
254 254
                 $value = '';
255 255
                 if (isset($field_info->htmlvar_name)) {
256 256
                     $value = esc_attr($field_info->htmlvar_name);
257
-                }elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
257
+                }elseif (isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']) {
258 258
                     $value = $cf['defaults']['htmlvar_name'];
259 259
                 }
260 260
                 ?>
261 261
                 <li>
262
-                    <label for="htmlvar_name" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('HTML variable name :', 'geodirectory');?>
262
+                    <label for="htmlvar_name" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('HTML variable name :', 'geodirectory'); ?>
263 263
                         <div class="gdcf-tooltip">
264 264
                             <?php _e('This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.', 'geodirectory'); ?>
265 265
                         </div>
266 266
                     </label>
267 267
                     <div class="gd-cf-input-wrap">
268
-                        <input type="text" name="htmlvar_name" id="htmlvar_name" pattern="[a-zA-Z0-9]+" title="<?php _e('Must not contain spaces or special characters', 'geodirectory');?>"
268
+                        <input type="text" name="htmlvar_name" id="htmlvar_name" pattern="[a-zA-Z0-9]+" title="<?php _e('Must not contain spaces or special characters', 'geodirectory'); ?>"
269 269
                                value="<?php if ($value) {
270 270
                                    echo preg_replace('/geodir_/', '', $value, 1);
271 271
                                }?>" <?php if ($default) {
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
 
279 279
 
280 280
             // is_active
281
-            if(has_filter("geodir_cfa_is_active_{$field_type}")){
281
+            if (has_filter("geodir_cfa_is_active_{$field_type}")) {
282 282
 
283
-                echo apply_filters("geodir_cfa_is_active_{$field_type}",'',$result_str,$cf,$field_info);
283
+                echo apply_filters("geodir_cfa_is_active_{$field_type}", '', $result_str, $cf, $field_info);
284 284
 
285
-            }else{
285
+            } else {
286 286
                 $value = '';
287 287
                 if (isset($field_info->is_active)) {
288 288
                     $value = esc_attr($field_info->is_active);
289
-                }elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
289
+                }elseif (isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']) {
290 290
                     $value = $cf['defaults']['is_active'];
291 291
                 }
292 292
                 ?>
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
                     </label>
299 299
                     <div class="gd-cf-input-wrap gd-switch">
300 300
 
301
-                        <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled"  value="1"
301
+                        <input type="radio" id="is_active_yes<?php echo $radio_id; ?>" name="is_active" class="gdri-enabled"  value="1"
302 302
                             <?php if ($value == '1') {
303 303
                                 echo 'checked';
304 304
                             } ?>/>
305
-                        <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
305
+                        <label for="is_active_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
306 306
 
307
-                        <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0"
307
+                        <input type="radio" id="is_active_no<?php echo $radio_id; ?>" name="is_active" class="gdri-disabled" value="0"
308 308
                             <?php if ($value == '0' || !$value) {
309 309
                                 echo 'checked';
310 310
                             } ?>/>
311
-                        <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
311
+                        <label for="is_active_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
312 312
 
313 313
                     </div>
314 314
                 </li>
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
 
318 318
 
319 319
             // for_admin_use
320
-            if(has_filter("geodir_cfa_for_admin_use_{$field_type}")){
320
+            if (has_filter("geodir_cfa_for_admin_use_{$field_type}")) {
321 321
 
322
-                echo apply_filters("geodir_cfa_for_admin_use_{$field_type}",'',$result_str,$cf,$field_info);
322
+                echo apply_filters("geodir_cfa_for_admin_use_{$field_type}", '', $result_str, $cf, $field_info);
323 323
 
324
-            }else{
324
+            } else {
325 325
                 $value = '';
326 326
                 if (isset($field_info->for_admin_use)) {
327 327
                     $value = esc_attr($field_info->for_admin_use);
328
-                }elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
328
+                }elseif (isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']) {
329 329
                     $value = $cf['defaults']['for_admin_use'];
330 330
                 }
331 331
                 ?>
@@ -337,17 +337,17 @@  discard block
 block discarded – undo
337 337
                     </label>
338 338
                     <div class="gd-cf-input-wrap gd-switch">
339 339
 
340
-                        <input type="radio" id="for_admin_use_yes<?php echo $radio_id;?>" name="for_admin_use" class="gdri-enabled"  value="1"
340
+                        <input type="radio" id="for_admin_use_yes<?php echo $radio_id; ?>" name="for_admin_use" class="gdri-enabled"  value="1"
341 341
                             <?php if ($value == '1') {
342 342
                                 echo 'checked';
343 343
                             } ?>/>
344
-                        <label for="for_admin_use_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
344
+                        <label for="for_admin_use_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
345 345
 
346
-                        <input type="radio" id="for_admin_use_no<?php echo $radio_id;?>" name="for_admin_use" class="gdri-disabled" value="0"
346
+                        <input type="radio" id="for_admin_use_no<?php echo $radio_id; ?>" name="for_admin_use" class="gdri-disabled" value="0"
347 347
                             <?php if ($value == '0' || !$value) {
348 348
                                 echo 'checked';
349 349
                             } ?>/>
350
-                        <label for="for_admin_use_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
350
+                        <label for="for_admin_use_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
351 351
 
352 352
                     </div>
353 353
                 </li>
@@ -356,20 +356,20 @@  discard block
 block discarded – undo
356 356
 
357 357
 
358 358
             // default_value
359
-            if(has_filter("geodir_cfa_default_value_{$field_type}")){
359
+            if (has_filter("geodir_cfa_default_value_{$field_type}")) {
360 360
 
361
-                echo apply_filters("geodir_cfa_default_value_{$field_type}",'',$result_str,$cf,$field_info);
361
+                echo apply_filters("geodir_cfa_default_value_{$field_type}", '', $result_str, $cf, $field_info);
362 362
 
363
-            }else{
363
+            } else {
364 364
                 $value = '';
365 365
                 if (isset($field_info->default_value)) {
366 366
                     $value = esc_attr($field_info->default_value);
367
-                }elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
367
+                }elseif (isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']) {
368 368
                     $value = $cf['defaults']['default_value'];
369 369
                 }
370 370
                 ?>
371 371
                 <li>
372
-                    <label for="default_value" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Default value :', 'geodirectory');?>
372
+                    <label for="default_value" class="gd-cf-tooltip-wrap"><i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Default value :', 'geodirectory'); ?>
373 373
                         <div class="gdcf-tooltip">
374 374
                             <?php
375 375
                             if ($field_type == 'checkbox') {
@@ -386,12 +386,12 @@  discard block
 block discarded – undo
386 386
                         <?php if ($field_type == 'checkbox') { ?>
387 387
                             <select name="default_value" id="default_value">
388 388
                                 <option value=""><?php _e('Unchecked', 'geodirectory'); ?></option>
389
-                                <option value="1" <?php selected(true, (int)$value === 1);?>><?php _e('Checked', 'geodirectory'); ?></option>
389
+                                <option value="1" <?php selected(true, (int) $value === 1); ?>><?php _e('Checked', 'geodirectory'); ?></option>
390 390
                             </select>
391 391
                         <?php } else if ($field_type == 'email') { ?>
392
-                            <input type="email" name="default_value" placeholder="<?php _e('[email protected]', 'geodirectory') ;?>" id="default_value" value="<?php echo esc_attr($value);?>" /><br/>
392
+                            <input type="email" name="default_value" placeholder="<?php _e('[email protected]', 'geodirectory'); ?>" id="default_value" value="<?php echo esc_attr($value); ?>" /><br/>
393 393
                         <?php } else { ?>
394
-                            <input type="text" name="default_value" id="default_value" value="<?php echo esc_attr($value);?>" /><br/>
394
+                            <input type="text" name="default_value" id="default_value" value="<?php echo esc_attr($value); ?>" /><br/>
395 395
                         <?php } ?>
396 396
                     </div>
397 397
                 </li>
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
 
401 401
 
402 402
             // show_in
403
-            if(has_filter("geodir_cfa_show_in_{$field_type}")){
403
+            if (has_filter("geodir_cfa_show_in_{$field_type}")) {
404 404
 
405
-                echo apply_filters("geodir_cfa_show_in_{$field_type}",'',$result_str,$cf,$field_info);
405
+                echo apply_filters("geodir_cfa_show_in_{$field_type}", '', $result_str, $cf, $field_info);
406 406
 
407
-            }else{
407
+            } else {
408 408
                 $value = '';
409 409
                 if (isset($field_info->show_in)) {
410 410
                     $value = esc_attr($field_info->show_in);
411
-                }elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
411
+                }elseif (isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']) {
412 412
                     $value = esc_attr($cf['defaults']['show_in']);
413 413
                 }
414 414
                 ?>
@@ -441,18 +441,18 @@  discard block
 block discarded – undo
441 441
                          * @param object $field_info The field being displayed info.
442 442
                          * @param string $field_info The type of field.
443 443
                          */
444
-                        $show_in_locations = apply_filters('geodir_show_in_locations',$show_in_locations,$field_info,$field_type);
444
+                        $show_in_locations = apply_filters('geodir_show_in_locations', $show_in_locations, $field_info, $field_type);
445 445
 
446 446
 
447 447
                         // remove some locations for some field types
448 448
 
449 449
                         // don't show new tab option for some types
450
-                        if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
451
-                        }else{
450
+                        if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) {
451
+                        } else {
452 452
                             unset($show_in_locations['[owntab]']);
453 453
                         }
454 454
 
455
-                        if(!$display_on_listing){
455
+                        if (!$display_on_listing) {
456 456
                             unset($show_in_locations['[listings]']);
457 457
                         }
458 458
 
@@ -466,17 +466,17 @@  discard block
 block discarded – undo
466 466
                                 option-ajaxchosen="false">
467 467
                             <?php
468 468
 
469
-                            $show_in_values = explode(',',$value);
469
+                            $show_in_values = explode(',', $value);
470 470
 
471
-                            foreach( $show_in_locations as $key => $val){
471
+                            foreach ($show_in_locations as $key => $val) {
472 472
                                 $selected = '';
473 473
 
474
-                                if(is_array($show_in_values) && in_array($key,$show_in_values ) ){
474
+                                if (is_array($show_in_values) && in_array($key, $show_in_values)) {
475 475
                                     $selected = 'selected';
476 476
                                 }
477 477
 
478 478
                                 ?>
479
-                                <option  value="<?php echo $key;?>" <?php echo $selected;?>><?php echo $val;?></option>
479
+                                <option  value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $val; ?></option>
480 480
                                 <?php
481 481
                             }
482 482
                             ?>
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
 
489 489
 
490 490
             // advanced_editor
491
-            if(has_filter("geodir_cfa_advanced_editor_{$field_type}")){
491
+            if (has_filter("geodir_cfa_advanced_editor_{$field_type}")) {
492 492
 
493
-                echo apply_filters("geodir_cfa_advanced_editor_{$field_type}",'',$result_str,$cf,$field_info);
493
+                echo apply_filters("geodir_cfa_advanced_editor_{$field_type}", '', $result_str, $cf, $field_info);
494 494
 
495 495
             }
496 496
 
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
 
502 502
 
503 503
             <?php // @todo this does not seem to be used for anything, it can be removed or replaced ?>
504
-            <input type="hidden" name="clabels" id="clabels" value="<?php if (isset($field_info->clabels)) { echo esc_attr($field_info->clabels);} ?>"/>
504
+            <input type="hidden" name="clabels" id="clabels" value="<?php if (isset($field_info->clabels)) { echo esc_attr($field_info->clabels); } ?>"/>
505 505
 
506 506
             <?php // we dont need to show the sort order ?>
507
-            <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" value="<?php if (isset($field_info->sort_order)) { echo esc_attr($field_info->sort_order);} ?>"/>
507
+            <input type="hidden" readonly="readonly" name="sort_order" id="sort_order" value="<?php if (isset($field_info->sort_order)) { echo esc_attr($field_info->sort_order); } ?>"/>
508 508
 
509 509
 
510 510
 
@@ -557,15 +557,15 @@  discard block
 block discarded – undo
557 557
             <?php
558 558
 
559 559
             // is_required
560
-            if(has_filter("geodir_cfa_is_required_{$field_type}")){
560
+            if (has_filter("geodir_cfa_is_required_{$field_type}")) {
561 561
 
562
-                echo apply_filters("geodir_cfa_is_required_{$field_type}",'',$result_str,$cf,$field_info);
562
+                echo apply_filters("geodir_cfa_is_required_{$field_type}", '', $result_str, $cf, $field_info);
563 563
 
564
-            }else{
564
+            } else {
565 565
                 $value = '';
566 566
                 if (isset($field_info->is_required)) {
567 567
                     $value = esc_attr($field_info->is_required);
568
-                }elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
568
+                }elseif (isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']) {
569 569
                     $value = $cf['defaults']['is_required'];
570 570
                 }
571 571
                 ?>
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
 
579 579
                     <div class="gd-cf-input-wrap gd-switch">
580 580
 
581
-                        <input type="radio" id="is_required_yes<?php echo $radio_id;?>" name="is_required" class="gdri-enabled"  value="1"
581
+                        <input type="radio" id="is_required_yes<?php echo $radio_id; ?>" name="is_required" class="gdri-enabled"  value="1"
582 582
                             <?php if ($value == '1') {
583 583
                                 echo 'checked';
584 584
                             } ?>/>
585
-                        <label onclick="show_hide_radio(this,'show','cf-is-required-msg');" for="is_required_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
585
+                        <label onclick="show_hide_radio(this,'show','cf-is-required-msg');" for="is_required_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
586 586
 
587
-                        <input type="radio" id="is_required_no<?php echo $radio_id;?>" name="is_required" class="gdri-disabled" value="0"
587
+                        <input type="radio" id="is_required_no<?php echo $radio_id; ?>" name="is_required" class="gdri-disabled" value="0"
588 588
                             <?php if ($value == '0' || !$value) {
589 589
                                 echo 'checked';
590 590
                             } ?>/>
591
-                        <label onclick="show_hide_radio(this,'hide','cf-is-required-msg');" for="is_required_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
591
+                        <label onclick="show_hide_radio(this,'hide','cf-is-required-msg');" for="is_required_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
592 592
 
593 593
                     </div>
594 594
 
@@ -598,19 +598,19 @@  discard block
 block discarded – undo
598 598
             }
599 599
 
600 600
             // required_msg
601
-            if(has_filter("geodir_cfa_required_msg_{$field_type}")){
601
+            if (has_filter("geodir_cfa_required_msg_{$field_type}")) {
602 602
 
603
-                echo apply_filters("geodir_cfa_required_msg_{$field_type}",'',$result_str,$cf,$field_info);
603
+                echo apply_filters("geodir_cfa_required_msg_{$field_type}", '', $result_str, $cf, $field_info);
604 604
 
605
-            }else{
605
+            } else {
606 606
                 $value = '';
607 607
                 if (isset($field_info->required_msg)) {
608 608
                     $value = esc_attr($field_info->required_msg);
609
-                }elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
609
+                }elseif (isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']) {
610 610
                     $value = $cf['defaults']['required_msg'];
611 611
                 }
612 612
                 ?>
613
-                <li class="cf-is-required-msg" <?php if ((isset($field_info->is_required) && $field_info->is_required == '0') || !isset($field_info->is_required)) {echo "style='display:none;'";}?>>
613
+                <li class="cf-is-required-msg" <?php if ((isset($field_info->is_required) && $field_info->is_required == '0') || !isset($field_info->is_required)) {echo "style='display:none;'"; }?>>
614 614
                     <label for="required_msg" class="gd-cf-tooltip-wrap">
615 615
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Required message:', 'geodirectory'); ?>
616 616
                         <div class="gdcf-tooltip">
@@ -627,31 +627,31 @@  discard block
 block discarded – undo
627 627
 
628 628
 
629 629
             // required_msg
630
-            if(has_filter("geodir_cfa_validation_pattern_{$field_type}")){
630
+            if (has_filter("geodir_cfa_validation_pattern_{$field_type}")) {
631 631
 
632
-                echo apply_filters("geodir_cfa_validation_pattern_{$field_type}",'',$result_str,$cf,$field_info);
632
+                echo apply_filters("geodir_cfa_validation_pattern_{$field_type}", '', $result_str, $cf, $field_info);
633 633
 
634 634
             }
635 635
 
636 636
 
637 637
             // extra_fields
638
-            if(has_filter("geodir_cfa_extra_fields_{$field_type}")){
638
+            if (has_filter("geodir_cfa_extra_fields_{$field_type}")) {
639 639
 
640
-                echo apply_filters("geodir_cfa_extra_fields_{$field_type}",'',$result_str,$cf,$field_info);
640
+                echo apply_filters("geodir_cfa_extra_fields_{$field_type}", '', $result_str, $cf, $field_info);
641 641
 
642 642
             }
643 643
 
644 644
 
645 645
             // field_icon
646
-            if(has_filter("geodir_cfa_field_icon_{$field_type}")){
646
+            if (has_filter("geodir_cfa_field_icon_{$field_type}")) {
647 647
 
648
-                echo apply_filters("geodir_cfa_field_icon_{$field_type}",'',$result_str,$cf,$field_info);
648
+                echo apply_filters("geodir_cfa_field_icon_{$field_type}", '', $result_str, $cf, $field_info);
649 649
 
650
-            }else{
650
+            } else {
651 651
                 $value = '';
652 652
                 if (isset($field_info->field_icon)) {
653 653
                     $value = esc_attr($field_info->field_icon);
654
-                }elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
654
+                }elseif (isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']) {
655 655
                     $value = $cf['defaults']['field_icon'];
656 656
                 }
657 657
                 ?>
@@ -662,12 +662,12 @@  discard block
 block discarded – undo
662 662
                     <label for="field_icon" class="gd-cf-tooltip-wrap">
663 663
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Upload icon :', 'geodirectory'); ?>
664 664
                         <div class="gdcf-tooltip">
665
-                            <?php _e('Upload icon using media and enter its url path, or enter <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank" >font awesome </a>class eg:"fas fa-home"', 'geodirectory');?>
665
+                            <?php _e('Upload icon using media and enter its url path, or enter <a href="http://fortawesome.github.io/Font-Awesome/icons/" target="_blank" >font awesome </a>class eg:"fas fa-home"', 'geodirectory'); ?>
666 666
                         </div>
667 667
                     </label>
668 668
                     <div class="gd-cf-input-wrap">
669 669
                         <input type="text" name="field_icon" id="field_icon"
670
-                               value="<?php echo $value;?>"/>
670
+                               value="<?php echo $value; ?>"/>
671 671
                     </div>
672 672
 
673 673
                 </li>
@@ -676,15 +676,15 @@  discard block
 block discarded – undo
676 676
 
677 677
 
678 678
             // css_class
679
-            if(has_filter("geodir_cfa_css_class_{$field_type}")){
679
+            if (has_filter("geodir_cfa_css_class_{$field_type}")) {
680 680
 
681
-                echo apply_filters("geodir_cfa_css_class_{$field_type}",'',$result_str,$cf,$field_info);
681
+                echo apply_filters("geodir_cfa_css_class_{$field_type}", '', $result_str, $cf, $field_info);
682 682
 
683
-            }else{
683
+            } else {
684 684
                 $value = '';
685 685
                 if (isset($field_info->css_class)) {
686 686
                     $value = esc_attr($field_info->css_class);
687
-                }elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
687
+                }elseif (isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']) {
688 688
                     $value = $cf['defaults']['css_class'];
689 689
                 }
690 690
                 ?>
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
                     <label for="css_class" class="gd-cf-tooltip-wrap">
694 694
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Css class :', 'geodirectory'); ?>
695 695
                         <div class="gdcf-tooltip">
696
-                            <?php _e('Enter custom css class for field custom style.', 'geodirectory');?>
697
-                            <?php if($field_type=='multiselect'){_e('(Enter class `gd-comma-list` to show list as comma separated)', 'geodirectory');}?>
696
+                            <?php _e('Enter custom css class for field custom style.', 'geodirectory'); ?>
697
+                            <?php if ($field_type == 'multiselect') {_e('(Enter class `gd-comma-list` to show list as comma separated)', 'geodirectory'); }?>
698 698
                         </div>
699 699
                     </label>
700 700
                     <div class="gd-cf-input-wrap">
@@ -709,23 +709,23 @@  discard block
 block discarded – undo
709 709
 
710 710
 
711 711
             // cat_sort
712
-            if(has_filter("geodir_cfa_cat_sort_{$field_type}")){
712
+            if (has_filter("geodir_cfa_cat_sort_{$field_type}")) {
713 713
 
714
-                echo apply_filters("geodir_cfa_cat_sort_{$field_type}",'',$result_str,$cf,$field_info);
714
+                echo apply_filters("geodir_cfa_cat_sort_{$field_type}", '', $result_str, $cf, $field_info);
715 715
 
716
-            }else{
716
+            } else {
717 717
                 $value = '';
718
-                $hide_cat_sort  ='';
718
+                $hide_cat_sort = '';
719 719
                 if (isset($field_info->cat_sort)) {
720 720
                     $value = esc_attr($field_info->cat_sort);
721
-                }elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
721
+                }elseif (isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']) {
722 722
                     $value = $cf['defaults']['cat_sort'];
723
-                    $hide_cat_sort = ($value===false) ? "style='display:none;'" : '';
723
+                    $hide_cat_sort = ($value === false) ? "style='display:none;'" : '';
724 724
                 }
725 725
 
726
-                $hide_cat_sort = (isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']===false) ? "style='display:none;'" : '';
726
+                $hide_cat_sort = (isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort'] === false) ? "style='display:none;'" : '';
727 727
                 ?>
728
-                <li <?php echo $hide_cat_sort ;?>>
728
+                <li <?php echo $hide_cat_sort; ?>>
729 729
                     <h3><?php
730 730
                         /**
731 731
                          * Filter the section title.
@@ -744,23 +744,23 @@  discard block
 block discarded – undo
744 744
                     <label for="cat_sort" class="gd-cf-tooltip-wrap">
745 745
                         <i class="fas fa-info-circle" aria-hidden="true"></i> <?php _e('Include this field in sorting options :', 'geodirectory'); ?>
746 746
                         <div class="gdcf-tooltip">
747
-                            <?php _e('Lets you use this filed as a sorting option, set from sorting options above.', 'geodirectory');?>
747
+                            <?php _e('Lets you use this filed as a sorting option, set from sorting options above.', 'geodirectory'); ?>
748 748
                         </div>
749 749
                     </label>
750 750
 
751 751
                     <div class="gd-cf-input-wrap gd-switch">
752 752
 
753
-                        <input type="radio" id="cat_sort_yes<?php echo $radio_id;?>" name="cat_sort" class="gdri-enabled"  value="1"
753
+                        <input type="radio" id="cat_sort_yes<?php echo $radio_id; ?>" name="cat_sort" class="gdri-enabled"  value="1"
754 754
                             <?php if ($value == '1') {
755 755
                                 echo 'checked';
756 756
                             } ?>/>
757
-                        <label for="cat_sort_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
757
+                        <label for="cat_sort_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
758 758
 
759
-                        <input type="radio" id="cat_sort_no<?php echo $radio_id;?>" name="cat_sort" class="gdri-disabled" value="0"
759
+                        <input type="radio" id="cat_sort_no<?php echo $radio_id; ?>" name="cat_sort" class="gdri-disabled" value="0"
760 760
                             <?php if (!$value) {
761 761
                                 echo 'checked';
762 762
                             } ?>/>
763
-                        <label for="cat_sort_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
763
+                        <label for="cat_sort_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
764 764
 
765 765
                     </div>
766 766
                 </li>
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
                      * @param object $field_info The current fields info.
788 788
                      * @param array $cf The custom field settings
789 789
                      */
790
-                    do_action('geodir_advance_custom_fields', $field_info,$cf);?>
790
+                    do_action('geodir_advance_custom_fields', $field_info, $cf); ?>
791 791
 
792 792
 
793 793
                 <?php endswitch; ?>
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
                     <h3></h3>
800 800
                 </label>
801 801
                 <div class="gd-cf-input-wrap">
802
-                    <input type="button" class="button button-primary" name="save" id="save" value="<?php echo esc_attr(__('Save','geodirectory'));?>"
802
+                    <input type="button" class="button button-primary" name="save" id="save" value="<?php echo esc_attr(__('Save', 'geodirectory')); ?>"
803 803
                            onclick="save_field('<?php echo esc_attr($result_str); ?>')"/>
804 804
                     <?php if (!$default): ?>
805
-                        <a href="javascript:void(0)"><input type="button" name="delete" value="<?php echo esc_attr(__('Delete','geodirectory'));?>"
805
+                        <a href="javascript:void(0)"><input type="button" name="delete" value="<?php echo esc_attr(__('Delete', 'geodirectory')); ?>"
806 806
                                                             onclick="delete_field('<?php echo esc_attr($result_str); ?>', '<?php echo $nonce; ?>')"
807 807
                                                             class="button"/></a>
808 808
                     <?php endif; ?>
Please login to merge, or discard this patch.
Braces   +38 added lines, -36 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
 if (!isset($field_info->post_type)) {
21 21
     $post_type = sanitize_text_field($_REQUEST['listing_type']);
22
-} else
23
-    $post_type = $field_info->post_type;
22
+} else {
23
+    $post_type = $field_info->post_type;
24
+}
24 25
 
25 26
 //if(isset($_REQUEST['custom_type']) && $_REQUEST['custom_type']=='predefined'){
26 27
 //    $cf_arr = geodir_custom_fields_predefined($post_type);
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
 $nonce = wp_create_nonce('custom_fields_' . $result_str);
48 49
 
49 50
 $field_admin_title = '';
50
-if (isset($field_info->admin_title))
51
-    $field_admin_title = $field_info->admin_title;
51
+if (isset($field_info->admin_title)) {
52
+    $field_admin_title = $field_info->admin_title;
53
+}
52 54
 
53 55
 $default = isset($field_info->is_admin) ? $field_info->is_admin : '';
54 56
 
@@ -69,15 +71,15 @@  discard block
 block discarded – undo
69 71
 
70 72
 if (isset($cf['icon']) && strpos($cf['icon'], ' fa-') !== false) {
71 73
     $field_icon = '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
72
-}elseif(isset($cf['icon']) && $cf['icon']){
74
+} elseif(isset($cf['icon']) && $cf['icon']){
73 75
     $field_icon = '<b class="gd-cf-icon" style="background-image: url(\''.$cf['icon'].'\')"></b>';
74
-}else{
76
+} else{
75 77
     $field_icon = '<i class="fas fa-cog" aria-hidden="true"></i>';
76 78
 }
77 79
 
78 80
 if(isset($cf['name']) && $cf['name']){
79 81
     $field_type_name = $cf['name'];
80
-}else{
82
+} else{
81 83
     $field_type_name = $field_type;
82 84
 }
83 85
 
@@ -147,11 +149,11 @@  discard block
 block discarded – undo
147 149
 
148 150
                 echo apply_filters("geodir_cfa_data_type_{$field_type}",'',$result_str,$cf,$field_info);
149 151
 
150
-            }else{
152
+            } else{
151 153
                 $value = '';
152 154
                 if (isset($field_info->data_type)) {
153 155
                     $value = esc_attr($field_info->data_type);
154
-                }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
156
+                } elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
155 157
                     $value = $cf['defaults']['data_type'];
156 158
                 }
157 159
                 ?>
@@ -165,11 +167,11 @@  discard block
 block discarded – undo
165 167
 
166 168
                 echo apply_filters("geodir_cfa_admin_title_{$field_type}",'',$result_str,$cf,$field_info);
167 169
 
168
-            }else{
170
+            } else{
169 171
                 $value = '';
170 172
                 if (isset($field_info->admin_title)) {
171 173
                     $value = esc_attr($field_info->admin_title);
172
-                }elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
174
+                } elseif(isset($cf['defaults']['admin_title']) && $cf['defaults']['admin_title']){
173 175
                     $value = $cf['defaults']['admin_title'];
174 176
                 }
175 177
                 ?>
@@ -194,11 +196,11 @@  discard block
 block discarded – undo
194 196
 
195 197
                 echo apply_filters("geodir_cfa_site_title_{$field_type}",'',$result_str,$cf,$field_info);
196 198
 
197
-            }else{
199
+            } else{
198 200
                 $value = '';
199 201
                 if (isset($field_info->site_title)) {
200 202
                     $value = esc_attr($field_info->site_title);
201
-                }elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
203
+                } elseif(isset($cf['defaults']['site_title']) && $cf['defaults']['site_title']){
202 204
                     $value = $cf['defaults']['site_title'];
203 205
                 }
204 206
                 ?>
@@ -222,11 +224,11 @@  discard block
 block discarded – undo
222 224
 
223 225
                 echo apply_filters("geodir_cfa_admin_desc_{$field_type}",'',$result_str,$cf,$field_info);
224 226
 
225
-            }else{
227
+            } else{
226 228
                 $value = '';
227 229
                 if (isset($field_info->admin_desc)) {
228 230
                     $value = esc_attr($field_info->admin_desc);
229
-                }elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
231
+                } elseif(isset($cf['defaults']['admin_desc']) && $cf['defaults']['admin_desc']){
230 232
                     $value = $cf['defaults']['admin_desc'];
231 233
                 }
232 234
                 ?>
@@ -250,11 +252,11 @@  discard block
 block discarded – undo
250 252
 
251 253
                 echo apply_filters("geodir_cfa_htmlvar_name_{$field_type}",'',$result_str,$cf,$field_info);
252 254
 
253
-            }else{
255
+            } else{
254 256
                 $value = '';
255 257
                 if (isset($field_info->htmlvar_name)) {
256 258
                     $value = esc_attr($field_info->htmlvar_name);
257
-                }elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
259
+                } elseif(isset($cf['defaults']['htmlvar_name']) && $cf['defaults']['htmlvar_name']){
258 260
                     $value = $cf['defaults']['htmlvar_name'];
259 261
                 }
260 262
                 ?>
@@ -282,11 +284,11 @@  discard block
 block discarded – undo
282 284
 
283 285
                 echo apply_filters("geodir_cfa_is_active_{$field_type}",'',$result_str,$cf,$field_info);
284 286
 
285
-            }else{
287
+            } else{
286 288
                 $value = '';
287 289
                 if (isset($field_info->is_active)) {
288 290
                     $value = esc_attr($field_info->is_active);
289
-                }elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
291
+                } elseif(isset($cf['defaults']['is_active']) && $cf['defaults']['is_active']){
290 292
                     $value = $cf['defaults']['is_active'];
291 293
                 }
292 294
                 ?>
@@ -321,11 +323,11 @@  discard block
 block discarded – undo
321 323
 
322 324
                 echo apply_filters("geodir_cfa_for_admin_use_{$field_type}",'',$result_str,$cf,$field_info);
323 325
 
324
-            }else{
326
+            } else{
325 327
                 $value = '';
326 328
                 if (isset($field_info->for_admin_use)) {
327 329
                     $value = esc_attr($field_info->for_admin_use);
328
-                }elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
330
+                } elseif(isset($cf['defaults']['for_admin_use']) && $cf['defaults']['for_admin_use']){
329 331
                     $value = $cf['defaults']['for_admin_use'];
330 332
                 }
331 333
                 ?>
@@ -360,11 +362,11 @@  discard block
 block discarded – undo
360 362
 
361 363
                 echo apply_filters("geodir_cfa_default_value_{$field_type}",'',$result_str,$cf,$field_info);
362 364
 
363
-            }else{
365
+            } else{
364 366
                 $value = '';
365 367
                 if (isset($field_info->default_value)) {
366 368
                     $value = esc_attr($field_info->default_value);
367
-                }elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
369
+                } elseif(isset($cf['defaults']['default_value']) && $cf['defaults']['default_value']){
368 370
                     $value = $cf['defaults']['default_value'];
369 371
                 }
370 372
                 ?>
@@ -404,11 +406,11 @@  discard block
 block discarded – undo
404 406
 
405 407
                 echo apply_filters("geodir_cfa_show_in_{$field_type}",'',$result_str,$cf,$field_info);
406 408
 
407
-            }else{
409
+            } else{
408 410
                 $value = '';
409 411
                 if (isset($field_info->show_in)) {
410 412
                     $value = esc_attr($field_info->show_in);
411
-                }elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
413
+                } elseif(isset($cf['defaults']['show_in']) && $cf['defaults']['show_in']){
412 414
                     $value = esc_attr($cf['defaults']['show_in']);
413 415
                 }
414 416
                 ?>
@@ -448,7 +450,7 @@  discard block
 block discarded – undo
448 450
 
449 451
                         // don't show new tab option for some types
450 452
                         if (in_array($field_type, array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
451
-                        }else{
453
+                        } else{
452 454
                             unset($show_in_locations['[owntab]']);
453 455
                         }
454 456
 
@@ -561,11 +563,11 @@  discard block
 block discarded – undo
561 563
 
562 564
                 echo apply_filters("geodir_cfa_is_required_{$field_type}",'',$result_str,$cf,$field_info);
563 565
 
564
-            }else{
566
+            } else{
565 567
                 $value = '';
566 568
                 if (isset($field_info->is_required)) {
567 569
                     $value = esc_attr($field_info->is_required);
568
-                }elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
570
+                } elseif(isset($cf['defaults']['is_required']) && $cf['defaults']['is_required']){
569 571
                     $value = $cf['defaults']['is_required'];
570 572
                 }
571 573
                 ?>
@@ -602,11 +604,11 @@  discard block
 block discarded – undo
602 604
 
603 605
                 echo apply_filters("geodir_cfa_required_msg_{$field_type}",'',$result_str,$cf,$field_info);
604 606
 
605
-            }else{
607
+            } else{
606 608
                 $value = '';
607 609
                 if (isset($field_info->required_msg)) {
608 610
                     $value = esc_attr($field_info->required_msg);
609
-                }elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
611
+                } elseif(isset($cf['defaults']['required_msg']) && $cf['defaults']['required_msg']){
610 612
                     $value = $cf['defaults']['required_msg'];
611 613
                 }
612 614
                 ?>
@@ -647,11 +649,11 @@  discard block
 block discarded – undo
647 649
 
648 650
                 echo apply_filters("geodir_cfa_field_icon_{$field_type}",'',$result_str,$cf,$field_info);
649 651
 
650
-            }else{
652
+            } else{
651 653
                 $value = '';
652 654
                 if (isset($field_info->field_icon)) {
653 655
                     $value = esc_attr($field_info->field_icon);
654
-                }elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
656
+                } elseif(isset($cf['defaults']['field_icon']) && $cf['defaults']['field_icon']){
655 657
                     $value = $cf['defaults']['field_icon'];
656 658
                 }
657 659
                 ?>
@@ -680,11 +682,11 @@  discard block
 block discarded – undo
680 682
 
681 683
                 echo apply_filters("geodir_cfa_css_class_{$field_type}",'',$result_str,$cf,$field_info);
682 684
 
683
-            }else{
685
+            } else{
684 686
                 $value = '';
685 687
                 if (isset($field_info->css_class)) {
686 688
                     $value = esc_attr($field_info->css_class);
687
-                }elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
689
+                } elseif(isset($cf['defaults']['css_class']) && $cf['defaults']['css_class']){
688 690
                     $value = $cf['defaults']['css_class'];
689 691
                 }
690 692
                 ?>
@@ -713,12 +715,12 @@  discard block
 block discarded – undo
713 715
 
714 716
                 echo apply_filters("geodir_cfa_cat_sort_{$field_type}",'',$result_str,$cf,$field_info);
715 717
 
716
-            }else{
718
+            } else{
717 719
                 $value = '';
718 720
                 $hide_cat_sort  ='';
719 721
                 if (isset($field_info->cat_sort)) {
720 722
                     $value = esc_attr($field_info->cat_sort);
721
-                }elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
723
+                } elseif(isset($cf['defaults']['cat_sort']) && $cf['defaults']['cat_sort']){
722 724
                     $value = $cf['defaults']['cat_sort'];
723 725
                     $hide_cat_sort = ($value===false) ? "style='display:none;'" : '';
724 726
                 }
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 3 patches
Braces   +61 added lines, -54 removed lines patch added patch discarded remove patch
@@ -24,8 +24,11 @@  discard block
 block discarded – undo
24 24
             global $current_tab;
25 25
             geodir_redirect_to_admin_panel_on_installed();
26 26
             $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
27
+            if (!(isset($_REQUEST['action']))) {
28
+            	// this will avoid Ajax requests
29
+                geodir_handle_option_form_submit($current_tab);
30
+            }
31
+            // located in admin function.php
29 32
             /**
30 33
              * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31 34
              *
@@ -328,8 +331,9 @@  discard block
 block discarded – undo
328 331
     if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
329 332
 
330 333
         foreach ($notification as $key => $value) {
331
-            if ($value['type'] == 'textarea')
332
-                $notification[$key]['type'] = 'editor';
334
+            if ($value['type'] == 'textarea') {
335
+                            $notification[$key]['type'] = 'editor';
336
+            }
333 337
         }
334 338
 
335 339
     }
@@ -354,8 +358,9 @@  discard block
 block discarded – undo
354 358
     if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
355 359
 
356 360
         foreach ($design_setting as $key => $value) {
357
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
358
-                $design_setting[$key]['type'] = 'editor';
361
+            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') {
362
+                            $design_setting[$key]['type'] = 'editor';
363
+            }
359 364
         }
360 365
 
361 366
     }
@@ -474,9 +479,9 @@  discard block
 block discarded – undo
474 479
                    class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
475 480
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], ' fa-') !== false) {
476 481
                         echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
477
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
482
+                    } elseif(isset($val['field_icon']) && $val['field_icon'] ){
478 483
                         echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>';
479
-                    }else{
484
+                    } else{
480 485
                         echo '<i class="fas fa-cog" aria-hidden="true"></i>';
481 486
                     }?>
482 487
                     <?php echo (! empty( $val['admin_title'] ) ? $val['admin_title'] : $val['site_title'] );?>
@@ -706,9 +711,9 @@  discard block
 block discarded – undo
706 711
         <?php
707 712
         if($type=='predefined'){
708 713
             $cfs = geodir_custom_fields_predefined($listing_type);
709
-        }elseif($type=='custom'){
714
+        } elseif($type=='custom'){
710 715
             $cfs = geodir_custom_fields_custom($listing_type);
711
-        }else{
716
+        } else{
712 717
             $cfs = geodir_custom_fields($listing_type);
713 718
             ?>
714 719
             <ul class="full gd-cf-tooltip-wrap">
@@ -763,7 +768,7 @@  discard block
 block discarded – undo
763 768
             </li>
764 769
             <?php
765 770
         }
766
-    }else{
771
+    } else{
767 772
         _e('There are no custom fields here yet.', 'geodirectory');
768 773
     }
769 774
         ?>
@@ -960,8 +965,9 @@  discard block
 block discarded – undo
960 965
 
961 966
     if (!get_option('geodir_remove_unnecessary_fields')) {
962 967
 
963
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
964
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
968
+        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) {
969
+                    $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
970
+        }
965 971
 
966 972
         update_option('geodir_remove_unnecessary_fields', '1');
967 973
 
@@ -997,8 +1003,9 @@  discard block
 block discarded – undo
997 1003
                 break;
998 1004
 
999 1005
             case 'diagnosis-fix' :
1000
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
1001
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1006
+                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
1007
+                                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1008
+                }
1002 1009
                 call_user_func('geodir_diagnose_' . $diagnose_this);
1003 1010
                 exit();
1004 1011
                 break;
@@ -1613,11 +1620,11 @@  discard block
 block discarded – undo
1613 1620
     //////////////////////////////////
1614 1621
     $option_value = get_option('geodir_home_page');
1615 1622
     $page = get_post($option_value);
1616
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1623
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1617 1624
 
1618
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1619
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1620
-    else {
1625
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1626
+            $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1627
+    } else {
1621 1628
         $is_error_during_diagnose = true;
1622 1629
         $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1623 1630
         if ($fix) {
@@ -1638,11 +1645,11 @@  discard block
 block discarded – undo
1638 1645
     //////////////////////////////////
1639 1646
     $option_value = get_option('geodir_add_listing_page');
1640 1647
     $page = get_post($option_value);
1641
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1648
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1642 1649
 
1643
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1644
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1645
-    else {
1650
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1651
+            $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1652
+    } else {
1646 1653
         $is_error_during_diagnose = true;
1647 1654
         $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1648 1655
         if ($fix) {
@@ -1664,11 +1671,11 @@  discard block
 block discarded – undo
1664 1671
     //////////////////////////////////
1665 1672
     $option_value = get_option('geodir_preview_page');
1666 1673
     $page = get_post($option_value);
1667
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1674
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1668 1675
 
1669
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1670
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1671
-    else {
1676
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1677
+            $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1678
+    } else {
1672 1679
         $is_error_during_diagnose = true;
1673 1680
         $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1674 1681
         if ($fix) {
@@ -1689,11 +1696,11 @@  discard block
 block discarded – undo
1689 1696
     //////////////////////////////////
1690 1697
     $option_value = get_option('geodir_success_page');
1691 1698
     $page = get_post($option_value);
1692
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1699
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1693 1700
 
1694
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1695
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1696
-    else {
1701
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1702
+            $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1703
+    } else {
1697 1704
         $is_error_during_diagnose = true;
1698 1705
         $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1699 1706
         if ($fix) {
@@ -1714,11 +1721,11 @@  discard block
 block discarded – undo
1714 1721
     //////////////////////////////////
1715 1722
     $option_value = get_option('geodir_info_page');
1716 1723
     $page = get_post($option_value);
1717
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1724
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1718 1725
 
1719
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1720
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1721
-    else {
1726
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1727
+            $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1728
+    } else {
1722 1729
         $is_error_during_diagnose = true;
1723 1730
         $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1724 1731
         if ($fix) {
@@ -1739,11 +1746,11 @@  discard block
 block discarded – undo
1739 1746
     //////////////////////////////////
1740 1747
     $option_value = get_option('geodir_login_page');
1741 1748
     $page = get_post($option_value);
1742
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1749
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1743 1750
 
1744
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1745
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1746
-    else {
1751
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1752
+            $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1753
+    } else {
1747 1754
         $is_error_during_diagnose = true;
1748 1755
         $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1749 1756
         if ($fix) {
@@ -1764,11 +1771,11 @@  discard block
 block discarded – undo
1764 1771
     //////////////////////////////////
1765 1772
     $option_value = get_option('geodir_location_page');
1766 1773
     $page = get_post($option_value);
1767
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1774
+    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
1768 1775
 
1769
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1770
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1771
-    else {
1776
+    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') {
1777
+            $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1778
+    } else {
1772 1779
         $is_error_during_diagnose = true;
1773 1780
         $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1774 1781
         if ($fix) {
@@ -2213,8 +2220,9 @@  discard block
 block discarded – undo
2213 2220
                             );
2214 2221
 
2215 2222
                             $post_location_info = $request_info['post_location'];
2216
-                            if ($location_id = geodir_add_new_location($post_location_info))
2217
-                                $post_location_id = $location_id;
2223
+                            if ($location_id = geodir_add_new_location($post_location_info)) {
2224
+                                                            $post_location_id = $location_id;
2225
+                            }
2218 2226
                         } else {
2219 2227
                             $post_location_id = 0;
2220 2228
                         }
@@ -2277,8 +2285,9 @@  discard block
 block discarded – undo
2277 2285
                             $attachment_set = '';
2278 2286
 
2279 2287
                             foreach ($attachment as $key => $val) {
2280
-                                if ($val != '')
2281
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2288
+                                if ($val != '') {
2289
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
2290
+                                }
2282 2291
                             }
2283 2292
                             $attachment_set = trim($attachment_set, ", ");
2284 2293
 
@@ -2374,8 +2383,7 @@  discard block
 block discarded – undo
2374 2383
 
2375 2384
         $parts = json_decode($response['body']);
2376 2385
         //print_r($parts);
2377
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2378
-        else{
2386
+        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{
2379 2387
 
2380 2388
             update_option('gd_ga_access_token', $parts->access_token);
2381 2389
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2383,17 +2391,16 @@  discard block
 block discarded – undo
2383 2391
         }
2384 2392
 
2385 2393
 
2386
-    }
2387
-    elseif(!empty($response['response']['code'])) {
2394
+    } elseif(!empty($response['response']['code'])) {
2388 2395
         $parts = json_decode($response['body']);
2389 2396
 
2390 2397
         if(isset($parts->error)){
2391 2398
             echo $parts->error.": ".$parts->error_description;exit;
2392
-        }else{
2399
+        } else{
2393 2400
             echo $error_msg." - #2";exit;
2394 2401
         }
2395 2402
 
2396
-    }else{
2403
+    } else{
2397 2404
 
2398 2405
         echo $error_msg." - #3";exit;
2399 2406
 
@@ -2531,7 +2538,7 @@  discard block
 block discarded – undo
2531 2538
         ob_start();
2532 2539
         geodir_diagnose_version_clear();
2533 2540
         ob_end_clean();
2534
-    }else{
2541
+    } else{
2535 2542
         $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2536 2543
     }
2537 2544
 
Please login to merge, or discard this patch.
Indentation   +1647 added lines, -1647 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 add_action('admin_init', 'geodir_admin_init');
12 12
 if (!function_exists('geodir_admin_init')) {
13
-    /**
14
-     * Adds GD setting pages in admin.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global string $current_tab The current settings tab name.
19
-     */
20
-    function geodir_admin_init()
21
-    {
22
-
23
-        if (is_admin()):
24
-            global $current_tab;
25
-            geodir_redirect_to_admin_panel_on_installed();
26
-            $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
-            /**
30
-             * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
-             *
32
-             * @since 1.0.0
33
-             */
34
-            do_action('admin_panel_init');
35
-            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
-
37
-
38
-        endif;
39
-    }
13
+	/**
14
+	 * Adds GD setting pages in admin.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global string $current_tab The current settings tab name.
19
+	 */
20
+	function geodir_admin_init()
21
+	{
22
+
23
+		if (is_admin()):
24
+			global $current_tab;
25
+			geodir_redirect_to_admin_panel_on_installed();
26
+			$current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
+			if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
+				geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
+			/**
30
+			 * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
+			 *
32
+			 * @since 1.0.0
33
+			 */
34
+			do_action('admin_panel_init');
35
+			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
+
37
+
38
+		endif;
39
+	}
40 40
 }
41 41
 
42 42
 /**
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_redirect_to_admin_panel_on_installed()
49 49
 {
50
-    if (get_option('geodir_installation_redirect', false)) {
51
-        delete_option('geodir_installation_redirect');
52
-        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
-    }
50
+	if (get_option('geodir_installation_redirect', false)) {
51
+		delete_option('geodir_installation_redirect');
52
+		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
+	}
54 54
 }
55 55
 
56 56
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+	geodir_admin_option_form($current_tab);// defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function geodir_conditional_admin_script_load()
88 88
 {
89
-    global $pagenow;
89
+	global $pagenow;
90 90
 	
91 91
 	// Get the current post type
92 92
 	$post_type = geodir_admin_current_post_type();
93 93
 	$geodir_post_types = geodir_get_posttypes();
94 94
     
95 95
 	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
98
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
98
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
99 99
         
100
-        // Disable VC editor for GD post types.
101
-        if (class_exists('Vc_Role_Access_Controller')) {
102
-            add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
103
-        }
104
-    }
100
+		// Disable VC editor for GD post types.
101
+		if (class_exists('Vc_Role_Access_Controller')) {
102
+			add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
103
+		}
104
+	}
105 105
 
106
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
106
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
107 107
 
108 108
 }
109 109
 
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  */
139 139
 function create_default_admin_main_nav()
140 140
 {
141
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
142
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
143
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
144
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
145
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
146
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
141
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
142
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
143
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
144
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
145
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
146
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
147 147
 
148 148
 }
149 149
 
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function geodir_admin_list_columns()
159 159
 {
160
-    if ($post_types = geodir_get_posttypes()) {
160
+	if ($post_types = geodir_get_posttypes()) {
161 161
 
162
-        foreach ($post_types as $post_type):
163
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
164
-            //Filter-Payment-Manager to show Package
165
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
162
+		foreach ($post_types as $post_type):
163
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
164
+			//Filter-Payment-Manager to show Package
165
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
166 166
 
167
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
167
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
168 168
             
169
-            // Filter bulk actions
170
-            add_filter("bulk_actions-edit-{$post_type}", 'geodir_filter_bulk_actions', 10, 1);
171
-        endforeach;
172
-    }
169
+			// Filter bulk actions
170
+			add_filter("bulk_actions-edit-{$post_type}", 'geodir_filter_bulk_actions', 10, 1);
171
+		endforeach;
172
+	}
173 173
 }
174 174
 
175 175
 /**
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
  */
183 183
 function geodir_default_admin_main_tabs($tabs)
184 184
 {
185
-    return $tabs = array(
186
-        'general_settings' => array('label' => __('General', 'geodirectory')),
187
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
188
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
189
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
190
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
191
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
192
-
193
-    );
185
+	return $tabs = array(
186
+		'general_settings' => array('label' => __('General', 'geodirectory')),
187
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
188
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
189
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
190
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
191
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
192
+
193
+	);
194 194
 }
195 195
 
196 196
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
  */
204 204
 function geodir_remove_image_box()
205 205
 {
206
-    global $post;
206
+	global $post;
207 207
 
208
-    $geodir_posttypes = geodir_get_posttypes();
208
+	$geodir_posttypes = geodir_get_posttypes();
209 209
 
210
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
210
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
211 211
 
212
-        remove_meta_box('postimagediv', $post->post_type, 'side');
213
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
212
+		remove_meta_box('postimagediv', $post->post_type, 'side');
213
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
214 214
 
215
-    endif;
215
+	endif;
216 216
 
217 217
 }
218 218
 
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
  */
228 228
 function geodir_meta_box_add()
229 229
 {
230
-    global $post;
230
+	global $post;
231 231
 
232
-    $geodir_post_types = geodir_get_posttypes('array');
233
-    $geodir_posttypes = array_keys($geodir_post_types);
232
+	$geodir_post_types = geodir_get_posttypes('array');
233
+	$geodir_posttypes = array_keys($geodir_post_types);
234 234
 
235
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
235
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
236 236
 
237
-        $geodir_posttype = $post->post_type;
238
-        $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory');
239
-        $post_typename = geodir_ucwords($post_typename);
237
+		$geodir_posttype = $post->post_type;
238
+		$post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory');
239
+		$post_typename = geodir_ucwords($post_typename);
240 240
 
241
-        // Filter-Payment-Manager
241
+		// Filter-Payment-Manager
242 242
 
243
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
243
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
244 244
 
245
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
245
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
246 246
 
247
-        // no need of this box as all fields moved to main information box
248
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
247
+		// no need of this box as all fields moved to main information box
248
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
249 249
 
250
-    endif;
250
+	endif;
251 251
 
252 252
 }
253 253
 
@@ -271,23 +271,23 @@  discard block
 block discarded – undo
271 271
 function geodir_hide_post_taxonomy_meta_boxes()
272 272
 {
273 273
 
274
-    $geodir_post_types = get_option('geodir_post_types');
274
+	$geodir_post_types = get_option('geodir_post_types');
275 275
 
276
-    if (!empty($geodir_post_types)) {
277
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
276
+	if (!empty($geodir_post_types)) {
277
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
278 278
 
279
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
279
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
280 280
 
281
-            if(!empty($gd_taxonomy)) {
282
-                foreach ($gd_taxonomy as $tax) {
281
+			if(!empty($gd_taxonomy)) {
282
+				foreach ($gd_taxonomy as $tax) {
283 283
 
284
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
284
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
285 285
 
286
-                }
287
-            }
286
+				}
287
+			}
288 288
 
289
-        }
290
-    }
289
+		}
290
+	}
291 291
 }
292 292
 
293 293
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  */
302 302
 function geodir_add_listing_map_restrict($map_restirct)
303 303
 {
304
-    if (is_admin()) {
305
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
306
-            $map_restirct = false;
307
-        }
308
-    }
309
-    return $map_restirct;
304
+	if (is_admin()) {
305
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
306
+			$map_restirct = false;
307
+		}
308
+	}
309
+	return $map_restirct;
310 310
 }
311 311
 
312 312
 
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
 function geodir_enable_editor_on_notifications($notification)
326 326
 {
327 327
 
328
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
328
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
329 329
 
330
-        foreach ($notification as $key => $value) {
331
-            if ($value['type'] == 'textarea')
332
-                $notification[$key]['type'] = 'editor';
333
-        }
330
+		foreach ($notification as $key => $value) {
331
+			if ($value['type'] == 'textarea')
332
+				$notification[$key]['type'] = 'editor';
333
+		}
334 334
 
335
-    }
335
+	}
336 336
 
337
-    return $notification;
337
+	return $notification;
338 338
 }
339 339
 
340 340
 
@@ -351,16 +351,16 @@  discard block
 block discarded – undo
351 351
 function geodir_enable_editor_on_design_settings($design_setting)
352 352
 {
353 353
 
354
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
354
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
355 355
 
356
-        foreach ($design_setting as $key => $value) {
357
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
358
-                $design_setting[$key]['type'] = 'editor';
359
-        }
356
+		foreach ($design_setting as $key => $value) {
357
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
358
+				$design_setting[$key]['type'] = 'editor';
359
+		}
360 360
 
361
-    }
361
+	}
362 362
 
363
-    return $design_setting;
363
+	return $design_setting;
364 364
 }
365 365
 
366 366
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -368,15 +368,15 @@  discard block
 block discarded – undo
368 368
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
369 369
 
370 370
 function geodir_manage_available_fields_predefined($sub_tab){
371
-    if($sub_tab=='custom_fields'){
372
-        geodir_custom_available_fields('predefined');
373
-    }
371
+	if($sub_tab=='custom_fields'){
372
+		geodir_custom_available_fields('predefined');
373
+	}
374 374
 }
375 375
 
376 376
 function geodir_manage_available_fields_custom($sub_tab){
377
-    if($sub_tab=='custom_fields'){
378
-        geodir_custom_available_fields('custom');
379
-    }
377
+	if($sub_tab=='custom_fields'){
378
+		geodir_custom_available_fields('custom');
379
+	}
380 380
 }
381 381
 
382 382
 
@@ -395,16 +395,16 @@  discard block
 block discarded – undo
395 395
 function geodir_manage_available_fields($sub_tab)
396 396
 {
397 397
 
398
-    switch ($sub_tab) {
399
-        case 'custom_fields':
400
-            geodir_custom_available_fields();
401
-            break;
398
+	switch ($sub_tab) {
399
+		case 'custom_fields':
400
+			geodir_custom_available_fields();
401
+			break;
402 402
 
403
-        case 'sorting_options':
404
-            geodir_sorting_options_available_fields();
405
-            break;
403
+		case 'sorting_options':
404
+			geodir_sorting_options_available_fields();
405
+			break;
406 406
 
407
-    }
407
+	}
408 408
 }
409 409
 
410 410
 
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
 function geodir_manage_selected_fields($sub_tab)
421 421
 {
422 422
 
423
-    switch ($sub_tab) {
424
-        case 'custom_fields':
425
-            geodir_custom_selected_fields();
426
-            break;
423
+	switch ($sub_tab) {
424
+		case 'custom_fields':
425
+			geodir_custom_selected_fields();
426
+			break;
427 427
 
428
-        case 'sorting_options':
429
-            geodir_sorting_options_selected_fields();
430
-            break;
428
+		case 'sorting_options':
429
+			geodir_sorting_options_selected_fields();
430
+			break;
431 431
 
432
-    }
432
+	}
433 433
 }
434 434
 
435 435
 /**
@@ -441,52 +441,52 @@  discard block
 block discarded – undo
441 441
  */
442 442
 function geodir_sorting_options_available_fields()
443 443
 {
444
-    global $wpdb;
445
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
446
-    ?>
444
+	global $wpdb;
445
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
446
+	?>
447 447
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
448 448
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
449 449
     <ul>
450 450
     <?php
451
-        $sort_options = geodir_get_custom_sort_options($listing_type);
451
+		$sort_options = geodir_get_custom_sort_options($listing_type);
452 452
         
453
-        foreach ($sort_options as $key => $val) {
454
-            $val = stripslashes_deep($val); // strip slashes
455
-
456
-            $check_html_variable = $wpdb->get_var(
457
-                $wpdb->prepare(
458
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
459
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
460
-                )
461
-            );
453
+		foreach ($sort_options as $key => $val) {
454
+			$val = stripslashes_deep($val); // strip slashes
455
+
456
+			$check_html_variable = $wpdb->get_var(
457
+				$wpdb->prepare(
458
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
459
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
460
+				)
461
+			);
462 462
             
463
-            $display = $check_html_variable ? ' style="display:none;"' : '';
464
-           ?>
463
+			$display = $check_html_variable ? ' style="display:none;"' : '';
464
+		   ?>
465 465
 
466 466
             <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
467 467
                 <?php
468
-                if(isset($val['description']) && $val['description']){
469
-                    echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
470
-                }?>
468
+				if(isset($val['description']) && $val['description']){
469
+					echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
470
+				}?>
471 471
 
472 472
                 <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>"  data-field-type="<?php echo $val['field_type'];?>"
473 473
                    title="<?php echo $val['site_title'];?>"
474 474
                    class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
475 475
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], ' fa-') !== false) {
476
-                        echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
477
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
478
-                        echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>';
479
-                    }else{
480
-                        echo '<i class="fas fa-cog" aria-hidden="true"></i>';
481
-                    }?>
476
+						echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
477
+					}elseif(isset($val['field_icon']) && $val['field_icon'] ){
478
+						echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>';
479
+					}else{
480
+						echo '<i class="fas fa-cog" aria-hidden="true"></i>';
481
+					}?>
482 482
                     <?php echo (! empty( $val['admin_title'] ) ? $val['admin_title'] : $val['site_title'] );?>
483 483
                 </a>
484 484
             </li>
485 485
 
486 486
 
487 487
             <?php
488
-        }
489
-    ?>
488
+		}
489
+	?>
490 490
     </ul>
491 491
     <?php
492 492
 }
@@ -500,28 +500,28 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function geodir_sorting_options_selected_fields()
502 502
 {
503
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
504
-    ?>
503
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
504
+	?>
505 505
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
506 506
     <ul class="core">
507 507
     <?php 
508
-        global $wpdb;
508
+		global $wpdb;
509 509
         
510
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
510
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
511 511
 
512
-        if (!empty($fields)) {
513
-            foreach ($fields as $field) {
514
-                //$result_str = $field->id;
515
-                $result_str = $field;
516
-                $field_type = $field->field_type;
517
-                $field_ins_upd = 'display';
512
+		if (!empty($fields)) {
513
+			foreach ($fields as $field) {
514
+				//$result_str = $field->id;
515
+				$result_str = $field;
516
+				$field_type = $field->field_type;
517
+				$field_ins_upd = 'display';
518 518
 
519
-                $default = false;
519
+				$default = false;
520 520
 
521
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
522
-            }
523
-        }
524
-    ?>
521
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
522
+			}
523
+		}
524
+	?>
525 525
     </ul>
526 526
     <?php
527 527
 }
@@ -534,12 +534,12 @@  discard block
 block discarded – undo
534 534
  */
535 535
 function geodir_custom_fields_custom($post_type=''){
536 536
 
537
-    $custom_fields = array();
537
+	$custom_fields = array();
538 538
 
539
-    /**
540
-     * @see `geodir_custom_fields`
541
-     */
542
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
539
+	/**
540
+	 * @see `geodir_custom_fields`
541
+	 */
542
+	return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
543 543
 }
544 544
 
545 545
 
@@ -552,140 +552,140 @@  discard block
 block discarded – undo
552 552
  */
553 553
 function geodir_custom_fields($post_type=''){
554 554
     
555
-    $custom_fields = array(
556
-        'text' => array(
557
-            'field_type'  =>  'text',
558
-            'class' =>  'gd-text',
559
-            'icon'  =>  'fas fa-minus',
560
-            'name'  =>  __('Text', 'geodirectory'),
561
-            'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
562
-        ),
563
-        'datepicker' => array(
564
-            'field_type'  =>  'datepicker',
565
-            'class' =>  'gd-datepicker',
566
-            'icon'  =>  'fas fa-calendar-alt',
567
-            'name'  =>  __('Date', 'geodirectory'),
568
-            'description' =>  __('Adds a date picker.', 'geodirectory')
569
-        ),
570
-        'textarea' => array(
571
-            'field_type'  =>  'textarea',
572
-            'class' =>  'gd-textarea',
573
-            'icon'  =>  'fas fa-bars',
574
-            'name'  =>  __('Textarea', 'geodirectory'),
575
-            'description' =>  __('Adds a textarea', 'geodirectory')
576
-        ),
577
-        'time' => array(
578
-            'field_type'  =>  'time',
579
-            'class' =>  'gd-time',
580
-            'icon' =>  'far fa-clock',
581
-            'name'  =>  __('Time', 'geodirectory'),
582
-            'description' =>  __('Adds a time picker', 'geodirectory')
583
-        ),
584
-        'checkbox' => array(
585
-            'field_type'  =>  'checkbox',
586
-            'class' =>  'gd-checkbox',
587
-            'icon' =>  'far fa-check-square',
588
-            'name'  =>  __('Checkbox', 'geodirectory'),
589
-            'description' =>  __('Adds a checkbox', 'geodirectory')
590
-        ),
591
-        'phone' => array(
592
-            'field_type'  =>  'phone',
593
-            'class' =>  'gd-phone',
594
-            'icon' =>  'fas fa-phone',
595
-            'name'  =>  __('Phone', 'geodirectory'),
596
-            'description' =>  __('Adds a phone input', 'geodirectory')
597
-        ),
598
-        'radio' => array(
599
-            'field_type'  =>  'radio',
600
-            'class' =>  'gd-radio',
601
-            'icon' =>  'far fa-dot-circle',
602
-            'name'  =>  __('Radio', 'geodirectory'),
603
-            'description' =>  __('Adds a radio input', 'geodirectory')
604
-        ),
605
-        'email' => array(
606
-            'field_type'  =>  'email',
607
-            'class' =>  'gd-email',
608
-            'icon' =>  'far fa-envelope',
609
-            'name'  =>  __('Email', 'geodirectory'),
610
-            'description' =>  __('Adds a email input', 'geodirectory')
611
-        ),
612
-        'select' => array(
613
-            'field_type'  =>  'select',
614
-            'class' =>  'gd-select',
615
-            'icon' =>  'far fa-caret-square-down',
616
-            'name'  =>  __('Select', 'geodirectory'),
617
-            'description' =>  __('Adds a select input', 'geodirectory')
618
-        ),
619
-        'multiselect' => array(
620
-            'field_type'  =>  'multiselect',
621
-            'class' =>  'gd-multiselect',
622
-            'icon' =>  'far fa-caret-square-down',
623
-            'name'  =>  __('Multi Select', 'geodirectory'),
624
-            'description' =>  __('Adds a multiselect input', 'geodirectory')
625
-        ),
626
-        'url' => array(
627
-            'field_type'  =>  'url',
628
-            'class' =>  'gd-url',
629
-            'icon' =>  'fas fa-link',
630
-            'name'  =>  __('URL', 'geodirectory'),
631
-            'description' =>  __('Adds a url input', 'geodirectory')
632
-        ),
633
-        'html' => array(
634
-            'field_type'  =>  'html',
635
-            'class' =>  'gd-html',
636
-            'icon' =>  'fas fa-code',
637
-            'name'  =>  __('HTML', 'geodirectory'),
638
-            'description' =>  __('Adds a html input textarea', 'geodirectory')
639
-        ),
640
-        'file' => array(
641
-            'field_type'  =>  'file',
642
-            'class' =>  'gd-file',
643
-            'icon' =>  'fas fa-file',
644
-            'name'  =>  __('File Upload', 'geodirectory'),
645
-            'description' =>  __('Adds a file input', 'geodirectory')
646
-        )
647
-    );
648
-
649
-    /**
650
-     * Filter the custom fields array to be able to add or remove items.
651
-     * 
652
-     * @since 1.6.6
653
-     *
654
-     * @param array $custom_fields {
655
-     *     The custom fields array to be filtered.
656
-     *
657
-     *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
658
-     *     @type string $class The class for the field in backend.
659
-     *     @type string $icon Can be font-awesome class name or icon image url.
660
-     *     @type string $name The name of the field.
661
-     *     @type string $description A short description about the field.
662
-     *     @type array $defaults {
663
-     *                    Optional. Used to set the default value of the field.
664
-     *
665
-     *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
666
-     *                    @type int decimal_point limit if using FLOAT data_type
667
-     *                    @type string admin_title The admin title for the field.
668
-     *                    @type string site_title This will be the title for the field on the frontend.
669
-     *                    @type string admin_desc This will be shown below the field on the add listing form.
670
-     *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
671
-     *                    @type bool is_active If false the field will not be displayed anywhere.
672
-     *                    @type bool for_admin_use If true then only site admin can see and edit this field.
673
-     *                    @type string default_value The default value for the input on the add listing page.
674
-     *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
675
-     *                    @type bool is_required If true the field will be required on the add listing page.
676
-     *                    @type string option_values The option values for select and multiselect only
677
-     *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
678
-     *                    @type string validation_msg HTML5 validation message (text input only by default).
679
-     *                    @type string required_msg Required warning message.
680
-     *                    @type string field_icon Icon url or font awesome class.
681
-     *                    @type string css_class Field custom css class for field custom style.
682
-     *                    @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option.
683
-     *                    @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required)
684
-     *     }
685
-     * }
686
-     * @param string $post_type The post type requested.
687
-     */
688
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
555
+	$custom_fields = array(
556
+		'text' => array(
557
+			'field_type'  =>  'text',
558
+			'class' =>  'gd-text',
559
+			'icon'  =>  'fas fa-minus',
560
+			'name'  =>  __('Text', 'geodirectory'),
561
+			'description' =>  __('Add any sort of text field, text or numbers', 'geodirectory')
562
+		),
563
+		'datepicker' => array(
564
+			'field_type'  =>  'datepicker',
565
+			'class' =>  'gd-datepicker',
566
+			'icon'  =>  'fas fa-calendar-alt',
567
+			'name'  =>  __('Date', 'geodirectory'),
568
+			'description' =>  __('Adds a date picker.', 'geodirectory')
569
+		),
570
+		'textarea' => array(
571
+			'field_type'  =>  'textarea',
572
+			'class' =>  'gd-textarea',
573
+			'icon'  =>  'fas fa-bars',
574
+			'name'  =>  __('Textarea', 'geodirectory'),
575
+			'description' =>  __('Adds a textarea', 'geodirectory')
576
+		),
577
+		'time' => array(
578
+			'field_type'  =>  'time',
579
+			'class' =>  'gd-time',
580
+			'icon' =>  'far fa-clock',
581
+			'name'  =>  __('Time', 'geodirectory'),
582
+			'description' =>  __('Adds a time picker', 'geodirectory')
583
+		),
584
+		'checkbox' => array(
585
+			'field_type'  =>  'checkbox',
586
+			'class' =>  'gd-checkbox',
587
+			'icon' =>  'far fa-check-square',
588
+			'name'  =>  __('Checkbox', 'geodirectory'),
589
+			'description' =>  __('Adds a checkbox', 'geodirectory')
590
+		),
591
+		'phone' => array(
592
+			'field_type'  =>  'phone',
593
+			'class' =>  'gd-phone',
594
+			'icon' =>  'fas fa-phone',
595
+			'name'  =>  __('Phone', 'geodirectory'),
596
+			'description' =>  __('Adds a phone input', 'geodirectory')
597
+		),
598
+		'radio' => array(
599
+			'field_type'  =>  'radio',
600
+			'class' =>  'gd-radio',
601
+			'icon' =>  'far fa-dot-circle',
602
+			'name'  =>  __('Radio', 'geodirectory'),
603
+			'description' =>  __('Adds a radio input', 'geodirectory')
604
+		),
605
+		'email' => array(
606
+			'field_type'  =>  'email',
607
+			'class' =>  'gd-email',
608
+			'icon' =>  'far fa-envelope',
609
+			'name'  =>  __('Email', 'geodirectory'),
610
+			'description' =>  __('Adds a email input', 'geodirectory')
611
+		),
612
+		'select' => array(
613
+			'field_type'  =>  'select',
614
+			'class' =>  'gd-select',
615
+			'icon' =>  'far fa-caret-square-down',
616
+			'name'  =>  __('Select', 'geodirectory'),
617
+			'description' =>  __('Adds a select input', 'geodirectory')
618
+		),
619
+		'multiselect' => array(
620
+			'field_type'  =>  'multiselect',
621
+			'class' =>  'gd-multiselect',
622
+			'icon' =>  'far fa-caret-square-down',
623
+			'name'  =>  __('Multi Select', 'geodirectory'),
624
+			'description' =>  __('Adds a multiselect input', 'geodirectory')
625
+		),
626
+		'url' => array(
627
+			'field_type'  =>  'url',
628
+			'class' =>  'gd-url',
629
+			'icon' =>  'fas fa-link',
630
+			'name'  =>  __('URL', 'geodirectory'),
631
+			'description' =>  __('Adds a url input', 'geodirectory')
632
+		),
633
+		'html' => array(
634
+			'field_type'  =>  'html',
635
+			'class' =>  'gd-html',
636
+			'icon' =>  'fas fa-code',
637
+			'name'  =>  __('HTML', 'geodirectory'),
638
+			'description' =>  __('Adds a html input textarea', 'geodirectory')
639
+		),
640
+		'file' => array(
641
+			'field_type'  =>  'file',
642
+			'class' =>  'gd-file',
643
+			'icon' =>  'fas fa-file',
644
+			'name'  =>  __('File Upload', 'geodirectory'),
645
+			'description' =>  __('Adds a file input', 'geodirectory')
646
+		)
647
+	);
648
+
649
+	/**
650
+	 * Filter the custom fields array to be able to add or remove items.
651
+	 * 
652
+	 * @since 1.6.6
653
+	 *
654
+	 * @param array $custom_fields {
655
+	 *     The custom fields array to be filtered.
656
+	 *
657
+	 *     @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
658
+	 *     @type string $class The class for the field in backend.
659
+	 *     @type string $icon Can be font-awesome class name or icon image url.
660
+	 *     @type string $name The name of the field.
661
+	 *     @type string $description A short description about the field.
662
+	 *     @type array $defaults {
663
+	 *                    Optional. Used to set the default value of the field.
664
+	 *
665
+	 *                    @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE
666
+	 *                    @type int decimal_point limit if using FLOAT data_type
667
+	 *                    @type string admin_title The admin title for the field.
668
+	 *                    @type string site_title This will be the title for the field on the frontend.
669
+	 *                    @type string admin_desc This will be shown below the field on the add listing form.
670
+	 *                    @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters.
671
+	 *                    @type bool is_active If false the field will not be displayed anywhere.
672
+	 *                    @type bool for_admin_use If true then only site admin can see and edit this field.
673
+	 *                    @type string default_value The default value for the input on the add listing page.
674
+	 *                    @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble]
675
+	 *                    @type bool is_required If true the field will be required on the add listing page.
676
+	 *                    @type string option_values The option values for select and multiselect only
677
+	 *                    @type string validation_pattern HTML5 validation pattern (text input only by default).
678
+	 *                    @type string validation_msg HTML5 validation message (text input only by default).
679
+	 *                    @type string required_msg Required warning message.
680
+	 *                    @type string field_icon Icon url or font awesome class.
681
+	 *                    @type string css_class Field custom css class for field custom style.
682
+	 *                    @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option.
683
+	 *                    @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required)
684
+	 *     }
685
+	 * }
686
+	 * @param string $post_type The post type requested.
687
+	 */
688
+	return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
689 689
 }
690 690
 
691 691
 /**
@@ -698,19 +698,19 @@  discard block
 block discarded – undo
698 698
  */
699 699
 function geodir_custom_available_fields($type='')
700 700
 {
701
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
702
-    ?>
701
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
702
+	?>
703 703
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
704 704
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
705 705
 
706 706
         <?php
707
-        if($type=='predefined'){
708
-            $cfs = geodir_custom_fields_predefined($listing_type);
709
-        }elseif($type=='custom'){
710
-            $cfs = geodir_custom_fields_custom($listing_type);
711
-        }else{
712
-            $cfs = geodir_custom_fields($listing_type);
713
-            ?>
707
+		if($type=='predefined'){
708
+			$cfs = geodir_custom_fields_predefined($listing_type);
709
+		}elseif($type=='custom'){
710
+			$cfs = geodir_custom_fields_custom($listing_type);
711
+		}else{
712
+			$cfs = geodir_custom_fields($listing_type);
713
+			?>
714 714
             <ul class="full gd-cf-tooltip-wrap">
715 715
                 <li>
716 716
                     <div class="gdcf-tooltip">
@@ -731,18 +731,18 @@  discard block
 block discarded – undo
731 731
             </ul>
732 732
 
733 733
             <?php
734
-        }
734
+		}
735 735
 
736
-    if(!empty($cfs)) {
737
-        echo '<ul>';
738
-        foreach ( $cfs as $id => $cf ) {
739
-            ?>
736
+	if(!empty($cfs)) {
737
+		echo '<ul>';
738
+		foreach ( $cfs as $id => $cf ) {
739
+			?>
740 740
 
741 741
             <li class="gd-cf-tooltip-wrap">
742 742
                 <?php
743
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
744
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
745
-                } ?>
743
+				if ( isset( $cf['description'] ) && $cf['description'] ) {
744
+					echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
745
+				} ?>
746 746
 
747 747
                 <a id="gd-<?php echo $id; ?>"
748 748
                    data-field-custom-type="<?php echo $type; ?>"
@@ -752,21 +752,21 @@  discard block
 block discarded – undo
752 752
                    href="javascript:void(0);">
753 753
 
754 754
                     <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], ' fa-' ) !== false ) {
755
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
756
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
757
-                        echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>';
758
-                    } else {
759
-                        echo '<i class="fas fa-cog" aria-hidden="true"></i>';
760
-                    } ?>
755
+						echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
756
+					} elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
757
+						echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>';
758
+					} else {
759
+						echo '<i class="fas fa-cog" aria-hidden="true"></i>';
760
+					} ?>
761 761
                     <?php echo $cf['name']; ?>
762 762
                 </a>
763 763
             </li>
764 764
             <?php
765
-        }
766
-    }else{
767
-        _e('There are no custom fields here yet.', 'geodirectory');
768
-    }
769
-        ?>
765
+		}
766
+	}else{
767
+		_e('There are no custom fields here yet.', 'geodirectory');
768
+	}
769
+		?>
770 770
 
771 771
 
772 772
     </ul>
@@ -785,26 +785,26 @@  discard block
 block discarded – undo
785 785
  */
786 786
 function geodir_custom_selected_fields()
787 787
 {
788
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
789
-    ?>
788
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
789
+	?>
790 790
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
791 791
     <ul class="core">
792 792
     <?php 
793
-        global $wpdb;
794
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
795
-
796
-        if (!empty($fields)) {
797
-            foreach ($fields as $field) {
798
-                //$result_str = $field->id;
799
-                $result_str = $field;
800
-                $field_type = $field->field_type;
801
-                $field_type_key = $field->field_type_key;
802
-                $field_ins_upd = 'display';
803
-
804
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
805
-            }
806
-        }
807
-        ?></ul>
793
+		global $wpdb;
794
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
795
+
796
+		if (!empty($fields)) {
797
+			foreach ($fields as $field) {
798
+				//$result_str = $field->id;
799
+				$result_str = $field;
800
+				$field_type = $field->field_type;
801
+				$field_type_key = $field->field_type_key;
802
+				$field_ins_upd = 'display';
803
+
804
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
805
+			}
806
+		}
807
+		?></ul>
808 808
 <?php
809 809
 
810 810
 }
@@ -823,16 +823,16 @@  discard block
 block discarded – undo
823 823
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
824 824
 {
825 825
 
826
-    switch ($sub_tab) {
827
-        case 'custom_fields':
828
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
829
-            break;
826
+	switch ($sub_tab) {
827
+		case 'custom_fields':
828
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
829
+			break;
830 830
 
831
-        case 'sorting_options':
832
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
833
-            break;
834
-    }
835
-    return $heading;
831
+		case 'sorting_options':
832
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
833
+			break;
834
+	}
835
+	return $heading;
836 836
 }
837 837
 
838 838
 
@@ -850,16 +850,16 @@  discard block
 block discarded – undo
850 850
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
851 851
 {
852 852
 
853
-    switch ($sub_tab) {
854
-        case 'custom_fields':
855
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
856
-            break;
853
+	switch ($sub_tab) {
854
+		case 'custom_fields':
855
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
856
+			break;
857 857
 
858
-        case 'sorting_options':
859
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
860
-            break;
861
-    }
862
-    return $heading;
858
+		case 'sorting_options':
859
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
860
+			break;
861
+	}
862
+	return $heading;
863 863
 }
864 864
 
865 865
 
@@ -877,16 +877,16 @@  discard block
 block discarded – undo
877 877
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
878 878
 {
879 879
 
880
-    switch ($sub_tab) {
881
-        case 'custom_fields':
882
-            $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
883
-            break;
880
+	switch ($sub_tab) {
881
+		case 'custom_fields':
882
+			$note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
883
+			break;
884 884
 
885
-        case 'sorting_options':
886
-            $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing page.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
887
-            break;
888
-    }
889
-    return $note;
885
+		case 'sorting_options':
886
+			$note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing page.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
887
+			break;
888
+	}
889
+	return $note;
890 890
 }
891 891
 
892 892
 
@@ -904,16 +904,16 @@  discard block
 block discarded – undo
904 904
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
905 905
 {
906 906
 
907
-    switch ($sub_tab) {
908
-        case 'custom_fields':
909
-            $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
910
-            break;
907
+	switch ($sub_tab) {
908
+		case 'custom_fields':
909
+			$heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
910
+			break;
911 911
 
912
-        case 'sorting_options':
913
-            $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
914
-            break;
915
-    }
916
-    return $heading;
912
+		case 'sorting_options':
913
+			$heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
914
+			break;
915
+	}
916
+	return $heading;
917 917
 }
918 918
 
919 919
 
@@ -931,16 +931,16 @@  discard block
 block discarded – undo
931 931
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
932 932
 {
933 933
 
934
-    switch ($sub_tab) {
935
-        case 'custom_fields':
936
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
937
-            break;
934
+	switch ($sub_tab) {
935
+		case 'custom_fields':
936
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
937
+			break;
938 938
 
939
-        case 'sorting_options':
940
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
941
-            break;
942
-    }
943
-    return $note;
939
+		case 'sorting_options':
940
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
941
+			break;
942
+	}
943
+	return $note;
944 944
 }
945 945
 
946 946
 
@@ -956,16 +956,16 @@  discard block
 block discarded – undo
956 956
  */
957 957
 function geodir_remove_unnecessary_fields()
958 958
 {
959
-    global $wpdb, $plugin_prefix;
959
+	global $wpdb, $plugin_prefix;
960 960
 
961
-    if (!get_option('geodir_remove_unnecessary_fields')) {
961
+	if (!get_option('geodir_remove_unnecessary_fields')) {
962 962
 
963
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
964
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
963
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
964
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
965 965
 
966
-        update_option('geodir_remove_unnecessary_fields', '1');
966
+		update_option('geodir_remove_unnecessary_fields', '1');
967 967
 
968
-    }
968
+	}
969 969
 
970 970
 }
971 971
 
@@ -983,28 +983,28 @@  discard block
 block discarded – undo
983 983
  */
984 984
 function geodir_admin_ajax_handler()
985 985
 {
986
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
987
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
988
-        $diagnose_this = "";
989
-        switch ($geodir_admin_ajax_action) {
990
-            case 'diagnosis' :
991
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
992
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
993
-                    call_user_func('geodir_diagnose_' . $diagnose_this);
994
-
995
-                }
996
-                exit();
997
-                break;
998
-
999
-            case 'diagnosis-fix' :
1000
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
1001
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1002
-                call_user_func('geodir_diagnose_' . $diagnose_this);
1003
-                exit();
1004
-                break;
1005
-        }
1006
-    }
1007
-    exit();
986
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
987
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
988
+		$diagnose_this = "";
989
+		switch ($geodir_admin_ajax_action) {
990
+			case 'diagnosis' :
991
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
992
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
993
+					call_user_func('geodir_diagnose_' . $diagnose_this);
994
+
995
+				}
996
+				exit();
997
+				break;
998
+
999
+			case 'diagnosis-fix' :
1000
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
1001
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1002
+				call_user_func('geodir_diagnose_' . $diagnose_this);
1003
+				exit();
1004
+				break;
1005
+		}
1006
+	}
1007
+	exit();
1008 1008
 }
1009 1009
 
1010 1010
 
@@ -1022,127 +1022,127 @@  discard block
 block discarded – undo
1022 1022
  */
1023 1023
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
1024 1024
 {
1025
-    global $wpdb;
1026
-    //$filter_arr['output_str'] .='###'.$table.'###';
1027
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1028
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1029
-        $filter_arr['is_error_during_diagnose'] = true;
1030
-
1031
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1032
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1033
-        $filter_arr['is_error_during_diagnose'] = true;
1034
-        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1035
-        $filter_arr['is_error_during_diagnose'] = true;
1036
-
1037
-        if ($fix) {
1038
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1039
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1040
-
1041
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1042
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1043
-
1044
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1045
-
1046
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1047
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1048
-                } else {
1049
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1050
-                }
1051
-
1052
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1053
-
1054
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1055
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1056
-
1057
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1058
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1059
-                } else {
1060
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1061
-                }
1062
-
1063
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1064
-
1065
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1066
-
1067
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1068
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1069
-                } else {
1070
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1071
-                }
1072
-
1073
-            }
1074
-
1075
-        }
1076
-
1077
-
1078
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1079
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1080
-        $filter_arr['is_error_during_diagnose'] = true;
1081
-
1082
-        if ($fix) {
1083
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1084
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1085
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1086
-                } else {
1087
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1088
-                }
1089
-
1090
-            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1091
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1092
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1093
-                } else {
1094
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1095
-                }
1096
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1097
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1098
-                } else {
1099
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1100
-                }
1101
-            } else {// else rename the original table to _ms_bak
1102
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1103
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1104
-                } else {
1105
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1106
-                }
1107
-            }
1108
-        }
1109
-
1110
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1111
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1112
-        $filter_arr['is_error_during_diagnose'] = true;
1113
-
1114
-        if ($fix) {
1115
-            // if original table exists but new does not, rename
1116
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1117
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1118
-            } else {
1119
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1120
-            }
1121
-
1122
-        }
1123
-
1124
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1125
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1126
-        $filter_arr['is_error_during_diagnose'] = true;
1127
-
1128
-        if ($fix) {
1129
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1130
-            delete_option('geodirlocation_db_version');
1131
-            delete_option('geodirevents_db_version');
1132
-            delete_option('geodir_reviewrating_db_version');
1133
-            delete_option('gdevents_db_version');
1134
-            delete_option('geodirectory_db_version');
1135
-            delete_option('geodirclaim_db_version');
1136
-            delete_option('geodir_custom_posts_db_version');
1137
-            delete_option('geodir_reviewratings_db_version');
1138
-            delete_option('geodiradvancesearch_db_version');
1139
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1140
-        }
1141
-
1142
-    } else {
1143
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1144
-    }
1145
-    return $filter_arr;
1025
+	global $wpdb;
1026
+	//$filter_arr['output_str'] .='###'.$table.'###';
1027
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1028
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1029
+		$filter_arr['is_error_during_diagnose'] = true;
1030
+
1031
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1032
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1033
+		$filter_arr['is_error_during_diagnose'] = true;
1034
+		$filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1035
+		$filter_arr['is_error_during_diagnose'] = true;
1036
+
1037
+		if ($fix) {
1038
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1039
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1040
+
1041
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1042
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1043
+
1044
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1045
+
1046
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1047
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1048
+				} else {
1049
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1050
+				}
1051
+
1052
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1053
+
1054
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1055
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1056
+
1057
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1058
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1059
+				} else {
1060
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1061
+				}
1062
+
1063
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1064
+
1065
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1066
+
1067
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1068
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1069
+				} else {
1070
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1071
+				}
1072
+
1073
+			}
1074
+
1075
+		}
1076
+
1077
+
1078
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1079
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1080
+		$filter_arr['is_error_during_diagnose'] = true;
1081
+
1082
+		if ($fix) {
1083
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1084
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1085
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1086
+				} else {
1087
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1088
+				}
1089
+
1090
+			} elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1091
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1092
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1093
+				} else {
1094
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1095
+				}
1096
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1097
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1098
+				} else {
1099
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1100
+				}
1101
+			} else {// else rename the original table to _ms_bak
1102
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1103
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1104
+				} else {
1105
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1106
+				}
1107
+			}
1108
+		}
1109
+
1110
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1111
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1112
+		$filter_arr['is_error_during_diagnose'] = true;
1113
+
1114
+		if ($fix) {
1115
+			// if original table exists but new does not, rename
1116
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1117
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1118
+			} else {
1119
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1120
+			}
1121
+
1122
+		}
1123
+
1124
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1125
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1126
+		$filter_arr['is_error_during_diagnose'] = true;
1127
+
1128
+		if ($fix) {
1129
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
1130
+			delete_option('geodirlocation_db_version');
1131
+			delete_option('geodirevents_db_version');
1132
+			delete_option('geodir_reviewrating_db_version');
1133
+			delete_option('gdevents_db_version');
1134
+			delete_option('geodirectory_db_version');
1135
+			delete_option('geodirclaim_db_version');
1136
+			delete_option('geodir_custom_posts_db_version');
1137
+			delete_option('geodir_reviewratings_db_version');
1138
+			delete_option('geodiradvancesearch_db_version');
1139
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1140
+		}
1141
+
1142
+	} else {
1143
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1144
+	}
1145
+	return $filter_arr;
1146 1146
 }
1147 1147
 
1148 1148
 
@@ -1156,111 +1156,111 @@  discard block
 block discarded – undo
1156 1156
  */
1157 1157
 function geodir_diagnose_tags_sync()
1158 1158
 {
1159
-    global $wpdb, $plugin_prefix;
1160
-    $fix = isset($_POST['fix']) ? true : false;
1161
-    $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0;
1162
-    $step_max_items = geodir_get_diagnose_step_max_items();
1163
-    $offset = (int) $step * $step_max_items;
1164
-    $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false;
1165
-
1166
-    $total_listings = geodir_total_listings_count();
1167
-    $total_ptype_listings = 0;
1168
-    if ($ptype) {
1169
-        $total_ptype_listings = geodir_total_listings_count($ptype);
1170
-    }
1171
-    $max_step = ceil($total_ptype_listings / $step_max_items) - 1;
1159
+	global $wpdb, $plugin_prefix;
1160
+	$fix = isset($_POST['fix']) ? true : false;
1161
+	$step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0;
1162
+	$step_max_items = geodir_get_diagnose_step_max_items();
1163
+	$offset = (int) $step * $step_max_items;
1164
+	$ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false;
1165
+
1166
+	$total_listings = geodir_total_listings_count();
1167
+	$total_ptype_listings = 0;
1168
+	if ($ptype) {
1169
+		$total_ptype_listings = geodir_total_listings_count($ptype);
1170
+	}
1171
+	$max_step = ceil($total_ptype_listings / $step_max_items) - 1;
1172 1172
     
1173
-    //if($fix){echo 'true';}else{echo 'false';}
1174
-    $is_error_during_diagnose = false;
1175
-    $output_str = '';
1173
+	//if($fix){echo 'true';}else{echo 'false';}
1174
+	$is_error_during_diagnose = false;
1175
+	$output_str = '';
1176 1176
     
1177
-    if ($ptype && !empty($ptype) && $total_listings > $step_max_items) {
1178
-        $stepped_process = true;
1179
-    } else {
1180
-        $stepped_process = false;
1181
-    }
1182
-
1183
-    if ($stepped_process) {
1184
-        $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1185
-        $posts = $wpdb->get_results( $sql );
1186
-
1187
-        if (!empty($posts)) {
1188
-
1189
-            foreach ($posts as $p) {
1190
-                $p->post_type = $ptype;
1191
-                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1192
-                if (empty($raw_tags)) {
1193
-                    $post_tags = '';
1194
-                } else {
1195
-                    $post_tags = implode(",", $raw_tags);
1196
-                }
1197
-                $tablename = $plugin_prefix . $p->post_type . '_detail';
1198
-                $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1199
-
1200
-            }
1201
-            if ($step >= $max_step) {
1202
-                $output_str = "done";    
1203
-            } else {
1204
-                $output_str = $step + 1;
1205
-            }
1206
-        }
1207
-
1208
-    } else {
1209
-        $all_postypes = geodir_get_posttypes();
1210
-
1211
-        if (!empty($all_postypes)) {
1212
-            foreach ($all_postypes as $key) {
1213
-                // update each GD CPT
1214
-                $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1215
-
1216
-                if (!empty($posts)) {
1217
-
1218
-                    foreach ($posts as $p) {
1219
-                        $p->post_type = $key;
1220
-                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1221
-                        if (empty($raw_tags)) {
1222
-                            $post_tags = '';
1223
-                        } else {
1224
-                            $post_tags = implode(",", $raw_tags);
1225
-                        }
1226
-                        $tablename = $plugin_prefix . $p->post_type . '_detail';
1227
-                        $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1228
-
1229
-                    }
1230
-                    $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1231
-                }
1232
-
1233
-            }
1234
-
1235
-        }
1236
-    }
1237
-
1238
-
1239
-    if ($is_error_during_diagnose) {
1240
-        $info_div_class = "geodir_problem_info";
1241
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1242
-    } else {
1243
-        $info_div_class = "geodir_noproblem_info";
1244
-        $fix_button_txt = '';
1245
-    }
1246
-
1247
-    if ($stepped_process) {
1248
-        $percent = ($step/$max_step) * 100;
1249
-        if ($output_str == 'done') {
1250
-            echo $output_str;
1251
-        } else {
1252
-            $output = array(
1253
-                'step' => $output_str,
1254
-                'percent' => $percent
1255
-            );
1256
-            echo json_encode($output);
1257
-        }
1258
-    } else {
1259
-        echo "<ul class='$info_div_class'>";
1260
-        echo $output_str;
1261
-        echo $fix_button_txt;
1262
-        echo "</ul>";
1263
-    }
1177
+	if ($ptype && !empty($ptype) && $total_listings > $step_max_items) {
1178
+		$stepped_process = true;
1179
+	} else {
1180
+		$stepped_process = false;
1181
+	}
1182
+
1183
+	if ($stepped_process) {
1184
+		$sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1185
+		$posts = $wpdb->get_results( $sql );
1186
+
1187
+		if (!empty($posts)) {
1188
+
1189
+			foreach ($posts as $p) {
1190
+				$p->post_type = $ptype;
1191
+				$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1192
+				if (empty($raw_tags)) {
1193
+					$post_tags = '';
1194
+				} else {
1195
+					$post_tags = implode(",", $raw_tags);
1196
+				}
1197
+				$tablename = $plugin_prefix . $p->post_type . '_detail';
1198
+				$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1199
+
1200
+			}
1201
+			if ($step >= $max_step) {
1202
+				$output_str = "done";    
1203
+			} else {
1204
+				$output_str = $step + 1;
1205
+			}
1206
+		}
1207
+
1208
+	} else {
1209
+		$all_postypes = geodir_get_posttypes();
1210
+
1211
+		if (!empty($all_postypes)) {
1212
+			foreach ($all_postypes as $key) {
1213
+				// update each GD CPT
1214
+				$posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1215
+
1216
+				if (!empty($posts)) {
1217
+
1218
+					foreach ($posts as $p) {
1219
+						$p->post_type = $key;
1220
+						$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1221
+						if (empty($raw_tags)) {
1222
+							$post_tags = '';
1223
+						} else {
1224
+							$post_tags = implode(",", $raw_tags);
1225
+						}
1226
+						$tablename = $plugin_prefix . $p->post_type . '_detail';
1227
+						$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1228
+
1229
+					}
1230
+					$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1231
+				}
1232
+
1233
+			}
1234
+
1235
+		}
1236
+	}
1237
+
1238
+
1239
+	if ($is_error_during_diagnose) {
1240
+		$info_div_class = "geodir_problem_info";
1241
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1242
+	} else {
1243
+		$info_div_class = "geodir_noproblem_info";
1244
+		$fix_button_txt = '';
1245
+	}
1246
+
1247
+	if ($stepped_process) {
1248
+		$percent = ($step/$max_step) * 100;
1249
+		if ($output_str == 'done') {
1250
+			echo $output_str;
1251
+		} else {
1252
+			$output = array(
1253
+				'step' => $output_str,
1254
+				'percent' => $percent
1255
+			);
1256
+			echo json_encode($output);
1257
+		}
1258
+	} else {
1259
+		echo "<ul class='$info_div_class'>";
1260
+		echo $output_str;
1261
+		echo $fix_button_txt;
1262
+		echo "</ul>";
1263
+	}
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1275,75 +1275,75 @@  discard block
 block discarded – undo
1275 1275
  */
1276 1276
 function geodir_diagnose_cats_sync()
1277 1277
 {
1278
-    global $wpdb, $plugin_prefix;
1279
-    $fix = isset($_POST['fix']) ? true : false;
1278
+	global $wpdb, $plugin_prefix;
1279
+	$fix = isset($_POST['fix']) ? true : false;
1280 1280
 
1281
-    //if($fix){echo 'true';}else{echo 'false';}
1282
-    $is_error_during_diagnose = false;
1283
-    $output_str = '';
1281
+	//if($fix){echo 'true';}else{echo 'false';}
1282
+	$is_error_during_diagnose = false;
1283
+	$output_str = '';
1284 1284
 
1285 1285
 
1286
-    $all_postypes = geodir_get_posttypes();
1286
+	$all_postypes = geodir_get_posttypes();
1287 1287
 
1288
-    if (!empty($all_postypes)) {
1289
-        foreach ($all_postypes as $key) {
1290
-            // update each GD CTP
1291
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1288
+	if (!empty($all_postypes)) {
1289
+		foreach ($all_postypes as $key) {
1290
+			// update each GD CTP
1291
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1292 1292
 
1293
-            if (!empty($posts)) {
1293
+			if (!empty($posts)) {
1294 1294
 
1295
-                foreach ($posts as $p) {
1296
-                    $p->post_type = $key;
1297
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1295
+				foreach ($posts as $p) {
1296
+					$p->post_type = $key;
1297
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1298 1298
 
1299
-                    if (empty($raw_cats)) {
1300
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1299
+					if (empty($raw_cats)) {
1300
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
1301 1301
 
1302
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1303
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1304
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1305
-                                if (is_numeric($cat_part)) {
1306
-                                    $raw_cats[] = (int)$cat_part;
1307
-                                }
1308
-                            }
1302
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1303
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1304
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1305
+								if (is_numeric($cat_part)) {
1306
+									$raw_cats[] = (int)$cat_part;
1307
+								}
1308
+							}
1309 1309
 
1310
-                        }
1310
+						}
1311 1311
 
1312
-                        if (!empty($raw_cats)) {
1313
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1312
+						if (!empty($raw_cats)) {
1313
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1314 1314
 
1315
-                        }
1315
+						}
1316 1316
 
1317
-                    }
1317
+					}
1318 1318
 
1319 1319
 
1320
-                    if (empty($raw_cats)) {
1321
-                        $post_cats = '';
1322
-                    } else {
1323
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1324
-                    }
1325
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1326
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1327
-                }
1320
+					if (empty($raw_cats)) {
1321
+						$post_cats = '';
1322
+					} else {
1323
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1324
+					}
1325
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1326
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1327
+				}
1328 1328
 
1329
-            }
1330
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1329
+			}
1330
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1331 1331
 
1332
-        }
1332
+		}
1333 1333
 
1334
-    }
1334
+	}
1335 1335
 
1336
-    if ($is_error_during_diagnose) {
1337
-        $info_div_class = "geodir_problem_info";
1338
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1339
-    } else {
1340
-        $info_div_class = "geodir_noproblem_info";
1341
-        $fix_button_txt = '';
1342
-    }
1343
-    echo "<ul class='$info_div_class'>";
1344
-    echo $output_str;
1345
-    echo $fix_button_txt;
1346
-    echo "</ul>";
1336
+	if ($is_error_during_diagnose) {
1337
+		$info_div_class = "geodir_problem_info";
1338
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1339
+	} else {
1340
+		$info_div_class = "geodir_noproblem_info";
1341
+		$fix_button_txt = '';
1342
+	}
1343
+	echo "<ul class='$info_div_class'>";
1344
+	echo $output_str;
1345
+	echo $fix_button_txt;
1346
+	echo "</ul>";
1347 1347
 
1348 1348
 }
1349 1349
 
@@ -1357,61 +1357,61 @@  discard block
 block discarded – undo
1357 1357
  */
1358 1358
 function geodir_diagnose_version_clear()
1359 1359
 {
1360
-    global $wpdb, $plugin_prefix;
1361
-    $fix = isset($_POST['fix']) ? true : false;
1362
-
1363
-    //if($fix){echo 'true';}else{echo 'false';}
1364
-    $is_error_during_diagnose = false;
1365
-    $output_str = '';
1366
-
1367
-
1368
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1369
-        'Payment Manager' => 'geodir_payments_db_version',
1370
-        'GeoDirectory Framework' => 'gdf_db_version',
1371
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1372
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1373
-        'Claim Manager' => 'geodirclaim_db_version',
1374
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1375
-        'Location Manager' => 'geodirlocation_db_version',
1376
-        'Payment Manager' => 'geodir_payments_db_version',
1377
-        'Events Manager' => 'geodirevents_db_version',
1378
-    );
1379
-
1380
-    /**
1381
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1382
-     *
1383
-     * @since 1.0.0
1384
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1385
-     */
1386
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1387
-
1388
-    if (!empty($ver_arr)) {
1389
-        foreach ($ver_arr as $key => $val) {
1390
-            if (delete_option($val)) {
1391
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1392
-            } else {
1393
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1394
-            }
1395
-
1396
-        }
1397
-
1398
-        if ($output_str) {
1399
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1400
-        }
1401
-
1402
-    }
1403
-
1404
-    if ($is_error_during_diagnose) {
1405
-        $info_div_class = "geodir_problem_info";
1406
-        $fix_button_txt = "";
1407
-    } else {
1408
-        $info_div_class = "geodir_noproblem_info";
1409
-        $fix_button_txt = '';
1410
-    }
1411
-    echo "<ul class='$info_div_class'>";
1412
-    echo $output_str;
1413
-    echo $fix_button_txt;
1414
-    echo "</ul>";
1360
+	global $wpdb, $plugin_prefix;
1361
+	$fix = isset($_POST['fix']) ? true : false;
1362
+
1363
+	//if($fix){echo 'true';}else{echo 'false';}
1364
+	$is_error_during_diagnose = false;
1365
+	$output_str = '';
1366
+
1367
+
1368
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1369
+		'Payment Manager' => 'geodir_payments_db_version',
1370
+		'GeoDirectory Framework' => 'gdf_db_version',
1371
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1372
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1373
+		'Claim Manager' => 'geodirclaim_db_version',
1374
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1375
+		'Location Manager' => 'geodirlocation_db_version',
1376
+		'Payment Manager' => 'geodir_payments_db_version',
1377
+		'Events Manager' => 'geodirevents_db_version',
1378
+	);
1379
+
1380
+	/**
1381
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1382
+	 *
1383
+	 * @since 1.0.0
1384
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1385
+	 */
1386
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1387
+
1388
+	if (!empty($ver_arr)) {
1389
+		foreach ($ver_arr as $key => $val) {
1390
+			if (delete_option($val)) {
1391
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1392
+			} else {
1393
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1394
+			}
1395
+
1396
+		}
1397
+
1398
+		if ($output_str) {
1399
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1400
+		}
1401
+
1402
+	}
1403
+
1404
+	if ($is_error_during_diagnose) {
1405
+		$info_div_class = "geodir_problem_info";
1406
+		$fix_button_txt = "";
1407
+	} else {
1408
+		$info_div_class = "geodir_noproblem_info";
1409
+		$fix_button_txt = '';
1410
+	}
1411
+	echo "<ul class='$info_div_class'>";
1412
+	echo $output_str;
1413
+	echo $fix_button_txt;
1414
+	echo "</ul>";
1415 1415
 
1416 1416
 }
1417 1417
 
@@ -1425,12 +1425,12 @@  discard block
 block discarded – undo
1425 1425
  */
1426 1426
 function geodir_diagnose_ratings()
1427 1427
 {
1428
-    global $wpdb;
1429
-    $fix = isset($_POST['fix']) ? true : false;
1428
+	global $wpdb;
1429
+	$fix = isset($_POST['fix']) ? true : false;
1430 1430
 
1431
-    //if($fix){echo 'true';}else{echo 'false';}
1432
-    $is_error_during_diagnose = false;
1433
-    $output_str = '';
1431
+	//if($fix){echo 'true';}else{echo 'false';}
1432
+	$is_error_during_diagnose = false;
1433
+	$output_str = '';
1434 1434
 
1435 1435
 	$gd_post_types = geodir_get_posttypes();
1436 1436
 
@@ -1446,52 +1446,52 @@  discard block
 block discarded – undo
1446 1446
 	}
1447 1447
 	$skip_post_types_where = ! empty( $skip_post_types ) ? " AND post_type NOT IN( '" . implode( "','", $skip_post_types ) . "' )" : '';
1448 1448
 
1449
-    // check review locations
1450
-    if ($wpdb->get_var("SELECT COUNT(*) FROM " . GEODIR_REVIEW_TABLE . " WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) {
1451
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1452
-        $is_error_during_diagnose = true;
1453
-
1454
-        if ($fix) {
1455
-            if (geodir_fix_review_location()) {
1456
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1457
-            } else {
1458
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1459
-            }
1460
-        }
1461
-
1462
-    } else {
1463
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1464
-    }
1465
-
1466
-    // check review content
1467
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1468
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1469
-        $is_error_during_diagnose = true;
1470
-
1471
-        if ($fix) {
1472
-            if (geodir_fix_review_content()) {
1473
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1474
-            } else {
1475
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1476
-            }
1477
-        }
1478
-
1479
-    } else {
1480
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1481
-    }
1482
-
1483
-
1484
-    if ($is_error_during_diagnose) {
1485
-        $info_div_class = "geodir_problem_info";
1486
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1487
-    } else {
1488
-        $info_div_class = "geodir_noproblem_info";
1489
-        $fix_button_txt = '';
1490
-    }
1491
-    echo "<ul class='$info_div_class'>";
1492
-    echo $output_str;
1493
-    echo $fix_button_txt;
1494
-    echo "</ul>";
1449
+	// check review locations
1450
+	if ($wpdb->get_var("SELECT COUNT(*) FROM " . GEODIR_REVIEW_TABLE . " WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) {
1451
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1452
+		$is_error_during_diagnose = true;
1453
+
1454
+		if ($fix) {
1455
+			if (geodir_fix_review_location()) {
1456
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1457
+			} else {
1458
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1459
+			}
1460
+		}
1461
+
1462
+	} else {
1463
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1464
+	}
1465
+
1466
+	// check review content
1467
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1468
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1469
+		$is_error_during_diagnose = true;
1470
+
1471
+		if ($fix) {
1472
+			if (geodir_fix_review_content()) {
1473
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1474
+			} else {
1475
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1476
+			}
1477
+		}
1478
+
1479
+	} else {
1480
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1481
+	}
1482
+
1483
+
1484
+	if ($is_error_during_diagnose) {
1485
+		$info_div_class = "geodir_problem_info";
1486
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1487
+	} else {
1488
+		$info_div_class = "geodir_noproblem_info";
1489
+		$fix_button_txt = '';
1490
+	}
1491
+	echo "<ul class='$info_div_class'>";
1492
+	echo $output_str;
1493
+	echo $fix_button_txt;
1494
+	echo "</ul>";
1495 1495
 
1496 1496
 }
1497 1497
 
@@ -1505,57 +1505,57 @@  discard block
 block discarded – undo
1505 1505
  */
1506 1506
 function geodir_diagnose_multisite_conversion()
1507 1507
 {
1508
-    global $wpdb;
1509
-    $fix = isset($_POST['fix']) ? true : false;
1510
-    //if($fix){echo 'true';}else{echo 'false';}
1511
-    $is_error_during_diagnose = false;
1512
-    $output_str = '';
1513
-
1514
-    $filter_arr = array();
1515
-    $filter_arr['output_str'] = $output_str;
1516
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1517
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1518
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1519
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1520
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1521
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1522
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1523
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1524
-    );
1525
-
1526
-    // allow other addons to hook in and add their checks
1527
-
1528
-    /**
1529
-     * Filter the array of tables.
1530
-     *
1531
-     * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1532
-     *
1533
-     * @since 1.0.0
1534
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1535
-     */
1536
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1537
-
1538
-    foreach ($table_arr as $table => $table_name) {
1539
-        // Diagnose table
1540
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1541
-    }
1542
-
1543
-
1544
-    $output_str = $filter_arr['output_str'];
1545
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1546
-
1547
-
1548
-    if ($is_error_during_diagnose) {
1549
-        $info_div_class = "geodir_problem_info";
1550
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1551
-    } else {
1552
-        $info_div_class = "geodir_noproblem_info";
1553
-        $fix_button_txt = '';
1554
-    }
1555
-    echo "<ul class='$info_div_class'>";
1556
-    echo $output_str;
1557
-    echo $fix_button_txt;
1558
-    echo "</ul>";
1508
+	global $wpdb;
1509
+	$fix = isset($_POST['fix']) ? true : false;
1510
+	//if($fix){echo 'true';}else{echo 'false';}
1511
+	$is_error_during_diagnose = false;
1512
+	$output_str = '';
1513
+
1514
+	$filter_arr = array();
1515
+	$filter_arr['output_str'] = $output_str;
1516
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1517
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1518
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1519
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1520
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1521
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1522
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1523
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1524
+	);
1525
+
1526
+	// allow other addons to hook in and add their checks
1527
+
1528
+	/**
1529
+	 * Filter the array of tables.
1530
+	 *
1531
+	 * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1532
+	 *
1533
+	 * @since 1.0.0
1534
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1535
+	 */
1536
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1537
+
1538
+	foreach ($table_arr as $table => $table_name) {
1539
+		// Diagnose table
1540
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1541
+	}
1542
+
1543
+
1544
+	$output_str = $filter_arr['output_str'];
1545
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1546
+
1547
+
1548
+	if ($is_error_during_diagnose) {
1549
+		$info_div_class = "geodir_problem_info";
1550
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1551
+	} else {
1552
+		$info_div_class = "geodir_noproblem_info";
1553
+		$fix_button_txt = '';
1554
+	}
1555
+	echo "<ul class='$info_div_class'>";
1556
+	echo $output_str;
1557
+	echo $fix_button_txt;
1558
+	echo "</ul>";
1559 1559
 }
1560 1560
 
1561 1561
 /**
@@ -1573,39 +1573,39 @@  discard block
 block discarded – undo
1573 1573
  */
1574 1574
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1575 1575
 {
1576
-    global $wpdb, $current_user;
1577
-
1578
-    if (!empty($old_id)) {
1579
-        wp_delete_post($old_id, true);
1580
-    }//delete post if already there
1581
-    else {
1582
-        $page_found = $wpdb->get_var(
1583
-            $wpdb->prepare(
1584
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1585
-                array($slug)
1586
-            )
1587
-        );
1588
-        wp_delete_post($page_found, true);
1589
-
1590
-    }
1591
-
1592
-    $page_data = array(
1593
-        'post_status' => 'publish',
1594
-        'post_type' => 'page',
1595
-        'post_author' => $current_user->ID,
1596
-        'post_name' => $slug,
1597
-        'post_title' => $page_title,
1598
-        'post_content' => '',
1599
-        'post_parent' => 0,
1600
-        'comment_status' => 'closed'
1601
-    );
1602
-    $page_id = wp_insert_post($page_data);
1603
-    update_option($option, $page_id);
1604
-    if ($page_id) {
1605
-        return true;
1606
-    } else {
1607
-        return false;
1608
-    }
1576
+	global $wpdb, $current_user;
1577
+
1578
+	if (!empty($old_id)) {
1579
+		wp_delete_post($old_id, true);
1580
+	}//delete post if already there
1581
+	else {
1582
+		$page_found = $wpdb->get_var(
1583
+			$wpdb->prepare(
1584
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1585
+				array($slug)
1586
+			)
1587
+		);
1588
+		wp_delete_post($page_found, true);
1589
+
1590
+	}
1591
+
1592
+	$page_data = array(
1593
+		'post_status' => 'publish',
1594
+		'post_type' => 'page',
1595
+		'post_author' => $current_user->ID,
1596
+		'post_name' => $slug,
1597
+		'post_title' => $page_title,
1598
+		'post_content' => '',
1599
+		'post_parent' => 0,
1600
+		'comment_status' => 'closed'
1601
+	);
1602
+	$page_id = wp_insert_post($page_data);
1603
+	update_option($option, $page_id);
1604
+	if ($page_id) {
1605
+		return true;
1606
+	} else {
1607
+		return false;
1608
+	}
1609 1609
 }
1610 1610
 
1611 1611
 /**
@@ -1617,212 +1617,212 @@  discard block
 block discarded – undo
1617 1617
  */
1618 1618
 function geodir_diagnose_default_pages()
1619 1619
 {
1620
-    global $wpdb;
1621
-    $is_error_during_diagnose = false;
1622
-    $output_str = '';
1623
-    $fix = isset($_POST['fix']) ? true : false;
1624
-
1625
-    //////////////////////////////////
1626
-    /* Diagnose GD Home Page Starts */
1627
-    //////////////////////////////////
1628
-    $option_value = get_option('geodir_home_page');
1629
-    $page = get_post($option_value);
1630
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1631
-
1632
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1633
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1634
-    else {
1635
-        $is_error_during_diagnose = true;
1636
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1637
-        if ($fix) {
1638
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1639
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1640
-            } else {
1641
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1642
-            }
1643
-        }
1644
-    }
1645
-
1646
-    ////////////////////////////////
1647
-    /* Diagnose GD Home Page Ends */
1648
-    ////////////////////////////////
1649
-
1650
-    //////////////////////////////////
1651
-    /* Diagnose Add Listing Page Starts */
1652
-    //////////////////////////////////
1653
-    $option_value = get_option('geodir_add_listing_page');
1654
-    $page = get_post($option_value);
1655
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1656
-
1657
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1658
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1659
-    else {
1660
-        $is_error_during_diagnose = true;
1661
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1662
-        if ($fix) {
1663
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1664
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1665
-            } else {
1666
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1667
-            }
1668
-        }
1669
-    }
1670
-
1671
-    ////////////////////////////////
1672
-    /* Diagnose Add Listing Page Ends */
1673
-    ////////////////////////////////
1674
-
1675
-
1676
-    //////////////////////////////////
1677
-    /* Diagnose Listing Preview Page Starts */
1678
-    //////////////////////////////////
1679
-    $option_value = get_option('geodir_preview_page');
1680
-    $page = get_post($option_value);
1681
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1682
-
1683
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1684
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1685
-    else {
1686
-        $is_error_during_diagnose = true;
1687
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1688
-        if ($fix) {
1689
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1690
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1691
-            } else {
1692
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1693
-            }
1694
-        }
1695
-    }
1696
-
1697
-    ////////////////////////////////
1698
-    /* Diagnose Listing Preview Page Ends */
1699
-    ////////////////////////////////
1700
-
1701
-    //////////////////////////////////
1702
-    /* Diagnose Listing Success Page Starts */
1703
-    //////////////////////////////////
1704
-    $option_value = get_option('geodir_success_page');
1705
-    $page = get_post($option_value);
1706
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1707
-
1708
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1709
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1710
-    else {
1711
-        $is_error_during_diagnose = true;
1712
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1713
-        if ($fix) {
1714
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1715
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1716
-            } else {
1717
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1718
-            }
1719
-        }
1720
-    }
1721
-
1722
-    ////////////////////////////////
1723
-    /* Diagnose Listing Sucess Page Ends */
1724
-    ////////////////////////////////
1725
-
1726
-    //////////////////////////////////
1727
-    /* Diagnose Info Page Starts */
1728
-    //////////////////////////////////
1729
-    $option_value = get_option('geodir_info_page');
1730
-    $page = get_post($option_value);
1731
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1732
-
1733
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1734
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1735
-    else {
1736
-        $is_error_during_diagnose = true;
1737
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1738
-        if ($fix) {
1739
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1740
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1741
-            } else {
1742
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1743
-            }
1744
-        }
1745
-    }
1746
-
1747
-    ////////////////////////////////
1748
-    /* Diagnose Info Page Ends */
1749
-    ////////////////////////////////
1750
-
1751
-    //////////////////////////////////
1752
-    /* Diagnose Login Page Starts */
1753
-    //////////////////////////////////
1754
-    $option_value = get_option('geodir_login_page');
1755
-    $page = get_post($option_value);
1756
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1757
-
1758
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1759
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1760
-    else {
1761
-        $is_error_during_diagnose = true;
1762
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1763
-        if ($fix) {
1764
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1765
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1766
-            } else {
1767
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1768
-            }
1769
-        }
1770
-    }
1771
-
1772
-    ////////////////////////////////
1773
-    /* Diagnose Info Page Ends */
1774
-    ////////////////////////////////
1775
-
1776
-    //////////////////////////////////
1777
-    /* Diagnose Location Page Starts */
1778
-    //////////////////////////////////
1779
-    $option_value = get_option('geodir_location_page');
1780
-    $page = get_post($option_value);
1781
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1782
-
1783
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1784
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1785
-    else {
1786
-        $is_error_during_diagnose = true;
1787
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1788
-        if ($fix) {
1789
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1790
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1791
-            } else {
1792
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1793
-            }
1794
-        }
1795
-    }
1796
-
1797
-    ////////////////////////////////
1798
-    /* Diagnose Location Page Ends */
1799
-    ////////////////////////////////
1800
-
1801
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1802
-    /**
1803
-     * This action is called at the end of the GD Tools page check function.
1804
-     *
1805
-     * @since 1.5.2
1806
-     */
1807
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1808
-
1809
-    $output_str = $page_chk_arr['output_str'];
1810
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1811
-
1812
-    if ($is_error_during_diagnose) {
1813
-        if ($fix) {
1814
-            flush_rewrite_rules();
1815
-        }
1816
-        $info_div_class = "geodir_problem_info";
1817
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1818
-    } else {
1819
-        $info_div_class = "geodir_noproblem_info";
1820
-        $fix_button_txt = '';
1821
-    }
1822
-    echo "<ul class='$info_div_class'>";
1823
-    echo $output_str;
1824
-    echo $fix_button_txt;
1825
-    echo "</ul>";
1620
+	global $wpdb;
1621
+	$is_error_during_diagnose = false;
1622
+	$output_str = '';
1623
+	$fix = isset($_POST['fix']) ? true : false;
1624
+
1625
+	//////////////////////////////////
1626
+	/* Diagnose GD Home Page Starts */
1627
+	//////////////////////////////////
1628
+	$option_value = get_option('geodir_home_page');
1629
+	$page = get_post($option_value);
1630
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1631
+
1632
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1633
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1634
+	else {
1635
+		$is_error_during_diagnose = true;
1636
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1637
+		if ($fix) {
1638
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1639
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1640
+			} else {
1641
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1642
+			}
1643
+		}
1644
+	}
1645
+
1646
+	////////////////////////////////
1647
+	/* Diagnose GD Home Page Ends */
1648
+	////////////////////////////////
1649
+
1650
+	//////////////////////////////////
1651
+	/* Diagnose Add Listing Page Starts */
1652
+	//////////////////////////////////
1653
+	$option_value = get_option('geodir_add_listing_page');
1654
+	$page = get_post($option_value);
1655
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1656
+
1657
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1658
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1659
+	else {
1660
+		$is_error_during_diagnose = true;
1661
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1662
+		if ($fix) {
1663
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1664
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1665
+			} else {
1666
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1667
+			}
1668
+		}
1669
+	}
1670
+
1671
+	////////////////////////////////
1672
+	/* Diagnose Add Listing Page Ends */
1673
+	////////////////////////////////
1674
+
1675
+
1676
+	//////////////////////////////////
1677
+	/* Diagnose Listing Preview Page Starts */
1678
+	//////////////////////////////////
1679
+	$option_value = get_option('geodir_preview_page');
1680
+	$page = get_post($option_value);
1681
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1682
+
1683
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1684
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1685
+	else {
1686
+		$is_error_during_diagnose = true;
1687
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1688
+		if ($fix) {
1689
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1690
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1691
+			} else {
1692
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1693
+			}
1694
+		}
1695
+	}
1696
+
1697
+	////////////////////////////////
1698
+	/* Diagnose Listing Preview Page Ends */
1699
+	////////////////////////////////
1700
+
1701
+	//////////////////////////////////
1702
+	/* Diagnose Listing Success Page Starts */
1703
+	//////////////////////////////////
1704
+	$option_value = get_option('geodir_success_page');
1705
+	$page = get_post($option_value);
1706
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1707
+
1708
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1709
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1710
+	else {
1711
+		$is_error_during_diagnose = true;
1712
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1713
+		if ($fix) {
1714
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1715
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1716
+			} else {
1717
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1718
+			}
1719
+		}
1720
+	}
1721
+
1722
+	////////////////////////////////
1723
+	/* Diagnose Listing Sucess Page Ends */
1724
+	////////////////////////////////
1725
+
1726
+	//////////////////////////////////
1727
+	/* Diagnose Info Page Starts */
1728
+	//////////////////////////////////
1729
+	$option_value = get_option('geodir_info_page');
1730
+	$page = get_post($option_value);
1731
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1732
+
1733
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1734
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1735
+	else {
1736
+		$is_error_during_diagnose = true;
1737
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1738
+		if ($fix) {
1739
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1740
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1741
+			} else {
1742
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1743
+			}
1744
+		}
1745
+	}
1746
+
1747
+	////////////////////////////////
1748
+	/* Diagnose Info Page Ends */
1749
+	////////////////////////////////
1750
+
1751
+	//////////////////////////////////
1752
+	/* Diagnose Login Page Starts */
1753
+	//////////////////////////////////
1754
+	$option_value = get_option('geodir_login_page');
1755
+	$page = get_post($option_value);
1756
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1757
+
1758
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1759
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1760
+	else {
1761
+		$is_error_during_diagnose = true;
1762
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1763
+		if ($fix) {
1764
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1765
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1766
+			} else {
1767
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1768
+			}
1769
+		}
1770
+	}
1771
+
1772
+	////////////////////////////////
1773
+	/* Diagnose Info Page Ends */
1774
+	////////////////////////////////
1775
+
1776
+	//////////////////////////////////
1777
+	/* Diagnose Location Page Starts */
1778
+	//////////////////////////////////
1779
+	$option_value = get_option('geodir_location_page');
1780
+	$page = get_post($option_value);
1781
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1782
+
1783
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1784
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1785
+	else {
1786
+		$is_error_during_diagnose = true;
1787
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1788
+		if ($fix) {
1789
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1790
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1791
+			} else {
1792
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1793
+			}
1794
+		}
1795
+	}
1796
+
1797
+	////////////////////////////////
1798
+	/* Diagnose Location Page Ends */
1799
+	////////////////////////////////
1800
+
1801
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1802
+	/**
1803
+	 * This action is called at the end of the GD Tools page check function.
1804
+	 *
1805
+	 * @since 1.5.2
1806
+	 */
1807
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1808
+
1809
+	$output_str = $page_chk_arr['output_str'];
1810
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1811
+
1812
+	if ($is_error_during_diagnose) {
1813
+		if ($fix) {
1814
+			flush_rewrite_rules();
1815
+		}
1816
+		$info_div_class = "geodir_problem_info";
1817
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1818
+	} else {
1819
+		$info_div_class = "geodir_noproblem_info";
1820
+		$fix_button_txt = '';
1821
+	}
1822
+	echo "<ul class='$info_div_class'>";
1823
+	echo $output_str;
1824
+	echo $fix_button_txt;
1825
+	echo "</ul>";
1826 1826
 
1827 1827
 }
1828 1828
 
@@ -1834,26 +1834,26 @@  discard block
 block discarded – undo
1834 1834
  * @global object $wpdb WordPress Database object.
1835 1835
  */
1836 1836
 function geodir_diagnose_load_db_language() {
1837
-    global $wpdb;
1837
+	global $wpdb;
1838 1838
 	
1839 1839
 	$is_error_during_diagnose = geodirectory_load_db_language();
1840 1840
 
1841
-    $output_str = '';
1842
-    $fix_button_txt = '';
1841
+	$output_str = '';
1842
+	$fix_button_txt = '';
1843 1843
 
1844
-    if ($is_error_during_diagnose) {
1845
-        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1844
+	if ($is_error_during_diagnose) {
1845
+		$output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1846 1846
 		$info_div_class = "geodir_problem_info";
1847
-    } else {
1848
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1847
+	} else {
1848
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1849 1849
 		$info_div_class = "geodir_noproblem_info";
1850
-        $fix_button_txt = '';
1851
-    }
1850
+		$fix_button_txt = '';
1851
+	}
1852 1852
     
1853 1853
 	echo "<ul class='$info_div_class'>";
1854
-    echo $output_str;
1855
-    echo $fix_button_txt;
1856
-    echo "</ul>";
1854
+	echo $output_str;
1855
+	echo $fix_button_txt;
1856
+	echo "</ul>";
1857 1857
 
1858 1858
 }
1859 1859
 
@@ -1884,23 +1884,23 @@  discard block
 block discarded – undo
1884 1884
  */
1885 1885
 function geodir_posts_clauses_request($clauses)
1886 1886
 {
1887
-    global $wpdb, $wp_query, $plugin_prefix;
1887
+	global $wpdb, $wp_query, $plugin_prefix;
1888 1888
 
1889
-    if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1890
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1889
+	if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1890
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1891 1891
 
1892
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1893
-        $clauses['join'] = $join;
1892
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1893
+		$clauses['join'] = $join;
1894 1894
 
1895
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1896
-        $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1897
-        $clauses['fields'] = $fields;
1895
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1896
+		$fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1897
+		$clauses['fields'] = $fields;
1898 1898
 
1899
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1900
-        $orderby = 'gd_expire ' . $order;
1901
-        $clauses['orderby'] = $orderby;
1902
-    }
1903
-    return $clauses;
1899
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1900
+		$orderby = 'gd_expire ' . $order;
1901
+		$clauses['orderby'] = $orderby;
1902
+	}
1903
+	return $clauses;
1904 1904
 }
1905 1905
 
1906 1906
 
@@ -1921,7 +1921,7 @@  discard block
 block discarded – undo
1921 1921
  */
1922 1922
 function gd_theme_switch_compat_check()
1923 1923
 {
1924
-    gd_set_theme_compat();
1924
+	gd_set_theme_compat();
1925 1925
 }
1926 1926
 
1927 1927
 /**
@@ -1934,27 +1934,27 @@  discard block
 block discarded – undo
1934 1934
  */
1935 1935
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1936 1936
 {
1937
-    if (function_exists('str_getcsv')) {
1938
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1939
-    } else {
1940
-        global $current_user;
1941
-        $upload_dir = wp_upload_dir();
1942
-
1943
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1944
-        $handle = fopen($file, 'w');
1945
-
1946
-        fwrite($handle, $input);
1947
-        fclose($handle);
1948
-
1949
-        $handle = fopen($file, 'rt');
1950
-        if (PHP_VERSION >= '5.3.0') {
1951
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1952
-        } else {
1953
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1954
-        }
1955
-        fclose($handle);
1956
-    }
1957
-    return $fgetcsv;
1937
+	if (function_exists('str_getcsv')) {
1938
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1939
+	} else {
1940
+		global $current_user;
1941
+		$upload_dir = wp_upload_dir();
1942
+
1943
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1944
+		$handle = fopen($file, 'w');
1945
+
1946
+		fwrite($handle, $input);
1947
+		fclose($handle);
1948
+
1949
+		$handle = fopen($file, 'rt');
1950
+		if (PHP_VERSION >= '5.3.0') {
1951
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1952
+		} else {
1953
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1954
+		}
1955
+		fclose($handle);
1956
+	}
1957
+	return $fgetcsv;
1958 1958
 }
1959 1959
 
1960 1960
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1969,375 +1969,375 @@  discard block
 block discarded – undo
1969 1969
  */
1970 1970
 function geodir_ajax_import_csv()
1971 1971
 {
1972
-    error_reporting(0); // hide error to get clean json response
1972
+	error_reporting(0); // hide error to get clean json response
1973 1973
 
1974
-    global $wpdb, $plugin_prefix, $current_user;
1975
-    $uploads = wp_upload_dir();
1976
-    @ini_set('auto_detect_line_endings', true);
1974
+	global $wpdb, $plugin_prefix, $current_user;
1975
+	$uploads = wp_upload_dir();
1976
+	@ini_set('auto_detect_line_endings', true);
1977 1977
 	
1978 1978
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1979 1979
 
1980
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1981
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1982
-    $filename = $uploadedFile;
1983
-
1984
-    $uploads = wp_upload_dir();
1985
-    $uploads_dir = $uploads['path'];
1986
-    $image_name_arr = explode('/', $filename);
1987
-    $filename = end($image_name_arr);
1988
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1989
-    $return = array();
1990
-    $return['file'] = $uploadedFile;
1991
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1992
-
1993
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1994
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1995
-
1996
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1997
-            $return['error'] = NULL;
1998
-
1999
-            $return['rows'] = 0;
2000
-
2001
-
2002
-
2003
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
2004
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
2005
-                        if(is_array($data) && !empty($data)) {
2006
-                            $file[] = '"' . implode('","', $data) . '"';
2007
-                        }
2008
-                    }
2009
-                    fclose($handle);
2010
-                    $file = $file;
2011
-                }
2012
-
2013
-
2014
-
2015
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
2016
-
2017
-
2018
-            if (!$return['rows'] > 0) {
2019
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
2020
-            }
2021
-        }
2022
-    }
2023
-    if ($task == 'prepare' || !empty($return['error'])) {
2024
-        echo json_encode($return);
2025
-        exit;
2026
-    }
2027
-
2028
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
2029
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
2030
-    $count = $importlimit;
2031
-    $requested_limit = $importlimit;
2032
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
2033
-
2034
-    if ($count < $totRecords) {
2035
-        $count = $tmpCnt + $count;
2036
-        if ($count > $totRecords) {
2037
-            $count = $totRecords;
2038
-        }
2039
-    } else {
2040
-        $count = $totRecords;
2041
-    }
2042
-
2043
-    $total_records = 0;
2044
-    $rowcount = 0;
2045
-    $address_invalid = 0;
2046
-    $blank_address = 0;
2047
-    $upload_files = 0;
2048
-    $invalid_post_type = 0;
2049
-    $invalid_title = 0;
2050
-    $customKeyarray = array();
2051
-    $gd_post_info = array();
2052
-    $post_location = array();
2053
-    $countpost = 0;
2054
-
2055
-    if (!empty($file)) {
2056
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
2057
-        $customKeyarray = $columns;
2058
-
2059
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
2060
-            $return['error'] = CSV_INVAILD_FILE;
2061
-            echo json_encode($return);
2062
-            exit;
2063
-        }
2064
-
2065
-        for ($i = 1; $i <= $importlimit; $i++) {
2066
-            $current_index = $tmpCnt + $i;
2067
-            if (isset($file[$current_index])) {
2068
-                $total_records++;
2069
-
2070
-                $buffer = geodir_str_getcsv($file[$current_index]);
2071
-                $post_title = addslashes($buffer[0]);
2072
-                $current_post_author = $buffer[1];
2073
-                $post_desc = addslashes($buffer[2]);
2074
-                $post_cat = array();
2075
-                $catids_arr = array();
2076
-                $post_cat = trim($buffer[3]); // comma seperated category name
2077
-
2078
-                if ($post_cat) {
2079
-                    $post_cat_arr = explode(',', $post_cat);
2080
-
2081
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
2082
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
2083
-
2084
-                        if (!empty($buffer[5])) {
2085
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
2086
-
2087
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2088
-
2089
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
2090
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2091
-                                    $catids_arr[] = $cat->slug;
2092
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2093
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2094
-                                    $catids_arr[] = $cat->slug;
2095
-                                } else {
2096
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
2097
-                                    if ($ret && !is_wp_error($ret)) {
2098
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
2099
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
2100
-                                            $catids_arr[] = $cat->slug;
2101
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2102
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2103
-                                            $catids_arr[] = $cat->slug;
2104
-                                        }
2105
-                                    }
2106
-                                }
2107
-                            }
2108
-                        }
2109
-                    }
2110
-                }
2111
-
2112
-                if (!$catids_arr) {
2113
-                    $catids_arr[] = 1;
2114
-                }
2115
-
2116
-                $post_tags = trim($buffer[4]); // comma seperated tags
2117
-
2118
-                $tag_arr = '';
2119
-                if ($post_tags) {
2120
-                    $tag_arr = explode(',', $post_tags);
2121
-                }
2122
-
2123
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2124
-
2125
-                $error = '';
2126
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2127
-                    $invalid_post_type++;
2128
-                    continue;
2129
-                }
2130
-
2131
-                if ($post_title != '') {
2132
-                    $menu_order = 0;
2133
-                    $image_folder_name = 'uplaod/';
2134
-
2135
-                    $image_names = array();
2136
-
2137
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
2138
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2139
-
2140
-                        if ($customKeyarray[$c] == 'IMAGE') {
2141
-                            $buffer[$c] = trim($buffer[$c]);
2142
-
2143
-                            if (!empty($buffer[$c])) {
2144
-                                $image_names[] = $buffer[$c];
2145
-                            }
2146
-                        }
2147
-
2148
-                        if ($customKeyarray[$c] == 'alive_days') {
2149
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
2150
-                                $submitdata = date('Y-m-d');
2151
-
2152
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2153
-                            } else {
2154
-                                $gd_post_info['expire_date'] = 'Never';
2155
-                            }
2156
-                        }
2157
-
2158
-                        if ($customKeyarray[$c] == 'post_city') {
2159
-                            $post_city = addslashes($buffer[$c]);
2160
-                        }
2161
-
2162
-                        if ($customKeyarray[$c] == 'post_region') {
2163
-                            $post_region = addslashes($buffer[$c]);
2164
-                        }
2165
-
2166
-                        if ($customKeyarray[$c] == 'post_country') {
2167
-                            $post_country = addslashes($buffer[$c]);
2168
-                        }
2169
-
2170
-                        if ($customKeyarray[$c] == 'post_latitude') {
2171
-                            $post_latitude = addslashes($buffer[$c]);
2172
-                        }
2173
-
2174
-                        if ($customKeyarray[$c] == 'post_longitude') {
2175
-                            $post_longitude = addslashes($buffer[$c]);
2176
-                        }
1980
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1981
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1982
+	$filename = $uploadedFile;
1983
+
1984
+	$uploads = wp_upload_dir();
1985
+	$uploads_dir = $uploads['path'];
1986
+	$image_name_arr = explode('/', $filename);
1987
+	$filename = end($image_name_arr);
1988
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1989
+	$return = array();
1990
+	$return['file'] = $uploadedFile;
1991
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1992
+
1993
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1994
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1995
+
1996
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1997
+			$return['error'] = NULL;
1998
+
1999
+			$return['rows'] = 0;
2000
+
2001
+
2002
+
2003
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
2004
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
2005
+						if(is_array($data) && !empty($data)) {
2006
+							$file[] = '"' . implode('","', $data) . '"';
2007
+						}
2008
+					}
2009
+					fclose($handle);
2010
+					$file = $file;
2011
+				}
2012
+
2013
+
2014
+
2015
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
2016
+
2017
+
2018
+			if (!$return['rows'] > 0) {
2019
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
2020
+			}
2021
+		}
2022
+	}
2023
+	if ($task == 'prepare' || !empty($return['error'])) {
2024
+		echo json_encode($return);
2025
+		exit;
2026
+	}
2027
+
2028
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
2029
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
2030
+	$count = $importlimit;
2031
+	$requested_limit = $importlimit;
2032
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
2033
+
2034
+	if ($count < $totRecords) {
2035
+		$count = $tmpCnt + $count;
2036
+		if ($count > $totRecords) {
2037
+			$count = $totRecords;
2038
+		}
2039
+	} else {
2040
+		$count = $totRecords;
2041
+	}
2042
+
2043
+	$total_records = 0;
2044
+	$rowcount = 0;
2045
+	$address_invalid = 0;
2046
+	$blank_address = 0;
2047
+	$upload_files = 0;
2048
+	$invalid_post_type = 0;
2049
+	$invalid_title = 0;
2050
+	$customKeyarray = array();
2051
+	$gd_post_info = array();
2052
+	$post_location = array();
2053
+	$countpost = 0;
2054
+
2055
+	if (!empty($file)) {
2056
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
2057
+		$customKeyarray = $columns;
2058
+
2059
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
2060
+			$return['error'] = CSV_INVAILD_FILE;
2061
+			echo json_encode($return);
2062
+			exit;
2063
+		}
2064
+
2065
+		for ($i = 1; $i <= $importlimit; $i++) {
2066
+			$current_index = $tmpCnt + $i;
2067
+			if (isset($file[$current_index])) {
2068
+				$total_records++;
2069
+
2070
+				$buffer = geodir_str_getcsv($file[$current_index]);
2071
+				$post_title = addslashes($buffer[0]);
2072
+				$current_post_author = $buffer[1];
2073
+				$post_desc = addslashes($buffer[2]);
2074
+				$post_cat = array();
2075
+				$catids_arr = array();
2076
+				$post_cat = trim($buffer[3]); // comma seperated category name
2077
+
2078
+				if ($post_cat) {
2079
+					$post_cat_arr = explode(',', $post_cat);
2080
+
2081
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
2082
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
2083
+
2084
+						if (!empty($buffer[5])) {
2085
+							if (in_array($buffer[5], geodir_get_posttypes())) {
2086
+
2087
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
2088
+
2089
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
2090
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2091
+									$catids_arr[] = $cat->slug;
2092
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
2093
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2094
+									$catids_arr[] = $cat->slug;
2095
+								} else {
2096
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
2097
+									if ($ret && !is_wp_error($ret)) {
2098
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
2099
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
2100
+											$catids_arr[] = $cat->slug;
2101
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
2102
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
2103
+											$catids_arr[] = $cat->slug;
2104
+										}
2105
+									}
2106
+								}
2107
+							}
2108
+						}
2109
+					}
2110
+				}
2111
+
2112
+				if (!$catids_arr) {
2113
+					$catids_arr[] = 1;
2114
+				}
2115
+
2116
+				$post_tags = trim($buffer[4]); // comma seperated tags
2117
+
2118
+				$tag_arr = '';
2119
+				if ($post_tags) {
2120
+					$tag_arr = explode(',', $post_tags);
2121
+				}
2122
+
2123
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2124
+
2125
+				$error = '';
2126
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2127
+					$invalid_post_type++;
2128
+					continue;
2129
+				}
2130
+
2131
+				if ($post_title != '') {
2132
+					$menu_order = 0;
2133
+					$image_folder_name = 'uplaod/';
2134
+
2135
+					$image_names = array();
2136
+
2137
+					for ($c = 5; $c < count($customKeyarray); $c++) {
2138
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
2139
+
2140
+						if ($customKeyarray[$c] == 'IMAGE') {
2141
+							$buffer[$c] = trim($buffer[$c]);
2142
+
2143
+							if (!empty($buffer[$c])) {
2144
+								$image_names[] = $buffer[$c];
2145
+							}
2146
+						}
2147
+
2148
+						if ($customKeyarray[$c] == 'alive_days') {
2149
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
2150
+								$submitdata = date('Y-m-d');
2151
+
2152
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2153
+							} else {
2154
+								$gd_post_info['expire_date'] = 'Never';
2155
+							}
2156
+						}
2157
+
2158
+						if ($customKeyarray[$c] == 'post_city') {
2159
+							$post_city = addslashes($buffer[$c]);
2160
+						}
2161
+
2162
+						if ($customKeyarray[$c] == 'post_region') {
2163
+							$post_region = addslashes($buffer[$c]);
2164
+						}
2165
+
2166
+						if ($customKeyarray[$c] == 'post_country') {
2167
+							$post_country = addslashes($buffer[$c]);
2168
+						}
2169
+
2170
+						if ($customKeyarray[$c] == 'post_latitude') {
2171
+							$post_latitude = addslashes($buffer[$c]);
2172
+						}
2173
+
2174
+						if ($customKeyarray[$c] == 'post_longitude') {
2175
+							$post_longitude = addslashes($buffer[$c]);
2176
+						}
2177 2177
 						
2178 2178
 						// Post status
2179 2179
 						if ($customKeyarray[$c] == 'post_status') {
2180
-                            $post_status = sanitize_key( $buffer[$c] );
2181
-                        }
2182
-                    }
2183
-
2184
-                    /* ================ before array create ============== */
2185
-                    $location_result = geodir_get_default_location();
2186
-                    if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
2187
-                        $blank_address++;
2188
-                        continue;
2189
-                    } else if ($location_result->location_id == 0) {
2190
-                        if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
2191
-                            $address_invalid++;
2192
-                            continue;
2193
-                        }
2194
-                    }
2180
+							$post_status = sanitize_key( $buffer[$c] );
2181
+						}
2182
+					}
2183
+
2184
+					/* ================ before array create ============== */
2185
+					$location_result = geodir_get_default_location();
2186
+					if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
2187
+						$blank_address++;
2188
+						continue;
2189
+					} else if ($location_result->location_id == 0) {
2190
+						if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
2191
+							$address_invalid++;
2192
+							continue;
2193
+						}
2194
+					}
2195 2195
 					
2196 2196
 					// Default post status
2197 2197
 					$default_status = 'publish';
2198 2198
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2199 2199
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2200 2200
 
2201
-                    $my_post['post_title'] = $post_title;
2202
-                    $my_post['post_content'] = $post_desc;
2203
-                    $my_post['post_type'] = addslashes($buffer[5]);
2204
-                    $my_post['post_author'] = $current_post_author;
2205
-                    $my_post['post_status'] = $post_status;
2206
-                    $my_post['post_category'] = $catids_arr;
2207
-                    $my_post['post_tags'] = $tag_arr;
2208
-
2209
-                    $gd_post_info['post_tags'] = $tag_arr;
2210
-                    $gd_post_info['post_title'] = $post_title;
2211
-                    $gd_post_info['post_status'] = $post_status;
2212
-                    $gd_post_info['submit_time'] = time();
2213
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2214
-
2215
-                    $last_postid = wp_insert_post($my_post);
2216
-                    $countpost++;
2217
-
2218
-                    // Check if we need to save post location as new location
2219
-                    if ($location_result->location_id > 0) {
2220
-                        if (isset($post_city) && isset($post_region)) {
2221
-                            $request_info['post_location'] = array(
2222
-                                'city' => $post_city,
2223
-                                'region' => $post_region,
2224
-                                'country' => $post_country,
2225
-                                'geo_lat' => $post_latitude,
2226
-                                'geo_lng' => $post_longitude
2227
-                            );
2228
-
2229
-                            $post_location_info = $request_info['post_location'];
2230
-                            if ($location_id = geodir_add_new_location($post_location_info))
2231
-                                $post_location_id = $location_id;
2232
-                        } else {
2233
-                            $post_location_id = 0;
2234
-                        }
2235
-                    } else {
2236
-                        $post_location_id = 0;
2237
-                    }
2238
-
2239
-                    /* ------- get default package info ----- */
2240
-                    $payment_info = array();
2241
-                    $package_info = array();
2242
-
2243
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2244
-                    $package_id = '';
2245
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2246
-                        $package_id = $gd_post_info['package_id'];
2247
-                    }
2248
-
2249
-                    if (!empty($package_info)) {
2250
-                        $payment_info['package_id'] = $package_info['pid'];
2251
-
2252
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2253
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2254
-                        } else {
2255
-                            $payment_info['expire_date'] = 'Never';
2256
-                        }
2257
-
2258
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
2259
-                    }
2260
-
2261
-                    $gd_post_info['post_location_id'] = $post_location_id;
2262
-
2263
-                    $post_type = get_post_type($last_postid);
2264
-
2265
-                    $table = $plugin_prefix . $post_type . '_detail';
2266
-
2267
-                    geodir_save_post_info($last_postid, $gd_post_info);
2268
-
2269
-                    if (!empty($image_names)) {
2270
-                        $upload_files++;
2271
-                        $menu_order = 1;
2272
-
2273
-                        foreach ($image_names as $image_name) {
2274
-                            $img_name_arr = explode('.', $image_name);
2275
-
2276
-                            $uploads = wp_upload_dir();
2277
-                            $sub_dir = $uploads['subdir'];
2278
-
2279
-                            $arr_file_type = wp_check_filetype($image_name);
2280
-                            $uploaded_file_type = $arr_file_type['type'];
2281
-
2282
-                            $attachment = array();
2283
-                            $attachment['post_id'] = $last_postid;
2284
-                            $attachment['title'] = $img_name_arr[0];
2285
-                            $attachment['content'] = '';
2286
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2287
-                            $attachment['mime_type'] = $uploaded_file_type;
2288
-                            $attachment['menu_order'] = $menu_order;
2289
-                            $attachment['is_featured'] = 0;
2290
-
2291
-                            $attachment_set = '';
2292
-
2293
-                            foreach ($attachment as $key => $val) {
2294
-                                if ($val != '')
2295
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2296
-                            }
2297
-                            $attachment_set = trim($attachment_set, ", ");
2298
-
2299
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2300
-
2301
-                            if ($menu_order == 1) {
2302
-                                $post_type = get_post_type($last_postid);
2303
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2304
-                            }
2305
-                            $menu_order++;
2306
-                        }
2307
-                    }
2308
-
2309
-                    $gd_post_info['package_id'] = $package_id;
2310
-
2311
-                    /** This action is documented in geodirectory-functions/post-functions.php */
2312
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2313
-
2314
-                    if (!empty($buffer[5])) {
2315
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2316
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2317
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2318
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2319
-
2320
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2321
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2322
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2323
-                        }
2324
-                    }
2325
-                } else {
2326
-                    $invalid_title++;
2327
-                }
2328
-            }
2329
-        }
2330
-    }
2331
-    $return['rowcount'] = $countpost;
2332
-    $return['invalidcount'] = $address_invalid;
2333
-    $return['blank_address'] = $blank_address;
2334
-    $return['upload_files'] = $upload_files;
2335
-    $return['invalid_post_type'] = $invalid_post_type;
2336
-    $return['invalid_title'] = $invalid_title;
2337
-    $return['total_records'] = $total_records;
2338
-
2339
-    echo json_encode($return);
2340
-    exit;
2201
+					$my_post['post_title'] = $post_title;
2202
+					$my_post['post_content'] = $post_desc;
2203
+					$my_post['post_type'] = addslashes($buffer[5]);
2204
+					$my_post['post_author'] = $current_post_author;
2205
+					$my_post['post_status'] = $post_status;
2206
+					$my_post['post_category'] = $catids_arr;
2207
+					$my_post['post_tags'] = $tag_arr;
2208
+
2209
+					$gd_post_info['post_tags'] = $tag_arr;
2210
+					$gd_post_info['post_title'] = $post_title;
2211
+					$gd_post_info['post_status'] = $post_status;
2212
+					$gd_post_info['submit_time'] = time();
2213
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
2214
+
2215
+					$last_postid = wp_insert_post($my_post);
2216
+					$countpost++;
2217
+
2218
+					// Check if we need to save post location as new location
2219
+					if ($location_result->location_id > 0) {
2220
+						if (isset($post_city) && isset($post_region)) {
2221
+							$request_info['post_location'] = array(
2222
+								'city' => $post_city,
2223
+								'region' => $post_region,
2224
+								'country' => $post_country,
2225
+								'geo_lat' => $post_latitude,
2226
+								'geo_lng' => $post_longitude
2227
+							);
2228
+
2229
+							$post_location_info = $request_info['post_location'];
2230
+							if ($location_id = geodir_add_new_location($post_location_info))
2231
+								$post_location_id = $location_id;
2232
+						} else {
2233
+							$post_location_id = 0;
2234
+						}
2235
+					} else {
2236
+						$post_location_id = 0;
2237
+					}
2238
+
2239
+					/* ------- get default package info ----- */
2240
+					$payment_info = array();
2241
+					$package_info = array();
2242
+
2243
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2244
+					$package_id = '';
2245
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2246
+						$package_id = $gd_post_info['package_id'];
2247
+					}
2248
+
2249
+					if (!empty($package_info)) {
2250
+						$payment_info['package_id'] = $package_info['pid'];
2251
+
2252
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2253
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2254
+						} else {
2255
+							$payment_info['expire_date'] = 'Never';
2256
+						}
2257
+
2258
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
2259
+					}
2260
+
2261
+					$gd_post_info['post_location_id'] = $post_location_id;
2262
+
2263
+					$post_type = get_post_type($last_postid);
2264
+
2265
+					$table = $plugin_prefix . $post_type . '_detail';
2266
+
2267
+					geodir_save_post_info($last_postid, $gd_post_info);
2268
+
2269
+					if (!empty($image_names)) {
2270
+						$upload_files++;
2271
+						$menu_order = 1;
2272
+
2273
+						foreach ($image_names as $image_name) {
2274
+							$img_name_arr = explode('.', $image_name);
2275
+
2276
+							$uploads = wp_upload_dir();
2277
+							$sub_dir = $uploads['subdir'];
2278
+
2279
+							$arr_file_type = wp_check_filetype($image_name);
2280
+							$uploaded_file_type = $arr_file_type['type'];
2281
+
2282
+							$attachment = array();
2283
+							$attachment['post_id'] = $last_postid;
2284
+							$attachment['title'] = $img_name_arr[0];
2285
+							$attachment['content'] = '';
2286
+							$attachment['file'] = $sub_dir . '/' . $image_name;
2287
+							$attachment['mime_type'] = $uploaded_file_type;
2288
+							$attachment['menu_order'] = $menu_order;
2289
+							$attachment['is_featured'] = 0;
2290
+
2291
+							$attachment_set = '';
2292
+
2293
+							foreach ($attachment as $key => $val) {
2294
+								if ($val != '')
2295
+									$attachment_set .= $key . " = '" . $val . "', ";
2296
+							}
2297
+							$attachment_set = trim($attachment_set, ", ");
2298
+
2299
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2300
+
2301
+							if ($menu_order == 1) {
2302
+								$post_type = get_post_type($last_postid);
2303
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2304
+							}
2305
+							$menu_order++;
2306
+						}
2307
+					}
2308
+
2309
+					$gd_post_info['package_id'] = $package_id;
2310
+
2311
+					/** This action is documented in geodirectory-functions/post-functions.php */
2312
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
2313
+
2314
+					if (!empty($buffer[5])) {
2315
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2316
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2317
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2318
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2319
+
2320
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2321
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2322
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2323
+						}
2324
+					}
2325
+				} else {
2326
+					$invalid_title++;
2327
+				}
2328
+			}
2329
+		}
2330
+	}
2331
+	$return['rowcount'] = $countpost;
2332
+	$return['invalidcount'] = $address_invalid;
2333
+	$return['blank_address'] = $blank_address;
2334
+	$return['upload_files'] = $upload_files;
2335
+	$return['invalid_post_type'] = $invalid_post_type;
2336
+	$return['invalid_title'] = $invalid_title;
2337
+	$return['total_records'] = $total_records;
2338
+
2339
+	echo json_encode($return);
2340
+	exit;
2341 2341
 }
2342 2342
 
2343 2343
 // Add the tab in left sidebar menu fro import & export page.
@@ -2357,9 +2357,9 @@  discard block
 block discarded – undo
2357 2357
  * @param $post object $post The post object of the post being saved.
2358 2358
  */
2359 2359
 function geodir_update_location_prefix($post_id,$post){
2360
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2361
-        update_option('geodir_location_prefix',$post->post_name);
2362
-    }
2360
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2361
+		update_option('geodir_location_prefix',$post->post_name);
2362
+	}
2363 2363
 
2364 2364
 }
2365 2365
 
@@ -2370,50 +2370,50 @@  discard block
 block discarded – undo
2370 2370
 function geodir_ga_callback(){
2371 2371
 
2372 2372
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2373
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2374
-    $code = "code=".$_REQUEST['code'];
2375
-    $grant_type = "&grant_type=authorization_code";
2376
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2377
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2378
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2373
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2374
+	$code = "code=".$_REQUEST['code'];
2375
+	$grant_type = "&grant_type=authorization_code";
2376
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2377
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2378
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2379 2379
 
2380
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2380
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2381 2381
 
2382
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2382
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2383 2383
 
2384
-    //print_r($response);
2384
+	//print_r($response);
2385 2385
 
2386
-    $error_msg =  __('Something went wrong','geodirectory');
2387
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2386
+	$error_msg =  __('Something went wrong','geodirectory');
2387
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2388 2388
 
2389
-        $parts = json_decode($response['body']);
2390
-        //print_r($parts);
2391
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2392
-        else{
2389
+		$parts = json_decode($response['body']);
2390
+		//print_r($parts);
2391
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2392
+		else{
2393 2393
 
2394
-            update_option('gd_ga_access_token', $parts->access_token);
2395
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2396
-            ?><script>window.close();</script><?php
2397
-        }
2394
+			update_option('gd_ga_access_token', $parts->access_token);
2395
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2396
+			?><script>window.close();</script><?php
2397
+		}
2398 2398
 
2399 2399
 
2400
-    }
2401
-    elseif(!empty($response['response']['code'])) {
2402
-        $parts = json_decode($response['body']);
2400
+	}
2401
+	elseif(!empty($response['response']['code'])) {
2402
+		$parts = json_decode($response['body']);
2403 2403
 
2404
-        if(isset($parts->error)){
2405
-            echo $parts->error.": ".$parts->error_description;exit;
2406
-        }else{
2407
-            echo $error_msg." - #2";exit;
2408
-        }
2404
+		if(isset($parts->error)){
2405
+			echo $parts->error.": ".$parts->error_description;exit;
2406
+		}else{
2407
+			echo $error_msg." - #2";exit;
2408
+		}
2409 2409
 
2410
-    }else{
2410
+	}else{
2411 2411
 
2412
-        echo $error_msg." - #3";exit;
2412
+		echo $error_msg." - #3";exit;
2413 2413
 
2414
-    }
2414
+	}
2415 2415
 }
2416
-    exit;
2416
+	exit;
2417 2417
 }
2418 2418
 
2419 2419
 if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -2429,45 +2429,45 @@  discard block
 block discarded – undo
2429 2429
  * @return array Array of settings.
2430 2430
  */
2431 2431
 function geodir_uninstall_settings($general_settings) {
2432
-    $settings   = array();
2433
-    $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2434
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2432
+	$settings   = array();
2433
+	$settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2434
+	$settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2435 2435
     
2436
-    $plugins    = get_plugins();
2437
-    $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2436
+	$plugins    = get_plugins();
2437
+	$un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
2438 2438
     
2439
-    if (!empty($plugins) && !empty($un_plugins)) {
2440
-        foreach ($plugins as $plugin => $data) {
2441
-            $plugin_name = plugin_basename(dirname($plugin));
2439
+	if (!empty($plugins) && !empty($un_plugins)) {
2440
+		foreach ($plugins as $plugin => $data) {
2441
+			$plugin_name = plugin_basename(dirname($plugin));
2442 2442
             
2443
-            if (in_array($plugin_name, $un_plugins)) {
2444
-                $settings[] = array(
2445
-                    'type' => 'checkbox',
2446
-                    'id' => 'geodir_un_' . $plugin_name,
2447
-                    'name' => $data['Name'],
2448
-                    'desc' => __('Remove all data when deleted?', 'geodirectory'),
2449
-                    'std' => '0'
2450
-                );
2451
-            }
2452
-        }
2453
-    }
2443
+			if (in_array($plugin_name, $un_plugins)) {
2444
+				$settings[] = array(
2445
+					'type' => 'checkbox',
2446
+					'id' => 'geodir_un_' . $plugin_name,
2447
+					'name' => $data['Name'],
2448
+					'desc' => __('Remove all data when deleted?', 'geodirectory'),
2449
+					'std' => '0'
2450
+				);
2451
+			}
2452
+		}
2453
+	}
2454 2454
         
2455
-    $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2455
+	$settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
2456 2456
     
2457
-    /**
2458
-     * Filter the uninstall settings array.
2459
-     *
2460
-     * @since 1.6.9
2461
-     *
2462
-     * @param array $settings The settings array.
2463
-     */
2464
-    $settings = apply_filters('geodir_uninstall_settings', $settings);
2457
+	/**
2458
+	 * Filter the uninstall settings array.
2459
+	 *
2460
+	 * @since 1.6.9
2461
+	 *
2462
+	 * @param array $settings The settings array.
2463
+	 */
2464
+	$settings = apply_filters('geodir_uninstall_settings', $settings);
2465 2465
     
2466
-    if (!empty($settings) && count($settings) > 3) {
2467
-        return array_merge($general_settings, $settings);
2468
-    }
2466
+	if (!empty($settings) && count($settings) > 3) {
2467
+		return array_merge($general_settings, $settings);
2468
+	}
2469 2469
     
2470
-    return $general_settings;
2470
+	return $general_settings;
2471 2471
 }
2472 2472
 add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1);
2473 2473
 
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
  * @since 1.6.9
2478 2478
  */
2479 2479
 function geodir_uninstall_settings_desc() {
2480
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>';
2480
+	echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>';
2481 2481
 }
2482 2482
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2483 2483
 
@@ -2493,18 +2493,18 @@  discard block
 block discarded – undo
2493 2493
  * @return array The settings array.
2494 2494
  */
2495 2495
 function geodir_resave_settings($settings = array()) {
2496
-    if (!empty($settings) && is_array($settings)) {
2497
-        $c = 0;
2496
+	if (!empty($settings) && is_array($settings)) {
2497
+		$c = 0;
2498 2498
         
2499
-        foreach ($settings as $setting) {
2500
-            if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2501
-                $settings[$c]['std'] = $value;
2502
-            }
2503
-            $c++;
2504
-        }
2505
-    }
2506
-
2507
-    return $settings;
2499
+		foreach ($settings as $setting) {
2500
+			if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
2501
+				$settings[$c]['std'] = $value;
2502
+			}
2503
+			$c++;
2504
+		}
2505
+	}
2506
+
2507
+	return $settings;
2508 2508
 }
2509 2509
 
2510 2510
 /**
@@ -2516,9 +2516,9 @@  discard block
 block discarded – undo
2516 2516
  * @return array The modified settings.
2517 2517
  */
2518 2518
 function geodir_core_uninstall_settings($settings) {
2519
-    $settings[] = plugin_basename(dirname(dirname(__FILE__)));
2519
+	$settings[] = plugin_basename(dirname(dirname(__FILE__)));
2520 2520
     
2521
-    return $settings;
2521
+	return $settings;
2522 2522
 }
2523 2523
 add_filter('geodir_plugins_uninstall_settings', 'geodir_core_uninstall_settings', 10, 1);
2524 2524
 
@@ -2532,34 +2532,34 @@  discard block
 block discarded – undo
2532 2532
  */
2533 2533
 function geodir_diagnose_reload_db_countries()
2534 2534
 {
2535
-    global $wpdb, $plugin_prefix;
2536
-
2537
-    $is_error_during_diagnose = false;
2538
-    $output_str = '';
2539
-
2540
-    $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE);
2541
-
2542
-
2543
-    if ($delete) {
2544
-            $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2545
-        ob_start();
2546
-        geodir_diagnose_version_clear();
2547
-        ob_end_clean();
2548
-    }else{
2549
-        $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2550
-    }
2551
-
2552
-    if ($is_error_during_diagnose) {
2553
-        $info_div_class = "geodir_problem_info";
2554
-        $fix_button_txt = "";
2555
-    } else {
2556
-        $info_div_class = "geodir_noproblem_info";
2557
-        $fix_button_txt = '';
2558
-    }
2559
-    echo "<ul class='$info_div_class'>";
2560
-    echo $output_str;
2561
-    echo $fix_button_txt;
2562
-    echo "</ul>";
2535
+	global $wpdb, $plugin_prefix;
2536
+
2537
+	$is_error_during_diagnose = false;
2538
+	$output_str = '';
2539
+
2540
+	$delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE);
2541
+
2542
+
2543
+	if ($delete) {
2544
+			$output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2545
+		ob_start();
2546
+		geodir_diagnose_version_clear();
2547
+		ob_end_clean();
2548
+	}else{
2549
+		$output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2550
+	}
2551
+
2552
+	if ($is_error_during_diagnose) {
2553
+		$info_div_class = "geodir_problem_info";
2554
+		$fix_button_txt = "";
2555
+	} else {
2556
+		$info_div_class = "geodir_noproblem_info";
2557
+		$fix_button_txt = '';
2558
+	}
2559
+	echo "<ul class='$info_div_class'>";
2560
+	echo $output_str;
2561
+	echo $fix_button_txt;
2562
+	echo "</ul>";
2563 2563
 }
2564 2564
 
2565 2565
 /**
@@ -2572,11 +2572,11 @@  discard block
 block discarded – undo
2572 2572
  * @return array Filtered actions.
2573 2573
  */
2574 2574
 function geodir_disable_quick_edit( $actions = array(), $row = null ) {
2575
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
2576
-        unset( $actions['inline hide-if-no-js'] );
2577
-    }
2575
+	if ( isset( $actions['inline hide-if-no-js'] ) ) {
2576
+		unset( $actions['inline hide-if-no-js'] );
2577
+	}
2578 2578
 
2579
-    return $actions;
2579
+	return $actions;
2580 2580
 }
2581 2581
 
2582 2582
 /**
@@ -2590,26 +2590,26 @@  discard block
 block discarded – undo
2590 2590
  * @global bool $gd_cpt_screen True if current scrrrn has GD post type.
2591 2591
  */
2592 2592
 function geodir_check_quick_edit() {
2593
-    global $pagenow, $current_screen, $gd_cpt_screen;
2594
-
2595
-    if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) {
2596
-        if ( empty( $gd_cpt_screen ) ) {
2597
-            if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) {
2598
-                $gd_cpt_screen = 'y';
2599
-            } else {
2600
-                $gd_cpt_screen = 'n';
2601
-            }
2602
-        }
2603
-
2604
-        if ( $gd_cpt_screen == 'y' ) {
2605
-            if ( $pagenow == 'edit.php' ) {
2606
-                add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2607
-                add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2608
-            } elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) {
2609
-                add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2610
-            }
2611
-        }
2612
-    }
2593
+	global $pagenow, $current_screen, $gd_cpt_screen;
2594
+
2595
+	if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) {
2596
+		if ( empty( $gd_cpt_screen ) ) {
2597
+			if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) {
2598
+				$gd_cpt_screen = 'y';
2599
+			} else {
2600
+				$gd_cpt_screen = 'n';
2601
+			}
2602
+		}
2603
+
2604
+		if ( $gd_cpt_screen == 'y' ) {
2605
+			if ( $pagenow == 'edit.php' ) {
2606
+				add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2607
+				add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2608
+			} elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) {
2609
+				add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2610
+			}
2611
+		}
2612
+	}
2613 2613
 }
2614 2614
 add_action( 'admin_head', 'geodir_check_quick_edit', 10 );
2615 2615
 
@@ -2623,11 +2623,11 @@  discard block
 block discarded – undo
2623 2623
  * @return array Filtered bulk actions.
2624 2624
  */
2625 2625
 function geodir_filter_bulk_actions( $actions ) {
2626
-    if ( isset( $actions['edit'] ) ) {
2627
-        unset( $actions['edit'] );
2628
-    }
2626
+	if ( isset( $actions['edit'] ) ) {
2627
+		unset( $actions['edit'] );
2628
+	}
2629 2629
     
2630
-    return $actions;
2630
+	return $actions;
2631 2631
 }
2632 2632
 
2633 2633
 /**
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+    geodir_admin_option_form($current_tab); // defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
71 71
 add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
72 72
 add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
73
-add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
73
+add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
74 74
 
75 75
 //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
76 76
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         
100 100
         // Disable VC editor for GD post types.
101 101
         if (class_exists('Vc_Role_Access_Controller')) {
102
-            add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 );
102
+            add_filter('vc_role_access_with_post_types_can', '__return_false', 100);
103 103
         }
104 104
     }
105 105
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 add_action('admin_panel_init', 'geodir_admin_list_columns', 2);
127 127
 
128 128
 /* --- insert dummy post action ---*/
129
-add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1,3);
130
-add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1,3);
129
+add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1, 3);
130
+add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1, 3);
131 131
 
132 132
 
133 133
 /**
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 
241 241
         // Filter-Payment-Manager
242 242
 
243
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
243
+        add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
244 244
 
245
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
245
+        add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
246 246
 
247 247
         // no need of this box as all fields moved to main information box
248 248
         //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
 }
253 253
 
254
-add_action('save_post', 'geodir_post_information_save',10,2);
254
+add_action('save_post', 'geodir_post_information_save', 10, 2);
255 255
 
256 256
 
257 257
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 
279 279
             $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
280 280
 
281
-            if(!empty($gd_taxonomy)) {
281
+            if (!empty($gd_taxonomy)) {
282 282
                 foreach ($gd_taxonomy as $tax) {
283 283
 
284
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
284
+                    remove_meta_box($tax.'div', $geodir_post_type, 'normal');
285 285
 
286 286
                 }
287 287
             }
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
 add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined');
368 368
 add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
369 369
 
370
-function geodir_manage_available_fields_predefined($sub_tab){
371
-    if($sub_tab=='custom_fields'){
370
+function geodir_manage_available_fields_predefined($sub_tab) {
371
+    if ($sub_tab == 'custom_fields') {
372 372
         geodir_custom_available_fields('predefined');
373 373
     }
374 374
 }
375 375
 
376
-function geodir_manage_available_fields_custom($sub_tab){
377
-    if($sub_tab=='custom_fields'){
376
+function geodir_manage_available_fields_custom($sub_tab) {
377
+    if ($sub_tab == 'custom_fields') {
378 378
         geodir_custom_available_fields('custom');
379 379
     }
380 380
 }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
     global $wpdb;
445 445
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
446 446
     ?>
447
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
447
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
448 448
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
449 449
     <ul>
450 450
     <?php
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 
456 456
             $check_html_variable = $wpdb->get_var(
457 457
                 $wpdb->prepare(
458
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
458
+                    "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
459 459
                     array($val['htmlvar_name'], $listing_type, $val['field_type'])
460 460
                 )
461 461
             );
@@ -463,23 +463,23 @@  discard block
 block discarded – undo
463 463
             $display = $check_html_variable ? ' style="display:none;"' : '';
464 464
            ?>
465 465
 
466
-            <li   class="gd-cf-tooltip-wrap" <?php echo $display;?>>
466
+            <li   class="gd-cf-tooltip-wrap" <?php echo $display; ?>>
467 467
                 <?php
468
-                if(isset($val['description']) && $val['description']){
468
+                if (isset($val['description']) && $val['description']) {
469 469
                     echo '<div class="gdcf-tooltip">'.$val['description'].'</div>';
470 470
                 }?>
471 471
 
472
-                <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>"  data-field-type="<?php echo $val['field_type'];?>"
473
-                   title="<?php echo $val['site_title'];?>"
474
-                   class="gd-draggable-form-items  gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);">
472
+                <a id="gd-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" data-field-type-key="<?php echo $val['htmlvar_name']; ?>"  data-field-type="<?php echo $val['field_type']; ?>"
473
+                   title="<?php echo $val['site_title']; ?>"
474
+                   class="gd-draggable-form-items  gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);">
475 475
                     <?php if (isset($val['field_icon']) && strpos($val['field_icon'], ' fa-') !== false) {
476 476
                         echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>';
477
-                    }elseif(isset($val['field_icon']) && $val['field_icon'] ){
477
+                    }elseif (isset($val['field_icon']) && $val['field_icon']) {
478 478
                         echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>';
479
-                    }else{
479
+                    } else {
480 480
                         echo '<i class="fas fa-cog" aria-hidden="true"></i>';
481 481
                     }?>
482
-                    <?php echo (! empty( $val['admin_title'] ) ? $val['admin_title'] : $val['site_title'] );?>
482
+                    <?php echo (!empty($val['admin_title']) ? $val['admin_title'] : $val['site_title']); ?>
483 483
                 </a>
484 484
             </li>
485 485
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
     <?php 
508 508
         global $wpdb;
509 509
         
510
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
510
+        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
511 511
 
512 512
         if (!empty($fields)) {
513 513
             foreach ($fields as $field) {
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
  * @since 1.6.9
533 533
  * @package GeoDirectory
534 534
  */
535
-function geodir_custom_fields_custom($post_type=''){
535
+function geodir_custom_fields_custom($post_type = '') {
536 536
 
537 537
     $custom_fields = array();
538 538
 
539 539
     /**
540 540
      * @see `geodir_custom_fields`
541 541
      */
542
-    return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
542
+    return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type);
543 543
 }
544 544
 
545 545
 
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
  * @since 1.6.6
551 551
  * @package GeoDirectory
552 552
  */
553
-function geodir_custom_fields($post_type=''){
553
+function geodir_custom_fields($post_type = '') {
554 554
     
555 555
     $custom_fields = array(
556 556
         'text' => array(
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
      * }
686 686
      * @param string $post_type The post type requested.
687 687
      */
688
-    return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
688
+    return apply_filters('geodir_custom_fields', $custom_fields, $post_type);
689 689
 }
690 690
 
691 691
 /**
@@ -696,25 +696,25 @@  discard block
 block discarded – undo
696 696
  * @param string $type The custom field type, predefined, custom or blank for default
697 697
  * @package GeoDirectory
698 698
  */
699
-function geodir_custom_available_fields($type='')
699
+function geodir_custom_available_fields($type = '')
700 700
 {
701 701
     $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
702 702
     ?>
703
-    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
703
+    <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/>
704 704
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" />
705 705
 
706 706
         <?php
707
-        if($type=='predefined'){
707
+        if ($type == 'predefined') {
708 708
             $cfs = geodir_custom_fields_predefined($listing_type);
709
-        }elseif($type=='custom'){
709
+        }elseif ($type == 'custom') {
710 710
             $cfs = geodir_custom_fields_custom($listing_type);
711
-        }else{
711
+        } else {
712 712
             $cfs = geodir_custom_fields($listing_type);
713 713
             ?>
714 714
             <ul class="full gd-cf-tooltip-wrap">
715 715
                 <li>
716 716
                     <div class="gdcf-tooltip">
717
-                        <?php _e('This adds a section separator with a title.', 'geodirectory');?>
717
+                        <?php _e('This adds a section separator with a title.', 'geodirectory'); ?>
718 718
                     </div>
719 719
                     <a id="gt-fieldset"
720 720
                        class="gd-draggable-form-items gt-fieldset"
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 
726 726
                         <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i>
727 727
                         <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i>
728
-                        <?php _e('Fieldset (section separator)', 'geodirectory');?>
728
+                        <?php _e('Fieldset (section separator)', 'geodirectory'); ?>
729 729
                     </a>
730 730
                 </li>
731 731
             </ul>
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
             <?php
734 734
         }
735 735
 
736
-    if(!empty($cfs)) {
736
+    if (!empty($cfs)) {
737 737
         echo '<ul>';
738
-        foreach ( $cfs as $id => $cf ) {
738
+        foreach ($cfs as $id => $cf) {
739 739
             ?>
740 740
 
741 741
             <li class="gd-cf-tooltip-wrap">
742 742
                 <?php
743
-                if ( isset( $cf['description'] ) && $cf['description'] ) {
744
-                    echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>';
743
+                if (isset($cf['description']) && $cf['description']) {
744
+                    echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>';
745 745
                 } ?>
746 746
 
747 747
                 <a id="gd-<?php echo $id; ?>"
@@ -751,10 +751,10 @@  discard block
 block discarded – undo
751 751
                    class="gd-draggable-form-items <?php echo $cf['class']; ?>"
752 752
                    href="javascript:void(0);">
753 753
 
754
-                    <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], ' fa-' ) !== false ) {
755
-                        echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>';
756
-                    } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
757
-                        echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>';
754
+                    <?php if (isset($cf['icon']) && strpos($cf['icon'], ' fa-') !== false) {
755
+                        echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>';
756
+                    } elseif (isset($cf['icon']) && $cf['icon']) {
757
+                        echo '<b class="gd-cf-icon" style="background-image: url(\''.$cf['icon'].'\')"></b>';
758 758
                     } else {
759 759
                         echo '<i class="fas fa-cog" aria-hidden="true"></i>';
760 760
                     } ?>
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
             </li>
764 764
             <?php
765 765
         }
766
-    }else{
766
+    } else {
767 767
         _e('There are no custom fields here yet.', 'geodirectory');
768 768
     }
769 769
         ?>
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     <ul class="core">
792 792
     <?php 
793 793
         global $wpdb;
794
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
794
+        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
795 795
 
796 796
         if (!empty($fields)) {
797 797
             foreach ($fields as $field) {
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
                 $field_type_key = $field->field_type_key;
802 802
                 $field_ins_upd = 'display';
803 803
 
804
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key);
804
+                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key);
805 805
             }
806 806
         }
807 807
         ?></ul>
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 
961 961
     if (!get_option('geodir_remove_unnecessary_fields')) {
962 962
 
963
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
964
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
963
+        if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
964
+            $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
965 965
 
966 966
         update_option('geodir_remove_unnecessary_fields', '1');
967 967
 
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
             case 'diagnosis' :
991 991
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') {
992 992
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
993
-                    call_user_func('geodir_diagnose_' . $diagnose_this);
993
+                    call_user_func('geodir_diagnose_'.$diagnose_this);
994 994
 
995 995
                 }
996 996
                 exit();
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
             case 'diagnosis-fix' :
1000 1000
                 if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
1001 1001
                     $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
1002
-                call_user_func('geodir_diagnose_' . $diagnose_this);
1002
+                call_user_func('geodir_diagnose_'.$diagnose_this);
1003 1003
                 exit();
1004 1004
                 break;
1005 1005
         }
@@ -1024,50 +1024,50 @@  discard block
 block discarded – undo
1024 1024
 {
1025 1025
     global $wpdb;
1026 1026
     //$filter_arr['output_str'] .='###'.$table.'###';
1027
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
1028
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
1027
+    if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
1028
+        $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
1029 1029
         $filter_arr['is_error_during_diagnose'] = true;
1030 1030
 
1031
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1032
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
1031
+    } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
1032
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
1033 1033
         $filter_arr['is_error_during_diagnose'] = true;
1034
-        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
1034
+        $filter_arr['output_str'] .= "<li>".__('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory')."</li>";
1035 1035
         $filter_arr['is_error_during_diagnose'] = true;
1036 1036
 
1037 1037
         if ($fix) {
1038
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
1039
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
1038
+            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
1039
+            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
1040 1040
 
1041 1041
             if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
1042 1042
                 //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
1043 1043
 
1044
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
1044
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
1045 1045
 
1046
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1047
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
1046
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
1047
+                    $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
1048 1048
                 } else {
1049
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1049
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1050 1050
                 }
1051 1051
 
1052 1052
             } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
1053 1053
 
1054
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
1055
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
1054
+                $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
1055
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
1056 1056
 
1057
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1058
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
1057
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1058
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
1059 1059
                 } else {
1060
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1060
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1061 1061
                 }
1062 1062
 
1063 1063
             } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
1064 1064
 
1065
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
1065
+                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
1066 1066
 
1067
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
1068
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
1067
+                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
1068
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
1069 1069
                 } else {
1070
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
1070
+                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
1071 1071
                 }
1072 1072
 
1073 1073
             }
@@ -1075,54 +1075,54 @@  discard block
 block discarded – undo
1075 1075
         }
1076 1076
 
1077 1077
 
1078
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
1079
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
1078
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
1079
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
1080 1080
         $filter_arr['is_error_during_diagnose'] = true;
1081 1081
 
1082 1082
         if ($fix) {
1083 1083
             if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
1084 1084
                 if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
1085
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
1085
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
1086 1086
                 } else {
1087
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
1087
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
1088 1088
                 }
1089 1089
 
1090
-            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
1091
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
1092
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1090
+            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table") == 0) {// if main table is empty but original is not, delete main and rename original
1091
+                if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
1092
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
1093 1093
                 } else {
1094
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
1094
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
1095 1095
                 }
1096
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1097
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1096
+                if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1097
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1098 1098
                 } else {
1099
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1099
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1100 1100
                 }
1101 1101
             } else {// else rename the original table to _ms_bak
1102
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1103
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1102
+                if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1103
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table."_ms_bak")."</li>";
1104 1104
                 } else {
1105
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
1105
+                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table."_ms_bak")."</li>";
1106 1106
                 }
1107 1107
             }
1108 1108
         }
1109 1109
 
1110
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1111
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
1110
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
1111
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
1112 1112
         $filter_arr['is_error_during_diagnose'] = true;
1113 1113
 
1114 1114
         if ($fix) {
1115 1115
             // if original table exists but new does not, rename
1116
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1117
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1116
+            if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
1117
+                $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1118 1118
             } else {
1119
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
1119
+                $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
1120 1120
             }
1121 1121
 
1122 1122
         }
1123 1123
 
1124
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
1125
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
1124
+    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
1125
+        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
1126 1126
         $filter_arr['is_error_during_diagnose'] = true;
1127 1127
 
1128 1128
         if ($fix) {
@@ -1136,11 +1136,11 @@  discard block
 block discarded – undo
1136 1136
             delete_option('geodir_custom_posts_db_version');
1137 1137
             delete_option('geodir_reviewratings_db_version');
1138 1138
             delete_option('geodiradvancesearch_db_version');
1139
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
1139
+            $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
1140 1140
         }
1141 1141
 
1142 1142
     } else {
1143
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
1143
+        $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
1144 1144
     }
1145 1145
     return $filter_arr;
1146 1146
 }
@@ -1181,21 +1181,21 @@  discard block
 block discarded – undo
1181 1181
     }
1182 1182
 
1183 1183
     if ($stepped_process) {
1184
-        $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset );
1185
-        $posts = $wpdb->get_results( $sql );
1184
+        $sql = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."geodir_".$ptype."_detail LIMIT %d OFFSET %d", $step_max_items, $offset);
1185
+        $posts = $wpdb->get_results($sql);
1186 1186
 
1187 1187
         if (!empty($posts)) {
1188 1188
 
1189 1189
             foreach ($posts as $p) {
1190 1190
                 $p->post_type = $ptype;
1191
-                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1191
+                $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
1192 1192
                 if (empty($raw_tags)) {
1193 1193
                     $post_tags = '';
1194 1194
                 } else {
1195 1195
                     $post_tags = implode(",", $raw_tags);
1196 1196
                 }
1197
-                $tablename = $plugin_prefix . $p->post_type . '_detail';
1198
-                $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1197
+                $tablename = $plugin_prefix.$p->post_type.'_detail';
1198
+                $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1199 1199
 
1200 1200
             }
1201 1201
             if ($step >= $max_step) {
@@ -1211,23 +1211,23 @@  discard block
 block discarded – undo
1211 1211
         if (!empty($all_postypes)) {
1212 1212
             foreach ($all_postypes as $key) {
1213 1213
                 // update each GD CPT
1214
-                $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail");
1214
+                $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail");
1215 1215
 
1216 1216
                 if (!empty($posts)) {
1217 1217
 
1218 1218
                     foreach ($posts as $p) {
1219 1219
                         $p->post_type = $key;
1220
-                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
1220
+                        $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
1221 1221
                         if (empty($raw_tags)) {
1222 1222
                             $post_tags = '';
1223 1223
                         } else {
1224 1224
                             $post_tags = implode(",", $raw_tags);
1225 1225
                         }
1226
-                        $tablename = $plugin_prefix . $p->post_type . '_detail';
1227
-                        $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1226
+                        $tablename = $plugin_prefix.$p->post_type.'_detail';
1227
+                        $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
1228 1228
 
1229 1229
                     }
1230
-                    $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1230
+                    $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1231 1231
                 }
1232 1232
 
1233 1233
             }
@@ -1238,14 +1238,14 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
     if ($is_error_during_diagnose) {
1240 1240
         $info_div_class = "geodir_problem_info";
1241
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1241
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1242 1242
     } else {
1243 1243
         $info_div_class = "geodir_noproblem_info";
1244 1244
         $fix_button_txt = '';
1245 1245
     }
1246 1246
 
1247 1247
     if ($stepped_process) {
1248
-        $percent = ($step/$max_step) * 100;
1248
+        $percent = ($step / $max_step) * 100;
1249 1249
         if ($output_str == 'done') {
1250 1250
             echo $output_str;
1251 1251
         } else {
@@ -1288,29 +1288,29 @@  discard block
 block discarded – undo
1288 1288
     if (!empty($all_postypes)) {
1289 1289
         foreach ($all_postypes as $key) {
1290 1290
             // update each GD CTP
1291
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
1291
+            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
1292 1292
 
1293 1293
             if (!empty($posts)) {
1294 1294
 
1295 1295
                 foreach ($posts as $p) {
1296 1296
                     $p->post_type = $key;
1297
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
1297
+                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
1298 1298
 
1299 1299
                     if (empty($raw_cats)) {
1300 1300
                         $post_categories = get_post_meta($p->post_id, 'post_categories', true);
1301 1301
 
1302
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1303
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1304
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1302
+                        if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
1303
+                            $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
1304
+                            foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
1305 1305
                                 if (is_numeric($cat_part)) {
1306
-                                    $raw_cats[] = (int)$cat_part;
1306
+                                    $raw_cats[] = (int) $cat_part;
1307 1307
                                 }
1308 1308
                             }
1309 1309
 
1310 1310
                         }
1311 1311
 
1312 1312
                         if (!empty($raw_cats)) {
1313
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1313
+                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category');
1314 1314
 
1315 1315
                         }
1316 1316
 
@@ -1320,14 +1320,14 @@  discard block
 block discarded – undo
1320 1320
                     if (empty($raw_cats)) {
1321 1321
                         $post_cats = '';
1322 1322
                     } else {
1323
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1323
+                        $post_cats = ','.implode(",", $raw_cats).',';
1324 1324
                     }
1325
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1326
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1325
+                    $tablename = $plugin_prefix.$p->post_type.'_detail';
1326
+                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1327 1327
                 }
1328 1328
 
1329 1329
             }
1330
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1330
+            $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
1331 1331
 
1332 1332
         }
1333 1333
 
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
     if ($is_error_during_diagnose) {
1337 1337
         $info_div_class = "geodir_problem_info";
1338
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1338
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1339 1339
     } else {
1340 1340
         $info_div_class = "geodir_noproblem_info";
1341 1341
         $fix_button_txt = '';
@@ -1388,15 +1388,15 @@  discard block
 block discarded – undo
1388 1388
     if (!empty($ver_arr)) {
1389 1389
         foreach ($ver_arr as $key => $val) {
1390 1390
             if (delete_option($val)) {
1391
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1391
+                $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
1392 1392
             } else {
1393
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1393
+                $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
1394 1394
             }
1395 1395
 
1396 1396
         }
1397 1397
 
1398 1398
         if ($output_str) {
1399
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1399
+            $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
1400 1400
         }
1401 1401
 
1402 1402
     }
@@ -1435,55 +1435,55 @@  discard block
 block discarded – undo
1435 1435
 	$gd_post_types = geodir_get_posttypes();
1436 1436
 
1437 1437
 	$skip_post_types = array();
1438
-	if ( ! empty( $gd_post_types ) ) {
1439
-		foreach ( $gd_post_types as $post_type ) {
1440
-			$location_allowed = $post_type && function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1441
-			if ( $location_allowed ) {
1438
+	if (!empty($gd_post_types)) {
1439
+		foreach ($gd_post_types as $post_type) {
1440
+			$location_allowed = $post_type && function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1441
+			if ($location_allowed) {
1442 1442
 				continue;
1443 1443
 			}
1444 1444
 			$skip_post_types[] = $post_type;
1445 1445
 		}
1446 1446
 	}
1447
-	$skip_post_types_where = ! empty( $skip_post_types ) ? " AND post_type NOT IN( '" . implode( "','", $skip_post_types ) . "' )" : '';
1447
+	$skip_post_types_where = !empty($skip_post_types) ? " AND post_type NOT IN( '".implode("','", $skip_post_types)."' )" : '';
1448 1448
 
1449 1449
     // check review locations
1450
-    if ($wpdb->get_var("SELECT COUNT(*) FROM " . GEODIR_REVIEW_TABLE . " WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) {
1451
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1450
+    if ($wpdb->get_var("SELECT COUNT(*) FROM ".GEODIR_REVIEW_TABLE." WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) {
1451
+        $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
1452 1452
         $is_error_during_diagnose = true;
1453 1453
 
1454 1454
         if ($fix) {
1455 1455
             if (geodir_fix_review_location()) {
1456
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1456
+                $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
1457 1457
             } else {
1458
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1458
+                $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
1459 1459
             }
1460 1460
         }
1461 1461
 
1462 1462
     } else {
1463
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1463
+        $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
1464 1464
     }
1465 1465
 
1466 1466
     // check review content
1467
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1468
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1467
+    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
1468
+        $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
1469 1469
         $is_error_during_diagnose = true;
1470 1470
 
1471 1471
         if ($fix) {
1472 1472
             if (geodir_fix_review_content()) {
1473
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1473
+                $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
1474 1474
             } else {
1475
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1475
+                $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
1476 1476
             }
1477 1477
         }
1478 1478
 
1479 1479
     } else {
1480
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1480
+        $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
1481 1481
     }
1482 1482
 
1483 1483
 
1484 1484
     if ($is_error_during_diagnose) {
1485 1485
         $info_div_class = "geodir_problem_info";
1486
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1486
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1487 1487
     } else {
1488 1488
         $info_div_class = "geodir_noproblem_info";
1489 1489
         $fix_button_txt = '';
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 
1548 1548
     if ($is_error_during_diagnose) {
1549 1549
         $info_div_class = "geodir_problem_info";
1550
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1550
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1551 1551
     } else {
1552 1552
         $info_div_class = "geodir_noproblem_info";
1553 1553
         $fix_button_txt = '';
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
     else {
1582 1582
         $page_found = $wpdb->get_var(
1583 1583
             $wpdb->prepare(
1584
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1584
+                "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
1585 1585
                 array($slug)
1586 1586
             )
1587 1587
         );
@@ -1627,18 +1627,18 @@  discard block
 block discarded – undo
1627 1627
     //////////////////////////////////
1628 1628
     $option_value = get_option('geodir_home_page');
1629 1629
     $page = get_post($option_value);
1630
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1630
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1631 1631
 
1632
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1633
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1632
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1633
+        $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
1634 1634
     else {
1635 1635
         $is_error_during_diagnose = true;
1636
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1636
+        $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
1637 1637
         if ($fix) {
1638 1638
             if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1639
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1639
+                $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
1640 1640
             } else {
1641
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1641
+                $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
1642 1642
             }
1643 1643
         }
1644 1644
     }
@@ -1652,18 +1652,18 @@  discard block
 block discarded – undo
1652 1652
     //////////////////////////////////
1653 1653
     $option_value = get_option('geodir_add_listing_page');
1654 1654
     $page = get_post($option_value);
1655
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1655
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1656 1656
 
1657
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1658
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1657
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1658
+        $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
1659 1659
     else {
1660 1660
         $is_error_during_diagnose = true;
1661
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1661
+        $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
1662 1662
         if ($fix) {
1663 1663
             if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1664
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1664
+                $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
1665 1665
             } else {
1666
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1666
+                $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
1667 1667
             }
1668 1668
         }
1669 1669
     }
@@ -1678,18 +1678,18 @@  discard block
 block discarded – undo
1678 1678
     //////////////////////////////////
1679 1679
     $option_value = get_option('geodir_preview_page');
1680 1680
     $page = get_post($option_value);
1681
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1681
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1682 1682
 
1683
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1684
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1683
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1684
+        $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
1685 1685
     else {
1686 1686
         $is_error_during_diagnose = true;
1687
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1687
+        $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
1688 1688
         if ($fix) {
1689 1689
             if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1690
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1690
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
1691 1691
             } else {
1692
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1692
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
1693 1693
             }
1694 1694
         }
1695 1695
     }
@@ -1703,18 +1703,18 @@  discard block
 block discarded – undo
1703 1703
     //////////////////////////////////
1704 1704
     $option_value = get_option('geodir_success_page');
1705 1705
     $page = get_post($option_value);
1706
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1706
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1707 1707
 
1708
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1709
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1708
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1709
+        $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
1710 1710
     else {
1711 1711
         $is_error_during_diagnose = true;
1712
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1712
+        $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
1713 1713
         if ($fix) {
1714 1714
             if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1715
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1715
+                $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
1716 1716
             } else {
1717
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1717
+                $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
1718 1718
             }
1719 1719
         }
1720 1720
     }
@@ -1728,18 +1728,18 @@  discard block
 block discarded – undo
1728 1728
     //////////////////////////////////
1729 1729
     $option_value = get_option('geodir_info_page');
1730 1730
     $page = get_post($option_value);
1731
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1731
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1732 1732
 
1733
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1734
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1733
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1734
+        $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
1735 1735
     else {
1736 1736
         $is_error_during_diagnose = true;
1737
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1737
+        $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
1738 1738
         if ($fix) {
1739 1739
             if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1740
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1740
+                $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
1741 1741
             } else {
1742
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1742
+                $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
1743 1743
             }
1744 1744
         }
1745 1745
     }
@@ -1753,18 +1753,18 @@  discard block
 block discarded – undo
1753 1753
     //////////////////////////////////
1754 1754
     $option_value = get_option('geodir_login_page');
1755 1755
     $page = get_post($option_value);
1756
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1756
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1757 1757
 
1758
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1759
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1758
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1759
+        $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
1760 1760
     else {
1761 1761
         $is_error_during_diagnose = true;
1762
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1762
+        $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
1763 1763
         if ($fix) {
1764 1764
             if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1765
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1765
+                $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
1766 1766
             } else {
1767
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1767
+                $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
1768 1768
             }
1769 1769
         }
1770 1770
     }
@@ -1778,18 +1778,18 @@  discard block
 block discarded – undo
1778 1778
     //////////////////////////////////
1779 1779
     $option_value = get_option('geodir_location_page');
1780 1780
     $page = get_post($option_value);
1781
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1781
+    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
1782 1782
 
1783
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1784
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1783
+    if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish')
1784
+        $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
1785 1785
     else {
1786 1786
         $is_error_during_diagnose = true;
1787
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1787
+        $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
1788 1788
         if ($fix) {
1789 1789
             if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1790
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1790
+                $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
1791 1791
             } else {
1792
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1792
+                $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
1793 1793
             }
1794 1794
         }
1795 1795
     }
@@ -1798,13 +1798,13 @@  discard block
 block discarded – undo
1798 1798
     /* Diagnose Location Page Ends */
1799 1799
     ////////////////////////////////
1800 1800
 
1801
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1801
+    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
1802 1802
     /**
1803 1803
      * This action is called at the end of the GD Tools page check function.
1804 1804
      *
1805 1805
      * @since 1.5.2
1806 1806
      */
1807
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1807
+    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
1808 1808
 
1809 1809
     $output_str = $page_chk_arr['output_str'];
1810 1810
     $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
@@ -1814,7 +1814,7 @@  discard block
 block discarded – undo
1814 1814
             flush_rewrite_rules();
1815 1815
         }
1816 1816
         $info_div_class = "geodir_problem_info";
1817
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1817
+        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1818 1818
     } else {
1819 1819
         $info_div_class = "geodir_noproblem_info";
1820 1820
         $fix_button_txt = '';
@@ -1842,10 +1842,10 @@  discard block
 block discarded – undo
1842 1842
     $fix_button_txt = '';
1843 1843
 
1844 1844
     if ($is_error_during_diagnose) {
1845
-        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1845
+        $output_str .= "<li>".__('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory').' '.geodir_plugin_path().'/db-language.php'."</li>";
1846 1846
 		$info_div_class = "geodir_problem_info";
1847 1847
     } else {
1848
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1848
+        $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
1849 1849
 		$info_div_class = "geodir_noproblem_info";
1850 1850
         $fix_button_txt = '';
1851 1851
     }
@@ -1887,17 +1887,17 @@  discard block
 block discarded – undo
1887 1887
     global $wpdb, $wp_query, $plugin_prefix;
1888 1888
 
1889 1889
     if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1890
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1890
+        $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail';
1891 1891
 
1892
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1892
+        $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)';
1893 1893
         $clauses['join'] = $join;
1894 1894
 
1895
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1895
+        $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : '';
1896 1896
         $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1897 1897
         $clauses['fields'] = $fields;
1898 1898
 
1899 1899
         $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1900
-        $orderby = 'gd_expire ' . $order;
1900
+        $orderby = 'gd_expire '.$order;
1901 1901
         $clauses['orderby'] = $orderby;
1902 1902
     }
1903 1903
     return $clauses;
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
         global $current_user;
1941 1941
         $upload_dir = wp_upload_dir();
1942 1942
 
1943
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1943
+        $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv';
1944 1944
         $handle = fopen($file, 'w');
1945 1945
 
1946 1946
         fwrite($handle, $input);
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
     $uploads_dir = $uploads['path'];
1986 1986
     $image_name_arr = explode('/', $filename);
1987 1987
     $filename = end($image_name_arr);
1988
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1988
+    $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1989 1989
     $return = array();
1990 1990
     $return['file'] = $uploadedFile;
1991 1991
     $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
@@ -2002,8 +2002,8 @@  discard block
 block discarded – undo
2002 2002
 
2003 2003
                 if (($handle = fopen($target_path, "r")) !== FALSE) {
2004 2004
                     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
2005
-                        if(is_array($data) && !empty($data)) {
2006
-                            $file[] = '"' . implode('","', $data) . '"';
2005
+                        if (is_array($data) && !empty($data)) {
2006
+                            $file[] = '"'.implode('","', $data).'"';
2007 2007
                         }
2008 2008
                     }
2009 2009
                     fclose($handle);
@@ -2120,10 +2120,10 @@  discard block
 block discarded – undo
2120 2120
                     $tag_arr = explode(',', $post_tags);
2121 2121
                 }
2122 2122
 
2123
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
2123
+                $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database
2124 2124
 
2125 2125
                 $error = '';
2126
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
2126
+                if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
2127 2127
                     $invalid_post_type++;
2128 2128
                     continue;
2129 2129
                 }
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
                             if ($buffer[$c] != '0' && $buffer[$c] != '') {
2150 2150
                                 $submitdata = date('Y-m-d');
2151 2151
 
2152
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
2152
+                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
2153 2153
                             } else {
2154 2154
                                 $gd_post_info['expire_date'] = 'Never';
2155 2155
                             }
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 						
2178 2178
 						// Post status
2179 2179
 						if ($customKeyarray[$c] == 'post_status') {
2180
-                            $post_status = sanitize_key( $buffer[$c] );
2180
+                            $post_status = sanitize_key($buffer[$c]);
2181 2181
                         }
2182 2182
                     }
2183 2183
 
@@ -2195,8 +2195,8 @@  discard block
 block discarded – undo
2195 2195
 					
2196 2196
 					// Default post status
2197 2197
 					$default_status = 'publish';
2198
-					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
2199
-					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
2198
+					$post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
2199
+					$post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
2200 2200
 
2201 2201
                     $my_post['post_title'] = $post_title;
2202 2202
                     $my_post['post_content'] = $post_desc;
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
                     $payment_info = array();
2241 2241
                     $package_info = array();
2242 2242
 
2243
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
2243
+                    $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]);
2244 2244
                     $package_id = '';
2245 2245
                     if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
2246 2246
                         $package_id = $gd_post_info['package_id'];
@@ -2250,7 +2250,7 @@  discard block
 block discarded – undo
2250 2250
                         $payment_info['package_id'] = $package_info['pid'];
2251 2251
 
2252 2252
                         if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
2253
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
2253
+                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
2254 2254
                         } else {
2255 2255
                             $payment_info['expire_date'] = 'Never';
2256 2256
                         }
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
 
2263 2263
                     $post_type = get_post_type($last_postid);
2264 2264
 
2265
-                    $table = $plugin_prefix . $post_type . '_detail';
2265
+                    $table = $plugin_prefix.$post_type.'_detail';
2266 2266
 
2267 2267
                     geodir_save_post_info($last_postid, $gd_post_info);
2268 2268
 
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
                             $attachment['post_id'] = $last_postid;
2284 2284
                             $attachment['title'] = $img_name_arr[0];
2285 2285
                             $attachment['content'] = '';
2286
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
2286
+                            $attachment['file'] = $sub_dir.'/'.$image_name;
2287 2287
                             $attachment['mime_type'] = $uploaded_file_type;
2288 2288
                             $attachment['menu_order'] = $menu_order;
2289 2289
                             $attachment['is_featured'] = 0;
@@ -2292,15 +2292,15 @@  discard block
 block discarded – undo
2292 2292
 
2293 2293
                             foreach ($attachment as $key => $val) {
2294 2294
                                 if ($val != '')
2295
-                                    $attachment_set .= $key . " = '" . $val . "', ";
2295
+                                    $attachment_set .= $key." = '".$val."', ";
2296 2296
                             }
2297 2297
                             $attachment_set = trim($attachment_set, ", ");
2298 2298
 
2299
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
2299
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
2300 2300
 
2301 2301
                             if ($menu_order == 1) {
2302 2302
                                 $post_type = get_post_type($last_postid);
2303
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
2303
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
2304 2304
                             }
2305 2305
                             $menu_order++;
2306 2306
                         }
@@ -2341,11 +2341,11 @@  discard block
 block discarded – undo
2341 2341
 }
2342 2342
 
2343 2343
 // Add the tab in left sidebar menu fro import & export page.
2344
-add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 );
2344
+add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
2345 2345
 
2346 2346
 // Handle ajax request for import/export.
2347
-add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' );
2348
-add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' );
2347
+add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
2348
+add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
2349 2349
 
2350 2350
 
2351 2351
 /**
@@ -2356,40 +2356,40 @@  discard block
 block discarded – undo
2356 2356
  * @param $post_id int $post_id The post ID of the post being saved.
2357 2357
  * @param $post object $post The post object of the post being saved.
2358 2358
  */
2359
-function geodir_update_location_prefix($post_id,$post){
2360
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2361
-        update_option('geodir_location_prefix',$post->post_name);
2359
+function geodir_update_location_prefix($post_id, $post) {
2360
+    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
2361
+        update_option('geodir_location_prefix', $post->post_name);
2362 2362
     }
2363 2363
 
2364 2364
 }
2365 2365
 
2366
-add_action('save_post', 'geodir_update_location_prefix',10,2);
2366
+add_action('save_post', 'geodir_update_location_prefix', 10, 2);
2367 2367
 
2368
-add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' );
2368
+add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
2369 2369
 
2370
-function geodir_ga_callback(){
2370
+function geodir_ga_callback() {
2371 2371
 
2372
-if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2372
+if (isset($_REQUEST['code']) && $_REQUEST['code']) {
2373 2373
     $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2374 2374
     $code = "code=".$_REQUEST['code'];
2375 2375
     $grant_type = "&grant_type=authorization_code";
2376
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2376
+    $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
2377 2377
     $client_id = "&client_id=".get_option('geodir_ga_client_id');
2378 2378
     $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2379 2379
 
2380
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2380
+    $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret;
2381 2381
 
2382 2382
     $response = wp_remote_post($auth_url, array('timeout' => 15));
2383 2383
 
2384 2384
     //print_r($response);
2385 2385
 
2386
-    $error_msg =  __('Something went wrong','geodirectory');
2387
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2386
+    $error_msg = __('Something went wrong', 'geodirectory');
2387
+    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
2388 2388
 
2389 2389
         $parts = json_decode($response['body']);
2390 2390
         //print_r($parts);
2391
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2392
-        else{
2391
+        if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
2392
+        else {
2393 2393
 
2394 2394
             update_option('gd_ga_access_token', $parts->access_token);
2395 2395
             update_option('gd_ga_refresh_token', $parts->refresh_token);
@@ -2398,18 +2398,18 @@  discard block
 block discarded – undo
2398 2398
 
2399 2399
 
2400 2400
     }
2401
-    elseif(!empty($response['response']['code'])) {
2401
+    elseif (!empty($response['response']['code'])) {
2402 2402
         $parts = json_decode($response['body']);
2403 2403
 
2404
-        if(isset($parts->error)){
2405
-            echo $parts->error.": ".$parts->error_description;exit;
2406
-        }else{
2407
-            echo $error_msg." - #2";exit;
2404
+        if (isset($parts->error)) {
2405
+            echo $parts->error.": ".$parts->error_description; exit;
2406
+        } else {
2407
+            echo $error_msg." - #2"; exit;
2408 2408
         }
2409 2409
 
2410
-    }else{
2410
+    } else {
2411 2411
 
2412
-        echo $error_msg." - #3";exit;
2412
+        echo $error_msg." - #3"; exit;
2413 2413
 
2414 2414
     }
2415 2415
 }
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
 function geodir_uninstall_settings($general_settings) {
2432 2432
     $settings   = array();
2433 2433
     $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
2434
-    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
2434
+    $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory'));
2435 2435
     
2436 2436
     $plugins    = get_plugins();
2437 2437
     $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
             if (in_array($plugin_name, $un_plugins)) {
2444 2444
                 $settings[] = array(
2445 2445
                     'type' => 'checkbox',
2446
-                    'id' => 'geodir_un_' . $plugin_name,
2446
+                    'id' => 'geodir_un_'.$plugin_name,
2447 2447
                     'name' => $data['Name'],
2448 2448
                     'desc' => __('Remove all data when deleted?', 'geodirectory'),
2449 2449
                     'std' => '0'
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
  * @since 1.6.9
2478 2478
  */
2479 2479
 function geodir_uninstall_settings_desc() {
2480
-    echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>';
2480
+    echo '<p class="gd-un-settings-desc">'.__('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory').'</p>';
2481 2481
 }
2482 2482
 add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
2483 2483
 
@@ -2541,12 +2541,12 @@  discard block
 block discarded – undo
2541 2541
 
2542 2542
 
2543 2543
     if ($delete) {
2544
-            $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>";
2544
+            $output_str .= "<li><strong>".__('Table dropped, refresh page to reinstall.', 'geodirectory')."</strong></li>";
2545 2545
         ob_start();
2546 2546
         geodir_diagnose_version_clear();
2547 2547
         ob_end_clean();
2548
-    }else{
2549
-        $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>";
2548
+    } else {
2549
+        $output_str .= "<li><strong>".__('Something went wrong.', 'geodirectory')."</strong></li>";
2550 2550
     }
2551 2551
 
2552 2552
     if ($is_error_during_diagnose) {
@@ -2571,9 +2571,9 @@  discard block
 block discarded – undo
2571 2571
  * @param object $row The post|taxonomy object.
2572 2572
  * @return array Filtered actions.
2573 2573
  */
2574
-function geodir_disable_quick_edit( $actions = array(), $row = null ) {
2575
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
2576
-        unset( $actions['inline hide-if-no-js'] );
2574
+function geodir_disable_quick_edit($actions = array(), $row = null) {
2575
+    if (isset($actions['inline hide-if-no-js'])) {
2576
+        unset($actions['inline hide-if-no-js']);
2577 2577
     }
2578 2578
 
2579 2579
     return $actions;
@@ -2592,26 +2592,26 @@  discard block
 block discarded – undo
2592 2592
 function geodir_check_quick_edit() {
2593 2593
     global $pagenow, $current_screen, $gd_cpt_screen;
2594 2594
 
2595
-    if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) {
2596
-        if ( empty( $gd_cpt_screen ) ) {
2597
-            if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) {
2595
+    if (($pagenow == 'edit.php' || $pagenow == 'edit-tags.php') && !empty($current_screen->post_type)) {
2596
+        if (empty($gd_cpt_screen)) {
2597
+            if (in_array($current_screen->post_type, geodir_get_posttypes())) {
2598 2598
                 $gd_cpt_screen = 'y';
2599 2599
             } else {
2600 2600
                 $gd_cpt_screen = 'n';
2601 2601
             }
2602 2602
         }
2603 2603
 
2604
-        if ( $gd_cpt_screen == 'y' ) {
2605
-            if ( $pagenow == 'edit.php' ) {
2606
-                add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2607
-                add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2608
-            } elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) {
2609
-                add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 );
2604
+        if ($gd_cpt_screen == 'y') {
2605
+            if ($pagenow == 'edit.php') {
2606
+                add_filter('post_row_actions', 'geodir_disable_quick_edit', 10, 2);
2607
+                add_filter('page_row_actions', 'geodir_disable_quick_edit', 10, 2);
2608
+            } elseif ($pagenow == 'edit-tags.php' && !empty($current_screen->taxonomy)) {
2609
+                add_filter($current_screen->taxonomy.'_row_actions', 'geodir_disable_quick_edit', 10, 2);
2610 2610
             }
2611 2611
         }
2612 2612
     }
2613 2613
 }
2614
-add_action( 'admin_head', 'geodir_check_quick_edit', 10 );
2614
+add_action('admin_head', 'geodir_check_quick_edit', 10);
2615 2615
 
2616 2616
 /**
2617 2617
  * Filter the bulk actions for GD CPT.
@@ -2622,9 +2622,9 @@  discard block
 block discarded – undo
2622 2622
  * @param array $actions An array of the available bulk actions.
2623 2623
  * @return array Filtered bulk actions.
2624 2624
  */
2625
-function geodir_filter_bulk_actions( $actions ) {
2626
-    if ( isset( $actions['edit'] ) ) {
2627
-        unset( $actions['edit'] );
2625
+function geodir_filter_bulk_actions($actions) {
2626
+    if (isset($actions['edit'])) {
2627
+        unset($actions['edit']);
2628 2628
     }
2629 2629
     
2630 2630
     return $actions;
@@ -2637,15 +2637,15 @@  discard block
 block discarded – undo
2637 2637
  *
2638 2638
  * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference
2639 2639
  */
2640
-function geodir_admin_bar_menu_set_post( $wp_admin_bar ) {
2640
+function geodir_admin_bar_menu_set_post($wp_admin_bar) {
2641 2641
 	global $post, $gd_admin_bar_post, $pagenow;
2642 2642
 
2643
-	if ( $pagenow == 'post.php' && ! empty( $post ) && is_object( $post ) && ! empty( $post->ID ) && ! is_a( $post, 'WP_Post' ) && isset( $post->post_id ) ) {
2643
+	if ($pagenow == 'post.php' && !empty($post) && is_object($post) && !empty($post->ID) && !is_a($post, 'WP_Post') && isset($post->post_id)) {
2644 2644
 		$gd_admin_bar_post = $post;
2645
-		$post = get_post( $post->ID );
2645
+		$post = get_post($post->ID);
2646 2646
 	}
2647 2647
 }
2648
-add_action( 'admin_bar_menu', 'geodir_admin_bar_menu_set_post', 94, 1 );
2648
+add_action('admin_bar_menu', 'geodir_admin_bar_menu_set_post', 94, 1);
2649 2649
 
2650 2650
 /**
2651 2651
  * Reset $post to original.
@@ -2655,9 +2655,9 @@  discard block
 block discarded – undo
2655 2655
 function geodir_admin_bar_menu_reset_post() {
2656 2656
 	global $post, $gd_admin_bar_post;
2657 2657
 
2658
-	if ( ! empty( $gd_admin_bar_post ) && ! empty( $post ) ) {
2658
+	if (!empty($gd_admin_bar_post) && !empty($post)) {
2659 2659
 		$post = $gd_admin_bar_post;
2660 2660
 		$gd_admin_bar_post = NULL;
2661 2661
 	}
2662 2662
 }
2663
-add_action( 'wp_after_admin_bar_render', 'geodir_admin_bar_menu_reset_post', 9999 );
2664 2663
\ No newline at end of file
2664
+add_action('wp_after_admin_bar_render', 'geodir_admin_bar_menu_reset_post', 9999);
2665 2665
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory_hooks_actions.php 3 patches
Indentation   +1212 added lines, -1212 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function geodir_get_ajax_url()
21 21
 {
22
-    return admin_url('admin-ajax.php?action=geodir_ajax_action');
22
+	return admin_url('admin-ajax.php?action=geodir_ajax_action');
23 23
 }
24 24
 
25 25
 /////////////////////
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 add_filter('query_vars', 'geodir_add_geodir_page_var');
88 88
 add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
89 89
 if (get_option('permalink_structure') != '')
90
-    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
90
+	add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
91 91
 
92 92
 add_filter('parse_query', 'geodir_modified_query');
93 93
 
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 /* POST AND LOOP ACTIONS */
155 155
 ////////////////////////
156 156
 if (!is_admin()) {
157
-    add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere
158
-    add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
-    /** Exclude Virtual Pages From Pages List **/
160
-    add_action('pre_get_posts', 'set_listing_request', 0);
161
-    add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
-    add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
-    add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
-    add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
157
+	add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere
158
+	add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
+	/** Exclude Virtual Pages From Pages List **/
160
+	add_action('pre_get_posts', 'set_listing_request', 0);
161
+	add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
+	add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
+	add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
+	add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
165 165
 }
166 166
 
167 167
 
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
  */
224 224
 function geodir_unset_prev_theme_nav_location($newname)
225 225
 {
226
-    $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
227
-    if ($geodir_theme_location) {
228
-        update_option('geodir_theme_location_nav', $geodir_theme_location);
229
-    } else {
230
-        update_option('geodir_theme_location_nav', '');
231
-    }
226
+	$geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
227
+	if ($geodir_theme_location) {
228
+		update_option('geodir_theme_location_nav', $geodir_theme_location);
229
+	} else {
230
+		update_option('geodir_theme_location_nav', '');
231
+	}
232 232
 }
233 233
 
234 234
 /// add action for theme switch to blank previous theme navigation location setting
@@ -249,42 +249,42 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function geodir_add_post_filters()
251 251
 {
252
-    /**
253
-     * Contains all function for filtering listing.
254
-     *
255
-     * @since 1.0.0
256
-     * @package GeoDirectory
257
-     */
258
-    include_once('geodirectory-functions/listing_filters.php');
252
+	/**
253
+	 * Contains all function for filtering listing.
254
+	 *
255
+	 * @since 1.0.0
256
+	 * @package GeoDirectory
257
+	 */
258
+	include_once('geodirectory-functions/listing_filters.php');
259 259
     
260
-    // Theme My Login compatibility fix
261
-    if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) {
262
-        remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) );
263
-    }
260
+	// Theme My Login compatibility fix
261
+	if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) {
262
+		remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) );
263
+	}
264 264
     
265
-    if ( isset( $_REQUEST['geodir_search'] ) ) {
266
-        add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 );
267
-        add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 );
268
-    }
265
+	if ( isset( $_REQUEST['geodir_search'] ) ) {
266
+		add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 );
267
+		add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 );
268
+	}
269 269
 }
270 270
 
271 271
 
272 272
 if (!function_exists('geodir_init_defaults')) {
273
-    /**
274
-     * Calls the function to register the GeoDirectory default CPT and taxonomies.
275
-     *
276
-     * @since 1.0.0
277
-     * @package GeoDirectory
278
-     */
279
-    function geodir_init_defaults()
280
-    {
281
-        if (function_exists('geodir_register_defaults')) {
273
+	/**
274
+	 * Calls the function to register the GeoDirectory default CPT and taxonomies.
275
+	 *
276
+	 * @since 1.0.0
277
+	 * @package GeoDirectory
278
+	 */
279
+	function geodir_init_defaults()
280
+	{
281
+		if (function_exists('geodir_register_defaults')) {
282 282
 
283
-            geodir_register_defaults();
283
+			geodir_register_defaults();
284 284
 
285
-        }
285
+		}
286 286
 
287
-    }
287
+	}
288 288
 }
289 289
 
290 290
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
 // CALLED ON 'sidebars_widgets' FILTER
307 307
 
308 308
 if (!function_exists('geodir_restrict_widget')) {
309
-    /**
310
-     * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
311
-     *
312
-     * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
313
-     * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
314
-     * @since 1.0.0
315
-     * @package GeoDirectory
316
-     */
317
-    function geodir_restrict_widget()
318
-    {
319
-        global $is_listing, $is_single_place;
309
+	/**
310
+	 * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
311
+	 *
312
+	 * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
313
+	 * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
314
+	 * @since 1.0.0
315
+	 * @package GeoDirectory
316
+	 */
317
+	function geodir_restrict_widget()
318
+	{
319
+		global $is_listing, $is_single_place;
320 320
 
321
-        // set is listing	
322
-        (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
321
+		// set is listing	
322
+		(geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
323 323
 
324
-        // set is single place
325
-        (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
324
+		// set is single place
325
+		(geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
326 326
 
327 327
 
328
-    }
328
+	}
329 329
 }
330 330
 
331 331
 
@@ -346,31 +346,31 @@  discard block
 block discarded – undo
346 346
  */
347 347
 function geodir_detail_page_sidebar_content_sorting()
348 348
 {
349
-    $arr_detail_page_sidebar_content =
350
-        /**
351
-         * An array of functions to be called to be displayed on the details (post) page sidebar.
352
-         *
353
-         * This filter can be used to remove sections of the details page sidebar,
354
-         * add new sections or rearrange the order of the sections.
355
-         *
356
-         * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
357
-         * @since 1.0.0
358
-         */
359
-        apply_filters('geodir_detail_page_sidebar_content',
360
-            array('geodir_social_sharing_buttons',
361
-                'geodir_detail_page_google_analytics',
362
-                'geodir_edit_post_link',
363
-                'geodir_detail_page_review_rating',
364
-                'geodir_detail_page_more_info'
365
-            ) // end of array 
366
-        ); // end of apply filter
367
-    if (!empty($arr_detail_page_sidebar_content)) {
368
-        foreach ($arr_detail_page_sidebar_content as $content_function) {
369
-            if (function_exists($content_function)) {
370
-                add_action('geodir_detail_page_sidebar', $content_function);
371
-            }
372
-        }
373
-    }
349
+	$arr_detail_page_sidebar_content =
350
+		/**
351
+		 * An array of functions to be called to be displayed on the details (post) page sidebar.
352
+		 *
353
+		 * This filter can be used to remove sections of the details page sidebar,
354
+		 * add new sections or rearrange the order of the sections.
355
+		 *
356
+		 * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
357
+		 * @since 1.0.0
358
+		 */
359
+		apply_filters('geodir_detail_page_sidebar_content',
360
+			array('geodir_social_sharing_buttons',
361
+				'geodir_detail_page_google_analytics',
362
+				'geodir_edit_post_link',
363
+				'geodir_detail_page_review_rating',
364
+				'geodir_detail_page_more_info'
365
+			) // end of array 
366
+		); // end of apply filter
367
+	if (!empty($arr_detail_page_sidebar_content)) {
368
+		foreach ($arr_detail_page_sidebar_content as $content_function) {
369
+			if (function_exists($content_function)) {
370
+				add_action('geodir_detail_page_sidebar', $content_function);
371
+			}
372
+		}
373
+	}
374 374
 }
375 375
 
376 376
 add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1);
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
  */
386 386
 function geodir_add_to_favourite_link()
387 387
 {
388
-    global $post, $preview;
389
-    if (!$preview && geodir_is_page('detail')) {
390
-        ?>
388
+	global $post, $preview;
389
+	if (!$preview && geodir_is_page('detail')) {
390
+		?>
391 391
         <p class="edit_link">
392 392
             <?php geodir_favourite_html($post->post_author, $post->ID); ?>
393 393
         </p>
394 394
     <?php
395
-    }
395
+	}
396 396
 }
397 397
 
398 398
 /**
@@ -406,41 +406,41 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function geodir_social_sharing_buttons()
408 408
 {
409
-    global $preview;
410
-    ob_start(); // Start  buffering;
411
-    /**
412
-     * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
413
-     *
414
-     * @since 1.0.0
415
-     */
416
-    do_action('geodir_before_social_sharing_buttons');
417
-    if (!$preview) {
418
-        ?>
409
+	global $preview;
410
+	ob_start(); // Start  buffering;
411
+	/**
412
+	 * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
413
+	 *
414
+	 * @since 1.0.0
415
+	 */
416
+	do_action('geodir_before_social_sharing_buttons');
417
+	if (!$preview) {
418
+		?>
419 419
         <div class="likethis">
420 420
             <?php geodir_twitter_tweet_button(); ?>
421 421
             <?php geodir_fb_like_button(); ?>
422 422
             <?php geodir_google_plus_button(); ?>
423 423
         </div>
424 424
     <?php
425
-    }// end of if, if its a preview or not
426
-
427
-    /**
428
-     * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
429
-     *
430
-     * @since 1.0.0
431
-     */
432
-    do_action('geodir_after_social_sharing_buttons');
433
-    $content_html = ob_get_clean();
434
-    if (trim($content_html) != '')
435
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
436
-    if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
437
-        /**
438
-         * Filter the geodir_social_sharing_buttons() function content.
439
-         *
440
-         * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
441
-         */
442
-        echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
443
-    }
425
+	}// end of if, if its a preview or not
426
+
427
+	/**
428
+	 * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
429
+	 *
430
+	 * @since 1.0.0
431
+	 */
432
+	do_action('geodir_after_social_sharing_buttons');
433
+	$content_html = ob_get_clean();
434
+	if (trim($content_html) != '')
435
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
436
+	if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
437
+		/**
438
+		 * Filter the geodir_social_sharing_buttons() function content.
439
+		 *
440
+		 * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
441
+		 */
442
+		echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
443
+	}
444 444
 
445 445
 
446 446
 }
@@ -458,46 +458,46 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_edit_post_link()
460 460
 {
461
-    global $post, $preview;
462
-    ob_start(); // Start buffering;
463
-    /**
464
-     * This is called before the edit post link html in the function geodir_edit_post_link()
465
-     *
466
-     * @since 1.0.0
467
-     */
468
-    do_action('geodir_before_edit_post_link');
469
-    if (!$preview) {
470
-        $is_current_user_owner = geodir_listing_belong_to_current_user();
461
+	global $post, $preview;
462
+	ob_start(); // Start buffering;
463
+	/**
464
+	 * This is called before the edit post link html in the function geodir_edit_post_link()
465
+	 *
466
+	 * @since 1.0.0
467
+	 */
468
+	do_action('geodir_before_edit_post_link');
469
+	if (!$preview) {
470
+		$is_current_user_owner = geodir_listing_belong_to_current_user();
471 471
         
472
-        if ($is_current_user_owner) {
473
-            $post_id = $post->ID;
472
+		if ($is_current_user_owner) {
473
+			$post_id = $post->ID;
474 474
             
475
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
476
-                $post_id = (int)$_REQUEST['pid'];
477
-            }
475
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
476
+				$post_id = (int)$_REQUEST['pid'];
477
+			}
478 478
 
479
-            $postlink = get_permalink(geodir_add_listing_page_id());
480
-            $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
481
-            echo ' <p class="edit_link"><i class="fas fa-pencil-alt"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
482
-        }
483
-    }// end of if, if its a preview or not
484
-    /**
485
-     * This is called after the edit post link html in the function geodir_edit_post_link()
486
-     *
487
-     * @since 1.0.0
488
-     */
489
-    do_action('geodir_after_edit_post_link');
490
-    $content_html = ob_get_clean();
491
-    if (trim($content_html) != '')
492
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
-    if ((int)get_option('geodir_disable_user_links_section') != 1) {
494
-        /**
495
-         * Filter the geodir_edit_post_link() function content.
496
-         *
497
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
498
-         */
499
-        echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
500
-    }
479
+			$postlink = get_permalink(geodir_add_listing_page_id());
480
+			$editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
481
+			echo ' <p class="edit_link"><i class="fas fa-pencil-alt"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
482
+		}
483
+	}// end of if, if its a preview or not
484
+	/**
485
+	 * This is called after the edit post link html in the function geodir_edit_post_link()
486
+	 *
487
+	 * @since 1.0.0
488
+	 */
489
+	do_action('geodir_after_edit_post_link');
490
+	$content_html = ob_get_clean();
491
+	if (trim($content_html) != '')
492
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
+	if ((int)get_option('geodir_disable_user_links_section') != 1) {
494
+		/**
495
+		 * Filter the geodir_edit_post_link() function content.
496
+		 *
497
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
498
+		 */
499
+		echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
500
+	}
501 501
 }
502 502
 
503 503
 /**
@@ -511,45 +511,45 @@  discard block
 block discarded – undo
511 511
  */
512 512
 function geodir_detail_page_google_analytics()
513 513
 {
514
-    if ( ! get_option( 'geodir_ga_stats' ) ) {
514
+	if ( ! get_option( 'geodir_ga_stats' ) ) {
515 515
 		return;
516 516
 	}
517 517
 	global $post,$preview;
518
-    if($preview){return '';}
519
-    $package_info = array();
520
-    $package_info = geodir_post_package_info($package_info, $post);
518
+	if($preview){return '';}
519
+	$package_info = array();
520
+	$package_info = geodir_post_package_info($package_info, $post);
521 521
 
522
-    $id = trim(get_option('geodir_ga_account_id'));
522
+	$id = trim(get_option('geodir_ga_account_id'));
523 523
 
524
-    if (!$id) {
525
-        return; //if no Google Analytics ID then bail.
526
-    }
524
+	if (!$id) {
525
+		return; //if no Google Analytics ID then bail.
526
+	}
527 527
 
528
-    ob_start(); // Start buffering;
529
-    /**
530
-     * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
531
-     *
532
-     * @since 1.0.0
533
-     */
534
-    do_action('geodir_before_google_analytics');
528
+	ob_start(); // Start buffering;
529
+	/**
530
+	 * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
531
+	 *
532
+	 * @since 1.0.0
533
+	 */
534
+	do_action('geodir_before_google_analytics');
535 535
     
536
-    $refresh_time = get_option('geodir_ga_refresh_time', 5);
537
-    /**
538
-     * Filter the time interval to check & refresh new users results.
539
-     *
540
-     * @since 1.5.9
541
-     *
542
-     * @param int $refresh_time Time interval to check & refresh new users results.
543
-     */
544
-    $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
545
-    $refresh_time = absint($refresh_time * 1000);
536
+	$refresh_time = get_option('geodir_ga_refresh_time', 5);
537
+	/**
538
+	 * Filter the time interval to check & refresh new users results.
539
+	 *
540
+	 * @since 1.5.9
541
+	 *
542
+	 * @param int $refresh_time Time interval to check & refresh new users results.
543
+	 */
544
+	$refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
545
+	$refresh_time = absint($refresh_time * 1000);
546 546
     
547
-    $hide_refresh = get_option('geodir_ga_auto_refresh');
547
+	$hide_refresh = get_option('geodir_ga_auto_refresh');
548 548
     
549
-    $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
550
-    if (is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
551
-        $page_url = urlencode($_SERVER['REQUEST_URI']);
552
-        ?>
549
+	$auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
550
+	if (is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
551
+		$page_url = urlencode($_SERVER['REQUEST_URI']);
552
+		?>
553 553
         <script type="text/javascript">
554 554
             var gd_gaTimeOut;
555 555
             var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
@@ -801,15 +801,15 @@  discard block
 block discarded – undo
801 801
                     var labels = results[1].rows.map(function(row) { return +row[0]; });
802 802
 
803 803
                     <?php
804
-                    // Here we list the shorthand days of the week so it can be used in translation.
805
-                    __("Mon",'geodirectory');
806
-                    __("Tue",'geodirectory');
807
-                    __("Wed",'geodirectory');
808
-                    __("Thu",'geodirectory');
809
-                    __("Fri",'geodirectory');
810
-                    __("Sat",'geodirectory');
811
-                    __("Sun",'geodirectory');
812
-                    ?>
804
+					// Here we list the shorthand days of the week so it can be used in translation.
805
+					__("Mon",'geodirectory');
806
+					__("Tue",'geodirectory');
807
+					__("Wed",'geodirectory');
808
+					__("Thu",'geodirectory');
809
+					__("Fri",'geodirectory');
810
+					__("Sat",'geodirectory');
811
+					__("Sun",'geodirectory');
812
+					?>
813 813
 
814 814
                     labels = [
815 815
                         "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
@@ -1058,24 +1058,24 @@  discard block
 block discarded – undo
1058 1058
         </span>
1059 1059
 
1060 1060
     <?php
1061
-    }
1062
-    /**
1063
-     * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1064
-     *
1065
-     * @since 1.0.0
1066
-     */
1067
-    do_action('geodir_after_google_analytics');
1068
-    $content_html = ob_get_clean();
1069
-    if (trim($content_html) != '')
1070
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1071
-    if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1072
-        /**
1073
-         * Filter the geodir_edit_post_link() function content.
1074
-         *
1075
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
1076
-         */
1077
-        echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1078
-    }
1061
+	}
1062
+	/**
1063
+	 * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1064
+	 *
1065
+	 * @since 1.0.0
1066
+	 */
1067
+	do_action('geodir_after_google_analytics');
1068
+	$content_html = ob_get_clean();
1069
+	if (trim($content_html) != '')
1070
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1071
+	if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1072
+		/**
1073
+		 * Filter the geodir_edit_post_link() function content.
1074
+		 *
1075
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
1076
+		 */
1077
+		echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1078
+	}
1079 1079
 }
1080 1080
 
1081 1081
 /**
@@ -1092,94 +1092,94 @@  discard block
 block discarded – undo
1092 1092
  */
1093 1093
 function geodir_detail_page_review_rating()
1094 1094
 {
1095
-    global $post, $preview, $post_images;
1095
+	global $post, $preview, $post_images;
1096 1096
     
1097
-    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1098
-        return;
1099
-    }
1100
-    ob_start(); // Start  buffering;
1101
-    /**
1102
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1103
-     *
1104
-     * This is called outside the check for an actual rating and the check for preview page.
1105
-     *
1106
-     * @since 1.0.0
1107
-     */
1108
-    do_action('geodir_before_detail_page_review_rating');
1109
-
1110
-    $comment_count = geodir_get_review_count_total($post->ID);
1111
-    $post_avgratings = geodir_get_post_rating($post->ID);
1112
-
1113
-    if ($post_avgratings != 0 && !$preview) {
1114
-        /**
1115
-         * This is called before the rating html in the function geodir_detail_page_review_rating().
1116
-         *
1117
-         * This is called inside the check for an actual rating and the check for preview page.
1118
-         *
1119
-         * @since 1.0.0
1120
-         * @param float $post_avgratings Average rating for the current post.
1121
-         * @param int $post->ID Current post ID.
1122
-         */
1123
-        do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1124
-
1125
-        $html = '<p style=" float:left;">';
1126
-        $html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1127
-        $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1128
-        $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1097
+	if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1098
+		return;
1099
+	}
1100
+	ob_start(); // Start  buffering;
1101
+	/**
1102
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1103
+	 *
1104
+	 * This is called outside the check for an actual rating and the check for preview page.
1105
+	 *
1106
+	 * @since 1.0.0
1107
+	 */
1108
+	do_action('geodir_before_detail_page_review_rating');
1109
+
1110
+	$comment_count = geodir_get_review_count_total($post->ID);
1111
+	$post_avgratings = geodir_get_post_rating($post->ID);
1112
+
1113
+	if ($post_avgratings != 0 && !$preview) {
1114
+		/**
1115
+		 * This is called before the rating html in the function geodir_detail_page_review_rating().
1116
+		 *
1117
+		 * This is called inside the check for an actual rating and the check for preview page.
1118
+		 *
1119
+		 * @since 1.0.0
1120
+		 * @param float $post_avgratings Average rating for the current post.
1121
+		 * @param int $post->ID Current post ID.
1122
+		 */
1123
+		do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1124
+
1125
+		$html = '<p style=" float:left;">';
1126
+		$html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1127
+		$html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1128
+		$post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1129 1129
        
1130 1130
 	   $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
1131 1131
 	   
1132 1132
 	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
1133 1133
 
1134
-        $html .= '<span class="item">';
1135
-        $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1134
+		$html .= '<span class="item">';
1135
+		$html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1136 1136
 
1137
-        if ($post_images) {
1138
-            foreach ($post_images as $img) {
1139
-                $post_img = $img->src;
1140
-                break;
1141
-            }
1142
-        }
1143
-
1144
-        if (isset($post_img) && $post_img) {
1145
-            $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1146
-        }
1147
-
1148
-        $html .= '</span>';
1149
-
1150
-        echo $html .= '</div>';
1151
-        /**
1152
-         * This is called after the rating html in the function geodir_detail_page_review_rating().
1153
-         *
1154
-         * This is called inside the check for an actual rating and the check for preview page.
1155
-         *
1156
-         * @since 1.0.0
1157
-         * @param float $post_avgratings Average rating for the current post.
1158
-         * @param int $post->ID Current post ID.
1159
-         */
1160
-        do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1161
-    }
1162
-    /**
1163
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1164
-     *
1165
-     * This is called outside the check for an actual rating and the check for preview page.
1166
-     *
1167
-     * @since 1.0.0
1168
-     */
1169
-    do_action('geodir_after_detail_page_review_rating');
1170
-    $content_html = ob_get_clean();
1171
-    if (trim($content_html) != '') {
1172
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1173
-    }
1174
-    if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1175
-        /**
1176
-         * Filter the geodir_detail_page_review_rating() function content.
1177
-         *
1178
-         * @since 1.0.0
1179
-         * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1180
-         */
1181
-        echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1182
-    }
1137
+		if ($post_images) {
1138
+			foreach ($post_images as $img) {
1139
+				$post_img = $img->src;
1140
+				break;
1141
+			}
1142
+		}
1143
+
1144
+		if (isset($post_img) && $post_img) {
1145
+			$html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1146
+		}
1147
+
1148
+		$html .= '</span>';
1149
+
1150
+		echo $html .= '</div>';
1151
+		/**
1152
+		 * This is called after the rating html in the function geodir_detail_page_review_rating().
1153
+		 *
1154
+		 * This is called inside the check for an actual rating and the check for preview page.
1155
+		 *
1156
+		 * @since 1.0.0
1157
+		 * @param float $post_avgratings Average rating for the current post.
1158
+		 * @param int $post->ID Current post ID.
1159
+		 */
1160
+		do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1161
+	}
1162
+	/**
1163
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1164
+	 *
1165
+	 * This is called outside the check for an actual rating and the check for preview page.
1166
+	 *
1167
+	 * @since 1.0.0
1168
+	 */
1169
+	do_action('geodir_after_detail_page_review_rating');
1170
+	$content_html = ob_get_clean();
1171
+	if (trim($content_html) != '') {
1172
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1173
+	}
1174
+	if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1175
+		/**
1176
+		 * Filter the geodir_detail_page_review_rating() function content.
1177
+		 *
1178
+		 * @since 1.0.0
1179
+		 * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1180
+		 */
1181
+		echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1182
+	}
1183 1183
 }
1184 1184
 
1185 1185
 /**
@@ -1191,35 +1191,35 @@  discard block
 block discarded – undo
1191 1191
  */
1192 1192
 function geodir_detail_page_more_info()
1193 1193
 {
1194
-    ob_start(); // Start  buffering;
1195
-    /**
1196
-     * This is called before the info section html.
1197
-     *
1198
-     * @since 1.0.0
1199
-     */
1200
-    do_action('geodir_before_detail_page_more_info');
1201
-    if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1202
-        echo $geodir_post_detail_fields;
1203
-    }
1204
-    /**
1205
-     * This is called after the info section html.
1206
-     *
1207
-     * @since 1.0.0
1208
-     */
1209
-    do_action('geodir_after_detail_page_more_info');
1210
-
1211
-    $content_html = ob_get_clean();
1212
-    if (trim($content_html) != '')
1213
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1214
-    if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1215
-        /**
1216
-         * Filter the output html for function geodir_detail_page_more_info().
1217
-         *
1218
-         * @since 1.0.0
1219
-         * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1220
-         */
1221
-        echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1222
-    }
1194
+	ob_start(); // Start  buffering;
1195
+	/**
1196
+	 * This is called before the info section html.
1197
+	 *
1198
+	 * @since 1.0.0
1199
+	 */
1200
+	do_action('geodir_before_detail_page_more_info');
1201
+	if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1202
+		echo $geodir_post_detail_fields;
1203
+	}
1204
+	/**
1205
+	 * This is called after the info section html.
1206
+	 *
1207
+	 * @since 1.0.0
1208
+	 */
1209
+	do_action('geodir_after_detail_page_more_info');
1210
+
1211
+	$content_html = ob_get_clean();
1212
+	if (trim($content_html) != '')
1213
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1214
+	if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1215
+		/**
1216
+		 * Filter the output html for function geodir_detail_page_more_info().
1217
+		 *
1218
+		 * @since 1.0.0
1219
+		 * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1220
+		 */
1221
+		echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1222
+	}
1223 1223
 }
1224 1224
 
1225 1225
 
@@ -1233,15 +1233,15 @@  discard block
 block discarded – undo
1233 1233
  */
1234 1234
 function geodir_localize_all_js_msg()
1235 1235
 {// check_ajax_referer function is used to make sure no files are uploaded remotely but it will fail if used between https and non https so we do the check below of the urls
1236
-    if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1237
-        $ajax_url = admin_url('admin-ajax.php');
1238
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1239
-        $ajax_url = admin_url('admin-ajax.php');
1240
-    } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1241
-        $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1242
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1243
-        $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1244
-    }
1236
+	if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1237
+		$ajax_url = admin_url('admin-ajax.php');
1238
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1239
+		$ajax_url = admin_url('admin-ajax.php');
1240
+	} elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1241
+		$ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1242
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1243
+		$ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1244
+	}
1245 1245
 	
1246 1246
 	/**
1247 1247
 	 * Filter the allowed image type extensions for post images.
@@ -1251,62 +1251,62 @@  discard block
 block discarded – undo
1251 1251
 	 */
1252 1252
 	$allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
1253 1253
 	
1254
-    $default_marker_icon = get_option('geodir_default_marker_icon');
1255
-    $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1256
-    $default_marker_width = $default_marker_size['w'];
1257
-    $default_marker_height = $default_marker_size['h'];
1254
+	$default_marker_icon = get_option('geodir_default_marker_icon');
1255
+	$default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1256
+	$default_marker_width = $default_marker_size['w'];
1257
+	$default_marker_height = $default_marker_size['h'];
1258 1258
     
1259
-    $arr_alert_msg = array(
1260
-        'geodir_plugin_url' => geodir_plugin_url(),
1261
-        'geodir_admin_ajax_url' => $ajax_url,
1262
-        'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1263
-        'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1264
-        'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1265
-        'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1266
-        //start not show alert msg
1267
-        'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1268
-        'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1269
-        'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1270
-        'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1271
-        'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1272
-        // end not show alert msg
1273
-        'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'),
1274
-        'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1275
-        //start not show alert msg
1276
-        'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1277
-        'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1278
-        'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1279
-        'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1280
-        'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1281
-        'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1282
-        'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1283
-        'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1284
-        'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1285
-        'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1286
-        'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1287
-        'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1288
-        'geodir_default_marker_icon' => $default_marker_icon,
1289
-        'geodir_default_marker_w' => $default_marker_width,
1290
-        'geodir_default_marker_h' => $default_marker_height,
1291
-        'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1292
-        'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1293
-        'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1294
-        'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1295
-        'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1296
-        'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1297
-        'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1298
-        'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1299
-        'err_empty_review' => __('Please type a review.', 'geodirectory'),
1300
-        'err_empty_reply' => __('Please type a reply.', 'geodirectory'),
1301
-        /* on/off dragging for phone devices */
1302
-        'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1303
-        'geodir_is_mobile' => wp_is_mobile() ? true : false,
1304
-        'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1305
-        'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1306
-        'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1307
-        'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1308
-        'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1309
-        'geodir_action_remove' => __('Remove', 'geodirectory'),
1259
+	$arr_alert_msg = array(
1260
+		'geodir_plugin_url' => geodir_plugin_url(),
1261
+		'geodir_admin_ajax_url' => $ajax_url,
1262
+		'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1263
+		'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1264
+		'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1265
+		'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1266
+		//start not show alert msg
1267
+		'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1268
+		'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1269
+		'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1270
+		'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1271
+		'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1272
+		// end not show alert msg
1273
+		'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'),
1274
+		'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1275
+		//start not show alert msg
1276
+		'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1277
+		'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1278
+		'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1279
+		'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1280
+		'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1281
+		'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1282
+		'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1283
+		'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1284
+		'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1285
+		'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1286
+		'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1287
+		'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1288
+		'geodir_default_marker_icon' => $default_marker_icon,
1289
+		'geodir_default_marker_w' => $default_marker_width,
1290
+		'geodir_default_marker_h' => $default_marker_height,
1291
+		'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1292
+		'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1293
+		'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1294
+		'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1295
+		'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1296
+		'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1297
+		'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1298
+		'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1299
+		'err_empty_review' => __('Please type a review.', 'geodirectory'),
1300
+		'err_empty_reply' => __('Please type a reply.', 'geodirectory'),
1301
+		/* on/off dragging for phone devices */
1302
+		'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1303
+		'geodir_is_mobile' => wp_is_mobile() ? true : false,
1304
+		'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1305
+		'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1306
+		'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1307
+		'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1308
+		'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1309
+		'geodir_action_remove' => __('Remove', 'geodirectory'),
1310 1310
 		'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
1311 1311
 		'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
1312 1312
 		'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
@@ -1314,43 +1314,43 @@  discard block
 block discarded – undo
1314 1314
 		'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
1315 1315
 		'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1316 1316
 		'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
1317
-        'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1318
-        'geodir_map_name' => geodir_map_name(),
1319
-        'osmStart' => __('Start', 'geodirectory'),
1320
-        'osmVia' => __('Via {viaNumber}', 'geodirectory'),
1321
-        'osmEnd' => __('Enter Your Location', 'geodirectory'),
1322
-        'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'),
1323
-        'geoMyLocation' => __('My Location', 'geodirectory'),
1324
-        'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')),
1325
-        'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')),
1326
-        'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')),
1327
-        'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')),
1328
-        'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')),
1317
+		'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1318
+		'geodir_map_name' => geodir_map_name(),
1319
+		'osmStart' => __('Start', 'geodirectory'),
1320
+		'osmVia' => __('Via {viaNumber}', 'geodirectory'),
1321
+		'osmEnd' => __('Enter Your Location', 'geodirectory'),
1322
+		'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'),
1323
+		'geoMyLocation' => __('My Location', 'geodirectory'),
1324
+		'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')),
1325
+		'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')),
1326
+		'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')),
1327
+		'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')),
1328
+		'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')),
1329 1329
 		'mapLanguage' => geodir_get_map_default_language(),
1330 1330
 		'lightBox_txtImage' => addslashes(__('Image', 'geodirectory')),
1331 1331
 		'lightBox_txtOf' => addslashes(__('of', 'geodirectory')),
1332
-    );
1333
-
1334
-    /**
1335
-     * Filters the translated JS strings from function geodir_localize_all_js_msg().
1336
-     *
1337
-     * With this filter you can add, remove or change translated JS strings.
1338
-     * You should add your own translations to this if you are building an addon rather than adding another script block.
1339
-     *
1340
-     * @since 1.0.0
1341
-     */
1342
-    $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1343
-
1344
-    foreach ($arr_alert_msg as $key => $value) {
1345
-        if (!is_scalar($value))
1346
-            continue;
1347
-        $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1348
-    }
1332
+	);
1333
+
1334
+	/**
1335
+	 * Filters the translated JS strings from function geodir_localize_all_js_msg().
1336
+	 *
1337
+	 * With this filter you can add, remove or change translated JS strings.
1338
+	 * You should add your own translations to this if you are building an addon rather than adding another script block.
1339
+	 *
1340
+	 * @since 1.0.0
1341
+	 */
1342
+	$arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1349 1343
 
1350
-    $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1351
-    echo '<script>';
1352
-    echo $script;
1353
-    echo '</script>';
1344
+	foreach ($arr_alert_msg as $key => $value) {
1345
+		if (!is_scalar($value))
1346
+			continue;
1347
+		$arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1348
+	}
1349
+
1350
+	$script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1351
+	echo '<script>';
1352
+	echo $script;
1353
+	echo '</script>';
1354 1354
 }
1355 1355
 
1356 1356
 add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31);
@@ -1366,11 +1366,11 @@  discard block
 block discarded – undo
1366 1366
  */
1367 1367
 function geodir_admin_bar_site_menu($wp_admin_bar)
1368 1368
 {
1369
-    if (get_option("geodir_installed")) {
1370
-        if (current_user_can('manage_options')) {
1371
-            $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1372
-        }
1373
-    }
1369
+	if (get_option("geodir_installed")) {
1370
+		if (current_user_can('manage_options')) {
1371
+			$wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1372
+		}
1373
+	}
1374 1374
 }
1375 1375
 
1376 1376
 add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/
@@ -1396,25 +1396,25 @@  discard block
 block discarded – undo
1396 1396
  */
1397 1397
 function geodir_store_sidebars()
1398 1398
 {
1399
-    global $geodir_sidebars;
1400
-    global $sidebars_widgets;
1401
-
1402
-    if (!is_array($sidebars_widgets))
1403
-        $sidebars_widgets = wp_get_sidebars_widgets();
1404
-    $geodir_old_sidebars = array();
1405
-
1406
-    if (is_array($geodir_sidebars)) {
1407
-        foreach ($geodir_sidebars as $val) {
1408
-            if (is_array($sidebars_widgets)) {
1409
-                if (array_key_exists($val, $sidebars_widgets))
1410
-                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1411
-                else
1412
-                    $geodir_old_sidebars[$val] = array();
1413
-            }
1414
-        }
1415
-    }
1416
-    update_option('geodir_sidebars', $geodir_old_sidebars);
1417
-    geodir_option_version_backup('geodir_sidebars');
1399
+	global $geodir_sidebars;
1400
+	global $sidebars_widgets;
1401
+
1402
+	if (!is_array($sidebars_widgets))
1403
+		$sidebars_widgets = wp_get_sidebars_widgets();
1404
+	$geodir_old_sidebars = array();
1405
+
1406
+	if (is_array($geodir_sidebars)) {
1407
+		foreach ($geodir_sidebars as $val) {
1408
+			if (is_array($sidebars_widgets)) {
1409
+				if (array_key_exists($val, $sidebars_widgets))
1410
+					$geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1411
+				else
1412
+					$geodir_old_sidebars[$val] = array();
1413
+			}
1414
+		}
1415
+	}
1416
+	update_option('geodir_sidebars', $geodir_old_sidebars);
1417
+	geodir_option_version_backup('geodir_sidebars');
1418 1418
 
1419 1419
 }
1420 1420
 
@@ -1428,28 +1428,28 @@  discard block
 block discarded – undo
1428 1428
  */
1429 1429
 function geodir_restore_sidebars()
1430 1430
 {
1431
-    global $sidebars_widgets;
1432
-
1433
-    if (!is_array($sidebars_widgets))
1434
-        $sidebars_widgets = wp_get_sidebars_widgets();
1435
-
1436
-    if (is_array($sidebars_widgets)) {
1437
-        $geodir_old_sidebars = get_option('geodir_sidebars');
1438
-        if (is_array($geodir_old_sidebars)) {
1439
-            foreach ($geodir_old_sidebars as $key => $val) {
1440
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1441
-                {
1442
-                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1443
-                }
1431
+	global $sidebars_widgets;
1444 1432
 
1433
+	if (!is_array($sidebars_widgets))
1434
+		$sidebars_widgets = wp_get_sidebars_widgets();
1445 1435
 
1446
-            }
1447
-        }
1436
+	if (is_array($sidebars_widgets)) {
1437
+		$geodir_old_sidebars = get_option('geodir_sidebars');
1438
+		if (is_array($geodir_old_sidebars)) {
1439
+			foreach ($geodir_old_sidebars as $key => $val) {
1440
+				if(0 === strpos($key, 'geodir_'))// if gd widget
1441
+				{
1442
+					$sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1443
+				}
1448 1444
 
1449
-    }
1450 1445
 
1451
-    update_option('sidebars_widgets', $sidebars_widgets);
1452
-    update_option('geodir_sidebars', '');
1446
+			}
1447
+		}
1448
+
1449
+	}
1450
+
1451
+	update_option('sidebars_widgets', $sidebars_widgets);
1452
+	update_option('geodir_sidebars', '');
1453 1453
 }
1454 1454
 
1455 1455
 add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview');
@@ -1462,9 +1462,9 @@  discard block
 block discarded – undo
1462 1462
  */
1463 1463
 function geodir_after_listing_post_gridview()
1464 1464
 {
1465
-    global $gridview_columns;
1465
+	global $gridview_columns;
1466 1466
 
1467
-    $gridview_columns = '';
1467
+	$gridview_columns = '';
1468 1468
 
1469 1469
 }
1470 1470
 
@@ -1492,11 +1492,11 @@  discard block
 block discarded – undo
1492 1492
  */
1493 1493
 function so_handle_038($url, $original_url, $_context)
1494 1494
 {
1495
-    if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1496
-        $url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1497
-    }
1495
+	if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1496
+		$url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1497
+	}
1498 1498
 
1499
-    return $url;
1499
+	return $url;
1500 1500
 }
1501 1501
 
1502 1502
 
@@ -1512,34 +1512,34 @@  discard block
 block discarded – undo
1512 1512
 function geodir_after_main_form_fields() {
1513 1513
 	global $gd_session;
1514 1514
 	
1515
-    if (get_option('geodir_accept_term_condition')) {
1516
-        global $post;
1517
-        $term_condition = '';
1518
-        if (isset($_REQUEST['backandedit'])) {
1519
-            $post = (object)$gd_session->get('listing');
1520
-            $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1521
-        }
1522
-
1523
-        ?>
1515
+	if (get_option('geodir_accept_term_condition')) {
1516
+		global $post;
1517
+		$term_condition = '';
1518
+		if (isset($_REQUEST['backandedit'])) {
1519
+			$post = (object)$gd_session->get('listing');
1520
+			$term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1521
+		}
1522
+
1523
+		?>
1524 1524
         <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix">
1525 1525
             <label>&nbsp;</label>
1526 1526
 
1527 1527
             <div class="geodir_taxonomy_field" style="float:left; width:70%;">
1528 1528
 				<span style="display:block"> 
1529 1529
 				<input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') {
1530
-                    echo 'checked="checked"';
1531
-                } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1530
+					echo 'checked="checked"';
1531
+				} ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1532 1532
                        class="geodir_textfield" value="1"
1533 1533
                        style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1534 1534
 				</span>
1535 1535
             </div>
1536 1536
             <span class="geodir_message_error"><?php if (isset($required_msg)) {
1537
-                    _e($required_msg, 'geodirectory');
1538
-                } ?></span>
1537
+					_e($required_msg, 'geodirectory');
1538
+				} ?></span>
1539 1539
         </div>
1540 1540
     <?php
1541 1541
 
1542
-    }
1542
+	}
1543 1543
 }
1544 1544
 
1545 1545
 
@@ -1564,42 +1564,42 @@  discard block
 block discarded – undo
1564 1564
  */
1565 1565
 function geodir_detail_page_tab_is_display($is_display, $tab)
1566 1566
 {
1567
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1567
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1568 1568
 
1569
-    if ($tab == 'post_profile') {
1570
-        /** This action is documented in geodirectory_template_actions.php */
1571
-        $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1569
+	if ($tab == 'post_profile') {
1570
+		/** This action is documented in geodirectory_template_actions.php */
1571
+		$desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1572 1572
         
1573
-        if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1574
-            $is_display = false;
1575
-        }
1576
-    }
1573
+		if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1574
+			$is_display = false;
1575
+		}
1576
+	}
1577 1577
     
1578
-    if ($tab == 'post_info')
1579
-        $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1578
+	if ($tab == 'post_info')
1579
+		$is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1580 1580
     
1581
-    if ($tab == 'post_images')
1582
-        $is_display = (!empty($post_images)) ? true : false;
1581
+	if ($tab == 'post_images')
1582
+		$is_display = (!empty($post_images)) ? true : false;
1583 1583
 
1584
-    if ($tab == 'post_video')
1585
-        $is_display = (!empty($video)) ? true : false;
1584
+	if ($tab == 'post_video')
1585
+		$is_display = (!empty($video)) ? true : false;
1586 1586
 
1587
-    if ($tab == 'special_offers')
1588
-        $is_display = (!empty($special_offers)) ? true : false;
1587
+	if ($tab == 'special_offers')
1588
+		$is_display = (!empty($special_offers)) ? true : false;
1589 1589
 
1590
-    if ($tab == 'reviews')
1591
-        $is_display = (geodir_is_page('detail')) ? true : false;
1590
+	if ($tab == 'reviews')
1591
+		$is_display = (geodir_is_page('detail')) ? true : false;
1592 1592
 
1593
-    if ($tab == 'related_listing') {
1594
-       $message = __('No listings found which match your selection.', 'geodirectory');
1593
+	if ($tab == 'related_listing') {
1594
+	   $message = __('No listings found which match your selection.', 'geodirectory');
1595 1595
        
1596
-       /** This action is documented in geodirectory-functions/template_functions.php */
1597
-       $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1596
+	   /** This action is documented in geodirectory-functions/template_functions.php */
1597
+	   $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1598 1598
        
1599
-       $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1600
-    }
1599
+	   $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1600
+	}
1601 1601
 
1602
-    return $is_display;
1602
+	return $is_display;
1603 1603
 }
1604 1604
 
1605 1605
 
@@ -1615,69 +1615,69 @@  discard block
 block discarded – undo
1615 1615
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1616 1616
  */
1617 1617
 function geodir_changes_in_custom_fields_table() {
1618
-    global $wpdb, $plugin_prefix;
1618
+	global $wpdb, $plugin_prefix;
1619 1619
 	
1620 1620
 	// Remove unused virtual page
1621 1621
 	$listings_page_id = (int)get_option('geodir_listing_page');
1622 1622
 	if ($listings_page_id) {
1623 1623
 		$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1624
-        delete_option('geodir_listing_page');
1624
+		delete_option('geodir_listing_page');
1625 1625
 	}
1626 1626
 
1627
-    if (!get_option('geodir_changes_in_custom_fields_table')) {
1628
-        $wpdb->query(
1629
-            $wpdb->prepare(
1630
-                "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1631
-                array('1', '1', 'admin')
1632
-            )
1633
-        );
1627
+	if (!get_option('geodir_changes_in_custom_fields_table')) {
1628
+		$wpdb->query(
1629
+			$wpdb->prepare(
1630
+				"UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1631
+				array('1', '1', 'admin')
1632
+			)
1633
+		);
1634 1634
 
1635 1635
 
1636
-        /* --- terms meta value set --- */
1636
+		/* --- terms meta value set --- */
1637 1637
 
1638
-        update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1638
+		update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1639 1639
 
1640
-        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1640
+		$options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1641 1641
 
1642
-        if (!empty($options_data)) {
1642
+		if (!empty($options_data)) {
1643 1643
 
1644
-            foreach ($options_data as $optobj) {
1644
+			foreach ($options_data as $optobj) {
1645 1645
 
1646
-                $option_val = str_replace('tax_meta_', '', $optobj->option_name);
1646
+				$option_val = str_replace('tax_meta_', '', $optobj->option_name);
1647 1647
 
1648
-                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1648
+				$taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1649 1649
 
1650
-                if (!empty($taxonomies_data)) {
1650
+				if (!empty($taxonomies_data)) {
1651 1651
 
1652
-                    foreach ($taxonomies_data as $taxobj) {
1652
+					foreach ($taxonomies_data as $taxobj) {
1653 1653
 
1654
-                        $taxObject = get_taxonomy($taxobj->taxonomy);
1655
-                        $post_type = $taxObject->object_type[0];
1654
+						$taxObject = get_taxonomy($taxobj->taxonomy);
1655
+						$post_type = $taxObject->object_type[0];
1656 1656
 
1657
-                        $opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1657
+						$opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1658 1658
 
1659
-                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1659
+						$duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1660 1660
 
1661
-                        if ($duplicate_data) {
1661
+						if ($duplicate_data) {
1662 1662
 
1663
-                            $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1663
+							$wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1664 1664
 
1665
-                        } else {
1665
+						} else {
1666 1666
 
1667
-                            $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1667
+							$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1668 1668
 
1669
-                        }
1669
+						}
1670 1670
 
1671
-                    }
1671
+					}
1672 1672
 
1673
-                }
1673
+				}
1674 1674
 
1675
-            }
1676
-        }
1675
+			}
1676
+		}
1677 1677
 
1678
-        update_option('geodir_changes_in_custom_fields_table', '1');
1678
+		update_option('geodir_changes_in_custom_fields_table', '1');
1679 1679
 
1680
-    }
1680
+	}
1681 1681
 
1682 1682
 }
1683 1683
 
@@ -1696,24 +1696,24 @@  discard block
 block discarded – undo
1696 1696
 function geodir_location_slug_check($slug)
1697 1697
 {
1698 1698
 
1699
-    global $wpdb, $table_prefix;
1699
+	global $wpdb, $table_prefix;
1700 1700
 
1701
-    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1701
+	$slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1702 1702
 
1703
-    if ($slug_exists) {
1703
+	if ($slug_exists) {
1704 1704
 
1705
-        $suffix = 1;
1706
-        do {
1707
-            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1708
-            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1709
-            $suffix++;
1710
-        } while ($location_slug_check && $suffix < 100);
1705
+		$suffix = 1;
1706
+		do {
1707
+			$alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1708
+			$location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1709
+			$suffix++;
1710
+		} while ($location_slug_check && $suffix < 100);
1711 1711
 
1712
-        $slug = $alt_location_name;
1712
+		$slug = $alt_location_name;
1713 1713
 
1714
-    }
1714
+	}
1715 1715
 
1716
-    return $slug;
1716
+	return $slug;
1717 1717
 
1718 1718
 }
1719 1719
 
@@ -1738,42 +1738,42 @@  discard block
 block discarded – undo
1738 1738
 function geodir_update_term_slug($term_id, $tt_id, $taxonomy)
1739 1739
 {
1740 1740
 
1741
-    global $wpdb, $plugin_prefix, $table_prefix;
1741
+	global $wpdb, $plugin_prefix, $table_prefix;
1742 1742
 
1743
-    $tern_data = get_term_by('id', $term_id, $taxonomy);
1743
+	$tern_data = get_term_by('id', $term_id, $taxonomy);
1744 1744
 
1745
-    $slug = $tern_data->slug;
1745
+	$slug = $tern_data->slug;
1746 1746
 
1747
-    /**
1748
-     * Filter if a term slug exists.
1749
-     *
1750
-     * @since 1.0.0
1751
-     * @package GeoDirectory
1752
-     * @param bool $bool Default: false.
1753
-     * @param string $slug The term slug.
1754
-     * @param int $term_id The term ID.
1755
-     */
1756
-    $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1747
+	/**
1748
+	 * Filter if a term slug exists.
1749
+	 *
1750
+	 * @since 1.0.0
1751
+	 * @package GeoDirectory
1752
+	 * @param bool $bool Default: false.
1753
+	 * @param string $slug The term slug.
1754
+	 * @param int $term_id The term ID.
1755
+	 */
1756
+	$slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1757 1757
 
1758
-    if ($slug_exists) {
1758
+	if ($slug_exists) {
1759 1759
 
1760
-        $suffix = 1;
1761
-        do {
1762
-            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1760
+		$suffix = 1;
1761
+		do {
1762
+			$new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1763 1763
 
1764
-            /** This action is documented in geodirectory_hooks_actions.php */
1765
-            $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1764
+			/** This action is documented in geodirectory_hooks_actions.php */
1765
+			$term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1766 1766
 
1767
-            $suffix++;
1768
-        } while ($term_slug_check && $suffix < 100);
1767
+			$suffix++;
1768
+		} while ($term_slug_check && $suffix < 100);
1769 1769
 
1770
-        $slug = $new_slug;
1770
+		$slug = $new_slug;
1771 1771
 
1772
-        //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1772
+		//wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1773 1773
 
1774
-        $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1774
+		$wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1775 1775
 
1776
-    }
1776
+	}
1777 1777
 	
1778 1778
 	// Update tag in detail table.
1779 1779
 	$taxonomy_obj = get_taxonomy($taxonomy);
@@ -1814,21 +1814,21 @@  discard block
 block discarded – undo
1814 1814
 function geodir_term_slug_is_exists($slug_exists, $slug, $term_id)
1815 1815
 {
1816 1816
 
1817
-    global $wpdb, $table_prefix;
1817
+	global $wpdb, $table_prefix;
1818 1818
 
1819
-    $default_location = geodir_get_default_location();
1819
+	$default_location = geodir_get_default_location();
1820 1820
 
1821
-    $country_slug = $default_location->country_slug;
1822
-    $region_slug = $default_location->region_slug;
1823
-    $city_slug = $default_location->city_slug;
1821
+	$country_slug = $default_location->country_slug;
1822
+	$region_slug = $default_location->region_slug;
1823
+	$city_slug = $default_location->city_slug;
1824 1824
 
1825
-    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1826
-        return $slug_exists = true;
1825
+	if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1826
+		return $slug_exists = true;
1827 1827
 
1828
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1829
-        return $slug_exists = true;
1828
+	if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1829
+		return $slug_exists = true;
1830 1830
 
1831
-    return $slug_exists;
1831
+	return $slug_exists;
1832 1832
 }
1833 1833
 
1834 1834
 
@@ -1848,75 +1848,75 @@  discard block
 block discarded – undo
1848 1848
  */
1849 1849
 function geodir_custom_page_title($title = '', $sep = '')
1850 1850
 {
1851
-    global $wp;
1852
-    if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1853
-        return $title;
1854
-    }
1851
+	global $wp;
1852
+	if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1853
+		return $title;
1854
+	}
1855 1855
 
1856
-    if ($sep == '') {
1857
-        /**
1858
-         * Filter the page title separator.
1859
-         *
1860
-         * @since 1.0.0
1861
-         * @package GeoDirectory
1862
-         * @param string $sep The separator, default: `|`.
1863
-         */
1864
-        $sep = apply_filters('geodir_page_title_separator', '|');
1865
-    }
1856
+	if ($sep == '') {
1857
+		/**
1858
+		 * Filter the page title separator.
1859
+		 *
1860
+		 * @since 1.0.0
1861
+		 * @package GeoDirectory
1862
+		 * @param string $sep The separator, default: `|`.
1863
+		 */
1864
+		$sep = apply_filters('geodir_page_title_separator', '|');
1865
+	}
1866 1866
 
1867 1867
 
1868
-    $gd_page = '';
1869
-    if(geodir_is_page('home')){
1870
-        $gd_page = 'home';
1871
-        $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1872
-    }
1873
-    elseif(geodir_is_page('detail')){
1874
-        $gd_page = 'detail';
1875
-        $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1876
-    }
1877
-    elseif(geodir_is_page('pt')){
1878
-        $gd_page = 'pt';
1879
-        $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1880
-    }
1881
-    elseif(geodir_is_page('listing')){
1882
-        $gd_page = 'listing';
1883
-        $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1884
-    }
1885
-    elseif(geodir_is_page('location')){
1886
-        $gd_page = 'location';
1887
-        $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1888
-    }
1889
-    elseif(geodir_is_page('search')){
1890
-        $gd_page = 'search';
1891
-        $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1892
-    }
1893
-    elseif(geodir_is_page('add-listing')){
1894
-        $gd_page = 'add-listing';
1895
-        $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1896
-    }
1897
-    elseif(geodir_is_page('author')){
1898
-        $gd_page = 'author';
1899
-        $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1900
-    }
1901
-    elseif(geodir_is_page('login')){
1902
-        $gd_page = 'login';
1903
-        $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1904
-    }
1905
-    elseif(geodir_is_page('listing-success')){
1906
-        $gd_page = 'listing-success';
1907
-        $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1908
-    }
1868
+	$gd_page = '';
1869
+	if(geodir_is_page('home')){
1870
+		$gd_page = 'home';
1871
+		$title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1872
+	}
1873
+	elseif(geodir_is_page('detail')){
1874
+		$gd_page = 'detail';
1875
+		$title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1876
+	}
1877
+	elseif(geodir_is_page('pt')){
1878
+		$gd_page = 'pt';
1879
+		$title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1880
+	}
1881
+	elseif(geodir_is_page('listing')){
1882
+		$gd_page = 'listing';
1883
+		$title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1884
+	}
1885
+	elseif(geodir_is_page('location')){
1886
+		$gd_page = 'location';
1887
+		$title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1888
+	}
1889
+	elseif(geodir_is_page('search')){
1890
+		$gd_page = 'search';
1891
+		$title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1892
+	}
1893
+	elseif(geodir_is_page('add-listing')){
1894
+		$gd_page = 'add-listing';
1895
+		$title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1896
+	}
1897
+	elseif(geodir_is_page('author')){
1898
+		$gd_page = 'author';
1899
+		$title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1900
+	}
1901
+	elseif(geodir_is_page('login')){
1902
+		$gd_page = 'login';
1903
+		$title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1904
+	}
1905
+	elseif(geodir_is_page('listing-success')){
1906
+		$gd_page = 'listing-success';
1907
+		$title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1908
+	}
1909 1909
 
1910 1910
 
1911
-    /**
1912
-     * Filter page meta title to replace variables.
1913
-     *
1914
-     * @since 1.5.4
1915
-     * @param string $title The page title including variables.
1916
-     * @param string $gd_page The GeoDirectory page type if any.
1917
-     * @param string $sep The title separator symbol.
1918
-     */
1919
-    return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1911
+	/**
1912
+	 * Filter page meta title to replace variables.
1913
+	 *
1914
+	 * @since 1.5.4
1915
+	 * @param string $title The page title including variables.
1916
+	 * @param string $gd_page The GeoDirectory page type if any.
1917
+	 * @param string $sep The title separator symbol.
1918
+	 */
1919
+	return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1920 1920
 
1921 1921
 }
1922 1922
 
@@ -1932,36 +1932,36 @@  discard block
 block discarded – undo
1932 1932
 function geodir_set_post_attachment()
1933 1933
 {
1934 1934
 
1935
-    if (!get_option('geodir_set_post_attachments')) {
1935
+	if (!get_option('geodir_set_post_attachments')) {
1936 1936
 
1937
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1938
-        require_once(ABSPATH . 'wp-admin/includes/file.php');
1937
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1938
+		require_once(ABSPATH . 'wp-admin/includes/file.php');
1939 1939
 
1940
-        $all_postypes = geodir_get_posttypes();
1940
+		$all_postypes = geodir_get_posttypes();
1941 1941
 
1942
-        foreach($all_postypes as $post_type){
1943
-            $args = array(
1944
-                'posts_per_page' => -1,
1945
-                'post_type' => $post_type,
1946
-                'post_status' => 'publish');
1942
+		foreach($all_postypes as $post_type){
1943
+			$args = array(
1944
+				'posts_per_page' => -1,
1945
+				'post_type' => $post_type,
1946
+				'post_status' => 'publish');
1947 1947
 
1948
-            $posts_array = get_posts($args);
1948
+			$posts_array = get_posts($args);
1949 1949
 
1950
-            if (!empty($posts_array)) {
1950
+			if (!empty($posts_array)) {
1951 1951
 
1952
-                foreach ($posts_array as $post) {
1952
+				foreach ($posts_array as $post) {
1953 1953
 
1954
-                    geodir_set_wp_featured_image($post->ID);
1954
+					geodir_set_wp_featured_image($post->ID);
1955 1955
 
1956
-                }
1956
+				}
1957 1957
 
1958
-            }
1959
-        }
1958
+			}
1959
+		}
1960 1960
 
1961 1961
 
1962
-        update_option('geodir_set_post_attachments', '1');
1962
+		update_option('geodir_set_post_attachments', '1');
1963 1963
 
1964
-    }
1964
+	}
1965 1965
 
1966 1966
 }
1967 1967
 
@@ -1978,19 +1978,19 @@  discard block
 block discarded – undo
1978 1978
 function geodir_remove_url_seperator()
1979 1979
 {
1980 1980
 
1981
-    if (!get_option('geodir_remove_url_seperator')) {
1981
+	if (!get_option('geodir_remove_url_seperator')) {
1982 1982
 
1983
-        if (get_option('geodir_listingurl_separator'))
1984
-            delete_option('geodir_listingurl_separator');
1983
+		if (get_option('geodir_listingurl_separator'))
1984
+			delete_option('geodir_listingurl_separator');
1985 1985
 
1986
-        if (get_option('geodir_detailurl_separator'))
1987
-            delete_option('geodir_detailurl_separator');
1986
+		if (get_option('geodir_detailurl_separator'))
1987
+			delete_option('geodir_detailurl_separator');
1988 1988
 
1989
-        flush_rewrite_rules(false);
1989
+		flush_rewrite_rules(false);
1990 1990
 
1991
-        update_option('geodir_remove_url_seperator', '1');
1991
+		update_option('geodir_remove_url_seperator', '1');
1992 1992
 
1993
-    }
1993
+	}
1994 1994
 
1995 1995
 }
1996 1996
 
@@ -2006,19 +2006,19 @@  discard block
 block discarded – undo
2006 2006
  */
2007 2007
 function geodir_remove_url_seperator_form_permalink_settings($permalink_arr)
2008 2008
 {
2009
-    foreach ($permalink_arr as $key => $value) {
2009
+	foreach ($permalink_arr as $key => $value) {
2010 2010
 
2011
-        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2012
-            unset($permalink_arr[$key]);
2011
+		if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2012
+			unset($permalink_arr[$key]);
2013 2013
 
2014
-    }
2014
+	}
2015 2015
 
2016
-    return $permalink_arr;
2016
+	return $permalink_arr;
2017 2017
 
2018 2018
 }
2019 2019
 
2020 2020
 if (!is_admin()) {
2021
-    add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2021
+	add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2022 2022
 }
2023 2023
 /**
2024 2024
  * Set status from draft to publish.
@@ -2031,16 +2031,16 @@  discard block
 block discarded – undo
2031 2031
  */
2032 2032
 function geodir_set_status_draft_to_publish_for_own_post($post)
2033 2033
 {
2034
-    $user_id = get_current_user_id();
2034
+	$user_id = get_current_user_id();
2035 2035
 
2036
-    if(!$user_id){return $post;}
2036
+	if(!$user_id){return $post;}
2037 2037
 
2038
-    $gd_post_types = geodir_get_posttypes();
2038
+	$gd_post_types = geodir_get_posttypes();
2039 2039
 
2040
-    if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2041
-        $post[0]->post_status = 'publish';
2042
-    }
2043
-    return $post;
2040
+	if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2041
+		$post[0]->post_status = 'publish';
2042
+	}
2043
+	return $post;
2044 2044
 }
2045 2045
 
2046 2046
 
@@ -2132,33 +2132,33 @@  discard block
 block discarded – undo
2132 2132
  */
2133 2133
 function geodir_detail_page_tab_headings_change($tabs_arr)
2134 2134
 {
2135
-    global $wpdb;
2135
+	global $wpdb;
2136 2136
 
2137
-    $post_type = geodir_get_current_posttype();
2137
+	$post_type = geodir_get_current_posttype();
2138 2138
 
2139
-    $all_postypes = geodir_get_posttypes();
2139
+	$all_postypes = geodir_get_posttypes();
2140 2140
 
2141
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2141
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2142 2142
 
2143
-        if (array_key_exists('post_video', $tabs_arr)) {
2143
+		if (array_key_exists('post_video', $tabs_arr)) {
2144 2144
 
2145
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2145
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2146 2146
 
2147
-            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2148
-                $tabs_arr['post_video']['heading_text'] = $field_title;
2149
-        }
2147
+			if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2148
+				$tabs_arr['post_video']['heading_text'] = $field_title;
2149
+		}
2150 2150
 
2151
-        if (array_key_exists('special_offers', $tabs_arr)) {
2151
+		if (array_key_exists('special_offers', $tabs_arr)) {
2152 2152
 
2153
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2153
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2154 2154
 
2155
-            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2156
-                $tabs_arr['special_offers']['heading_text'] = $field_title;
2157
-        }
2155
+			if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2156
+				$tabs_arr['special_offers']['heading_text'] = $field_title;
2157
+		}
2158 2158
 
2159
-    }
2159
+	}
2160 2160
 
2161
-    return $tabs_arr;
2161
+	return $tabs_arr;
2162 2162
 
2163 2163
 }
2164 2164
 
@@ -2171,10 +2171,10 @@  discard block
 block discarded – undo
2171 2171
  */
2172 2172
 function geodir_remove_template_redirect_actions()
2173 2173
 {
2174
-    if (geodir_is_page('login')){
2175
-        remove_all_actions('template_redirect');
2176
-        remove_action('init', 'avia_modify_front', 10);
2177
-    }
2174
+	if (geodir_is_page('login')){
2175
+		remove_all_actions('template_redirect');
2176
+		remove_action('init', 'avia_modify_front', 10);
2177
+	}
2178 2178
 }
2179 2179
 
2180 2180
 
@@ -2196,51 +2196,51 @@  discard block
 block discarded – undo
2196 2196
 function geodirectory_before_featured_image_delete($attachment_id)
2197 2197
 {
2198 2198
 
2199
-    global $wpdb, $plugin_prefix;
2199
+	global $wpdb, $plugin_prefix;
2200 2200
 
2201
-    $post_id = get_post_field('post_parent', $attachment_id);
2201
+	$post_id = get_post_field('post_parent', $attachment_id);
2202 2202
 
2203
-    $attachment_url = wp_get_attachment_url($attachment_id);
2203
+	$attachment_url = wp_get_attachment_url($attachment_id);
2204 2204
 
2205
-    if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2205
+	if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2206 2206
 
2207
-        $post_type = get_post_type($post_id);
2207
+		$post_type = get_post_type($post_id);
2208 2208
 
2209
-        $all_postypes = geodir_get_posttypes();
2209
+		$all_postypes = geodir_get_posttypes();
2210 2210
 
2211
-        if (!in_array($post_type, $all_postypes) || !is_admin())
2212
-            return false;
2211
+		if (!in_array($post_type, $all_postypes) || !is_admin())
2212
+			return false;
2213 2213
 
2214
-        $uploads = wp_upload_dir();
2214
+		$uploads = wp_upload_dir();
2215 2215
 
2216
-        $split_img_path = explode($uploads['baseurl'], $attachment_url);
2216
+		$split_img_path = explode($uploads['baseurl'], $attachment_url);
2217 2217
 
2218
-        $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2218
+		$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2219 2219
 
2220
-        $wpdb->query(
2221
-            $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2222
-                array($post_id, $split_img_file_path)
2223
-            )
2224
-        );
2220
+		$wpdb->query(
2221
+			$wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2222
+				array($post_id, $split_img_file_path)
2223
+			)
2224
+		);
2225 2225
 
2226
-        $attachment_data = $wpdb->get_row(
2227
-            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2228
-                array($post_id)
2229
-            )
2230
-        );
2226
+		$attachment_data = $wpdb->get_row(
2227
+			$wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2228
+				array($post_id)
2229
+			)
2230
+		);
2231 2231
 
2232
-        if (!empty($attachment_data)) {
2233
-            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2234
-        }
2232
+		if (!empty($attachment_data)) {
2233
+			$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2234
+		}
2235 2235
 
2236 2236
 
2237
-        $table_name = $plugin_prefix . $post_type . '_detail';
2237
+		$table_name = $plugin_prefix . $post_type . '_detail';
2238 2238
 
2239
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2239
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2240 2240
 
2241
-        geodir_set_wp_featured_image($post_id);
2241
+		geodir_set_wp_featured_image($post_id);
2242 2242
 
2243
-    }
2243
+	}
2244 2244
 
2245 2245
 }
2246 2246
 
@@ -2258,79 +2258,79 @@  discard block
 block discarded – undo
2258 2258
 function geodir_temp_set_post_attachment()
2259 2259
 {
2260 2260
 
2261
-    global $wpdb, $plugin_prefix;
2261
+	global $wpdb, $plugin_prefix;
2262 2262
 
2263
-    $all_postypes = geodir_get_posttypes();
2263
+	$all_postypes = geodir_get_posttypes();
2264 2264
 
2265
-    foreach ($all_postypes as $posttype) {
2265
+	foreach ($all_postypes as $posttype) {
2266 2266
 
2267
-        $tablename = $plugin_prefix . $posttype . '_detail';
2267
+		$tablename = $plugin_prefix . $posttype . '_detail';
2268 2268
 
2269
-        $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2269
+		$get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2270 2270
 
2271
-        if (!empty($get_post_data)) {
2271
+		if (!empty($get_post_data)) {
2272 2272
 
2273
-            foreach ($get_post_data as $data) {
2273
+			foreach ($get_post_data as $data) {
2274 2274
 
2275
-                $post_id = $data->post_id;
2275
+				$post_id = $data->post_id;
2276 2276
 
2277
-                $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2277
+				$attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2278 2278
 
2279
-                if (!empty($attachment_data)) {
2279
+				if (!empty($attachment_data)) {
2280 2280
 
2281
-                    foreach ($attachment_data as $attach) {
2281
+					foreach ($attachment_data as $attach) {
2282 2282
 
2283
-                        $file_info = pathinfo($attach->file);
2283
+						$file_info = pathinfo($attach->file);
2284 2284
 
2285
-                        $sub_dir = '';
2286
-                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2287
-                            $sub_dir = stripslashes_deep($file_info['dirname']);
2285
+						$sub_dir = '';
2286
+						if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2287
+							$sub_dir = stripslashes_deep($file_info['dirname']);
2288 2288
 
2289
-                        $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2290
-                        $uploads_path = $uploads['basedir'];
2289
+						$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2290
+						$uploads_path = $uploads['basedir'];
2291 2291
 
2292
-                        $file_name = $file_info['basename'];
2292
+						$file_name = $file_info['basename'];
2293 2293
 
2294
-                        $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2294
+						$img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2295 2295
 
2296
-                        if (!file_exists($img_arr['path'])) {
2296
+						if (!file_exists($img_arr['path'])) {
2297 2297
 
2298
-                            $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2298
+							$wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2299 2299
 
2300
-                        }
2300
+						}
2301 2301
 
2302
-                    }
2302
+					}
2303 2303
 
2304
-                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2304
+					$attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2305 2305
 
2306
-                    if (!empty($attachment_data)) {
2306
+					if (!empty($attachment_data)) {
2307 2307
 
2308
-                        if ($attachment_data->ID)
2309
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2308
+						if ($attachment_data->ID)
2309
+							$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2310 2310
 
2311
-                    } else {
2311
+					} else {
2312 2312
 
2313
-                        if (has_post_thumbnail($post_id)) {
2313
+						if (has_post_thumbnail($post_id)) {
2314 2314
 
2315
-                            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2315
+							$post_thumbnail_id = get_post_thumbnail_id($post_id);
2316 2316
 
2317
-                            wp_delete_attachment($post_thumbnail_id);
2317
+							wp_delete_attachment($post_thumbnail_id);
2318 2318
 
2319
-                        }
2319
+						}
2320 2320
 
2321
-                    }
2321
+					}
2322 2322
 
2323
-                    $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2323
+					$wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2324 2324
 
2325
-                    geodir_set_wp_featured_image($post_id);
2325
+					geodir_set_wp_featured_image($post_id);
2326 2326
 
2327
-                }
2327
+				}
2328 2328
 
2329
-            }
2329
+			}
2330 2330
 
2331
-        }
2331
+		}
2332 2332
 
2333
-    }
2333
+	}
2334 2334
 
2335 2335
 }
2336 2336
 
@@ -2348,9 +2348,9 @@  discard block
 block discarded – undo
2348 2348
 function geodir_default_rating_star_icon()
2349 2349
 {
2350 2350
 
2351
-    if (!get_option('geodir_default_rating_star_icon')) {
2352
-        update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2353
-    }
2351
+	if (!get_option('geodir_default_rating_star_icon')) {
2352
+		update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2353
+	}
2354 2354
 
2355 2355
 }
2356 2356
 
@@ -2368,25 +2368,25 @@  discard block
 block discarded – undo
2368 2368
  */
2369 2369
 function geodir_user_post_listing_count($user_id = 0)
2370 2370
 {
2371
-    global $wpdb, $plugin_prefix, $current_user;
2372
-    if(!$user_id){
2373
-        $user_id = $current_user->ID;
2374
-    }
2371
+	global $wpdb, $plugin_prefix, $current_user;
2372
+	if(!$user_id){
2373
+		$user_id = $current_user->ID;
2374
+	}
2375 2375
 
2376
-    $all_posts = get_option('geodir_listing_link_user_dashboard');
2376
+	$all_posts = get_option('geodir_listing_link_user_dashboard');
2377 2377
 
2378
-    $user_listing = array();
2379
-    if ($user_id && is_array($all_posts) && !empty($all_posts)) {
2380
-        foreach ($all_posts as $ptype) {
2381
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )");
2378
+	$user_listing = array();
2379
+	if ($user_id && is_array($all_posts) && !empty($all_posts)) {
2380
+		foreach ($all_posts as $ptype) {
2381
+			$total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )");
2382 2382
 
2383
-            if ($total_posts > 0) {
2384
-                $user_listing[$ptype] = $total_posts;
2385
-            }
2386
-        }
2387
-    }
2383
+			if ($total_posts > 0) {
2384
+				$user_listing[$ptype] = $total_posts;
2385
+			}
2386
+		}
2387
+	}
2388 2388
 
2389
-    return $user_listing;
2389
+	return $user_listing;
2390 2390
 }
2391 2391
 
2392 2392
 
@@ -2406,189 +2406,189 @@  discard block
 block discarded – undo
2406 2406
  */
2407 2407
 function geodir_detail_page_custom_field_tab($tabs_arr)
2408 2408
 {
2409
-    global $post;
2410
-
2411
-    $post_type = geodir_get_current_posttype();
2412
-    $all_postypes = geodir_get_posttypes();
2413
-
2414
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2415
-        $package_info = array();
2416
-        $package_info = geodir_post_package_info($package_info, $post);
2417
-        $post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
2418
-        $fields_location = 'owntab';
2419
-
2420
-        $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2421
-        //remove video and special offers if it is already set to show
2422
-        if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2423
-            $unset_video = true;
2424
-        }
2425
-
2426
-        if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2427
-            $unset_special_offers = true;
2428
-        }
2429
-        if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2430
-            foreach($custom_fields as $key => $custom_field){
2431
-                if($custom_field['name']=='geodir_video' && isset($unset_video)){
2432
-                    unset($custom_fields[$key]);
2433
-                }
2434
-                if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2435
-                    unset($custom_fields[$key]);
2436
-                }
2437
-            }
2438
-        }
2439
-
2440
-
2441
-        if (!empty($custom_fields)) {
2442
-            $parse_custom_fields = array();
2443
-            foreach ($custom_fields as $field) {
2444
-                $field = stripslashes_deep($field); // strip slashes
2445
-                $type = $field;
2446
-                $field_name = $field['htmlvar_name'];
2447
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2448
-                    $post->{$field_name} = $_REQUEST[$field_name];
2449
-                }
2409
+	global $post;
2450 2410
 
2451
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2452
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2453
-                        continue;
2454
-                    }
2411
+	$post_type = geodir_get_current_posttype();
2412
+	$all_postypes = geodir_get_posttypes();
2455 2413
 
2456
-                    $parse_custom_fields[] = $field;
2457
-                }
2458
-            }
2459
-            $custom_fields = $parse_custom_fields;
2460
-        }
2461
-        //print_r($custom_fields);
2462
-        if (!empty($custom_fields)) {
2414
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2415
+		$package_info = array();
2416
+		$package_info = geodir_post_package_info($package_info, $post);
2417
+		$post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
2418
+		$fields_location = 'owntab';
2463 2419
 
2464
-            global $field_set_start;
2420
+		$custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2421
+		//remove video and special offers if it is already set to show
2422
+		if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2423
+			$unset_video = true;
2424
+		}
2465 2425
 
2466
-            $post = stripslashes_deep($post); // strip slashes
2467
-            
2468
-            $field_set_start = 0;
2469
-            $fieldset_count = 0;
2470
-            $fieldset = '';
2471
-            $total_fields = count($custom_fields);
2472
-            $count_field = 0;
2473
-            $fieldset_arr = array();
2474
-            $i = 0;
2475
-            $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2476
-
2477
-            foreach ($custom_fields as $field) {
2478
-                $count_field++;
2479
-                $field_name = $field['htmlvar_name'];
2480
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2481
-                    $post->{$field_name} = $_REQUEST[$field_name];
2482
-                }
2426
+		if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2427
+			$unset_special_offers = true;
2428
+		}
2429
+		if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2430
+			foreach($custom_fields as $key => $custom_field){
2431
+				if($custom_field['name']=='geodir_video' && isset($unset_video)){
2432
+					unset($custom_fields[$key]);
2433
+				}
2434
+				if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2435
+					unset($custom_fields[$key]);
2436
+				}
2437
+			}
2438
+		}
2483 2439
 
2484
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2485
-                    $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2486
-                    $site_title = trim($field['site_title']);
2487
-                    $type = $field;
2488
-                    $variables_array = array();
2489 2440
 
2490
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2491
-                        continue;
2492
-                    }
2441
+		if (!empty($custom_fields)) {
2442
+			$parse_custom_fields = array();
2443
+			foreach ($custom_fields as $field) {
2444
+				$field = stripslashes_deep($field); // strip slashes
2445
+				$type = $field;
2446
+				$field_name = $field['htmlvar_name'];
2447
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2448
+					$post->{$field_name} = $_REQUEST[$field_name];
2449
+				}
2493 2450
 
2494
-                    if ($type['type'] != 'fieldset') {
2495
-                        $i++;
2496
-                        $variables_array['post_id'] = $post->ID;
2497
-                        $variables_array['label'] = __($type['site_title'], 'geodirectory');
2498
-                        $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2499
-
2500
-                    }else{
2501
-                        $i = 0;
2502
-                        $fieldset_count++;
2503
-                        $field_set_start = 1;
2504
-                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2505
-                        $fieldset_arr[$fieldset_count]['label'] = $label;
2506
-                    }
2451
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2452
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2453
+						continue;
2454
+					}
2507 2455
 
2456
+					$parse_custom_fields[] = $field;
2457
+				}
2458
+			}
2459
+			$custom_fields = $parse_custom_fields;
2460
+		}
2461
+		//print_r($custom_fields);
2462
+		if (!empty($custom_fields)) {
2508 2463
 
2509
-                    if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2510
-                    $type = stripslashes_deep($type); // strip slashes
2511
-                    if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2512
-                    $html = '';
2513
-                    $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2514
-                    if($html_var=='post'){$html_var='post_address';}
2515
-                    $field_icon = geodir_field_icon_proccess($type);
2516
-                    $filed_type = $type['type'];
2517
-
2518
-                    /**
2519
-                     * Filter the output for custom fields.
2520
-                     *
2521
-                     * Here we can remove or add new functions depending on the field type.
2522
-                     *
2523
-                     * @param string $html The html to be filtered (blank).
2524
-                     * @param string $fields_location The location the field is to be show.
2525
-                     * @param array $type The array of field values.
2526
-                     */
2527
-                    $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2528
-
2529
-
2530
-                    /**
2531
-                     * Filter custom field output in tab.
2532
-                     *
2533
-                     * @since 1.5.6
2534
-                     *
2535
-                     * @param string $html_var The HTML variable name for the field.
2536
-                     * @param string $html Custom field unfiltered HTML.
2537
-                     * @param array $variables_array Custom field variables array.
2538
-                     */
2539
-                    $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2540
-
2541
-                    $fieldset_html = '';
2542
-                    if ($field_set_start == 1) {
2543
-                        $add_html = false;
2544
-                        if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2545
-                            if ($fieldset != '') {
2546
-                                $add_html = true;
2547
-                                $label = $fieldset_arr[$fieldset_count - 1]['label'];
2548
-                                $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2549
-                            }
2550
-                            $fieldset_html = $fieldset;
2551
-                            $fieldset = '';
2552
-                        } else {
2553
-                            $fieldset .= $html;
2554
-                            if ($total_fields == $count_field && $fieldset != '') {
2555
-                                $add_html = true;
2556
-                                $label = $fieldset_arr[$fieldset_count]['label'];
2557
-                                $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2558
-                                $fieldset_html = $fieldset;
2559
-                            }
2560
-                        }
2464
+			global $field_set_start;
2561 2465
 
2562
-                        if ($add_html) {
2563
-                            $tabs_arr[$htmlvar_name] = array(
2564
-                                'heading_text' => __($label, 'geodirectory'),
2565
-                                'is_active_tab' => false,
2566
-                                /**
2567
-                                 * Filter if a custom field should be displayed on the details page tab.
2568
-                                 *
2569
-                                 * @since 1.0.0
2570
-                                 * @param string $htmlvar_name The field HTML var name.
2571
-                                 */
2572
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2573
-                                'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2574
-                            );
2575
-                        }
2576
-                    } else {
2577
-                        if ($html != '') {
2578
-                            $tabs_arr[$html_var] = array(
2579
-                                'heading_text' => __($label, 'geodirectory'),
2580
-                                'is_active_tab' => false,
2581
-                                /** This action is documented in geodirectory_hooks_actions.php */
2582
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2583
-                                'tab_content' => $html
2584
-                            );
2585
-                        }
2586
-                    }
2587
-                }
2588
-            }
2589
-        }
2590
-    }
2591
-    return $tabs_arr;
2466
+			$post = stripslashes_deep($post); // strip slashes
2467
+            
2468
+			$field_set_start = 0;
2469
+			$fieldset_count = 0;
2470
+			$fieldset = '';
2471
+			$total_fields = count($custom_fields);
2472
+			$count_field = 0;
2473
+			$fieldset_arr = array();
2474
+			$i = 0;
2475
+			$geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2476
+
2477
+			foreach ($custom_fields as $field) {
2478
+				$count_field++;
2479
+				$field_name = $field['htmlvar_name'];
2480
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2481
+					$post->{$field_name} = $_REQUEST[$field_name];
2482
+				}
2483
+
2484
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2485
+					$label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2486
+					$site_title = trim($field['site_title']);
2487
+					$type = $field;
2488
+					$variables_array = array();
2489
+
2490
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2491
+						continue;
2492
+					}
2493
+
2494
+					if ($type['type'] != 'fieldset') {
2495
+						$i++;
2496
+						$variables_array['post_id'] = $post->ID;
2497
+						$variables_array['label'] = __($type['site_title'], 'geodirectory');
2498
+						$variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2499
+
2500
+					}else{
2501
+						$i = 0;
2502
+						$fieldset_count++;
2503
+						$field_set_start = 1;
2504
+						$fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2505
+						$fieldset_arr[$fieldset_count]['label'] = $label;
2506
+					}
2507
+
2508
+
2509
+					if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2510
+					$type = stripslashes_deep($type); // strip slashes
2511
+					if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2512
+					$html = '';
2513
+					$html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2514
+					if($html_var=='post'){$html_var='post_address';}
2515
+					$field_icon = geodir_field_icon_proccess($type);
2516
+					$filed_type = $type['type'];
2517
+
2518
+					/**
2519
+					 * Filter the output for custom fields.
2520
+					 *
2521
+					 * Here we can remove or add new functions depending on the field type.
2522
+					 *
2523
+					 * @param string $html The html to be filtered (blank).
2524
+					 * @param string $fields_location The location the field is to be show.
2525
+					 * @param array $type The array of field values.
2526
+					 */
2527
+					$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2528
+
2529
+
2530
+					/**
2531
+					 * Filter custom field output in tab.
2532
+					 *
2533
+					 * @since 1.5.6
2534
+					 *
2535
+					 * @param string $html_var The HTML variable name for the field.
2536
+					 * @param string $html Custom field unfiltered HTML.
2537
+					 * @param array $variables_array Custom field variables array.
2538
+					 */
2539
+					$html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2540
+
2541
+					$fieldset_html = '';
2542
+					if ($field_set_start == 1) {
2543
+						$add_html = false;
2544
+						if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2545
+							if ($fieldset != '') {
2546
+								$add_html = true;
2547
+								$label = $fieldset_arr[$fieldset_count - 1]['label'];
2548
+								$htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2549
+							}
2550
+							$fieldset_html = $fieldset;
2551
+							$fieldset = '';
2552
+						} else {
2553
+							$fieldset .= $html;
2554
+							if ($total_fields == $count_field && $fieldset != '') {
2555
+								$add_html = true;
2556
+								$label = $fieldset_arr[$fieldset_count]['label'];
2557
+								$htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2558
+								$fieldset_html = $fieldset;
2559
+							}
2560
+						}
2561
+
2562
+						if ($add_html) {
2563
+							$tabs_arr[$htmlvar_name] = array(
2564
+								'heading_text' => __($label, 'geodirectory'),
2565
+								'is_active_tab' => false,
2566
+								/**
2567
+								 * Filter if a custom field should be displayed on the details page tab.
2568
+								 *
2569
+								 * @since 1.0.0
2570
+								 * @param string $htmlvar_name The field HTML var name.
2571
+								 */
2572
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2573
+								'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2574
+							);
2575
+						}
2576
+					} else {
2577
+						if ($html != '') {
2578
+							$tabs_arr[$html_var] = array(
2579
+								'heading_text' => __($label, 'geodirectory'),
2580
+								'is_active_tab' => false,
2581
+								/** This action is documented in geodirectory_hooks_actions.php */
2582
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2583
+								'tab_content' => $html
2584
+							);
2585
+						}
2586
+					}
2587
+				}
2588
+			}
2589
+		}
2590
+	}
2591
+	return $tabs_arr;
2592 2592
 }
2593 2593
 
2594 2594
 /* display add listing page for wpml */
@@ -2612,41 +2612,41 @@  discard block
 block discarded – undo
2612 2612
  */
2613 2613
 function geodir_add_post_status_author_page()
2614 2614
 {
2615
-    global $wpdb, $post;
2616
-
2617
-    $html = '';
2618
-    if (get_current_user_id()) {
2619
-
2620
-        $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
2621
-        if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2622
-
2623
-            // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2624
-            $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2625
-            $status = "<strong>(";
2626
-            $status_icon = '<i class="fas fa-play"></i>';
2627
-            if ($real_status == 'publish') {
2628
-                $status .= __('Published', 'geodirectory');
2629
-            }elseif ($real_status == 'pending') {
2630
-                $status .= __('Awaiting Review', 'geodirectory');
2631
-            } else {
2632
-                $status .= __('Not published', 'geodirectory');
2633
-                $status_icon = '<i class="fas fa-pause"></i>';
2634
-            }
2635
-            $status .= ")</strong>";
2615
+	global $wpdb, $post;
2616
+
2617
+	$html = '';
2618
+	if (get_current_user_id()) {
2619
+
2620
+		$is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
2621
+		if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2622
+
2623
+			// we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2624
+			$real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2625
+			$status = "<strong>(";
2626
+			$status_icon = '<i class="fas fa-play"></i>';
2627
+			if ($real_status == 'publish') {
2628
+				$status .= __('Published', 'geodirectory');
2629
+			}elseif ($real_status == 'pending') {
2630
+				$status .= __('Awaiting Review', 'geodirectory');
2631
+			} else {
2632
+				$status .= __('Not published', 'geodirectory');
2633
+				$status_icon = '<i class="fas fa-pause"></i>';
2634
+			}
2635
+			$status .= ")</strong>";
2636 2636
 
2637
-            $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2638
-        }
2639
-    }
2637
+			$html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2638
+		}
2639
+	}
2640 2640
 
2641
-    if ($html != '') {
2642
-        /**
2643
-         * Filter the post status text on the author page.
2644
-         *
2645
-         * @since 1.0.0
2646
-         * @param string $html The HTML of the status.
2647
-         */
2648
-        echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2649
-    }
2641
+	if ($html != '') {
2642
+		/**
2643
+		 * Filter the post status text on the author page.
2644
+		 *
2645
+		 * @since 1.0.0
2646
+		 * @param string $html The HTML of the status.
2647
+		 */
2648
+		echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2649
+	}
2650 2650
 
2651 2651
 
2652 2652
 }
@@ -2660,9 +2660,9 @@  discard block
 block discarded – undo
2660 2660
  * @package GeoDirectory
2661 2661
  */
2662 2662
 function geodir_init_no_rating() {
2663
-    if (geodir_rating_disabled_post_types()) {
2664
-        add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2665
-    }
2663
+	if (geodir_rating_disabled_post_types()) {
2664
+		add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2665
+	}
2666 2666
 }
2667 2667
 
2668 2668
 /**
@@ -2676,22 +2676,22 @@  discard block
 block discarded – undo
2676 2676
  * @return array Modified sort options array.
2677 2677
  */
2678 2678
 function geodir_no_rating_get_sort_options($options, $post_type = '') {
2679
-    if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) {
2680
-        $new_options = array();
2679
+	if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) {
2680
+		$new_options = array();
2681 2681
         
2682
-        if (!empty($options)) {
2683
-            foreach ($options as $option) {
2684
-                if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2685
-                    continue;
2686
-                }
2687
-                $new_options[] = $option;
2688
-            }
2682
+		if (!empty($options)) {
2683
+			foreach ($options as $option) {
2684
+				if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2685
+					continue;
2686
+				}
2687
+				$new_options[] = $option;
2688
+			}
2689 2689
 
2690
-            $options = $new_options;
2691
-        }
2692
-    }
2690
+			$options = $new_options;
2691
+		}
2692
+	}
2693 2693
 
2694
-    return $options;
2694
+	return $options;
2695 2695
 }
2696 2696
 
2697 2697
 /**
@@ -2703,9 +2703,9 @@  discard block
 block discarded – undo
2703 2703
  * @return array Modified class array.
2704 2704
  */
2705 2705
 function geodir_body_class_active_map($classes = array()) {
2706
-    $classes[] = 'gd-map-' . geodir_map_name();
2706
+	$classes[] = 'gd-map-' . geodir_map_name();
2707 2707
 
2708
-    return $classes;
2708
+	return $classes;
2709 2709
 }
2710 2710
 add_filter('body_class', 'geodir_body_class_active_map', 100);
2711 2711
 
@@ -2718,9 +2718,9 @@  discard block
 block discarded – undo
2718 2718
  * @return string Modified class string.
2719 2719
  */
2720 2720
 function geodir_admin_body_class_active_map($class = '') {    
2721
-    $class .= ' gd-map-' . geodir_map_name();
2721
+	$class .= ' gd-map-' . geodir_map_name();
2722 2722
 
2723
-    return $class;
2723
+	return $class;
2724 2724
 }
2725 2725
 add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100);
2726 2726
 
@@ -2738,36 +2738,36 @@  discard block
 block discarded – undo
2738 2738
  * @return array Translation texts.
2739 2739
  */
2740 2740
 function geodir_load_gd_options_text_translation($translation_texts = array()) {
2741
-    $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2742
-
2743
-    $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2744
-
2745
-    /**
2746
-     * Filters the geodirectory option names that requires to add for translation.
2747
-     *
2748
-     * @since 1.5.7
2749
-     * @package GeoDirectory
2750
-     *
2751
-     * @param  array $gd_options Array of option names.
2752
-     */
2753
-    $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2754
-    $gd_options = array_unique($gd_options);
2755
-
2756
-    if (!empty($gd_options)) {
2757
-        foreach ($gd_options as $gd_option) {
2758
-            if ($gd_option != '' && $option_value = get_option($gd_option)) {
2759
-                $option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2741
+	$translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2742
+
2743
+	$gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2744
+
2745
+	/**
2746
+	 * Filters the geodirectory option names that requires to add for translation.
2747
+	 *
2748
+	 * @since 1.5.7
2749
+	 * @package GeoDirectory
2750
+	 *
2751
+	 * @param  array $gd_options Array of option names.
2752
+	 */
2753
+	$gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2754
+	$gd_options = array_unique($gd_options);
2755
+
2756
+	if (!empty($gd_options)) {
2757
+		foreach ($gd_options as $gd_option) {
2758
+			if ($gd_option != '' && $option_value = get_option($gd_option)) {
2759
+				$option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2760 2760
                 
2761
-                if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2762
-                    $translation_texts[] = stripslashes_deep($option_value);
2763
-                }
2764
-            }
2765
-        }
2766
-    }
2761
+				if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2762
+					$translation_texts[] = stripslashes_deep($option_value);
2763
+				}
2764
+			}
2765
+		}
2766
+	}
2767 2767
 
2768
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2768
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2769 2769
 
2770
-    return $translation_texts;
2770
+	return $translation_texts;
2771 2771
 }
2772 2772
 
2773 2773
 add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation');
@@ -2781,15 +2781,15 @@  discard block
 block discarded – undo
2781 2781
 
2782 2782
 add_filter('get_comments_link', 'gd_get_comments_link', 10, 2);
2783 2783
 function gd_get_comments_link($comments_link, $post_id) {
2784
-    $post_type = get_post_type($post_id);
2784
+	$post_type = get_post_type($post_id);
2785 2785
 
2786
-    $all_postypes = geodir_get_posttypes();
2787
-    if (in_array($post_type, $all_postypes)) {
2788
-        $comments_link = str_replace('#comments', '#reviews', $comments_link);
2789
-        $comments_link = str_replace('#respond', '#reviews', $comments_link);
2790
-    }
2786
+	$all_postypes = geodir_get_posttypes();
2787
+	if (in_array($post_type, $all_postypes)) {
2788
+		$comments_link = str_replace('#comments', '#reviews', $comments_link);
2789
+		$comments_link = str_replace('#respond', '#reviews', $comments_link);
2790
+	}
2791 2791
 
2792
-    return $comments_link;
2792
+	return $comments_link;
2793 2793
 }
2794 2794
 
2795 2795
 
@@ -2807,11 +2807,11 @@  discard block
 block discarded – undo
2807 2807
 function geodir_add_nav_menu_class( $args )
2808 2808
 {
2809 2809
 
2810
-        if(isset($args['menu_class'])){
2811
-            $args['menu_class'] = $args['menu_class']." gd-menu-z";
2812
-        }
2810
+		if(isset($args['menu_class'])){
2811
+			$args['menu_class'] = $args['menu_class']." gd-menu-z";
2812
+		}
2813 2813
     
2814
-    return $args;
2814
+	return $args;
2815 2815
 }
2816 2816
 
2817 2817
 add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' );
@@ -2828,15 +2828,15 @@  discard block
 block discarded – undo
2828 2828
  * @return string Filtered locale ID.
2829 2829
  */
2830 2830
 function geodir_wpml_filter_locale($locale) {
2831
-    global $sitepress;
2831
+	global $sitepress;
2832 2832
     
2833
-    $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : '');
2833
+	$post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : '');
2834 2834
     
2835
-    if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) {
2836
-        $locale = $sitepress->get_locale($current_lang);
2837
-    }
2835
+	if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) {
2836
+		$locale = $sitepress->get_locale($current_lang);
2837
+	}
2838 2838
     
2839
-    return $locale;
2839
+	return $locale;
2840 2840
 }
2841 2841
 
2842 2842
 /**
@@ -2846,20 +2846,20 @@  discard block
 block discarded – undo
2846 2846
  * @package GeoDirectory
2847 2847
  */
2848 2848
 function geodir_wpml_set_filter() {
2849
-    if (geodir_is_wpml()) {
2850
-        global $sitepress;
2849
+	if (geodir_is_wpml()) {
2850
+		global $sitepress;
2851 2851
         
2852
-        if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2853
-            add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1);
2854
-        }
2852
+		if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2853
+			add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1);
2854
+		}
2855 2855
         
2856
-        add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2857
-        add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2856
+		add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2857
+		add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2858 2858
 		add_action( 'geodir_after_search_form', 'geodir_wpml_add_language_input_field' );
2859
-        if (is_admin()) {
2860
-            add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2861
-        }
2862
-    }
2859
+		if (is_admin()) {
2860
+			add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2861
+		}
2862
+	}
2863 2863
 }
2864 2864
 add_filter('plugins_loaded', 'geodir_wpml_set_filter');
2865 2865
 
@@ -2872,38 +2872,38 @@  discard block
 block discarded – undo
2872 2872
  * @return array Filtered languages.
2873 2873
  */
2874 2874
 function geodir_wpml_filter_ls_languages($languages) {    
2875
-    if (geodir_is_geodir_page()) {        
2876
-        $keep_vars = array();
2875
+	if (geodir_is_geodir_page()) {        
2876
+		$keep_vars = array();
2877 2877
         
2878
-        if (geodir_is_page('add-listing')) {
2879
-            $keep_vars = array('listing_type', 'package_id');
2880
-        } else if (geodir_is_page('search')) {
2881
-            $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon');
2882
-        } else if (geodir_is_page('author')) {
2883
-            $keep_vars = array('geodir_dashbord', 'stype', 'list');
2884
-        } else if (geodir_is_page('login')) {
2885
-            $keep_vars = array('forgot', 'signup');
2886
-        }        
2878
+		if (geodir_is_page('add-listing')) {
2879
+			$keep_vars = array('listing_type', 'package_id');
2880
+		} else if (geodir_is_page('search')) {
2881
+			$keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon');
2882
+		} else if (geodir_is_page('author')) {
2883
+			$keep_vars = array('geodir_dashbord', 'stype', 'list');
2884
+		} else if (geodir_is_page('login')) {
2885
+			$keep_vars = array('forgot', 'signup');
2886
+		}        
2887 2887
         
2888
-        if (!empty($keep_vars)) {
2889
-            foreach ( $languages as $code => $url) {
2890
-                $filter_url = $url['url'];
2888
+		if (!empty($keep_vars)) {
2889
+			foreach ( $languages as $code => $url) {
2890
+				$filter_url = $url['url'];
2891 2891
                 
2892
-                foreach ($keep_vars as $var) {
2893
-                    if (isset($_GET[$var]) && !is_array($_GET[$var])) {
2894
-                        $filter_url = remove_query_arg(array($var), $filter_url);
2895
-                        $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url);
2896
-                    }
2897
-                }
2892
+				foreach ($keep_vars as $var) {
2893
+					if (isset($_GET[$var]) && !is_array($_GET[$var])) {
2894
+						$filter_url = remove_query_arg(array($var), $filter_url);
2895
+						$filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url);
2896
+					}
2897
+				}
2898 2898
                 
2899
-                if ($filter_url != $url['url']) {
2900
-                    $languages[$code]['url'] = $filter_url;
2901
-                }
2902
-            }
2903
-        }
2904
-    }
2899
+				if ($filter_url != $url['url']) {
2900
+					$languages[$code]['url'] = $filter_url;
2901
+				}
2902
+			}
2903
+		}
2904
+	}
2905 2905
 
2906
-    return $languages;
2906
+	return $languages;
2907 2907
 }
2908 2908
 add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 );
2909 2909
 
@@ -2914,18 +2914,18 @@  discard block
 block discarded – undo
2914 2914
  *
2915 2915
  */
2916 2916
 function geodir_remove_yoast_seo_metas(){
2917
-    if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2918
-        $wpseo = WPSEO_Frontend::get_instance();
2917
+	if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2918
+		$wpseo = WPSEO_Frontend::get_instance();
2919 2919
         
2920
-        remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2921
-        remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2922
-        remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2923
-        remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2924
-        remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2925
-        remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2920
+		remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2921
+		remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2922
+		remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2923
+		remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2924
+		remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2925
+		remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2926 2926
         
2927
-        remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2928
-    }
2927
+		remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2928
+	}
2929 2929
 }
2930 2930
 
2931 2931
 /**
@@ -2939,20 +2939,20 @@  discard block
 block discarded – undo
2939 2939
  *
2940 2940
  */
2941 2941
  function geodir_wpml_ajax_set_guest_lang() {    
2942
-    if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2943
-        if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2944
-            global $sitepress;
2942
+	if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2943
+		if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2944
+			global $sitepress;
2945 2945
             
2946
-            $referer = wp_get_referer();
2946
+			$referer = wp_get_referer();
2947 2947
             
2948
-            $current_lang = $sitepress->get_current_language();
2949
-            $referrer_lang = $sitepress->get_language_from_url( $referer );
2948
+			$current_lang = $sitepress->get_current_language();
2949
+			$referrer_lang = $sitepress->get_language_from_url( $referer );
2950 2950
             
2951
-            if ( $referrer_lang && $current_lang != $referrer_lang ) {
2952
-                $_GET['lang'] = $referrer_lang;
2953
-            }
2954
-        }
2955
-    }
2951
+			if ( $referrer_lang && $current_lang != $referrer_lang ) {
2952
+				$_GET['lang'] = $referrer_lang;
2953
+			}
2954
+		}
2955
+	}
2956 2956
 }
2957 2957
 add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 );
2958 2958
 
@@ -2964,36 +2964,36 @@  discard block
 block discarded – undo
2964 2964
  * @param object $wp The WordPress object.
2965 2965
  */
2966 2966
 function geodir_check_redirect($wp) {
2967
-    if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) {
2968
-        $current_url = geodir_curPageURL();
2969
-        $search = 'czech-republic';
2970
-        $replace = 'czechia';        
2967
+	if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) {
2968
+		$current_url = geodir_curPageURL();
2969
+		$search = 'czech-republic';
2970
+		$replace = 'czechia';        
2971 2971
         
2972
-        $has_slash = substr($current_url, -1);
2973
-        if ($has_slash != "/") {
2974
-            $current_url .= '/';
2975
-        }
2972
+		$has_slash = substr($current_url, -1);
2973
+		if ($has_slash != "/") {
2974
+			$current_url .= '/';
2975
+		}
2976 2976
         
2977
-        $redirect = false;
2978
-        if (strpos($current_url, '/' . $search . '/') !== false) {
2979
-            $redirect = true;
2980
-            $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2981
-        }
2977
+		$redirect = false;
2978
+		if (strpos($current_url, '/' . $search . '/') !== false) {
2979
+			$redirect = true;
2980
+			$current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2981
+		}
2982 2982
         
2983
-        if ($has_slash != "/") {
2984
-            $current_url = trim($current_url, '/');
2985
-        }
2983
+		if ($has_slash != "/") {
2984
+			$current_url = trim($current_url, '/');
2985
+		}
2986 2986
         
2987
-        if (strpos($current_url, 'gd_country=' . $search) !== false) {
2988
-            $redirect = true;
2989
-            $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2990
-        }
2991
-
2992
-        if ($redirect) {
2993
-            wp_redirect($current_url);
2994
-            exit;
2995
-        }
2996
-    }
2987
+		if (strpos($current_url, 'gd_country=' . $search) !== false) {
2988
+			$redirect = true;
2989
+			$current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2990
+		}
2991
+
2992
+		if ($redirect) {
2993
+			wp_redirect($current_url);
2994
+			exit;
2995
+		}
2996
+	}
2997 2997
 }
2998 2998
 add_action('parse_request', 'geodir_check_redirect', 101, 1);
2999 2999
 
@@ -3013,50 +3013,50 @@  discard block
 block discarded – undo
3013 3013
  * @param string $original_slug The original post slug.
3014 3014
  */
3015 3015
 function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
3016
-    global $wpdb, $sitepress;
3016
+	global $wpdb, $sitepress;
3017 3017
     
3018
-    if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
3019
-        $wpml_post_join = "";
3020
-        $wpml_post_where = "";
3021
-        $wpml_term_join = "";
3022
-        $wpml_term_where = "";
3018
+	if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
3019
+		$wpml_post_join = "";
3020
+		$wpml_post_where = "";
3021
+		$wpml_term_join = "";
3022
+		$wpml_term_where = "";
3023 3023
         
3024
-        if (geodir_wpml_is_post_type_translated($post_type)) {
3025
-            $post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language();
3026
-            $post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress);
3027
-            if (!$post_language) {
3028
-                $post_language = $sitepress->get_current_language();
3029
-            }
3024
+		if (geodir_wpml_is_post_type_translated($post_type)) {
3025
+			$post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language();
3026
+			$post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress);
3027
+			if (!$post_language) {
3028
+				$post_language = $sitepress->get_current_language();
3029
+			}
3030 3030
             
3031
-            $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3032
-            $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'";
3031
+			$wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3032
+			$wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'";
3033 3033
             
3034
-            $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)";
3035
-            $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'";
3036
-        }
3034
+			$wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)";
3035
+			$wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'";
3036
+		}
3037 3037
 
3038
-        $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) );
3038
+		$term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) );
3039 3039
 
3040
-        if ( $term_slug_check ) {
3041
-            $suffix = 1;
3040
+		if ( $term_slug_check ) {
3041
+			$suffix = 1;
3042 3042
             
3043
-            do {
3044
-                $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3043
+			do {
3044
+				$alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3045 3045
                 
3046
-                $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) );
3046
+				$term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) );
3047 3047
                 
3048
-                $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3048
+				$post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3049 3049
                 
3050
-                $term_slug_check = $term_check || $post_check;
3050
+				$term_slug_check = $term_check || $post_check;
3051 3051
                 
3052
-                $suffix++;
3053
-            } while ( $term_slug_check );
3052
+				$suffix++;
3053
+			} while ( $term_slug_check );
3054 3054
             
3055
-            $slug = $alt_slug;
3056
-        }
3057
-    }
3055
+			$slug = $alt_slug;
3056
+		}
3057
+	}
3058 3058
     
3059
-    return $slug;
3059
+	return $slug;
3060 3060
 }
3061 3061
 add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6 );
3062 3062
 
@@ -3076,48 +3076,48 @@  discard block
 block discarded – undo
3076 3076
  * @return bool true when exists. false when not exists.
3077 3077
  */
3078 3078
 function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) {
3079
-    global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress;
3079
+	global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress;
3080 3080
     
3081
-    if ( $slug_exists ) {
3082
-        return $slug_exists;
3083
-    }
3081
+	if ( $slug_exists ) {
3082
+		return $slug_exists;
3083
+	}
3084 3084
     
3085
-    if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) {
3086
-        $taxonomy = $gd_term_taxonomy[$term_id];
3087
-    } else {
3088
-        $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3089
-        $gd_term_taxonomy[$term_id] = $taxonomy;
3090
-    }
3085
+	if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) {
3086
+		$taxonomy = $gd_term_taxonomy[$term_id];
3087
+	} else {
3088
+		$taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3089
+		$gd_term_taxonomy[$term_id] = $taxonomy;
3090
+	}
3091 3091
     
3092
-    if ( empty($taxonomy) ) {
3093
-        return $slug_exists;
3094
-    }
3092
+	if ( empty($taxonomy) ) {
3093
+		return $slug_exists;
3094
+	}
3095 3095
     
3096
-    if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3097
-        $post_type = $gd_term_post_type[$term_id];
3098
-    } else {
3099
-        $taxonomy_obj = get_taxonomy( $taxonomy );
3100
-        $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3101
-    }
3096
+	if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3097
+		$post_type = $gd_term_post_type[$term_id];
3098
+	} else {
3099
+		$taxonomy_obj = get_taxonomy( $taxonomy );
3100
+		$post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3101
+	}
3102 3102
     
3103
-    $wpml_post_join = "";
3104
-    $wpml_post_where = "";
3103
+	$wpml_post_join = "";
3104
+	$wpml_post_where = "";
3105 3105
     
3106
-    if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) {
3107
-        $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language();
3108
-        if (!$term_language) {
3109
-            $term_language = $sitepress->get_current_language();
3110
-        }
3106
+	if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) {
3107
+		$term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language();
3108
+		if (!$term_language) {
3109
+			$term_language = $sitepress->get_current_language();
3110
+		}
3111 3111
         
3112
-        $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3113
-        $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'";
3114
-    }
3112
+		$wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3113
+		$wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'";
3114
+	}
3115 3115
     
3116
-    if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s  {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) {
3117
-        $slug_exists = true;
3118
-    }
3116
+	if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s  {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) {
3117
+		$slug_exists = true;
3118
+	}
3119 3119
 
3120
-    return $slug_exists;
3120
+	return $slug_exists;
3121 3121
 }
3122 3122
 add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 );
3123 3123
 
Please login to merge, or discard this patch.
Braces   +89 added lines, -72 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
 add_filter('query_vars', 'geodir_add_location_var');
87 87
 add_filter('query_vars', 'geodir_add_geodir_page_var');
88 88
 add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
89
-if (get_option('permalink_structure') != '')
90
-    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
89
+if (get_option('permalink_structure') != '') {
90
+    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
91
+}
91 92
 
92 93
 add_filter('parse_query', 'geodir_modified_query');
93 94
 
@@ -431,8 +432,9 @@  discard block
 block discarded – undo
431 432
      */
432 433
     do_action('geodir_after_social_sharing_buttons');
433 434
     $content_html = ob_get_clean();
434
-    if (trim($content_html) != '')
435
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
435
+    if (trim($content_html) != '') {
436
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
437
+    }
436 438
     if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
437 439
         /**
438 440
          * Filter the geodir_social_sharing_buttons() function content.
@@ -488,8 +490,9 @@  discard block
 block discarded – undo
488 490
      */
489 491
     do_action('geodir_after_edit_post_link');
490 492
     $content_html = ob_get_clean();
491
-    if (trim($content_html) != '')
492
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
+    if (trim($content_html) != '') {
494
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
495
+    }
493 496
     if ((int)get_option('geodir_disable_user_links_section') != 1) {
494 497
         /**
495 498
          * Filter the geodir_edit_post_link() function content.
@@ -1066,8 +1069,9 @@  discard block
 block discarded – undo
1066 1069
      */
1067 1070
     do_action('geodir_after_google_analytics');
1068 1071
     $content_html = ob_get_clean();
1069
-    if (trim($content_html) != '')
1070
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1072
+    if (trim($content_html) != '') {
1073
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1074
+    }
1071 1075
     if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1072 1076
         /**
1073 1077
          * Filter the geodir_edit_post_link() function content.
@@ -1209,8 +1213,9 @@  discard block
 block discarded – undo
1209 1213
     do_action('geodir_after_detail_page_more_info');
1210 1214
 
1211 1215
     $content_html = ob_get_clean();
1212
-    if (trim($content_html) != '')
1213
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1216
+    if (trim($content_html) != '') {
1217
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1218
+    }
1214 1219
     if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1215 1220
         /**
1216 1221
          * Filter the output html for function geodir_detail_page_more_info().
@@ -1342,8 +1347,9 @@  discard block
 block discarded – undo
1342 1347
     $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1343 1348
 
1344 1349
     foreach ($arr_alert_msg as $key => $value) {
1345
-        if (!is_scalar($value))
1346
-            continue;
1350
+        if (!is_scalar($value)) {
1351
+                    continue;
1352
+        }
1347 1353
         $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1348 1354
     }
1349 1355
 
@@ -1399,17 +1405,19 @@  discard block
 block discarded – undo
1399 1405
     global $geodir_sidebars;
1400 1406
     global $sidebars_widgets;
1401 1407
 
1402
-    if (!is_array($sidebars_widgets))
1403
-        $sidebars_widgets = wp_get_sidebars_widgets();
1408
+    if (!is_array($sidebars_widgets)) {
1409
+            $sidebars_widgets = wp_get_sidebars_widgets();
1410
+    }
1404 1411
     $geodir_old_sidebars = array();
1405 1412
 
1406 1413
     if (is_array($geodir_sidebars)) {
1407 1414
         foreach ($geodir_sidebars as $val) {
1408 1415
             if (is_array($sidebars_widgets)) {
1409
-                if (array_key_exists($val, $sidebars_widgets))
1410
-                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1411
-                else
1412
-                    $geodir_old_sidebars[$val] = array();
1416
+                if (array_key_exists($val, $sidebars_widgets)) {
1417
+                                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1418
+                } else {
1419
+                                    $geodir_old_sidebars[$val] = array();
1420
+                }
1413 1421
             }
1414 1422
         }
1415 1423
     }
@@ -1430,16 +1438,19 @@  discard block
 block discarded – undo
1430 1438
 {
1431 1439
     global $sidebars_widgets;
1432 1440
 
1433
-    if (!is_array($sidebars_widgets))
1434
-        $sidebars_widgets = wp_get_sidebars_widgets();
1441
+    if (!is_array($sidebars_widgets)) {
1442
+            $sidebars_widgets = wp_get_sidebars_widgets();
1443
+    }
1435 1444
 
1436 1445
     if (is_array($sidebars_widgets)) {
1437 1446
         $geodir_old_sidebars = get_option('geodir_sidebars');
1438 1447
         if (is_array($geodir_old_sidebars)) {
1439 1448
             foreach ($geodir_old_sidebars as $key => $val) {
1440
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1449
+                if(0 === strpos($key, 'geodir_')) {
1450
+                	// if gd widget
1441 1451
                 {
1442
-                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1452
+                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1453
+                }
1443 1454
                 }
1444 1455
 
1445 1456
 
@@ -1575,20 +1586,25 @@  discard block
 block discarded – undo
1575 1586
         }
1576 1587
     }
1577 1588
     
1578
-    if ($tab == 'post_info')
1579
-        $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1589
+    if ($tab == 'post_info') {
1590
+            $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1591
+    }
1580 1592
     
1581
-    if ($tab == 'post_images')
1582
-        $is_display = (!empty($post_images)) ? true : false;
1593
+    if ($tab == 'post_images') {
1594
+            $is_display = (!empty($post_images)) ? true : false;
1595
+    }
1583 1596
 
1584
-    if ($tab == 'post_video')
1585
-        $is_display = (!empty($video)) ? true : false;
1597
+    if ($tab == 'post_video') {
1598
+            $is_display = (!empty($video)) ? true : false;
1599
+    }
1586 1600
 
1587
-    if ($tab == 'special_offers')
1588
-        $is_display = (!empty($special_offers)) ? true : false;
1601
+    if ($tab == 'special_offers') {
1602
+            $is_display = (!empty($special_offers)) ? true : false;
1603
+    }
1589 1604
 
1590
-    if ($tab == 'reviews')
1591
-        $is_display = (geodir_is_page('detail')) ? true : false;
1605
+    if ($tab == 'reviews') {
1606
+            $is_display = (geodir_is_page('detail')) ? true : false;
1607
+    }
1592 1608
 
1593 1609
     if ($tab == 'related_listing') {
1594 1610
        $message = __('No listings found which match your selection.', 'geodirectory');
@@ -1822,11 +1838,13 @@  discard block
 block discarded – undo
1822 1838
     $region_slug = $default_location->region_slug;
1823 1839
     $city_slug = $default_location->city_slug;
1824 1840
 
1825
-    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1826
-        return $slug_exists = true;
1841
+    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) {
1842
+            return $slug_exists = true;
1843
+    }
1827 1844
 
1828
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1829
-        return $slug_exists = true;
1845
+    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) {
1846
+            return $slug_exists = true;
1847
+    }
1830 1848
 
1831 1849
     return $slug_exists;
1832 1850
 }
@@ -1869,40 +1887,31 @@  discard block
 block discarded – undo
1869 1887
     if(geodir_is_page('home')){
1870 1888
         $gd_page = 'home';
1871 1889
         $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1872
-    }
1873
-    elseif(geodir_is_page('detail')){
1890
+    } elseif(geodir_is_page('detail')){
1874 1891
         $gd_page = 'detail';
1875 1892
         $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1876
-    }
1877
-    elseif(geodir_is_page('pt')){
1893
+    } elseif(geodir_is_page('pt')){
1878 1894
         $gd_page = 'pt';
1879 1895
         $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1880
-    }
1881
-    elseif(geodir_is_page('listing')){
1896
+    } elseif(geodir_is_page('listing')){
1882 1897
         $gd_page = 'listing';
1883 1898
         $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1884
-    }
1885
-    elseif(geodir_is_page('location')){
1899
+    } elseif(geodir_is_page('location')){
1886 1900
         $gd_page = 'location';
1887 1901
         $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1888
-    }
1889
-    elseif(geodir_is_page('search')){
1902
+    } elseif(geodir_is_page('search')){
1890 1903
         $gd_page = 'search';
1891 1904
         $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1892
-    }
1893
-    elseif(geodir_is_page('add-listing')){
1905
+    } elseif(geodir_is_page('add-listing')){
1894 1906
         $gd_page = 'add-listing';
1895 1907
         $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1896
-    }
1897
-    elseif(geodir_is_page('author')){
1908
+    } elseif(geodir_is_page('author')){
1898 1909
         $gd_page = 'author';
1899 1910
         $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1900
-    }
1901
-    elseif(geodir_is_page('login')){
1911
+    } elseif(geodir_is_page('login')){
1902 1912
         $gd_page = 'login';
1903 1913
         $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1904
-    }
1905
-    elseif(geodir_is_page('listing-success')){
1914
+    } elseif(geodir_is_page('listing-success')){
1906 1915
         $gd_page = 'listing-success';
1907 1916
         $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1908 1917
     }
@@ -1980,11 +1989,13 @@  discard block
 block discarded – undo
1980 1989
 
1981 1990
     if (!get_option('geodir_remove_url_seperator')) {
1982 1991
 
1983
-        if (get_option('geodir_listingurl_separator'))
1984
-            delete_option('geodir_listingurl_separator');
1992
+        if (get_option('geodir_listingurl_separator')) {
1993
+                    delete_option('geodir_listingurl_separator');
1994
+        }
1985 1995
 
1986
-        if (get_option('geodir_detailurl_separator'))
1987
-            delete_option('geodir_detailurl_separator');
1996
+        if (get_option('geodir_detailurl_separator')) {
1997
+                    delete_option('geodir_detailurl_separator');
1998
+        }
1988 1999
 
1989 2000
         flush_rewrite_rules(false);
1990 2001
 
@@ -2008,8 +2019,9 @@  discard block
 block discarded – undo
2008 2019
 {
2009 2020
     foreach ($permalink_arr as $key => $value) {
2010 2021
 
2011
-        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2012
-            unset($permalink_arr[$key]);
2022
+        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') {
2023
+                    unset($permalink_arr[$key]);
2024
+        }
2013 2025
 
2014 2026
     }
2015 2027
 
@@ -2144,16 +2156,18 @@  discard block
 block discarded – undo
2144 2156
 
2145 2157
             $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2146 2158
 
2147
-            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2148
-                $tabs_arr['post_video']['heading_text'] = $field_title;
2159
+            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') {
2160
+                            $tabs_arr['post_video']['heading_text'] = $field_title;
2161
+            }
2149 2162
         }
2150 2163
 
2151 2164
         if (array_key_exists('special_offers', $tabs_arr)) {
2152 2165
 
2153 2166
             $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2154 2167
 
2155
-            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2156
-                $tabs_arr['special_offers']['heading_text'] = $field_title;
2168
+            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') {
2169
+                            $tabs_arr['special_offers']['heading_text'] = $field_title;
2170
+            }
2157 2171
         }
2158 2172
 
2159 2173
     }
@@ -2208,8 +2222,9 @@  discard block
 block discarded – undo
2208 2222
 
2209 2223
         $all_postypes = geodir_get_posttypes();
2210 2224
 
2211
-        if (!in_array($post_type, $all_postypes) || !is_admin())
2212
-            return false;
2225
+        if (!in_array($post_type, $all_postypes) || !is_admin()) {
2226
+                    return false;
2227
+        }
2213 2228
 
2214 2229
         $uploads = wp_upload_dir();
2215 2230
 
@@ -2283,8 +2298,9 @@  discard block
 block discarded – undo
2283 2298
                         $file_info = pathinfo($attach->file);
2284 2299
 
2285 2300
                         $sub_dir = '';
2286
-                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2287
-                            $sub_dir = stripslashes_deep($file_info['dirname']);
2301
+                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
2302
+                                                    $sub_dir = stripslashes_deep($file_info['dirname']);
2303
+                        }
2288 2304
 
2289 2305
                         $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2290 2306
                         $uploads_path = $uploads['basedir'];
@@ -2305,8 +2321,9 @@  discard block
 block discarded – undo
2305 2321
 
2306 2322
                     if (!empty($attachment_data)) {
2307 2323
 
2308
-                        if ($attachment_data->ID)
2309
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2324
+                        if ($attachment_data->ID) {
2325
+                                                    $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2326
+                        }
2310 2327
 
2311 2328
                     } else {
2312 2329
 
@@ -2497,7 +2514,7 @@  discard block
 block discarded – undo
2497 2514
                         $variables_array['label'] = __($type['site_title'], 'geodirectory');
2498 2515
                         $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2499 2516
 
2500
-                    }else{
2517
+                    } else{
2501 2518
                         $i = 0;
2502 2519
                         $fieldset_count++;
2503 2520
                         $field_set_start = 1;
@@ -2626,7 +2643,7 @@  discard block
 block discarded – undo
2626 2643
             $status_icon = '<i class="fas fa-play"></i>';
2627 2644
             if ($real_status == 'publish') {
2628 2645
                 $status .= __('Published', 'geodirectory');
2629
-            }elseif ($real_status == 'pending') {
2646
+            } elseif ($real_status == 'pending') {
2630 2647
                 $status .= __('Awaiting Review', 'geodirectory');
2631 2648
             } else {
2632 2649
                 $status .= __('Not published', 'geodirectory');
Please login to merge, or discard this patch.
Spacing   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 /* ON TEMPLATE INCLUDE */
137 137
 /////////////////////////
138 138
 
139
-add_filter('template_include', 'geodir_template_loader',9);
139
+add_filter('template_include', 'geodir_template_loader', 9);
140 140
 
141 141
 /////////////////////////
142 142
 /* CATEGORY / TAXONOMY / CUSTOM POST ACTIONS */
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 /* WP REVIEW COUNT ACTIONS */
177 177
 ////////////////////////
178 178
 
179
-add_action('geodir_update_postrating', 'geodir_term_review_count_force_update_single_post', 100,1);
179
+add_action('geodir_update_postrating', 'geodir_term_review_count_force_update_single_post', 100, 1);
180 180
 //add_action('geodir_update_postrating', 'geodir_term_review_count_force_update', 100);
181
-add_action('transition_post_status', 'geodir_term_review_count_force_update', 100,3);
181
+add_action('transition_post_status', 'geodir_term_review_count_force_update', 100, 3);
182 182
 //add_action('created_term', 'geodir_term_review_count_force_update', 100);
183 183
 add_action('edited_term', 'geodir_term_review_count_force_update', 100);
184 184
 //add_action('delete_term', 'geodir_term_review_count_force_update', 100); /*causes memory timeout on delete bulk tags*/
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
  */
224 224
 function geodir_unset_prev_theme_nav_location($newname)
225 225
 {
226
-    $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
226
+    $geodir_theme_location = get_option('geodir_theme_location_nav_'.$newname);
227 227
     if ($geodir_theme_location) {
228 228
         update_option('geodir_theme_location_nav', $geodir_theme_location);
229 229
     } else {
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
     include_once('geodirectory-functions/listing_filters.php');
259 259
     
260 260
     // Theme My Login compatibility fix
261
-    if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) {
262
-        remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) );
261
+    if (isset($_REQUEST['geodir_search']) && class_exists('Theme_My_Login')) {
262
+        remove_action('pre_get_posts', array(Theme_My_Login::get_object(), 'pre_get_posts'));
263 263
     }
264 264
     
265
-    if ( isset( $_REQUEST['geodir_search'] ) ) {
266
-        add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 );
267
-        add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 );
265
+    if (isset($_REQUEST['geodir_search'])) {
266
+        add_filter('geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3);
267
+        add_filter('geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3);
268 268
     }
269 269
 }
270 270
 
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 
332 332
 /////// GEO DIRECOTORY CUSTOM HOOKS ///
333 333
 
334
-add_action('geodir_before_tab_content', 'geodir_before_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content 
335
-add_action('geodir_after_tab_content', 'geodir_after_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content
334
+add_action('geodir_before_tab_content', 'geodir_before_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content 
335
+add_action('geodir_after_tab_content', 'geodir_after_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content
336 336
 
337 337
 // Detail page sidebar content 
338 338
 add_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting', 1);
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
     do_action('geodir_after_social_sharing_buttons');
433 433
     $content_html = ob_get_clean();
434 434
     if (trim($content_html) != '')
435
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
436
-    if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
435
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">'.$content_html.'</div>';
436
+    if ((int) get_option('geodir_disable_tfg_buttons_section') != 1) {
437 437
         /**
438 438
          * Filter the geodir_social_sharing_buttons() function content.
439 439
          *
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
             $post_id = $post->ID;
474 474
             
475 475
             if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
476
-                $post_id = (int)$_REQUEST['pid'];
476
+                $post_id = (int) $_REQUEST['pid'];
477 477
             }
478 478
 
479 479
             $postlink = get_permalink(geodir_add_listing_page_id());
480 480
             $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
481
-            echo ' <p class="edit_link"><i class="fas fa-pencil-alt"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
481
+            echo ' <p class="edit_link"><i class="fas fa-pencil-alt"></i> <a href="'.esc_url($editlink).'">'.__('Edit this Post', 'geodirectory').'</a></p>';
482 482
         }
483 483
     }// end of if, if its a preview or not
484 484
     /**
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
     do_action('geodir_after_edit_post_link');
490 490
     $content_html = ob_get_clean();
491 491
     if (trim($content_html) != '')
492
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
-    if ((int)get_option('geodir_disable_user_links_section') != 1) {
492
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">'.$content_html.'</div>';
493
+    if ((int) get_option('geodir_disable_user_links_section') != 1) {
494 494
         /**
495 495
          * Filter the geodir_edit_post_link() function content.
496 496
          *
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
  */
512 512
 function geodir_detail_page_google_analytics()
513 513
 {
514
-    if ( ! get_option( 'geodir_ga_stats' ) ) {
514
+    if (!get_option('geodir_ga_stats')) {
515 515
 		return;
516 516
 	}
517
-	global $post,$preview;
518
-    if($preview){return '';}
517
+	global $post, $preview;
518
+    if ($preview) {return ''; }
519 519
     $package_info = array();
520 520
     $package_info = geodir_post_package_info($package_info, $post);
521 521
 
@@ -547,14 +547,14 @@  discard block
 block discarded – undo
547 547
     $hide_refresh = get_option('geodir_ga_auto_refresh');
548 548
     
549 549
     $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
550
-    if (is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
550
+    if (is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id() == $post->post_author || current_user_can('manage_options'))) {
551 551
         $page_url = urlencode($_SERVER['REQUEST_URI']);
552 552
         ?>
553 553
         <script type="text/javascript">
554 554
             var gd_gaTimeOut;
555
-            var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
556
-            var gd_gaHideRefresh = <?php echo (int)$hide_refresh;?>;
557
-            var gd_gaAutoRefresh = <?php echo $auto_refresh;?>;
555
+            var gd_gaTime = parseInt('<?php echo $refresh_time; ?>');
556
+            var gd_gaHideRefresh = <?php echo (int) $hide_refresh; ?>;
557
+            var gd_gaAutoRefresh = <?php echo $auto_refresh; ?>;
558 558
             ga_data1 = false;
559 559
             ga_data2 = false;
560 560
             ga_data3 = false;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
             }
696 696
 
697 697
             function gdga_noResults() {
698
-                jQuery('#gdga-chart-container').html('<?php _e('No results available','geodirectory');?>');
698
+                jQuery('#gdga-chart-container').html('<?php _e('No results available', 'geodirectory'); ?>');
699 699
                 jQuery('#gdga-legend-container').html('');
700 700
             }
701 701
 
@@ -727,18 +727,18 @@  discard block
 block discarded – undo
727 727
                     var data2 = results[1].rows.map(function(row) { return +row[2]; });
728 728
                     //var labelsN = results[0].rows.map(function(row) { return +row[1]; });
729 729
 
730
-                    var labels = ['<?php _e('Jan', 'geodirectory');?>',
731
-                        '<?php _e('Feb', 'geodirectory');?>',
732
-                        '<?php _e('Mar', 'geodirectory');?>',
733
-                        '<?php _e('Apr', 'geodirectory');?>',
734
-                        '<?php _e('May', 'geodirectory');?>',
735
-                        '<?php _e('Jun', 'geodirectory');?>',
736
-                        '<?php _e('Jul', 'geodirectory');?>',
737
-                        '<?php _e('Aug', 'geodirectory');?>',
738
-                        '<?php _e('Sep', 'geodirectory');?>',
739
-                        '<?php _e('Oct', 'geodirectory');?>',
740
-                        '<?php _e('Nov', 'geodirectory');?>',
741
-                        '<?php _e('Dec', 'geodirectory');?>'];
730
+                    var labels = ['<?php _e('Jan', 'geodirectory'); ?>',
731
+                        '<?php _e('Feb', 'geodirectory'); ?>',
732
+                        '<?php _e('Mar', 'geodirectory'); ?>',
733
+                        '<?php _e('Apr', 'geodirectory'); ?>',
734
+                        '<?php _e('May', 'geodirectory'); ?>',
735
+                        '<?php _e('Jun', 'geodirectory'); ?>',
736
+                        '<?php _e('Jul', 'geodirectory'); ?>',
737
+                        '<?php _e('Aug', 'geodirectory'); ?>',
738
+                        '<?php _e('Sep', 'geodirectory'); ?>',
739
+                        '<?php _e('Oct', 'geodirectory'); ?>',
740
+                        '<?php _e('Nov', 'geodirectory'); ?>',
741
+                        '<?php _e('Dec', 'geodirectory'); ?>'];
742 742
 
743 743
                     // Ensure the data arrays are at least as long as the labels array.
744 744
                     // Chart.js bar charts don't (yet) accept sparse datasets.
@@ -751,13 +751,13 @@  discard block
 block discarded – undo
751 751
                         labels : labels,
752 752
                         datasets : [
753 753
                             {
754
-                                label: '<?php _e('Last Year', 'geodirectory');?>',
754
+                                label: '<?php _e('Last Year', 'geodirectory'); ?>',
755 755
                                 fillColor : "rgba(220,220,220,0.5)",
756 756
                                 strokeColor : "rgba(220,220,220,1)",
757 757
                                 data : data2
758 758
                             },
759 759
                             {
760
-                                label: '<?php _e('This Year', 'geodirectory');?>',
760
+                                label: '<?php _e('This Year', 'geodirectory'); ?>',
761 761
                                 fillColor : "rgba(151,187,205,0.5)",
762 762
                                 strokeColor : "rgba(151,187,205,1)",
763 763
                                 data : data1
@@ -802,30 +802,30 @@  discard block
 block discarded – undo
802 802
 
803 803
                     <?php
804 804
                     // Here we list the shorthand days of the week so it can be used in translation.
805
-                    __("Mon",'geodirectory');
806
-                    __("Tue",'geodirectory');
807
-                    __("Wed",'geodirectory');
808
-                    __("Thu",'geodirectory');
809
-                    __("Fri",'geodirectory');
810
-                    __("Sat",'geodirectory');
811
-                    __("Sun",'geodirectory');
805
+                    __("Mon", 'geodirectory');
806
+                    __("Tue", 'geodirectory');
807
+                    __("Wed", 'geodirectory');
808
+                    __("Thu", 'geodirectory');
809
+                    __("Fri", 'geodirectory');
810
+                    __("Sat", 'geodirectory');
811
+                    __("Sun", 'geodirectory');
812 812
                     ?>
813 813
 
814 814
                     labels = [
815
-                        "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
816
-                        "<?php _e(date('D', strtotime("+2 day")),'geodirectory'); ?>",
817
-                        "<?php _e(date('D', strtotime("+3 day")),'geodirectory'); ?>",
818
-                        "<?php _e(date('D', strtotime("+4 day")),'geodirectory'); ?>",
819
-                        "<?php _e(date('D', strtotime("+5 day")),'geodirectory'); ?>",
820
-                        "<?php _e(date('D', strtotime("+6 day")),'geodirectory'); ?>",
821
-                        "<?php _e(date('D', strtotime("+7 day")),'geodirectory'); ?>"
815
+                        "<?php _e(date('D', strtotime("+1 day")), 'geodirectory'); ?>",
816
+                        "<?php _e(date('D', strtotime("+2 day")), 'geodirectory'); ?>",
817
+                        "<?php _e(date('D', strtotime("+3 day")), 'geodirectory'); ?>",
818
+                        "<?php _e(date('D', strtotime("+4 day")), 'geodirectory'); ?>",
819
+                        "<?php _e(date('D', strtotime("+5 day")), 'geodirectory'); ?>",
820
+                        "<?php _e(date('D', strtotime("+6 day")), 'geodirectory'); ?>",
821
+                        "<?php _e(date('D', strtotime("+7 day")), 'geodirectory'); ?>"
822 822
                     ];
823 823
 
824 824
                     var data = {
825 825
                         labels : labels,
826 826
                         datasets : [
827 827
                             {
828
-                                label: '<?php _e('Last Week', 'geodirectory');?>',
828
+                                label: '<?php _e('Last Week', 'geodirectory'); ?>',
829 829
                                 fillColor : "rgba(220,220,220,0.5)",
830 830
                                 strokeColor : "rgba(220,220,220,1)",
831 831
                                 pointColor : "rgba(220,220,220,1)",
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                                 data : data2
834 834
                             },
835 835
                             {
836
-                                label: '<?php _e('This Week', 'geodirectory');?>',
836
+                                label: '<?php _e('This Week', 'geodirectory'); ?>',
837 837
                                 fillColor : "rgba(151,187,205,0.5)",
838 838
                                 strokeColor : "rgba(151,187,205,1)",
839 839
                                 pointColor : "rgba(151,187,205,1)",
@@ -1040,18 +1040,18 @@  discard block
 block discarded – undo
1040 1040
         </style>
1041 1041
         <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
1042 1042
         <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
1043
-        <button type="button" class="gdga-show-analytics"><?php _e('Show Google Analytics', 'geodirectory');?></button>
1043
+        <button type="button" class="gdga-show-analytics"><?php _e('Show Google Analytics', 'geodirectory'); ?></button>
1044 1044
         <span id="ga_stats" class="gdga-analytics-box" style="display:none">
1045
-            <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory');?></div>
1045
+            <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory'); ?></div>
1046 1046
             <div id="gd-active-users-container">
1047
-                <div class="gd-ActiveUsers"><i id="gdga-loader-icon" class="fas fa-refresh fa-spin" title="<?php esc_attr_e("Refresh", 'geodirectory');?>"></i><?php _e("Active Users:", 'geodirectory');?>
1047
+                <div class="gd-ActiveUsers"><i id="gdga-loader-icon" class="fas fa-refresh fa-spin" title="<?php esc_attr_e("Refresh", 'geodirectory'); ?>"></i><?php _e("Active Users:", 'geodirectory'); ?>
1048 1048
                     <b class="gd-ActiveUsers-value">0</b>
1049 1049
                 </div>
1050 1050
             </div>
1051 1051
             <select id="gdga-select-analytic" onchange="gdga_select_option();" style="display: none;">
1052
-                <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory');?></option>
1053
-                <option value="years"><?php _e("This Year vs Last Year", 'geodirectory');?></option>
1054
-                <option value="country"><?php _e("Top Countries", 'geodirectory');?></option>
1052
+                <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory'); ?></option>
1053
+                <option value="years"><?php _e("This Year vs Last Year", 'geodirectory'); ?></option>
1054
+                <option value="country"><?php _e("Top Countries", 'geodirectory'); ?></option>
1055 1055
             </select>
1056 1056
             <div class="Chartjs-figure" id="gdga-chart-container"></div>
1057 1057
             <ol class="Chartjs-legend" id="gdga-legend-container"></ol>
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
     do_action('geodir_after_google_analytics');
1068 1068
     $content_html = ob_get_clean();
1069 1069
     if (trim($content_html) != '')
1070
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1071
-    if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1070
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">'.$content_html.'</div>';
1071
+    if ((int) get_option('geodir_disable_google_analytics_section') != 1) {
1072 1072
         /**
1073 1073
          * Filter the geodir_edit_post_link() function content.
1074 1074
          *
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 {
1095 1095
     global $post, $preview, $post_images;
1096 1096
     
1097
-    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1097
+    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int) $post->ID)) {
1098 1098
         return;
1099 1099
     }
1100 1100
     ob_start(); // Start  buffering;
@@ -1129,10 +1129,10 @@  discard block
 block discarded – undo
1129 1129
        
1130 1130
 	   $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
1131 1131
 	   
1132
-	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
1132
+	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="'.$post_avgratings.'">'.$post_avgratings.'</span> / <span itemprop="best" content="5">5</span> '.__("based on", 'geodirectory').' </span><span class="count" itemprop="count" content="'.$comment_count.'">'.$comment_count.' '.$reviews_text.'</span><br />';
1133 1133
 
1134 1134
         $html .= '<span class="item">';
1135
-        $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1135
+        $html .= '<span class="fn" itemprop="itemreviewed">'.$post->post_title.'</span>';
1136 1136
 
1137 1137
         if ($post_images) {
1138 1138
             foreach ($post_images as $img) {
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
         }
1143 1143
 
1144 1144
         if (isset($post_img) && $post_img) {
1145
-            $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1145
+            $html .= '<br /><img src="'.$post_img.'" class="photo" alt="'.esc_attr($post->post_title).'" itemprop="photo" content="'.$post_img.'" class="photo" />';
1146 1146
         }
1147 1147
 
1148 1148
         $html .= '</span>';
@@ -1169,9 +1169,9 @@  discard block
 block discarded – undo
1169 1169
     do_action('geodir_after_detail_page_review_rating');
1170 1170
     $content_html = ob_get_clean();
1171 1171
     if (trim($content_html) != '') {
1172
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1172
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">'.$content_html.'</div>';
1173 1173
     }
1174
-    if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1174
+    if ((int) get_option('geodir_disable_rating_info_section') != 1) {
1175 1175
         /**
1176 1176
          * Filter the geodir_detail_page_review_rating() function content.
1177 1177
          *
@@ -1210,8 +1210,8 @@  discard block
 block discarded – undo
1210 1210
 
1211 1211
     $content_html = ob_get_clean();
1212 1212
     if (trim($content_html) != '')
1213
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1214
-    if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1213
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">'.$content_html.'</div>';
1214
+    if ((int) get_option('geodir_disable_listing_info_section') != 1) {
1215 1215
         /**
1216 1216
          * Filter the output html for function geodir_detail_page_more_info().
1217 1217
          *
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
 		'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
1313 1313
 		'geodir_txt_form_wait' => __('Wait...', 'geodirectory'),
1314 1314
 		'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
1315
-		'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1315
+		'fa_rating' => (int) get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1316 1316
 		'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
1317 1317
         'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1318 1318
         'geodir_map_name' => geodir_map_name(),
@@ -1344,10 +1344,10 @@  discard block
 block discarded – undo
1344 1344
     foreach ($arr_alert_msg as $key => $value) {
1345 1345
         if (!is_scalar($value))
1346 1346
             continue;
1347
-        $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1347
+        $arr_alert_msg[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
1348 1348
     }
1349 1349
 
1350
-    $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1350
+    $script = "var geodir_all_js_msg = ".json_encode($arr_alert_msg).';';
1351 1351
     echo '<script>';
1352 1352
     echo $script;
1353 1353
     echo '</script>';
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
         $geodir_old_sidebars = get_option('geodir_sidebars');
1438 1438
         if (is_array($geodir_old_sidebars)) {
1439 1439
             foreach ($geodir_old_sidebars as $key => $val) {
1440
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1440
+                if (0 === strpos($key, 'geodir_'))// if gd widget
1441 1441
                 {
1442 1442
                     $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1443 1443
                 }
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
         global $post;
1517 1517
         $term_condition = '';
1518 1518
         if (isset($_REQUEST['backandedit'])) {
1519
-            $post = (object)$gd_session->get('listing');
1519
+            $post = (object) $gd_session->get('listing');
1520 1520
             $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1521 1521
         }
1522 1522
 
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
                     echo 'checked="checked"';
1531 1531
                 } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1532 1532
                        class="geodir_textfield" value="1"
1533
-                       style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1533
+                       style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if ($terms_page) { echo get_permalink($terms_page); }?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1534 1534
 				</span>
1535 1535
             </div>
1536 1536
             <span class="geodir_message_error"><?php if (isset($required_msg)) {
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
         /** This action is documented in geodirectory_template_actions.php */
1571 1571
         $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1572 1572
         
1573
-        if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1573
+        if (!($desc_limit === '' || (int) $desc_limit > 0)) {
1574 1574
             $is_display = false;
1575 1575
         }
1576 1576
     }
@@ -1618,16 +1618,16 @@  discard block
 block discarded – undo
1618 1618
     global $wpdb, $plugin_prefix;
1619 1619
 	
1620 1620
 	// Remove unused virtual page
1621
-	$listings_page_id = (int)get_option('geodir_listing_page');
1621
+	$listings_page_id = (int) get_option('geodir_listing_page');
1622 1622
 	if ($listings_page_id) {
1623
-		$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1623
+		$wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->posts." WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1624 1624
         delete_option('geodir_listing_page');
1625 1625
 	}
1626 1626
 
1627 1627
     if (!get_option('geodir_changes_in_custom_fields_table')) {
1628 1628
         $wpdb->query(
1629 1629
             $wpdb->prepare(
1630
-                "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1630
+                "UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET is_default=%s, is_admin=%s WHERE is_default=%s",
1631 1631
                 array('1', '1', 'admin')
1632 1632
             )
1633 1633
         );
@@ -1635,9 +1635,9 @@  discard block
 block discarded – undo
1635 1635
 
1636 1636
         /* --- terms meta value set --- */
1637 1637
 
1638
-        update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1638
+        update_option('geodir_default_marker_icon', geodir_plugin_url().'/geodirectory-functions/map-functions/icons/pin.png');
1639 1639
 
1640
-        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1640
+        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."options WHERE option_name LIKE %s", array('%tax_meta_%')));
1641 1641
 
1642 1642
         if (!empty($options_data)) {
1643 1643
 
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
 
1646 1646
                 $option_val = str_replace('tax_meta_', '', $optobj->option_name);
1647 1647
 
1648
-                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1648
+                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM ".$wpdb->prefix."term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1649 1649
 
1650 1650
                 if (!empty($taxonomies_data)) {
1651 1651
 
@@ -1654,17 +1654,17 @@  discard block
 block discarded – undo
1654 1654
                         $taxObject = get_taxonomy($taxobj->taxonomy);
1655 1655
                         $post_type = $taxObject->object_type[0];
1656 1656
 
1657
-                        $opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1657
+                        $opt_value = 'tax_meta_'.$post_type.'_'.$option_val;
1658 1658
 
1659
-                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1659
+                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM ".$wpdb->prefix."options WHERE option_name=%s", array('tax_meta_'.$option_val)));
1660 1660
 
1661 1661
                         if ($duplicate_data) {
1662 1662
 
1663
-                            $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1663
+                            $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1664 1664
 
1665 1665
                         } else {
1666 1666
 
1667
-                            $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1667
+                            $wpdb->query($wpdb->prepare("INSERT INTO ".$wpdb->prefix."options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1668 1668
 
1669 1669
                         }
1670 1670
 
@@ -1698,14 +1698,14 @@  discard block
 block discarded – undo
1698 1698
 
1699 1699
     global $wpdb, $table_prefix;
1700 1700
 
1701
-    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1701
+    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s", array($slug)));
1702 1702
 
1703 1703
     if ($slug_exists) {
1704 1704
 
1705 1705
         $suffix = 1;
1706 1706
         do {
1707
-            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1708
-            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1707
+            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
1708
+            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s", array($alt_location_name)));
1709 1709
             $suffix++;
1710 1710
         } while ($location_slug_check && $suffix < 100);
1711 1711
 
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
 
1721 1721
 add_action('edited_term', 'geodir_update_term_slug', '1', 3);
1722 1722
 add_action('create_term', 'geodir_update_term_slug', '1', 3);
1723
-add_action( 'delete_term', 'geodir_on_delete_term', 1, 5 );
1723
+add_action('delete_term', 'geodir_on_delete_term', 1, 5);
1724 1724
 
1725 1725
 /**
1726 1726
  * Update term slug.
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 
1760 1760
         $suffix = 1;
1761 1761
         do {
1762
-            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1762
+            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
1763 1763
 
1764 1764
             /** This action is documented in geodirectory_hooks_actions.php */
1765 1765
             $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
 
1772 1772
         //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1773 1773
 
1774
-        $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1774
+        $wpdb->query($wpdb->prepare("UPDATE ".$table_prefix."terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1775 1775
 
1776 1776
     }
1777 1777
 	
@@ -1780,18 +1780,18 @@  discard block
 block discarded – undo
1780 1780
 	$post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL;
1781 1781
 	
1782 1782
 	$post_types = geodir_get_posttypes();
1783
-	if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) {		
1784
-		$posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id)));
1783
+	if ($post_type && in_array($post_type, $post_types) && $post_type.'_tags' == $taxonomy) {		
1784
+		$posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id = %d", array($tt_id)));
1785 1785
 		
1786 1786
 		if (!empty($posts_obj)) {
1787 1787
 			foreach ($posts_obj as $post_obj) {
1788 1788
 				$post_id = $post_obj->object_id;
1789 1789
 				
1790
-				$raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names'));
1790
+				$raw_tags = wp_get_object_terms($post_id, $post_type.'_tags', array('fields' => 'names'));
1791 1791
 				$post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : '';
1792 1792
 				
1793
-				$listing_table = $plugin_prefix . $post_type . '_detail';
1794
-				$wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id)));
1793
+				$listing_table = $plugin_prefix.$post_type.'_detail';
1794
+				$wpdb->query($wpdb->prepare("UPDATE ".$listing_table." SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id)));
1795 1795
 			}
1796 1796
 		}
1797 1797
 	}
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
     if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1826 1826
         return $slug_exists = true;
1827 1827
 
1828
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1828
+    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1829 1829
         return $slug_exists = true;
1830 1830
 
1831 1831
     return $slug_exists;
@@ -1866,43 +1866,43 @@  discard block
 block discarded – undo
1866 1866
 
1867 1867
 
1868 1868
     $gd_page = '';
1869
-    if(geodir_is_page('home')){
1869
+    if (geodir_is_page('home')) {
1870 1870
         $gd_page = 'home';
1871 1871
         $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1872 1872
     }
1873
-    elseif(geodir_is_page('detail')){
1873
+    elseif (geodir_is_page('detail')) {
1874 1874
         $gd_page = 'detail';
1875 1875
         $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1876 1876
     }
1877
-    elseif(geodir_is_page('pt')){
1877
+    elseif (geodir_is_page('pt')) {
1878 1878
         $gd_page = 'pt';
1879 1879
         $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1880 1880
     }
1881
-    elseif(geodir_is_page('listing')){
1881
+    elseif (geodir_is_page('listing')) {
1882 1882
         $gd_page = 'listing';
1883 1883
         $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1884 1884
     }
1885
-    elseif(geodir_is_page('location')){
1885
+    elseif (geodir_is_page('location')) {
1886 1886
         $gd_page = 'location';
1887 1887
         $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1888 1888
     }
1889
-    elseif(geodir_is_page('search')){
1889
+    elseif (geodir_is_page('search')) {
1890 1890
         $gd_page = 'search';
1891 1891
         $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1892 1892
     }
1893
-    elseif(geodir_is_page('add-listing')){
1893
+    elseif (geodir_is_page('add-listing')) {
1894 1894
         $gd_page = 'add-listing';
1895 1895
         $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1896 1896
     }
1897
-    elseif(geodir_is_page('author')){
1897
+    elseif (geodir_is_page('author')) {
1898 1898
         $gd_page = 'author';
1899 1899
         $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1900 1900
     }
1901
-    elseif(geodir_is_page('login')){
1901
+    elseif (geodir_is_page('login')) {
1902 1902
         $gd_page = 'login';
1903 1903
         $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1904 1904
     }
1905
-    elseif(geodir_is_page('listing-success')){
1905
+    elseif (geodir_is_page('listing-success')) {
1906 1906
         $gd_page = 'listing-success';
1907 1907
         $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1908 1908
     }
@@ -1934,12 +1934,12 @@  discard block
 block discarded – undo
1934 1934
 
1935 1935
     if (!get_option('geodir_set_post_attachments')) {
1936 1936
 
1937
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1938
-        require_once(ABSPATH . 'wp-admin/includes/file.php');
1937
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1938
+        require_once(ABSPATH.'wp-admin/includes/file.php');
1939 1939
 
1940 1940
         $all_postypes = geodir_get_posttypes();
1941 1941
 
1942
-        foreach($all_postypes as $post_type){
1942
+        foreach ($all_postypes as $post_type) {
1943 1943
             $args = array(
1944 1944
                 'posts_per_page' => -1,
1945 1945
                 'post_type' => $post_type,
@@ -2033,7 +2033,7 @@  discard block
 block discarded – undo
2033 2033
 {
2034 2034
     $user_id = get_current_user_id();
2035 2035
 
2036
-    if(!$user_id){return $post;}
2036
+    if (!$user_id) {return $post; }
2037 2037
 
2038 2038
     $gd_post_types = geodir_get_posttypes();
2039 2039
 
@@ -2142,7 +2142,7 @@  discard block
 block discarded – undo
2142 2142
 
2143 2143
         if (array_key_exists('post_video', $tabs_arr)) {
2144 2144
 
2145
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2145
+            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from ".GEODIR_CUSTOM_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2146 2146
 
2147 2147
             if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2148 2148
                 $tabs_arr['post_video']['heading_text'] = $field_title;
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
 
2151 2151
         if (array_key_exists('special_offers', $tabs_arr)) {
2152 2152
 
2153
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2153
+            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from ".GEODIR_CUSTOM_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2154 2154
 
2155 2155
             if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2156 2156
                 $tabs_arr['special_offers']['heading_text'] = $field_title;
@@ -2171,7 +2171,7 @@  discard block
 block discarded – undo
2171 2171
  */
2172 2172
 function geodir_remove_template_redirect_actions()
2173 2173
 {
2174
-    if (geodir_is_page('login')){
2174
+    if (geodir_is_page('login')) {
2175 2175
         remove_all_actions('template_redirect');
2176 2176
         remove_action('init', 'avia_modify_front', 10);
2177 2177
     }
@@ -2218,25 +2218,25 @@  discard block
 block discarded – undo
2218 2218
         $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2219 2219
 
2220 2220
         $wpdb->query(
2221
-            $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2221
+            $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d AND file=%s ",
2222 2222
                 array($post_id, $split_img_file_path)
2223 2223
             )
2224 2224
         );
2225 2225
 
2226 2226
         $attachment_data = $wpdb->get_row(
2227
-            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2227
+            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id=%d",
2228 2228
                 array($post_id)
2229 2229
             )
2230 2230
         );
2231 2231
 
2232 2232
         if (!empty($attachment_data)) {
2233
-            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2233
+            $wpdb->query("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order=1 WHERE ID=".$attachment_data->ID);
2234 2234
         }
2235 2235
 
2236 2236
 
2237
-        $table_name = $plugin_prefix . $post_type . '_detail';
2237
+        $table_name = $plugin_prefix.$post_type.'_detail';
2238 2238
 
2239
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2239
+        $wpdb->query("UPDATE ".$table_name." SET featured_image='' WHERE post_id =".$post_id);
2240 2240
 
2241 2241
         geodir_set_wp_featured_image($post_id);
2242 2242
 
@@ -2264,9 +2264,9 @@  discard block
 block discarded – undo
2264 2264
 
2265 2265
     foreach ($all_postypes as $posttype) {
2266 2266
 
2267
-        $tablename = $plugin_prefix . $posttype . '_detail';
2267
+        $tablename = $plugin_prefix.$posttype.'_detail';
2268 2268
 
2269
-        $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2269
+        $get_post_data = $wpdb->get_results("SELECT post_id FROM ".$tablename);
2270 2270
 
2271 2271
         if (!empty($get_post_data)) {
2272 2272
 
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
 
2275 2275
                 $post_id = $data->post_id;
2276 2276
 
2277
-                $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2277
+                $attachment_data = $wpdb->get_results("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id =".$post_id." AND file!=''");
2278 2278
 
2279 2279
                 if (!empty($attachment_data)) {
2280 2280
 
@@ -2291,22 +2291,22 @@  discard block
 block discarded – undo
2291 2291
 
2292 2292
                         $file_name = $file_info['basename'];
2293 2293
 
2294
-                        $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2294
+                        $img_arr['path'] = $uploads_path.$sub_dir.'/'.$file_name;
2295 2295
 
2296 2296
                         if (!file_exists($img_arr['path'])) {
2297 2297
 
2298
-                            $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2298
+                            $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ID=".$attach->ID);
2299 2299
 
2300 2300
                         }
2301 2301
 
2302 2302
                     }
2303 2303
 
2304
-                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2304
+                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id=".$post_id." GROUP BY post_id");
2305 2305
 
2306 2306
                     if (!empty($attachment_data)) {
2307 2307
 
2308 2308
                         if ($attachment_data->ID)
2309
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2309
+                            $wpdb->query("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order=1 WHERE ID=".$attachment_data->ID);
2310 2310
 
2311 2311
                     } else {
2312 2312
 
@@ -2320,7 +2320,7 @@  discard block
 block discarded – undo
2320 2320
 
2321 2321
                     }
2322 2322
 
2323
-                    $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2323
+                    $wpdb->query("UPDATE ".$tablename." SET featured_image='' WHERE post_id =".$post_id);
2324 2324
 
2325 2325
                     geodir_set_wp_featured_image($post_id);
2326 2326
 
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
 {
2350 2350
 
2351 2351
     if (!get_option('geodir_default_rating_star_icon')) {
2352
-        update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2352
+        update_option('geodir_default_rating_star_icon', geodir_plugin_url().'/geodirectory-assets/images/stars.png');
2353 2353
     }
2354 2354
 
2355 2355
 }
@@ -2369,7 +2369,7 @@  discard block
 block discarded – undo
2369 2369
 function geodir_user_post_listing_count($user_id = 0)
2370 2370
 {
2371 2371
     global $wpdb, $plugin_prefix, $current_user;
2372
-    if(!$user_id){
2372
+    if (!$user_id) {
2373 2373
         $user_id = $current_user->ID;
2374 2374
     }
2375 2375
 
@@ -2378,7 +2378,7 @@  discard block
 block discarded – undo
2378 2378
     $user_listing = array();
2379 2379
     if ($user_id && is_array($all_posts) && !empty($all_posts)) {
2380 2380
         foreach ($all_posts as $ptype) {
2381
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )");
2381
+            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM ".$wpdb->prefix."posts WHERE post_author=".$user_id." AND post_type='".$ptype."' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )");
2382 2382
 
2383 2383
             if ($total_posts > 0) {
2384 2384
                 $user_listing[$ptype] = $total_posts;
@@ -2419,19 +2419,19 @@  discard block
 block discarded – undo
2419 2419
 
2420 2420
         $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2421 2421
         //remove video and special offers if it is already set to show
2422
-        if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2422
+        if (isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']) {
2423 2423
             $unset_video = true;
2424 2424
         }
2425 2425
 
2426
-        if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2426
+        if (isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']) {
2427 2427
             $unset_special_offers = true;
2428 2428
         }
2429
-        if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2430
-            foreach($custom_fields as $key => $custom_field){
2431
-                if($custom_field['name']=='geodir_video' && isset($unset_video)){
2429
+        if (isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)) {
2430
+            foreach ($custom_fields as $key => $custom_field) {
2431
+                if ($custom_field['name'] == 'geodir_video' && isset($unset_video)) {
2432 2432
                     unset($custom_fields[$key]);
2433 2433
                 }
2434
-                if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2434
+                if ($custom_field['name'] == 'geodir_special_offers' && isset($unset_special_offers)) {
2435 2435
                     unset($custom_fields[$key]);
2436 2436
                 }
2437 2437
             }
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
                     $post->{$field_name} = $_REQUEST[$field_name];
2449 2449
                 }
2450 2450
 
2451
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2451
+                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) {
2452 2452
                     if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2453 2453
                         continue;
2454 2454
                     }
@@ -2481,7 +2481,7 @@  discard block
 block discarded – undo
2481 2481
                     $post->{$field_name} = $_REQUEST[$field_name];
2482 2482
                 }
2483 2483
 
2484
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2484
+                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) {
2485 2485
                     $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2486 2486
                     $site_title = trim($field['site_title']);
2487 2487
                     $type = $field;
@@ -2497,21 +2497,21 @@  discard block
 block discarded – undo
2497 2497
                         $variables_array['label'] = __($type['site_title'], 'geodirectory');
2498 2498
                         $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2499 2499
 
2500
-                    }else{
2500
+                    } else {
2501 2501
                         $i = 0;
2502 2502
                         $fieldset_count++;
2503 2503
                         $field_set_start = 1;
2504
-                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2504
+                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_'.$fieldset_count;
2505 2505
                         $fieldset_arr[$fieldset_count]['label'] = $label;
2506 2506
                     }
2507 2507
 
2508 2508
 
2509
-                    if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2509
+                    if (isset($type['extra_fields'])) {$extra_fields = $type['extra_fields']; }
2510 2510
                     $type = stripslashes_deep($type); // strip slashes
2511
-                    if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2511
+                    if (isset($type['extra_fields'])) {$type['extra_fields'] = $extra_fields; }
2512 2512
                     $html = '';
2513 2513
                     $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2514
-                    if($html_var=='post'){$html_var='post_address';}
2514
+                    if ($html_var == 'post') {$html_var = 'post_address'; }
2515 2515
                     $field_icon = geodir_field_icon_proccess($type);
2516 2516
                     $filed_type = $type['type'];
2517 2517
 
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
                      * @param string $fields_location The location the field is to be show.
2525 2525
                      * @param array $type The array of field values.
2526 2526
                      */
2527
-                    $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2527
+                    $html = apply_filters("geodir_custom_field_output_{$filed_type}", $html, $fields_location, $type);
2528 2528
 
2529 2529
 
2530 2530
                     /**
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
                                  * @param string $htmlvar_name The field HTML var name.
2571 2571
                                  */
2572 2572
                                 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2573
-                                'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2573
+                                'tab_content' => '<div class="geodir-company_info field-group xxx">'.$fieldset_html.'</div>'
2574 2574
                             );
2575 2575
                         }
2576 2576
                     } else {
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
             }
2635 2635
             $status .= ")</strong>";
2636 2636
 
2637
-            $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2637
+            $html = '<span class="geodir-post-status">'.$status_icon.' <font class="geodir-status-label">'.__('Status: ', 'geodirectory').'</font>'.$status.'</span>';
2638 2638
         }
2639 2639
     }
2640 2640
 
@@ -2703,7 +2703,7 @@  discard block
 block discarded – undo
2703 2703
  * @return array Modified class array.
2704 2704
  */
2705 2705
 function geodir_body_class_active_map($classes = array()) {
2706
-    $classes[] = 'gd-map-' . geodir_map_name();
2706
+    $classes[] = 'gd-map-'.geodir_map_name();
2707 2707
 
2708 2708
     return $classes;
2709 2709
 }
@@ -2718,7 +2718,7 @@  discard block
 block discarded – undo
2718 2718
  * @return string Modified class string.
2719 2719
  */
2720 2720
 function geodir_admin_body_class_active_map($class = '') {    
2721
-    $class .= ' gd-map-' . geodir_map_name();
2721
+    $class .= ' gd-map-'.geodir_map_name();
2722 2722
 
2723 2723
     return $class;
2724 2724
 }
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
  * @return array Translation texts.
2739 2739
  */
2740 2740
 function geodir_load_gd_options_text_translation($translation_texts = array()) {
2741
-    $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2741
+    $translation_texts = !empty($translation_texts) && is_array($translation_texts) ? $translation_texts : array();
2742 2742
 
2743 2743
     $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2744 2744
 
@@ -2804,17 +2804,17 @@  discard block
 block discarded – undo
2804 2804
  * @param array $args The array of menu arguments.
2805 2805
  * @return array The modified arguments.
2806 2806
  */
2807
-function geodir_add_nav_menu_class( $args )
2807
+function geodir_add_nav_menu_class($args)
2808 2808
 {
2809 2809
 
2810
-        if(isset($args['menu_class'])){
2810
+        if (isset($args['menu_class'])) {
2811 2811
             $args['menu_class'] = $args['menu_class']." gd-menu-z";
2812 2812
         }
2813 2813
     
2814 2814
     return $args;
2815 2815
 }
2816 2816
 
2817
-add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' );
2817
+add_filter('wp_nav_menu_args', 'geodir_add_nav_menu_class');
2818 2818
 
2819 2819
 /**
2820 2820
  * Filters WordPress locale ID.
@@ -2854,10 +2854,10 @@  discard block
 block discarded – undo
2854 2854
         }
2855 2855
         
2856 2856
         add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2857
-        add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2858
-		add_action( 'geodir_after_search_form', 'geodir_wpml_add_language_input_field' );
2857
+        add_action('geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1);
2858
+		add_action('geodir_after_search_form', 'geodir_wpml_add_language_input_field');
2859 2859
         if (is_admin()) {
2860
-            add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2860
+            add_filter('geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1);
2861 2861
         }
2862 2862
     }
2863 2863
 }
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
         }        
2887 2887
         
2888 2888
         if (!empty($keep_vars)) {
2889
-            foreach ( $languages as $code => $url) {
2889
+            foreach ($languages as $code => $url) {
2890 2890
                 $filter_url = $url['url'];
2891 2891
                 
2892 2892
                 foreach ($keep_vars as $var) {
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
 
2906 2906
     return $languages;
2907 2907
 }
2908
-add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 );
2908
+add_filter('icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1);
2909 2909
 
2910 2910
 /**
2911 2911
  * Remove Yoast SEO hook if disabled on GD pages.
@@ -2913,18 +2913,18 @@  discard block
 block discarded – undo
2913 2913
  * @since 1.6.18
2914 2914
  *
2915 2915
  */
2916
-function geodir_remove_yoast_seo_metas(){
2917
-    if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2916
+function geodir_remove_yoast_seo_metas() {
2917
+    if (class_exists('WPSEO_Frontend') && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas()) {
2918 2918
         $wpseo = WPSEO_Frontend::get_instance();
2919 2919
         
2920
-        remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2921
-        remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2922
-        remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2923
-        remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2924
-        remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2925
-        remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2920
+        remove_action('wp_head', array($wpseo, 'metadesc'), 6);
2921
+        remove_action('wp_head', array($wpseo, 'metakeywords'), 11);
2922
+        remove_filter('pre_get_document_title', array($wpseo, 'title'), 15);
2923
+        remove_filter('wp_title', array($wpseo, 'title'), 15, 3);
2924
+        remove_filter('thematic_doctitle', array($wpseo, 'title'), 15);
2925
+        remove_filter('woo_title', array($wpseo, 'fix_woo_title'), 99);
2926 2926
         
2927
-        remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2927
+        remove_action('template_redirect', 'wpseo_frontend_head_init', 999);
2928 2928
     }
2929 2929
 }
2930 2930
 
@@ -2939,22 +2939,22 @@  discard block
 block discarded – undo
2939 2939
  *
2940 2940
  */
2941 2941
  function geodir_wpml_ajax_set_guest_lang() {    
2942
-    if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2943
-        if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2942
+    if (geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in()) {
2943
+        if (empty($_GET['lang']) && !(!empty($_SERVER['REQUEST_URI']) && preg_match('@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename(preg_replace('@\?.*$@', '', $_SERVER['REQUEST_URI']))))) {
2944 2944
             global $sitepress;
2945 2945
             
2946 2946
             $referer = wp_get_referer();
2947 2947
             
2948 2948
             $current_lang = $sitepress->get_current_language();
2949
-            $referrer_lang = $sitepress->get_language_from_url( $referer );
2949
+            $referrer_lang = $sitepress->get_language_from_url($referer);
2950 2950
             
2951
-            if ( $referrer_lang && $current_lang != $referrer_lang ) {
2951
+            if ($referrer_lang && $current_lang != $referrer_lang) {
2952 2952
                 $_GET['lang'] = $referrer_lang;
2953 2953
             }
2954 2954
         }
2955 2955
     }
2956 2956
 }
2957
-add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 );
2957
+add_action('plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1);
2958 2958
 
2959 2959
 /**
2960 2960
  * Change country slug czech-republic to czechia and redirect.
@@ -2975,18 +2975,18 @@  discard block
 block discarded – undo
2975 2975
         }
2976 2976
         
2977 2977
         $redirect = false;
2978
-        if (strpos($current_url, '/' . $search . '/') !== false) {
2978
+        if (strpos($current_url, '/'.$search.'/') !== false) {
2979 2979
             $redirect = true;
2980
-            $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2980
+            $current_url = preg_replace('/\/'.$search.'\//', '/'.$replace.'/', $current_url, 1);
2981 2981
         }
2982 2982
         
2983 2983
         if ($has_slash != "/") {
2984 2984
             $current_url = trim($current_url, '/');
2985 2985
         }
2986 2986
         
2987
-        if (strpos($current_url, 'gd_country=' . $search) !== false) {
2987
+        if (strpos($current_url, 'gd_country='.$search) !== false) {
2988 2988
             $redirect = true;
2989
-            $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2989
+            $current_url = str_replace('gd_country='.$search, 'gd_country='.$replace, $current_url);
2990 2990
         }
2991 2991
 
2992 2992
         if ($redirect) {
@@ -3012,10 +3012,10 @@  discard block
 block discarded – undo
3012 3012
  * @param int    $post_parent   Post parent ID
3013 3013
  * @param string $original_slug The original post slug.
3014 3014
  */
3015
-function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
3015
+function geodir_check_post_to_term_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) {
3016 3016
     global $wpdb, $sitepress;
3017 3017
     
3018
-    if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
3018
+    if ($post_type && strpos($post_type, 'gd_') === 0) {
3019 3019
         $wpml_post_join = "";
3020 3020
         $wpml_post_where = "";
3021 3021
         $wpml_term_join = "";
@@ -3029,28 +3029,28 @@  discard block
 block discarded – undo
3029 3029
             }
3030 3030
             
3031 3031
             $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3032
-            $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'";
3032
+            $wpml_post_where = " AND icl_t.language_code = '".$post_language."'";
3033 3033
             
3034 3034
             $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)";
3035
-            $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'";
3035
+            $wpml_term_where = " AND icl_t.language_code = '".$post_language."'";
3036 3036
         }
3037 3037
 
3038
-        $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) );
3038
+        $term_slug_check = $wpdb->get_var($wpdb->prepare("SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '".$post_type."category' OR tt.taxonomy = '".$post_type."_tags' ) {$wpml_term_where} LIMIT 1", $slug));
3039 3039
 
3040
-        if ( $term_slug_check ) {
3040
+        if ($term_slug_check) {
3041 3041
             $suffix = 1;
3042 3042
             
3043 3043
             do {
3044
-                $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3044
+                $alt_slug = _truncate_post_slug($original_slug, 200 - (strlen($suffix) + 1))."-$suffix";
3045 3045
                 
3046
-                $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) );
3046
+                $term_check = $wpdb->get_var($wpdb->prepare("SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '".$post_type."category' OR tt.taxonomy = '".$post_type."_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug));
3047 3047
                 
3048
-                $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3048
+                $post_check = !$term_check && $wpdb->get_var($wpdb->prepare("SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID));
3049 3049
                 
3050 3050
                 $term_slug_check = $term_check || $post_check;
3051 3051
                 
3052 3052
                 $suffix++;
3053
-            } while ( $term_slug_check );
3053
+            } while ($term_slug_check);
3054 3054
             
3055 3055
             $slug = $alt_slug;
3056 3056
         }
@@ -3058,7 +3058,7 @@  discard block
 block discarded – undo
3058 3058
     
3059 3059
     return $slug;
3060 3060
 }
3061
-add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6 );
3061
+add_filter('wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6);
3062 3062
 
3063 3063
 /**
3064 3064
  * Check whether a post name with slug exists or not.
@@ -3075,51 +3075,51 @@  discard block
 block discarded – undo
3075 3075
  * @param int $term_id The term ID.
3076 3076
  * @return bool true when exists. false when not exists.
3077 3077
  */
3078
-function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) {
3078
+function geodir_check_term_to_post_slug($slug_exists, $slug, $term_id) {
3079 3079
     global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress;
3080 3080
     
3081
-    if ( $slug_exists ) {
3081
+    if ($slug_exists) {
3082 3082
         return $slug_exists;
3083 3083
     }
3084 3084
     
3085
-    if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) {
3085
+    if (!empty($gd_term_taxonomy) && isset($gd_term_taxonomy[$term_id])) {
3086 3086
         $taxonomy = $gd_term_taxonomy[$term_id];
3087 3087
     } else {
3088
-        $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3088
+        $taxonomy = $wpdb->get_var($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id));
3089 3089
         $gd_term_taxonomy[$term_id] = $taxonomy;
3090 3090
     }
3091 3091
     
3092
-    if ( empty($taxonomy) ) {
3092
+    if (empty($taxonomy)) {
3093 3093
         return $slug_exists;
3094 3094
     }
3095 3095
     
3096
-    if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3096
+    if (!empty($gd_term_post_type) && $gd_term_post_type[$term_id]) {
3097 3097
         $post_type = $gd_term_post_type[$term_id];
3098 3098
     } else {
3099
-        $taxonomy_obj = get_taxonomy( $taxonomy );
3100
-        $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3099
+        $taxonomy_obj = get_taxonomy($taxonomy);
3100
+        $post_type = !empty($taxonomy_obj->object_type) ? $taxonomy_obj->object_type[0] : NULL;
3101 3101
     }
3102 3102
     
3103 3103
     $wpml_post_join = "";
3104 3104
     $wpml_post_where = "";
3105 3105
     
3106 3106
     if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) {
3107
-        $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language();
3107
+        $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_'.$taxonomy) : $sitepress->get_current_language();
3108 3108
         if (!$term_language) {
3109 3109
             $term_language = $sitepress->get_current_language();
3110 3110
         }
3111 3111
         
3112 3112
         $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)";
3113
-        $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'";
3113
+        $wpml_post_where = " AND icl_t.language_code = '".$term_language."'";
3114 3114
     }
3115 3115
     
3116
-    if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s  {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) {
3116
+    if ($post_type && $wpdb->get_var($wpdb->prepare("SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s  {$wpml_post_where} LIMIT 1", $slug, $post_type))) {
3117 3117
         $slug_exists = true;
3118 3118
     }
3119 3119
 
3120 3120
     return $slug_exists;
3121 3121
 }
3122
-add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 );
3122
+add_filter('geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3);
3123 3123
 
3124 3124
 /**
3125 3125
  * Add hidden WPML language input field.
@@ -3133,7 +3133,7 @@  discard block
 block discarded – undo
3133 3133
 function geodir_wpml_add_language_input_field() {
3134 3134
 	global $sitepress;
3135 3135
 
3136
-	if ( function_exists( 'wpml_add_language_form_field_action' ) && WPML_LANGUAGE_NEGOTIATION_TYPE_PARAMETER === (int) $sitepress->get_setting( 'language_negotiation_type' ) ) {
3136
+	if (function_exists('wpml_add_language_form_field_action') && WPML_LANGUAGE_NEGOTIATION_TYPE_PARAMETER === (int) $sitepress->get_setting('language_negotiation_type')) {
3137 3137
 		wpml_add_language_form_field_action();
3138 3138
 	}
3139 3139
 }
@@ -3153,21 +3153,21 @@  discard block
 block discarded – undo
3153 3153
  *                              by the parent function. WP_Error otherwise.
3154 3154
  * @param array   $object_ids   List of term object IDs.
3155 3155
  */
3156
-function geodir_on_delete_term( $term, $tt_id, $taxonomy = '', $deleted_term = array(), $object_ids = array() ) {
3156
+function geodir_on_delete_term($term, $tt_id, $taxonomy = '', $deleted_term = array(), $object_ids = array()) {
3157 3157
 	global $wpdb, $plugin_prefix;
3158 3158
 
3159
-	if ( ! empty( $object_ids ) && strpos( $taxonomy, 'gd_' ) === 0 && substr( $taxonomy , -5 ) == '_tags' && ( $taxonomy_obj = get_taxonomy( $taxonomy ) ) ) {
3160
-		$post_type = !empty( $taxonomy_obj ) ? $taxonomy_obj->object_type[0] : '';
3159
+	if (!empty($object_ids) && strpos($taxonomy, 'gd_') === 0 && substr($taxonomy, -5) == '_tags' && ($taxonomy_obj = get_taxonomy($taxonomy))) {
3160
+		$post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : '';
3161 3161
 
3162
-		if ( $post_type ) {
3163
-			$table = $plugin_prefix . $post_type . '_detail';
3162
+		if ($post_type) {
3163
+			$table = $plugin_prefix.$post_type.'_detail';
3164 3164
 		
3165
-			foreach ( $object_ids as $post_id ) {
3166
-				$post_tags = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'names' ) );
3167
-				$post_tags = ! empty( $post_tags ) && ! is_wp_error( $post_tags ) ? array_map( 'trim', $post_tags ) : '';
3168
-				$post_tags = ! empty( $post_tags ) ? implode( ',', array_filter( array_unique( $post_tags ) ) ) : '';
3165
+			foreach ($object_ids as $post_id) {
3166
+				$post_tags = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'names'));
3167
+				$post_tags = !empty($post_tags) && !is_wp_error($post_tags) ? array_map('trim', $post_tags) : '';
3168
+				$post_tags = !empty($post_tags) ? implode(',', array_filter(array_unique($post_tags))) : '';
3169 3169
 
3170
-				$wpdb->query( $wpdb->prepare( "UPDATE {$table} SET post_tags = %s WHERE post_id = %d", array( $post_tags, $post_id ) ) );
3170
+				$wpdb->query($wpdb->prepare("UPDATE {$table} SET post_tags = %s WHERE post_id = %d", array($post_tags, $post_id)));
3171 3171
 			}
3172 3172
 		}
3173 3173
 	}
Please login to merge, or discard this patch.
geodirectory_template_tags.php 3 patches
Braces   +42 added lines, -26 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         </script>
263 263
 
264 264
         <?php
265
-    }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
265
+    } elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
266 266
         echo stripslashes(get_option('geodir_ga_tracking_code'));
267 267
     }
268 268
 }
@@ -301,13 +301,14 @@  discard block
 block discarded – undo
301 301
  */
302 302
 function geodir_add_async_forscript($url)
303 303
 {
304
-    if (strpos($url, '#asyncload')===false)
305
-        return $url;
306
-    else if (is_admin())
307
-        return str_replace('#asyncload', '', $url);
308
-    else
309
-        return str_replace('#asyncload', '', $url)."' async='async";
310
-}
304
+    if (strpos($url, '#asyncload')===false) {
305
+            return $url;
306
+    } else if (is_admin()) {
307
+            return str_replace('#asyncload', '', $url);
308
+    } else {
309
+            return str_replace('#asyncload', '', $url)."' async='async";
310
+    }
311
+    }
311 312
 add_filter('clean_url', 'geodir_add_async_forscript', 11, 1);
312 313
 
313 314
 /**
@@ -375,8 +376,10 @@  discard block
 block discarded – undo
375 376
 
376 377
     $half_pages_to_show = round($pages_to_show / 2);
377 378
 
378
-    if (geodir_is_page('home')) // dont apply default  pagination for geodirectory home page.
379
-        return;
379
+    if (geodir_is_page('home')) {
380
+    	// dont apply default  pagination for geodirectory home page.
381
+        return;
382
+    }
380 383
 
381 384
     if (!is_single()) {
382 385
         if (function_exists('geodir_location_geo_home_link')) {
@@ -496,11 +499,21 @@  discard block
 block discarded – undo
496 499
     }
497 500
     $dist_dif = 1000;
498 501
 
499
-    if ($dist <= 5000) $dist_dif = 500;
500
-    if ($dist <= 1000) $dist_dif = 100;
501
-    if ($dist <= 500) $dist_dif = 50;
502
-    if ($dist <= 100) $dist_dif = 10;
503
-    if ($dist <= 50) $dist_dif = 5;
502
+    if ($dist <= 5000) {
503
+    	$dist_dif = 500;
504
+    }
505
+    if ($dist <= 1000) {
506
+    	$dist_dif = 100;
507
+    }
508
+    if ($dist <= 500) {
509
+    	$dist_dif = 50;
510
+    }
511
+    if ($dist <= 100) {
512
+    	$dist_dif = 10;
513
+    }
514
+    if ($dist <= 50) {
515
+    	$dist_dif = 5;
516
+    }
504 517
 
505 518
     ?>
506 519
     <script type="text/javascript">
@@ -561,12 +574,14 @@  discard block
 block discarded – undo
561 574
  */
562 575
 function geodir_add_sharelocation_scripts() {
563 576
     $default_search_for_text = SEARCH_FOR_TEXT;
564
-    if (get_option('geodir_search_field_default_text'))
565
-        $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
577
+    if (get_option('geodir_search_field_default_text')) {
578
+            $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
579
+    }
566 580
 
567 581
     $default_near_text = NEAR_TEXT;
568
-    if (get_option('geodir_near_field_default_text'))
569
-        $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
582
+    if (get_option('geodir_near_field_default_text')) {
583
+            $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
584
+    }
570 585
     
571 586
     $search_location = geodir_get_default_location();
572 587
     
@@ -835,13 +850,14 @@  discard block
 block discarded – undo
835 850
  */
836 851
 function geodir_fontawesome_defer($url)
837 852
 {
838
-    if (strpos($url, 'use.fontawesome.com/releases/')===false)
839
-        return $url;
840
-    else if (is_admin())
841
-        return str_replace('#faload', '', $url);
842
-    else
843
-        return $url."' data-search-pseudo-elements defer='defer";
844
-}
853
+    if (strpos($url, 'use.fontawesome.com/releases/')===false) {
854
+            return $url;
855
+    } else if (is_admin()) {
856
+            return str_replace('#faload', '', $url);
857
+    } else {
858
+            return $url."' data-search-pseudo-elements defer='defer";
859
+    }
860
+    }
845 861
 //add_filter('clean_url', 'geodir_fontawesome_defer', 11, 1); // let users add this as a snippet if they need it
846 862
 
847 863
 /**
Please login to merge, or discard this patch.
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -36,177 +36,177 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function geodir_templates_scripts()
38 38
 {
39
-    $is_detail_page = false;
40
-    $geodir_map_name = geodir_map_name();
39
+	$is_detail_page = false;
40
+	$geodir_map_name = geodir_map_name();
41 41
 
42
-    if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
43
-        $is_detail_page = true;
44
-    }
42
+	if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
43
+		$is_detail_page = true;
44
+	}
45 45
 
46
-    wp_enqueue_script('jquery');
46
+	wp_enqueue_script('jquery');
47 47
 
48
-    wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
49
-    wp_enqueue_script('geodirectory-script');
48
+	wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
49
+	wp_enqueue_script('geodirectory-script');
50 50
 
51
-    $geodir_vars_data = array(
52
-        'siteurl' => get_option('siteurl'),
53
-        'geodir_plugin_url' => geodir_plugin_url(),
54
-        'geodir_lazy_load' => get_option('geodir_lazy_load',1),
55
-        'geodir_ajax_url' => geodir_get_ajax_url(),
56
-        'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
57
-        'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue
51
+	$geodir_vars_data = array(
52
+		'siteurl' => get_option('siteurl'),
53
+		'geodir_plugin_url' => geodir_plugin_url(),
54
+		'geodir_lazy_load' => get_option('geodir_lazy_load',1),
55
+		'geodir_ajax_url' => geodir_get_ajax_url(),
56
+		'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
57
+		'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue
58 58
 		'lightBox_txtImage' => addslashes(__('Image', 'geodirectory')),
59 59
 		'lightBox_txtOf' => addslashes(__('of', 'geodirectory')),
60
-    );
61
-
62
-    /**
63
-     * Filter the `geodir_var` data array that outputs the  wp_localize_script() translations and variables.
64
-     *
65
-     * This is used by addons to add JS translatable variables.
66
-     *
67
-     * @since 1.4.4
68
-     * @param array $geodir_vars_data {
69
-     *    geodir var data used by addons to add JS translatable variables.
70
-     *
71
-     *    @type string $siteurl Site url.
72
-     *    @type string $geodir_plugin_url Geodirectory core plugin url.
73
-     *    @type string $geodir_ajax_url Geodirectory plugin ajax url.
74
-     *    @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?.
75
-     *    @type int $is_rtl Checks if current locale is RTL.
76
-     *
77
-     * }
78
-     */
79
-    $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
80
-
81
-    wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
82
-
83
-    wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
84
-    if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
85
-
86
-    wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
87
-    wp_enqueue_script('geodirectory-lightbox-jquery');
88
-
89
-    wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
90
-    if ($is_detail_page) {
91
-        wp_enqueue_script('geodirectory-jquery-simplemodal');
92
-    }
60
+	);
61
+
62
+	/**
63
+	 * Filter the `geodir_var` data array that outputs the  wp_localize_script() translations and variables.
64
+	 *
65
+	 * This is used by addons to add JS translatable variables.
66
+	 *
67
+	 * @since 1.4.4
68
+	 * @param array $geodir_vars_data {
69
+	 *    geodir var data used by addons to add JS translatable variables.
70
+	 *
71
+	 *    @type string $siteurl Site url.
72
+	 *    @type string $geodir_plugin_url Geodirectory core plugin url.
73
+	 *    @type string $geodir_ajax_url Geodirectory plugin ajax url.
74
+	 *    @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?.
75
+	 *    @type int $is_rtl Checks if current locale is RTL.
76
+	 *
77
+	 * }
78
+	 */
79
+	$geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
80
+
81
+	wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
82
+
83
+	wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
84
+	if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
85
+
86
+	wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
87
+	wp_enqueue_script('geodirectory-lightbox-jquery');
88
+
89
+	wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
90
+	if ($is_detail_page) {
91
+		wp_enqueue_script('geodirectory-jquery-simplemodal');
92
+	}
93 93
 
94
-    if (in_array($geodir_map_name, array('auto', 'google'))) {
95
-        $map_lang = "&language=" . geodir_get_map_default_language();
96
-        $map_key = "&key=" . geodir_get_map_api_key();
97
-        /**
98
-         * Filter the variables that are added to the end of the google maps script call.
99
-         *
100
-         * This i used to change things like google maps language etc.
101
-         *
102
-         * @since 1.0.0
103
-         * @param string $var The string to filter, default is empty string.
104
-         */
105
-        $map_extra = apply_filters('geodir_googlemap_script_extra', '');
106
-        wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
94
+	if (in_array($geodir_map_name, array('auto', 'google'))) {
95
+		$map_lang = "&language=" . geodir_get_map_default_language();
96
+		$map_key = "&key=" . geodir_get_map_api_key();
97
+		/**
98
+		 * Filter the variables that are added to the end of the google maps script call.
99
+		 *
100
+		 * This i used to change things like google maps language etc.
101
+		 *
102
+		 * @since 1.0.0
103
+		 * @param string $var The string to filter, default is empty string.
104
+		 */
105
+		$map_extra = apply_filters('geodir_googlemap_script_extra', '');
106
+		wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
107 107
         
108
-        // Overlapping Marker Spiderfier
109
-        wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
110
-        wp_enqueue_script('geodirectory-g-overlappingmarker-script');
111
-    }
108
+		// Overlapping Marker Spiderfier
109
+		wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
110
+		wp_enqueue_script('geodirectory-g-overlappingmarker-script');
111
+	}
112 112
     
113
-    if ($geodir_map_name == 'osm') {
114
-        // Leaflet OpenStreetMap
115
-        wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
116
-        wp_enqueue_style('geodirectory-leaflet-style');
113
+	if ($geodir_map_name == 'osm') {
114
+		// Leaflet OpenStreetMap
115
+		wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
116
+		wp_enqueue_style('geodirectory-leaflet-style');
117 117
             
118
-        wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
119
-        wp_enqueue_script('geodirectory-leaflet-script');
118
+		wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
119
+		wp_enqueue_script('geodirectory-leaflet-script');
120 120
         
121
-        wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
122
-        wp_enqueue_script('geodirectory-leaflet-geo-script');
121
+		wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
122
+		wp_enqueue_script('geodirectory-leaflet-geo-script');
123 123
         
124
-        if ($is_detail_page) {
125
-            wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
126
-            wp_enqueue_style('geodirectory-leaflet-routing-style');
124
+		if ($is_detail_page) {
125
+			wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
126
+			wp_enqueue_style('geodirectory-leaflet-routing-style');
127 127
                 
128
-            wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
129
-            wp_enqueue_script('geodirectory-leaflet-routing-script');
130
-        }
128
+			wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
129
+			wp_enqueue_script('geodirectory-leaflet-routing-script');
130
+		}
131 131
         
132
-        // Overlapping Marker Spiderfier Leaflet
133
-        wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
134
-        wp_enqueue_script('geodirectory-o-overlappingmarker-script');
135
-    }
136
-    wp_enqueue_script( 'jquery-ui-autocomplete' );
132
+		// Overlapping Marker Spiderfier Leaflet
133
+		wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
134
+		wp_enqueue_script('geodirectory-o-overlappingmarker-script');
135
+	}
136
+	wp_enqueue_script( 'jquery-ui-autocomplete' );
137 137
     
138
-    wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
139
-    wp_enqueue_script('geodirectory-goMap-script');
140
-
141
-    wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
142
-    wp_enqueue_script('chosen');
143
-
144
-    wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
145
-    wp_enqueue_script('geodirectory-choose-ajax');
146
-
147
-    wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
148
-
149
-    if (is_page() && geodir_is_page('add-listing')) {
150
-        // SCRIPT FOR UPLOAD
151
-        wp_enqueue_script('plupload-all');
152
-        wp_enqueue_script('jquery-ui-sortable');
153
-
154
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
155
-        wp_enqueue_script('geodirectory-plupload-script');
156
-        // SCRIPT FOR UPLOAD END
157
-
158
-        // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls
159
-        if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
160
-            $ajax_url = admin_url('admin-ajax.php');
161
-        } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
162
-            $ajax_url = admin_url('admin-ajax.php');
163
-        } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
164
-            $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
165
-        } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
166
-            $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
167
-        } else {
168
-            $ajax_url = admin_url('admin-ajax.php');
169
-        }
138
+	wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
139
+	wp_enqueue_script('geodirectory-goMap-script');
140
+
141
+	wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
142
+	wp_enqueue_script('chosen');
143
+
144
+	wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
145
+	wp_enqueue_script('geodirectory-choose-ajax');
146
+
147
+	wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
148
+
149
+	if (is_page() && geodir_is_page('add-listing')) {
150
+		// SCRIPT FOR UPLOAD
151
+		wp_enqueue_script('plupload-all');
152
+		wp_enqueue_script('jquery-ui-sortable');
153
+
154
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
155
+		wp_enqueue_script('geodirectory-plupload-script');
156
+		// SCRIPT FOR UPLOAD END
157
+
158
+		// check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls
159
+		if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
160
+			$ajax_url = admin_url('admin-ajax.php');
161
+		} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
162
+			$ajax_url = admin_url('admin-ajax.php');
163
+		} elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
164
+			$ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
165
+		} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
166
+			$ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
167
+		} else {
168
+			$ajax_url = admin_url('admin-ajax.php');
169
+		}
170 170
 
171
-        // place js config array for plupload
172
-        $plupload_init = array(
173
-            'runtimes' => 'html5,silverlight,browserplus,gears,html4',
174
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
175
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
176
-            'drop_element' => 'dropbox', // will be adjusted per uploader
177
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
178
-            'multiple_queues' => true,
179
-            'max_file_size' => geodir_max_upload_size(),
180
-            'url' => $ajax_url,
181
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
182
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
183
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
184
-            'multipart' => true,
185
-            'urlstream_upload' => true,
186
-            'multi_selection' => false, // will be added per uploader
187
-            // additional post data to send to our ajax hook
188
-            'multipart_params' => array(
189
-                '_ajax_nonce' => "", // will be added per uploader
190
-                'action' => 'plupload_action', // the ajax action name
191
-                'imgid' => 0 // will be added per uploader
192
-            )
193
-        );
194
-        $base_plupload_config = json_encode($plupload_init);
195
-
196
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
197
-            'upload_img_size' => geodir_max_upload_size());
198
-
199
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
200
-
201
-        wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
202
-    } // End if for add place page
203
-
204
-    wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
205
-    if ($is_detail_page) {
171
+		// place js config array for plupload
172
+		$plupload_init = array(
173
+			'runtimes' => 'html5,silverlight,browserplus,gears,html4',
174
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
175
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
176
+			'drop_element' => 'dropbox', // will be adjusted per uploader
177
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
178
+			'multiple_queues' => true,
179
+			'max_file_size' => geodir_max_upload_size(),
180
+			'url' => $ajax_url,
181
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
182
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
183
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
184
+			'multipart' => true,
185
+			'urlstream_upload' => true,
186
+			'multi_selection' => false, // will be added per uploader
187
+			// additional post data to send to our ajax hook
188
+			'multipart_params' => array(
189
+				'_ajax_nonce' => "", // will be added per uploader
190
+				'action' => 'plupload_action', // the ajax action name
191
+				'imgid' => 0 // will be added per uploader
192
+			)
193
+		);
194
+		$base_plupload_config = json_encode($plupload_init);
195
+
196
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
197
+			'upload_img_size' => geodir_max_upload_size());
198
+
199
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
200
+
201
+		wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
202
+	} // End if for add place page
203
+
204
+	wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
205
+	if ($is_detail_page) {
206 206
 		wp_enqueue_script('geodirectory-post-custom-js');
207 207
 	}
208 208
 
209
-    // font awesome rating script
209
+	// font awesome rating script
210 210
 	if (get_option('geodir_reviewrating_enable_font_awesome')) {
211 211
 		wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
212 212
 		wp_enqueue_script('geodir-barrating-js');
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 		wp_enqueue_script('geodir-jRating-js');
216 216
 	}
217 217
 
218
-    wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
219
-    wp_enqueue_script('geodir-on-document-load');
218
+	wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
219
+	wp_enqueue_script('geodir-on-document-load');
220 220
 
221
-    wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
222
-    wp_enqueue_script('google-geometa');
221
+	wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
222
+	wp_enqueue_script('google-geometa');
223 223
 }
224 224
 
225 225
 /**
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function geodir_header_scripts()
235 235
 {
236
-    echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
237
-    echo stripslashes(get_option('geodir_header_scripts'));
236
+	echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
237
+	echo stripslashes(get_option('geodir_header_scripts'));
238 238
 }
239 239
 
240 240
 /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
  */
248 248
 function geodir_google_analytics_tracking_code()
249 249
 {
250
-    if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
250
+	if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
251 251
 
252 252
         <script>
253 253
             (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
         </script>
263 263
 
264 264
         <?php
265
-    }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
266
-        echo stripslashes(get_option('geodir_ga_tracking_code'));
267
-    }
265
+	}elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
266
+		echo stripslashes(get_option('geodir_ga_tracking_code'));
267
+	}
268 268
 }
269 269
 
270 270
 /**
@@ -278,16 +278,16 @@  discard block
 block discarded – undo
278 278
 function geodir_footer_scripts()
279 279
 {
280 280
 
281
-    echo stripslashes(get_option('geodir_footer_scripts'));
281
+	echo stripslashes(get_option('geodir_footer_scripts'));
282 282
 
283
-    /*
283
+	/*
284 284
      * Apple suck and can't/won't fix bugs: https://bugs.webkit.org/show_bug.cgi?id=136041
285 285
      *
286 286
      * Flexbox wont wrap on ios for search form items
287 287
      */
288
-    if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
289
-        echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
290
-    }
288
+	if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
289
+		echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
290
+	}
291 291
 }
292 292
 
293 293
 
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  */
302 302
 function geodir_add_async_forscript($url)
303 303
 {
304
-    if (strpos($url, '#asyncload')===false)
305
-        return $url;
306
-    else if (is_admin())
307
-        return str_replace('#asyncload', '', $url);
308
-    else
309
-        return str_replace('#asyncload', '', $url)."' async='async";
304
+	if (strpos($url, '#asyncload')===false)
305
+		return $url;
306
+	else if (is_admin())
307
+		return str_replace('#asyncload', '', $url);
308
+	else
309
+		return str_replace('#asyncload', '', $url)."' async='async";
310 310
 }
311 311
 add_filter('clean_url', 'geodir_add_async_forscript', 11, 1);
312 312
 
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
 function geodir_templates_styles()
320 320
 {
321 321
 
322
-    wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
323
-    wp_enqueue_style('geodir-core-scss');
324
-    wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
322
+	wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
323
+	wp_enqueue_style('geodir-core-scss');
324
+	wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
325 325
 
326
-    if(is_rtl()){
327
-    wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
328
-    wp_enqueue_style('geodirectory-frontend-rtl-style');
329
-    }
326
+	if(is_rtl()){
327
+	wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
328
+	wp_enqueue_style('geodirectory-frontend-rtl-style');
329
+	}
330 330
 
331 331
 //    wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.5.0/js/all.js#faload', array('font-awesome-shim'), GEODIRECTORY_VERSION);
332 332
 //    wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.5.0/js/v4-shims.js', array(), GEODIRECTORY_VERSION);
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
  */
345 345
 function geodir_get_sidebar()
346 346
 {
347
-    get_sidebar('geodirectory');
347
+	get_sidebar('geodirectory');
348 348
 }
349 349
 
350 350
 /**
@@ -363,122 +363,122 @@  discard block
 block discarded – undo
363 363
  * @param bool $always_show Do you want to show the pagination always? Default: false.
364 364
  */
365 365
 function geodir_pagination($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
366
-    global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id;
366
+	global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id;
367 367
 
368
-    if (empty($prelabel)) {
369
-        $prelabel = '<strong>&lt;</strong>';
370
-    }
368
+	if (empty($prelabel)) {
369
+		$prelabel = '<strong>&lt;</strong>';
370
+	}
371 371
 
372
-    if (empty($nxtlabel)) {
373
-        $nxtlabel = '<strong>&gt;</strong>';
374
-    }
372
+	if (empty($nxtlabel)) {
373
+		$nxtlabel = '<strong>&gt;</strong>';
374
+	}
375 375
 
376
-    $half_pages_to_show = round($pages_to_show / 2);
376
+	$half_pages_to_show = round($pages_to_show / 2);
377 377
 
378
-    if (geodir_is_page('home')) // dont apply default  pagination for geodirectory home page.
379
-        return;
378
+	if (geodir_is_page('home')) // dont apply default  pagination for geodirectory home page.
379
+		return;
380 380
 
381
-    if (!is_single()) {
382
-        if (function_exists('geodir_location_geo_home_link')) {
383
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
384
-        }
385
-        $numposts = $wp_query->found_posts;
381
+	if (!is_single()) {
382
+		if (function_exists('geodir_location_geo_home_link')) {
383
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
384
+		}
385
+		$numposts = $wp_query->found_posts;
386 386
 
387
-        $max_page = ceil($numposts / $posts_per_page);
387
+		$max_page = ceil($numposts / $posts_per_page);
388 388
 
389
-        if (empty($paged)) {
390
-            $paged = 1;
391
-        }
389
+		if (empty($paged)) {
390
+			$paged = 1;
391
+		}
392 392
         
393
-        $post_type = geodir_get_current_posttype();
394
-        $listing_type_name = get_post_type_plural_label($post_type);
395
-        if (geodir_is_page('listing') || geodir_is_page('search')) {            
396
-            $term = array();
393
+		$post_type = geodir_get_current_posttype();
394
+		$listing_type_name = get_post_type_plural_label($post_type);
395
+		if (geodir_is_page('listing') || geodir_is_page('search')) {            
396
+			$term = array();
397 397
             
398
-            if (is_tax()) {
399
-                $term_id = get_queried_object_id();
400
-                $taxonomy = get_query_var('taxonomy');
398
+			if (is_tax()) {
399
+				$term_id = get_queried_object_id();
400
+				$taxonomy = get_query_var('taxonomy');
401 401
 
402
-                if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
403
-                    $term = get_term($term_id, $post_type . 'category');
404
-                }
405
-            }
402
+				if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
403
+					$term = get_term($term_id, $post_type . 'category');
404
+				}
405
+			}
406 406
             
407
-            if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
408
-                $taxonomy_search = $_REQUEST['s' . $post_type . 'category'];
407
+			if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
408
+				$taxonomy_search = $_REQUEST['s' . $post_type . 'category'];
409 409
                 
410
-                if (!is_array($taxonomy_search)) {
411
-                    $term = get_term((int)$taxonomy_search, $post_type . 'category');
412
-                } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
413
-                    $term = get_term((int)$taxonomy_search[0], $post_type . 'category');
414
-                }
415
-            }
410
+				if (!is_array($taxonomy_search)) {
411
+					$term = get_term((int)$taxonomy_search, $post_type . 'category');
412
+				} else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
413
+					$term = get_term((int)$taxonomy_search[0], $post_type . 'category');
414
+				}
415
+			}
416 416
             
417
-            if (!empty($term) && !is_wp_error($term)) {
418
-                $listing_type_name = $term->name;
419
-            }
420
-        }
417
+			if (!empty($term) && !is_wp_error($term)) {
418
+				$listing_type_name = $term->name;
419
+			}
420
+		}
421 421
 
422
-        if ($max_page > 1 || $always_show) {            
423
-            // Extra pagination info
424
-            $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
425
-            $start_no = ( $paged - 1 ) * $posts_per_page + 1;
426
-            $end_no = min($paged * $posts_per_page, $numposts);
422
+		if ($max_page > 1 || $always_show) {            
423
+			// Extra pagination info
424
+			$geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
425
+			$start_no = ( $paged - 1 ) * $posts_per_page + 1;
426
+			$end_no = min($paged * $posts_per_page, $numposts);
427 427
 
428
-            if ($geodir_pagination_more_info != '') {
429
-                if ($listing_type_name) {
430
-                    $listing_type_name = __($listing_type_name, 'geodirectory');
431
-                    $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts);
432
-                } else {
433
-                    $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
434
-                }
435
-                $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>';
436
-                /**
437
-                 * Adds an extra pagination info above/under pagination.
438
-                 *
439
-                 * @since 1.5.9
440
-                 *
441
-                 * @param string $pagination_info Extra pagination info content.
442
-                 * @param string $listing_type_name Listing results type.
443
-                 * @param string $start_no First result number.
444
-                 * @param string $end_no Last result number.
445
-                 * @param string $numposts Total number of listings.
446
-                 * @param string $post_type The post type.
447
-                 */
448
-                $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
428
+			if ($geodir_pagination_more_info != '') {
429
+				if ($listing_type_name) {
430
+					$listing_type_name = __($listing_type_name, 'geodirectory');
431
+					$pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts);
432
+				} else {
433
+					$pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
434
+				}
435
+				$pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>';
436
+				/**
437
+				 * Adds an extra pagination info above/under pagination.
438
+				 *
439
+				 * @since 1.5.9
440
+				 *
441
+				 * @param string $pagination_info Extra pagination info content.
442
+				 * @param string $listing_type_name Listing results type.
443
+				 * @param string $start_no First result number.
444
+				 * @param string $end_no Last result number.
445
+				 * @param string $numposts Total number of listings.
446
+				 * @param string $post_type The post type.
447
+				 */
448
+				$pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
449 449
                 
450
-                if ($geodir_pagination_more_info == 'before') {
451
-                    $before = $before . $pagination_info;
452
-                } else if ($geodir_pagination_more_info == 'after') {
453
-                    $after = $pagination_info . $after;
454
-                }
455
-            }
450
+				if ($geodir_pagination_more_info == 'before') {
451
+					$before = $before . $pagination_info;
452
+				} else if ($geodir_pagination_more_info == 'after') {
453
+					$after = $pagination_info . $after;
454
+				}
455
+			}
456 456
             
457
-            echo "$before <div class='Navi gd-navi'>";
458
-            if ($paged >= ($pages_to_show - 1)) {
459
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link()) . '">&laquo;</a>';
460
-            }
461
-            previous_posts_link($prelabel);
462
-            for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
463
-                if ($i >= 1 && $i <= $max_page) {
464
-                    if ($i == $paged) {
465
-                        echo "<strong class='on'>$i</strong>";
466
-                    } else {
467
-                        echo ' <a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
468
-                    }
469
-                }
470
-            }
471
-            next_posts_link($nxtlabel, $max_page);
472
-            if (($paged + $half_pages_to_show) < ($max_page)) {
473
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)) . '">&raquo;</a>';
474
-            }
475
-            echo "</div> $after";
476
-        }
457
+			echo "$before <div class='Navi gd-navi'>";
458
+			if ($paged >= ($pages_to_show - 1)) {
459
+				echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link()) . '">&laquo;</a>';
460
+			}
461
+			previous_posts_link($prelabel);
462
+			for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
463
+				if ($i >= 1 && $i <= $max_page) {
464
+					if ($i == $paged) {
465
+						echo "<strong class='on'>$i</strong>";
466
+					} else {
467
+						echo ' <a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
468
+					}
469
+				}
470
+			}
471
+			next_posts_link($nxtlabel, $max_page);
472
+			if (($paged + $half_pages_to_show) < ($max_page)) {
473
+				echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)) . '">&raquo;</a>';
474
+			}
475
+			echo "</div> $after";
476
+		}
477 477
         
478
-        if (function_exists('geodir_location_geo_home_link')) {
479
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
480
-        }
481
-    }
478
+		if (function_exists('geodir_location_geo_home_link')) {
479
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
480
+		}
481
+	}
482 482
 }
483 483
 
484 484
 /**
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
  */
490 490
 function geodir_listingsearch_scripts()
491 491
 {
492
-    if (get_option('gd_search_dist') != '') {
493
-        $dist = get_option('gd_search_dist');
494
-    } else {
495
-        $dist = 500;
496
-    }
497
-    $dist_dif = 1000;
498
-
499
-    if ($dist <= 5000) $dist_dif = 500;
500
-    if ($dist <= 1000) $dist_dif = 100;
501
-    if ($dist <= 500) $dist_dif = 50;
502
-    if ($dist <= 100) $dist_dif = 10;
503
-    if ($dist <= 50) $dist_dif = 5;
504
-
505
-    ?>
492
+	if (get_option('gd_search_dist') != '') {
493
+		$dist = get_option('gd_search_dist');
494
+	} else {
495
+		$dist = 500;
496
+	}
497
+	$dist_dif = 1000;
498
+
499
+	if ($dist <= 5000) $dist_dif = 500;
500
+	if ($dist <= 1000) $dist_dif = 100;
501
+	if ($dist <= 500) $dist_dif = 50;
502
+	if ($dist <= 100) $dist_dif = 10;
503
+	if ($dist <= 50) $dist_dif = 5;
504
+
505
+	?>
506 506
     <script type="text/javascript">
507 507
 
508 508
         jQuery(function ($) {
@@ -560,20 +560,20 @@  discard block
 block discarded – undo
560 560
  * @package GeoDirectory
561 561
  */
562 562
 function geodir_add_sharelocation_scripts() {
563
-    $default_search_for_text = SEARCH_FOR_TEXT;
564
-    if (get_option('geodir_search_field_default_text'))
565
-        $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
563
+	$default_search_for_text = SEARCH_FOR_TEXT;
564
+	if (get_option('geodir_search_field_default_text'))
565
+		$default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
566 566
 
567
-    $default_near_text = NEAR_TEXT;
568
-    if (get_option('geodir_near_field_default_text'))
569
-        $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
567
+	$default_near_text = NEAR_TEXT;
568
+	if (get_option('geodir_near_field_default_text'))
569
+		$default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
570 570
     
571
-    $search_location = geodir_get_default_location();
571
+	$search_location = geodir_get_default_location();
572 572
     
573
-    $default_search_for_text = addslashes(stripslashes($default_search_for_text));
574
-    $default_near_text = addslashes(stripslashes($default_near_text));
575
-    $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : '';
576
-    ?>
573
+	$default_search_for_text = addslashes(stripslashes($default_search_for_text));
574
+	$default_near_text = addslashes(stripslashes($default_near_text));
575
+	$city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : '';
576
+	?>
577 577
     <script type="text/javascript">
578 578
         var default_location = '<?php echo $city ;?>';
579 579
         var latlng;
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
                     initialise2();
666 666
                 } else {
667 667
                     <?php
668
-                    $near_add = get_option('geodir_search_near_addition');
669
-                    /**
670
-                     * Adds any extra info to the near search box query when trying to geolocate it via google api.
671
-                     *
672
-                     * @since 1.0.0
673
-                     */
674
-                    $near_add2 = apply_filters('geodir_search_near_addition', '');
675
-                    ?>
668
+					$near_add = get_option('geodir_search_near_addition');
669
+					/**
670
+					 * Adds any extra info to the near search box query when trying to geolocate it via google api.
671
+					 *
672
+					 * @since 1.0.0
673
+					 */
674
+					$near_add2 = apply_filters('geodir_search_near_addition', '');
675
+					?>
676 676
                     if (window.gdMaps === 'google') {
677 677
                         Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>},
678 678
                             function (results, status) {
@@ -786,32 +786,32 @@  discard block
 block discarded – undo
786 786
  */
787 787
 function geodir_show_badges_on_image($which, $post, $link)
788 788
 {
789
-    $return = '';
790
-    switch ($which) {
791
-        case 'featured':
792
-            /**
793
-             * Filter the featured image badge html that appears in the listings pages over the thumbnail.
794
-             *
795
-             * @since 1.0.0
796
-             * @param object $post The post object.
797
-             * @param string $link The link to the post.
798
-             */
799
-            $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img">&nbsp;</span></a>',$post,$link);
800
-            break;
801
-        case 'new' :
802
-            /**
803
-             * Filter the new image badge html that appears in the listings pages over the thumbnail.
804
-             *
805
-             * @since 1.0.0
806
-             * @param object $post The post object.
807
-             * @param string $link The link to the post.
808
-             */
809
-            $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing">&nbsp;</span></a>',$post,$link);
810
-            break;
811
-
812
-    }
789
+	$return = '';
790
+	switch ($which) {
791
+		case 'featured':
792
+			/**
793
+			 * Filter the featured image badge html that appears in the listings pages over the thumbnail.
794
+			 *
795
+			 * @since 1.0.0
796
+			 * @param object $post The post object.
797
+			 * @param string $link The link to the post.
798
+			 */
799
+			$return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img">&nbsp;</span></a>',$post,$link);
800
+			break;
801
+		case 'new' :
802
+			/**
803
+			 * Filter the new image badge html that appears in the listings pages over the thumbnail.
804
+			 *
805
+			 * @since 1.0.0
806
+			 * @param object $post The post object.
807
+			 * @param string $link The link to the post.
808
+			 */
809
+			$return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing">&nbsp;</span></a>',$post,$link);
810
+			break;
811
+
812
+	}
813 813
     
814
-    return $return;
814
+	return $return;
815 815
 }
816 816
 
817 817
 /**
@@ -820,9 +820,9 @@  discard block
 block discarded – undo
820 820
  * @since 1.6.22
821 821
  */
822 822
 function geodir_fix_script_conflict() {
823
-    if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
824
-        wp_dequeue_script( 'flexslider' );
825
-    }
823
+	if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
824
+		wp_dequeue_script( 'flexslider' );
825
+	}
826 826
 }
827 827
 add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 );
828 828
 
@@ -835,12 +835,12 @@  discard block
 block discarded – undo
835 835
  */
836 836
 function geodir_fontawesome_defer($url)
837 837
 {
838
-    if (strpos($url, 'use.fontawesome.com/releases/')===false)
839
-        return $url;
840
-    else if (is_admin())
841
-        return str_replace('#faload', '', $url);
842
-    else
843
-        return $url."' data-search-pseudo-elements defer='defer";
838
+	if (strpos($url, 'use.fontawesome.com/releases/')===false)
839
+		return $url;
840
+	else if (is_admin())
841
+		return str_replace('#faload', '', $url);
842
+	else
843
+		return $url."' data-search-pseudo-elements defer='defer";
844 844
 }
845 845
 //add_filter('clean_url', 'geodir_fontawesome_defer', 11, 1); // let users add this as a snippet if they need it
846 846
 
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
  * Dequeue our fontawesome if using BB page.
849 849
  */
850 850
 function geodir_fix_beaver_builder(){
851
-    if(isset($_REQUEST['fl_builder'])){
852
-        wp_dequeue_script( 'font-awesome' );
853
-    }
851
+	if(isset($_REQUEST['fl_builder'])){
852
+		wp_dequeue_script( 'font-awesome' );
853
+	}
854 854
 }
855 855
 //add_filter('wp_print_scripts','geodir_fix_beaver_builder',100);
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
     $is_detail_page = false;
40 40
     $geodir_map_name = geodir_map_name();
41 41
 
42
-    if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
42
+    if ((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview'))) {
43 43
         $is_detail_page = true;
44 44
     }
45 45
 
46 46
     wp_enqueue_script('jquery');
47 47
 
48
-    wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
48
+    wp_register_script('geodirectory-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
49 49
     wp_enqueue_script('geodirectory-script');
50 50
 
51 51
     $geodir_vars_data = array(
52 52
         'siteurl' => get_option('siteurl'),
53 53
         'geodir_plugin_url' => geodir_plugin_url(),
54
-        'geodir_lazy_load' => get_option('geodir_lazy_load',1),
54
+        'geodir_lazy_load' => get_option('geodir_lazy_load', 1),
55 55
         'geodir_ajax_url' => geodir_get_ajax_url(),
56
-        'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
56
+        'geodir_gd_modal' => (int) get_option('geodir_disable_gb_modal'),
57 57
         'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue
58 58
 		'lightBox_txtImage' => addslashes(__('Image', 'geodirectory')),
59 59
 		'lightBox_txtOf' => addslashes(__('of', 'geodirectory')),
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
      *
77 77
      * }
78 78
      */
79
-    $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
79
+    $geodir_vars_data = apply_filters('geodir_vars_data', $geodir_vars_data);
80 80
 
81 81
     wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
82 82
 
83
-    wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
84
-    if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
83
+    wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION, true);
84
+    if ($is_detail_page) {wp_enqueue_script('geodirectory-jquery-flexslider-js'); }
85 85
 
86
-    wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
86
+    wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url().'/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION, true);
87 87
     wp_enqueue_script('geodirectory-lightbox-jquery');
88 88
 
89
-    wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
89
+    wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url().'/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION, true);
90 90
     if ($is_detail_page) {
91 91
         wp_enqueue_script('geodirectory-jquery-simplemodal');
92 92
     }
93 93
 
94 94
     if (in_array($geodir_map_name, array('auto', 'google'))) {
95
-        $map_lang = "&language=" . geodir_get_map_default_language();
96
-        $map_key = "&key=" . geodir_get_map_api_key();
95
+        $map_lang = "&language=".geodir_get_map_default_language();
96
+        $map_key = "&key=".geodir_get_map_api_key();
97 97
         /**
98 98
          * Filter the variables that are added to the end of the google maps script call.
99 99
          *
@@ -103,55 +103,55 @@  discard block
 block discarded – undo
103 103
          * @param string $var The string to filter, default is empty string.
104 104
          */
105 105
         $map_extra = apply_filters('geodir_googlemap_script_extra', '');
106
-        wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
106
+        wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?'.$map_lang.$map_key.$map_extra, '', NULL);
107 107
         
108 108
         // Overlapping Marker Spiderfier
109
-        wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
109
+        wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url().'/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
110 110
         wp_enqueue_script('geodirectory-g-overlappingmarker-script');
111 111
     }
112 112
     
113 113
     if ($geodir_map_name == 'osm') {
114 114
         // Leaflet OpenStreetMap
115
-        wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
115
+        wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
116 116
         wp_enqueue_style('geodirectory-leaflet-style');
117 117
             
118
-        wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
118
+        wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
119 119
         wp_enqueue_script('geodirectory-leaflet-script');
120 120
         
121
-        wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
121
+        wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
122 122
         wp_enqueue_script('geodirectory-leaflet-geo-script');
123 123
         
124 124
         if ($is_detail_page) {
125
-            wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
125
+            wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url().'/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
126 126
             wp_enqueue_style('geodirectory-leaflet-routing-style');
127 127
                 
128
-            wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
128
+            wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url().'/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
129 129
             wp_enqueue_script('geodirectory-leaflet-routing-script');
130 130
         }
131 131
         
132 132
         // Overlapping Marker Spiderfier Leaflet
133
-        wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
133
+        wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url().'/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
134 134
         wp_enqueue_script('geodirectory-o-overlappingmarker-script');
135 135
     }
136
-    wp_enqueue_script( 'jquery-ui-autocomplete' );
136
+    wp_enqueue_script('jquery-ui-autocomplete');
137 137
     
138
-    wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
138
+    wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
139 139
     wp_enqueue_script('geodirectory-goMap-script');
140 140
 
141
-    wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
141
+    wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
142 142
     wp_enqueue_script('chosen');
143 143
 
144
-    wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
144
+    wp_register_script('geodirectory-choose-ajax', geodir_plugin_url().'/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
145 145
     wp_enqueue_script('geodirectory-choose-ajax');
146 146
 
147
-    wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
147
+    wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
148 148
 
149 149
     if (is_page() && geodir_is_page('add-listing')) {
150 150
         // SCRIPT FOR UPLOAD
151 151
         wp_enqueue_script('plupload-all');
152 152
         wp_enqueue_script('jquery-ui-sortable');
153 153
 
154
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
154
+        wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
155 155
         wp_enqueue_script('geodirectory-plupload-script');
156 156
         // SCRIPT FOR UPLOAD END
157 157
 
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 
199 199
         wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
200 200
 
201
-        wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
201
+        wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation.min.js#asyncload');
202 202
     } // End if for add place page
203 203
 
204
-    wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
204
+    wp_register_script('geodirectory-post-custom-js', geodir_plugin_url().'/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
205 205
     if ($is_detail_page) {
206 206
 		wp_enqueue_script('geodirectory-post-custom-js');
207 207
 	}
208 208
 
209 209
     // font awesome rating script
210 210
 	if (get_option('geodir_reviewrating_enable_font_awesome')) {
211
-		wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
211
+		wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
212 212
 		wp_enqueue_script('geodir-barrating-js');
213 213
 	} else { // default rating script
214
-		wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.min.js', array(), GEODIRECTORY_VERSION, true);
214
+		wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.min.js', array(), GEODIRECTORY_VERSION, true);
215 215
 		wp_enqueue_script('geodir-jRating-js');
216 216
 	}
217 217
 
218
-    wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
218
+    wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
219 219
     wp_enqueue_script('geodir-on-document-load');
220 220
 
221
-    wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
221
+    wp_register_script('google-geometa', geodir_plugin_url().'/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
222 222
     wp_enqueue_script('google-geometa');
223 223
 }
224 224
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function geodir_header_scripts()
235 235
 {
236
-    echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
236
+    echo '<style>'.stripslashes(get_option('geodir_coustem_css')).'</style>';
237 237
     echo stripslashes(get_option('geodir_header_scripts'));
238 238
 }
239 239
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
  */
248 248
 function geodir_google_analytics_tracking_code()
249 249
 {
250
-    if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
250
+    if (get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')) {?>
251 251
 
252 252
         <script>
253 253
             (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
                 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
256 256
             })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
257 257
 
258
-            ga('create', '<?php echo esc_attr(get_option('geodir_ga_account_id'));?>', 'auto');
259
-            <?php if(get_option('geodir_ga_anonymize_ip')){echo "ga('set', 'anonymizeIP', true);";}?>
258
+            ga('create', '<?php echo esc_attr(get_option('geodir_ga_account_id')); ?>', 'auto');
259
+            <?php if (get_option('geodir_ga_anonymize_ip')) {echo "ga('set', 'anonymizeIP', true);"; }?>
260 260
             ga('send', 'pageview');
261 261
 
262 262
         </script>
263 263
 
264 264
         <?php
265
-    }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
265
+    }elseif (get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')) {
266 266
         echo stripslashes(get_option('geodir_ga_tracking_code'));
267 267
     }
268 268
 }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      *
286 286
      * Flexbox wont wrap on ios for search form items
287 287
      */
288
-    if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
288
+    if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'])) {
289 289
         echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
290 290
     }
291 291
 }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  */
302 302
 function geodir_add_async_forscript($url)
303 303
 {
304
-    if (strpos($url, '#asyncload')===false)
304
+    if (strpos($url, '#asyncload') === false)
305 305
         return $url;
306 306
     else if (is_admin())
307 307
         return str_replace('#asyncload', '', $url);
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 function geodir_templates_styles()
320 320
 {
321 321
 
322
-    wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
322
+    wp_register_style('geodir-core-scss', geodir_plugin_url().'/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
323 323
     wp_enqueue_style('geodir-core-scss');
324
-    wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
324
+    wp_register_style('geodir-core-scss-footer', geodir_plugin_url().'/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
325 325
 
326
-    if(is_rtl()){
327
-    wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
326
+    if (is_rtl()) {
327
+    wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url().'/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
328 328
     wp_enqueue_style('geodirectory-frontend-rtl-style');
329 329
     }
330 330
 
@@ -399,18 +399,18 @@  discard block
 block discarded – undo
399 399
                 $term_id = get_queried_object_id();
400 400
                 $taxonomy = get_query_var('taxonomy');
401 401
 
402
-                if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
403
-                    $term = get_term($term_id, $post_type . 'category');
402
+                if ($term_id && $post_type && get_query_var('taxonomy') == $post_type.'category') {
403
+                    $term = get_term($term_id, $post_type.'category');
404 404
                 }
405 405
             }
406 406
             
407
-            if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
408
-                $taxonomy_search = $_REQUEST['s' . $post_type . 'category'];
407
+            if (geodir_is_page('search') && !empty($_REQUEST['s'.$post_type.'category'])) {
408
+                $taxonomy_search = $_REQUEST['s'.$post_type.'category'];
409 409
                 
410 410
                 if (!is_array($taxonomy_search)) {
411
-                    $term = get_term((int)$taxonomy_search, $post_type . 'category');
412
-                } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
413
-                    $term = get_term((int)$taxonomy_search[0], $post_type . 'category');
411
+                    $term = get_term((int) $taxonomy_search, $post_type.'category');
412
+                } else if (is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
413
+                    $term = get_term((int) $taxonomy_search[0], $post_type.'category');
414 414
                 }
415 415
             }
416 416
             
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
         if ($max_page > 1 || $always_show) {            
423 423
             // Extra pagination info
424 424
             $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
425
-            $start_no = ( $paged - 1 ) * $posts_per_page + 1;
425
+            $start_no = ($paged - 1) * $posts_per_page + 1;
426 426
             $end_no = min($paged * $posts_per_page, $numposts);
427 427
 
428 428
             if ($geodir_pagination_more_info != '') {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                 } else {
433 433
                     $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
434 434
                 }
435
-                $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>';
435
+                $pagination_info = '<div class="gd-pagination-details">'.$pegination_desc.'</div>';
436 436
                 /**
437 437
                  * Adds an extra pagination info above/under pagination.
438 438
                  *
@@ -448,15 +448,15 @@  discard block
 block discarded – undo
448 448
                 $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
449 449
                 
450 450
                 if ($geodir_pagination_more_info == 'before') {
451
-                    $before = $before . $pagination_info;
451
+                    $before = $before.$pagination_info;
452 452
                 } else if ($geodir_pagination_more_info == 'after') {
453
-                    $after = $pagination_info . $after;
453
+                    $after = $pagination_info.$after;
454 454
                 }
455 455
             }
456 456
             
457 457
             echo "$before <div class='Navi gd-navi'>";
458 458
             if ($paged >= ($pages_to_show - 1)) {
459
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link()) . '">&laquo;</a>';
459
+                echo '<a href="'.str_replace('&paged', '&amp;paged', get_pagenum_link()).'">&laquo;</a>';
460 460
             }
461 461
             previous_posts_link($prelabel);
462 462
             for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
                     if ($i == $paged) {
465 465
                         echo "<strong class='on'>$i</strong>";
466 466
                     } else {
467
-                        echo ' <a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
467
+                        echo ' <a href="'.str_replace('&paged', '&amp;paged', get_pagenum_link($i)).'">'.$i.'</a> ';
468 468
                     }
469 469
                 }
470 470
             }
471 471
             next_posts_link($nxtlabel, $max_page);
472 472
             if (($paged + $half_pages_to_show) < ($max_page)) {
473
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)) . '">&raquo;</a>';
473
+                echo '<a href="'.str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)).'">&raquo;</a>';
474 474
             }
475 475
             echo "</div> $after";
476 476
         }
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
         jQuery(function ($) {
509 509
             $("#distance_slider").slider({
510 510
                 range: true,
511
-                values: [0, <?php echo ($_REQUEST['sdist']!='') ? sanitize_text_field($_REQUEST['sdist']) : "0"; ?>],
511
+                values: [0, <?php echo ($_REQUEST['sdist'] != '') ? sanitize_text_field($_REQUEST['sdist']) : "0"; ?>],
512 512
                 min: 0,
513 513
                 max: <?php echo $dist; ?>,
514 514
                 step: <?php echo $dist_dif; ?>,
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
     $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : '';
576 576
     ?>
577 577
     <script type="text/javascript">
578
-        var default_location = '<?php echo $city ;?>';
578
+        var default_location = '<?php echo $city; ?>';
579 579
         var latlng;
580 580
         var address;
581 581
         var dist = 0;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 				var $form = jQuery(this).closest('form');
592 592
 
593 593
 				if (jQuery("#sdist input[type='radio']:checked").length != 0) dist = jQuery("#sdist input[type='radio']:checked").val();
594
-				if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php echo $default_search_for_text;?>') jQuery('.search_text', $form).val(s);
594
+				if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php echo $default_search_for_text; ?>') jQuery('.search_text', $form).val(s);
595 595
 				
596 596
 				// Disable location based search for disabled location post type.
597 597
 				if (jQuery('.search_by_post', $form).val() != '' && typeof gd_cpt_no_location == 'function') {
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 					}
606 606
 				}
607 607
 				
608
-				if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php echo $default_near_text;?>')) {
608
+				if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php echo $default_near_text; ?>')) {
609 609
 
610 610
                     // OSM can't handel post code with no space so we test for it and add one if needed
611 611
                     if(window.gdMaps === 'osm'){
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
         });
635 635
         
636 636
 		function geodir_setsearch($form) {
637
-			if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php echo $default_near_text;?>')) jQuery(".snear", $form).val(default_location);
637
+			if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php echo $default_near_text; ?>')) jQuery(".snear", $form).val(default_location);
638 638
 			geocodeAddress($form);
639 639
 		}
640 640
 
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
             // Call the geocode function
654 654
             Sgeocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
655 655
 
656
-            if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != ''  ) || jQuery('.snear', $form).val().match("^<?php _e('In:','geodirectory');?>")) {
657
-                if (jQuery('.snear', $form).val().match("^<?php _e('In:','geodirectory');?>")) {
656
+            if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != ''  ) || jQuery('.snear', $form).val().match("^<?php _e('In:', 'geodirectory'); ?>")) {
657
+                if (jQuery('.snear', $form).val().match("^<?php _e('In:', 'geodirectory'); ?>")) {
658 658
                     jQuery(".snear", $form).val('');
659 659
                 }
660 660
                 jQuery($form).submit();
661 661
             } else {
662 662
                 var address = jQuery(".snear", $form).val();
663 663
 
664
-                if (jQuery('.snear', $form).val() == '<?php echo $default_near_text;?>') {
664
+                if (jQuery('.snear', $form).val() == '<?php echo $default_near_text; ?>') {
665 665
                     initialise2();
666 666
                 } else {
667 667
                     <?php
@@ -674,21 +674,21 @@  discard block
 block discarded – undo
674 674
                     $near_add2 = apply_filters('geodir_search_near_addition', '');
675 675
                     ?>
676 676
                     if (window.gdMaps === 'google') {
677
-                        Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>},
677
+                        Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", '.$near_add.'"' : '').$near_add2; ?>},
678 678
                             function (results, status) {
679 679
                                 if (status == google.maps.GeocoderStatus.OK) {
680 680
                                     updateSearchPosition(results[0].geometry.location, $form);
681 681
                                 } else {
682
-                                    alert("<?php esc_attr_e('Search was not successful for the following reason :', 'geodirectory');?>" + status);
682
+                                    alert("<?php esc_attr_e('Search was not successful for the following reason :', 'geodirectory'); ?>" + status);
683 683
                                 }
684 684
                             });
685 685
                     } else if (window.gdMaps === 'osm') {
686
-                        geocodePositionOSM(false, address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>, false, false,
686
+                        geocodePositionOSM(false, address<?php echo ($near_add ? '+", '.$near_add.'"' : '').$near_add2; ?>, false, false,
687 687
                             function(geo) {
688 688
                                 if (typeof geo !== 'undefined' && geo.lat && geo.lon) {
689 689
                                     updateSearchPosition(geo, $form);
690 690
                                 } else {
691
-                                    alert("<?php esc_attr_e('Search was not successful for the requested address.', 'geodirectory');?>");
691
+                                    alert("<?php esc_attr_e('Search was not successful for the requested address.', 'geodirectory'); ?>");
692 692
                                 }
693 693
                             });
694 694
                     } else {
@@ -734,19 +734,19 @@  discard block
 block discarded – undo
734 734
             var msg;
735 735
             switch (err.code) {
736 736
                 case err.UNKNOWN_ERROR:
737
-                    msg = "<?php _e('Unable to find your location','geodirectory');?>";
737
+                    msg = "<?php _e('Unable to find your location', 'geodirectory'); ?>";
738 738
                     break;
739 739
                 case err.PERMISSION_DENINED:
740
-                    msg = "<?php _e('Permission denied in finding your location','geodirectory');?>";
740
+                    msg = "<?php _e('Permission denied in finding your location', 'geodirectory'); ?>";
741 741
                     break;
742 742
                 case err.POSITION_UNAVAILABLE:
743
-                    msg = "<?php _e('Your location is currently unknown','geodirectory');?>";
743
+                    msg = "<?php _e('Your location is currently unknown', 'geodirectory'); ?>";
744 744
                     break;
745 745
                 case err.BREAK:
746
-                    msg = "<?php _e('Attempt to find location took too long','geodirectory');?>";
746
+                    msg = "<?php _e('Attempt to find location took too long', 'geodirectory'); ?>";
747 747
                     break;
748 748
                 default:
749
-                    msg = "<?php _e('Location detection not supported in browser','geodirectory');?>";
749
+                    msg = "<?php _e('Location detection not supported in browser', 'geodirectory'); ?>";
750 750
             }
751 751
             jQuery('#info').html(msg);
752 752
         }
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
              * @param object $post The post object.
797 797
              * @param string $link The link to the post.
798 798
              */
799
-            $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img">&nbsp;</span></a>',$post,$link);
799
+            $return = apply_filters('geodir_featured_badge_on_image', '<a href="'.$link.'"><span class="geodir_featured_img">&nbsp;</span></a>', $post, $link);
800 800
             break;
801 801
         case 'new' :
802 802
             /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
              * @param object $post The post object.
807 807
              * @param string $link The link to the post.
808 808
              */
809
-            $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing">&nbsp;</span></a>',$post,$link);
809
+            $return = apply_filters('geodir_new_badge_on_image', '<a href="'.$link.'"><span class="geodir_new_listing">&nbsp;</span></a>', $post, $link);
810 810
             break;
811 811
 
812 812
     }
@@ -820,11 +820,11 @@  discard block
 block discarded – undo
820 820
  * @since 1.6.22
821 821
  */
822 822
 function geodir_fix_script_conflict() {
823
-    if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
824
-        wp_dequeue_script( 'flexslider' );
823
+    if (wp_script_is('flexslider', 'enqueued') && wp_script_is('geodirectory-jquery-flexslider-js', 'enqueued')) {
824
+        wp_dequeue_script('flexslider');
825 825
     }
826 826
 }
827
-add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 );
827
+add_action('wp_enqueue_scripts', 'geodir_fix_script_conflict', 100);
828 828
 
829 829
 /**
830 830
  * make fontawesome search for inline before and after icons
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
  */
836 836
 function geodir_fontawesome_defer($url)
837 837
 {
838
-    if (strpos($url, 'use.fontawesome.com/releases/')===false)
838
+    if (strpos($url, 'use.fontawesome.com/releases/') === false)
839 839
         return $url;
840 840
     else if (is_admin())
841 841
         return str_replace('#faload', '', $url);
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
 /**
848 848
  * Dequeue our fontawesome if using BB page.
849 849
  */
850
-function geodir_fix_beaver_builder(){
851
-    if(isset($_REQUEST['fl_builder'])){
852
-        wp_dequeue_script( 'font-awesome' );
850
+function geodir_fix_beaver_builder() {
851
+    if (isset($_REQUEST['fl_builder'])) {
852
+        wp_dequeue_script('font-awesome');
853 853
     }
854 854
 }
855 855
 //add_filter('wp_print_scripts','geodir_fix_beaver_builder',100);
Please login to merge, or discard this patch.
geodirectory-functions/listing_filters.php 3 patches
Indentation   +623 added lines, -623 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function geodir_session_start()
18 18
 {
19
-    if (!session_id()) session_start();
20
-    global $geodir_add_location_url;
19
+	if (!session_id()) session_start();
20
+	global $geodir_add_location_url;
21 21
 
22
-    $geodir_add_location_url = NULL;
22
+	$geodir_add_location_url = NULL;
23 23
 }
24 24
 
25 25
 /**
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_modified_query($query)
35 35
 {
36
-    if ($query->is_main_query() && (
37
-            (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
38
-            || geodir_is_page('listing')
39
-            || geodir_is_page('author')
40
-            || geodir_is_page('search')
41
-            || geodir_is_page('detail'))
42
-    ) {
43
-
44
-        $query->set('is_geodir_loop', true);
45
-    }
36
+	if ($query->is_main_query() && (
37
+			(geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
38
+			|| geodir_is_page('listing')
39
+			|| geodir_is_page('author')
40
+			|| geodir_is_page('search')
41
+			|| geodir_is_page('detail'))
42
+	) {
43
+
44
+		$query->set('is_geodir_loop', true);
45
+	}
46 46
 
47
-    return $query;
47
+	return $query;
48 48
 }
49 49
 
50 50
 /**
@@ -67,81 +67,81 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function set_listing_request($query )
69 69
 {
70
-    global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
70
+	global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
71 71
 
72 72
 
73
-    // fix woocommerce shop products filtered by language for GD + WPML + Woocommerce
74
-    if (!geodir_is_geodir_page()) {
75
-        return;
76
-    }
73
+	// fix woocommerce shop products filtered by language for GD + WPML + Woocommerce
74
+	if (!geodir_is_geodir_page()) {
75
+		return;
76
+	}
77 77
 
78
-    /* remove all pre filters */
79
-    remove_all_filters('query');
80
-    remove_all_filters('posts_search');
81
-    remove_all_filters('posts_fields');
82
-    remove_all_filters('posts_join');
83
-    remove_all_filters('posts_orderby');
84
-    remove_all_filters('posts_where');
78
+	/* remove all pre filters */
79
+	remove_all_filters('query');
80
+	remove_all_filters('posts_search');
81
+	remove_all_filters('posts_fields');
82
+	remove_all_filters('posts_join');
83
+	remove_all_filters('posts_orderby');
84
+	remove_all_filters('posts_where');
85 85
 
86 86
 
87
-    if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')):
87
+	if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')):
88 88
 
89
-        if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = '';
90
-        //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = '';
89
+		if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = '';
90
+		//if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = '';
91 91
 
92
-        if (isset($_REQUEST['sdist'])) {
93
-            ($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000;
94
-        } elseif (get_option('geodir_search_dist') != '') {
95
-            $dist = get_option('geodir_search_dist');
92
+		if (isset($_REQUEST['sdist'])) {
93
+			($_REQUEST['sdist'] != '0' && $_REQUEST['sdist'] != '') ? $dist = esc_attr($_REQUEST['sdist']) : $dist = 25000;
94
+		} elseif (get_option('geodir_search_dist') != '') {
95
+			$dist = get_option('geodir_search_dist');
96 96
 
97
-        } else {
98
-            $dist = 25000;
99
-        } //  Distance
97
+		} else {
98
+			$dist = 25000;
99
+		} //  Distance
100 100
 
101
-        if (isset($_REQUEST['sgeo_lat'])) {
102
-            $mylat = (float)esc_attr($_REQUEST['sgeo_lat']);
103
-        } else {
104
-            $mylat = (float)geodir_get_current_city_lat();
105
-        } //  Latitude
101
+		if (isset($_REQUEST['sgeo_lat'])) {
102
+			$mylat = (float)esc_attr($_REQUEST['sgeo_lat']);
103
+		} else {
104
+			$mylat = (float)geodir_get_current_city_lat();
105
+		} //  Latitude
106 106
 
107
-        if (isset($_REQUEST['sgeo_lon'])) {
108
-            $mylon = (float)esc_attr($_REQUEST['sgeo_lon']);
109
-        } else {
110
-            $mylon = (float)geodir_get_current_city_lng();
111
-        } //  Distance
107
+		if (isset($_REQUEST['sgeo_lon'])) {
108
+			$mylon = (float)esc_attr($_REQUEST['sgeo_lon']);
109
+		} else {
110
+			$mylon = (float)geodir_get_current_city_lng();
111
+		} //  Distance
112 112
 
113
-        if (isset($_REQUEST['snear'])) {
114
-            $snear = trim(esc_attr($_REQUEST['snear']));
115
-        }
113
+		if (isset($_REQUEST['snear'])) {
114
+			$snear = trim(esc_attr($_REQUEST['snear']));
115
+		}
116 116
 
117
-        if (isset($_REQUEST['s'])) {
118
-            $s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s'])));
119
-        }
117
+		if (isset($_REQUEST['s'])) {
118
+			$s = trim(esc_attr(wp_strip_all_tags($_REQUEST['s'])));
119
+		}
120 120
 
121
-        if ($snear == 'NEAR ME') {
122
-            $ip = $_SERVER['REMOTE_ADDR'];
123
-            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
124
-            $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
125
-            $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
126
-        }
121
+		if ($snear == 'NEAR ME') {
122
+			$ip = $_SERVER['REMOTE_ADDR'];
123
+			$addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
124
+			$mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
125
+			$mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
126
+		}
127 127
 
128 128
 
129
-        if (strstr($s, ',')) {
130
-            $s_AA = str_replace(" ", "", $s);
131
-            $s_A = explode(",", $s_AA);
132
-            $s_A = implode('","', $s_A);
133
-            $s_A = '"' . $s_A . '"';
134
-        } else {
135
-            $s_A = '"' . $s . '"';
136
-        }
129
+		if (strstr($s, ',')) {
130
+			$s_AA = str_replace(" ", "", $s);
131
+			$s_A = explode(",", $s_AA);
132
+			$s_A = implode('","', $s_A);
133
+			$s_A = '"' . $s_A . '"';
134
+		} else {
135
+			$s_A = '"' . $s . '"';
136
+		}
137 137
 
138
-        if (strstr($s, ' ')) {
139
-            $s_SA = explode(" ", $s);
140
-        } else {
141
-            $s_SA = '';
142
-        }
138
+		if (strstr($s, ' ')) {
139
+			$s_SA = explode(" ", $s);
140
+		} else {
141
+			$s_SA = '';
142
+		}
143 143
 
144
-    endif;
144
+	endif;
145 145
 
146 146
 
147 147
 
@@ -162,56 +162,56 @@  discard block
 block discarded – undo
162 162
  */
163 163
 function geodir_listing_loop_filter($query)
164 164
 {
165
-    global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term;
165
+	global $wp_query, $geodir_post_type, $table, $plugin_prefix, $table, $term;
166 166
 
167
-    // fix wp_reset_query for popular post view widget
168
-    if (!geodir_is_geodir_page()) {
169
-        return;
170
-    }
167
+	// fix wp_reset_query for popular post view widget
168
+	if (!geodir_is_geodir_page()) {
169
+		return;
170
+	}
171 171
 
172
-    $geodir_post_type = geodir_get_current_posttype();
173
-
174
-    if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
175
-        $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
176
-
177
-        if (isset($wp_query->query[$taxonomies[0]])) {
178
-            $request_term = explode("/", $wp_query->query[$taxonomies[0]]);
179
-            $request_term = end($request_term);
180
-            if (!term_exists($request_term)) {
181
-                $args = array('number' => '1',);
182
-                $terms_arr = get_terms($taxonomies[0], $args);
183
-                foreach ($terms_arr as $location_term) {
184
-                    $term_arr = $location_term;
185
-                    $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
186
-                }
187
-                $wp_query->queried_object_id = 1;
188
-                $wp_query->queried_object = $term_arr;
189
-                //print_r($wp_query) ;
190
-            }
191
-        }
172
+	$geodir_post_type = geodir_get_current_posttype();
192 173
 
193
-    }
194
-    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
195
-
196
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
197
-
198
-        add_filter('posts_fields', 'geodir_posts_fields', 1);
199
-        add_filter('posts_join', 'geodir_posts_join', 1);
200
-        geodir_post_where();
201
-        if (!is_admin())
202
-            add_filter('posts_orderby', 'geodir_posts_orderby', 1);
203
-
204
-        // advanced filter for popular post view widget
205
-        global $wp_query;
206
-        if (!is_admin()) {
207
-            if (!empty($wp_query->query['with_pics_only'])) {
208
-                add_filter('posts_join', 'geodir_filter_widget_join', 1000);
209
-            }
210
-            add_filter('posts_where', 'geodir_filter_widget_where', 1000);
211
-        }
174
+	if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) {
175
+		$taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
212 176
 
213
-    }
214
-    return $query;
177
+		if (isset($wp_query->query[$taxonomies[0]])) {
178
+			$request_term = explode("/", $wp_query->query[$taxonomies[0]]);
179
+			$request_term = end($request_term);
180
+			if (!term_exists($request_term)) {
181
+				$args = array('number' => '1',);
182
+				$terms_arr = get_terms($taxonomies[0], $args);
183
+				foreach ($terms_arr as $location_term) {
184
+					$term_arr = $location_term;
185
+					$term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term));
186
+				}
187
+				$wp_query->queried_object_id = 1;
188
+				$wp_query->queried_object = $term_arr;
189
+				//print_r($wp_query) ;
190
+			}
191
+		}
192
+
193
+	}
194
+	if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
195
+
196
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
197
+
198
+		add_filter('posts_fields', 'geodir_posts_fields', 1);
199
+		add_filter('posts_join', 'geodir_posts_join', 1);
200
+		geodir_post_where();
201
+		if (!is_admin())
202
+			add_filter('posts_orderby', 'geodir_posts_orderby', 1);
203
+
204
+		// advanced filter for popular post view widget
205
+		global $wp_query;
206
+		if (!is_admin()) {
207
+			if (!empty($wp_query->query['with_pics_only'])) {
208
+				add_filter('posts_join', 'geodir_filter_widget_join', 1000);
209
+			}
210
+			add_filter('posts_where', 'geodir_filter_widget_where', 1000);
211
+		}
212
+
213
+	}
214
+	return $query;
215 215
 }
216 216
 
217 217
 
@@ -230,67 +230,67 @@  discard block
 block discarded – undo
230 230
  * @return string Modified fields query string.
231 231
  */
232 232
 function geodir_posts_fields($fields) {
233
-    global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
233
+	global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
234 234
 
235
-    // Filter-Location-Manager to add location table.
236
-    $fields .= ", " . $table . ".* ";
235
+	// Filter-Location-Manager to add location table.
236
+	$fields .= ", " . $table . ".* ";
237 237
 
238 238
 	if ($snear != '' || $gd_session->get('all_near_me')) {
239
-        $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
239
+		$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
240 240
 
241 241
 		if ($gd_session->get('all_near_me')) {
242
-            $mylat = $gd_session->get('user_lat');
243
-            $mylon = $gd_session->get('user_lon');
244
-        }
242
+			$mylat = $gd_session->get('user_lat');
243
+			$mylon = $gd_session->get('user_lon');
244
+		}
245 245
 
246
-        $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
247
-    }
246
+		$fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
247
+	}
248 248
 
249
-    global $s;
250
-    if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
251
-        $keywords = explode(" ", $s);
249
+	global $s;
250
+	if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
251
+		$keywords = explode(" ", $s);
252 252
 
253
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
254
-            foreach($keywords as $kkey=>$kword){
255
-                if(geodir_utf8_strlen($kword)<=$klimit){
256
-                    unset($keywords[$kkey]);
257
-                }
258
-            }
259
-        }
253
+		if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
254
+			foreach($keywords as $kkey=>$kword){
255
+				if(geodir_utf8_strlen($kword)<=$klimit){
256
+					unset($keywords[$kkey]);
257
+				}
258
+			}
259
+		}
260 260
 
261 261
 
262
-        if (count($keywords) > 1) {
263
-            $parts = array(
264
-                'AND' => 'gd_alltitlematch_part',
265
-                'OR' => 'gd_titlematch_part'
266
-            );
267
-            $gd_titlematch_part = "";
268
-            foreach ($parts as $key => $part) {
269
-                $gd_titlematch_part .= " CASE WHEN ";
270
-                $count = 0;
271
-                foreach ($keywords as $keyword) {
272
-                    $keyword = trim($keyword);
273
-                    $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
262
+		if (count($keywords) > 1) {
263
+			$parts = array(
264
+				'AND' => 'gd_alltitlematch_part',
265
+				'OR' => 'gd_titlematch_part'
266
+			);
267
+			$gd_titlematch_part = "";
268
+			foreach ($parts as $key => $part) {
269
+				$gd_titlematch_part .= " CASE WHEN ";
270
+				$count = 0;
271
+				foreach ($keywords as $keyword) {
272
+					$keyword = trim($keyword);
273
+					$keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
274 274
 					$count++;
275
-                    if ($count < count($keywords)) {
276
-                       // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
275
+					if ($count < count($keywords)) {
276
+					   // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
277 277
 						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " ";
278
-                    } else {
279
-                        //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
278
+					} else {
279
+						//$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
280 280
 						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) ";
281
-                    }
282
-                }
283
-                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
284
-            }
285
-        } else {
286
-            $gd_titlematch_part = "";
287
-        }
288
-        $s = stripslashes_deep( $s );
289
-        $s = wp_specialchars_decode($s,ENT_QUOTES);
281
+					}
282
+				}
283
+				$gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
284
+			}
285
+		} else {
286
+			$gd_titlematch_part = "";
287
+		}
288
+		$s = stripslashes_deep( $s );
289
+		$s = wp_specialchars_decode($s,ENT_QUOTES);
290 290
 		$fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s,'%>' . $s . '%','% ' . $s . ','));
291
-    }
291
+	}
292 292
 
293
-    return $fields;
293
+	return $fields;
294 294
 }
295 295
 
296 296
 
@@ -307,26 +307,26 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function geodir_posts_join($join)
309 309
 {
310
-    global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix;
310
+	global $wpdb, $geodir_post_type, $table, $table_prefix, $plugin_prefix;
311 311
 
312
-    ########### WPML ###########
312
+	########### WPML ###########
313 313
 
314
-    if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
315
-        global $sitepress;
316
-        $lang_code = ICL_LANGUAGE_CODE;
317
-        $default_lang_code = $sitepress->get_default_language();
318
-        if ($lang_code) {
319
-            $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
320
-        }
314
+	if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
315
+		global $sitepress;
316
+		$lang_code = ICL_LANGUAGE_CODE;
317
+		$default_lang_code = $sitepress->get_default_language();
318
+		if ($lang_code) {
319
+			$join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
320
+		}
321 321
 
322
-    }
323
-    ########### WPML ###########
322
+	}
323
+	########### WPML ###########
324 324
 
325
-    $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
326
-    //===old code start
327
-    //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
325
+	$join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
326
+	//===old code start
327
+	//$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
328 328
 
329
-    return $join;
329
+	return $join;
330 330
 }
331 331
 
332 332
 
@@ -344,15 +344,15 @@  discard block
 block discarded – undo
344 344
  */
345 345
 function geodir_posts_orderby($orderby)
346 346
 {
347
-    global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort;
347
+	global $wpdb, $wp_query, $geodir_post_type, $table, $plugin_prefix, $snear, $default_sort;
348 348
 
349
-    $sort_by = '';
350
-    $orderby = ' ';
349
+	$sort_by = '';
350
+	$orderby = ' ';
351 351
 
352
-    if (get_query_var('order_by'))
353
-        $sort_by = get_query_var('order_by');
352
+	if (get_query_var('order_by'))
353
+		$sort_by = get_query_var('order_by');
354 354
 
355
-    /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
355
+	/*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
356 356
         $current_term = $wp_query->get_queried_object();
357 357
     }
358 358
 
@@ -366,133 +366,133 @@  discard block
 block discarded – undo
366 366
     }*/
367 367
 
368 368
 
369
-    if ($snear != '') {
370
-        $orderby .= " distance,";
371
-    }
369
+	if ($snear != '') {
370
+		$orderby .= " distance,";
371
+	}
372 372
 
373
-    if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query())
374
-        $sort_by = esc_attr($_REQUEST['sort_by']);
373
+	if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query())
374
+		$sort_by = esc_attr($_REQUEST['sort_by']);
375 375
 
376 376
 
377
-    if ($sort_by == '') {
378
-        $default_sort = geodir_get_posts_default_sort($geodir_post_type);
379
-        if (!empty($default_sort))
380
-            $sort_by = $default_sort;
381
-    }
377
+	if ($sort_by == '') {
378
+		$default_sort = geodir_get_posts_default_sort($geodir_post_type);
379
+		if (!empty($default_sort))
380
+			$sort_by = $default_sort;
381
+	}
382 382
 
383
-    /*
383
+	/*
384 384
     if search by term & no location then order always "relevance"
385 385
     if search by location then order always "nearest"
386 386
     */
387
-    if (is_main_query() && geodir_is_page('search')) {
388
-        $search_term = get_query_var('s');
387
+	if (is_main_query() && geodir_is_page('search')) {
388
+		$search_term = get_query_var('s');
389 389
 
390
-        if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
391
-            $sort_by = 'az';
392
-        }
390
+		if (trim($search_term) != '' && !isset($_REQUEST['sort_by'])) {
391
+			$sort_by = 'az';
392
+		}
393 393
 
394
-        if ($snear != '' &&  $sort_by!='farthest') {
395
-            $sort_by = 'nearest';
396
-        }
397
-    }
394
+		if ($snear != '' &&  $sort_by!='farthest') {
395
+			$sort_by = 'nearest';
396
+		}
397
+	}
398 398
 
399
-    switch ($sort_by):
400
-        case 'newest':
401
-            $orderby = "$wpdb->posts.post_date desc, ";
402
-            break;
403
-        case 'oldest':
404
-            $orderby = "$wpdb->posts.post_date asc, ";
405
-            break;
406
-        case 'low_review':
407
-        case 'rating_count_asc':
408
-            $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
409
-            break;
410
-        case 'high_review':
411
-        case 'rating_count_desc':
412
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
413
-            break;
414
-        case 'low_rating':
415
-            $orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
416
-            break;
417
-        case 'high_rating':
418
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
419
-            break;
420
-        case 'featured':
421
-            $orderby = $table . ".is_featured asc, ";
422
-            break;
423
-        case 'nearest':
424
-            $orderby = " distance asc, ";
425
-            break;
426
-        case 'farthest':
427
-            $orderby = " distance desc, ";
428
-            break;
429
-        case 'random':
430
-            $orderby = " rand(), ";
431
-            break;
432
-        case 'az':
433
-            $orderby = "$wpdb->posts.post_title asc, ";
434
-            break;
435
-        // sort by rating
436
-        case 'overall_rating_desc':
437
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
438
-            break;
439
-        case 'overall_rating_asc':
440
-            $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
441
-            break;
442
-        default:
443
-
444
-            break;
445
-    endswitch;
446
-
447
-    if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
448
-        if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
449
-            $orderby = "$wpdb->posts.comment_count DESC, ";
450
-            $sort_by = 'comment_count_desc';
451
-        } else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
452
-            $orderby = "$wpdb->posts.comment_count ASC, ";
453
-            $sort_by = 'comment_count_asc';
454
-        }
455
-    }
399
+	switch ($sort_by):
400
+		case 'newest':
401
+			$orderby = "$wpdb->posts.post_date desc, ";
402
+			break;
403
+		case 'oldest':
404
+			$orderby = "$wpdb->posts.post_date asc, ";
405
+			break;
406
+		case 'low_review':
407
+		case 'rating_count_asc':
408
+			$orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
409
+			break;
410
+		case 'high_review':
411
+		case 'rating_count_desc':
412
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
413
+			break;
414
+		case 'low_rating':
415
+			$orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
416
+			break;
417
+		case 'high_rating':
418
+			$orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
419
+			break;
420
+		case 'featured':
421
+			$orderby = $table . ".is_featured asc, ";
422
+			break;
423
+		case 'nearest':
424
+			$orderby = " distance asc, ";
425
+			break;
426
+		case 'farthest':
427
+			$orderby = " distance desc, ";
428
+			break;
429
+		case 'random':
430
+			$orderby = " rand(), ";
431
+			break;
432
+		case 'az':
433
+			$orderby = "$wpdb->posts.post_title asc, ";
434
+			break;
435
+		// sort by rating
436
+		case 'overall_rating_desc':
437
+			$orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
438
+			break;
439
+		case 'overall_rating_asc':
440
+			$orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
441
+			break;
442
+		default:
443
+
444
+			break;
445
+	endswitch;
446
+
447
+	if ($sort_by != '' && geodir_cpt_has_rating_disabled($geodir_post_type)) {
448
+		if (in_array($sort_by, array('high_review', 'rating_count_desc', 'high_rating', 'overall_rating_desc'))) {
449
+			$orderby = "$wpdb->posts.comment_count DESC, ";
450
+			$sort_by = 'comment_count_desc';
451
+		} else if (in_array($sort_by, array('low_review', 'rating_count_asc', 'low_rating', 'overall_rating_asc'))) {
452
+			$orderby = "$wpdb->posts.comment_count ASC, ";
453
+			$sort_by = 'comment_count_asc';
454
+		}
455
+	}
456 456
 
457
-    global $s;
457
+	global $s;
458 458
 
459
-    if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
460
-        $keywords = explode(" ", $s);
461
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
462
-            foreach($keywords as $kkey=>$kword){
463
-                if(geodir_utf8_strlen($kword)<=$klimit){
464
-                    unset($keywords[$kkey]);
465
-                }
466
-            }
467
-        }
468
-        if ($sort_by == 'nearest' || $sort_by == 'farthest') {
469
-            if (count($keywords) > 1) {
470
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
471
-            } else {
472
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
473
-            }
474
-        } else {
475
-            if (count($keywords) > 1) {
476
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby;
477
-            } else {
478
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
479
-            }
480
-        }
481
-    }
459
+	if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
460
+		$keywords = explode(" ", $s);
461
+		if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
462
+			foreach($keywords as $kkey=>$kword){
463
+				if(geodir_utf8_strlen($kword)<=$klimit){
464
+					unset($keywords[$kkey]);
465
+				}
466
+			}
467
+		}
468
+		if ($sort_by == 'nearest' || $sort_by == 'farthest') {
469
+			if (count($keywords) > 1) {
470
+				$orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
471
+			} else {
472
+				$orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
473
+			}
474
+		} else {
475
+			if (count($keywords) > 1) {
476
+				$orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby;
477
+			} else {
478
+				$orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
479
+			}
480
+		}
481
+	}
482 482
 
483
-    /**
484
-     * Filter order by SQL.
485
-     *
486
-     * @since 1.0.0
487
-     * @param string $orderby The orderby query string.
488
-     * @param string $sort_by Sortby query string.
489
-     * @param string $table Listing table name.
490
-     */
491
-    $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
483
+	/**
484
+	 * Filter order by SQL.
485
+	 *
486
+	 * @since 1.0.0
487
+	 * @param string $orderby The orderby query string.
488
+	 * @param string $sort_by Sortby query string.
489
+	 * @param string $table Listing table name.
490
+	 */
491
+	$orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
492 492
 
493
-    $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
493
+	$orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
494 494
 
495
-    return $orderby;
495
+	return $orderby;
496 496
 }
497 497
 
498 498
 
@@ -510,78 +510,78 @@  discard block
 block discarded – undo
510 510
 function geodir_posts_order_by_custom_sort($orderby, $sort_by, $table)
511 511
 {
512 512
 
513
-    global $wpdb;
513
+	global $wpdb;
514 514
 
515
-    if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
515
+	if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
516 516
 
517
-        $sort_array = explode('_', $sort_by);
517
+		$sort_array = explode('_', $sort_by);
518 518
 
519
-        $sort_by_count = count($sort_array);
519
+		$sort_by_count = count($sort_array);
520 520
 
521
-        $order = $sort_array[$sort_by_count - 1];
521
+		$order = $sort_array[$sort_by_count - 1];
522 522
 
523
-        if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
523
+		if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
524 524
 
525
-            $sort_by = str_replace('_' . $order, '', $sort_by);
525
+			$sort_by = str_replace('_' . $order, '', $sort_by);
526 526
 
527
-            switch ($sort_by):
527
+			switch ($sort_by):
528 528
 
529
-                case 'post_date':
530
-                case 'comment_count':
529
+				case 'post_date':
530
+				case 'comment_count':
531 531
 
532
-                    $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
533
-                    break;
532
+					$orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
533
+					break;
534 534
 
535
-                case 'distance':
536
-                    $orderby = $sort_by . " " . $order . ", ";
537
-                    break;
535
+				case 'distance':
536
+					$orderby = $sort_by . " " . $order . ", ";
537
+					break;
538 538
 
539 539
 
540
-                // sort by rating
541
-                case 'overall_rating':
540
+				// sort by rating
541
+				case 'overall_rating':
542 542
 
543
-                    $use_bayesian = apply_filters('gd_use_bayesian',true,$table);
544
-                    $avg_rating = 0;
545
-                    if($use_bayesian){
546
-                        $avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
547
-                        if(!$avg_num_votes){
548
-                            $avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
549
-                            if($avg_num_votes){
543
+					$use_bayesian = apply_filters('gd_use_bayesian',true,$table);
544
+					$avg_rating = 0;
545
+					if($use_bayesian){
546
+						$avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
547
+						if(!$avg_num_votes){
548
+							$avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
549
+							if($avg_num_votes){
550 550
 
551
-                                $avg_rating = get_transient( 'gd_avg_rating_'.$table );
552
-                                if(!$avg_rating){
553
-                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
554
-                                }
555
-                                set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
556
-                                set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
557
-                            }
558
-                        }
551
+								$avg_rating = get_transient( 'gd_avg_rating_'.$table );
552
+								if(!$avg_rating){
553
+									$avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
554
+								}
555
+								set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
556
+								set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
557
+							}
558
+						}
559 559
 
560
-                        if(!$avg_num_votes){ $avg_num_votes = 0;}
560
+						if(!$avg_num_votes){ $avg_num_votes = 0;}
561 561
 
562
-                        $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
562
+						$orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
563 563
 
564
-                        //$orderby = " ( " . $table . ".rating_count * " . $table . ".overall_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating )   / ( " . $table . ".rating_count + " . $table . ".rating_count )  $order , "; // seems to work mostly with no extra overheads
565
-                    }else{
566
-                        $orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
567
-                    }
564
+						//$orderby = " ( " . $table . ".rating_count * " . $table . ".overall_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating )   / ( " . $table . ".rating_count + " . $table . ".rating_count )  $order , "; // seems to work mostly with no extra overheads
565
+					}else{
566
+						$orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
567
+					}
568 568
 
569
-                    break;
569
+					break;
570 570
 
571 571
 
572
-                default:
573
-                    if (geodir_column_exist($table, $sort_by)) {
572
+				default:
573
+					if (geodir_column_exist($table, $sort_by)) {
574 574
 						$orderby = $table . "." . $sort_by . " " . $order . ", ";
575 575
 					}
576
-                    break;
576
+					break;
577 577
 
578
-            endswitch;
578
+			endswitch;
579 579
 
580
-        }
580
+		}
581 581
 
582
-    }
582
+	}
583 583
 
584
-    return $orderby;
584
+	return $orderby;
585 585
 }
586 586
 
587 587
 /**
@@ -596,35 +596,35 @@  discard block
 block discarded – undo
596 596
 {
597 597
 
598 598
 
599
-    global $wpdb, $geodir_post_type, $table, $s, $snear;
599
+	global $wpdb, $geodir_post_type, $table, $s, $snear;
600 600
 
601
-    if (!is_admin()) {
601
+	if (!is_admin()) {
602 602
 
603
-        if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
604
-            add_filter('posts_where', 'geodir_edit_listing_where', 1);
603
+		if (geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
604
+			add_filter('posts_where', 'geodir_edit_listing_where', 1);
605 605
 
606
-        } elseif ((is_search() && $_REQUEST['geodir_search'])) {
606
+		} elseif ((is_search() && $_REQUEST['geodir_search'])) {
607 607
 
608
-            add_filter('posts_where', 'searching_filter_where', 1);
608
+			add_filter('posts_where', 'searching_filter_where', 1);
609 609
 
610
-            if ($snear != '')
611
-                add_filter('posts_where', 'searching_filter_where', 1);
610
+			if ($snear != '')
611
+				add_filter('posts_where', 'searching_filter_where', 1);
612 612
 
613
-            add_filter('posts_orderby', 'geodir_posts_orderby', 1);
613
+			add_filter('posts_orderby', 'geodir_posts_orderby', 1);
614 614
 			add_filter( 'posts_clauses', 'geodir_posts_having', 99999, 2 );
615 615
 
616
-        } elseif (geodir_is_page('author')) {
616
+		} elseif (geodir_is_page('author')) {
617 617
 
618
-            add_filter('posts_where', 'author_filter_where', 1);
618
+			add_filter('posts_where', 'author_filter_where', 1);
619 619
 
620
-        }
620
+		}
621 621
 
622
-        //if (!geodir_is_page('detail'))
623
-            add_filter('posts_where', 'geodir_default_where', 1);/**/
622
+		//if (!geodir_is_page('detail'))
623
+			add_filter('posts_where', 'geodir_default_where', 1);/**/
624 624
 
625
-        //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
625
+		//add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
626 626
 
627
-    }
627
+	}
628 628
 }
629 629
 
630 630
 /**
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
  */
640 640
 function geodir_preview_post_cap($allcaps, $caps, $args)
641 641
 {
642
-    $user_id = get_current_user_id();
643
-    if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
642
+	$user_id = get_current_user_id();
643
+	if ($user_id && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' && isset($_REQUEST['p']) && $_REQUEST['p'] != '' && $args[0] == 'edit_post' && $_REQUEST['p'] == $args[2]) {
644 644
 
645
-        $allcaps['edit_posts'] = true;
646
-    }
647
-    //print_r($allcaps);
648
-    return $allcaps;
645
+		$allcaps['edit_posts'] = true;
646
+	}
647
+	//print_r($allcaps);
648
+	return $allcaps;
649 649
 }
650 650
 
651 651
 
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
  */
661 661
 function geodir_edit_listing_where($where)
662 662
 {
663
-    global $wpdb;
664
-    $where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
665
-    return $where;
663
+	global $wpdb;
664
+	$where = $wpdb->prepare(" AND $wpdb->posts.ID = %d ", $_REQUEST['pid']);
665
+	return $where;
666 666
 }
667 667
 
668 668
 
@@ -679,29 +679,29 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function geodir_default_where($where)
681 681
 {
682
-    global $wp_query, $wpdb;
683
-
684
-    //print_r($wp_query);
685
-    ########### WPML ###########
686
-
687
-    if (geodir_is_wpml()) {
688
-        global $sitepress, $table_prefix;
689
-        $lang_code = ICL_LANGUAGE_CODE;
690
-        $default_lang_code = $sitepress->get_default_language();
691
-        $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
692
-        //echo '##########'.$q_post_type;
693
-        if ($lang_code && $q_post_type && geodir_wpml_is_post_type_translated($q_post_type)) {
694
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
695
-            //$where .= " AND icl_t.language_code = '$lang_code' ";
696
-        }
682
+	global $wp_query, $wpdb;
697 683
 
698
-    }
699
-    ########### WPML ###########
684
+	//print_r($wp_query);
685
+	########### WPML ###########
686
+
687
+	if (geodir_is_wpml()) {
688
+		global $sitepress, $table_prefix;
689
+		$lang_code = ICL_LANGUAGE_CODE;
690
+		$default_lang_code = $sitepress->get_default_language();
691
+		$q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
692
+		//echo '##########'.$q_post_type;
693
+		if ($lang_code && $q_post_type && geodir_wpml_is_post_type_translated($q_post_type)) {
694
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
695
+			//$where .= " AND icl_t.language_code = '$lang_code' ";
696
+		}
697
+
698
+	}
699
+	########### WPML ###########
700 700
 
701 701
 
702
-    return $where = str_replace("0 = 1", "1=1", $where);
702
+	return $where = str_replace("0 = 1", "1=1", $where);
703 703
 
704
-    /* ====== old code start ===
704
+	/* ====== old code start ===
705 705
     $where = str_replace("0 = 1", "1=1", $where);
706 706
     $country = get_query_var('gd_country');
707 707
     $region = get_query_var('gd_region');
@@ -742,94 +742,94 @@  discard block
 block discarded – undo
742 742
  * @return string Modified where query string.
743 743
  */
744 744
 function searching_filter_where($where) {
745
-    global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session;
745
+	global $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $s, $snear, $s_A, $s_SA, $search_term, $gd_session;
746 746
 
747
-    $search_term = 'OR';
748
-    $search_term = 'AND';
749
-    $geodir_custom_search = '';
750
-    $category_search_range = '';
747
+	$search_term = 'OR';
748
+	$search_term = 'AND';
749
+	$geodir_custom_search = '';
750
+	$category_search_range = '';
751 751
 
752
-    if (is_single() && get_query_var('post_type')) {
752
+	if (is_single() && get_query_var('post_type')) {
753 753
 		return $where;
754 754
 	}
755 755
 
756
-    if (is_tax()) {
756
+	if (is_tax()) {
757 757
 		return $where;
758 758
 	}
759 759
 
760 760
 	$s = trim($s);
761
-    $s  = wp_specialchars_decode($s ,ENT_QUOTES);
762
-    $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES);
763
-
764
-    $where = '';
765
-    $better_search_terms = '';
766
-    if (isset($_REQUEST['stype']))
767
-        $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
768
-    else
769
-        $post_types = 'gd_place';
770
-
771
-    if ($s != '') {
772
-        $keywords = explode(" ", $s);
773
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
774
-            foreach($keywords as $kkey=>$kword){
775
-                if(geodir_utf8_strlen($kword)<=$klimit){
776
-                    unset($keywords[$kkey]);
777
-                }
778
-            }
779
-        }
761
+	$s  = wp_specialchars_decode($s ,ENT_QUOTES);
762
+	$s_A = wp_specialchars_decode($s_A ,ENT_QUOTES);
763
+
764
+	$where = '';
765
+	$better_search_terms = '';
766
+	if (isset($_REQUEST['stype']))
767
+		$post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
768
+	else
769
+		$post_types = 'gd_place';
780 770
 
781
-        if (!empty($keywords)) {
782
-            foreach ($keywords as $keyword) {
783
-                $keyword = trim($keyword);
784
-                $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
785
-                if ($keyword != '') {
786
-                    /**
787
-                     * Filter the search query keywords SQL.
788
-                     *
789
-                     * @since 1.5.9
790
-                     * @package GeoDirectory
791
-                     * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`.
792
-                     * @param array $keywords The array of keywords for the query.
793
-                     * @param string $keyword The single keyword being searched.
794
-                     */
771
+	if ($s != '') {
772
+		$keywords = explode(" ", $s);
773
+		if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
774
+			foreach($keywords as $kkey=>$kword){
775
+				if(geodir_utf8_strlen($kword)<=$klimit){
776
+					unset($keywords[$kkey]);
777
+				}
778
+			}
779
+		}
780
+
781
+		if (!empty($keywords)) {
782
+			foreach ($keywords as $keyword) {
783
+				$keyword = trim($keyword);
784
+				$keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
785
+				if ($keyword != '') {
786
+					/**
787
+					 * Filter the search query keywords SQL.
788
+					 *
789
+					 * @since 1.5.9
790
+					 * @package GeoDirectory
791
+					 * @param string $better_search_terms The query values, default: `' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )'`.
792
+					 * @param array $keywords The array of keywords for the query.
793
+					 * @param string $keyword The single keyword being searched.
794
+					 */
795 795
 					$better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
796
-                }
797
-            }
798
-        }
799
-    }
796
+				}
797
+			}
798
+		}
799
+	}
800 800
 
801
-    /* get taxonomy */
802
-    $taxonomies = geodir_get_taxonomies($post_types, true);
803
-    if($taxonomies) {
804
-        $taxonomies = implode("','", $taxonomies);
805
-        $taxonomies = "'" . $taxonomies . "'";
806
-    }else{$taxonomies='';}
801
+	/* get taxonomy */
802
+	$taxonomies = geodir_get_taxonomies($post_types, true);
803
+	if($taxonomies) {
804
+		$taxonomies = implode("','", $taxonomies);
805
+		$taxonomies = "'" . $taxonomies . "'";
806
+	}else{$taxonomies='';}
807 807
 
808
-    $content_where = $terms_where = '';
809
-    $terms_sql    = '';
808
+	$content_where = $terms_where = '';
809
+	$terms_sql    = '';
810 810
 	if ($s != '') {
811
-        /**
812
-         * Filter the search query content where values.
813
-         *
814
-         * @since 1.5.0
815
-         * @package GeoDirectory
816
-         *
817
-         * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`.
818
-         */
819
-        $content_where = apply_filters( "geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") " );
820
-        /**
821
-         * Filter the search query term values.
822
-         *
823
-         * @since 1.5.0
824
-         * @package GeoDirectory
825
-         *
826
-         * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`.
827
-         */
828
-        $terms_where = apply_filters( "geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) " );
829
-
830
-
831
-        // get term sql
832
-        $term_sql = "SELECT $wpdb->term_taxonomy.term_id, $wpdb->terms.name, $wpdb->term_taxonomy.taxonomy
811
+		/**
812
+		 * Filter the search query content where values.
813
+		 *
814
+		 * @since 1.5.0
815
+		 * @package GeoDirectory
816
+		 *
817
+		 * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`.
818
+		 */
819
+		$content_where = apply_filters( "geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") " );
820
+		/**
821
+		 * Filter the search query term values.
822
+		 *
823
+		 * @since 1.5.0
824
+		 * @package GeoDirectory
825
+		 *
826
+		 * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`.
827
+		 */
828
+		$terms_where = apply_filters( "geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) " );
829
+
830
+
831
+		// get term sql
832
+		$term_sql = "SELECT $wpdb->term_taxonomy.term_id, $wpdb->terms.name, $wpdb->term_taxonomy.taxonomy
833 833
                     FROM $wpdb->term_taxonomy,  $wpdb->terms, $wpdb->term_relationships
834 834
                     WHERE $wpdb->term_taxonomy.term_id =  $wpdb->terms.term_id
835 835
                     AND $wpdb->term_relationships.term_taxonomy_id =  $wpdb->term_taxonomy.term_taxonomy_id
@@ -837,46 +837,46 @@  discard block
 block discarded – undo
837 837
                     $terms_where
838 838
                     GROUP BY $wpdb->term_taxonomy.term_id";
839 839
 
840
-        $term_results = $wpdb->get_results( $term_sql );
841
-        $term_ids     = array();
842
-        $terms_sql    = '';
843
-
844
-        if ( ! empty( $term_results ) ) {
845
-            foreach ( $term_results as $term_id ) {
846
-                $term_ids[] = $term_id;
847
-            }
848
-            if ( ! empty( $term_ids ) ) {
849
-                foreach ( $term_ids as $term ) {
850
-                    if ( $term->taxonomy == $post_types . '_tags' ) {
851
-                        $terms_sql .= $wpdb->prepare( " OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name );
852
-                    } else {
853
-                        $terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
854
-                    }
855
-                }
856
-            }
857
-        }
840
+		$term_results = $wpdb->get_results( $term_sql );
841
+		$term_ids     = array();
842
+		$terms_sql    = '';
858 843
 
859
-    }
844
+		if ( ! empty( $term_results ) ) {
845
+			foreach ( $term_results as $term_id ) {
846
+				$term_ids[] = $term_id;
847
+			}
848
+			if ( ! empty( $term_ids ) ) {
849
+				foreach ( $term_ids as $term ) {
850
+					if ( $term->taxonomy == $post_types . '_tags' ) {
851
+						$terms_sql .= $wpdb->prepare( " OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name );
852
+					} else {
853
+						$terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
854
+					}
855
+				}
856
+			}
857
+		}
860 858
 
861
-    if ($snear != '') {
859
+	}
862 860
 
861
+	if ($snear != '') {
863 862
 
864
-        if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
865
-            $dist = $gd_session->get('near_me_range');
866
-        }
867
-        $lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69);
868
-        $lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69);
869
-        $lat1 = $mylat - ($dist / 69);
870
-        $lat2 = $mylat + ($dist / 69);
871 863
 
872
-        $rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : '';
873
-        $rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : '';
874
-        $rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : '';
875
-        $rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : '';
864
+		if (is_numeric($gd_session->get('near_me_range')) && !isset($_REQUEST['sdist'])) {
865
+			$dist = $gd_session->get('near_me_range');
866
+		}
867
+		$lon1 = $mylon - $dist / abs(cos(deg2rad($mylat)) * 69);
868
+		$lon2 = $mylon + $dist / abs(cos(deg2rad($mylat)) * 69);
869
+		$lat1 = $mylat - ($dist / 69);
870
+		$lat2 = $mylat + ($dist / 69);
871
+
872
+		$rlon1 = is_numeric(min($lon1, $lon2)) ? min($lon1, $lon2) : '';
873
+		$rlon2 = is_numeric(max($lon1, $lon2)) ? max($lon1, $lon2) : '';
874
+		$rlat1 = is_numeric(min($lat1, $lat2)) ? min($lat1, $lat2) : '';
875
+		$rlat2 = is_numeric(max($lat1, $lat2)) ? max($lat1, $lat2) : '';
876 876
 
877 877
 
878 878
 		$post_title_where = $s != "" ? "{$wpdb->posts}.post_title LIKE \"$s\"" : "1=1";
879
-	    $where .= " AND ( ( $post_title_where $better_search_terms)
879
+		$where .= " AND ( ( $post_title_where $better_search_terms)
880 880
 			                    $content_where 
881 881
 								$terms_sql 
882 882
 							)
@@ -885,35 +885,35 @@  discard block
 block discarded – undo
885 885
 						AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 )
886 886
 						AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) ";
887 887
 
888
-        if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
889
-            $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
890
-            $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
891
-        }
888
+		if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
889
+			$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
890
+			$where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
891
+		}
892 892
 
893
-    } else {
893
+	} else {
894 894
 
895 895
 
896
-        $post_title_where = $s != "" ? "{$wpdb->posts}.post_title LIKE \"$s\"" : "1=1";
897
-        $where .= " AND (	( $post_title_where $better_search_terms)
896
+		$post_title_where = $s != "" ? "{$wpdb->posts}.post_title LIKE \"$s\"" : "1=1";
897
+		$where .= " AND (	( $post_title_where $better_search_terms)
898 898
                             $content_where  
899 899
 							$terms_sql 
900 900
 					    ) 
901 901
 					
902 902
 				AND $wpdb->posts.post_type in ('$post_types')
903 903
 				AND ($wpdb->posts.post_status = 'publish') ";
904
-    }
904
+	}
905 905
 
906 906
 	########### WPML ###########
907
-    if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
907
+	if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
908 908
 		$lang_code = ICL_LANGUAGE_CODE;
909 909
 
910 910
 		if ($lang_code && $post_types) {
911
-            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
912
-        }
913
-    }
914
-    ########### WPML ###########
911
+			$where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
912
+		}
913
+	}
914
+	########### WPML ###########
915 915
 
916
-    return $where;
916
+	return $where;
917 917
 }
918 918
 
919 919
 
@@ -928,45 +928,45 @@  discard block
 block discarded – undo
928 928
  * @return string Modified where query string.
929 929
  */
930 930
 function author_filter_where($where) {
931
-    global $wpdb, $geodir_post_type, $table, $curr;
931
+	global $wpdb, $geodir_post_type, $table, $curr;
932 932
 
933
-    $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
934
-    $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
933
+	$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
934
+	$user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
935 935
 
936
-    if (isset($_REQUEST['stype'])) {
937
-        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
938
-    } else {
939
-        $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
940
-    }
936
+	if (isset($_REQUEST['stype'])) {
937
+		$where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
938
+	} else {
939
+		$where = " AND $wpdb->posts.post_type IN ('gd_place') ";
940
+	}
941 941
 
942
-    if ($user_id > 0) {
943
-        if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
944
-            $user_fav_posts = geodir_get_user_favourites($user_id);
945
-            $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
946
-            $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
947
-        } else
948
-            $where .= " AND $wpdb->posts.post_author = $user_id";
949
-
950
-        if ($user_id == (int)get_current_user_id()) {
951
-            $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
952
-        } else {
953
-            $where .= " AND $wpdb->posts.post_status = 'publish' ";
954
-        }
955
-    } else {
956
-        $where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' ";
957
-    }
942
+	if ($user_id > 0) {
943
+		if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
944
+			$user_fav_posts = geodir_get_user_favourites($user_id);
945
+			$user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
946
+			$where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
947
+		} else
948
+			$where .= " AND $wpdb->posts.post_author = $user_id";
949
+
950
+		if ($user_id == (int)get_current_user_id()) {
951
+			$where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
952
+		} else {
953
+			$where .= " AND $wpdb->posts.post_status = 'publish' ";
954
+		}
955
+	} else {
956
+		$where .= " AND $wpdb->posts.post_author = '-1' AND $wpdb->posts.post_status = 'publish' ";
957
+	}
958 958
 
959
-    ########### WPML ###########
960
-    if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
961
-        $lang_code = ICL_LANGUAGE_CODE;
962
-        if ($lang_code) {
963
-            $where .= " AND icl_t.language_code='" . $lang_code . "' ";
964
-        }
959
+	########### WPML ###########
960
+	if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
961
+		$lang_code = ICL_LANGUAGE_CODE;
962
+		if ($lang_code) {
963
+			$where .= " AND icl_t.language_code='" . $lang_code . "' ";
964
+		}
965 965
 
966
-    }
967
-    ########### WPML ###########
966
+	}
967
+	########### WPML ###########
968 968
 
969
-    return $where;
969
+	return $where;
970 970
 }
971 971
 
972 972
 /**
@@ -981,11 +981,11 @@  discard block
 block discarded – undo
981 981
  */
982 982
 function geodir_filter_widget_join($join)
983 983
 {
984
-    global $wp_query, $table;
985
-    if (!empty($wp_query->query['with_pics_only'])) {
986
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
987
-    }
988
-    return $join;
984
+	global $wp_query, $table;
985
+	if (!empty($wp_query->query['with_pics_only'])) {
986
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
987
+	}
988
+	return $join;
989 989
 }
990 990
 
991 991
 /**
@@ -1000,43 +1000,43 @@  discard block
 block discarded – undo
1000 1000
  */
1001 1001
 function geodir_filter_widget_where($where)
1002 1002
 {
1003
-    global $wp_query, $table;
1004
-    if (!empty($wp_query->query['show_featured_only'])) {
1005
-        $where .= " AND " . $table . ".is_featured = '1'";
1006
-    }
1007
-    if (!empty($wp_query->query['show_special_only'])) {
1008
-        $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1009
-    }
1010
-    if (!empty($wp_query->query['with_pics_only'])) {
1011
-        $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1012
-    }
1013
-    if (!empty($wp_query->query['with_videos_only'])) {
1014
-        $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1015
-    }
1016
-    return $where;
1003
+	global $wp_query, $table;
1004
+	if (!empty($wp_query->query['show_featured_only'])) {
1005
+		$where .= " AND " . $table . ".is_featured = '1'";
1006
+	}
1007
+	if (!empty($wp_query->query['show_special_only'])) {
1008
+		$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1009
+	}
1010
+	if (!empty($wp_query->query['with_pics_only'])) {
1011
+		$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1012
+	}
1013
+	if (!empty($wp_query->query['with_videos_only'])) {
1014
+		$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1015
+	}
1016
+	return $where;
1017 1017
 }
1018 1018
 
1019 1019
 
1020 1020
 function geodir_related_posts_fields($fields) {
1021
-    global $wp_query, $wpdb, $table, $post;
1021
+	global $wp_query, $wpdb, $table, $post;
1022 1022
 
1023
-    $fields .= ", " . $table . ".* ";
1023
+	$fields .= ", " . $table . ".* ";
1024 1024
 
1025
-    $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1025
+	$DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1026 1026
 
1027
-    $mylat = $post->post_latitude;
1028
-    $mylon = $post->post_longitude;
1027
+	$mylat = $post->post_latitude;
1028
+	$mylon = $post->post_longitude;
1029 1029
 
1030
-    $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
1031
-    return $fields;
1030
+	$fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
1031
+	return $fields;
1032 1032
 }
1033 1033
 function geodir_related_posts_fields_filter($query) {
1034
-    if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1035
-        && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1036
-        && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1037
-    ) {
1038
-        add_filter('posts_fields', 'geodir_related_posts_fields', 1);
1039
-    }
1034
+	if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1035
+		&& isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1036
+		&& isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1037
+	) {
1038
+		add_filter('posts_fields', 'geodir_related_posts_fields', 1);
1039
+	}
1040 1040
 }
1041 1041
 add_action('pre_get_posts', 'geodir_related_posts_fields_filter', 1);
1042 1042
 
@@ -1051,30 +1051,30 @@  discard block
 block discarded – undo
1051 1051
  * @return string|null If field exists in table returns order by clause else returns empty.
1052 1052
  */
1053 1053
 function geodir_prepare_custom_sorting( $sorting, $table ) {
1054
-    $orderby = '';
1054
+	$orderby = '';
1055 1055
     
1056
-    if ( empty( $sorting ) || empty( $table ) ) {
1057
-        return $orderby;
1058
-    }
1056
+	if ( empty( $sorting ) || empty( $table ) ) {
1057
+		return $orderby;
1058
+	}
1059 1059
     
1060
-    if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1061
-        $sorting_array = explode( '_', $sorting );
1060
+	if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1061
+		$sorting_array = explode( '_', $sorting );
1062 1062
         
1063
-        if ( ( $count = count( $sorting_array ) ) > 1 ) {
1064
-            $order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1065
-            array_pop( $sorting_array );
1063
+		if ( ( $count = count( $sorting_array ) ) > 1 ) {
1064
+			$order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1065
+			array_pop( $sorting_array );
1066 1066
             
1067
-            if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1068
-                $sort_by = implode( '_', $sorting_array );
1067
+			if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1068
+				$sort_by = implode( '_', $sorting_array );
1069 1069
                 
1070
-                if ( geodir_column_exist( $table, $sort_by ) ) {
1071
-                    $orderby = $table . "." . $sort_by . " " . $order;
1072
-                }
1073
-            }
1074
-        }
1075
-    }
1070
+				if ( geodir_column_exist( $table, $sort_by ) ) {
1071
+					$orderby = $table . "." . $sort_by . " " . $order;
1072
+				}
1073
+			}
1074
+		}
1075
+	}
1076 1076
 
1077
-    return $orderby;
1077
+	return $orderby;
1078 1078
 }
1079 1079
 
1080 1080
 /**
@@ -1094,21 +1094,21 @@  discard block
 block discarded – undo
1094 1094
  * @return string Modified fields SQL.
1095 1095
  */
1096 1096
 function geodir_search_widget_location_filter_fields( $fields, $table, $post_type ) {
1097
-    global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1097
+	global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1098 1098
 
1099
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1100
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1099
+	if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1100
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1101 1101
 
1102
-        if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1103
-            $latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1104
-            $longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1105
-            $radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1102
+		if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1103
+			$latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1104
+			$longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1105
+			$radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1106 1106
 
1107
-            $fields .= $wpdb->prepare( ", (" . $radius . " * 2 * ASIN(SQRT(POWER(SIN((ABS(%s) - ABS(" . $table . ".post_latitude)) * PI() / 180 / 2), 2) + COS(ABS(%s) * PI() / 180) * COS(ABS(" . $table . ".post_latitude) * PI() / 180) * POWER(SIN((%s - " . $table . ".post_longitude) * PI() / 180 / 2), 2)))) AS distance ", $latitude, $latitude, $longitude );
1108
-        }
1109
-    }
1107
+			$fields .= $wpdb->prepare( ", (" . $radius . " * 2 * ASIN(SQRT(POWER(SIN((ABS(%s) - ABS(" . $table . ".post_latitude)) * PI() / 180 / 2), 2) + COS(ABS(%s) * PI() / 180) * COS(ABS(" . $table . ".post_latitude) * PI() / 180) * POWER(SIN((%s - " . $table . ".post_longitude) * PI() / 180 / 2), 2)))) AS distance ", $latitude, $latitude, $longitude );
1108
+		}
1109
+	}
1110 1110
 
1111
-    return $fields;
1111
+	return $fields;
1112 1112
 }
1113 1113
 
1114 1114
 /**
@@ -1127,17 +1127,17 @@  discard block
 block discarded – undo
1127 1127
  * @return string Modified fields SQL.
1128 1128
  */
1129 1129
 function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) {
1130
-    global $gd_query_args_widgets, $snear, $gd_session;
1130
+	global $gd_query_args_widgets, $snear, $gd_session;
1131 1131
 
1132
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1133
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1132
+	if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1133
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1134 1134
 
1135
-        if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1136
-            $orderby = "distance ASC, " . $orderby;
1137
-        }
1138
-    }
1135
+		if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1136
+			$orderby = "distance ASC, " . $orderby;
1137
+		}
1138
+	}
1139 1139
 
1140
-    return $orderby;
1140
+	return $orderby;
1141 1141
 }
1142 1142
 
1143 1143
 /**
@@ -1148,23 +1148,23 @@  discard block
 block discarded – undo
1148 1148
  * @return string Filtered url.
1149 1149
  */
1150 1150
 function geodir_search_page_base_url() {
1151
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1152
-        remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1153
-    }
1151
+	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1152
+		remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1153
+	}
1154 1154
 
1155
-    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1156
-        $url = icl_get_home_url();
1157
-    } else {
1158
-        $url = get_home_url();
1159
-    }
1155
+	if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1156
+		$url = icl_get_home_url();
1157
+	} else {
1158
+		$url = get_home_url();
1159
+	}
1160 1160
 
1161
-    $url = trailingslashit( $url );
1161
+	$url = trailingslashit( $url );
1162 1162
 
1163
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1164
-        add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1165
-    }
1163
+	if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1164
+		add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1165
+	}
1166 1166
 
1167
-    return apply_filters( 'geodir_search_page_base_url', $url );
1167
+	return apply_filters( 'geodir_search_page_base_url', $url );
1168 1168
 }
1169 1169
 
1170 1170
 /**
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 function geodir_jetpack_fix_post_types_search(){
1176 1176
 	if ( defined( 'JETPACK__VERSION' ) && ! empty( $_REQUEST['geodir_search'] ) ) {
1177 1177
 		add_filter( 'jetpack_search_should_handle_query', '__return_false', 999, 1 );
1178
-    }
1178
+	}
1179 1179
 }
1180 1180
 add_action( 'plugins_loaded','geodir_jetpack_fix_post_types_search', 10 );
1181 1181
 
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
  * @global string $s_A Extra parameters.
66 66
  * @global string $s_SA Extra parameters.
67 67
  */
68
-function set_listing_request($query )
68
+function set_listing_request($query)
69 69
 {
70 70
     global $wp_query, $wpdb, $geodir_post_type, $table, $dist, $mylat, $mylon, $s, $snear, $s, $s_A, $s_SA;
71 71
 
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
         } //  Distance
100 100
 
101 101
         if (isset($_REQUEST['sgeo_lat'])) {
102
-            $mylat = (float)esc_attr($_REQUEST['sgeo_lat']);
102
+            $mylat = (float) esc_attr($_REQUEST['sgeo_lat']);
103 103
         } else {
104
-            $mylat = (float)geodir_get_current_city_lat();
104
+            $mylat = (float) geodir_get_current_city_lat();
105 105
         } //  Latitude
106 106
 
107 107
         if (isset($_REQUEST['sgeo_lon'])) {
108
-            $mylon = (float)esc_attr($_REQUEST['sgeo_lon']);
108
+            $mylon = (float) esc_attr($_REQUEST['sgeo_lon']);
109 109
         } else {
110
-            $mylon = (float)geodir_get_current_city_lng();
110
+            $mylon = (float) geodir_get_current_city_lng();
111 111
         } //  Distance
112 112
 
113 113
         if (isset($_REQUEST['snear'])) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
         if ($snear == 'NEAR ME') {
122 122
             $ip = $_SERVER['REMOTE_ADDR'];
123
-            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $ip));
123
+            $addr_details = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
124 124
             $mylat = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_latitude]));
125 125
             $mylon = stripslashes(geodir_utf8_ucfirst($addr_details[geoplugin_longitude]));
126 126
         }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
             $s_AA = str_replace(" ", "", $s);
131 131
             $s_A = explode(",", $s_AA);
132 132
             $s_A = implode('","', $s_A);
133
-            $s_A = '"' . $s_A . '"';
133
+            $s_A = '"'.$s_A.'"';
134 134
         } else {
135
-            $s_A = '"' . $s . '"';
135
+            $s_A = '"'.$s.'"';
136 136
         }
137 137
 
138 138
         if (strstr($s, ' ')) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     }
194 194
     if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) {
195 195
 
196
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
196
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
197 197
 
198 198
         add_filter('posts_fields', 'geodir_posts_fields', 1);
199 199
         add_filter('posts_join', 'geodir_posts_join', 1);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     global $wp_query, $wpdb, $geodir_post_type, $table, $plugin_prefix, $dist, $mylat, $mylon, $snear, $gd_session;
234 234
 
235 235
     // Filter-Location-Manager to add location table.
236
-    $fields .= ", " . $table . ".* ";
236
+    $fields .= ", ".$table.".* ";
237 237
 
238 238
 	if ($snear != '' || $gd_session->get('all_near_me')) {
239 239
         $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
             $mylon = $gd_session->get('user_lon');
244 244
         }
245 245
 
246
-        $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
246
+        $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
247 247
     }
248 248
 
249 249
     global $s;
250 250
     if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
251 251
         $keywords = explode(" ", $s);
252 252
 
253
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
254
-            foreach($keywords as $kkey=>$kword){
255
-                if(geodir_utf8_strlen($kword)<=$klimit){
253
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
254
+            foreach ($keywords as $kkey=>$kword) {
255
+                if (geodir_utf8_strlen($kword) <= $klimit) {
256 256
                     unset($keywords[$kkey]);
257 257
                 }
258 258
             }
@@ -270,24 +270,24 @@  discard block
 block discarded – undo
270 270
                 $count = 0;
271 271
                 foreach ($keywords as $keyword) {
272 272
                     $keyword = trim($keyword);
273
-                    $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
273
+                    $keyword = wp_specialchars_decode($keyword, ENT_QUOTES);
274 274
 					$count++;
275 275
                     if ($count < count($keywords)) {
276 276
                        // $gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' " . $key . " ";
277
-						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) " . $key . " ";
277
+						$gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ".$key." ";
278 278
                     } else {
279 279
                         //$gd_titlematch_part .= $wpdb->posts . ".post_title LIKE '%%" . $keyword . "%%' ";
280
-						$gd_titlematch_part .= "( " . $wpdb->posts . ".post_title LIKE '" . $keyword . "' OR " . $wpdb->posts . ".post_title LIKE '" . $keyword . "%%' OR " . $wpdb->posts . ".post_title LIKE '%% " . $keyword . "%%' ) ";
280
+						$gd_titlematch_part .= "( ".$wpdb->posts.".post_title LIKE '".$keyword."' OR ".$wpdb->posts.".post_title LIKE '".$keyword."%%' OR ".$wpdb->posts.".post_title LIKE '%% ".$keyword."%%' ) ";
281 281
                     }
282 282
                 }
283
-                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS " . $part . ",";
283
+                $gd_titlematch_part .= "THEN 1 ELSE 0 END AS ".$part.",";
284 284
             }
285 285
         } else {
286 286
             $gd_titlematch_part = "";
287 287
         }
288
-        $s = stripslashes_deep( $s );
289
-        $s = wp_specialchars_decode($s,ENT_QUOTES);
290
-		$fields .= $wpdb->prepare(", CASE WHEN " . $table . ".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN " . $wpdb->posts . ".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle," . $gd_titlematch_part . " CASE WHEN ( " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s OR " . $wpdb->posts . ".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s OR " . $wpdb->posts . ".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s . '%', '% ' . $s . '%', $s, $s . ' %', '% ' . $s . ' %', '% ' . $s,'%>' . $s . '%','% ' . $s . ','));
288
+        $s = stripslashes_deep($s);
289
+        $s = wp_specialchars_decode($s, ENT_QUOTES);
290
+		$fields .= $wpdb->prepare(", CASE WHEN ".$table.".is_featured='1' THEN 1 ELSE 0 END AS gd_featured, CASE WHEN ".$wpdb->posts.".post_title LIKE %s THEN 1 ELSE 0 END AS gd_exacttitle,".$gd_titlematch_part." CASE WHEN ( ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s OR ".$wpdb->posts.".post_title LIKE %s ) THEN 1 ELSE 0 END AS gd_titlematch, CASE WHEN ( ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s OR ".$wpdb->posts.".post_content LIKE %s ) THEN 1 ELSE 0 END AS gd_content", array($s, $s, $s.'%', '% '.$s.'%', $s, $s.' %', '% '.$s.' %', '% '.$s, '%>'.$s.'%', '% '.$s.','));
291 291
     }
292 292
 
293 293
     return $fields;
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 
312 312
     ########### WPML ###########
313 313
 
314
-    if ( geodir_wpml_is_post_type_translated( $geodir_post_type ) ) {
314
+    if (geodir_wpml_is_post_type_translated($geodir_post_type)) {
315 315
         global $sitepress;
316 316
         $lang_code = ICL_LANGUAGE_CODE;
317 317
         $default_lang_code = $sitepress->get_default_language();
318 318
         if ($lang_code) {
319
-            $join .= "JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
319
+            $join .= "JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
320 320
         }
321 321
 
322 322
     }
323 323
     ########### WPML ###########
324 324
 
325
-    $join .= " INNER JOIN " . $table . " ON (" . $table . ".post_id = $wpdb->posts.ID)  ";
325
+    $join .= " INNER JOIN ".$table." ON (".$table.".post_id = $wpdb->posts.ID)  ";
326 326
     //===old code start
327 327
     //$join .= " INNER JOIN ".POST_LOCATION_TABLE." ON (".$table.".post_location_id = ".POST_LOCATION_TABLE.".location_id)  " ;//===old code end
328 328
 
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
             $sort_by = 'az';
392 392
         }
393 393
 
394
-        if ($snear != '' &&  $sort_by!='farthest') {
394
+        if ($snear != '' && $sort_by != 'farthest') {
395 395
             $sort_by = 'nearest';
396 396
         }
397 397
     }
@@ -405,20 +405,20 @@  discard block
 block discarded – undo
405 405
             break;
406 406
         case 'low_review':
407 407
         case 'rating_count_asc':
408
-            $orderby = $table . ".rating_count ASC, " . $table . ".overall_rating ASC, ";
408
+            $orderby = $table.".rating_count ASC, ".$table.".overall_rating ASC, ";
409 409
             break;
410 410
         case 'high_review':
411 411
         case 'rating_count_desc':
412
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
412
+            $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
413 413
             break;
414 414
         case 'low_rating':
415
-            $orderby = "( " . $table . ".overall_rating  ) ASC, " . $table . ".rating_count ASC,  ";
415
+            $orderby = "( ".$table.".overall_rating  ) ASC, ".$table.".rating_count ASC,  ";
416 416
             break;
417 417
         case 'high_rating':
418
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
418
+            $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, ";
419 419
             break;
420 420
         case 'featured':
421
-            $orderby = $table . ".is_featured asc, ";
421
+            $orderby = $table.".is_featured asc, ";
422 422
             break;
423 423
         case 'nearest':
424 424
             $orderby = " distance asc, ";
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
             break;
435 435
         // sort by rating
436 436
         case 'overall_rating_desc':
437
-            $orderby = " " . $table . ".overall_rating DESC, " . $table . ".rating_count DESC, ";
437
+            $orderby = " ".$table.".overall_rating DESC, ".$table.".rating_count DESC, ";
438 438
             break;
439 439
         case 'overall_rating_asc':
440
-            $orderby = " " . $table . ".overall_rating ASC, " . $table . ".rating_count ASC, ";
440
+            $orderby = " ".$table.".overall_rating ASC, ".$table.".rating_count ASC, ";
441 441
             break;
442 442
         default:
443 443
 
@@ -458,24 +458,24 @@  discard block
 block discarded – undo
458 458
 
459 459
     if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
460 460
         $keywords = explode(" ", $s);
461
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
462
-            foreach($keywords as $kkey=>$kword){
463
-                if(geodir_utf8_strlen($kword)<=$klimit){
461
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
462
+            foreach ($keywords as $kkey=>$kword) {
463
+                if (geodir_utf8_strlen($kword) <= $klimit) {
464 464
                     unset($keywords[$kkey]);
465 465
                 }
466 466
             }
467 467
         }
468 468
         if ($sort_by == 'nearest' || $sort_by == 'farthest') {
469 469
             if (count($keywords) > 1) {
470
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
470
+                $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
471 471
             } else {
472
-                $orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
472
+                $orderby = $orderby." ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ";
473 473
             }
474 474
         } else {
475 475
             if (count($keywords) > 1) {
476
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, " . $orderby;
476
+                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ".$orderby;
477 477
             } else {
478
-                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, " . $orderby;
478
+                $orderby = "( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_content * 1.5) DESC, ".$orderby;
479 479
             }
480 480
         }
481 481
     }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
      */
491 491
     $orderby = apply_filters('geodir_posts_order_by_sort', $orderby, $sort_by, $table);
492 492
 
493
-    $orderby .= $table . ".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
493
+    $orderby .= $table.".is_featured asc, $wpdb->posts.post_date desc, $wpdb->posts.post_title ";
494 494
 
495 495
     return $orderby;
496 496
 }
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
     global $wpdb;
514 514
 
515
-    if ($sort_by != '' && (!is_search() || ( isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear']=='' && ( $_REQUEST['s']=='' ||  $_REQUEST['s']==' ') ) )) {
515
+    if ($sort_by != '' && (!is_search() || (isset($_REQUEST['s']) && isset($_REQUEST['snear']) && $_REQUEST['snear'] == '' && ($_REQUEST['s'] == '' || $_REQUEST['s'] == ' ')))) {
516 516
 
517 517
         $sort_array = explode('_', $sort_by);
518 518
 
@@ -522,48 +522,48 @@  discard block
 block discarded – undo
522 522
 
523 523
         if ($sort_by_count > 1 && ($order == 'asc' || $order == 'desc')) {
524 524
 
525
-            $sort_by = str_replace('_' . $order, '', $sort_by);
525
+            $sort_by = str_replace('_'.$order, '', $sort_by);
526 526
 
527 527
             switch ($sort_by):
528 528
 
529 529
                 case 'post_date':
530 530
                 case 'comment_count':
531 531
 
532
-                    $orderby = "$wpdb->posts." . $sort_by . " " . $order . ", ".$table . ".overall_rating " . $order . ", ";
532
+                    $orderby = "$wpdb->posts.".$sort_by." ".$order.", ".$table.".overall_rating ".$order.", ";
533 533
                     break;
534 534
 
535 535
                 case 'distance':
536
-                    $orderby = $sort_by . " " . $order . ", ";
536
+                    $orderby = $sort_by." ".$order.", ";
537 537
                     break;
538 538
 
539 539
 
540 540
                 // sort by rating
541 541
                 case 'overall_rating':
542 542
 
543
-                    $use_bayesian = apply_filters('gd_use_bayesian',true,$table);
543
+                    $use_bayesian = apply_filters('gd_use_bayesian', true, $table);
544 544
                     $avg_rating = 0;
545
-                    if($use_bayesian){
546
-                        $avg_num_votes = get_transient( 'gd_avg_num_votes_'.$table );
547
-                        if(!$avg_num_votes){
545
+                    if ($use_bayesian) {
546
+                        $avg_num_votes = get_transient('gd_avg_num_votes_'.$table);
547
+                        if (!$avg_num_votes) {
548 548
                             $avg_num_votes = $wpdb->get_var("SELECT SUM(rating_count) FROM $table");
549
-                            if($avg_num_votes){
549
+                            if ($avg_num_votes) {
550 550
 
551
-                                $avg_rating = get_transient( 'gd_avg_rating_'.$table );
552
-                                if(!$avg_rating){
553
-                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table")/$avg_num_votes;
551
+                                $avg_rating = get_transient('gd_avg_rating_'.$table);
552
+                                if (!$avg_rating) {
553
+                                    $avg_rating = $wpdb->get_var("SELECT SUM(overall_rating) FROM $table") / $avg_num_votes;
554 554
                                 }
555
-                                set_transient( 'gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS );
556
-                                set_transient( 'gd_avg_rating_'.$table, $avg_rating , 12 * HOUR_IN_SECONDS );
555
+                                set_transient('gd_avg_num_votes_'.$table, $avg_num_votes, 12 * HOUR_IN_SECONDS);
556
+                                set_transient('gd_avg_rating_'.$table, $avg_rating, 12 * HOUR_IN_SECONDS);
557 557
                             }
558 558
                         }
559 559
 
560
-                        if(!$avg_num_votes){ $avg_num_votes = 0;}
560
+                        if (!$avg_num_votes) { $avg_num_votes = 0; }
561 561
 
562
-                        $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
562
+                        $orderby = " (( $avg_num_votes * $avg_rating ) + (".$table.".rating_count * ".$table.".overall_rating ))  / ( $avg_num_votes + ".$table.".rating_count )  $order , ";
563 563
 
564 564
                         //$orderby = " ( " . $table . ".rating_count * " . $table . ".overall_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating )   / ( " . $table . ".rating_count + " . $table . ".rating_count )  $order , "; // seems to work mostly with no extra overheads
565
-                    }else{
566
-                        $orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
565
+                    } else {
566
+                        $orderby = " ".$table.".".$sort_by."  ".$order.", ".$table.".rating_count ".$order.", ";
567 567
                     }
568 568
 
569 569
                     break;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
                 default:
573 573
                     if (geodir_column_exist($table, $sort_by)) {
574
-						$orderby = $table . "." . $sort_by . " " . $order . ", ";
574
+						$orderby = $table.".".$sort_by." ".$order.", ";
575 575
 					}
576 576
                     break;
577 577
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
                 add_filter('posts_where', 'searching_filter_where', 1);
612 612
 
613 613
             add_filter('posts_orderby', 'geodir_posts_orderby', 1);
614
-			add_filter( 'posts_clauses', 'geodir_posts_having', 99999, 2 );
614
+			add_filter('posts_clauses', 'geodir_posts_having', 99999, 2);
615 615
 
616 616
         } elseif (geodir_is_page('author')) {
617 617
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         }
621 621
 
622 622
         //if (!geodir_is_page('detail'))
623
-            add_filter('posts_where', 'geodir_default_where', 1);/**/
623
+            add_filter('posts_where', 'geodir_default_where', 1); /**/
624 624
 
625 625
         //add_filter( 'user_has_cap', 'geodir_preview_post_cap', 10, 3 );// let subscribers edit their own posts
626 626
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         $q_post_type = isset($wp_query->query['post_type']) ? $wp_query->query['post_type'] : '';
692 692
         //echo '##########'.$q_post_type;
693 693
         if ($lang_code && $q_post_type && geodir_wpml_is_post_type_translated($q_post_type)) {
694
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_" . $q_post_type . "') ";
694
+            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type IN('post_".$q_post_type."') ";
695 695
             //$where .= " AND icl_t.language_code = '$lang_code' ";
696 696
         }
697 697
 
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	}
759 759
 
760 760
 	$s = trim($s);
761
-    $s  = wp_specialchars_decode($s ,ENT_QUOTES);
762
-    $s_A = wp_specialchars_decode($s_A ,ENT_QUOTES);
761
+    $s = wp_specialchars_decode($s, ENT_QUOTES);
762
+    $s_A = wp_specialchars_decode($s_A, ENT_QUOTES);
763 763
 
764 764
     $where = '';
765 765
     $better_search_terms = '';
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
 
771 771
     if ($s != '') {
772 772
         $keywords = explode(" ", $s);
773
-        if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
774
-            foreach($keywords as $kkey=>$kword){
775
-                if(geodir_utf8_strlen($kword)<=$klimit){
773
+        if (is_array($keywords) && $klimit = get_option('geodir_search_word_limit')) {
774
+            foreach ($keywords as $kkey=>$kword) {
775
+                if (geodir_utf8_strlen($kword) <= $klimit) {
776 776
                     unset($keywords[$kkey]);
777 777
                 }
778 778
             }
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
         if (!empty($keywords)) {
782 782
             foreach ($keywords as $keyword) {
783 783
                 $keyword = trim($keyword);
784
-                $keyword  = wp_specialchars_decode($keyword ,ENT_QUOTES);
784
+                $keyword = wp_specialchars_decode($keyword, ENT_QUOTES);
785 785
                 if ($keyword != '') {
786 786
                     /**
787 787
                      * Filter the search query keywords SQL.
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
                      * @param array $keywords The array of keywords for the query.
793 793
                      * @param string $keyword The single keyword being searched.
794 794
                      */
795
-					$better_search_terms .= apply_filters("geodir_search_better_search_terms",' OR ( ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '" OR ' . $wpdb->posts . '.post_title LIKE "' . $keyword . '%" OR ' . $wpdb->posts . '.post_title LIKE "% ' . $keyword . '%" )',$keywords,$keyword);
795
+					$better_search_terms .= apply_filters("geodir_search_better_search_terms", ' OR ( '.$wpdb->posts.'.post_title LIKE "'.$keyword.'" OR '.$wpdb->posts.'.post_title LIKE "'.$keyword.'%" OR '.$wpdb->posts.'.post_title LIKE "% '.$keyword.'%" )', $keywords, $keyword);
796 796
                 }
797 797
             }
798 798
         }
@@ -800,13 +800,13 @@  discard block
 block discarded – undo
800 800
 
801 801
     /* get taxonomy */
802 802
     $taxonomies = geodir_get_taxonomies($post_types, true);
803
-    if($taxonomies) {
803
+    if ($taxonomies) {
804 804
         $taxonomies = implode("','", $taxonomies);
805
-        $taxonomies = "'" . $taxonomies . "'";
806
-    }else{$taxonomies='';}
805
+        $taxonomies = "'".$taxonomies."'";
806
+    } else {$taxonomies = ''; }
807 807
 
808 808
     $content_where = $terms_where = '';
809
-    $terms_sql    = '';
809
+    $terms_sql = '';
810 810
 	if ($s != '') {
811 811
         /**
812 812
          * Filter the search query content where values.
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
          *
817 817
          * @param string $content_where The query values, default: `" OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ") "`.
818 818
          */
819
-        $content_where = apply_filters( "geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") " );
819
+        $content_where = apply_filters("geodir_search_content_where", " OR ($wpdb->posts.post_content LIKE \"$s\" OR $wpdb->posts.post_content LIKE \"$s%\" OR $wpdb->posts.post_content LIKE \"% $s%\" OR $wpdb->posts.post_content LIKE \"%>$s%\" OR $wpdb->posts.post_content LIKE \"%\n$s%\") ");
820 820
         /**
821 821
          * Filter the search query term values.
822 822
          *
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
          *
826 826
          * @param string $terms_where The separator, default: `" AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) "`.
827 827
          */
828
-        $terms_where = apply_filters( "geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) " );
828
+        $terms_where = apply_filters("geodir_search_terms_where", " AND ($wpdb->terms.name LIKE \"$s\" OR $wpdb->terms.name LIKE \"$s%\" OR $wpdb->terms.name LIKE \"% $s%\" OR $wpdb->terms.name IN ($s_A)) ");
829 829
 
830 830
 
831 831
         // get term sql
@@ -837,20 +837,20 @@  discard block
 block discarded – undo
837 837
                     $terms_where
838 838
                     GROUP BY $wpdb->term_taxonomy.term_id";
839 839
 
840
-        $term_results = $wpdb->get_results( $term_sql );
840
+        $term_results = $wpdb->get_results($term_sql);
841 841
         $term_ids     = array();
842 842
         $terms_sql    = '';
843 843
 
844
-        if ( ! empty( $term_results ) ) {
845
-            foreach ( $term_results as $term_id ) {
844
+        if (!empty($term_results)) {
845
+            foreach ($term_results as $term_id) {
846 846
                 $term_ids[] = $term_id;
847 847
             }
848
-            if ( ! empty( $term_ids ) ) {
849
-                foreach ( $term_ids as $term ) {
850
-                    if ( $term->taxonomy == $post_types . '_tags' ) {
851
-                        $terms_sql .= $wpdb->prepare( " OR FIND_IN_SET(%s , " . $table . ".post_tags) ", $term->name );
848
+            if (!empty($term_ids)) {
849
+                foreach ($term_ids as $term) {
850
+                    if ($term->taxonomy == $post_types.'_tags') {
851
+                        $terms_sql .= $wpdb->prepare(" OR FIND_IN_SET(%s , ".$table.".post_tags) ", $term->name);
852 852
                     } else {
853
-                        $terms_sql .= " OR FIND_IN_SET($term->term_id , " . $table . "." . $post_types . "category) ";
853
+                        $terms_sql .= " OR FIND_IN_SET($term->term_id , ".$table.".".$post_types."category) ";
854 854
                     }
855 855
                 }
856 856
             }
@@ -882,12 +882,12 @@  discard block
 block discarded – undo
882 882
 							)
883 883
 						AND $wpdb->posts.post_type in ('{$post_types}')
884 884
 						AND ($wpdb->posts.post_status = 'publish')
885
-						AND ( " . $table . ".post_latitude between $rlat1 and $rlat2 )
886
-						AND ( " . $table . ".post_longitude between $rlon1 and $rlon2 ) ";
885
+						AND ( ".$table.".post_latitude between $rlat1 and $rlat2 )
886
+						AND ( ".$table.".post_longitude between $rlon1 and $rlon2 ) ";
887 887
 
888 888
         if (isset($_REQUEST['sdist']) && $_REQUEST['sdist'] != 'all') {
889 889
             $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
890
-            $where .= " AND CONVERT((" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= " . $dist;
890
+            $where .= " AND CONVERT((".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) ))),DECIMAL(64,4)) <= ".$dist;
891 891
         }
892 892
 
893 893
     } else {
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
     }
905 905
 
906 906
 	########### WPML ###########
907
-    if ( geodir_wpml_is_post_type_translated( $post_types ) ) {
907
+    if (geodir_wpml_is_post_type_translated($post_types)) {
908 908
 		$lang_code = ICL_LANGUAGE_CODE;
909 909
 
910 910
 		if ($lang_code && $post_types) {
911
-            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_" . $post_types . "') ";
911
+            $where .= " AND icl_t.language_code = '".$lang_code."' AND icl_t.element_type IN('post_".$post_types."') ";
912 912
         }
913 913
     }
914 914
     ########### WPML ###########
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
     global $wpdb, $geodir_post_type, $table, $curr;
932 932
 
933 933
     $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
934
-    $user_id = !empty($curauth->ID) ? (int)$curauth->ID : 0;
934
+    $user_id = !empty($curauth->ID) ? (int) $curauth->ID : 0;
935 935
 
936 936
     if (isset($_REQUEST['stype'])) {
937
-        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ",$_REQUEST['stype']);
937
+        $where = $wpdb->prepare(" AND $wpdb->posts.post_type IN (%s) ", $_REQUEST['stype']);
938 938
     } else {
939 939
         $where = " AND $wpdb->posts.post_type IN ('gd_place') ";
940 940
     }
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
         } else
948 948
             $where .= " AND $wpdb->posts.post_author = $user_id";
949 949
 
950
-        if ($user_id == (int)get_current_user_id()) {
950
+        if ($user_id == (int) get_current_user_id()) {
951 951
             $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
952 952
         } else {
953 953
             $where .= " AND $wpdb->posts.post_status = 'publish' ";
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
     if (geodir_wpml_is_post_type_translated(sanitize_text_field($_REQUEST['stype']))) {
961 961
         $lang_code = ICL_LANGUAGE_CODE;
962 962
         if ($lang_code) {
963
-            $where .= " AND icl_t.language_code='" . $lang_code . "' ";
963
+            $where .= " AND icl_t.language_code='".$lang_code."' ";
964 964
         }
965 965
 
966 966
     }
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 {
984 984
     global $wp_query, $table;
985 985
     if (!empty($wp_query->query['with_pics_only'])) {
986
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
986
+        $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
987 987
     }
988 988
     return $join;
989 989
 }
@@ -1002,16 +1002,16 @@  discard block
 block discarded – undo
1002 1002
 {
1003 1003
     global $wp_query, $table;
1004 1004
     if (!empty($wp_query->query['show_featured_only'])) {
1005
-        $where .= " AND " . $table . ".is_featured = '1'";
1005
+        $where .= " AND ".$table.".is_featured = '1'";
1006 1006
     }
1007 1007
     if (!empty($wp_query->query['show_special_only'])) {
1008
-        $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
1008
+        $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
1009 1009
     }
1010 1010
     if (!empty($wp_query->query['with_pics_only'])) {
1011
-        $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL GROUP BY " . $table . ".post_id";
1011
+        $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL GROUP BY ".$table.".post_id";
1012 1012
     }
1013 1013
     if (!empty($wp_query->query['with_videos_only'])) {
1014
-        $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
1014
+        $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
1015 1015
     }
1016 1016
     return $where;
1017 1017
 }
@@ -1020,18 +1020,18 @@  discard block
 block discarded – undo
1020 1020
 function geodir_related_posts_fields($fields) {
1021 1021
     global $wp_query, $wpdb, $table, $post;
1022 1022
 
1023
-    $fields .= ", " . $table . ".* ";
1023
+    $fields .= ", ".$table.".* ";
1024 1024
 
1025 1025
     $DistanceRadius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1026 1026
 
1027 1027
     $mylat = $post->post_latitude;
1028 1028
     $mylon = $post->post_longitude;
1029 1029
 
1030
-    $fields .= " , (" . $DistanceRadius . " * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(" . $table . ".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(" . $table . ".post_latitude) * pi()/180) *POWER(SIN(($mylon - " . $table . ".post_longitude) * pi()/180 / 2), 2) )))as distance ";
1030
+    $fields .= " , (".$DistanceRadius." * 2 * ASIN(SQRT( POWER(SIN((ABS($mylat) - ABS(".$table.".post_latitude)) * pi()/180 / 2), 2) +COS(ABS($mylat) * pi()/180) * COS( ABS(".$table.".post_latitude) * pi()/180) *POWER(SIN(($mylon - ".$table.".post_longitude) * pi()/180 / 2), 2) )))as distance ";
1031 1031
     return $fields;
1032 1032
 }
1033 1033
 function geodir_related_posts_fields_filter($query) {
1034
-    if ( isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1034
+    if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']
1035 1035
         && isset($query->query_vars['order_by']) && $query->query_vars['order_by'] == 'nearest'
1036 1036
         && isset($query->query_vars['related_listings']) && $query->query_vars['related_listings']
1037 1037
     ) {
@@ -1050,25 +1050,25 @@  discard block
 block discarded – undo
1050 1050
  * @param string $table Listing table name.
1051 1051
  * @return string|null If field exists in table returns order by clause else returns empty.
1052 1052
  */
1053
-function geodir_prepare_custom_sorting( $sorting, $table ) {
1053
+function geodir_prepare_custom_sorting($sorting, $table) {
1054 1054
     $orderby = '';
1055 1055
     
1056
-    if ( empty( $sorting ) || empty( $table ) ) {
1056
+    if (empty($sorting) || empty($table)) {
1057 1057
         return $orderby;
1058 1058
     }
1059 1059
     
1060
-    if ( strpos( strtoupper( $sorting ), '_ASC' ) !== false || strpos( strtoupper( $sorting ), '_DESC') !== false ) {
1061
-        $sorting_array = explode( '_', $sorting );
1060
+    if (strpos(strtoupper($sorting), '_ASC') !== false || strpos(strtoupper($sorting), '_DESC') !== false) {
1061
+        $sorting_array = explode('_', $sorting);
1062 1062
         
1063
-        if ( ( $count = count( $sorting_array ) ) > 1 ) {
1064
-            $order = !empty( $sorting_array[$count - 1] ) ? strtoupper( $sorting_array[$count - 1] ) : '';
1065
-            array_pop( $sorting_array );
1063
+        if (($count = count($sorting_array)) > 1) {
1064
+            $order = !empty($sorting_array[$count - 1]) ? strtoupper($sorting_array[$count - 1]) : '';
1065
+            array_pop($sorting_array);
1066 1066
             
1067
-            if ( !empty( $sorting_array ) && ( $order == 'ASC' || $order == 'DESC' ) ) {
1068
-                $sort_by = implode( '_', $sorting_array );
1067
+            if (!empty($sorting_array) && ($order == 'ASC' || $order == 'DESC')) {
1068
+                $sort_by = implode('_', $sorting_array);
1069 1069
                 
1070
-                if ( geodir_column_exist( $table, $sort_by ) ) {
1071
-                    $orderby = $table . "." . $sort_by . " " . $order;
1070
+                if (geodir_column_exist($table, $sort_by)) {
1071
+                    $orderby = $table.".".$sort_by." ".$order;
1072 1072
                 }
1073 1073
             }
1074 1074
         }
@@ -1093,18 +1093,18 @@  discard block
 block discarded – undo
1093 1093
  *
1094 1094
  * @return string Modified fields SQL.
1095 1095
  */
1096
-function geodir_search_widget_location_filter_fields( $fields, $table, $post_type ) {
1096
+function geodir_search_widget_location_filter_fields($fields, $table, $post_type) {
1097 1097
     global $wpdb, $gd_query_args_widgets, $snear, $gd_session;
1098 1098
 
1099
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1100
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1099
+    if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
1100
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1101 1101
 
1102
-        if ( $location_allowed && strpos( strtolower( $fields ), ' as distance ' ) === false && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1103
-            $latitude = sanitize_text_field( $_REQUEST['sgeo_lat'] );
1104
-            $longitude = sanitize_text_field( $_REQUEST['sgeo_lon'] );
1105
-            $radius = geodir_getDistanceRadius( get_option( 'geodir_search_dist_1' ) );
1102
+        if ($location_allowed && strpos(strtolower($fields), ' as distance ') === false && ($snear != '' || $gd_session->get('all_near_me'))) {
1103
+            $latitude = sanitize_text_field($_REQUEST['sgeo_lat']);
1104
+            $longitude = sanitize_text_field($_REQUEST['sgeo_lon']);
1105
+            $radius = geodir_getDistanceRadius(get_option('geodir_search_dist_1'));
1106 1106
 
1107
-            $fields .= $wpdb->prepare( ", (" . $radius . " * 2 * ASIN(SQRT(POWER(SIN((ABS(%s) - ABS(" . $table . ".post_latitude)) * PI() / 180 / 2), 2) + COS(ABS(%s) * PI() / 180) * COS(ABS(" . $table . ".post_latitude) * PI() / 180) * POWER(SIN((%s - " . $table . ".post_longitude) * PI() / 180 / 2), 2)))) AS distance ", $latitude, $latitude, $longitude );
1107
+            $fields .= $wpdb->prepare(", (".$radius." * 2 * ASIN(SQRT(POWER(SIN((ABS(%s) - ABS(".$table.".post_latitude)) * PI() / 180 / 2), 2) + COS(ABS(%s) * PI() / 180) * COS(ABS(".$table.".post_latitude) * PI() / 180) * POWER(SIN((%s - ".$table.".post_longitude) * PI() / 180 / 2), 2)))) AS distance ", $latitude, $latitude, $longitude);
1108 1108
         }
1109 1109
     }
1110 1110
 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return string Modified fields SQL.
1128 1128
  */
1129
-function geodir_search_widget_location_filter_orderby( $orderby, $table, $post_type ) {
1129
+function geodir_search_widget_location_filter_orderby($orderby, $table, $post_type) {
1130 1130
     global $gd_query_args_widgets, $snear, $gd_session;
1131 1131
 
1132
-    if ( !empty( $gd_query_args_widgets['gd_location'] ) && geodir_is_page( 'search' ) && !empty( $_REQUEST['sgeo_lat'] ) && !empty( $_REQUEST['sgeo_lon'] ) ) {
1133
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
1132
+    if (!empty($gd_query_args_widgets['gd_location']) && geodir_is_page('search') && !empty($_REQUEST['sgeo_lat']) && !empty($_REQUEST['sgeo_lon'])) {
1133
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
1134 1134
 
1135
-        if ( $location_allowed && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1136
-            $orderby = "distance ASC, " . $orderby;
1135
+        if ($location_allowed && ($snear != '' || $gd_session->get('all_near_me'))) {
1136
+            $orderby = "distance ASC, ".$orderby;
1137 1137
         }
1138 1138
     }
1139 1139
 
@@ -1148,23 +1148,23 @@  discard block
 block discarded – undo
1148 1148
  * @return string Filtered url.
1149 1149
  */
1150 1150
 function geodir_search_page_base_url() {
1151
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1152
-        remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
1151
+    if (function_exists('geodir_location_geo_home_link')) {
1152
+        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1153 1153
     }
1154 1154
 
1155
-    if ( defined( 'DOING_AJAX' ) && DOING_AJAX && geodir_is_wpml() ) {
1155
+    if (defined('DOING_AJAX') && DOING_AJAX && geodir_is_wpml()) {
1156 1156
         $url = icl_get_home_url();
1157 1157
     } else {
1158 1158
         $url = get_home_url();
1159 1159
     }
1160 1160
 
1161
-    $url = trailingslashit( $url );
1161
+    $url = trailingslashit($url);
1162 1162
 
1163
-    if ( function_exists( 'geodir_location_geo_home_link' ) ) {
1164
-        add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
1163
+    if (function_exists('geodir_location_geo_home_link')) {
1164
+        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1165 1165
     }
1166 1166
 
1167
-    return apply_filters( 'geodir_search_page_base_url', $url );
1167
+    return apply_filters('geodir_search_page_base_url', $url);
1168 1168
 }
1169 1169
 
1170 1170
 /**
@@ -1172,24 +1172,24 @@  discard block
 block discarded – undo
1172 1172
  *
1173 1173
  * @since 1.6.31
1174 1174
  */
1175
-function geodir_jetpack_fix_post_types_search(){
1176
-	if ( defined( 'JETPACK__VERSION' ) && ! empty( $_REQUEST['geodir_search'] ) ) {
1177
-		add_filter( 'jetpack_search_should_handle_query', '__return_false', 999, 1 );
1175
+function geodir_jetpack_fix_post_types_search() {
1176
+	if (defined('JETPACK__VERSION') && !empty($_REQUEST['geodir_search'])) {
1177
+		add_filter('jetpack_search_should_handle_query', '__return_false', 999, 1);
1178 1178
     }
1179 1179
 }
1180
-add_action( 'plugins_loaded','geodir_jetpack_fix_post_types_search', 10 );
1180
+add_action('plugins_loaded', 'geodir_jetpack_fix_post_types_search', 10);
1181 1181
 
1182
-function geodir_posts_having( $clauses, $query = array() ) {
1182
+function geodir_posts_having($clauses, $query = array()) {
1183 1183
 	global $wpdb, $gd_session, $geodir_post_type, $dist, $mylat, $mylon, $snear;
1184 1184
 
1185
-	if ( geodir_is_gd_main_query( $query ) ) {
1186
-		$support_location = $geodir_post_type && function_exists( 'geodir_cpt_no_location' ) && ! geodir_cpt_no_location( $geodir_post_type );
1185
+	if (geodir_is_gd_main_query($query)) {
1186
+		$support_location = $geodir_post_type && function_exists('geodir_cpt_no_location') && !geodir_cpt_no_location($geodir_post_type);
1187 1187
 
1188
-		if ( $support_location && $dist && ( $snear != '' || $gd_session->get( 'all_near_me' ) ) ) {
1189
-			if ( $gd_session->get( 'near_me_range' ) && ! isset( $_REQUEST['sdist'] ) ) {
1190
-				$dist = $gd_session->get( 'near_me_range' );
1188
+		if ($support_location && $dist && ($snear != '' || $gd_session->get('all_near_me'))) {
1189
+			if ($gd_session->get('near_me_range') && !isset($_REQUEST['sdist'])) {
1190
+				$dist = $gd_session->get('near_me_range');
1191 1191
 
1192
-				if ( get_option( 'geodir_search_dist_1' ) == 'km' ) {
1192
+				if (get_option('geodir_search_dist_1') == 'km') {
1193 1193
 					$dist = $dist * 1.6093440001;
1194 1194
 				}
1195 1195
 			}
@@ -1198,9 +1198,9 @@  discard block
 block discarded – undo
1198 1198
 			 * The HAVING clause is often used with the GROUP BY clause to filter groups based on a specified condition. 
1199 1199
 			 * If the GROUP BY clause is omitted, the HAVING clause behaves like the WHERE clause.
1200 1200
 			 */
1201
-			if ( strpos( $clauses['where'], ' HAVING ') === false && strpos( $clauses['groupby'], ' HAVING ') === false ) {
1202
-				$having = $wpdb->prepare( " HAVING distance <= %f ", $dist );
1203
-				if ( trim( $clauses['groupby'] ) != '' ) {
1201
+			if (strpos($clauses['where'], ' HAVING ') === false && strpos($clauses['groupby'], ' HAVING ') === false) {
1202
+				$having = $wpdb->prepare(" HAVING distance <= %f ", $dist);
1203
+				if (trim($clauses['groupby']) != '') {
1204 1204
 					$clauses['groupby'] .= $having;
1205 1205
 				} else {
1206 1206
 					$clauses['where'] .= $having;
@@ -1212,12 +1212,12 @@  discard block
 block discarded – undo
1212 1212
 	return $clauses;
1213 1213
 }
1214 1214
 
1215
-function geodir_is_gd_main_query( $query ){
1215
+function geodir_is_gd_main_query($query) {
1216 1216
 	$is_main_query = false;
1217 1217
 
1218
-	if(isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
1218
+	if (isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
1219 1219
 		$is_main_query = true;
1220
-	}elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
1220
+	}elseif (isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
1221 1221
 		$is_main_query = true;
1222 1222
 	}
1223 1223
 
Please login to merge, or discard this patch.
Braces   +32 added lines, -21 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function geodir_session_start()
18 18
 {
19
-    if (!session_id()) session_start();
19
+    if (!session_id()) {
20
+    	session_start();
21
+    }
20 22
     global $geodir_add_location_url;
21 23
 
22 24
     $geodir_add_location_url = NULL;
@@ -86,7 +88,9 @@  discard block
 block discarded – undo
86 88
 
87 89
     if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')):
88 90
 
89
-        if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = '';
91
+        if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') {
92
+        	$_REQUEST['scat'] = '';
93
+        }
90 94
         //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = '';
91 95
 
92 96
         if (isset($_REQUEST['sdist'])) {
@@ -198,8 +202,9 @@  discard block
 block discarded – undo
198 202
         add_filter('posts_fields', 'geodir_posts_fields', 1);
199 203
         add_filter('posts_join', 'geodir_posts_join', 1);
200 204
         geodir_post_where();
201
-        if (!is_admin())
202
-            add_filter('posts_orderby', 'geodir_posts_orderby', 1);
205
+        if (!is_admin()) {
206
+                    add_filter('posts_orderby', 'geodir_posts_orderby', 1);
207
+        }
203 208
 
204 209
         // advanced filter for popular post view widget
205 210
         global $wp_query;
@@ -349,8 +354,9 @@  discard block
 block discarded – undo
349 354
     $sort_by = '';
350 355
     $orderby = ' ';
351 356
 
352
-    if (get_query_var('order_by'))
353
-        $sort_by = get_query_var('order_by');
357
+    if (get_query_var('order_by')) {
358
+            $sort_by = get_query_var('order_by');
359
+    }
354 360
 
355 361
     /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
356 362
         $current_term = $wp_query->get_queried_object();
@@ -370,14 +376,16 @@  discard block
 block discarded – undo
370 376
         $orderby .= " distance,";
371 377
     }
372 378
 
373
-    if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query())
374
-        $sort_by = esc_attr($_REQUEST['sort_by']);
379
+    if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) {
380
+            $sort_by = esc_attr($_REQUEST['sort_by']);
381
+    }
375 382
 
376 383
 
377 384
     if ($sort_by == '') {
378 385
         $default_sort = geodir_get_posts_default_sort($geodir_post_type);
379
-        if (!empty($default_sort))
380
-            $sort_by = $default_sort;
386
+        if (!empty($default_sort)) {
387
+                    $sort_by = $default_sort;
388
+        }
381 389
     }
382 390
 
383 391
     /*
@@ -562,7 +570,7 @@  discard block
 block discarded – undo
562 570
                         $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ))  / ( $avg_num_votes + " . $table . ".rating_count )  $order , ";
563 571
 
564 572
                         //$orderby = " ( " . $table . ".rating_count * " . $table . ".overall_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating )   / ( " . $table . ".rating_count + " . $table . ".rating_count )  $order , "; // seems to work mostly with no extra overheads
565
-                    }else{
573
+                    } else{
566 574
                         $orderby = " " . $table . "." . $sort_by . "  " . $order . ", " . $table . ".rating_count " . $order . ", ";
567 575
                     }
568 576
 
@@ -607,8 +615,9 @@  discard block
 block discarded – undo
607 615
 
608 616
             add_filter('posts_where', 'searching_filter_where', 1);
609 617
 
610
-            if ($snear != '')
611
-                add_filter('posts_where', 'searching_filter_where', 1);
618
+            if ($snear != '') {
619
+                            add_filter('posts_where', 'searching_filter_where', 1);
620
+            }
612 621
 
613 622
             add_filter('posts_orderby', 'geodir_posts_orderby', 1);
614 623
 			add_filter( 'posts_clauses', 'geodir_posts_having', 99999, 2 );
@@ -763,10 +772,11 @@  discard block
 block discarded – undo
763 772
 
764 773
     $where = '';
765 774
     $better_search_terms = '';
766
-    if (isset($_REQUEST['stype']))
767
-        $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
768
-    else
769
-        $post_types = 'gd_place';
775
+    if (isset($_REQUEST['stype'])) {
776
+            $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype']));
777
+    } else {
778
+            $post_types = 'gd_place';
779
+    }
770 780
 
771 781
     if ($s != '') {
772 782
         $keywords = explode(" ", $s);
@@ -803,7 +813,7 @@  discard block
 block discarded – undo
803 813
     if($taxonomies) {
804 814
         $taxonomies = implode("','", $taxonomies);
805 815
         $taxonomies = "'" . $taxonomies . "'";
806
-    }else{$taxonomies='';}
816
+    } else{$taxonomies='';}
807 817
 
808 818
     $content_where = $terms_where = '';
809 819
     $terms_sql    = '';
@@ -944,8 +954,9 @@  discard block
 block discarded – undo
944 954
             $user_fav_posts = geodir_get_user_favourites($user_id);
945 955
             $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
946 956
             $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
947
-        } else
948
-            $where .= " AND $wpdb->posts.post_author = $user_id";
957
+        } else {
958
+                    $where .= " AND $wpdb->posts.post_author = $user_id";
959
+        }
949 960
 
950 961
         if ($user_id == (int)get_current_user_id()) {
951 962
             $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
@@ -1217,7 +1228,7 @@  discard block
 block discarded – undo
1217 1228
 
1218 1229
 	if(isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
1219 1230
 		$is_main_query = true;
1220
-	}elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
1231
+	} elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
1221 1232
 		$is_main_query = true;
1222 1233
 	}
1223 1234
 
Please login to merge, or discard this patch.
geodirectory-admin/wp-font-awesome-settings.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -202,8 +202,8 @@
 block discarded – undo
202 202
 		public function remove_font_awesome( $url, $original_url, $_context ) {
203 203
 
204 204
 			if ( $_context == 'display'
205
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
206
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
205
+				 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
206
+				 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
207 207
 			) {// it's a font-awesome-url (probably)
208 208
 
209 209
 				if ( strstr( $url, "wpfas=true" ) !== false ) {
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
 		 * @return WP_Font_Awesome_Settings - Main instance.
78 78
 		 */
79 79
 		public static function instance() {
80
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
80
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
81 81
 				self::$instance = new WP_Font_Awesome_Settings;
82 82
 
83
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
83
+				add_action('init', array(self::$instance, 'init')); // set settings
84 84
 
85
-				if ( is_admin() ) {
86
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
85
+				if (is_admin()) {
86
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
87
+					add_action('admin_init', array(self::$instance, 'register_settings'));
88 88
 				}
89 89
 
90
-				do_action( 'wp_font_awesome_settings_loaded' );
90
+				do_action('wp_font_awesome_settings_loaded');
91 91
 			}
92 92
 
93 93
 			return self::$instance;
@@ -101,30 +101,30 @@  discard block
 block discarded – undo
101 101
 		public function init() {
102 102
 			$this->settings = $this->get_settings();
103 103
 
104
-			if ( $this->settings['type'] == 'CSS' ) {
104
+			if ($this->settings['type'] == 'CSS') {
105 105
 
106
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
107
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
106
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
107
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); //echo '###';exit;
108 108
 				}
109 109
 
110
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
111
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
110
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
111
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
112 112
 				}
113 113
 
114 114
 			} else {
115 115
 
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
116
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
117
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); //echo '###';exit;
118 118
 				}
119 119
 
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
120
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
121
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
122 122
 				}
123 123
 			}
124 124
 
125 125
 			// remove font awesome if set to do so
126
-			if ( $this->settings['dequeue'] == '1' ) {
127
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
126
+			if ($this->settings['dequeue'] == '1') {
127
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
128 128
 			}
129 129
 
130 130
 		}
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 			// build url
137 137
 			$url = $this->get_url();
138 138
 
139
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
140
-			wp_register_style( 'font-awesome', $url, array(), null );
141
-			wp_enqueue_style( 'font-awesome' );
139
+			wp_deregister_style('font-awesome'); // deregister in case its already there
140
+			wp_register_style('font-awesome', $url, array(), null);
141
+			wp_enqueue_style('font-awesome');
142 142
 
143
-			if ( $this->settings['shims'] ) {
144
-				$url = $this->get_url( true );
145
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
146
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
147
-				wp_enqueue_style( 'font-awesome-shims' );
143
+			if ($this->settings['shims']) {
144
+				$url = $this->get_url(true);
145
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
146
+				wp_register_style('font-awesome-shims', $url, array(), null);
147
+				wp_enqueue_style('font-awesome-shims');
148 148
 			}
149 149
 		}
150 150
 
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 			// build url
156 156
 			$url = $this->get_url();
157 157
 
158
-			wp_deregister_script( 'font-awesome' ); // deregister in case its already there
159
-			wp_register_script( 'font-awesome', $url, array(), null );
160
-			wp_enqueue_script( 'font-awesome' );
158
+			wp_deregister_script('font-awesome'); // deregister in case its already there
159
+			wp_register_script('font-awesome', $url, array(), null);
160
+			wp_enqueue_script('font-awesome');
161 161
 
162
-			if ( $this->settings['shims'] ) {
163
-				$url = $this->get_url( true );
164
-				wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
165
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
166
-				wp_enqueue_script( 'font-awesome-shims' );
162
+			if ($this->settings['shims']) {
163
+				$url = $this->get_url(true);
164
+				wp_deregister_script('font-awesome-shims'); // deregister in case its already there
165
+				wp_register_script('font-awesome-shims', $url, array(), null);
166
+				wp_enqueue_script('font-awesome-shims');
167 167
 			}
168 168
 		}
169 169
 
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 		 *
175 175
 		 * @return string The url to the file.
176 176
 		 */
177
-		public function get_url( $shims = false ) {
177
+		public function get_url($shims = false) {
178 178
 			$script  = $shims ? 'v4-shims' : 'all';
179 179
 			$type    = $this->settings['type'];
180 180
 			$version = $this->settings['version'];
181 181
 
182 182
 			$url = "https://use.fontawesome.com/releases/"; // CDN
183
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
183
+			$url .= !empty($version) ? "v".$version.'/' : "v".$this->get_latest_version().'/'; // version
184 184
 			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
185
-			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
185
+			$url .= $type == 'CSS' ? $script.'.css' : $script.'.js'; // type
186 186
 			$url .= "?wpfas=true"; // set our var so our version is not removed
187 187
 
188 188
 			return $url;
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
 		 *
200 200
 		 * @return string The filtered url.
201 201
 		 */
202
-		public function remove_font_awesome( $url, $original_url, $_context ) {
202
+		public function remove_font_awesome($url, $original_url, $_context) {
203 203
 
204
-			if ( $_context == 'display'
205
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
206
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
204
+			if ($_context == 'display'
205
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
206
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
207 207
 			) {// it's a font-awesome-url (probably)
208 208
 
209
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
210
-					if ( $this->settings['type'] == 'JS' ) {
211
-						if ( $this->settings['js-pseudo'] ) {
209
+				if (strstr($url, "wpfas=true") !== false) {
210
+					if ($this->settings['type'] == 'JS') {
211
+						if ($this->settings['js-pseudo']) {
212 212
 							$url .= "' data-search-pseudo-elements defer='defer";
213 213
 						} else {
214 214
 							$url .= "' defer='defer";
@@ -227,17 +227,17 @@  discard block
 block discarded – undo
227 227
 		 * Register the database settings with WordPress.
228 228
 		 */
229 229
 		public function register_settings() {
230
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
230
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
231 231
 		}
232 232
 
233 233
 		/**
234 234
 		 * Add the WordPress settings menu item.
235 235
 		 */
236 236
 		public function menu_item() {
237
-			add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
237
+			add_options_page($this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
238 238
 				$this,
239 239
 				'settings_page'
240
-			) );
240
+			));
241 241
 		}
242 242
 
243 243
 		/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		 */
248 248
 		public function get_settings() {
249 249
 
250
-			$db_settings = get_option( 'wp-font-awesome-settings' );
250
+			$db_settings = get_option('wp-font-awesome-settings');
251 251
 
252 252
 			$defaults = array(
253 253
 				'type'      => 'CSS', // type to use, CSS or JS
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
259 259
 			);
260 260
 
261
-			$settings = wp_parse_args( $db_settings, $defaults );
261
+			$settings = wp_parse_args($db_settings, $defaults);
262 262
 
263 263
 			/**
264 264
 			 * Filter the Font Awesome settings.
265 265
 			 *
266 266
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
267 267
 			 */
268
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
268
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
269 269
 		}
270 270
 
271 271
 
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 		 * The settings page html output.
274 274
 		 */
275 275
 		public function settings_page() {
276
-			if ( ! current_user_can( 'manage_options' ) ) {
277
-				wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
276
+			if (!current_user_can('manage_options')) {
277
+				wp_die(__('You do not have sufficient permissions to access this page.'));
278 278
 			}
279 279
 
280 280
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
281
-			if(isset($_REQUEST['force-version-check'])){
281
+			if (isset($_REQUEST['force-version-check'])) {
282 282
 				$this->get_latest_version($force_api = true);
283 283
 			}
284 284
 			?>
@@ -286,46 +286,46 @@  discard block
 block discarded – undo
286 286
 				<h1><?php echo $this->name; ?></h1>
287 287
 				<form method="post" action="options.php">
288 288
 					<?php
289
-					settings_fields( 'wp-font-awesome-settings' );
290
-					do_settings_sections( 'wp-font-awesome-settings' );
289
+					settings_fields('wp-font-awesome-settings');
290
+					do_settings_sections('wp-font-awesome-settings');
291 291
 					?>
292 292
 					<table class="form-table">
293 293
 						<tr valign="top">
294
-							<th scope="row"><label for="wpfas-type"><?php _e( 'Type' ); ?></label></th>
294
+							<th scope="row"><label for="wpfas-type"><?php _e('Type'); ?></label></th>
295 295
 							<td>
296 296
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type">
297 297
 									<option
298
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)' ); ?></option>
299
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
298
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)'); ?></option>
299
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
300 300
 								</select>
301 301
 							</td>
302 302
 						</tr>
303 303
 
304 304
 						<tr valign="top">
305
-							<th scope="row"><label for="wpfas-version"><?php _e( 'Version' ); ?></label></th>
305
+							<th scope="row"><label for="wpfas-version"><?php _e('Version'); ?></label></th>
306 306
 							<td>
307 307
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
308 308
 									<option
309
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)' ), $this->get_latest_version() ); ?></option>
310
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
309
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)'), $this->get_latest_version()); ?></option>
310
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
311 311
 										5.6.0
312 312
 									</option>
313
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
313
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
314 314
 										5.5.0
315 315
 									</option>
316
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
316
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
317 317
 										5.4.0
318 318
 									</option>
319
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
319
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
320 320
 										5.3.0
321 321
 									</option>
322
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
322
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
323 323
 										5.2.0
324 324
 									</option>
325
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
325
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
326 326
 										5.1.0
327 327
 									</option>
328
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
328
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
329 329
 										4.7.1 (CSS only)
330 330
 									</option>
331 331
 								</select>
@@ -333,51 +333,51 @@  discard block
 block discarded – undo
333 333
 						</tr>
334 334
 
335 335
 						<tr valign="top">
336
-							<th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue' ); ?></label></th>
336
+							<th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue'); ?></label></th>
337 337
 							<td>
338 338
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
339 339
 									<option
340
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)' ); ?></option>
340
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)'); ?></option>
341 341
 									<option
342
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend' ); ?></option>
342
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend'); ?></option>
343 343
 									<option
344
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend' ); ?></option>
344
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend'); ?></option>
345 345
 								</select>
346 346
 							</td>
347 347
 						</tr>
348 348
 
349 349
 						<tr valign="top">
350 350
 							<th scope="row"><label
351
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility' ); ?></label></th>
351
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility'); ?></label></th>
352 352
 							<td>
353 353
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
354 354
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
355
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
356
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.' ); ?></span>
355
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
356
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.'); ?></span>
357 357
 							</td>
358 358
 						</tr>
359 359
 
360 360
 						<tr valign="top">
361 361
 							<th scope="row"><label
362
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)' ); ?></label>
362
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)'); ?></label>
363 363
 							</th>
364 364
 							<td>
365 365
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
366 366
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
367
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
367
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
368 368
 								       id="wpfas-js-pseudo"/>
369
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.' ); ?></span>
369
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.'); ?></span>
370 370
 							</td>
371 371
 						</tr>
372 372
 
373 373
 						<tr valign="top">
374
-							<th scope="row"><label for="wpfas-dequeue"><?php _e( 'Dequeue' ); ?></label></th>
374
+							<th scope="row"><label for="wpfas-dequeue"><?php _e('Dequeue'); ?></label></th>
375 375
 							<td>
376 376
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
377 377
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
378
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
378
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
379 379
 								       id="wpfas-dequeue"/>
380
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.' ); ?></span>
380
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.'); ?></span>
381 381
 							</td>
382 382
 						</tr>
383 383
 
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
 		 *
403 403
 		 * @return string Either a valid version number or an empty string.
404 404
 		 */
405
-		public function validate_version_number( $version ) {
405
+		public function validate_version_number($version) {
406 406
 
407
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
407
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
408 408
 				// valid
409 409
 			} else {
410
-				$version = '';// not validated
410
+				$version = ''; // not validated
411 411
 			}
412 412
 
413 413
 			return $version;
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 		public function get_latest_version($force_api = false) {
426 426
 			$latest_version = $this->latest;
427 427
 
428
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
428
+			$cache = get_transient('wp-font-awesome-settings-version');
429 429
 
430
-			if ( $cache === false || $force_api) { // its not set
430
+			if ($cache === false || $force_api) { // its not set
431 431
 				$api_ver = $this->get_latest_version_from_api();
432
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
432
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
433 433
 					$latest_version = $api_ver;
434
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
434
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
435 435
 				}
436
-			} elseif ( $this->validate_version_number( $cache ) ) {
437
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
436
+			} elseif ($this->validate_version_number($cache)) {
437
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
438 438
 					$latest_version = $cache;
439 439
 				}
440 440
 			}
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
 		 */
451 451
 		public function get_latest_version_from_api() {
452 452
 			$version  = "0";
453
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
454
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
455
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
456
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
453
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
454
+			if (!is_wp_error($response) && is_array($response)) {
455
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
456
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
457 457
 					$version = $api_response['tag_name'];
458 458
 				}
459 459
 			}
Please login to merge, or discard this patch.
geodirectory-functions/location_functions.php 3 patches
Indentation   +397 added lines, -397 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function geodir_get_current_city_lat()
11 11
 {
12
-    $location = geodir_get_default_location();
13
-    $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484';
12
+	$location = geodir_get_default_location();
13
+	$lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484';
14 14
 
15
-    return $lat;
15
+	return $lat;
16 16
 }
17 17
 
18 18
 /**
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function geodir_get_current_city_lng()
27 27
 {
28
-    $location = geodir_get_default_location();
29
-    $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786';
30
-    return $lng;
28
+	$location = geodir_get_default_location();
29
+	$lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786';
30
+	return $lng;
31 31
 }
32 32
 
33 33
 
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function geodir_get_default_location()
42 42
 {
43
-    /**
44
-     * Filter the default location.
45
-     *
46
-     * @since 1.0.0
47
-     * @package GeoDirectory
48
-     *
49
-     * @param string $location_result The default location object.
50
-     */
51
-    return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location'));
43
+	/**
44
+	 * Filter the default location.
45
+	 *
46
+	 * @since 1.0.0
47
+	 * @package GeoDirectory
48
+	 *
49
+	 * @param string $location_result The default location object.
50
+	 */
51
+	return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location'));
52 52
 }
53 53
 
54 54
 /**
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function geodir_is_default_location_set()
62 62
 {
63
-    $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
63
+	$default_location = geodir_get_default_location();
64
+	if (!empty($default_location))
65
+		return true;
66
+	else
67
+		return false;
68 68
 }
69 69
 
70 70
 /**
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 function create_location_slug($location_string)
79 79
 {
80 80
 
81
-    /**
82
-     * Filter the location slug.
83
-     *
84
-     * @since 1.0.0
85
-     * @package GeoDirectory
86
-     *
87
-     * @param string $location_string Sanitized location string.
88
-     */
89
-    return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string)));
81
+	/**
82
+	 * Filter the location slug.
83
+	 *
84
+	 * @since 1.0.0
85
+	 * @package GeoDirectory
86
+	 *
87
+	 * @param string $location_string Sanitized location string.
88
+	 */
89
+	return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string)));
90 90
 
91 91
 }
92 92
 
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_get_location($id = '')
102 102
 {
103
-    /**
104
-     * Filter the location information.
105
-     *
106
-     * @since 1.0.0
107
-     * @package GeoDirectory
108
-     *
109
-     * @param string $id The location ID.
110
-     */
111
-    return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id);
103
+	/**
104
+	 * Filter the location information.
105
+	 *
106
+	 * @since 1.0.0
107
+	 * @package GeoDirectory
108
+	 *
109
+	 * @param string $id The location ID.
110
+	 */
111
+	return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id);
112 112
 }
113 113
 
114 114
 /**
@@ -122,28 +122,28 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function geodir_get_country_dl($post_country = '', $prefix = '')
124 124
 {
125
-    global $wpdb;
125
+	global $wpdb;
126 126
 
127
-    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
127
+	$rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
128 128
     
129
-    $ISO2 = array();
130
-    $countries = array();
129
+	$ISO2 = array();
130
+	$countries = array();
131 131
     
132
-    foreach ($rows as $row) {
133
-        $ISO2[$row->Country] = $row->ISO2;
134
-        $countries[$row->Country] = __($row->Country, 'geodirectory');
135
-    }
132
+	foreach ($rows as $row) {
133
+		$ISO2[$row->Country] = $row->ISO2;
134
+		$countries[$row->Country] = __($row->Country, 'geodirectory');
135
+	}
136 136
     
137
-    asort($countries);
137
+	asort($countries);
138 138
     
139
-    $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
140
-    foreach ($countries as $country => $name) {
141
-        $ccode = $ISO2[$country];
139
+	$out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
140
+	foreach ($countries as $country => $name) {
141
+		$ccode = $ISO2[$country];
142 142
 
143
-        $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
144
-    }
143
+		$out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
144
+	}
145 145
 
146
-    echo $out_put;
146
+	echo $out_put;
147 147
 }
148 148
 
149 149
 
@@ -158,40 +158,40 @@  discard block
 block discarded – undo
158 158
 function geodir_location_form_submit()
159 159
 {
160 160
 
161
-    global $wpdb, $plugin_prefix;
162
-    if (isset($_REQUEST['add_location'])) {
161
+	global $wpdb, $plugin_prefix;
162
+	if (isset($_REQUEST['add_location'])) {
163 163
 
164
-        $location_info = array(
165
-            'city' => $_REQUEST['city'],
166
-            'region' => $_REQUEST['region'],
167
-            'country' => $_REQUEST['country'],
168
-            'geo_lat' => $_REQUEST['latitude'],
169
-            'geo_lng' => $_REQUEST['longitude'],
170
-            'is_default' => $_REQUEST['is_default'],
171
-            'update_city' => $_REQUEST['update_city']
172
-        );
164
+		$location_info = array(
165
+			'city' => $_REQUEST['city'],
166
+			'region' => $_REQUEST['region'],
167
+			'country' => $_REQUEST['country'],
168
+			'geo_lat' => $_REQUEST['latitude'],
169
+			'geo_lng' => $_REQUEST['longitude'],
170
+			'is_default' => $_REQUEST['is_default'],
171
+			'update_city' => $_REQUEST['update_city']
172
+		);
173 173
 
174
-        $old_location = geodir_get_default_location();
174
+		$old_location = geodir_get_default_location();
175 175
 
176
-        $locationid = geodir_add_new_location($location_info);
176
+		$locationid = geodir_add_new_location($location_info);
177 177
 
178
-        $default_location = geodir_get_location($locationid);
178
+		$default_location = geodir_get_location($locationid);
179 179
 
180
-        //UPDATE AND DELETE LISTING
181
-        $posttype = geodir_get_posttypes();
182
-        if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
180
+		//UPDATE AND DELETE LISTING
181
+		$posttype = geodir_get_posttypes();
182
+		if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
183 183
 
184
-            foreach ($posttype as $posttypeobj) {
185
-                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
184
+			foreach ($posttype as $posttypeobj) {
185
+				$post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
186 186
 
187
-                $sql = $wpdb->prepare(
188
-                    "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189
-                    array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190
-                );
191
-                $wpdb->query($sql);
192
-            }
193
-        }
194
-    }
187
+				$sql = $wpdb->prepare(
188
+					"UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189
+					array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190
+				);
191
+				$wpdb->query($sql);
192
+			}
193
+		}
194
+	}
195 195
 }
196 196
 
197 197
 /**
@@ -215,37 +215,37 @@  discard block
 block discarded – undo
215 215
  */
216 216
 function geodir_add_new_location($location_info = array())
217 217
 {
218
-    global $wpdb;
219
-
220
-    if (!empty($location_info)) {
221
-        $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all';
222
-        $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all';
223
-        $location_country = ($location_info['country'] != '') ? geodir_get_normal_country($location_info['country']) : 'all';
224
-        $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : '';
225
-        $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : '';
226
-        $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : '';
227
-        $country_slug = create_location_slug(__($location_country, 'geodirectory'));
228
-        $region_slug = create_location_slug($location_region);
229
-        $city_slug = create_location_slug($location_city);
218
+	global $wpdb;
219
+
220
+	if (!empty($location_info)) {
221
+		$location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all';
222
+		$location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all';
223
+		$location_country = ($location_info['country'] != '') ? geodir_get_normal_country($location_info['country']) : 'all';
224
+		$location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : '';
225
+		$location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : '';
226
+		$is_default = isset($location_info['is_default']) ? $location_info['is_default'] : '';
227
+		$country_slug = create_location_slug(__($location_country, 'geodirectory'));
228
+		$region_slug = create_location_slug($location_region);
229
+		$city_slug = create_location_slug($location_city);
230 230
         
231
-        /**
232
-         * Filter add new location data.
233
-         *
234
-         * @since 1.0.0
235
-         */
236
-        $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
237
-            'country' => $location_country,
238
-            'region' => $location_region,
239
-            'city' => $location_city,
240
-            'country_slug' => $country_slug,
241
-            'region_slug' => $region_slug,
242
-            'city_slug' => $city_slug,
243
-            'city_latitude' => $location_lat,
244
-            'city_longitude' => $location_lng,
245
-            'is_default' => $is_default
246
-        ));
247
-
248
-        /* // Not allowed to create country in DB : 2016-12-09
231
+		/**
232
+		 * Filter add new location data.
233
+		 *
234
+		 * @since 1.0.0
235
+		 */
236
+		$geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
237
+			'country' => $location_country,
238
+			'region' => $location_region,
239
+			'city' => $location_city,
240
+			'country_slug' => $country_slug,
241
+			'region_slug' => $region_slug,
242
+			'city_slug' => $city_slug,
243
+			'city_latitude' => $location_lat,
244
+			'city_longitude' => $location_lng,
245
+			'is_default' => $is_default
246
+		));
247
+
248
+		/* // Not allowed to create country in DB : 2016-12-09
249 249
         if ($geodir_location->country) {
250 250
 
251 251
             $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
@@ -259,14 +259,14 @@  discard block
 block discarded – undo
259 259
         }
260 260
         */
261 261
 
262
-        if ($geodir_location->is_default)
263
-            update_option('geodir_default_location', $geodir_location);
262
+		if ($geodir_location->is_default)
263
+			update_option('geodir_default_location', $geodir_location);
264 264
 
265
-        return $geodir_location->location_id;
265
+		return $geodir_location->location_id;
266 266
 
267
-    } else {
268
-        return false;
269
-    }
267
+	} else {
268
+		return false;
269
+	}
270 270
 }
271 271
 
272 272
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
  */
281 281
 function geodir_random_float($min = 0, $max = 1)
282 282
 {
283
-    return $min + mt_rand() / mt_getrandmax() * ($max - $min);
283
+	return $min + mt_rand() / mt_getrandmax() * ($max - $min);
284 284
 }
285 285
 
286 286
 /**
@@ -294,20 +294,20 @@  discard block
 block discarded – undo
294 294
  */
295 295
 function geodir_get_address_by_lat_lan($lat, $lng)
296 296
 {
297
-    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng);// . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl.
297
+	$url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng);// . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl.
298 298
 
299
-    $response = wp_remote_get($url);
300
-    if ( is_wp_error( $response ) ) {
301
-        return false;
302
-    }
299
+	$response = wp_remote_get($url);
300
+	if ( is_wp_error( $response ) ) {
301
+		return false;
302
+	}
303 303
 
304
-    $result = json_decode( wp_remote_retrieve_body( $response ) );
304
+	$result = json_decode( wp_remote_retrieve_body( $response ) );
305 305
 
306
-    if(isset($result->results[0]->address_components)){
307
-        return $result->results[0]->address_components;
308
-    }else{
309
-        return false;
310
-    }
306
+	if(isset($result->results[0]->address_components)){
307
+		return $result->results[0]->address_components;
308
+	}else{
309
+		return false;
310
+	}
311 311
 }
312 312
 
313 313
 /**
@@ -324,71 +324,71 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '')
326 326
 {
327
-    global $wp, $gd_session;
328
-    $location_array = array();
329
-    if ($location_array_from == 'session') {
330
-        if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
331
-            return $location_array;
332
-        }
327
+	global $wp, $gd_session;
328
+	$location_array = array();
329
+	if ($location_array_from == 'session') {
330
+		if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
331
+			return $location_array;
332
+		}
333 333
 
334
-        $country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country');
335
-        if ($country != '' && $country)
336
-            $location_array['gd_country'] = urldecode($country);
334
+		$country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country');
335
+		if ($country != '' && $country)
336
+			$location_array['gd_country'] = urldecode($country);
337 337
 
338
-        $region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region');
339
-        if ($region != '' && $region)
340
-            $location_array['gd_region'] = urldecode($region);
338
+		$region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region');
339
+		if ($region != '' && $region)
340
+			$location_array['gd_region'] = urldecode($region);
341 341
 
342
-        $city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city');
343
-        if ($city != '' && $city)
344
-            $location_array['gd_city'] = urldecode($city);
345
-    } else {
346
-        if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
347
-            return $location_array;
348
-        }
342
+		$city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city');
343
+		if ($city != '' && $city)
344
+			$location_array['gd_city'] = urldecode($city);
345
+	} else {
346
+		if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
347
+			return $location_array;
348
+		}
349 349
 
350
-        $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
350
+		$country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
351 351
 
352
-        $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
352
+		$region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
353 353
 
354
-        $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
354
+		$city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
355 355
 
356
-        if ($country != '')
357
-            $location_array['gd_country'] = urldecode($country);
356
+		if ($country != '')
357
+			$location_array['gd_country'] = urldecode($country);
358 358
 
359
-        if ($region != '')
360
-            $location_array['gd_region'] = urldecode($region);
359
+		if ($region != '')
360
+			$location_array['gd_region'] = urldecode($region);
361 361
 
362
-        if ($city != '')
363
-            $location_array['gd_city'] = urldecode($city);
362
+		if ($city != '')
363
+			$location_array['gd_city'] = urldecode($city);
364 364
 			
365 365
 		// Fix category link in ajax popular category widget on change post type
366 366
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
367 367
 			$location_array = geodir_get_current_location_terms('session');
368 368
 		}
369
-    }
369
+	}
370 370
 
371 371
 
372 372
 	/**
373 373
 	 * Filter the location terms.
374 374
 	 *
375 375
 	 * @since 1.4.6
376
-     * @package GeoDirectory
376
+	 * @package GeoDirectory
377
+	 *
378
+	 * @param array $location_array {
379
+	 *    Attributes of the location_array.
380
+	 *
381
+	 *    @type string $gd_country The country slug.
382
+	 *    @type string $gd_region The region slug.
383
+	 *    @type string $gd_city The city slug.
377 384
 	 *
378
-     * @param array $location_array {
379
-     *    Attributes of the location_array.
380
-     *
381
-     *    @type string $gd_country The country slug.
382
-     *    @type string $gd_region The region slug.
383
-     *    @type string $gd_city The city slug.
384
-     *
385
-     * }
385
+	 * }
386 386
 	 * @param string $location_array_from Source type of location terms. Default session.
387 387
 	 * @param string $gd_post_type WP post type.
388 388
 	 */
389 389
 	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
390 390
 
391
-    return $location_array;
391
+	return $location_array;
392 392
 
393 393
 }
394 394
 
@@ -401,24 +401,24 @@  discard block
 block discarded – undo
401 401
  * @return bool|string
402 402
  */
403 403
 function geodir_get_location_link($which_location = 'current') {
404
-    $location_link = get_permalink(geodir_location_page_id());
405
-
406
-    if ($which_location == 'base') {
407
-        return $location_link;
408
-    } else {
409
-        $location_terms = geodir_get_current_location_terms();
410
-
411
-        if (!empty($location_terms)) {
412
-            if (get_option('permalink_structure') != '') {
413
-                $location_terms = implode("/", $location_terms);
414
-                $location_terms = rtrim($location_terms, '/');
415
-                $location_link .= $location_terms;
416
-            } else {
417
-                $location_link = geodir_getlink($location_link, $location_terms);
418
-            }
419
-        }
420
-    }
421
-    return $location_link;
404
+	$location_link = get_permalink(geodir_location_page_id());
405
+
406
+	if ($which_location == 'base') {
407
+		return $location_link;
408
+	} else {
409
+		$location_terms = geodir_get_current_location_terms();
410
+
411
+		if (!empty($location_terms)) {
412
+			if (get_option('permalink_structure') != '') {
413
+				$location_terms = implode("/", $location_terms);
414
+				$location_terms = rtrim($location_terms, '/');
415
+				$location_link .= $location_terms;
416
+			} else {
417
+				$location_link = geodir_getlink($location_link, $location_terms);
418
+			}
419
+		}
420
+	}
421
+	return $location_link;
422 422
 }
423 423
 
424 424
 /**
@@ -431,30 +431,30 @@  discard block
 block discarded – undo
431 431
  * @return array|bool Returns address on success.
432 432
  */
433 433
 function geodir_get_osm_address_by_lat_lan($lat, $lng) {
434
-    $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
434
+	$url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
435 435
 
436
-    $response = wp_remote_get($url);
437
-    if ( is_wp_error( $response ) ) {
438
-        return false;
439
-    }
436
+	$response = wp_remote_get($url);
437
+	if ( is_wp_error( $response ) ) {
438
+		return false;
439
+	}
440 440
 
441
-    $result = json_decode( wp_remote_retrieve_body( $response ) );
441
+	$result = json_decode( wp_remote_retrieve_body( $response ) );
442 442
 
443
-    if(!empty($result->address)){
444
-        $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
445
-        $formatted_address = (array)$result->address;
443
+	if(!empty($result->address)){
444
+		$address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
445
+		$formatted_address = (array)$result->address;
446 446
 
447
-        foreach ( $result->address as $key => $value ) {
448
-            if (!in_array($key, $address_fields)) {
449
-                unset($formatted_address[$key]);
450
-            }
451
-        }
452
-        $result->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
447
+		foreach ( $result->address as $key => $value ) {
448
+			if (!in_array($key, $address_fields)) {
449
+				unset($formatted_address[$key]);
450
+			}
451
+		}
452
+		$result->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
453 453
 
454
-        return $result;
455
-    }else{
456
-        return false;
457
-    }
454
+		return $result;
455
+	}else{
456
+		return false;
457
+	}
458 458
 }
459 459
 
460 460
 /**
@@ -468,51 +468,51 @@  discard block
 block discarded – undo
468 468
  * @return string Returns the country.
469 469
  */
470 470
 function geodir_get_normal_country($country, $default = '1') {
471
-    global $wpdb;
472
-    if ($result = geodir_get_country_by_name($country)) {
473
-        return $result;
474
-    }
471
+	global $wpdb;
472
+	if ($result = geodir_get_country_by_name($country)) {
473
+		return $result;
474
+	}
475 475
     
476
-    if (defined('POST_LOCATION_TABLE')) {
477
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
478
-        if (!empty($rows)) {
479
-            foreach ($rows as $row) {
480
-                $translated = __($row->country, 'geodirectory');
481
-                if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
482
-                    return $result;
483
-                }
484
-            }
485
-        }
476
+	if (defined('POST_LOCATION_TABLE')) {
477
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
478
+		if (!empty($rows)) {
479
+			foreach ($rows as $row) {
480
+				$translated = __($row->country, 'geodirectory');
481
+				if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
482
+					return $result;
483
+				}
484
+			}
485
+		}
486 486
         
487
-        $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) );
488
-        if (!empty($rows)) {
489
-            foreach ($rows as $row) {
490
-                $translated = __($row->country, 'geodirectory');
491
-                if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
492
-                    return $result;
493
-                }
494
-            }
495
-        }
496
-    }
487
+		$rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) );
488
+		if (!empty($rows)) {
489
+			foreach ($rows as $row) {
490
+				$translated = __($row->country, 'geodirectory');
491
+				if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
492
+					return $result;
493
+				}
494
+			}
495
+		}
496
+	}
497 497
     
498
-    if ( $default === '0' ) {
499
-        return NULL;
500
-    }
498
+	if ( $default === '0' ) {
499
+		return NULL;
500
+	}
501 501
     
502
-    $default_location = geodir_get_default_location();
503
-    if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) {
504
-        return $result;
505
-    }
502
+	$default_location = geodir_get_default_location();
503
+	if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) {
504
+		return $result;
505
+	}
506 506
     
507
-    if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) {
508
-        return $result;
509
-    }
507
+	if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) {
508
+		return $result;
509
+	}
510 510
     
511
-    if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) {
512
-        return $result;
513
-    }
511
+	if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) {
512
+		return $result;
513
+	}
514 514
     
515
-    return $country;
515
+	return $country;
516 516
 }
517 517
 
518 518
 /**
@@ -524,16 +524,16 @@  discard block
 block discarded – undo
524 524
  * @return string Country ISO2 code.
525 525
  */
526 526
 function geodir_get_country_iso2($country) {
527
-    global $wpdb;
527
+	global $wpdb;
528 528
     
529
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
530
-        return $result;
531
-    }
532
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
533
-        return $result;
534
-    }
529
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
530
+		return $result;
531
+	}
532
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
533
+		return $result;
534
+	}
535 535
     
536
-    return $country;
536
+	return $country;
537 537
 }
538 538
 
539 539
 /**
@@ -546,16 +546,16 @@  discard block
 block discarded – undo
546 546
  * @return string|null Country ISO2 code.
547 547
  */
548 548
 function geodir_get_country_by_name($country, $iso2 = false) {
549
-    global $wpdb;
549
+	global $wpdb;
550 550
     
551
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
552
-        return $result;
553
-    }
554
-    if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
555
-        return $result;
556
-    }
551
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
552
+		return $result;
553
+	}
554
+	if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
555
+		return $result;
556
+	}
557 557
     
558
-    return NULL;
558
+	return NULL;
559 559
 }
560 560
 
561 561
 
@@ -575,158 +575,158 @@  discard block
 block discarded – undo
575 575
  */
576 576
 function geodir_replace_location_variables($content, $location_array = array(), $sep = NULL, $gd_page = '') {
577 577
 
578
-    if (empty($content)) {
579
-        return $content;
580
-    }
578
+	if (empty($content)) {
579
+		return $content;
580
+	}
581 581
 
582 582
 
583
-    $location_replace_vars = geodir_location_replace_vars($location_array, $sep, $gd_page);
583
+	$location_replace_vars = geodir_location_replace_vars($location_array, $sep, $gd_page);
584 584
 
585
-    if (!empty($location_replace_vars)) {
586
-        foreach ($location_replace_vars as $search => $replace) {
587
-            if (!empty($search) && strpos($content, $search) !== false) {
588
-                $content = str_replace($search, $replace, $content);
589
-            }
590
-        }
591
-    }
585
+	if (!empty($location_replace_vars)) {
586
+		foreach ($location_replace_vars as $search => $replace) {
587
+			if (!empty($search) && strpos($content, $search) !== false) {
588
+				$content = str_replace($search, $replace, $content);
589
+			}
590
+		}
591
+	}
592 592
 
593
-    return $content;
593
+	return $content;
594 594
 }
595 595
 add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables');
596 596
 
597 597
 
598 598
 function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){
599 599
 
600
-    global $wp;
600
+	global $wp;
601 601
     
602
-    $location_manager = defined('GEODIRLOCATION_VERSION') ? true : false;
603
-
604
-    if (empty($location_array)) {
605
-        $location_array = geodir_get_current_location_terms('query_vars');
606
-    }
607
-
608
-    $location_terms = array();
609
-    $location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : '';
610
-    $location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : '';
611
-    $location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : '';
612
-    $location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : '';
613
-
614
-    $location_names = array();
615
-    foreach ($location_terms as $type => $location) {
616
-        $location_name = $location;
617
-
618
-        if (!empty($location_name)) {
619
-            if ($location_manager) {
620
-                $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
621
-                $location_name = get_actual_location_name($location_type, $location, true);
622
-            } else {
623
-                $location_name = preg_replace( '/-(\d+)$/', '', $location_name);
624
-                $location_name = preg_replace( '/[_-]/', ' ', $location_name );
625
-                $location_name = __(geodir_ucwords($location_name), 'geodirectory');
626
-            }
627
-        }
628
-
629
-        $location_names[$type] = $location_name;
630
-    }
631
-
632
-    $location_single = '';
633
-    foreach ($location_terms as $type => $location) {
634
-        if (!empty($location)) {
635
-            if (!empty($location_names[$type])) {
636
-                $location_single = $location_names[$type];
637
-            } else {
638
-                if ($location_manager) {
639
-                    $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
640
-                    $location_single = get_actual_location_name($location_type, $location, true);
641
-                } else {
642
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
643
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
644
-                    $location_single = __(geodir_ucwords($location_name), 'geodirectory');
645
-                }
646
-            }
647
-            break;
648
-        }
649
-    }
650
-
651
-    $full_location = array();
652
-    if (!empty($location_array)) {
653
-        $location_array = array_reverse($location_array);
654
-
655
-        foreach ($location_array as $type => $location) {
656
-            if (!empty($location_names[$type])) {
657
-                $location_name = $location_names[$type];
658
-            } else {
659
-                if ($location_manager) {
660
-                    $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
661
-                    $location_name = get_actual_location_name($location_type, $location, true);
662
-                } else {
663
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
664
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
665
-                    $location_name = __(geodir_ucwords($location_name), 'geodirectory');
666
-                }
667
-            }
602
+	$location_manager = defined('GEODIRLOCATION_VERSION') ? true : false;
603
+
604
+	if (empty($location_array)) {
605
+		$location_array = geodir_get_current_location_terms('query_vars');
606
+	}
607
+
608
+	$location_terms = array();
609
+	$location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : '';
610
+	$location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : '';
611
+	$location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : '';
612
+	$location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : '';
613
+
614
+	$location_names = array();
615
+	foreach ($location_terms as $type => $location) {
616
+		$location_name = $location;
617
+
618
+		if (!empty($location_name)) {
619
+			if ($location_manager) {
620
+				$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
621
+				$location_name = get_actual_location_name($location_type, $location, true);
622
+			} else {
623
+				$location_name = preg_replace( '/-(\d+)$/', '', $location_name);
624
+				$location_name = preg_replace( '/[_-]/', ' ', $location_name );
625
+				$location_name = __(geodir_ucwords($location_name), 'geodirectory');
626
+			}
627
+		}
668 628
 
669
-            $full_location[] = $location_name;
670
-        }
629
+		$location_names[$type] = $location_name;
630
+	}
631
+
632
+	$location_single = '';
633
+	foreach ($location_terms as $type => $location) {
634
+		if (!empty($location)) {
635
+			if (!empty($location_names[$type])) {
636
+				$location_single = $location_names[$type];
637
+			} else {
638
+				if ($location_manager) {
639
+					$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
640
+					$location_single = get_actual_location_name($location_type, $location, true);
641
+				} else {
642
+					$location_name = preg_replace( '/-(\d+)$/', '', $location);
643
+					$location_name = preg_replace( '/[_-]/', ' ', $location_name );
644
+					$location_single = __(geodir_ucwords($location_name), 'geodirectory');
645
+				}
646
+			}
647
+			break;
648
+		}
649
+	}
650
+
651
+	$full_location = array();
652
+	if (!empty($location_array)) {
653
+		$location_array = array_reverse($location_array);
654
+
655
+		foreach ($location_array as $type => $location) {
656
+			if (!empty($location_names[$type])) {
657
+				$location_name = $location_names[$type];
658
+			} else {
659
+				if ($location_manager) {
660
+					$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
661
+					$location_name = get_actual_location_name($location_type, $location, true);
662
+				} else {
663
+					$location_name = preg_replace( '/-(\d+)$/', '', $location);
664
+					$location_name = preg_replace( '/[_-]/', ' ', $location_name );
665
+					$location_name = __(geodir_ucwords($location_name), 'geodirectory');
666
+				}
667
+			}
668
+
669
+			$full_location[] = $location_name;
670
+		}
671 671
 
672
-        if (!empty($full_location)) {
673
-            $full_location = array_unique($full_location);
674
-        }
675
-    }
676
-    $full_location = !empty($full_location) ? implode(', ', $full_location): '';
672
+		if (!empty($full_location)) {
673
+			$full_location = array_unique($full_location);
674
+		}
675
+	}
676
+	$full_location = !empty($full_location) ? implode(', ', $full_location): '';
677 677
     
678
-    if ( empty( $full_location ) ) {
679
-        /**
680
-         * Filter the text in meta description in full location is empty.
681
-         *
682
-         * @since 1.6.22
683
-         * 
684
-         * @param string $full_location Default: Empty.
685
-         * @param array  $location_array The array of location variables.
686
-         * @param string $gd_page       The page being filtered.
687
-         * @param string $sep           The separator.
688
-         */
689
-         $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
690
-    }
678
+	if ( empty( $full_location ) ) {
679
+		/**
680
+		 * Filter the text in meta description in full location is empty.
681
+		 *
682
+		 * @since 1.6.22
683
+		 * 
684
+		 * @param string $full_location Default: Empty.
685
+		 * @param array  $location_array The array of location variables.
686
+		 * @param string $gd_page       The page being filtered.
687
+		 * @param string $sep           The separator.
688
+		 */
689
+		 $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
690
+	}
691 691
     
692
-    if ( empty( $location_single ) ) {
693
-        /**
694
-         * Filter the text in meta description in single location is empty.
695
-         *
696
-         * @since 1.6.22
697
-         * 
698
-         * @param string $location_single Default: Empty.
699
-         * @param array $location_array The array of location variables.
700
-         * @param string $gd_page       The page being filtered.
701
-         * @param string $sep           The separator.
702
-         */
703
-         $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
704
-    }
705
-
706
-    $location_replace_vars = array();
707
-    $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
708
-    $location_replace_vars['%%location%%'] = $full_location;
709
-    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
710
-    $location_replace_vars['%%location_single%%'] = $location_single;
711
-    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
712
-
713
-    foreach ($location_names as $type => $name) {
714
-        $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
715
-
716
-        $location_replace_vars['%%location_' . $location_type . '%%'] = $name;
717
-        $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
718
-    }
719
-
720
-    /**
721
-     * Filter the location terms variables to search & replace.
722
-     *
723
-     * @since   1.6.16
724
-     * @package GeoDirectory
725
-     *
726
-     * @param array $location_replace_vars The array of search & replace variables.
727
-     * @param array $location_array The array of location variables.
728
-     * @param string $gd_page       The page being filtered.
729
-     * @param string $sep           The separator.
730
-     */
731
-    return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
692
+	if ( empty( $location_single ) ) {
693
+		/**
694
+		 * Filter the text in meta description in single location is empty.
695
+		 *
696
+		 * @since 1.6.22
697
+		 * 
698
+		 * @param string $location_single Default: Empty.
699
+		 * @param array $location_array The array of location variables.
700
+		 * @param string $gd_page       The page being filtered.
701
+		 * @param string $sep           The separator.
702
+		 */
703
+		 $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
704
+	}
705
+
706
+	$location_replace_vars = array();
707
+	$location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
708
+	$location_replace_vars['%%location%%'] = $full_location;
709
+	$location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
710
+	$location_replace_vars['%%location_single%%'] = $location_single;
711
+	$location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
712
+
713
+	foreach ($location_names as $type => $name) {
714
+		$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
715
+
716
+		$location_replace_vars['%%location_' . $location_type . '%%'] = $name;
717
+		$location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
718
+	}
719
+
720
+	/**
721
+	 * Filter the location terms variables to search & replace.
722
+	 *
723
+	 * @since   1.6.16
724
+	 * @package GeoDirectory
725
+	 *
726
+	 * @param array $location_replace_vars The array of search & replace variables.
727
+	 * @param array $location_array The array of location variables.
728
+	 * @param string $gd_page       The page being filtered.
729
+	 * @param string $sep           The separator.
730
+	 */
731
+	return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
732 732
 }
733 733
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 {
125 125
     global $wpdb;
126 126
 
127
-    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
127
+    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM ".GEODIR_COUNTRIES_TABLE." ORDER BY Country ASC");
128 128
     
129 129
     $ISO2 = array();
130 130
     $countries = array();
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     
137 137
     asort($countries);
138 138
     
139
-    $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
139
+    $out_put = '<option '.selected('', $post_country, false).' value="">'.__('Select Country', 'geodirectory').'</option>';
140 140
     foreach ($countries as $country => $name) {
141 141
         $ccode = $ISO2[$country];
142 142
 
143
-        $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
143
+        $out_put .= '<option '.selected($post_country, $country, false).' value="'.esc_attr($country).'" data-country_code="'.$ccode.'">'.$name.'</option>';
144 144
     }
145 145
 
146 146
     echo $out_put;
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
         if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
183 183
 
184 184
             foreach ($posttype as $posttypeobj) {
185
-                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
185
+                $post_locations = '['.$default_location->city_slug.'],['.$default_location->region_slug.'],['.$default_location->country_slug.']'; // set all overall post location
186 186
 
187 187
                 $sql = $wpdb->prepare(
188
-                    "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
188
+                    "UPDATE ".$plugin_prefix.$posttypeobj."_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189 189
                     array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190 190
                 );
191 191
                 $wpdb->query($sql);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
          *
234 234
          * @since 1.0.0
235 235
          */
236
-        $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
236
+        $geodir_location = (object) apply_filters('geodir_add_new_location', array('location_id' => 0,
237 237
             'country' => $location_country,
238 238
             'region' => $location_region,
239 239
             'city' => $location_city,
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
  */
295 295
 function geodir_get_address_by_lat_lan($lat, $lng)
296 296
 {
297
-    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng);// . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl.
297
+    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng); // . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl.
298 298
 
299 299
     $response = wp_remote_get($url);
300
-    if ( is_wp_error( $response ) ) {
300
+    if (is_wp_error($response)) {
301 301
         return false;
302 302
     }
303 303
 
304
-    $result = json_decode( wp_remote_retrieve_body( $response ) );
304
+    $result = json_decode(wp_remote_retrieve_body($response));
305 305
 
306
-    if(isset($result->results[0]->address_components)){
306
+    if (isset($result->results[0]->address_components)) {
307 307
         return $result->results[0]->address_components;
308
-    }else{
308
+    } else {
309 309
         return false;
310 310
     }
311 311
 }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 	 * @param string $location_array_from Source type of location terms. Default session.
387 387
 	 * @param string $gd_post_type WP post type.
388 388
 	 */
389
-	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
389
+	$location_array = apply_filters('geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type);
390 390
 
391 391
     return $location_array;
392 392
 
@@ -431,20 +431,20 @@  discard block
 block discarded – undo
431 431
  * @return array|bool Returns address on success.
432 432
  */
433 433
 function geodir_get_osm_address_by_lat_lan($lat, $lng) {
434
-    $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
434
+    $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat='.trim($lat).'&lon='.trim($lng).'&zoom=16&addressdetails=1&email='.get_option('admin_email');
435 435
 
436 436
     $response = wp_remote_get($url);
437
-    if ( is_wp_error( $response ) ) {
437
+    if (is_wp_error($response)) {
438 438
         return false;
439 439
     }
440 440
 
441
-    $result = json_decode( wp_remote_retrieve_body( $response ) );
441
+    $result = json_decode(wp_remote_retrieve_body($response));
442 442
 
443
-    if(!empty($result->address)){
443
+    if (!empty($result->address)) {
444 444
         $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
445
-        $formatted_address = (array)$result->address;
445
+        $formatted_address = (array) $result->address;
446 446
 
447
-        foreach ( $result->address as $key => $value ) {
447
+        foreach ($result->address as $key => $value) {
448 448
             if (!in_array($key, $address_fields)) {
449 449
                 unset($formatted_address[$key]);
450 450
             }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         $result->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
453 453
 
454 454
         return $result;
455
-    }else{
455
+    } else {
456 456
         return false;
457 457
     }
458 458
 }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
     }
475 475
     
476 476
     if (defined('POST_LOCATION_TABLE')) {
477
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
477
+        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
478 478
         if (!empty($rows)) {
479 479
             foreach ($rows as $row) {
480 480
                 $translated = __($row->country, 'geodirectory');
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
             }
485 485
         }
486 486
         
487
-        $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) );
487
+        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country));
488 488
         if (!empty($rows)) {
489 489
             foreach ($rows as $row) {
490 490
                 $translated = __($row->country, 'geodirectory');
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         }
496 496
     }
497 497
     
498
-    if ( $default === '0' ) {
498
+    if ($default === '0') {
499 499
         return NULL;
500 500
     }
501 501
     
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 function geodir_get_country_iso2($country) {
527 527
     global $wpdb;
528 528
     
529
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
529
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", $country))) {
530 530
         return $result;
531 531
     }
532
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
532
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
533 533
         return $result;
534 534
     }
535 535
     
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
 function geodir_get_country_by_name($country, $iso2 = false) {
549 549
     global $wpdb;
550 550
     
551
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
551
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", $country))) {
552 552
         return $result;
553 553
     }
554
-    if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
554
+    if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE ISO2 LIKE %s", $country))) {
555 555
         return $result;
556 556
     }
557 557
     
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables');
596 596
 
597 597
 
598
-function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){
598
+function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = '') {
599 599
 
600 600
     global $wp;
601 601
     
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
                 $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
621 621
                 $location_name = get_actual_location_name($location_type, $location, true);
622 622
             } else {
623
-                $location_name = preg_replace( '/-(\d+)$/', '', $location_name);
624
-                $location_name = preg_replace( '/[_-]/', ' ', $location_name );
623
+                $location_name = preg_replace('/-(\d+)$/', '', $location_name);
624
+                $location_name = preg_replace('/[_-]/', ' ', $location_name);
625 625
                 $location_name = __(geodir_ucwords($location_name), 'geodirectory');
626 626
             }
627 627
         }
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
                     $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
640 640
                     $location_single = get_actual_location_name($location_type, $location, true);
641 641
                 } else {
642
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
643
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
642
+                    $location_name = preg_replace('/-(\d+)$/', '', $location);
643
+                    $location_name = preg_replace('/[_-]/', ' ', $location_name);
644 644
                     $location_single = __(geodir_ucwords($location_name), 'geodirectory');
645 645
                 }
646 646
             }
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
                     $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
661 661
                     $location_name = get_actual_location_name($location_type, $location, true);
662 662
                 } else {
663
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
664
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
663
+                    $location_name = preg_replace('/-(\d+)$/', '', $location);
664
+                    $location_name = preg_replace('/[_-]/', ' ', $location_name);
665 665
                     $location_name = __(geodir_ucwords($location_name), 'geodirectory');
666 666
                 }
667 667
             }
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
             $full_location = array_unique($full_location);
674 674
         }
675 675
     }
676
-    $full_location = !empty($full_location) ? implode(', ', $full_location): '';
676
+    $full_location = !empty($full_location) ? implode(', ', $full_location) : '';
677 677
     
678
-    if ( empty( $full_location ) ) {
678
+    if (empty($full_location)) {
679 679
         /**
680 680
          * Filter the text in meta description in full location is empty.
681 681
          *
@@ -686,10 +686,10 @@  discard block
 block discarded – undo
686 686
          * @param string $gd_page       The page being filtered.
687 687
          * @param string $sep           The separator.
688 688
          */
689
-         $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
689
+         $full_location = apply_filters('geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep);
690 690
     }
691 691
     
692
-    if ( empty( $location_single ) ) {
692
+    if (empty($location_single)) {
693 693
         /**
694 694
          * Filter the text in meta description in single location is empty.
695 695
          *
@@ -700,21 +700,21 @@  discard block
 block discarded – undo
700 700
          * @param string $gd_page       The page being filtered.
701 701
          * @param string $sep           The separator.
702 702
          */
703
-         $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
703
+         $location_single = apply_filters('geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep);
704 704
     }
705 705
 
706 706
     $location_replace_vars = array();
707 707
     $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
708 708
     $location_replace_vars['%%location%%'] = $full_location;
709
-    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
709
+    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $full_location) : '';
710 710
     $location_replace_vars['%%location_single%%'] = $location_single;
711
-    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
711
+    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $location_single) : '';
712 712
 
713 713
     foreach ($location_names as $type => $name) {
714 714
         $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
715 715
 
716
-        $location_replace_vars['%%location_' . $location_type . '%%'] = $name;
717
-        $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
716
+        $location_replace_vars['%%location_'.$location_type.'%%'] = $name;
717
+        $location_replace_vars['%%in_location_'.$location_type.'%%'] = !empty($name) ? sprintf(_x('in %s', 'in location', 'geodirectory'), $name) : '';
718 718
     }
719 719
 
720 720
     /**
@@ -728,5 +728,5 @@  discard block
 block discarded – undo
728 728
      * @param string $gd_page       The page being filtered.
729 729
      * @param string $sep           The separator.
730 730
      */
731
-    return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
731
+    return apply_filters('geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep);
732 732
 }
733 733
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +29 added lines, -21 removed lines patch added patch discarded remove patch
@@ -61,11 +61,12 @@  discard block
 block discarded – undo
61 61
 function geodir_is_default_location_set()
62 62
 {
63 63
     $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
68
-}
64
+    if (!empty($default_location)) {
65
+            return true;
66
+    } else {
67
+            return false;
68
+    }
69
+    }
69 70
 
70 71
 /**
71 72
  * Returns location slug using location string.
@@ -259,8 +260,9 @@  discard block
 block discarded – undo
259 260
         }
260 261
         */
261 262
 
262
-        if ($geodir_location->is_default)
263
-            update_option('geodir_default_location', $geodir_location);
263
+        if ($geodir_location->is_default) {
264
+                    update_option('geodir_default_location', $geodir_location);
265
+        }
264 266
 
265 267
         return $geodir_location->location_id;
266 268
 
@@ -305,7 +307,7 @@  discard block
 block discarded – undo
305 307
 
306 308
     if(isset($result->results[0]->address_components)){
307 309
         return $result->results[0]->address_components;
308
-    }else{
310
+    } else{
309 311
         return false;
310 312
     }
311 313
 }
@@ -332,16 +334,19 @@  discard block
 block discarded – undo
332 334
         }
333 335
 
334 336
         $country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country');
335
-        if ($country != '' && $country)
336
-            $location_array['gd_country'] = urldecode($country);
337
+        if ($country != '' && $country) {
338
+                    $location_array['gd_country'] = urldecode($country);
339
+        }
337 340
 
338 341
         $region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region');
339
-        if ($region != '' && $region)
340
-            $location_array['gd_region'] = urldecode($region);
342
+        if ($region != '' && $region) {
343
+                    $location_array['gd_region'] = urldecode($region);
344
+        }
341 345
 
342 346
         $city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city');
343
-        if ($city != '' && $city)
344
-            $location_array['gd_city'] = urldecode($city);
347
+        if ($city != '' && $city) {
348
+                    $location_array['gd_city'] = urldecode($city);
349
+        }
345 350
     } else {
346 351
         if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
347 352
             return $location_array;
@@ -353,14 +358,17 @@  discard block
 block discarded – undo
353 358
 
354 359
         $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
355 360
 
356
-        if ($country != '')
357
-            $location_array['gd_country'] = urldecode($country);
361
+        if ($country != '') {
362
+                    $location_array['gd_country'] = urldecode($country);
363
+        }
358 364
 
359
-        if ($region != '')
360
-            $location_array['gd_region'] = urldecode($region);
365
+        if ($region != '') {
366
+                    $location_array['gd_region'] = urldecode($region);
367
+        }
361 368
 
362
-        if ($city != '')
363
-            $location_array['gd_city'] = urldecode($city);
369
+        if ($city != '') {
370
+                    $location_array['gd_city'] = urldecode($city);
371
+        }
364 372
 			
365 373
 		// Fix category link in ajax popular category widget on change post type
366 374
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
@@ -452,7 +460,7 @@  discard block
 block discarded – undo
452 460
         $result->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
453 461
 
454 462
         return $result;
455
-    }else{
463
+    } else{
456 464
         return false;
457 465
     }
458 466
 }
Please login to merge, or discard this patch.
uninstall.php 2 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -10,140 +10,140 @@
 block discarded – undo
10 10
 
11 11
 // Exit if accessed directly.
12 12
 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
-    exit;
13
+	exit;
14 14
 }
15 15
 
16 16
 global $wpdb;
17 17
 
18 18
 function geodir_uninstall(){
19
-    global $wpdb;
20
-
21
-    // Pages.
22
-    wp_delete_post( get_option('geodir_location_page'), true );
23
-    wp_delete_post( get_option('geodir_success_page'), true );
24
-    wp_delete_post( get_option('geodir_preview_page'), true );
25
-    wp_delete_post( get_option('geodir_add_listing_page'), true );
26
-    wp_delete_post( get_option('geodir_home_page'), true );
27
-    wp_delete_post( get_option('geodir_info_page'), true );
28
-    wp_delete_post( get_option('geodir_login_page'), true );
29
-
30
-    // Delete usermeta.
31
-    $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'gd\_user\_favourite\_post%';" );
32
-
33
-    // remove post types
34
-    $post_types = get_option('geodir_post_types');
35
-
36
-    // Delete posts.
37
-    if ( ! empty( $post_types ) ) {
38
-        foreach ( $post_types as $post_type => $data ) {
39
-            $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type LIKE '{$post_type}';" );
40
-
41
-            // Delete post menu
42
-            $wpdb->query( "DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_object' AND meta.meta_value = '{$post_type}';" );
43
-            $wpdb->query( "DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_url' AND meta.meta_value LIKE '%listing_type={$post_type}%';" );
44
-        }
45
-    }
46
-
47
-    // Delete post meta.
48
-    $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
49
-
50
-    // Delete orphan attachment.
51
-    $wpdb->query( "DELETE post1 FROM {$wpdb->posts} post1 LEFT JOIN {$wpdb->posts} post2 ON post1.post_parent = post2.ID WHERE post1.post_parent > 0 AND post1.post_type = 'attachment' AND post2.ID IS NULL;" );
52
-
53
-    // Delete term taxonomies.
54
-    if ( ! empty( $post_types ) ) {
55
-        foreach ( $post_types as $post_type => $data  ) {
56
-            $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy LIKE '{$post_type}category' OR taxonomy LIKE '{$post_type}_tags';" );
57
-        }
58
-    }
59
-
60
-    // Delete orphan relationships.
61
-    $wpdb->query( "DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;" );
62
-
63
-    // Delete orphan terms.
64
-    $wpdb->query( "DELETE t FROM {$wpdb->terms} t LEFT JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
65
-
66
-    // Delete orphan term meta.
67
-    $wpdb->query( "DELETE tm FROM {$wpdb->termmeta} tm LEFT JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
68
-
69
-    // Comments
70
-    $wpdb->query( "DELETE comments FROM {$wpdb->comments} AS comments LEFT JOIN {$wpdb->posts} AS posts ON posts.ID = comments.comment_post_ID WHERE posts.ID IS NULL;" );
71
-    $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" );
72
-
73
-    // Options
74
-    // Delete settings
75
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'geodir_settings' OR option_name LIKE 'geodirectory\_%' OR option_name LIKE 'geodir\_%' OR option_name LIKE 'tax_meta_gd\_%' OR  option_name LIKE 'gd\_%' AND option_name LIKE '%category\_installed' ;" );
76
-
77
-    // Extra options
78
-    $extra_options = array(
79
-        "widget_popular_post_category",
80
-        "widget_popular_post_view",
81
-        "gd_theme_compats",
82
-        "gd_theme_compats",
83
-        "theme_compatibility_setting",
84
-        "skip_install_geodir_pages",
85
-        "widget_social_like_widget",
86
-        "widget_widget_subscribewidget",
87
-        "widget_advtwidget",
88
-        "widget_widget_flickrwidget",
89
-        "widget_widget_twidget",
90
-        "widget_listing_slider_view",
91
-        "widget_geodir_recent_reviews",
92
-        "widget_post_related_listing",
93
-        "widget_bestof_widget",
94
-        "gd_place_dummy_data_type",
95
-        "gd_theme_compat",
96
-        "gd_term_icons",
97
-    );
98
-
99
-    foreach( $extra_options as $option){
100
-        $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name= '$option';" );
101
-    }
102
-
103
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'widget\_gd\_%' OR option_name LIKE 'widget\_geodir\_%' ;" );
104
-
105
-    // Delete transients
106
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient__gd_activation_redirect' OR option_name LIKE '\_transient\_geodir\_%' OR option_name LIKE '\_transient\_gd_addons_section\_%' OR option_name LIKE '\_transient\_gd_avg\_%'" );
107
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_timeout\_transient\_geodir\_%' OR option_name LIKE '\_timeout\_transient\_gd_addons_section\_%' OR option_name LIKE '\_timeout\_transient\_gd_avg\_%'" );
108
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_geodir\_%' OR option_name LIKE '\_site\_transient\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_gd_avg\_%'" );
109
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_timeout\_geodir\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_avg\_%'" );
110
-
111
-    // Drop tables
112
-    $plugin_prefix = $wpdb->prefix . 'geodir_';
113
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'countries' );
114
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'custom_fields' );
115
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'post_icon' );
116
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'attachments' );
117
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'post_review' );
118
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'custom_sort_fields' );
119
-
120
-
121
-    // Delete term taxonomies.
122
-    if ( ! empty( $post_types ) ) {
123
-        foreach ( $post_types as $post_type => $data  ) {
124
-            $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . $post_type . '_detail' );
125
-
126
-        }
127
-    }
128
-
129
-    // Clear any cached data that has been removed.
130
-    wp_cache_flush();
19
+	global $wpdb;
20
+
21
+	// Pages.
22
+	wp_delete_post( get_option('geodir_location_page'), true );
23
+	wp_delete_post( get_option('geodir_success_page'), true );
24
+	wp_delete_post( get_option('geodir_preview_page'), true );
25
+	wp_delete_post( get_option('geodir_add_listing_page'), true );
26
+	wp_delete_post( get_option('geodir_home_page'), true );
27
+	wp_delete_post( get_option('geodir_info_page'), true );
28
+	wp_delete_post( get_option('geodir_login_page'), true );
29
+
30
+	// Delete usermeta.
31
+	$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'gd\_user\_favourite\_post%';" );
32
+
33
+	// remove post types
34
+	$post_types = get_option('geodir_post_types');
35
+
36
+	// Delete posts.
37
+	if ( ! empty( $post_types ) ) {
38
+		foreach ( $post_types as $post_type => $data ) {
39
+			$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type LIKE '{$post_type}';" );
40
+
41
+			// Delete post menu
42
+			$wpdb->query( "DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_object' AND meta.meta_value = '{$post_type}';" );
43
+			$wpdb->query( "DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_url' AND meta.meta_value LIKE '%listing_type={$post_type}%';" );
44
+		}
45
+	}
46
+
47
+	// Delete post meta.
48
+	$wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
49
+
50
+	// Delete orphan attachment.
51
+	$wpdb->query( "DELETE post1 FROM {$wpdb->posts} post1 LEFT JOIN {$wpdb->posts} post2 ON post1.post_parent = post2.ID WHERE post1.post_parent > 0 AND post1.post_type = 'attachment' AND post2.ID IS NULL;" );
52
+
53
+	// Delete term taxonomies.
54
+	if ( ! empty( $post_types ) ) {
55
+		foreach ( $post_types as $post_type => $data  ) {
56
+			$wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy LIKE '{$post_type}category' OR taxonomy LIKE '{$post_type}_tags';" );
57
+		}
58
+	}
59
+
60
+	// Delete orphan relationships.
61
+	$wpdb->query( "DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;" );
62
+
63
+	// Delete orphan terms.
64
+	$wpdb->query( "DELETE t FROM {$wpdb->terms} t LEFT JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
65
+
66
+	// Delete orphan term meta.
67
+	$wpdb->query( "DELETE tm FROM {$wpdb->termmeta} tm LEFT JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
68
+
69
+	// Comments
70
+	$wpdb->query( "DELETE comments FROM {$wpdb->comments} AS comments LEFT JOIN {$wpdb->posts} AS posts ON posts.ID = comments.comment_post_ID WHERE posts.ID IS NULL;" );
71
+	$wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" );
72
+
73
+	// Options
74
+	// Delete settings
75
+	$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'geodir_settings' OR option_name LIKE 'geodirectory\_%' OR option_name LIKE 'geodir\_%' OR option_name LIKE 'tax_meta_gd\_%' OR  option_name LIKE 'gd\_%' AND option_name LIKE '%category\_installed' ;" );
76
+
77
+	// Extra options
78
+	$extra_options = array(
79
+		"widget_popular_post_category",
80
+		"widget_popular_post_view",
81
+		"gd_theme_compats",
82
+		"gd_theme_compats",
83
+		"theme_compatibility_setting",
84
+		"skip_install_geodir_pages",
85
+		"widget_social_like_widget",
86
+		"widget_widget_subscribewidget",
87
+		"widget_advtwidget",
88
+		"widget_widget_flickrwidget",
89
+		"widget_widget_twidget",
90
+		"widget_listing_slider_view",
91
+		"widget_geodir_recent_reviews",
92
+		"widget_post_related_listing",
93
+		"widget_bestof_widget",
94
+		"gd_place_dummy_data_type",
95
+		"gd_theme_compat",
96
+		"gd_term_icons",
97
+	);
98
+
99
+	foreach( $extra_options as $option){
100
+		$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name= '$option';" );
101
+	}
102
+
103
+	$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'widget\_gd\_%' OR option_name LIKE 'widget\_geodir\_%' ;" );
104
+
105
+	// Delete transients
106
+	$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient__gd_activation_redirect' OR option_name LIKE '\_transient\_geodir\_%' OR option_name LIKE '\_transient\_gd_addons_section\_%' OR option_name LIKE '\_transient\_gd_avg\_%'" );
107
+	$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_timeout\_transient\_geodir\_%' OR option_name LIKE '\_timeout\_transient\_gd_addons_section\_%' OR option_name LIKE '\_timeout\_transient\_gd_avg\_%'" );
108
+	$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_geodir\_%' OR option_name LIKE '\_site\_transient\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_gd_avg\_%'" );
109
+	$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_timeout\_geodir\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_avg\_%'" );
110
+
111
+	// Drop tables
112
+	$plugin_prefix = $wpdb->prefix . 'geodir_';
113
+	$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'countries' );
114
+	$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'custom_fields' );
115
+	$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'post_icon' );
116
+	$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'attachments' );
117
+	$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'post_review' );
118
+	$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'custom_sort_fields' );
119
+
120
+
121
+	// Delete term taxonomies.
122
+	if ( ! empty( $post_types ) ) {
123
+		foreach ( $post_types as $post_type => $data  ) {
124
+			$wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . $post_type . '_detail' );
125
+
126
+		}
127
+	}
128
+
129
+	// Clear any cached data that has been removed.
130
+	wp_cache_flush();
131 131
 
132 132
 }
133 133
 
134 134
 if (get_option('geodir_un_geodirectory')) {
135
-    $wpdb->hide_errors();
135
+	$wpdb->hide_errors();
136 136
     
137
-    /*
137
+	/*
138 138
     if (!defined('GEODIRECTORY_VERSION')) {
139 139
         // Load plugin file.
140 140
         include_once('geodirectory.php');
141 141
     }
142 142
     */
143 143
 
144
-    geodir_uninstall();
144
+	geodir_uninstall();
145 145
 
146
-    // Delete default data.
147
-    delete_option('geodir_default_data_installed');
146
+	// Delete default data.
147
+	delete_option('geodir_default_data_installed');
148 148
 }
149 149
 
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -9,70 +9,70 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
12
+if (!defined('WP_UNINSTALL_PLUGIN')) {
13 13
     exit;
14 14
 }
15 15
 
16 16
 global $wpdb;
17 17
 
18
-function geodir_uninstall(){
18
+function geodir_uninstall() {
19 19
     global $wpdb;
20 20
 
21 21
     // Pages.
22
-    wp_delete_post( get_option('geodir_location_page'), true );
23
-    wp_delete_post( get_option('geodir_success_page'), true );
24
-    wp_delete_post( get_option('geodir_preview_page'), true );
25
-    wp_delete_post( get_option('geodir_add_listing_page'), true );
26
-    wp_delete_post( get_option('geodir_home_page'), true );
27
-    wp_delete_post( get_option('geodir_info_page'), true );
28
-    wp_delete_post( get_option('geodir_login_page'), true );
22
+    wp_delete_post(get_option('geodir_location_page'), true);
23
+    wp_delete_post(get_option('geodir_success_page'), true);
24
+    wp_delete_post(get_option('geodir_preview_page'), true);
25
+    wp_delete_post(get_option('geodir_add_listing_page'), true);
26
+    wp_delete_post(get_option('geodir_home_page'), true);
27
+    wp_delete_post(get_option('geodir_info_page'), true);
28
+    wp_delete_post(get_option('geodir_login_page'), true);
29 29
 
30 30
     // Delete usermeta.
31
-    $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'gd\_user\_favourite\_post%';" );
31
+    $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'gd\_user\_favourite\_post%';");
32 32
 
33 33
     // remove post types
34 34
     $post_types = get_option('geodir_post_types');
35 35
 
36 36
     // Delete posts.
37
-    if ( ! empty( $post_types ) ) {
38
-        foreach ( $post_types as $post_type => $data ) {
39
-            $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type LIKE '{$post_type}';" );
37
+    if (!empty($post_types)) {
38
+        foreach ($post_types as $post_type => $data) {
39
+            $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type LIKE '{$post_type}';");
40 40
 
41 41
             // Delete post menu
42
-            $wpdb->query( "DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_object' AND meta.meta_value = '{$post_type}';" );
43
-            $wpdb->query( "DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_url' AND meta.meta_value LIKE '%listing_type={$post_type}%';" );
42
+            $wpdb->query("DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_object' AND meta.meta_value = '{$post_type}';");
43
+            $wpdb->query("DELETE posts FROM {$wpdb->posts} posts LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id WHERE posts.post_type= 'nav_menu_item' AND meta.meta_key = '_menu_item_url' AND meta.meta_value LIKE '%listing_type={$post_type}%';");
44 44
         }
45 45
     }
46 46
 
47 47
     // Delete post meta.
48
-    $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
48
+    $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;");
49 49
 
50 50
     // Delete orphan attachment.
51
-    $wpdb->query( "DELETE post1 FROM {$wpdb->posts} post1 LEFT JOIN {$wpdb->posts} post2 ON post1.post_parent = post2.ID WHERE post1.post_parent > 0 AND post1.post_type = 'attachment' AND post2.ID IS NULL;" );
51
+    $wpdb->query("DELETE post1 FROM {$wpdb->posts} post1 LEFT JOIN {$wpdb->posts} post2 ON post1.post_parent = post2.ID WHERE post1.post_parent > 0 AND post1.post_type = 'attachment' AND post2.ID IS NULL;");
52 52
 
53 53
     // Delete term taxonomies.
54
-    if ( ! empty( $post_types ) ) {
55
-        foreach ( $post_types as $post_type => $data  ) {
56
-            $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy LIKE '{$post_type}category' OR taxonomy LIKE '{$post_type}_tags';" );
54
+    if (!empty($post_types)) {
55
+        foreach ($post_types as $post_type => $data) {
56
+            $wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy LIKE '{$post_type}category' OR taxonomy LIKE '{$post_type}_tags';");
57 57
         }
58 58
     }
59 59
 
60 60
     // Delete orphan relationships.
61
-    $wpdb->query( "DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;" );
61
+    $wpdb->query("DELETE tr FROM {$wpdb->term_relationships} tr LEFT JOIN {$wpdb->posts} posts ON posts.ID = tr.object_id WHERE posts.ID IS NULL;");
62 62
 
63 63
     // Delete orphan terms.
64
-    $wpdb->query( "DELETE t FROM {$wpdb->terms} t LEFT JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
64
+    $wpdb->query("DELETE t FROM {$wpdb->terms} t LEFT JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.term_id IS NULL;");
65 65
 
66 66
     // Delete orphan term meta.
67
-    $wpdb->query( "DELETE tm FROM {$wpdb->termmeta} tm LEFT JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.term_id IS NULL;" );
67
+    $wpdb->query("DELETE tm FROM {$wpdb->termmeta} tm LEFT JOIN {$wpdb->term_taxonomy} tt ON tm.term_id = tt.term_id WHERE tt.term_id IS NULL;");
68 68
 
69 69
     // Comments
70
-    $wpdb->query( "DELETE comments FROM {$wpdb->comments} AS comments LEFT JOIN {$wpdb->posts} AS posts ON posts.ID = comments.comment_post_ID WHERE posts.ID IS NULL;" );
71
-    $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" );
70
+    $wpdb->query("DELETE comments FROM {$wpdb->comments} AS comments LEFT JOIN {$wpdb->posts} AS posts ON posts.ID = comments.comment_post_ID WHERE posts.ID IS NULL;");
71
+    $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;");
72 72
 
73 73
     // Options
74 74
     // Delete settings
75
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'geodir_settings' OR option_name LIKE 'geodirectory\_%' OR option_name LIKE 'geodir\_%' OR option_name LIKE 'tax_meta_gd\_%' OR  option_name LIKE 'gd\_%' AND option_name LIKE '%category\_installed' ;" );
75
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'geodir_settings' OR option_name LIKE 'geodirectory\_%' OR option_name LIKE 'geodir\_%' OR option_name LIKE 'tax_meta_gd\_%' OR  option_name LIKE 'gd\_%' AND option_name LIKE '%category\_installed' ;");
76 76
 
77 77
     // Extra options
78 78
     $extra_options = array(
@@ -96,32 +96,32 @@  discard block
 block discarded – undo
96 96
         "gd_term_icons",
97 97
     );
98 98
 
99
-    foreach( $extra_options as $option){
100
-        $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name= '$option';" );
99
+    foreach ($extra_options as $option) {
100
+        $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name= '$option';");
101 101
     }
102 102
 
103
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'widget\_gd\_%' OR option_name LIKE 'widget\_geodir\_%' ;" );
103
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'widget\_gd\_%' OR option_name LIKE 'widget\_geodir\_%' ;");
104 104
 
105 105
     // Delete transients
106
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient__gd_activation_redirect' OR option_name LIKE '\_transient\_geodir\_%' OR option_name LIKE '\_transient\_gd_addons_section\_%' OR option_name LIKE '\_transient\_gd_avg\_%'" );
107
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_timeout\_transient\_geodir\_%' OR option_name LIKE '\_timeout\_transient\_gd_addons_section\_%' OR option_name LIKE '\_timeout\_transient\_gd_avg\_%'" );
108
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_geodir\_%' OR option_name LIKE '\_site\_transient\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_gd_avg\_%'" );
109
-    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_timeout\_geodir\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_avg\_%'" );
106
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient__gd_activation_redirect' OR option_name LIKE '\_transient\_geodir\_%' OR option_name LIKE '\_transient\_gd_addons_section\_%' OR option_name LIKE '\_transient\_gd_avg\_%'");
107
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_timeout\_transient\_geodir\_%' OR option_name LIKE '\_timeout\_transient\_gd_addons_section\_%' OR option_name LIKE '\_timeout\_transient\_gd_avg\_%'");
108
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_geodir\_%' OR option_name LIKE '\_site\_transient\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_gd_avg\_%'");
109
+    $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_site_transient_timeout__gd_activation_redirect' OR option_name LIKE '\_site\_transient\_timeout\_geodir\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_addons_section\_%' OR option_name LIKE '\_site\_transient\_timeout\_gd_avg\_%'");
110 110
 
111 111
     // Drop tables
112
-    $plugin_prefix = $wpdb->prefix . 'geodir_';
113
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'countries' );
114
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'custom_fields' );
115
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'post_icon' );
116
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'attachments' );
117
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'post_review' );
118
-    $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . 'custom_sort_fields' );
112
+    $plugin_prefix = $wpdb->prefix.'geodir_';
113
+    $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.'countries');
114
+    $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.'custom_fields');
115
+    $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.'post_icon');
116
+    $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.'attachments');
117
+    $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.'post_review');
118
+    $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.'custom_sort_fields');
119 119
 
120 120
 
121 121
     // Delete term taxonomies.
122
-    if ( ! empty( $post_types ) ) {
123
-        foreach ( $post_types as $post_type => $data  ) {
124
-            $wpdb->query( "DROP TABLE IF EXISTS ". $plugin_prefix . $post_type . '_detail' );
122
+    if (!empty($post_types)) {
123
+        foreach ($post_types as $post_type => $data) {
124
+            $wpdb->query("DROP TABLE IF EXISTS ".$plugin_prefix.$post_type.'_detail');
125 125
 
126 126
         }
127 127
     }
Please login to merge, or discard this patch.