Test Failed
Push — master ( 9498cc...6f90fd )
by Stiofan
25:52
created
geodirectory-functions/helper_functions.php 2 patches
Indentation   +379 added lines, -379 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
  * @return int|null Return the page ID if present or null if not.
15 15
  */
16 16
 function geodir_add_listing_page_id(){
17
-    $gd_page_id = get_option('geodir_add_listing_page');
17
+	$gd_page_id = get_option('geodir_add_listing_page');
18 18
 
19
-    if (function_exists('icl_object_id')) {
20
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
21
-    }
19
+	if (function_exists('icl_object_id')) {
20
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
21
+	}
22 22
 
23
-    return $gd_page_id;
23
+	return $gd_page_id;
24 24
 }
25 25
 
26 26
 /**
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  * @return int|null Return the page ID if present or null if not.
32 32
  */
33 33
 function geodir_preview_page_id(){
34
-    $gd_page_id = get_option('geodir_preview_page');
34
+	$gd_page_id = get_option('geodir_preview_page');
35 35
 
36
-    if (function_exists('icl_object_id')) {
37
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
38
-    }
36
+	if (function_exists('icl_object_id')) {
37
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
38
+	}
39 39
 
40
-    return $gd_page_id;
40
+	return $gd_page_id;
41 41
 }
42 42
 
43 43
 /**
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
  * @return int|null Return the page ID if present or null if not.
49 49
  */
50 50
 function geodir_success_page_id(){
51
-    $gd_page_id = get_option('geodir_success_page');
51
+	$gd_page_id = get_option('geodir_success_page');
52 52
 
53
-    if (function_exists('icl_object_id')) {
54
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
55
-    }
53
+	if (function_exists('icl_object_id')) {
54
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
55
+	}
56 56
 
57
-    return $gd_page_id;
57
+	return $gd_page_id;
58 58
 }
59 59
 
60 60
 /**
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  * @return int|null Return the page ID if present or null if not.
66 66
  */
67 67
 function geodir_location_page_id(){
68
-    $gd_page_id = get_option('geodir_location_page');
68
+	$gd_page_id = get_option('geodir_location_page');
69 69
 
70
-    if (function_exists('icl_object_id')) {
71
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
72
-    }
70
+	if (function_exists('icl_object_id')) {
71
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
72
+	}
73 73
 
74
-    return $gd_page_id;
74
+	return $gd_page_id;
75 75
 }
76 76
 
77 77
 /**
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
  * @return int|null Return the page ID if present or null if not.
83 83
  */
84 84
 function geodir_home_page_id(){
85
-    $gd_page_id = get_option('geodir_home_page');
85
+	$gd_page_id = get_option('geodir_home_page');
86 86
 
87
-    if (function_exists('icl_object_id')) {
88
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
89
-    }
87
+	if (function_exists('icl_object_id')) {
88
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
89
+	}
90 90
 
91
-    return $gd_page_id;
91
+	return $gd_page_id;
92 92
 }
93 93
 
94 94
 /**
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
  * @return int|null Return the page ID if present or null if not.
100 100
  */
101 101
 function geodir_info_page_id(){
102
-    $gd_page_id = get_option('geodir_info_page');
102
+	$gd_page_id = get_option('geodir_info_page');
103 103
 
104
-    if (function_exists('icl_object_id')) {
105
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
106
-    }
104
+	if (function_exists('icl_object_id')) {
105
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
106
+	}
107 107
 
108
-    return $gd_page_id;
108
+	return $gd_page_id;
109 109
 }
110 110
 
111 111
 /**
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
  * @return int|null Return the page ID if present or null if not.
117 117
  */
118 118
 function geodir_login_page_id(){
119
-    $gd_page_id = get_option('geodir_login_page');
119
+	$gd_page_id = get_option('geodir_login_page');
120 120
 
121
-    if (function_exists('icl_object_id')) {
122
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
123
-    }
121
+	if (function_exists('icl_object_id')) {
122
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
123
+	}
124 124
 
125
-    return $gd_page_id;
125
+	return $gd_page_id;
126 126
 }
127 127
 
128 128
 
@@ -134,51 +134,51 @@  discard block
 block discarded – undo
134 134
  * @return int|null Return the page ID if present or null if not.
135 135
  */
136 136
 function geodir_login_url($args=array()){
137
-    $gd_page_id = get_option('geodir_login_page');
138
-
139
-    if (function_exists('icl_object_id')) {
140
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
141
-    }
142
-
143
-    if (function_exists('geodir_location_geo_home_link')) {
144
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
145
-    }
146
-
147
-    if (geodir_is_wpml()){
148
-        $home_url = icl_get_home_url();
149
-    }else{
150
-        $home_url = home_url();
151
-    }
152
-
153
-    if (function_exists('geodir_location_geo_home_link')) {
154
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
155
-    }
156
-
157
-    if($gd_page_id){
158
-        $post = get_post($gd_page_id);
159
-        $slug = $post->post_name;
160
-        //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161
-        $login_url = trailingslashit($home_url)."$slug/";
162
-    }else{
163
-        $login_url = trailingslashit($home_url)."?geodir_signup=true";
164
-    }
165
-
166
-    if($args){
167
-        $login_url = add_query_arg($args,$login_url );
168
-    }
169
-
170
-    /**
171
-     * Filter the GeoDirectory login page url.
172
-     *
173
-     * This filter can be used to change the GeoDirectory page url.
174
-     *
175
-     * @since 1.5.3
176
-     * @package GeoDirectory
177
-     * @param string $login_url The url of the login page.
178
-     * @param array $args The array of query args used.
179
-     * @param int $gd_page_id The page id of the GD login page.
180
-     */
181
-	    return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id);
137
+	$gd_page_id = get_option('geodir_login_page');
138
+
139
+	if (function_exists('icl_object_id')) {
140
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
141
+	}
142
+
143
+	if (function_exists('geodir_location_geo_home_link')) {
144
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
145
+	}
146
+
147
+	if (geodir_is_wpml()){
148
+		$home_url = icl_get_home_url();
149
+	}else{
150
+		$home_url = home_url();
151
+	}
152
+
153
+	if (function_exists('geodir_location_geo_home_link')) {
154
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
155
+	}
156
+
157
+	if($gd_page_id){
158
+		$post = get_post($gd_page_id);
159
+		$slug = $post->post_name;
160
+		//$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161
+		$login_url = trailingslashit($home_url)."$slug/";
162
+	}else{
163
+		$login_url = trailingslashit($home_url)."?geodir_signup=true";
164
+	}
165
+
166
+	if($args){
167
+		$login_url = add_query_arg($args,$login_url );
168
+	}
169
+
170
+	/**
171
+	 * Filter the GeoDirectory login page url.
172
+	 *
173
+	 * This filter can be used to change the GeoDirectory page url.
174
+	 *
175
+	 * @since 1.5.3
176
+	 * @package GeoDirectory
177
+	 * @param string $login_url The url of the login page.
178
+	 * @param array $args The array of query args used.
179
+	 * @param int $gd_page_id The page id of the GD login page.
180
+	 */
181
+		return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id);
182 182
 }
183 183
 
184 184
 /**
@@ -190,40 +190,40 @@  discard block
 block discarded – undo
190 190
  * @return string Info page url.
191 191
  */
192 192
 function geodir_info_url($args=array()){
193
-    $gd_page_id = get_option('geodir_info_page');
194
-
195
-    if (function_exists('icl_object_id')) {
196
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
197
-    }
198
-
199
-    if (function_exists('geodir_location_geo_home_link')) {
200
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
201
-    }
202
-
203
-    if (geodir_is_wpml()){
204
-        $home_url = icl_get_home_url();
205
-    }else{
206
-        $home_url = home_url();
207
-    }
208
-
209
-    if (function_exists('geodir_location_geo_home_link')) {
210
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
211
-    }
212
-
213
-    if($gd_page_id){
214
-        $post = get_post($gd_page_id);
215
-        $slug = $post->post_name;
216
-        //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217
-        $info_url = trailingslashit($home_url)."$slug/";
218
-    }else{
219
-        $info_url = trailingslashit($home_url);
220
-    }
221
-
222
-    if($args){
223
-        $info_url = add_query_arg($args,$info_url );
224
-    }
225
-
226
-    return $info_url;
193
+	$gd_page_id = get_option('geodir_info_page');
194
+
195
+	if (function_exists('icl_object_id')) {
196
+		$gd_page_id =  icl_object_id($gd_page_id, 'page', true);
197
+	}
198
+
199
+	if (function_exists('geodir_location_geo_home_link')) {
200
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
201
+	}
202
+
203
+	if (geodir_is_wpml()){
204
+		$home_url = icl_get_home_url();
205
+	}else{
206
+		$home_url = home_url();
207
+	}
208
+
209
+	if (function_exists('geodir_location_geo_home_link')) {
210
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
211
+	}
212
+
213
+	if($gd_page_id){
214
+		$post = get_post($gd_page_id);
215
+		$slug = $post->post_name;
216
+		//$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217
+		$info_url = trailingslashit($home_url)."$slug/";
218
+	}else{
219
+		$info_url = trailingslashit($home_url);
220
+	}
221
+
222
+	if($args){
223
+		$info_url = add_query_arg($args,$info_url );
224
+	}
225
+
226
+	return $info_url;
227 227
 }
228 228
 
229 229
 /**
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
  * @return string Returns converted string.
240 240
  */
241 241
 function geodir_ucwords($string, $charset='UTF-8') {
242
-    if (function_exists('mb_convert_case')) {
243
-        return mb_convert_case($string, MB_CASE_TITLE, $charset);
244
-    } else {
245
-        return ucwords($string);
246
-    }
242
+	if (function_exists('mb_convert_case')) {
243
+		return mb_convert_case($string, MB_CASE_TITLE, $charset);
244
+	} else {
245
+		return ucwords($string);
246
+	}
247 247
 }
248 248
 
249 249
 /**
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  * @return string Returns converted string.
260 260
  */
261 261
 function geodir_strtolower($string, $charset='UTF-8') {
262
-    if (function_exists('mb_convert_case')) {
263
-        return mb_convert_case($string, MB_CASE_LOWER, $charset);
264
-    } else {
265
-        return strtolower($string);
266
-    }
262
+	if (function_exists('mb_convert_case')) {
263
+		return mb_convert_case($string, MB_CASE_LOWER, $charset);
264
+	} else {
265
+		return strtolower($string);
266
+	}
267 267
 }
268 268
 
269 269
 /**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
  * @return string Returns converted string.
280 280
  */
281 281
 function geodir_strtoupper($string, $charset='UTF-8') {
282
-    if (function_exists('mb_convert_case')) {
283
-        return mb_convert_case($string, MB_CASE_UPPER, $charset);
284
-    } else {
285
-        return strtoupper($string);
286
-    }
282
+	if (function_exists('mb_convert_case')) {
283
+		return mb_convert_case($string, MB_CASE_UPPER, $charset);
284
+	} else {
285
+		return strtoupper($string);
286
+	}
287 287
 }
288 288
 
289 289
 /**
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
  * @package GeoDirectory
463 463
  */
464 464
 function _gd_die_handler() {
465
-    if ( defined( 'GD_TESTING_MODE' ) ) {
466
-        return '_gd_die_handler';
467
-    } else {
468
-        die();
469
-    }
465
+	if ( defined( 'GD_TESTING_MODE' ) ) {
466
+		return '_gd_die_handler';
467
+	} else {
468
+		die();
469
+	}
470 470
 }
471 471
 
472 472
 /**
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
  * @param int $status     Optional. Status code.
482 482
  */
483 483
 function gd_die( $message = '', $title = '', $status = 400 ) {
484
-    add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 );
485
-    add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 );
486
-    wp_die( $message, $title, array( 'response' => $status ));
484
+	add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 );
485
+	add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 );
486
+	wp_die( $message, $title, array( 'response' => $status ));
487 487
 }
488 488
 
489 489
 /*
@@ -652,37 +652,37 @@  discard block
 block discarded – undo
652 652
  * @return string The formatted date.
653 653
  */
654 654
 function geodir_date($date_input, $date_to, $date_from = '') {
655
-    if (empty($date_input) || empty($date_to)) {
656
-        return NULL;
657
-    }
655
+	if (empty($date_input) || empty($date_to)) {
656
+		return NULL;
657
+	}
658 658
     
659
-    $date = '';
660
-    if (!empty($date_from)) {
661
-        $datetime = date_create_from_format($date_from, $date_input);
659
+	$date = '';
660
+	if (!empty($date_from)) {
661
+		$datetime = date_create_from_format($date_from, $date_input);
662 662
         
663
-        if (!empty($datetime)) {
664
-            $date = $datetime->format($date_to);
665
-        }
666
-    }
663
+		if (!empty($datetime)) {
664
+			$date = $datetime->format($date_to);
665
+		}
666
+	}
667 667
     
668
-    if (empty($date)) {
669
-        $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input;
670
-        $date = date_i18n($date_to, strtotime($date));
671
-    }
668
+	if (empty($date)) {
669
+		$date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input;
670
+		$date = date_i18n($date_to, strtotime($date));
671
+	}
672 672
     
673
-    $date = geodir_maybe_untranslate_date($date);
674
-    /**
675
-     * Filter the the date format conversion.
676
-     *
677
-     * @since 1.6.7
678
-     * @package GeoDirectory
679
-     *
680
-     * @param string $date The date string.
681
-     * @param string $date_input The date input.
682
-     * @param string $date_to The destination date format.
683
-     * @param string $date_from The source date format.
684
-     */
685
-    return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from);
673
+	$date = geodir_maybe_untranslate_date($date);
674
+	/**
675
+	 * Filter the the date format conversion.
676
+	 *
677
+	 * @since 1.6.7
678
+	 * @package GeoDirectory
679
+	 *
680
+	 * @param string $date The date string.
681
+	 * @param string $date_input The date input.
682
+	 * @param string $date_to The destination date format.
683
+	 * @param string $date_from The source date format.
684
+	 */
685
+	return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from);
686 686
 }
687 687
 
688 688
 /**
@@ -707,91 +707,91 @@  discard block
 block discarded – undo
707 707
  * @return string Trimmed string.
708 708
  */
709 709
 function geodir_excerpt($text, $length = 100, $options = array()) {
710
-    if (!(int)$length > 0) {
711
-        return $text;
712
-    }
713
-    $default = array(
714
-        'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false,
710
+	if (!(int)$length > 0) {
711
+		return $text;
712
+	}
713
+	$default = array(
714
+		'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false,
715 715
 	);
716
-    if (!empty($options['html']) && function_exists('mb_internal_encoding') && strtolower(mb_internal_encoding()) === 'utf-8') {
717
-        $default['ellipsis'] = "";
718
-    }
719
-    $options += $default;
720
-
721
-    $prefix = '';
722
-    $suffix = $options['ellipsis'];
723
-
724
-    if ($options['html']) {
725
-        $ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options);
726
-
727
-        $truncateLength = 0;
728
-        $totalLength = 0;
729
-        $openTags = array();
730
-        $truncate = '';
731
-
732
-        preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
733
-        foreach ($tags as $tag) {
734
-            $contentLength = geodir_strlen($tag[3], $options);
735
-
736
-            if ($truncate === '') {
737
-                if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) {
738
-                    if (preg_match('/<[\w]+[^>]*>/', $tag[0])) {
739
-                        array_unshift($openTags, $tag[2]);
740
-                    } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) {
741
-                        $pos = array_search($closeTag[1], $openTags);
742
-                        if ($pos !== false) {
743
-                            array_splice($openTags, $pos, 1);
744
-                        }
745
-                    }
746
-                }
747
-
748
-                $prefix .= $tag[1];
749
-
750
-                if ($totalLength + $contentLength + $ellipsisLength > $length) {
751
-                    $truncate = $tag[3];
752
-                    $truncateLength = $length - $totalLength;
753
-                } else {
754
-                    $prefix .= $tag[3];
755
-                }
756
-            }
757
-
758
-            $totalLength += $contentLength;
759
-            if ($totalLength > $length) {
760
-                break;
761
-            }
762
-        }
763
-
764
-        if ($totalLength <= $length) {
765
-            return $text;
766
-        }
767
-
768
-        $text = $truncate;
769
-        $length = $truncateLength;
770
-
771
-        foreach ($openTags as $tag) {
772
-            $suffix .= '</' . $tag . '>';
773
-        }
774
-    } else {
775
-        if (geodir_strlen($text, $options) <= $length) {
776
-            return $text;
777
-        }
778
-        $ellipsisLength = geodir_strlen($options['ellipsis'], $options);
779
-    }
780
-
781
-    $result = geodir_substr($text, 0, $length - $ellipsisLength, $options);
782
-
783
-    if (!$options['exact']) {
784
-        if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') {
785
-            $result = geodir_remove_last_word($result);
786
-        }
787
-
788
-        // Do not need to count ellipsis in the cut, if result is empty.
789
-        if (!strlen($result)) {
790
-            $result = geodir_substr($text, 0, $length, $options);
791
-        }
792
-    }
793
-
794
-    return $prefix . $result . $suffix;
716
+	if (!empty($options['html']) && function_exists('mb_internal_encoding') && strtolower(mb_internal_encoding()) === 'utf-8') {
717
+		$default['ellipsis'] = "";
718
+	}
719
+	$options += $default;
720
+
721
+	$prefix = '';
722
+	$suffix = $options['ellipsis'];
723
+
724
+	if ($options['html']) {
725
+		$ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options);
726
+
727
+		$truncateLength = 0;
728
+		$totalLength = 0;
729
+		$openTags = array();
730
+		$truncate = '';
731
+
732
+		preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
733
+		foreach ($tags as $tag) {
734
+			$contentLength = geodir_strlen($tag[3], $options);
735
+
736
+			if ($truncate === '') {
737
+				if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) {
738
+					if (preg_match('/<[\w]+[^>]*>/', $tag[0])) {
739
+						array_unshift($openTags, $tag[2]);
740
+					} elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) {
741
+						$pos = array_search($closeTag[1], $openTags);
742
+						if ($pos !== false) {
743
+							array_splice($openTags, $pos, 1);
744
+						}
745
+					}
746
+				}
747
+
748
+				$prefix .= $tag[1];
749
+
750
+				if ($totalLength + $contentLength + $ellipsisLength > $length) {
751
+					$truncate = $tag[3];
752
+					$truncateLength = $length - $totalLength;
753
+				} else {
754
+					$prefix .= $tag[3];
755
+				}
756
+			}
757
+
758
+			$totalLength += $contentLength;
759
+			if ($totalLength > $length) {
760
+				break;
761
+			}
762
+		}
763
+
764
+		if ($totalLength <= $length) {
765
+			return $text;
766
+		}
767
+
768
+		$text = $truncate;
769
+		$length = $truncateLength;
770
+
771
+		foreach ($openTags as $tag) {
772
+			$suffix .= '</' . $tag . '>';
773
+		}
774
+	} else {
775
+		if (geodir_strlen($text, $options) <= $length) {
776
+			return $text;
777
+		}
778
+		$ellipsisLength = geodir_strlen($options['ellipsis'], $options);
779
+	}
780
+
781
+	$result = geodir_substr($text, 0, $length - $ellipsisLength, $options);
782
+
783
+	if (!$options['exact']) {
784
+		if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') {
785
+			$result = geodir_remove_last_word($result);
786
+		}
787
+
788
+		// Do not need to count ellipsis in the cut, if result is empty.
789
+		if (!strlen($result)) {
790
+			$result = geodir_substr($text, 0, $length, $options);
791
+		}
792
+	}
793
+
794
+	return $prefix . $result . $suffix;
795 795
 }
796 796
 
797 797
 /**
@@ -815,28 +815,28 @@  discard block
 block discarded – undo
815 815
  * @return int
816 816
  */
817 817
 function geodir_strlen($text, array $options) {
818
-    if (empty($options['trimWidth'])) {
819
-        $strlen = 'geodir_utf8_strlen';
820
-    } else {
821
-        $strlen = 'geodir_utf8_strwidth';
822
-    }
823
-
824
-    if (empty($options['html'])) {
825
-        return $strlen($text);
826
-    }
827
-
828
-    $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
829
-    $replace = preg_replace_callback(
830
-        $pattern,
831
-        function ($match) use ($strlen) {
832
-            $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');
833
-
834
-            return str_repeat(' ', $strlen($utf8, 'UTF-8'));
835
-        },
836
-        $text
837
-    );
838
-
839
-    return $strlen($replace);
818
+	if (empty($options['trimWidth'])) {
819
+		$strlen = 'geodir_utf8_strlen';
820
+	} else {
821
+		$strlen = 'geodir_utf8_strwidth';
822
+	}
823
+
824
+	if (empty($options['html'])) {
825
+		return $strlen($text);
826
+	}
827
+
828
+	$pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
829
+	$replace = preg_replace_callback(
830
+		$pattern,
831
+		function ($match) use ($strlen) {
832
+			$utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');
833
+
834
+			return str_repeat(' ', $strlen($utf8, 'UTF-8'));
835
+		},
836
+		$text
837
+	);
838
+
839
+	return $strlen($replace);
840 840
 }
841 841
 
842 842
 /**
@@ -857,80 +857,80 @@  discard block
 block discarded – undo
857 857
  * @return string
858 858
  */
859 859
 function geodir_substr($text, $start, $length, array $options) {
860
-    if (empty($options['trimWidth'])) {
861
-        $substr = 'geodir_utf8_substr';
862
-    } else {
863
-        $substr = 'geodir_utf8_strimwidth';
864
-    }
865
-
866
-    $maxPosition = geodir_strlen($text, array('trimWidth' => false) + $options);
867
-    if ($start < 0) {
868
-        $start += $maxPosition;
869
-        if ($start < 0) {
870
-            $start = 0;
871
-        }
872
-    }
873
-    if ($start >= $maxPosition) {
874
-        return '';
875
-    }
876
-
877
-    if ($length === null) {
878
-        $length = geodir_strlen($text, $options);
879
-    }
880
-
881
-    if ($length < 0) {
882
-        $text = geodir_substr($text, $start, null, $options);
883
-        $start = 0;
884
-        $length += geodir_strlen($text, $options);
885
-    }
886
-
887
-    if ($length <= 0) {
888
-        return '';
889
-    }
890
-
891
-    if (empty($options['html'])) {
892
-        return (string)$substr($text, $start, $length);
893
-    }
894
-
895
-    $totalOffset = 0;
896
-    $totalLength = 0;
897
-    $result = '';
898
-
899
-    $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i';
900
-    $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
901
-    foreach ($parts as $part) {
902
-        $offset = 0;
903
-
904
-        if ($totalOffset < $start) {
905
-            $len = geodir_strlen($part, array('trimWidth' => false) + $options);
906
-            if ($totalOffset + $len <= $start) {
907
-                $totalOffset += $len;
908
-                continue;
909
-            }
910
-
911
-            $offset = $start - $totalOffset;
912
-            $totalOffset = $start;
913
-        }
914
-
915
-        $len = geodir_strlen($part, $options);
916
-        if ($offset !== 0 || $totalLength + $len > $length) {
917
-            if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) {
918
-                // Entities cannot be passed substr.
919
-                continue;
920
-            }
921
-
922
-            $part = $substr($part, $offset, $length - $totalLength);
923
-            $len = geodir_strlen($part, $options);
924
-        }
925
-
926
-        $result .= $part;
927
-        $totalLength += $len;
928
-        if ($totalLength >= $length) {
929
-            break;
930
-        }
931
-    }
932
-
933
-    return $result;
860
+	if (empty($options['trimWidth'])) {
861
+		$substr = 'geodir_utf8_substr';
862
+	} else {
863
+		$substr = 'geodir_utf8_strimwidth';
864
+	}
865
+
866
+	$maxPosition = geodir_strlen($text, array('trimWidth' => false) + $options);
867
+	if ($start < 0) {
868
+		$start += $maxPosition;
869
+		if ($start < 0) {
870
+			$start = 0;
871
+		}
872
+	}
873
+	if ($start >= $maxPosition) {
874
+		return '';
875
+	}
876
+
877
+	if ($length === null) {
878
+		$length = geodir_strlen($text, $options);
879
+	}
880
+
881
+	if ($length < 0) {
882
+		$text = geodir_substr($text, $start, null, $options);
883
+		$start = 0;
884
+		$length += geodir_strlen($text, $options);
885
+	}
886
+
887
+	if ($length <= 0) {
888
+		return '';
889
+	}
890
+
891
+	if (empty($options['html'])) {
892
+		return (string)$substr($text, $start, $length);
893
+	}
894
+
895
+	$totalOffset = 0;
896
+	$totalLength = 0;
897
+	$result = '';
898
+
899
+	$pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i';
900
+	$parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
901
+	foreach ($parts as $part) {
902
+		$offset = 0;
903
+
904
+		if ($totalOffset < $start) {
905
+			$len = geodir_strlen($part, array('trimWidth' => false) + $options);
906
+			if ($totalOffset + $len <= $start) {
907
+				$totalOffset += $len;
908
+				continue;
909
+			}
910
+
911
+			$offset = $start - $totalOffset;
912
+			$totalOffset = $start;
913
+		}
914
+
915
+		$len = geodir_strlen($part, $options);
916
+		if ($offset !== 0 || $totalLength + $len > $length) {
917
+			if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) {
918
+				// Entities cannot be passed substr.
919
+				continue;
920
+			}
921
+
922
+			$part = $substr($part, $offset, $length - $totalLength);
923
+			$len = geodir_strlen($part, $options);
924
+		}
925
+
926
+		$result .= $part;
927
+		$totalLength += $len;
928
+		if ($totalLength >= $length) {
929
+			break;
930
+		}
931
+	}
932
+
933
+	return $result;
934 934
 }
935 935
 
936 936
 /**
@@ -943,21 +943,21 @@  discard block
 block discarded – undo
943 943
  * @return string
944 944
  */
945 945
 function geodir_remove_last_word($text) {
946
-    $spacepos = geodir_utf8_strrpos($text, ' ');
946
+	$spacepos = geodir_utf8_strrpos($text, ' ');
947 947
 
948
-    if ($spacepos !== false) {
949
-        $lastWord = geodir_utf8_strrpos($text, $spacepos);
948
+	if ($spacepos !== false) {
949
+		$lastWord = geodir_utf8_strrpos($text, $spacepos);
950 950
 
951
-        // Some languages are written without word separation.
952
-        // We recognize a string as a word if it does not contain any full-width characters.
953
-        if (geodir_utf8_strwidth($lastWord) === geodir_utf8_strlen($lastWord)) {
954
-            $text = geodir_utf8_substr($text, 0, $spacepos);
955
-        }
951
+		// Some languages are written without word separation.
952
+		// We recognize a string as a word if it does not contain any full-width characters.
953
+		if (geodir_utf8_strwidth($lastWord) === geodir_utf8_strlen($lastWord)) {
954
+			$text = geodir_utf8_substr($text, 0, $spacepos);
955
+		}
956 956
 
957
-        return $text;
958
-    }
957
+		return $text;
958
+	}
959 959
 
960
-    return '';
960
+	return '';
961 961
 }
962 962
 
963 963
 function geodir_tool_restore_cpt_from_taxonomies(){
@@ -1075,11 +1075,11 @@  discard block
 block discarded – undo
1075 1075
  * @return string
1076 1076
  */
1077 1077
 function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
1078
-    if ( function_exists( 'mb_strimwidth' ) ) {
1079
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
1080
-    }
1078
+	if ( function_exists( 'mb_strimwidth' ) ) {
1079
+		return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
1080
+	}
1081 1081
     
1082
-    return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
1082
+	return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1093,11 +1093,11 @@  discard block
 block discarded – undo
1093 1093
  * @return int Returns the number of characters in string.
1094 1094
  */
1095 1095
 function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) {
1096
-    if ( function_exists( 'mb_strlen' ) ) {
1097
-        return mb_strlen( $str, $encoding );
1098
-    }
1096
+	if ( function_exists( 'mb_strlen' ) ) {
1097
+		return mb_strlen( $str, $encoding );
1098
+	}
1099 1099
         
1100
-    return strlen( $str );
1100
+	return strlen( $str );
1101 1101
 }
1102 1102
 
1103 1103
 /**
@@ -1113,11 +1113,11 @@  discard block
 block discarded – undo
1113 1113
  * @return int Returns the position of the first occurrence of search in the string.
1114 1114
  */
1115 1115
 function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1116
-    if ( function_exists( 'mb_strpos' ) ) {
1117
-        return mb_strpos( $str, $find, $offset, $encoding );
1118
-    }
1116
+	if ( function_exists( 'mb_strpos' ) ) {
1117
+		return mb_strpos( $str, $find, $offset, $encoding );
1118
+	}
1119 1119
         
1120
-    return strpos( $str, $find, $offset );
1120
+	return strpos( $str, $find, $offset );
1121 1121
 }
1122 1122
 
1123 1123
 /**
@@ -1133,11 +1133,11 @@  discard block
 block discarded – undo
1133 1133
  * @return int Returns the position of the last occurrence of search.
1134 1134
  */
1135 1135
 function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1136
-    if ( function_exists( 'mb_strrpos' ) ) {
1137
-        return mb_strrpos( $str, $find, $offset, $encoding );
1138
-    }
1136
+	if ( function_exists( 'mb_strrpos' ) ) {
1137
+		return mb_strrpos( $str, $find, $offset, $encoding );
1138
+	}
1139 1139
         
1140
-    return strrpos( $str, $find, $offset );
1140
+	return strrpos( $str, $find, $offset );
1141 1141
 }
1142 1142
 
1143 1143
 /**
@@ -1154,15 +1154,15 @@  discard block
 block discarded – undo
1154 1154
  * @return string
1155 1155
  */
1156 1156
 function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
1157
-    if ( function_exists( 'mb_substr' ) ) {
1158
-        if ( $length === null ) {
1159
-            return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
1160
-        } else {
1161
-            return mb_substr( $str, $start, $length, $encoding );
1162
-        }
1163
-    }
1157
+	if ( function_exists( 'mb_substr' ) ) {
1158
+		if ( $length === null ) {
1159
+			return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
1160
+		} else {
1161
+			return mb_substr( $str, $start, $length, $encoding );
1162
+		}
1163
+	}
1164 1164
         
1165
-    return substr( $str, $start, $length );
1165
+	return substr( $str, $start, $length );
1166 1166
 }
1167 1167
 
1168 1168
 /**
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
  * @since 1.4.6
14 14
  * @return int|null Return the page ID if present or null if not.
15 15
  */
16
-function geodir_add_listing_page_id(){
16
+function geodir_add_listing_page_id() {
17 17
     $gd_page_id = get_option('geodir_add_listing_page');
18 18
 
19 19
     if (function_exists('icl_object_id')) {
20
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
20
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
21 21
     }
22 22
 
23 23
     return $gd_page_id;
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
  * @since 1.4.6
31 31
  * @return int|null Return the page ID if present or null if not.
32 32
  */
33
-function geodir_preview_page_id(){
33
+function geodir_preview_page_id() {
34 34
     $gd_page_id = get_option('geodir_preview_page');
35 35
 
36 36
     if (function_exists('icl_object_id')) {
37
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
37
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
38 38
     }
39 39
 
40 40
     return $gd_page_id;
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
  * @since 1.4.6
48 48
  * @return int|null Return the page ID if present or null if not.
49 49
  */
50
-function geodir_success_page_id(){
50
+function geodir_success_page_id() {
51 51
     $gd_page_id = get_option('geodir_success_page');
52 52
 
53 53
     if (function_exists('icl_object_id')) {
54
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
54
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
55 55
     }
56 56
 
57 57
     return $gd_page_id;
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
  * @since 1.4.6
65 65
  * @return int|null Return the page ID if present or null if not.
66 66
  */
67
-function geodir_location_page_id(){
67
+function geodir_location_page_id() {
68 68
     $gd_page_id = get_option('geodir_location_page');
69 69
 
70 70
     if (function_exists('icl_object_id')) {
71
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
71
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
72 72
     }
73 73
 
74 74
     return $gd_page_id;
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
  * @since 1.5.4
82 82
  * @return int|null Return the page ID if present or null if not.
83 83
  */
84
-function geodir_home_page_id(){
84
+function geodir_home_page_id() {
85 85
     $gd_page_id = get_option('geodir_home_page');
86 86
 
87 87
     if (function_exists('icl_object_id')) {
88
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
88
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
89 89
     }
90 90
 
91 91
     return $gd_page_id;
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
  * @since 1.5.3
99 99
  * @return int|null Return the page ID if present or null if not.
100 100
  */
101
-function geodir_info_page_id(){
101
+function geodir_info_page_id() {
102 102
     $gd_page_id = get_option('geodir_info_page');
103 103
 
104 104
     if (function_exists('icl_object_id')) {
105
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
105
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
106 106
     }
107 107
 
108 108
     return $gd_page_id;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
  * @since 1.5.3
116 116
  * @return int|null Return the page ID if present or null if not.
117 117
  */
118
-function geodir_login_page_id(){
118
+function geodir_login_page_id() {
119 119
     $gd_page_id = get_option('geodir_login_page');
120 120
 
121 121
     if (function_exists('icl_object_id')) {
122
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
122
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
123 123
     }
124 124
 
125 125
     return $gd_page_id;
@@ -133,20 +133,20 @@  discard block
 block discarded – undo
133 133
  * @since 1.5.3
134 134
  * @return int|null Return the page ID if present or null if not.
135 135
  */
136
-function geodir_login_url($args=array()){
136
+function geodir_login_url($args = array()) {
137 137
     $gd_page_id = get_option('geodir_login_page');
138 138
 
139 139
     if (function_exists('icl_object_id')) {
140
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
140
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
141 141
     }
142 142
 
143 143
     if (function_exists('geodir_location_geo_home_link')) {
144 144
         remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
145 145
     }
146 146
 
147
-    if (geodir_is_wpml()){
147
+    if (geodir_is_wpml()) {
148 148
         $home_url = icl_get_home_url();
149
-    }else{
149
+    } else {
150 150
         $home_url = home_url();
151 151
     }
152 152
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
155 155
     }
156 156
 
157
-    if($gd_page_id){
157
+    if ($gd_page_id) {
158 158
         $post = get_post($gd_page_id);
159 159
         $slug = $post->post_name;
160 160
         //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161 161
         $login_url = trailingslashit($home_url)."$slug/";
162
-    }else{
162
+    } else {
163 163
         $login_url = trailingslashit($home_url)."?geodir_signup=true";
164 164
     }
165 165
 
166
-    if($args){
167
-        $login_url = add_query_arg($args,$login_url );
166
+    if ($args) {
167
+        $login_url = add_query_arg($args, $login_url);
168 168
     }
169 169
 
170 170
     /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @param array $args The array of query args used.
179 179
      * @param int $gd_page_id The page id of the GD login page.
180 180
      */
181
-	    return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id);
181
+	    return apply_filters('geodir_login_url', $login_url, $args, $gd_page_id);
182 182
 }
183 183
 
184 184
 /**
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
  * @since 1.5.16 Added WPML lang code to url.
190 190
  * @return string Info page url.
191 191
  */
192
-function geodir_info_url($args=array()){
192
+function geodir_info_url($args = array()) {
193 193
     $gd_page_id = get_option('geodir_info_page');
194 194
 
195 195
     if (function_exists('icl_object_id')) {
196
-        $gd_page_id =  icl_object_id($gd_page_id, 'page', true);
196
+        $gd_page_id = icl_object_id($gd_page_id, 'page', true);
197 197
     }
198 198
 
199 199
     if (function_exists('geodir_location_geo_home_link')) {
200 200
         remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
201 201
     }
202 202
 
203
-    if (geodir_is_wpml()){
203
+    if (geodir_is_wpml()) {
204 204
         $home_url = icl_get_home_url();
205
-    }else{
205
+    } else {
206 206
         $home_url = home_url();
207 207
     }
208 208
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
211 211
     }
212 212
 
213
-    if($gd_page_id){
213
+    if ($gd_page_id) {
214 214
         $post = get_post($gd_page_id);
215 215
         $slug = $post->post_name;
216 216
         //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217 217
         $info_url = trailingslashit($home_url)."$slug/";
218
-    }else{
218
+    } else {
219 219
         $info_url = trailingslashit($home_url);
220 220
     }
221 221
 
222
-    if($args){
223
-        $info_url = add_query_arg($args,$info_url );
222
+    if ($args) {
223
+        $info_url = add_query_arg($args, $info_url);
224 224
     }
225 225
 
226 226
     return $info_url;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  * @param string $charset Character set to use for conversion.
239 239
  * @return string Returns converted string.
240 240
  */
241
-function geodir_ucwords($string, $charset='UTF-8') {
241
+function geodir_ucwords($string, $charset = 'UTF-8') {
242 242
     if (function_exists('mb_convert_case')) {
243 243
         return mb_convert_case($string, MB_CASE_TITLE, $charset);
244 244
     } else {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
  * @param string $charset Character set to use for conversion.
259 259
  * @return string Returns converted string.
260 260
  */
261
-function geodir_strtolower($string, $charset='UTF-8') {
261
+function geodir_strtolower($string, $charset = 'UTF-8') {
262 262
     if (function_exists('mb_convert_case')) {
263 263
         return mb_convert_case($string, MB_CASE_LOWER, $charset);
264 264
     } else {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
  * @param string $charset Character set to use for conversion.
279 279
  * @return string Returns converted string.
280 280
  */
281
-function geodir_strtoupper($string, $charset='UTF-8') {
281
+function geodir_strtoupper($string, $charset = 'UTF-8') {
282 282
     if (function_exists('mb_convert_case')) {
283 283
         return mb_convert_case($string, MB_CASE_UPPER, $charset);
284 284
     } else {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	
310 310
 	$url = trim($parts[0]);
311 311
 	if ($formatted && $url != '') {
312
-		$url = str_replace( ' ', '%20', $url );
312
+		$url = str_replace(' ', '%20', $url);
313 313
 		$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);
314 314
 		
315 315
 		if (0 !== stripos($url, 'mailto:')) {
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 		
320 320
 		$url = str_replace(';//', '://', $url);
321 321
 		
322
-		if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) {
323
-			$url = 'http://' . $url;
322
+		if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) {
323
+			$url = 'http://'.$url;
324 324
 		}
325 325
 		
326 326
 		$url = wp_kses_normalize_entities($url);
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
  * @package GeoDirectory
463 463
  */
464 464
 function _gd_die_handler() {
465
-    if ( defined( 'GD_TESTING_MODE' ) ) {
465
+    if (defined('GD_TESTING_MODE')) {
466 466
         return '_gd_die_handler';
467 467
     } else {
468 468
         die();
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
  * @param string $title   Optional. Error title.
481 481
  * @param int $status     Optional. Status code.
482 482
  */
483
-function gd_die( $message = '', $title = '', $status = 400 ) {
484
-    add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 );
485
-    add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 );
486
-    wp_die( $message, $title, array( 'response' => $status ));
483
+function gd_die($message = '', $title = '', $status = 400) {
484
+    add_filter('wp_die_ajax_handler', '_gd_die_handler', 10, 3);
485
+    add_filter('wp_die_handler', '_gd_die_handler', 10, 3);
486
+    wp_die($message, $title, array('response' => $status));
487 487
 }
488 488
 
489 489
 /*
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
  * @param string $php_format The PHP date format.
494 494
  * @return string The jQuery format date string.
495 495
  */
496
-function geodir_date_format_php_to_jqueryui( $php_format ) {
496
+function geodir_date_format_php_to_jqueryui($php_format) {
497 497
 	$symbols = array(
498 498
 		// Day
499 499
 		'd' => 'dd',
@@ -533,27 +533,27 @@  discard block
 block discarded – undo
533 533
 	$jqueryui_format = "";
534 534
 	$escaping = false;
535 535
 
536
-	for ( $i = 0; $i < strlen( $php_format ); $i++ ) {
536
+	for ($i = 0; $i < strlen($php_format); $i++) {
537 537
 		$char = $php_format[$i];
538 538
 
539 539
 		// PHP date format escaping character
540
-		if ( $char === '\\' ) {
540
+		if ($char === '\\') {
541 541
 			$i++;
542 542
 
543
-			if ( $escaping ) {
543
+			if ($escaping) {
544 544
 				$jqueryui_format .= $php_format[$i];
545 545
 			} else {
546
-				$jqueryui_format .= '\'' . $php_format[$i];
546
+				$jqueryui_format .= '\''.$php_format[$i];
547 547
 			}
548 548
 
549 549
 			$escaping = true;
550 550
 		} else {
551
-			if ( $escaping ) {
551
+			if ($escaping) {
552 552
 				$jqueryui_format .= "'";
553 553
 				$escaping = false;
554 554
 			}
555 555
 
556
-			if ( isset( $symbols[$char] ) ) {
556
+			if (isset($symbols[$char])) {
557 557
 				$jqueryui_format .= $symbols[$char];
558 558
 			} else {
559 559
 				$jqueryui_format .= $char;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
  * @return string The untranslated date string.
573 573
  * @since 1.6.5
574 574
  */
575
-function geodir_maybe_untranslate_date($date){
575
+function geodir_maybe_untranslate_date($date) {
576 576
 	$english_long_months = array(
577 577
 		'January',
578 578
 		'February',
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 		'December',
589 589
 	);
590 590
 
591
-	$non_english_long_months  = array(
591
+	$non_english_long_months = array(
592 592
 		__('January'),
593 593
 		__('February'),
594 594
 		__('March'),
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		__('November'),
603 603
 		__('December'),
604 604
 	);
605
-	$date = str_replace($non_english_long_months,$english_long_months,$date);
605
+	$date = str_replace($non_english_long_months, $english_long_months, $date);
606 606
 
607 607
 
608 608
 	$english_short_months = array(
@@ -621,21 +621,21 @@  discard block
 block discarded – undo
621 621
 	);
622 622
 
623 623
 	$non_english_short_months = array(
624
-		' '._x( 'Jan', 'January abbreviation' ).' ',
625
-		' '._x( 'Feb', 'February abbreviation' ).' ',
626
-		' '._x( 'Mar', 'March abbreviation' ).' ',
627
-		' '._x( 'Apr', 'April abbreviation' ).' ',
628
-		' '._x( 'May', 'May abbreviation' ).' ',
629
-		' '._x( 'Jun', 'June abbreviation' ).' ',
630
-		' '._x( 'Jul', 'July abbreviation' ).' ',
631
-		' '._x( 'Aug', 'August abbreviation' ).' ',
632
-		' '._x( 'Sep', 'September abbreviation' ).' ',
633
-		' '._x( 'Oct', 'October abbreviation' ).' ',
634
-		' '._x( 'Nov', 'November abbreviation' ).' ',
635
-		' '._x( 'Dec', 'December abbreviation' ).' ',
624
+		' '._x('Jan', 'January abbreviation').' ',
625
+		' '._x('Feb', 'February abbreviation').' ',
626
+		' '._x('Mar', 'March abbreviation').' ',
627
+		' '._x('Apr', 'April abbreviation').' ',
628
+		' '._x('May', 'May abbreviation').' ',
629
+		' '._x('Jun', 'June abbreviation').' ',
630
+		' '._x('Jul', 'July abbreviation').' ',
631
+		' '._x('Aug', 'August abbreviation').' ',
632
+		' '._x('Sep', 'September abbreviation').' ',
633
+		' '._x('Oct', 'October abbreviation').' ',
634
+		' '._x('Nov', 'November abbreviation').' ',
635
+		' '._x('Dec', 'December abbreviation').' ',
636 636
 	);
637 637
 
638
-	$date = str_replace($non_english_short_months,$english_short_months,$date);
638
+	$date = str_replace($non_english_short_months, $english_short_months, $date);
639 639
 
640 640
 
641 641
 	return $date;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
  * @return string Trimmed string.
708 708
  */
709 709
 function geodir_excerpt($text, $length = 100, $options = array()) {
710
-    if (!(int)$length > 0) {
710
+    if (!(int) $length > 0) {
711 711
         return $text;
712 712
     }
713 713
     $default = array(
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $length = $truncateLength;
770 770
 
771 771
         foreach ($openTags as $tag) {
772
-            $suffix .= '</' . $tag . '>';
772
+            $suffix .= '</'.$tag.'>';
773 773
         }
774 774
     } else {
775 775
         if (geodir_strlen($text, $options) <= $length) {
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
         }
792 792
     }
793 793
 
794
-    return $prefix . $result . $suffix;
794
+    return $prefix.$result.$suffix;
795 795
 }
796 796
 
797 797
 /**
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
     $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
829 829
     $replace = preg_replace_callback(
830 830
         $pattern,
831
-        function ($match) use ($strlen) {
831
+        function($match) use ($strlen) {
832 832
             $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');
833 833
 
834 834
             return str_repeat(' ', $strlen($utf8, 'UTF-8'));
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
     }
890 890
 
891 891
     if (empty($options['html'])) {
892
-        return (string)$substr($text, $start, $length);
892
+        return (string) $substr($text, $start, $length);
893 893
     }
894 894
 
895 895
     $totalOffset = 0;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 
915 915
         $len = geodir_strlen($part, $options);
916 916
         if ($offset !== 0 || $totalLength + $len > $length) {
917
-            if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) {
917
+            if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8')) {
918 918
                 // Entities cannot be passed substr.
919 919
                 continue;
920 920
             }
@@ -960,39 +960,39 @@  discard block
 block discarded – undo
960 960
     return '';
961 961
 }
962 962
 
963
-function geodir_tool_restore_cpt_from_taxonomies(){
963
+function geodir_tool_restore_cpt_from_taxonomies() {
964 964
 
965 965
 	$cpts = get_option('geodir_post_types');
966 966
 
967
-	if(!empty($cpts)){return;}
967
+	if (!empty($cpts)) {return; }
968 968
 
969 969
 	$taxonomies = get_option('geodir_taxonomies');
970 970
 
971
-	if(empty($taxonomies)){return;}
971
+	if (empty($taxonomies)) {return; }
972 972
 
973 973
 	$cpts = array();
974 974
 
975
-	foreach($taxonomies as $key => $val){
975
+	foreach ($taxonomies as $key => $val) {
976 976
 
977
-		if(strpos($val['listing_slug'], '/') === false) {
978
-			$cpts[$val['object_type']] = array('cpt'=>$val['object_type'],'slug'=>$val['listing_slug']);
977
+		if (strpos($val['listing_slug'], '/') === false) {
978
+			$cpts[$val['object_type']] = array('cpt'=>$val['object_type'], 'slug'=>$val['listing_slug']);
979 979
 		}
980 980
 
981 981
 	}
982 982
 
983
-	if(empty($cpts)){return;}
983
+	if (empty($cpts)) {return; }
984 984
 
985 985
 
986 986
 	$cpts_restore = $cpts;
987 987
 
988
-	foreach($cpts as $cpt){
988
+	foreach ($cpts as $cpt) {
989 989
 
990 990
 
991
-		$is_custom = $cpt['cpt']=='gd_place' ? 0 : 1;
991
+		$is_custom = $cpt['cpt'] == 'gd_place' ? 0 : 1;
992 992
 
993
-		$cpts_restore[$cpt['cpt']] = array (
993
+		$cpts_restore[$cpt['cpt']] = array(
994 994
 				'labels' =>
995
-					array (
995
+					array(
996 996
 						'name' => $cpt['slug'],
997 997
 						'singular_name' => $cpt['slug'],
998 998
 						'add_new' => 'Add New',
@@ -1020,14 +1020,14 @@  discard block
 block discarded – undo
1020 1020
 				'public' => true,
1021 1021
 				'query_var' => true,
1022 1022
 				'rewrite' =>
1023
-					array (
1023
+					array(
1024 1024
 						'slug' => $cpt['slug'],
1025 1025
 						'with_front' => false,
1026 1026
 						'hierarchical' => true,
1027 1027
 						'feeds' => true,
1028 1028
 					),
1029 1029
 				'supports' =>
1030
-					array (
1030
+					array(
1031 1031
 						0 => 'title',
1032 1032
 						1 => 'editor',
1033 1033
 						2 => 'author',
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
 						6 => 'comments',
1038 1038
 					),
1039 1039
 				'taxonomies' =>
1040
-					array (
1040
+					array(
1041 1041
 						0 => $cpt['cpt'].'category',
1042 1042
 						1 => $cpt['cpt'].'_tags',
1043 1043
 					),
1044 1044
 				'is_custom' => $is_custom,
1045 1045
 				'listing_order' => '1',
1046 1046
 				'seo' =>
1047
-					array (
1047
+					array(
1048 1048
 						'meta_keyword' => '',
1049 1049
 						'meta_description' => '',
1050 1050
 					),
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 	}
1057 1057
 
1058 1058
 
1059
-	update_option('geodir_post_types',$cpts_restore);
1059
+	update_option('geodir_post_types', $cpts_restore);
1060 1060
 
1061 1061
 }
1062 1062
 
@@ -1074,12 +1074,12 @@  discard block
 block discarded – undo
1074 1074
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1075 1075
  * @return string
1076 1076
  */
1077
-function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
1078
-    if ( function_exists( 'mb_strimwidth' ) ) {
1079
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
1077
+function geodir_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
1078
+    if (function_exists('mb_strimwidth')) {
1079
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
1080 1080
     }
1081 1081
     
1082
-    return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
1082
+    return geodir_utf8_substr($str, $start, $width, $encoding).$trimmaker;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1092,12 +1092,12 @@  discard block
 block discarded – undo
1092 1092
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1093 1093
  * @return int Returns the number of characters in string.
1094 1094
  */
1095
-function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) {
1096
-    if ( function_exists( 'mb_strlen' ) ) {
1097
-        return mb_strlen( $str, $encoding );
1095
+function geodir_utf8_strlen($str, $encoding = 'UTF-8') {
1096
+    if (function_exists('mb_strlen')) {
1097
+        return mb_strlen($str, $encoding);
1098 1098
     }
1099 1099
         
1100
-    return strlen( $str );
1100
+    return strlen($str);
1101 1101
 }
1102 1102
 
1103 1103
 /**
@@ -1112,12 +1112,12 @@  discard block
 block discarded – undo
1112 1112
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1113 1113
  * @return int Returns the position of the first occurrence of search in the string.
1114 1114
  */
1115
-function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1116
-    if ( function_exists( 'mb_strpos' ) ) {
1117
-        return mb_strpos( $str, $find, $offset, $encoding );
1115
+function geodir_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
1116
+    if (function_exists('mb_strpos')) {
1117
+        return mb_strpos($str, $find, $offset, $encoding);
1118 1118
     }
1119 1119
         
1120
-    return strpos( $str, $find, $offset );
1120
+    return strpos($str, $find, $offset);
1121 1121
 }
1122 1122
 
1123 1123
 /**
@@ -1132,12 +1132,12 @@  discard block
 block discarded – undo
1132 1132
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1133 1133
  * @return int Returns the position of the last occurrence of search.
1134 1134
  */
1135
-function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1136
-    if ( function_exists( 'mb_strrpos' ) ) {
1137
-        return mb_strrpos( $str, $find, $offset, $encoding );
1135
+function geodir_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
1136
+    if (function_exists('mb_strrpos')) {
1137
+        return mb_strrpos($str, $find, $offset, $encoding);
1138 1138
     }
1139 1139
         
1140
-    return strrpos( $str, $find, $offset );
1140
+    return strrpos($str, $find, $offset);
1141 1141
 }
1142 1142
 
1143 1143
 /**
@@ -1153,16 +1153,16 @@  discard block
 block discarded – undo
1153 1153
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1154 1154
  * @return string
1155 1155
  */
1156
-function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
1157
-    if ( function_exists( 'mb_substr' ) ) {
1158
-        if ( $length === null ) {
1159
-            return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
1156
+function geodir_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
1157
+    if (function_exists('mb_substr')) {
1158
+        if ($length === null) {
1159
+            return mb_substr($str, $start, geodir_utf8_strlen($str, $encoding), $encoding);
1160 1160
         } else {
1161
-            return mb_substr( $str, $start, $length, $encoding );
1161
+            return mb_substr($str, $start, $length, $encoding);
1162 1162
         }
1163 1163
     }
1164 1164
         
1165
-    return substr( $str, $start, $length );
1165
+    return substr($str, $start, $length);
1166 1166
 }
1167 1167
 
1168 1168
 /**
@@ -1175,12 +1175,12 @@  discard block
 block discarded – undo
1175 1175
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1176 1176
  * @return string The width of string.
1177 1177
  */
1178
-function geodir_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
1179
-	if ( function_exists( 'mb_strwidth' ) ) {
1180
-		return mb_strwidth( $str, $encoding );
1178
+function geodir_utf8_strwidth($str, $encoding = 'UTF-8') {
1179
+	if (function_exists('mb_strwidth')) {
1180
+		return mb_strwidth($str, $encoding);
1181 1181
 	}
1182 1182
 
1183
-	return geodir_utf8_strlen( $str, $encoding );
1183
+	return geodir_utf8_strlen($str, $encoding);
1184 1184
 }
1185 1185
 
1186 1186
 function geodir_total_listings_count($post_type = false)
@@ -1190,13 +1190,13 @@  discard block
 block discarded – undo
1190 1190
 	$count = 0;
1191 1191
 	
1192 1192
 	if ($post_type) {
1193
-		$count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $post_type . "_detail");
1193
+		$count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$post_type."_detail");
1194 1194
 	} else {
1195 1195
 		$all_postypes = geodir_get_posttypes();
1196 1196
 
1197 1197
 		if (!empty($all_postypes)) {
1198 1198
 			foreach ($all_postypes as $key) {
1199
-				$count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $key . "_detail");
1199
+				$count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$key."_detail");
1200 1200
 			}
1201 1201
 		}	
1202 1202
 	}
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 2 patches
Indentation   +1244 added lines, -1244 removed lines patch added patch discarded remove patch
@@ -33,265 +33,265 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_add_nav_menu_items()
35 35
 {
36
-    $items = '';
37
-    // apply filter to add more navigations // -Filter-Location-Manager
38
-
39
-    if (get_option('geodir_show_listing_nav')) {
40
-
41
-        $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
44
-
45
-
46
-        //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
-        $post_types = geodir_get_posttypes('object');
48
-        $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
-        if (!empty($post_types)) {
50
-            foreach ($post_types as $post_type => $args) {
51
-                if (!empty($show_post_type_main_nav)) {
52
-                    if (in_array($post_type, $show_post_type_main_nav)) {
53
-                        if (get_post_type_archive_link($post_type)) {
54
-                            $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
57
-                            /**
58
-                             * Filter the menu li class.
59
-                             *
60
-                             * @since 1.0.0
61
-                             * @param string $menu_class The menu HTML class.
62
-                             */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
-                            /**
65
-                             * Filter the menu a class.
66
-                             *
67
-                             * @since 1.0.0
68
-                             */
69
-                            $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
36
+	$items = '';
37
+	// apply filter to add more navigations // -Filter-Location-Manager
38
+
39
+	if (get_option('geodir_show_listing_nav')) {
40
+
41
+		$menu_class = '';
42
+		if (geodir_is_page('listing'))
43
+			$menu_class = 'current-menu-item';
44
+
45
+
46
+		//SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
+		$post_types = geodir_get_posttypes('object');
48
+		$show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
+		if (!empty($post_types)) {
50
+			foreach ($post_types as $post_type => $args) {
51
+				if (!empty($show_post_type_main_nav)) {
52
+					if (in_array($post_type, $show_post_type_main_nav)) {
53
+						if (get_post_type_archive_link($post_type)) {
54
+							$menu_class = '';
55
+							if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
+								$menu_class = 'current-menu-item';
57
+							/**
58
+							 * Filter the menu li class.
59
+							 *
60
+							 * @since 1.0.0
61
+							 * @param string $menu_class The menu HTML class.
62
+							 */
63
+							$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
+							/**
65
+							 * Filter the menu a class.
66
+							 *
67
+							 * @since 1.0.0
68
+							 */
69
+							$a_class = apply_filters('geodir_menu_a_class', '');
70
+							$items .= '<li class="' . $li_class . '">
71 71
 									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72 72
 										' . __(ucfirst($args->labels->name),'geodirectory') . '
73 73
 									</a>
74 74
 								</li>';
75
-                        }
76
-                    }
77
-                }
78
-            }
79
-        }
80
-        //END LISTING OF POST TYPE IN MAIN NAVIGATION
81
-
82
-        $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
-        $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
-        if ($is_listing_sub_meny_exists) {
85
-            /**
86
-             * Filter the menu li class.
87
-             *
88
-             * @since 1.0.0
89
-             * @param string $menu_class The menu HTML class.
90
-             */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
-            /**
93
-             * Filter the sub menu li class.
94
-             *
95
-             * @since 1.0.0
96
-             * @param string $menu_class The menu HTML class.
97
-             */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
-            /**
100
-             * Filter the sub menu ul class.
101
-             *
102
-             * @since 1.0.0
103
-             */
104
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
-            /**
106
-             * Filter the menu a class.
107
-             *
108
-             * @since 1.0.0
109
-             */
110
-            $a_class = apply_filters('geodir_menu_a_class', '');
111
-            /**
112
-             * Filter the sub menu a class.
113
-             *
114
-             * @since 1.0.0
115
-             */
116
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
75
+						}
76
+					}
77
+				}
78
+			}
79
+		}
80
+		//END LISTING OF POST TYPE IN MAIN NAVIGATION
81
+
82
+		$view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
+		$is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
+		if ($is_listing_sub_meny_exists) {
85
+			/**
86
+			 * Filter the menu li class.
87
+			 *
88
+			 * @since 1.0.0
89
+			 * @param string $menu_class The menu HTML class.
90
+			 */
91
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
+			/**
93
+			 * Filter the sub menu li class.
94
+			 *
95
+			 * @since 1.0.0
96
+			 * @param string $menu_class The menu HTML class.
97
+			 */
98
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
+			/**
100
+			 * Filter the sub menu ul class.
101
+			 *
102
+			 * @since 1.0.0
103
+			 */
104
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
+			/**
106
+			 * Filter the menu a class.
107
+			 *
108
+			 * @since 1.0.0
109
+			 */
110
+			$a_class = apply_filters('geodir_menu_a_class', '');
111
+			/**
112
+			 * Filter the sub menu a class.
113
+			 *
114
+			 * @since 1.0.0
115
+			 */
116
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
+			$items .= '<li class="' . $li_class . '">
118 118
 					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119 119
 					<ul class="' . $sub_ul_class . '">';
120
-            $post_types = geodir_get_posttypes('object');
120
+			$post_types = geodir_get_posttypes('object');
121 121
 
122
-            $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
122
+			$show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
123 123
 
124
-            if (!empty($post_types)) {
125
-                global $geodir_add_location_url;
126
-                $geodir_add_location_url = true;
127
-                foreach ($post_types as $post_type => $args) {
128
-                    if (!empty($show_listing_post_types)) {
129
-                        if (in_array($post_type, $show_listing_post_types)) {
130
-                            if (get_post_type_archive_link($post_type)) {
124
+			if (!empty($post_types)) {
125
+				global $geodir_add_location_url;
126
+				$geodir_add_location_url = true;
127
+				foreach ($post_types as $post_type => $args) {
128
+					if (!empty($show_listing_post_types)) {
129
+						if (in_array($post_type, $show_listing_post_types)) {
130
+							if (get_post_type_archive_link($post_type)) {
131 131
 
132
-                                $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
132
+								$menu_class = '';
133
+								if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
+									$menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
136
+								$items .= '<li class="' . $sub_li_class . '">
137 137
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138 138
 															' . __(ucfirst($args->labels->name),'geodirectory') . '
139 139
 														</a>
140 140
 													</li>';
141
-                            }
142
-                        }
143
-                    }
144
-                }
145
-                $geodir_add_location_url = NULL;
146
-            }
141
+							}
142
+						}
143
+					}
144
+				}
145
+				$geodir_add_location_url = NULL;
146
+			}
147 147
 
148
-            $items .= '	</ul> ';
149
-            /**
150
-             * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
-             *
152
-             * @since 1.5.9
153
-             */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
155
-            $items .= '</li>';
156
-        }
157
-    }
158
-
159
-    if (get_option('geodir_show_addlisting_nav')) {
160
-
161
-        $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
164
-
165
-        //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
-        $post_types = geodir_get_posttypes('object');
167
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
-
170
-        if (!empty($post_types)) {
171
-            foreach ($post_types as $post_type => $args) {
172
-                if (!empty($geodir_allow_posttype_frontend)) {
173
-                    if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
-                        if (!empty($show_add_listing_post_types_main_nav)) {
175
-                            if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
-                                if (geodir_get_addlisting_link($post_type)) {
177
-
178
-                                    $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
181
-                                    /**
182
-                                     * Filter the menu li class.
183
-                                     *
184
-                                     * @since 1.0.0
185
-                                     * @param string $menu_class The menu HTML class.
186
-                                     */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
-                                    /**
189
-                                     * Filter the menu a class.
190
-                                     *
191
-                                     * @since 1.0.0
192
-                                     */
193
-                                    $a_class = apply_filters('geodir_menu_a_class', '');
194
-                                    $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
148
+			$items .= '	</ul> ';
149
+			/**
150
+			 * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
+			 *
152
+			 * @since 1.5.9
153
+			 */
154
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
155
+			$items .= '</li>';
156
+		}
157
+	}
158
+
159
+	if (get_option('geodir_show_addlisting_nav')) {
160
+
161
+		$menu_class = '';
162
+		if (geodir_is_page('add-listing'))
163
+			$menu_class = 'current-menu-item';
164
+
165
+		//SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
+		$post_types = geodir_get_posttypes('object');
167
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
+
170
+		if (!empty($post_types)) {
171
+			foreach ($post_types as $post_type => $args) {
172
+				if (!empty($geodir_allow_posttype_frontend)) {
173
+					if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
+						if (!empty($show_add_listing_post_types_main_nav)) {
175
+							if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
+								if (geodir_get_addlisting_link($post_type)) {
177
+
178
+									$menu_class = '';
179
+									if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
+										$menu_class = 'current-menu-item';
181
+									/**
182
+									 * Filter the menu li class.
183
+									 *
184
+									 * @since 1.0.0
185
+									 * @param string $menu_class The menu HTML class.
186
+									 */
187
+									$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
+									/**
189
+									 * Filter the menu a class.
190
+									 *
191
+									 * @since 1.0.0
192
+									 */
193
+									$a_class = apply_filters('geodir_menu_a_class', '');
194
+									$cpt_name = __($args->labels->singular_name, 'geodirectory');
195
+									$items .= '<li class="' . $li_class . '">
196 196
 											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197 197
 												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
198 198
 											</a>
199 199
 										</li>';
200
-                                }
201
-                            }
202
-                        }
203
-                    }
204
-                }
205
-            }
206
-        }
207
-        //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
-    }
209
-
210
-    $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
-    $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
-    if ($is_add_listing_sub_meny_exists) {
213
-
214
-        if (get_option('geodir_show_addlisting_nav')) {
215
-            /**
216
-             * Filter the menu li class.
217
-             *
218
-             * @since 1.0.0
219
-             * @param string $menu_class The menu HTML class.
220
-             */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
-            /**
223
-             * Filter the sub menu li class.
224
-             *
225
-             * @since 1.0.0
226
-             * @param string $menu_class The menu HTML class.
227
-             */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
-            /**
230
-             * Filter the sub menu ul class.
231
-             *
232
-             * @since 1.0.0
233
-             */
234
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
-            /**
236
-             * Filter the menu a class.
237
-             *
238
-             * @since 1.0.0
239
-             */
240
-            $a_class = apply_filters('geodir_menu_a_class', '');
241
-            /**
242
-             * Filter the sub menu a class.
243
-             *
244
-             * @since 1.0.0
245
-             */
246
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
200
+								}
201
+							}
202
+						}
203
+					}
204
+				}
205
+			}
206
+		}
207
+		//END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
+	}
209
+
210
+	$view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
+	$is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
+	if ($is_add_listing_sub_meny_exists) {
213
+
214
+		if (get_option('geodir_show_addlisting_nav')) {
215
+			/**
216
+			 * Filter the menu li class.
217
+			 *
218
+			 * @since 1.0.0
219
+			 * @param string $menu_class The menu HTML class.
220
+			 */
221
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
+			/**
223
+			 * Filter the sub menu li class.
224
+			 *
225
+			 * @since 1.0.0
226
+			 * @param string $menu_class The menu HTML class.
227
+			 */
228
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
+			/**
230
+			 * Filter the sub menu ul class.
231
+			 *
232
+			 * @since 1.0.0
233
+			 */
234
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
+			/**
236
+			 * Filter the menu a class.
237
+			 *
238
+			 * @since 1.0.0
239
+			 */
240
+			$a_class = apply_filters('geodir_menu_a_class', '');
241
+			/**
242
+			 * Filter the sub menu a class.
243
+			 *
244
+			 * @since 1.0.0
245
+			 */
246
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
+			$items .= '<li  class="' . $li_class . '">
248 248
 					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249 249
 					<ul class="' . $sub_ul_class . '">';
250 250
 
251
-            $post_types = geodir_get_posttypes('object');
252
-
253
-            $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
-
255
-            if (!empty($post_types)) {
256
-                foreach ($post_types as $post_type => $args) {
257
-                    if (!empty($geodir_allow_posttype_frontend)) {
258
-                        if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
-                            if (!empty($show_add_listing_post_types)) {
260
-                                if (in_array($post_type, $show_add_listing_post_types)) {
261
-                                    if (geodir_get_addlisting_link($post_type)) {
262
-
263
-                                        $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
266
-                                        /**
267
-                                         * Filter the menu li class.
268
-                                         *
269
-                                         * @since 1.0.0
270
-                                         * @param string $menu_class The menu HTML class.
271
-                                         */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
-                                        $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $li_class . '">
251
+			$post_types = geodir_get_posttypes('object');
252
+
253
+			$show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
+
255
+			if (!empty($post_types)) {
256
+				foreach ($post_types as $post_type => $args) {
257
+					if (!empty($geodir_allow_posttype_frontend)) {
258
+						if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
+							if (!empty($show_add_listing_post_types)) {
260
+								if (in_array($post_type, $show_add_listing_post_types)) {
261
+									if (geodir_get_addlisting_link($post_type)) {
262
+
263
+										$menu_class = '';
264
+										if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
+											$menu_class = 'current-menu-item';
266
+										/**
267
+										 * Filter the menu li class.
268
+										 *
269
+										 * @since 1.0.0
270
+										 * @param string $menu_class The menu HTML class.
271
+										 */
272
+										$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
+										$cpt_name = __($args->labels->singular_name, 'geodirectory');
274
+										$items .= '<li class="' . $li_class . '">
275 275
 														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276 276
 															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
277 277
 														</a>
278 278
 													</li>';
279
-                                    }
280
-                                }
281
-                            }
282
-                        }
283
-                    }
284
-                }
285
-            }
279
+									}
280
+								}
281
+							}
282
+						}
283
+					}
284
+				}
285
+			}
286 286
 
287
-            $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
289
-            $items .= '</li>';
287
+			$items .= '	</ul> ';
288
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
289
+			$items .= '</li>';
290 290
 
291
-        }
292
-    }
293
-    // apply filter to add more navigations // -Filter-Location-Manager
294
-    return $items;
291
+		}
292
+	}
293
+	// apply filter to add more navigations // -Filter-Location-Manager
294
+	return $items;
295 295
 }
296 296
 
297 297
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function geodir_pagemenu_items($menu, $args)
311 311
 {
312
-    $locations = get_nav_menu_locations();
313
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
314
-    $geodir_theme_location_nav = array();
315
-    if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
-        $geodir_theme_location_nav[] = $args['theme_location'];
318
-        update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
-    }
320
-    //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
312
+	$locations = get_nav_menu_locations();
313
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
314
+	$geodir_theme_location_nav = array();
315
+	if (empty($locations) && empty($geodir_theme_location)) {
316
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
+		$geodir_theme_location_nav[] = $args['theme_location'];
318
+		update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
+	}
320
+	//else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
322
+	else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
324 324
 
325
-    return $menu;
325
+	return $menu;
326 326
 
327 327
 }
328 328
 
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
 function geodir_menu_items($items, $args)
343 343
 {
344 344
 
345
-    $location = $args->theme_location;
345
+	$location = $args->theme_location;
346 346
 
347
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
347
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
348 348
 
349
-    if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
349
+	if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
352
-        return $items;
351
+		$items = $items . geodir_add_nav_menu_items();
352
+		return $items;
353 353
 
354
-    } else {
355
-        return $items;
356
-    }
354
+	} else {
355
+		return $items;
356
+	}
357 357
 }
358 358
 
359 359
 /**
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function geodir_get_category_all_array()
370 370
 {
371
-    global $wpdb;
372
-    $return_array = array();
373
-
374
-    $taxonomies = geodir_get_taxonomies();
375
-    $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
377
-
378
-    $pn_categories = $wpdb->get_results(
379
-        $wpdb->prepare(
380
-            "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
382
-        )
383
-    );
384
-
385
-    foreach ($pn_categories as $pn_categories_obj) {
386
-        $return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
-            "title" => $pn_categories_obj->name,);
388
-    }
389
-    return $return_array;
371
+	global $wpdb;
372
+	$return_array = array();
373
+
374
+	$taxonomies = geodir_get_taxonomies();
375
+	$taxonomies = implode("','", $taxonomies);
376
+	$taxonomies = "'" . $taxonomies . "'";
377
+
378
+	$pn_categories = $wpdb->get_results(
379
+		$wpdb->prepare(
380
+			"SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
+			array($wpdb->terms . term_id)
382
+		)
383
+	);
384
+
385
+	foreach ($pn_categories as $pn_categories_obj) {
386
+		$return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
+			"title" => $pn_categories_obj->name,);
388
+	}
389
+	return $return_array;
390 390
 }
391 391
 
392 392
 
@@ -401,41 +401,41 @@  discard block
 block discarded – undo
401 401
  */
402 402
 function geodir_get_current_posttype()
403 403
 {
404
-    global $wp_query, $geodir_post_type;
404
+	global $wp_query, $geodir_post_type;
405 405
 
406
-    $geodir_post_type = get_query_var('post_type');
406
+	$geodir_post_type = get_query_var('post_type');
407 407
 
408
-    if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
409
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
410
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
411
-        elseif (isset($_REQUEST['listing_type']))
412
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
413
-    }
408
+	if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
409
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
410
+			$geodir_post_type = get_post_type((int)$_REQUEST['pid']);
411
+		elseif (isset($_REQUEST['listing_type']))
412
+			$geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
413
+	}
414 414
 
415
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
416
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
415
+	if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
416
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
417 417
 
418
-    if (is_tax())
419
-        $geodir_post_type = geodir_get_taxonomy_posttype();
418
+	if (is_tax())
419
+		$geodir_post_type = geodir_get_taxonomy_posttype();
420 420
 
421 421
 
422
-    $all_postypes = geodir_get_posttypes();
423
-    $all_postypes = stripslashes_deep($all_postypes);
422
+	$all_postypes = geodir_get_posttypes();
423
+	$all_postypes = stripslashes_deep($all_postypes);
424 424
 
425
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
426
-        $geodir_post_type = '';
425
+	if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
426
+		$geodir_post_type = '';
427 427
 
428
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
429
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
430
-    }
428
+	if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
429
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
430
+	}
431 431
 
432 432
 
433
-    /**
434
-     * Filter the default CPT return.
435
-     *
436
-     * @since 1.6.9
437
-     */
438
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
433
+	/**
434
+	 * Filter the default CPT return.
435
+	 *
436
+	 * @since 1.6.9
437
+	 */
438
+	return apply_filters('geodir_get_current_posttype',$geodir_post_type);
439 439
 }
440 440
 
441 441
 /**
@@ -449,22 +449,22 @@  discard block
 block discarded – undo
449 449
  */
450 450
 function geodir_get_default_posttype()
451 451
 {
452
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
453
-
454
-    $stype = false;
455
-    foreach ( $post_types as $post_type => $info ) {
456
-        global $wpdb;
457
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
458
-        if ( $has_posts ) {
459
-            $stype = $post_type; break;
460
-        }
461
-    }
462
-
463
-    if(!$stype){
464
-        $stype = 'gd_place';
465
-    }
466
-
467
-    return $stype;
452
+	$post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
453
+
454
+	$stype = false;
455
+	foreach ( $post_types as $post_type => $info ) {
456
+		global $wpdb;
457
+		$has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
458
+		if ( $has_posts ) {
459
+			$stype = $post_type; break;
460
+		}
461
+	}
462
+
463
+	if(!$stype){
464
+		$stype = 'gd_place';
465
+	}
466
+
467
+	return $stype;
468 468
 }
469 469
 
470 470
 /**
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
  */
479 479
 function geodir_get_posttypes($output = 'names')
480 480
 {
481
-    $post_types = array();
482
-    $post_types = get_option('geodir_post_types');
483
-    $post_types = stripslashes_deep($post_types);
484
-    if (!empty($post_types)) {
485
-        switch ($output):
486
-            case 'object':
487
-            case 'Object':
488
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
489
-                break;
490
-            case 'array':
491
-            case 'Array':
492
-                $post_types = (array)$post_types;
493
-                break;
481
+	$post_types = array();
482
+	$post_types = get_option('geodir_post_types');
483
+	$post_types = stripslashes_deep($post_types);
484
+	if (!empty($post_types)) {
485
+		switch ($output):
486
+			case 'object':
487
+			case 'Object':
488
+				$post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
489
+				break;
490
+			case 'array':
491
+			case 'Array':
492
+				$post_types = (array)$post_types;
493
+				break;
494 494
 			case 'options':
495
-                $post_types = (array)$post_types;
495
+				$post_types = (array)$post_types;
496 496
 				
497 497
 				$options = array();
498 498
 				if (!empty($post_types)) {
@@ -501,17 +501,17 @@  discard block
 block discarded – undo
501 501
 					}
502 502
 				}
503 503
 				$post_types = $options;
504
-                break;
505
-            default:
506
-                $post_types = array_keys($post_types);
507
-                break;
508
-        endswitch;
509
-    }
510
-
511
-    if (!empty($post_types))
512
-        return $post_types;
513
-    else
514
-        return array();
504
+				break;
505
+			default:
506
+				$post_types = array_keys($post_types);
507
+				break;
508
+		endswitch;
509
+	}
510
+
511
+	if (!empty($post_types))
512
+		return $post_types;
513
+	else
514
+		return array();
515 515
 }
516 516
 
517 517
 /**
@@ -524,108 +524,108 @@  discard block
 block discarded – undo
524 524
  */
525 525
 function geodir_get_posttype_info($post_type = '')
526 526
 {
527
-    $post_types = array();
528
-    $post_types = get_option('geodir_post_types');
529
-    $post_types = stripslashes_deep($post_types);
530
-    if (!empty($post_types) && $post_type != '') {
531
-        return $post_types[$post_type];
532
-    } else
533
-        return false;
527
+	$post_types = array();
528
+	$post_types = get_option('geodir_post_types');
529
+	$post_types = stripslashes_deep($post_types);
530
+	if (!empty($post_types) && $post_type != '') {
531
+		return $post_types[$post_type];
532
+	} else
533
+		return false;
534 534
 }
535 535
 
536 536
 if (!function_exists('geodir_get_taxonomies')) {
537
-    /**
538
-     * Get all custom taxonomies.
539
-     *
540
-     * @since 1.0.0
541
-     * @package GeoDirectory
542
-     * @param string $post_type The post type.
543
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
544
-     * @return array|bool Taxonomies on success. false on failure.
545
-     */
546
-    function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false)
547
-    {
537
+	/**
538
+	 * Get all custom taxonomies.
539
+	 *
540
+	 * @since 1.0.0
541
+	 * @package GeoDirectory
542
+	 * @param string $post_type The post type.
543
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
544
+	 * @return array|bool Taxonomies on success. false on failure.
545
+	 */
546
+	function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false)
547
+	{
548 548
 
549
-        $taxonomies = array();
550
-        $gd_taxonomies = array();
549
+		$taxonomies = array();
550
+		$gd_taxonomies = array();
551 551
 
552
-        if ($taxonomies = get_option('geodir_taxonomies')) {
552
+		if ($taxonomies = get_option('geodir_taxonomies')) {
553 553
 
554 554
 
555
-            $gd_taxonomies = array_keys($taxonomies);
555
+			$gd_taxonomies = array_keys($taxonomies);
556 556
 
557 557
 
558
-            if ($post_type != '')
559
-                $gd_taxonomies = array();
558
+			if ($post_type != '')
559
+				$gd_taxonomies = array();
560 560
 
561
-            $i = 0;
562
-            foreach ($taxonomies as $taxonomy => $args) {
561
+			$i = 0;
562
+			foreach ($taxonomies as $taxonomy => $args) {
563 563
 
564
-                if ($post_type != '' && $args['object_type'] == $post_type)
565
-                    $gd_taxonomies[] = $taxonomy;
564
+				if ($post_type != '' && $args['object_type'] == $post_type)
565
+					$gd_taxonomies[] = $taxonomy;
566 566
 
567
-                if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
568
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
569
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
570
-                }
567
+				if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
568
+					if (array_search($taxonomy, $gd_taxonomies) !== false)
569
+						unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
570
+				}
571 571
 
572
-            }
572
+			}
573 573
 
574
-            $gd_taxonomies = array_values($gd_taxonomies);
575
-        }
576
-
577
-        /**
578
-         * Filter the taxonomies.
579
-         *
580
-         * @since 1.0.0
581
-         * @param array $gd_taxonomies The taxonomy array.
582
-         */
583
-        $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
584
-
585
-        if (!empty($taxonomies)) {
586
-            return $taxonomies;
587
-        } else {
588
-            return false;
589
-        }
590
-    }
574
+			$gd_taxonomies = array_values($gd_taxonomies);
575
+		}
576
+
577
+		/**
578
+		 * Filter the taxonomies.
579
+		 *
580
+		 * @since 1.0.0
581
+		 * @param array $gd_taxonomies The taxonomy array.
582
+		 */
583
+		$taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
584
+
585
+		if (!empty($taxonomies)) {
586
+			return $taxonomies;
587
+		} else {
588
+			return false;
589
+		}
590
+	}
591 591
 }
592 592
 
593 593
 if (!function_exists(' geodir_get_categories_dl')) {
594
-    /**
595
-     * Get categories dropdown HTML.
596
-     *
597
-     * @since 1.0.0
598
-     * @package GeoDirectory
599
-     * @param string $post_type The post type.
600
-     * @param string $selected The selected value.
601
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
602
-     * @param bool $echo Prints the HTML when set to true. Default: true.
603
-     * @return void|string Dropdown HTML.
604
-     */
605
-    function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
606
-    {
607
-
608
-        $html = '';
609
-        $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
610
-
611
-        $categories = get_terms($taxonomies);
612
-
613
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
614
-
615
-        foreach ($categories as $category_obj) {
616
-            $select_opt = '';
617
-            if ($selected == $category_obj->term_id) {
618
-                $select_opt = 'selected="selected"';
619
-            }
620
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
621
-                . ucfirst($category_obj->name) . '</option>';
622
-        }
623
-
624
-        if ($echo)
625
-            echo $html;
626
-        else
627
-            return $html;
628
-    }
594
+	/**
595
+	 * Get categories dropdown HTML.
596
+	 *
597
+	 * @since 1.0.0
598
+	 * @package GeoDirectory
599
+	 * @param string $post_type The post type.
600
+	 * @param string $selected The selected value.
601
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
602
+	 * @param bool $echo Prints the HTML when set to true. Default: true.
603
+	 * @return void|string Dropdown HTML.
604
+	 */
605
+	function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
606
+	{
607
+
608
+		$html = '';
609
+		$taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
610
+
611
+		$categories = get_terms($taxonomies);
612
+
613
+		$html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
614
+
615
+		foreach ($categories as $category_obj) {
616
+			$select_opt = '';
617
+			if ($selected == $category_obj->term_id) {
618
+				$select_opt = 'selected="selected"';
619
+			}
620
+			$html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
621
+				. ucfirst($category_obj->name) . '</option>';
622
+		}
623
+
624
+		if ($echo)
625
+			echo $html;
626
+		else
627
+			return $html;
628
+	}
629 629
 }
630 630
 
631 631
 
@@ -640,28 +640,28 @@  discard block
 block discarded – undo
640 640
 function geodir_get_listing_slug($object_type = '')
641 641
 {
642 642
 
643
-    $listing_slug = '';
643
+	$listing_slug = '';
644 644
 
645
-    $post_types = get_option('geodir_post_types');
646
-    $taxonomies = get_option('geodir_taxonomies');
645
+	$post_types = get_option('geodir_post_types');
646
+	$taxonomies = get_option('geodir_taxonomies');
647 647
 
648 648
 
649
-    if ($object_type != '') {
650
-        if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
649
+	if ($object_type != '') {
650
+		if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
651 651
 
652
-            $object_info = $post_types[$object_type];
653
-            $listing_slug = $object_info['listing_slug'];
654
-        } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
655
-            $object_info = $taxonomies[$object_type];
656
-            $listing_slug = $object_info['listing_slug'];
657
-        }
652
+			$object_info = $post_types[$object_type];
653
+			$listing_slug = $object_info['listing_slug'];
654
+		} elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
655
+			$object_info = $taxonomies[$object_type];
656
+			$listing_slug = $object_info['listing_slug'];
657
+		}
658 658
 
659
-    }
659
+	}
660 660
 
661
-    if (!empty($listing_slug))
662
-        return $listing_slug;
663
-    else
664
-        return false;
661
+	if (!empty($listing_slug))
662
+		return $listing_slug;
663
+	else
664
+		return false;
665 665
 }
666 666
 
667 667
 
@@ -676,212 +676,212 @@  discard block
 block discarded – undo
676 676
  */
677 677
 function geodir_get_taxonomy_posttype($taxonomy = '')
678 678
 {
679
-    global $wp_query;
680
-
681
-    $post_type = array();
682
-    $taxonomies = array();
683
-
684
-    if (!empty($taxonomy)) {
685
-        $taxonomies[] = $taxonomy;
686
-    } elseif (isset($wp_query->tax_query->queries)) {
687
-        $tax_arr = $wp_query->tax_query->queries;
688
-        //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
689
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
690
-        $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
691
-    }
692
-
693
-    if (!empty($taxonomies)) {
694
-        foreach (geodir_get_posttypes() as $pt) {
695
-            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
696
-            if (array_intersect($taxonomies, $object_taxonomies))
697
-                $post_type[] = $pt;
698
-        }
699
-    }
700
-
701
-    if (!empty($post_type))
702
-        return $post_type[0];
703
-    else
704
-        return false;
679
+	global $wp_query;
680
+
681
+	$post_type = array();
682
+	$taxonomies = array();
683
+
684
+	if (!empty($taxonomy)) {
685
+		$taxonomies[] = $taxonomy;
686
+	} elseif (isset($wp_query->tax_query->queries)) {
687
+		$tax_arr = $wp_query->tax_query->queries;
688
+		//if tax query has 'relation' set then it will break wp_list_pluck so we remove it
689
+		if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
690
+		$taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
691
+	}
692
+
693
+	if (!empty($taxonomies)) {
694
+		foreach (geodir_get_posttypes() as $pt) {
695
+			$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
696
+			if (array_intersect($taxonomies, $object_taxonomies))
697
+				$post_type[] = $pt;
698
+		}
699
+	}
700
+
701
+	if (!empty($post_type))
702
+		return $post_type[0];
703
+	else
704
+		return false;
705 705
 }
706 706
 
707 707
 if (!function_exists('geodir_custom_taxonomy_walker')) {
708
-    /**
709
-     * Custom taxonomy walker function.
710
-     *
711
-     * @since 1.0.0
712
-     * @package GeoDirectory
713
-     * @param string $cat_taxonomy The taxonomy name.
714
-     * @param int $cat_parent The parent term ID.
715
-     * @param bool $hide_empty Hide empty taxonomies? Default: false.
716
-     * @param int $pading CSS padding in pixels.
717
-     * @return string|void taxonomy HTML.
718
-     */
719
-    function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
720
-    {
721
-        global $cat_display, $post_cat, $exclude_cats;
722
-
723
-        $search_terms = trim($post_cat, ",");
724
-
725
-        $search_terms = explode(",", $search_terms);
726
-
727
-        $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
728
-
729
-        $display = '';
730
-        $onchange = '';
731
-        $term_check = '';
732
-        $main_list_class = '';
733
-        $out = '';
734
-        //If there are terms, start displaying
735
-        if (count($cat_terms) > 0) {
736
-            //Displaying as a list
737
-            $p = $pading * 20;
738
-            $pading++;
739
-
740
-
741
-            if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
742
-                if ($cat_parent == 0) {
743
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
744
-                    $main_list_class = 'class="main_list_selecter"';
745
-                } else {
746
-                    //$display = 'display:none';
747
-                    $list_class = 'sub_list gd-sub-cats-list';
748
-                }
749
-            }
708
+	/**
709
+	 * Custom taxonomy walker function.
710
+	 *
711
+	 * @since 1.0.0
712
+	 * @package GeoDirectory
713
+	 * @param string $cat_taxonomy The taxonomy name.
714
+	 * @param int $cat_parent The parent term ID.
715
+	 * @param bool $hide_empty Hide empty taxonomies? Default: false.
716
+	 * @param int $pading CSS padding in pixels.
717
+	 * @return string|void taxonomy HTML.
718
+	 */
719
+	function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
720
+	{
721
+		global $cat_display, $post_cat, $exclude_cats;
722
+
723
+		$search_terms = trim($post_cat, ",");
724
+
725
+		$search_terms = explode(",", $search_terms);
726
+
727
+		$cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
728
+
729
+		$display = '';
730
+		$onchange = '';
731
+		$term_check = '';
732
+		$main_list_class = '';
733
+		$out = '';
734
+		//If there are terms, start displaying
735
+		if (count($cat_terms) > 0) {
736
+			//Displaying as a list
737
+			$p = $pading * 20;
738
+			$pading++;
739
+
740
+
741
+			if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
742
+				if ($cat_parent == 0) {
743
+					$list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
744
+					$main_list_class = 'class="main_list_selecter"';
745
+				} else {
746
+					//$display = 'display:none';
747
+					$list_class = 'sub_list gd-sub-cats-list';
748
+				}
749
+			}
750 750
 
751
-            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
752
-                $p = 0;
753
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
754
-            }
751
+			if ($cat_display == 'checkbox' || $cat_display == 'radio') {
752
+				$p = 0;
753
+				$out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
754
+			}
755 755
 
756
-            foreach ($cat_terms as $cat_term) {
756
+			foreach ($cat_terms as $cat_term) {
757 757
 
758
-                $checked = '';
758
+				$checked = '';
759 759
 
760
-                if (in_array($cat_term->term_id, $search_terms)) {
761
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
762
-                        $checked = 'selected="selected"';
763
-                    else
764
-                        $checked = 'checked="checked"';
765
-                }
760
+				if (in_array($cat_term->term_id, $search_terms)) {
761
+					if ($cat_display == 'select' || $cat_display == 'multiselect')
762
+						$checked = 'selected="selected"';
763
+					else
764
+						$checked = 'checked="checked"';
765
+				}
766 766
 
767
-                if ($cat_display == 'radio')
768
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
769
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
770
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>';
767
+				if ($cat_display == 'radio')
768
+					$out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
769
+				elseif ($cat_display == 'select' || $cat_display == 'multiselect')
770
+					$out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>';
771 771
 
772
-                else {
773
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
774
-                }
772
+				else {
773
+					$out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
774
+				}
775 775
 
776
-                // Call recurson to print sub cats
777
-                $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
776
+				// Call recurson to print sub cats
777
+				$out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
778 778
 
779
-            }
779
+			}
780 780
 
781
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
782
-                $out .= '</div>';
781
+			if ($cat_display == 'checkbox' || $cat_display == 'radio')
782
+				$out .= '</div>';
783 783
 
784
-            return $out;
785
-        }
786
-        return;
787
-    }
784
+			return $out;
785
+		}
786
+		return;
787
+	}
788 788
 }
789 789
 
790 790
 if (!function_exists('geodir_custom_taxonomy_walker2')) {
791
-    /**
792
-     * Custom taxonomy walker function.
793
-     *
794
-     * @since 1.0.0
795
-     * @package GeoDirectory
796
-     * @global object $post WordPress Post object.
797
-     * @global object $gd_session GeoDirectory Session object.
798
-     * @param string $cat_taxonomy The taxonomy name.
799
-     * @param string $cat_limit Number of categories to display.
800
-     */
801
-    function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
802
-    {
803
-        $post_category = '';
804
-        $post_category_str = '';
805
-        global $exclude_cats, $gd_session;
806
-
807
-        $cat_exclude = '';
808
-        if (is_array($exclude_cats) && !empty($exclude_cats))
809
-            $cat_exclude = serialize($exclude_cats);
810
-
811
-        if (isset($_REQUEST['backandedit'])) {
812
-            $post = (object)$gd_session->get('listing');
813
-
814
-            if (!is_array($post->post_category[$cat_taxonomy]))
815
-                $post_category = $post->post_category[$cat_taxonomy];
816
-
817
-            $post_categories = $post->post_category_str;
818
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
819
-                $post_category_str = $post_categories[$cat_taxonomy];
820
-
821
-        } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
822
-            global $post;
823
-
824
-            $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
825
-            if (empty($post_category) && isset($post->{$cat_taxonomy})) {
826
-                $post_category = $post->{$cat_taxonomy};
827
-            }
791
+	/**
792
+	 * Custom taxonomy walker function.
793
+	 *
794
+	 * @since 1.0.0
795
+	 * @package GeoDirectory
796
+	 * @global object $post WordPress Post object.
797
+	 * @global object $gd_session GeoDirectory Session object.
798
+	 * @param string $cat_taxonomy The taxonomy name.
799
+	 * @param string $cat_limit Number of categories to display.
800
+	 */
801
+	function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
802
+	{
803
+		$post_category = '';
804
+		$post_category_str = '';
805
+		global $exclude_cats, $gd_session;
806
+
807
+		$cat_exclude = '';
808
+		if (is_array($exclude_cats) && !empty($exclude_cats))
809
+			$cat_exclude = serialize($exclude_cats);
810
+
811
+		if (isset($_REQUEST['backandedit'])) {
812
+			$post = (object)$gd_session->get('listing');
813
+
814
+			if (!is_array($post->post_category[$cat_taxonomy]))
815
+				$post_category = $post->post_category[$cat_taxonomy];
816
+
817
+			$post_categories = $post->post_category_str;
818
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
819
+				$post_category_str = $post_categories[$cat_taxonomy];
820
+
821
+		} elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
822
+			global $post;
823
+
824
+			$post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
825
+			if (empty($post_category) && isset($post->{$cat_taxonomy})) {
826
+				$post_category = $post->{$cat_taxonomy};
827
+			}
828 828
 
829
-            $post_categories = get_post_meta($post->ID, 'post_categories', true);
829
+			$post_categories = get_post_meta($post->ID, 'post_categories', true);
830 830
 
831
-            if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
832
-                foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
833
-                    if (is_numeric($cat_part)) {
834
-                        $cat_part_arr[] = $cat_part;
835
-                    }
836
-                }
837
-                if (is_array($cat_part_arr)) {
838
-                    $post_category = implode(',', $cat_part_arr);
839
-                }
840
-            }
831
+			if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
832
+				foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
833
+					if (is_numeric($cat_part)) {
834
+						$cat_part_arr[] = $cat_part;
835
+					}
836
+				}
837
+				if (is_array($cat_part_arr)) {
838
+					$post_category = implode(',', $cat_part_arr);
839
+				}
840
+			}
841 841
 
842
-            if (!empty($post_category)) {
843
-                $cat1 = array_filter(explode(',', $post_category));
844
-                $post_category = ',' . implode(',', $cat1) . ',';
842
+			if (!empty($post_category)) {
843
+				$cat1 = array_filter(explode(',', $post_category));
844
+				$post_category = ',' . implode(',', $cat1) . ',';
845 845
 
846
-            }
846
+			}
847 847
 
848
-            if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
848
+			if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
849 849
 
850
-                $post_category_upd = explode(',', $post_category);
851
-                $post_category_change = '';
852
-                foreach ($post_category_upd as $cat) {
850
+				$post_category_upd = explode(',', $post_category);
851
+				$post_category_change = '';
852
+				foreach ($post_category_upd as $cat) {
853 853
 
854
-                    if (!in_array($cat, $exclude_cats) && $cat != '') {
855
-                        $post_category_change .= ',' . $cat;
856
-                    }
857
-                }
858
-                $post_category = $post_category_change;
859
-            }
854
+					if (!in_array($cat, $exclude_cats) && $cat != '') {
855
+						$post_category_change .= ',' . $cat;
856
+					}
857
+				}
858
+				$post_category = $post_category_change;
859
+			}
860 860
 
861 861
 
862
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
863
-                $post_category_str = $post_categories[$cat_taxonomy];
864
-            }
865
-        }
862
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
863
+				$post_category_str = $post_categories[$cat_taxonomy];
864
+			}
865
+		}
866 866
 
867
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
867
+		echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
868 868
 
869
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
869
+		echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
870 870
 
871
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
871
+		echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
872 872
 
873 873
 
874
-        ?>
874
+		?>
875 875
         <div class="cat_sublist">
876 876
             <?php
877 877
 
878
-            $post_id = isset($post->ID) ? $post->ID : '';
878
+			$post_id = isset($post->ID) ? $post->ID : '';
879 879
 
880
-            if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
880
+			if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
881 881
 
882
-                geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
883
-            }
884
-            ?>
882
+				geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
883
+			}
884
+			?>
885 885
         </div>
886 886
         <script type="text/javascript">
887 887
 
@@ -1004,22 +1004,22 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
         </script>
1006 1006
         <?php
1007
-        if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1008
-            $post_cat_str = $post_categories[$cat_taxonomy];
1009
-            $post_cat_array = explode("#", $post_cat_str);
1010
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1011
-                $style = "display:none;";
1012
-        }
1013
-        ?>
1007
+		if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1008
+			$post_cat_str = $post_categories[$cat_taxonomy];
1009
+			$post_cat_array = explode("#", $post_cat_str);
1010
+			if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1011
+				$style = "display:none;";
1012
+		}
1013
+		?>
1014 1014
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1015
-            echo $style;
1016
-        }?> ">
1015
+			echo $style;
1016
+		}?> ">
1017 1017
             <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1018
-            ?>
1018
+			?>
1019 1019
         </div>
1020 1020
     <?php
1021 1021
 
1022
-    }
1022
+	}
1023 1023
 }
1024 1024
 
1025 1025
 /**
@@ -1036,23 +1036,23 @@  discard block
 block discarded – undo
1036 1036
  */
1037 1037
 function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '')
1038 1038
 {
1039
-    global $exclude_cats;
1039
+	global $exclude_cats;
1040 1040
 
1041
-    if ($exclude != '') {
1042
-        $exclude_cats = maybe_unserialize(base64_decode($exclude));
1041
+	if ($exclude != '') {
1042
+		$exclude_cats = maybe_unserialize(base64_decode($exclude));
1043 1043
 
1044
-        if(is_array( $exclude_cats)){
1045
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1046
-        }else{
1047
-            $exclude_cats = intval($exclude_cats);
1048
-        }
1044
+		if(is_array( $exclude_cats)){
1045
+			$exclude_cats = array_map( 'intval', $exclude_cats );
1046
+		}else{
1047
+			$exclude_cats = intval($exclude_cats);
1048
+		}
1049 1049
 
1050
-    }
1050
+	}
1051 1051
 
1052
-    if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1053
-        (!is_array($exclude_cats) || empty($exclude_cats))
1054
-    ) {
1055
-        ?>
1052
+	if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1053
+		(!is_array($exclude_cats) || empty($exclude_cats))
1054
+	) {
1055
+		?>
1056 1056
 
1057 1057
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1058 1058
 
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
 
1082 1082
             <br/>
1083 1083
             <?php
1084
-            $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1085
-            if (!empty($cat_terms)) { ?>
1084
+			$cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1085
+			if (!empty($cat_terms)) { ?>
1086 1086
                 <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
1087 1087
                 <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?>
1088 1088
             <?php } ?>
@@ -1104,53 +1104,53 @@  discard block
 block discarded – undo
1104 1104
 function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories)
1105 1105
 {
1106 1106
 
1107
-    if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1108
-        $post_cat_str = $post_categories[$request_taxonomy];
1109
-        $post_cat_array = explode("#", $post_cat_str);
1110
-        if (is_array($post_cat_array)) {
1111
-            $post_cat_array = array_unique( $post_cat_array );
1107
+	if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1108
+		$post_cat_str = $post_categories[$request_taxonomy];
1109
+		$post_cat_array = explode("#", $post_cat_str);
1110
+		if (is_array($post_cat_array)) {
1111
+			$post_cat_array = array_unique( $post_cat_array );
1112 1112
 
1113 1113
 			foreach ($post_cat_array as $post_cat_html) {
1114 1114
 
1115
-                $post_cat_info = explode(":", $post_cat_html);
1116
-                $post_maincat_str = $post_cat_info[0];
1115
+				$post_cat_info = explode(":", $post_cat_html);
1116
+				$post_maincat_str = $post_cat_info[0];
1117 1117
 
1118
-                if (!empty($post_maincat_str)) {
1119
-                    $post_maincat_info = explode(",", $post_maincat_str);
1120
-                    $post_maincat_id = $post_maincat_info[0];
1121
-                    ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1122
-                    (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1123
-                }
1124
-                $post_sub_catid = '';
1125
-                if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1126
-                    $post_sub_catid = (int)$post_cat_info[1];
1127
-                }
1118
+				if (!empty($post_maincat_str)) {
1119
+					$post_maincat_info = explode(",", $post_maincat_str);
1120
+					$post_maincat_id = $post_maincat_info[0];
1121
+					($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1122
+					(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1123
+				}
1124
+				$post_sub_catid = '';
1125
+				if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1126
+					$post_sub_catid = (int)$post_cat_info[1];
1127
+				}
1128 1128
 
1129
-                geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1129
+				geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1130 1130
 
1131
-            }
1132
-        } else {
1131
+			}
1132
+		} else {
1133 1133
 
1134
-            $post_cat_info = explode(":", $post_cat_str);
1135
-            $post_maincat_str = $post_cat_info[0];
1134
+			$post_cat_info = explode(":", $post_cat_str);
1135
+			$post_maincat_str = $post_cat_info[0];
1136 1136
 
1137
-            $post_sub_catid = '';
1137
+			$post_sub_catid = '';
1138 1138
 
1139
-            if (!empty($post_maincat_str)) {
1140
-                $post_maincat_info = explode(",", $post_maincat_str);
1141
-                $post_maincat_id = $post_maincat_info[0];
1142
-                ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1143
-                (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1144
-            }
1139
+			if (!empty($post_maincat_str)) {
1140
+				$post_maincat_info = explode(",", $post_maincat_str);
1141
+				$post_maincat_id = $post_maincat_info[0];
1142
+				($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1143
+				(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1144
+			}
1145 1145
 
1146
-            if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1147
-                $post_sub_catid = (int)$post_cat_info[1];
1148
-            }
1146
+			if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1147
+				$post_sub_catid = (int)$post_cat_info[1];
1148
+			}
1149 1149
 
1150
-            geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1150
+			geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1151 1151
 
1152
-        }
1153
-    }
1152
+		}
1153
+	}
1154 1154
 }
1155 1155
 
1156 1156
 /**
@@ -1164,35 +1164,35 @@  discard block
 block discarded – undo
1164 1164
  */
1165 1165
 function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false)
1166 1166
 {
1167
-    global $exclude_cats;
1167
+	global $exclude_cats;
1168 1168
 
1169
-    $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1169
+	$cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1170 1170
 
1171
-    if (!empty($cat_terms)) {
1172
-        $onchange = '';
1173
-        $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1171
+	if (!empty($cat_terms)) {
1172
+		$onchange = '';
1173
+		$onchange = ' onchange="show_subcatlist(this.value, this)" ';
1174 1174
 
1175
-        $option_selected = '';
1176
-        if (!$selected)
1177
-            $option_slected = ' selected="selected" ';
1175
+		$option_selected = '';
1176
+		if (!$selected)
1177
+			$option_slected = ' selected="selected" ';
1178 1178
 
1179
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1179
+		echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1180 1180
 
1181
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1181
+		echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1182 1182
 
1183
-        foreach ($cat_terms as $cat_term) {
1184
-            $option_selected = '';
1185
-            if ($selected == $cat_term->term_id)
1186
-                $option_selected = ' selected="selected" ';
1183
+		foreach ($cat_terms as $cat_term) {
1184
+			$option_selected = '';
1185
+			if ($selected == $cat_term->term_id)
1186
+				$option_selected = ' selected="selected" ';
1187 1187
 
1188
-            // Count child terms
1189
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1190
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1188
+			// Count child terms
1189
+			$child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1190
+			$has_child = !empty( $child_terms ) ? 't' : 'f';
1191 1191
 
1192
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>';
1193
-        }
1194
-        echo '</select>';
1195
-    }
1192
+			echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>';
1193
+		}
1194
+		echo '</select>';
1195
+	}
1196 1196
 }
1197 1197
 
1198 1198
 /**
@@ -1208,28 +1208,28 @@  discard block
 block discarded – undo
1208 1208
  */
1209 1209
 function geodir_custom_update_messages($messages)
1210 1210
 {
1211
-    global $post, $post_ID;
1212
-
1213
-    $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1214
-
1215
-    foreach ($post_types as $post_type => $post_object) {
1216
-
1217
-        $messages[$post_type] = array(
1218
-            0 => '', // Unused. Messages start at index 1.
1219
-            1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1220
-            2 => __('Custom field updated.', 'geodirectory'),
1221
-            3 => __('Custom field deleted.', 'geodirectory'),
1222
-            4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1223
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1224
-            6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225
-            7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1226
-            8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1227
-            9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1228
-            10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1229
-        );
1230
-    }
1231
-
1232
-    return $messages;
1211
+	global $post, $post_ID;
1212
+
1213
+	$post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1214
+
1215
+	foreach ($post_types as $post_type => $post_object) {
1216
+
1217
+		$messages[$post_type] = array(
1218
+			0 => '', // Unused. Messages start at index 1.
1219
+			1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1220
+			2 => __('Custom field updated.', 'geodirectory'),
1221
+			3 => __('Custom field deleted.', 'geodirectory'),
1222
+			4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1223
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1224
+			6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225
+			7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1226
+			8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1227
+			9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1228
+			10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1229
+		);
1230
+	}
1231
+
1232
+	return $messages;
1233 1233
 }
1234 1234
 
1235 1235
 
@@ -1244,182 +1244,182 @@  discard block
 block discarded – undo
1244 1244
 function geodir_register_defaults()
1245 1245
 {
1246 1246
 
1247
-    global $wpdb;
1248
-
1249
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1250
-
1251
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1252
-        $listing_slug = 'places';
1253
-
1254
-    /**
1255
-     * Taxonomies
1256
-     **/
1257
-    //if ( ! taxonomy_exists('gd_place_tags') )
1258
-    {
1259
-
1260
-        $gd_placetags = array();
1261
-        $gd_placetags['object_type'] = 'gd_place';
1262
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1263
-        $gd_placetags['args'] = array(
1264
-            'public' => true,
1265
-            'hierarchical' => false,
1266
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1267
-            'query_var' => true,
1268
-
1269
-            'labels' => array(
1270
-                'name' => __('Place Tags', 'geodirectory'),
1271
-                'singular_name' => __('Place Tag', 'geodirectory'),
1272
-                'search_items' => __('Search Place Tags', 'geodirectory'),
1273
-                'popular_items' => __('Popular Place Tags', 'geodirectory'),
1274
-                'all_items' => __('All Place Tags', 'geodirectory'),
1275
-                'edit_item' => __('Edit Place Tag', 'geodirectory'),
1276
-                'update_item' => __('Update Place Tag', 'geodirectory'),
1277
-                'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1278
-                'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1279
-                'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1280
-                'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1281
-                'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1282
-            ),
1283
-        );
1284
-
1285
-
1286
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1287
-        $geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1288
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1289
-
1290
-
1291
-        // Update post types and delete tmp options
1292
-        flush_rewrite_rules();
1293
-
1294
-    }
1295
-
1296
-    //if ( ! taxonomy_exists('gd_placecategory') )
1297
-    {
1298
-
1299
-        $gd_placecategory = array();
1300
-        $gd_placecategory['object_type'] = 'gd_place';
1301
-        $gd_placecategory['listing_slug'] = $listing_slug;
1302
-        $gd_placecategory['args'] = array(
1303
-            'public' => true,
1304
-            'hierarchical' => true,
1305
-            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1306
-            'query_var' => true,
1307
-            'labels' => array(
1308
-                'name' => __('Place Categories', 'geodirectory'),
1309
-                'singular_name' => __('Place Category', 'geodirectory'),
1310
-                'search_items' => __('Search Place Categories', 'geodirectory'),
1311
-                'popular_items' => __('Popular Place Categories', 'geodirectory'),
1312
-                'all_items' => __('All Place Categories', 'geodirectory'),
1313
-                'edit_item' => __('Edit Place Category', 'geodirectory'),
1314
-                'update_item' => __('Update Place Category', 'geodirectory'),
1315
-                'add_new_item' => __('Add New Place Category', 'geodirectory'),
1316
-                'new_item_name' => __('New Place Category', 'geodirectory'),
1317
-                'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1318
-            ),
1319
-        );
1320
-
1321
-
1322
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1323
-        $geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1324
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1325
-
1326
-
1327
-        flush_rewrite_rules();
1328
-    }
1329
-
1330
-    /**
1331
-     * Post Types
1332
-     **/
1333
-
1334
-    //if ( ! post_type_exists('gd_place') )
1335
-    {
1336
-
1337
-        $labels = array(
1338
-            'name' => __('Places', 'geodirectory'),
1339
-            'singular_name' => __('Place', 'geodirectory'),
1340
-            'add_new' => __('Add New', 'geodirectory'),
1341
-            'add_new_item' => __('Add New Place', 'geodirectory'),
1342
-            'edit_item' => __('Edit Place', 'geodirectory'),
1343
-            'new_item' => __('New Place', 'geodirectory'),
1344
-            'view_item' => __('View Place', 'geodirectory'),
1345
-            'search_items' => __('Search Places', 'geodirectory'),
1346
-            'not_found' => __('No Place Found', 'geodirectory'),
1347
-            'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1348
-
1349
-        $place_default = array(
1350
-            'labels' => $labels,
1351
-            'can_export' => true,
1352
-            'capability_type' => 'post',
1353
-            'description' => 'Place post type.',
1354
-            'has_archive' => $listing_slug,
1355
-            'hierarchical' => false,
1356
-            'map_meta_cap' => true,
1357
-            'menu_icon' => $menu_icon,
1358
-            'public' => true,
1359
-            'query_var' => true,
1360
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1361
-            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1362
-            'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1363
-
1364
-        //Update custom post types
1365
-        $geodir_post_types = get_option('geodir_post_types');
1366
-        $geodir_post_types['gd_place'] = $place_default;
1367
-        update_option('geodir_post_types', $geodir_post_types);
1368
-
1369
-        // Update post types and delete tmp options
1370
-        flush_rewrite_rules();
1371
-    }
1372
-
1373
-
1374
-    geodir_register_taxonomies();
1375
-    geodir_register_post_types();
1376
-
1377
-    //die;
1247
+	global $wpdb;
1248
+
1249
+	$menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1250
+
1251
+	if (!$listing_slug = get_option('geodir_listing_prefix'))
1252
+		$listing_slug = 'places';
1253
+
1254
+	/**
1255
+	 * Taxonomies
1256
+	 **/
1257
+	//if ( ! taxonomy_exists('gd_place_tags') )
1258
+	{
1259
+
1260
+		$gd_placetags = array();
1261
+		$gd_placetags['object_type'] = 'gd_place';
1262
+		$gd_placetags['listing_slug'] = $listing_slug . '/tags';
1263
+		$gd_placetags['args'] = array(
1264
+			'public' => true,
1265
+			'hierarchical' => false,
1266
+			'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1267
+			'query_var' => true,
1268
+
1269
+			'labels' => array(
1270
+				'name' => __('Place Tags', 'geodirectory'),
1271
+				'singular_name' => __('Place Tag', 'geodirectory'),
1272
+				'search_items' => __('Search Place Tags', 'geodirectory'),
1273
+				'popular_items' => __('Popular Place Tags', 'geodirectory'),
1274
+				'all_items' => __('All Place Tags', 'geodirectory'),
1275
+				'edit_item' => __('Edit Place Tag', 'geodirectory'),
1276
+				'update_item' => __('Update Place Tag', 'geodirectory'),
1277
+				'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1278
+				'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1279
+				'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1280
+				'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1281
+				'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1282
+			),
1283
+		);
1284
+
1285
+
1286
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1287
+		$geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1288
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1289
+
1290
+
1291
+		// Update post types and delete tmp options
1292
+		flush_rewrite_rules();
1293
+
1294
+	}
1295
+
1296
+	//if ( ! taxonomy_exists('gd_placecategory') )
1297
+	{
1298
+
1299
+		$gd_placecategory = array();
1300
+		$gd_placecategory['object_type'] = 'gd_place';
1301
+		$gd_placecategory['listing_slug'] = $listing_slug;
1302
+		$gd_placecategory['args'] = array(
1303
+			'public' => true,
1304
+			'hierarchical' => true,
1305
+			'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1306
+			'query_var' => true,
1307
+			'labels' => array(
1308
+				'name' => __('Place Categories', 'geodirectory'),
1309
+				'singular_name' => __('Place Category', 'geodirectory'),
1310
+				'search_items' => __('Search Place Categories', 'geodirectory'),
1311
+				'popular_items' => __('Popular Place Categories', 'geodirectory'),
1312
+				'all_items' => __('All Place Categories', 'geodirectory'),
1313
+				'edit_item' => __('Edit Place Category', 'geodirectory'),
1314
+				'update_item' => __('Update Place Category', 'geodirectory'),
1315
+				'add_new_item' => __('Add New Place Category', 'geodirectory'),
1316
+				'new_item_name' => __('New Place Category', 'geodirectory'),
1317
+				'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1318
+			),
1319
+		);
1320
+
1321
+
1322
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1323
+		$geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1324
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1325
+
1326
+
1327
+		flush_rewrite_rules();
1328
+	}
1329
+
1330
+	/**
1331
+	 * Post Types
1332
+	 **/
1333
+
1334
+	//if ( ! post_type_exists('gd_place') )
1335
+	{
1336
+
1337
+		$labels = array(
1338
+			'name' => __('Places', 'geodirectory'),
1339
+			'singular_name' => __('Place', 'geodirectory'),
1340
+			'add_new' => __('Add New', 'geodirectory'),
1341
+			'add_new_item' => __('Add New Place', 'geodirectory'),
1342
+			'edit_item' => __('Edit Place', 'geodirectory'),
1343
+			'new_item' => __('New Place', 'geodirectory'),
1344
+			'view_item' => __('View Place', 'geodirectory'),
1345
+			'search_items' => __('Search Places', 'geodirectory'),
1346
+			'not_found' => __('No Place Found', 'geodirectory'),
1347
+			'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1348
+
1349
+		$place_default = array(
1350
+			'labels' => $labels,
1351
+			'can_export' => true,
1352
+			'capability_type' => 'post',
1353
+			'description' => 'Place post type.',
1354
+			'has_archive' => $listing_slug,
1355
+			'hierarchical' => false,
1356
+			'map_meta_cap' => true,
1357
+			'menu_icon' => $menu_icon,
1358
+			'public' => true,
1359
+			'query_var' => true,
1360
+			'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1361
+			'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1362
+			'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1363
+
1364
+		//Update custom post types
1365
+		$geodir_post_types = get_option('geodir_post_types');
1366
+		$geodir_post_types['gd_place'] = $place_default;
1367
+		update_option('geodir_post_types', $geodir_post_types);
1368
+
1369
+		// Update post types and delete tmp options
1370
+		flush_rewrite_rules();
1371
+	}
1372
+
1373
+
1374
+	geodir_register_taxonomies();
1375
+	geodir_register_post_types();
1376
+
1377
+	//die;
1378 1378
 
1379 1379
 }
1380 1380
 
1381 1381
 $gd_wpml_get_languages = "";
1382 1382
 function gd_wpml_get_lang_from_url($url) {
1383
-    global $sitepress, $gd_wpml_get_languages;
1383
+	global $sitepress, $gd_wpml_get_languages;
1384 1384
     
1385
-    if (geodir_is_wpml()) {
1386
-        return $sitepress->get_language_from_url($url);
1387
-    }
1385
+	if (geodir_is_wpml()) {
1386
+		return $sitepress->get_language_from_url($url);
1387
+	}
1388 1388
     
1389
-    if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1390
-        return $_REQUEST['lang'];
1391
-    }
1389
+	if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1390
+		return $_REQUEST['lang'];
1391
+	}
1392 1392
 
1393
-    $url = str_replace(array("http://","https://"),"",$url);
1393
+	$url = str_replace(array("http://","https://"),"",$url);
1394 1394
 
1395
-    // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1396
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1395
+	// site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1396
+	$site_url = str_replace(array("http://","https://"),"",site_url());
1397 1397
 
1398
-    $url = str_replace($site_url,"",$url);
1398
+	$url = str_replace($site_url,"",$url);
1399 1399
 
1400
-    $segments = explode('/', trim($url, '/'));
1400
+	$segments = explode('/', trim($url, '/'));
1401 1401
 
1402
-    if ($gd_wpml_get_languages) {
1403
-        $langs = $gd_wpml_get_languages;
1404
-    } else {
1405
-        $gd_wpml_get_languages = $sitepress->get_active_languages();
1406
-    }
1402
+	if ($gd_wpml_get_languages) {
1403
+		$langs = $gd_wpml_get_languages;
1404
+	} else {
1405
+		$gd_wpml_get_languages = $sitepress->get_active_languages();
1406
+	}
1407 1407
 
1408
-    if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1409
-        return $segments[0];
1410
-    }
1408
+	if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1409
+		return $segments[0];
1410
+	}
1411 1411
 
1412
-    return false;
1412
+	return false;
1413 1413
 }
1414 1414
 
1415 1415
 function gd_wpml_slug_translation_turned_on($post_type) {
1416 1416
 
1417
-    global $sitepress;
1418
-    $settings = $sitepress->get_settings();
1419
-    return isset($settings['posts_slug_translation']['types'][$post_type])
1420
-    && $settings['posts_slug_translation']['types'][$post_type]
1421
-    && isset($settings['posts_slug_translation']['on'])
1422
-    && $settings['posts_slug_translation']['on'];
1417
+	global $sitepress;
1418
+	$settings = $sitepress->get_settings();
1419
+	return isset($settings['posts_slug_translation']['types'][$post_type])
1420
+	&& $settings['posts_slug_translation']['types'][$post_type]
1421
+	&& isset($settings['posts_slug_translation']['on'])
1422
+	&& $settings['posts_slug_translation']['on'];
1423 1423
 }
1424 1424
 
1425 1425
 
@@ -1446,158 +1446,158 @@  discard block
 block discarded – undo
1446 1446
  */
1447 1447
 function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample)
1448 1448
 {
1449
-    //echo $post_link."<br />".$sample ;
1449
+	//echo $post_link."<br />".$sample ;
1450 1450
 
1451 1451
 
1452
-    global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1453
-    if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1454
-    } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1455
-        return $post_link;
1456
-    } else {
1457
-        $orig_post = $post;
1458
-        $post = $post_obj;
1459
-    }
1452
+	global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1453
+	if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1454
+	} elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1455
+		return $post_link;
1456
+	} else {
1457
+		$orig_post = $post;
1458
+		$post = $post_obj;
1459
+	}
1460 1460
 
1461
-    if (in_array($post->post_type, geodir_get_posttypes())) {
1461
+	if (in_array($post->post_type, geodir_get_posttypes())) {
1462 1462
 
1463
-        // if we dont have a GD post then try to grab it
1464
-        if(!isset($post->default_category)){
1465
-            $gd_post = geodir_get_post_info($post->ID);
1466
-            if(!empty($gd_post)){
1467
-                $post = $gd_post;
1468
-            }
1469
-        }
1463
+		// if we dont have a GD post then try to grab it
1464
+		if(!isset($post->default_category)){
1465
+			$gd_post = geodir_get_post_info($post->ID);
1466
+			if(!empty($gd_post)){
1467
+				$post = $gd_post;
1468
+			}
1469
+		}
1470 1470
 
1471 1471
 
1472
-        $post_types = get_option('geodir_post_types');
1473
-        $slug = $post_types[$post->post_type]['rewrite']['slug'];
1472
+		$post_types = get_option('geodir_post_types');
1473
+		$slug = $post_types[$post->post_type]['rewrite']['slug'];
1474 1474
 
1475
-        // Alter the CPT slug if WPML is set to do so
1476
-        if(function_exists('icl_object_id')){
1477
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1475
+		// Alter the CPT slug if WPML is set to do so
1476
+		if(function_exists('icl_object_id')){
1477
+			if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1478 1478
 
1479
-                $org_slug = $slug;
1480
-                $slug = apply_filters( 'wpml_translate_single_string',
1481
-                    $slug,
1482
-                    'WordPress',
1483
-                    'URL slug: ' . $slug,
1484
-                    $language_code);
1479
+				$org_slug = $slug;
1480
+				$slug = apply_filters( 'wpml_translate_single_string',
1481
+					$slug,
1482
+					'WordPress',
1483
+					'URL slug: ' . $slug,
1484
+					$language_code);
1485 1485
 
1486
-                if(!$slug){$slug = $org_slug;}
1486
+				if(!$slug){$slug = $org_slug;}
1487 1487
 
1488
-            }
1489
-        }
1488
+			}
1489
+		}
1490 1490
 
1491
-        if (function_exists('geodir_location_geo_home_link')) {
1492
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1493
-        }
1491
+		if (function_exists('geodir_location_geo_home_link')) {
1492
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1493
+		}
1494 1494
         
1495
-        // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1496
-        $site_url = trailingslashit(get_bloginfo('url'));
1495
+		// Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1496
+		$site_url = trailingslashit(get_bloginfo('url'));
1497 1497
         
1498
-        if (function_exists('geodir_location_geo_home_link')) {
1499
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1500
-        }
1501
-
1502
-        $fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1503
-        if ($fix_url) {
1504
-            $post_link = str_replace($site_url, '', $post_link);
1505
-        }
1506
-
1507
-        $post_link = trailingslashit(
1508
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1509
-        );
1510
-
1511
-        if ($fix_url) {
1512
-            $post_link = $site_url . $post_link;
1513
-        }
1514
-
1515
-        if (isset($comment_post_cache[$post->ID])) {
1516
-            $post = $comment_post_cache[$post->ID];
1517
-        }
1518
-        if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1519
-            $post_id = $post->ID;
1520
-            if (isset($orig_post)) {
1521
-                $post = $orig_post;
1522
-            }
1523
-            return $gd_permalink_cache[$post_id];
1524
-        }
1498
+		if (function_exists('geodir_location_geo_home_link')) {
1499
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1500
+		}
1525 1501
 
1526
-        if (!isset($post->post_locations)) {
1527
-            $post_type = $post->post_type;
1528
-            $ID = $post->ID;
1529
-            $post2 = $wpdb->get_row(
1530
-                $wpdb->prepare(
1531
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1532
-                    array($post->ID)
1533
-                )
1534
-            );
1502
+		$fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1503
+		if ($fix_url) {
1504
+			$post_link = str_replace($site_url, '', $post_link);
1505
+		}
1535 1506
 
1536
-            $post = (object)array_merge((array)$post, (array)$post2);
1507
+		$post_link = trailingslashit(
1508
+			preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1509
+		);
1537 1510
 
1538
-            $comment_post_cache[$post->ID] = $post;
1539
-        }
1511
+		if ($fix_url) {
1512
+			$post_link = $site_url . $post_link;
1513
+		}
1540 1514
 
1515
+		if (isset($comment_post_cache[$post->ID])) {
1516
+			$post = $comment_post_cache[$post->ID];
1517
+		}
1518
+		if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1519
+			$post_id = $post->ID;
1520
+			if (isset($orig_post)) {
1521
+				$post = $orig_post;
1522
+			}
1523
+			return $gd_permalink_cache[$post_id];
1524
+		}
1541 1525
 
1526
+		if (!isset($post->post_locations)) {
1527
+			$post_type = $post->post_type;
1528
+			$ID = $post->ID;
1529
+			$post2 = $wpdb->get_row(
1530
+				$wpdb->prepare(
1531
+					"SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1532
+					array($post->ID)
1533
+				)
1534
+			);
1542 1535
 
1543
-        if (false !== strpos($post_link, '%gd_taxonomy%')) {
1536
+			$post = (object)array_merge((array)$post, (array)$post2);
1544 1537
 
1545
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1546
-                $location_request = '';
1538
+			$comment_post_cache[$post->ID] = $post;
1539
+		}
1547 1540
 
1548 1541
 
1549
-                if (!empty($post->post_locations)) {
1550
-                    $geodir_arr_locations = explode(',', $post->post_locations);
1551
-                    if (count($geodir_arr_locations) == 3) {
1552
-                        $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1553
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1554
-                        $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1555
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1556
-                        $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1557
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1558 1542
 
1559
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1560
-                            'region_slug' => $post->region_slug,
1561
-                            'city_slug' => $post->city_slug
1562
-                        );
1543
+		if (false !== strpos($post_link, '%gd_taxonomy%')) {
1563 1544
 
1564
-                    } else
1565
-                        $post_location = geodir_get_location();
1545
+			if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1546
+				$location_request = '';
1566 1547
 
1567 1548
 
1568
-                } else {
1549
+				if (!empty($post->post_locations)) {
1550
+					$geodir_arr_locations = explode(',', $post->post_locations);
1551
+					if (count($geodir_arr_locations) == 3) {
1552
+						$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1553
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1554
+						$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1555
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1556
+						$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1557
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1569 1558
 
1570
-                    $post_location_sql = $wpdb->get_results(
1571
-                        $wpdb->prepare(
1572
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1573
-                            array($post->ID)
1574
-                        )
1575
-                    );
1576
-
1577
-                    if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1578
-
1579
-                        $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1580
-                        if (count($geodir_arr_locations) == 3) {
1581
-                            $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1582
-                            $post->city_slug = str_replace(']', '', $post->city_slug);
1583
-                            $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1584
-                            $post->region_slug = str_replace(']', '', $post->region_slug);
1585
-                            $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1586
-                            $post->country_slug = str_replace(']', '', $post->country_slug);
1587
-
1588
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1589
-                                'region_slug' => $post->region_slug,
1590
-                                'city_slug' => $post->city_slug
1591
-                            );
1559
+						$post_location = (object)array('country_slug' => $post->country_slug,
1560
+							'region_slug' => $post->region_slug,
1561
+							'city_slug' => $post->city_slug
1562
+						);
1592 1563
 
1593
-                        }
1594
-                    } else
1595
-                        $post_location = geodir_get_location();
1596
-                }
1564
+					} else
1565
+						$post_location = geodir_get_location();
1597 1566
 
1598 1567
 
1599
-                if (!empty($post_location)) {
1600
-                    $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1568
+				} else {
1569
+
1570
+					$post_location_sql = $wpdb->get_results(
1571
+						$wpdb->prepare(
1572
+							"SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1573
+							array($post->ID)
1574
+						)
1575
+					);
1576
+
1577
+					if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1578
+
1579
+						$geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1580
+						if (count($geodir_arr_locations) == 3) {
1581
+							$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1582
+							$post->city_slug = str_replace(']', '', $post->city_slug);
1583
+							$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1584
+							$post->region_slug = str_replace(']', '', $post->region_slug);
1585
+							$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1586
+							$post->country_slug = str_replace(']', '', $post->country_slug);
1587
+
1588
+							$post_location = (object)array('country_slug' => $post->country_slug,
1589
+								'region_slug' => $post->region_slug,
1590
+								'city_slug' => $post->city_slug
1591
+							);
1592
+
1593
+						}
1594
+					} else
1595
+						$post_location = geodir_get_location();
1596
+				}
1597
+
1598
+
1599
+				if (!empty($post_location)) {
1600
+					$country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1601 1601
 					$region_slug = isset($post_location->region_slug) ? $post_location->region_slug : '';
1602 1602
 					$city_slug = isset($post_location->city_slug) ? $post_location->city_slug : '';
1603 1603
 					
@@ -1615,89 +1615,89 @@  discard block
 block discarded – undo
1615 1615
 					$location_slug[] = $city_slug;
1616 1616
 					
1617 1617
 					$location_request .= implode('/', $location_slug) . '/';
1618
-                }
1619
-            }
1618
+				}
1619
+			}
1620 1620
 
1621
-            if (get_option('geodir_add_categories_url')) {
1621
+			if (get_option('geodir_add_categories_url')) {
1622 1622
 
1623
-                $term_request = '';
1624
-                $taxonomies = geodir_get_taxonomies($post->post_type);
1623
+				$term_request = '';
1624
+				$taxonomies = geodir_get_taxonomies($post->post_type);
1625 1625
 
1626
-                $taxonomies = end($taxonomies);
1626
+				$taxonomies = end($taxonomies);
1627 1627
 
1628
-                if (!empty($post->default_category)) {
1629
-                    $post_terms = $post->default_category;
1630
-                } else {
1631
-                    $post_terms = '';
1632
-
1633
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1634
-                        $post_terms = absint($_POST['post_default_category']);
1635
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1636
-                        $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
1637
-                        $post_terms = absint($post_terms[0]);
1638
-                    }elseif (isset($post->{$taxonomies})) {
1639
-                        $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1640
-                        $post_terms = $post_terms[0];
1641
-                    }
1628
+				if (!empty($post->default_category)) {
1629
+					$post_terms = $post->default_category;
1630
+				} else {
1631
+					$post_terms = '';
1632
+
1633
+					if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1634
+						$post_terms = absint($_POST['post_default_category']);
1635
+					}elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1636
+						$post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
1637
+						$post_terms = absint($post_terms[0]);
1638
+					}elseif (isset($post->{$taxonomies})) {
1639
+						$post_terms = explode(",", trim($post->{$taxonomies}, ","));
1640
+						$post_terms = $post_terms[0];
1641
+					}
1642 1642
 
1643
-                    if (!$post_terms)
1644
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1643
+					if (!$post_terms)
1644
+						$post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1645 1645
 
1646
-                    if (!$post_terms) {
1647
-                        $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1646
+					if (!$post_terms) {
1647
+						$post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1648 1648
 
1649
-                        if ($post_terms) {
1650
-                            $post_terms = explode(",", trim($post_terms, ","));
1651
-                            $post_terms = $post_terms[0];
1652
-                        }
1653
-                    }
1654
-                }
1649
+						if ($post_terms) {
1650
+							$post_terms = explode(",", trim($post_terms, ","));
1651
+							$post_terms = $post_terms[0];
1652
+						}
1653
+					}
1654
+				}
1655 1655
 
1656
-                $term = get_term_by('id', $post_terms, $taxonomies);
1656
+				$term = get_term_by('id', $post_terms, $taxonomies);
1657 1657
 
1658
-                if (!empty($term))
1659
-                    $term_request = $term->slug;
1660
-                //$term_request = $term->slug.'/';
1661
-            }
1658
+				if (!empty($term))
1659
+					$term_request = $term->slug;
1660
+				//$term_request = $term->slug.'/';
1661
+			}
1662 1662
 
1663
-            $request_term = '';
1664
-            $listingurl_separator = '';
1665
-            //$detailurl_separator = get_option('geodir_detailurl_separator');
1666
-            $detailurl_separator = '';
1667
-            if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1668
-                $request_term = $location_request;
1669
-                //$listingurl_separator = get_option('geodir_listingurl_separator');
1670
-                //$request_term .= $listingurl_separator.'/'.$term_request;
1671
-                $request_term .= $term_request;
1663
+			$request_term = '';
1664
+			$listingurl_separator = '';
1665
+			//$detailurl_separator = get_option('geodir_detailurl_separator');
1666
+			$detailurl_separator = '';
1667
+			if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1668
+				$request_term = $location_request;
1669
+				//$listingurl_separator = get_option('geodir_listingurl_separator');
1670
+				//$request_term .= $listingurl_separator.'/'.$term_request;
1671
+				$request_term .= $term_request;
1672 1672
 
1673
-            } else {
1674
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1673
+			} else {
1674
+				if (isset($location_request) && $location_request != '') $request_term = $location_request;
1675 1675
 
1676
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1677
-            }
1678
-            $request_term = trim($request_term, '/');
1676
+				if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1677
+			}
1678
+			$request_term = trim($request_term, '/');
1679 1679
             
1680
-            // Fix with WPML the location terms added twice when CPT slug is translated.
1681
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1682
-                $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1683
-            }
1680
+			// Fix with WPML the location terms added twice when CPT slug is translated.
1681
+			if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1682
+				$post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1683
+			}
1684 1684
             
1685
-            if (!empty($request_term))
1686
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1687
-            else
1688
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1689
-            //echo $post_link ;
1690
-        }
1691
-        // temp cache the permalink
1692
-        if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1693
-            $gd_permalink_cache[$post->ID] = $post_link;
1694
-        }
1695
-    }
1696
-    if (isset($orig_post)) {
1697
-        $post = $orig_post;
1698
-    }
1699
-
1700
-    return $post_link;
1685
+			if (!empty($request_term))
1686
+				$post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1687
+			else
1688
+				$post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1689
+			//echo $post_link ;
1690
+		}
1691
+		// temp cache the permalink
1692
+		if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1693
+			$gd_permalink_cache[$post->ID] = $post_link;
1694
+		}
1695
+	}
1696
+	if (isset($orig_post)) {
1697
+		$post = $orig_post;
1698
+	}
1699
+
1700
+	return $post_link;
1701 1701
 }
1702 1702
 
1703 1703
 /**
@@ -1713,99 +1713,99 @@  discard block
 block discarded – undo
1713 1713
  * @return string The term link.
1714 1714
  */
1715 1715
 function geodir_term_link($termlink, $term, $taxonomy) {
1716
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1716
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1717 1717
 
1718
-    if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1719
-        global $geodir_add_location_url, $gd_session;
1720
-        $include_location = false;
1721
-        $request_term = array();
1722
-        $add_location_url = get_option('geodir_add_location_url');
1723
-        $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1718
+	if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1719
+		global $geodir_add_location_url, $gd_session;
1720
+		$include_location = false;
1721
+		$request_term = array();
1722
+		$add_location_url = get_option('geodir_add_location_url');
1723
+		$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1724 1724
 
1725
-        $listing_slug = geodir_get_listing_slug($taxonomy);
1725
+		$listing_slug = geodir_get_listing_slug($taxonomy);
1726 1726
 
1727
-        if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1728
-            if ($geodir_add_location_url && $add_location_url) {
1729
-                $include_location = true;
1730
-            }
1731
-        } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1732
-            $include_location = true;
1733
-        } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1734
-            $include_location = true;
1735
-        }
1736
-
1737
-        if ($include_location) {
1738
-            global $post;
1727
+		if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1728
+			if ($geodir_add_location_url && $add_location_url) {
1729
+				$include_location = true;
1730
+			}
1731
+		} elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1732
+			$include_location = true;
1733
+		} elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1734
+			$include_location = true;
1735
+		}
1736
+
1737
+		if ($include_location) {
1738
+			global $post;
1739 1739
             
1740
-            $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1740
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1741 1741
             
1742
-            if (geodir_is_page('detail') && isset($post->country_slug)) {
1743
-                $location_terms = array(
1744
-                    'gd_country' => $post->country_slug,
1745
-                    'gd_region' => $post->region_slug,
1746
-                    'gd_city' => $post->city_slug
1747
-                );
1742
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
1743
+				$location_terms = array(
1744
+					'gd_country' => $post->country_slug,
1745
+					'gd_region' => $post->region_slug,
1746
+					'gd_city' => $post->city_slug
1747
+				);
1748 1748
                 
1749
-                if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1750
-                    $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1751
-                }
1752
-            } else {
1753
-                $location_terms = geodir_get_current_location_terms('query_vars');
1754
-            }
1749
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1750
+					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1751
+				}
1752
+			} else {
1753
+				$location_terms = geodir_get_current_location_terms('query_vars');
1754
+			}
1755 1755
 
1756
-            $geodir_show_location_url = get_option('geodir_show_location_url');
1757
-            $location_terms = geodir_remove_location_terms($location_terms);
1756
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1757
+			$location_terms = geodir_remove_location_terms($location_terms);
1758 1758
 
1759
-            if (!empty($location_terms)) {
1760
-                $url_separator = '';
1759
+			if (!empty($location_terms)) {
1760
+				$url_separator = '';
1761 1761
 
1762
-                if (get_option('permalink_structure') != '') {
1763
-                    $old_listing_slug = '/' . $listing_slug . '/';
1764
-                    $request_term = implode("/", $location_terms);
1765
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1762
+				if (get_option('permalink_structure') != '') {
1763
+					$old_listing_slug = '/' . $listing_slug . '/';
1764
+					$request_term = implode("/", $location_terms);
1765
+					$new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1766 1766
 
1767
-                    $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1768
-                } else {
1769
-                    $termlink = geodir_getlink($termlink, $request_term);
1770
-                }
1771
-            }
1772
-        }
1767
+					$termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1768
+				} else {
1769
+					$termlink = geodir_getlink($termlink, $request_term);
1770
+				}
1771
+			}
1772
+		}
1773 1773
 
1774
-        // Alter the CPT slug is WPML is set to do so
1775
-        /* we can replace this with the below function
1774
+		// Alter the CPT slug is WPML is set to do so
1775
+		/* we can replace this with the below function
1776 1776
         if(function_exists('icl_object_id')){
1777 1777
             global $sitepress;
1778 1778
             $post_type = str_replace("category","",$taxonomy);
1779 1779
             $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type);
1780 1780
         }*/
1781 1781
 
1782
-        // Alter the CPT slug if WPML is set to do so
1783
-        if (function_exists('icl_object_id')) {
1784
-            $post_types = get_option('geodir_post_types');
1785
-            $post_type = str_replace("category","",$taxonomy);
1786
-            $post_type = str_replace("_tags","",$post_type);
1787
-            $slug = $post_types[$post_type]['rewrite']['slug'];
1788
-            if (gd_wpml_slug_translation_turned_on($post_type)) {
1789
-                global $sitepress;
1790
-                $default_lang = $sitepress->get_default_language();
1791
-                $language_code = gd_wpml_get_lang_from_url($termlink);
1792
-                if (!$language_code ) {
1793
-                    $language_code  = $default_lang;
1794
-                }
1782
+		// Alter the CPT slug if WPML is set to do so
1783
+		if (function_exists('icl_object_id')) {
1784
+			$post_types = get_option('geodir_post_types');
1785
+			$post_type = str_replace("category","",$taxonomy);
1786
+			$post_type = str_replace("_tags","",$post_type);
1787
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1788
+			if (gd_wpml_slug_translation_turned_on($post_type)) {
1789
+				global $sitepress;
1790
+				$default_lang = $sitepress->get_default_language();
1791
+				$language_code = gd_wpml_get_lang_from_url($termlink);
1792
+				if (!$language_code ) {
1793
+					$language_code  = $default_lang;
1794
+				}
1795 1795
 
1796
-                $org_slug = $slug;
1797
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1796
+				$org_slug = $slug;
1797
+				$slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1798 1798
 
1799
-                if (!$slug) {
1800
-                    $slug = $org_slug;
1801
-                }
1799
+				if (!$slug) {
1800
+					$slug = $org_slug;
1801
+				}
1802 1802
 
1803
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1804
-            }
1805
-        }
1806
-    }
1803
+				$termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1804
+			}
1805
+		}
1806
+	}
1807 1807
     
1808
-    return $termlink;
1808
+	return $termlink;
1809 1809
 }
1810 1810
 
1811 1811
 /**
@@ -1831,14 +1831,14 @@  discard block
 block discarded – undo
1831 1831
 	if (in_array($post_type, geodir_get_posttypes())) {
1832 1832
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1833 1833
 			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1834
-                $location_terms = array(
1835
-                    'gd_country' => $post->country_slug,
1836
-                    'gd_region' => $post->region_slug,
1837
-                    'gd_city' => $post->city_slug
1838
-                );
1839
-            } else {
1840
-                $location_terms = geodir_get_current_location_terms('query_vars');
1841
-            }
1834
+				$location_terms = array(
1835
+					'gd_country' => $post->country_slug,
1836
+					'gd_region' => $post->region_slug,
1837
+					'gd_city' => $post->city_slug
1838
+				);
1839
+			} else {
1840
+				$location_terms = geodir_get_current_location_terms('query_vars');
1841
+			}
1842 1842
 			
1843 1843
 			$location_terms = geodir_remove_location_terms($location_terms);
1844 1844
 			
@@ -1870,17 +1870,17 @@  discard block
 block discarded – undo
1870 1870
  * @return void|string Label.
1871 1871
  */
1872 1872
 function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
1873
-    $obj_post_type = get_post_type_object($post_type);
1874
-    if (!is_object($obj_post_type)) {
1875
-        return;
1876
-    }
1873
+	$obj_post_type = get_post_type_object($post_type);
1874
+	if (!is_object($obj_post_type)) {
1875
+		return;
1876
+	}
1877 1877
     
1878
-    $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1878
+	$label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1879 1879
     
1880
-    if ($echo)
1881
-        echo $label;
1882
-    else
1883
-        return $label;
1880
+	if ($echo)
1881
+		echo $label;
1882
+	else
1883
+		return $label;
1884 1884
 }
1885 1885
 
1886 1886
 /**
@@ -1895,19 +1895,19 @@  discard block
 block discarded – undo
1895 1895
  * @return void|string Label.
1896 1896
  */
1897 1897
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1898
-    $all_postypes = geodir_get_posttypes();
1898
+	$all_postypes = geodir_get_posttypes();
1899 1899
 
1900
-    if (!in_array($post_type, $all_postypes))
1901
-        return false;
1900
+	if (!in_array($post_type, $all_postypes))
1901
+		return false;
1902 1902
 
1903
-    $obj_post_type = get_post_type_object($post_type);
1903
+	$obj_post_type = get_post_type_object($post_type);
1904 1904
     
1905
-    $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1905
+	$label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1906 1906
     
1907
-    if ($echo)
1908
-        echo $label;
1909
-    else
1910
-        return $label;
1907
+	if ($echo)
1908
+		echo $label;
1909
+	else
1910
+		return $label;
1911 1911
 }
1912 1912
 
1913 1913
 /**
@@ -1925,51 +1925,51 @@  discard block
 block discarded – undo
1925 1925
  */
1926 1926
 function geodir_term_exists($term, $taxonomy = '', $parent = 0)
1927 1927
 {
1928
-    global $wpdb;
1929
-
1930
-    $select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1931
-    $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1932
-
1933
-    if (is_int($term)) {
1934
-        if (0 == $term)
1935
-            return 0;
1936
-        $where = 't.term_id = %d';
1937
-        if (!empty($taxonomy))
1938
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1939
-        else
1940
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1941
-    }
1928
+	global $wpdb;
1929
+
1930
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1931
+	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1932
+
1933
+	if (is_int($term)) {
1934
+		if (0 == $term)
1935
+			return 0;
1936
+		$where = 't.term_id = %d';
1937
+		if (!empty($taxonomy))
1938
+			return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1939
+		else
1940
+			return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1941
+	}
1942 1942
 
1943
-    $term = trim(wp_unslash($term));
1943
+	$term = trim(wp_unslash($term));
1944 1944
 
1945
-    if ('' === $slug = sanitize_title($term))
1946
-        return 0;
1945
+	if ('' === $slug = sanitize_title($term))
1946
+		return 0;
1947 1947
 
1948
-    $where = 't.slug = %s';
1948
+	$where = 't.slug = %s';
1949 1949
 
1950
-    $where_fields = array($slug);
1951
-    if (!empty($taxonomy)) {
1952
-        $parent = (int)$parent;
1953
-        if ($parent > 0) {
1954
-            $where_fields[] = $parent;
1955
-            $else_where_fields[] = $parent;
1956
-            $where .= ' AND tt.parent = %d';
1950
+	$where_fields = array($slug);
1951
+	if (!empty($taxonomy)) {
1952
+		$parent = (int)$parent;
1953
+		if ($parent > 0) {
1954
+			$where_fields[] = $parent;
1955
+			$else_where_fields[] = $parent;
1956
+			$where .= ' AND tt.parent = %d';
1957 1957
 
1958
-        }
1958
+		}
1959 1959
 
1960
-        $where_fields[] = $taxonomy;
1960
+		$where_fields[] = $taxonomy;
1961 1961
 
1962 1962
 
1963
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1964
-            return $result;
1963
+		if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1964
+			return $result;
1965 1965
 
1966
-        return false;
1967
-    }
1966
+		return false;
1967
+	}
1968 1968
 
1969
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1970
-        return $result;
1969
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1970
+		return $result;
1971 1971
 
1972
-    return false;
1972
+	return false;
1973 1973
 }
1974 1974
 
1975 1975
 /**
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 function geodir_get_term_icon_rebuild()
1982 1982
 {
1983 1983
 
1984
-    update_option('gd_term_icons', '');
1984
+	update_option('gd_term_icons', '');
1985 1985
 
1986 1986
 }
1987 1987
 
@@ -1999,61 +1999,61 @@  discard block
 block discarded – undo
1999 1999
  */
2000 2000
 function geodir_get_term_icon($term_id = false, $rebuild = false)
2001 2001
 {
2002
-    global $wpdb;
2003
-    if (!$rebuild) {
2004
-        $terms_icons = get_option('gd_term_icons');
2005
-    } else {
2006
-        $terms_icons = array();
2007
-    }
2008
-
2009
-    if (empty($terms_icons)) {
2010
-        $terms_icons = array();
2011
-        $default_icon_url = get_option('geodir_default_marker_icon');
2012
-        $taxonomy = geodir_get_taxonomies();
2013
-        $post_types = geodir_get_posttypes();
2014
-        $tax_arr = array();
2015
-        foreach ($post_types as $post_type) {
2016
-            $tax_arr[] = "'" . $post_type . "category'";
2017
-        }
2018
-        $tax_c = implode(',', $tax_arr);
2019
-        $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2020
-        //$terms = get_terms( $taxonomy );
2021
-
2022
-        if($terms) {
2023
-            foreach ($terms as $term) {
2024
-                $post_type = str_replace("category", "", $term->taxonomy);
2025
-                $a_terms[$post_type][] = $term;
2002
+	global $wpdb;
2003
+	if (!$rebuild) {
2004
+		$terms_icons = get_option('gd_term_icons');
2005
+	} else {
2006
+		$terms_icons = array();
2007
+	}
2026 2008
 
2027
-            }
2028
-        }
2009
+	if (empty($terms_icons)) {
2010
+		$terms_icons = array();
2011
+		$default_icon_url = get_option('geodir_default_marker_icon');
2012
+		$taxonomy = geodir_get_taxonomies();
2013
+		$post_types = geodir_get_posttypes();
2014
+		$tax_arr = array();
2015
+		foreach ($post_types as $post_type) {
2016
+			$tax_arr[] = "'" . $post_type . "category'";
2017
+		}
2018
+		$tax_c = implode(',', $tax_arr);
2019
+		$terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2020
+		//$terms = get_terms( $taxonomy );
2029 2021
 
2030
-        if($a_terms) {
2031
-            foreach ($a_terms as $pt => $t2) {
2022
+		if($terms) {
2023
+			foreach ($terms as $term) {
2024
+				$post_type = str_replace("category", "", $term->taxonomy);
2025
+				$a_terms[$post_type][] = $term;
2032 2026
 
2033
-                foreach ($t2 as $term) {
2034
-                    $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2035
-                    if ($term_icon) {
2036
-                        $term_icon_url = $term_icon["src"];
2037
-                    } else {
2038
-                        $term_icon_url = $default_icon_url;
2039
-                    }
2040
-                    $terms_icons[$term->term_id] = $term_icon_url;
2041
-                }
2042
-            }
2043
-        }
2027
+			}
2028
+		}
2044 2029
 
2045
-        update_option('gd_term_icons', $terms_icons);
2046
-    }
2030
+		if($a_terms) {
2031
+			foreach ($a_terms as $pt => $t2) {
2047 2032
 
2048
-    if ($term_id && isset($terms_icons[$term_id])) {
2049
-        return $terms_icons[$term_id];
2050
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2051
-        return get_option('geodir_default_marker_icon');
2052
-    }
2033
+				foreach ($t2 as $term) {
2034
+					$term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2035
+					if ($term_icon) {
2036
+						$term_icon_url = $term_icon["src"];
2037
+					} else {
2038
+						$term_icon_url = $default_icon_url;
2039
+					}
2040
+					$terms_icons[$term->term_id] = $term_icon_url;
2041
+				}
2042
+			}
2043
+		}
2044
+
2045
+		update_option('gd_term_icons', $terms_icons);
2046
+	}
2053 2047
 
2054
-    if (is_ssl()) {
2055
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2056
-    }
2048
+	if ($term_id && isset($terms_icons[$term_id])) {
2049
+		return $terms_icons[$term_id];
2050
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2051
+		return get_option('geodir_default_marker_icon');
2052
+	}
2053
+
2054
+	if (is_ssl()) {
2055
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2056
+	}
2057 2057
 
2058
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2058
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2059 2059
 }
2060 2060
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
                              * @since 1.0.0
61 61
                              * @param string $menu_class The menu HTML class.
62 62
                              */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
63
+                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
64 64
                             /**
65 65
                              * Filter the menu a class.
66 66
                              *
67 67
                              * @since 1.0.0
68 68
                              */
69 69
                             $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
71
-									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72
-										' . __(ucfirst($args->labels->name),'geodirectory') . '
70
+                            $items .= '<li class="'.$li_class.'">
71
+									<a href="' . get_post_type_archive_link($post_type).'" class="'.$a_class.'">
72
+										' . __(ucfirst($args->labels->name), 'geodirectory').'
73 73
 									</a>
74 74
 								</li>';
75 75
                         }
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
              * @since 1.0.0
89 89
              * @param string $menu_class The menu HTML class.
90 90
              */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
91
+            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings '.$menu_class);
92 92
             /**
93 93
              * Filter the sub menu li class.
94 94
              *
95 95
              * @since 1.0.0
96 96
              * @param string $menu_class The menu HTML class.
97 97
              */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
98
+            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
99 99
             /**
100 100
              * Filter the sub menu ul class.
101 101
              *
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
              * @since 1.0.0
115 115
              */
116 116
             $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
118
-					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119
-					<ul class="' . $sub_ul_class . '">';
117
+            $items .= '<li class="'.$li_class.'">
118
+					<a href="#" class="' . $a_class.'">'.__('Listing', 'geodirectory').'</a>
119
+					<ul class="' . $sub_ul_class.'">';
120 120
             $post_types = geodir_get_posttypes('object');
121 121
 
122 122
             $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
                                 if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134 134
                                     $menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
137
-														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138
-															' . __(ucfirst($args->labels->name),'geodirectory') . '
136
+                                $items .= '<li class="'.$sub_li_class.'">
137
+														<a href="' . get_post_type_archive_link($post_type).'" class="'.$sub_a_class.'">
138
+															' . __(ucfirst($args->labels->name), 'geodirectory').'
139 139
 														</a>
140 140
 													</li>';
141 141
                             }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
              *
152 152
              * @since 1.5.9
153 153
              */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
154
+            $items .= apply_filters('geodir_menu_after_sub_ul', '');
155 155
             $items .= '</li>';
156 156
         }
157 157
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                                      * @since 1.0.0
185 185
                                      * @param string $menu_class The menu HTML class.
186 186
                                      */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
187
+                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
188 188
                                     /**
189 189
                                      * Filter the menu a class.
190 190
                                      *
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
                                      */
193 193
                                     $a_class = apply_filters('geodir_menu_a_class', '');
194 194
                                     $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
196
-											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197
-												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
195
+                                    $items .= '<li class="'.$li_class.'">
196
+											<a href="' . geodir_get_addlisting_link($post_type).'" class="'.$a_class.'">
197
+												' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
198 198
 											</a>
199 199
 										</li>';
200 200
                                 }
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
              * @since 1.0.0
219 219
              * @param string $menu_class The menu HTML class.
220 220
              */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
221
+            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing '.$menu_class);
222 222
             /**
223 223
              * Filter the sub menu li class.
224 224
              *
225 225
              * @since 1.0.0
226 226
              * @param string $menu_class The menu HTML class.
227 227
              */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
228
+            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
229 229
             /**
230 230
              * Filter the sub menu ul class.
231 231
              *
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
              * @since 1.0.0
245 245
              */
246 246
             $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
248
-					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249
-					<ul class="' . $sub_ul_class . '">';
247
+            $items .= '<li  class="'.$li_class.'">
248
+					<a href="#" class="' . $a_class.'">'.__('Add Listing', 'geodirectory').'</a>
249
+					<ul class="' . $sub_ul_class.'">';
250 250
 
251 251
             $post_types = geodir_get_posttypes('object');
252 252
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
                                          * @since 1.0.0
270 270
                                          * @param string $menu_class The menu HTML class.
271 271
                                          */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
272
+                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
273 273
                                         $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $li_class . '">
275
-														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276
-															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
274
+                                        $items .= '<li class="'.$li_class.'">
275
+														<a href="' . geodir_get_addlisting_link($post_type).'" class="'.$sub_a_class.'">
276
+															' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
277 277
 														</a>
278 278
 													</li>';
279 279
                                     }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             }
286 286
 
287 287
             $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
288
+            $items .= apply_filters('geodir_menu_after_sub_ul', '');
289 289
             $items .= '</li>';
290 290
 
291 291
         }
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
     $geodir_theme_location = get_option('geodir_theme_location_nav');
314 314
     $geodir_theme_location_nav = array();
315 315
     if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
316
+        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
317 317
         $geodir_theme_location_nav[] = $args['theme_location'];
318 318
         update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319 319
     }
320 320
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322 322
     else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
323
+        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
324 324
 
325 325
     return $menu;
326 326
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
     if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
351
+        $items = $items.geodir_add_nav_menu_items();
352 352
         return $items;
353 353
 
354 354
     } else {
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
 
374 374
     $taxonomies = geodir_get_taxonomies();
375 375
     $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
376
+    $taxonomies = "'".$taxonomies."'";
377 377
 
378 378
     $pn_categories = $wpdb->get_results(
379 379
         $wpdb->prepare(
380 380
             "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
381
+            array($wpdb->terms.term_id)
382 382
         )
383 383
     );
384 384
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
409 409
         if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
410
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
410
+            $geodir_post_type = get_post_type((int) $_REQUEST['pid']);
411 411
         elseif (isset($_REQUEST['listing_type']))
412 412
             $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
413 413
     }
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
     if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
426 426
         $geodir_post_type = '';
427 427
 
428
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
428
+    if (defined('DOING_AJAX') && isset($_REQUEST['stype'])) {
429 429
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
430 430
     }
431 431
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
      *
436 436
      * @since 1.6.9
437 437
      */
438
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
438
+    return apply_filters('geodir_get_current_posttype', $geodir_post_type);
439 439
 }
440 440
 
441 441
 /**
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
  */
450 450
 function geodir_get_default_posttype()
451 451
 {
452
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
452
+    $post_types = apply_filters('geodir_get_default_posttype', geodir_get_posttypes('object'));
453 453
 
454 454
     $stype = false;
455
-    foreach ( $post_types as $post_type => $info ) {
455
+    foreach ($post_types as $post_type => $info) {
456 456
         global $wpdb;
457
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
458
-        if ( $has_posts ) {
457
+        $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
458
+        if ($has_posts) {
459 459
             $stype = $post_type; break;
460 460
         }
461 461
     }
462 462
 
463
-    if(!$stype){
463
+    if (!$stype) {
464 464
         $stype = 'gd_place';
465 465
     }
466 466
 
@@ -485,14 +485,14 @@  discard block
 block discarded – undo
485 485
         switch ($output):
486 486
             case 'object':
487 487
             case 'Object':
488
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
488
+                $post_types = json_decode(json_encode($post_types), FALSE); //(object)$post_types;
489 489
                 break;
490 490
             case 'array':
491 491
             case 'Array':
492
-                $post_types = (array)$post_types;
492
+                $post_types = (array) $post_types;
493 493
                 break;
494 494
 			case 'options':
495
-                $post_types = (array)$post_types;
495
+                $post_types = (array) $post_types;
496 496
 				
497 497
 				$options = array();
498 498
 				if (!empty($post_types)) {
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
 
611 611
         $categories = get_terms($taxonomies);
612 612
 
613
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
613
+        $html .= '<option value="0">'.__('All', 'geodirectory').'</option>';
614 614
 
615 615
         foreach ($categories as $category_obj) {
616 616
             $select_opt = '';
617 617
             if ($selected == $category_obj->term_id) {
618 618
                 $select_opt = 'selected="selected"';
619 619
             }
620
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
621
-                . ucfirst($category_obj->name) . '</option>';
620
+            $html .= '<option '.$select_opt.' value="'.$category_obj->term_id.'">'
621
+                . ucfirst($category_obj->name).'</option>';
622 622
         }
623 623
 
624 624
         if ($echo)
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     } elseif (isset($wp_query->tax_query->queries)) {
687 687
         $tax_arr = $wp_query->tax_query->queries;
688 688
         //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
689
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
689
+        if (isset($tax_arr['relation'])) {unset($tax_arr['relation']); }
690 690
         $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
691 691
     }
692 692
 
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 
741 741
             if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
742 742
                 if ($cat_parent == 0) {
743
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
743
+                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-'.$cat_display;
744 744
                     $main_list_class = 'class="main_list_selecter"';
745 745
                 } else {
746 746
                     //$display = 'display:none';
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 
751 751
             if ($cat_display == 'checkbox' || $cat_display == 'radio') {
752 752
                 $p = 0;
753
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
753
+                $out = '<div class="'.$list_class.' gd-cat-row-'.$cat_parent.'" style="margin-left:'.$p.'px;'.$display.';">';
754 754
             }
755 755
 
756 756
             foreach ($cat_terms as $cat_term) {
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
                 }
766 766
 
767 767
                 if ($cat_display == 'radio')
768
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
768
+                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.ucfirst($cat_term->name).'</span>';
769 769
                 elseif ($cat_display == 'select' || $cat_display == 'multiselect')
770
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>';
770
+                    $out .= '<option '.$main_list_class.' style="margin-left:'.$p.'px;" alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' >'.$term_check.ucfirst($cat_term->name).'</option>';
771 771
 
772 772
                 else {
773
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
773
+                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.ucfirst($cat_term->name).'</span>';
774 774
                 }
775 775
 
776 776
                 // Call recurson to print sub cats
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
             $cat_exclude = serialize($exclude_cats);
810 810
 
811 811
         if (isset($_REQUEST['backandedit'])) {
812
-            $post = (object)$gd_session->get('listing');
812
+            $post = (object) $gd_session->get('listing');
813 813
 
814 814
             if (!is_array($post->post_category[$cat_taxonomy]))
815 815
                 $post_category = $post->post_category[$cat_taxonomy];
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 
842 842
             if (!empty($post_category)) {
843 843
                 $cat1 = array_filter(explode(',', $post_category));
844
-                $post_category = ',' . implode(',', $cat1) . ',';
844
+                $post_category = ','.implode(',', $cat1).',';
845 845
 
846 846
             }
847 847
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
                 foreach ($post_category_upd as $cat) {
853 853
 
854 854
                     if (!in_array($cat, $exclude_cats) && $cat != '') {
855
-                        $post_category_change .= ',' . $cat;
855
+                        $post_category_change .= ','.$cat;
856 856
                     }
857 857
                 }
858 858
                 $post_category = $post_category_change;
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
             }
865 865
         }
866 866
 
867
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
867
+        echo '<input type="hidden" id="cat_limit" value="'.$cat_limit.'" name="cat_limit['.$cat_taxonomy.']"  />';
868 868
 
869
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
869
+        echo '<input type="hidden" id="post_category" value="'.$post_category.'" name="post_category['.$cat_taxonomy.']"  />';
870 870
 
871
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
871
+        echo '<input type="hidden" id="post_category_str" value="'.$post_category_str.'" name="post_category_str['.$cat_taxonomy.']"  />';
872 872
 
873 873
 
874 874
         ?>
@@ -887,14 +887,14 @@  discard block
 block discarded – undo
887 887
 
888 888
             function show_subcatlist(main_cat, catObj) {
889 889
                 if (main_cat != '') {
890
-					var url = '<?php echo geodir_get_ajax_url();?>';
891
-                    var cat_taxonomy = '<?php echo $cat_taxonomy;?>';
892
-                    var cat_exclude = '<?php echo base64_encode($cat_exclude);?>';
890
+					var url = '<?php echo geodir_get_ajax_url(); ?>';
891
+                    var cat_taxonomy = '<?php echo $cat_taxonomy; ?>';
892
+                    var cat_exclude = '<?php echo base64_encode($cat_exclude); ?>';
893 893
                     var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val();
894
-					<?php if ((int)$cat_limit > 0) { ?>
894
+					<?php if ((int) $cat_limit > 0) { ?>
895 895
 					var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length);
896 896
 					if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) {
897
-						alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int)$cat_limit));?>");
897
+						alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int) $cat_limit)); ?>");
898 898
 						return false;
899 899
 					}
900 900
 					<?php } ?>
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
             }
934 934
 
935 935
             function update_listing_cat(el) {
936
-                var cat_taxonomy = '<?php echo $cat_taxonomy;?>';
936
+                var cat_taxonomy = '<?php echo $cat_taxonomy; ?>';
937 937
                 var cat_ids = '';
938 938
                 var main_cat = '';
939 939
                 var sub_cat = '';
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1015 1015
             echo $style;
1016 1016
         }?> ">
1017
-            <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1017
+            <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list
1018 1018
             ?>
1019 1019
         </div>
1020 1020
     <?php
@@ -1041,9 +1041,9 @@  discard block
 block discarded – undo
1041 1041
     if ($exclude != '') {
1042 1042
         $exclude_cats = maybe_unserialize(base64_decode($exclude));
1043 1043
 
1044
-        if(is_array( $exclude_cats)){
1045
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1046
-        }else{
1044
+        if (is_array($exclude_cats)) {
1045
+            $exclude_cats = array_map('intval', $exclude_cats);
1046
+        } else {
1047 1047
             $exclude_cats = intval($exclude_cats);
1048 1048
         }
1049 1049
 
@@ -1057,25 +1057,25 @@  discard block
 block discarded – undo
1057 1057
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1058 1058
 
1059 1059
         <div class="post_catlist_item" style="border:1px solid #CCCCCC; margin:5px auto; padding:5px;">
1060
-            <img alt="move icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/move.png';?>"
1060
+            <img alt="move icon" src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png'; ?>"
1061 1061
                  onclick="jQuery(this).closest('div').remove();update_listing_cat(this);" align="right"/>
1062 1062
             <?php /* ?>
1063 1063
 		<img src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png';?>" onclick="jQuery(this).closest('div').remove();show_subcatlist();" align="right" /> 
1064 1064
 		<?php */ ?>
1065 1065
 
1066
-            <input type="checkbox" value="<?php echo $main_cat->term_id;?>" class="listing_main_cat"
1066
+            <input type="checkbox" value="<?php echo $main_cat->term_id; ?>" class="listing_main_cat"
1067 1067
                    onchange="if(jQuery(this).is(':checked')){jQuery(this).closest('div').find('.post_default_category').prop('checked',false).show();}else{jQuery(this).closest('div').find('.post_default_category').prop('checked',false).hide();};update_listing_cat()"
1068 1068
                    checked="checked" disabled="disabled"/>
1069 1069
        <span> 
1070
-        <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1070
+        <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
1071 1071
         </span>
1072 1072
             <br/>
1073 1073
 
1074 1074
             <div class="post_default_category">
1075
-                <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1076
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1075
+                <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id; ?>"
1076
+                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" '; ?>   />
1077 1077
         <span> 
1078
-        <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1078
+        <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
1079 1079
         </span>
1080 1080
             </div>
1081 1081
 
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
         $post_cat_str = $post_categories[$request_taxonomy];
1109 1109
         $post_cat_array = explode("#", $post_cat_str);
1110 1110
         if (is_array($post_cat_array)) {
1111
-            $post_cat_array = array_unique( $post_cat_array );
1111
+            $post_cat_array = array_unique($post_cat_array);
1112 1112
 
1113 1113
 			foreach ($post_cat_array as $post_cat_html) {
1114 1114
 
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
                 }
1124 1124
                 $post_sub_catid = '';
1125 1125
                 if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1126
-                    $post_sub_catid = (int)$post_cat_info[1];
1126
+                    $post_sub_catid = (int) $post_cat_info[1];
1127 1127
                 }
1128 1128
 
1129 1129
                 geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
             }
1145 1145
 
1146 1146
             if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1147
-                $post_sub_catid = (int)$post_cat_info[1];
1147
+                $post_sub_catid = (int) $post_cat_info[1];
1148 1148
             }
1149 1149
 
1150 1150
             geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
@@ -1176,9 +1176,9 @@  discard block
 block discarded – undo
1176 1176
         if (!$selected)
1177 1177
             $option_slected = ' selected="selected" ';
1178 1178
 
1179
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1179
+        echo '<select field_type="select" id="'.sanitize_text_field($cat_taxonomy).'" class="chosen_select" '.$onchange.' option-ajaxChosen="false" >';
1180 1180
 
1181
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1181
+        echo '<option value="" '.$option_selected.' >'.__('Select Category', 'geodirectory').'</option>';
1182 1182
 
1183 1183
         foreach ($cat_terms as $cat_term) {
1184 1184
             $option_selected = '';
@@ -1186,10 +1186,10 @@  discard block
 block discarded – undo
1186 1186
                 $option_selected = ' selected="selected" ';
1187 1187
 
1188 1188
             // Count child terms
1189
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1190
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1189
+            $child_terms = get_terms($cat_taxonomy, array('parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1));
1190
+            $has_child = !empty($child_terms) ? 't' : 'f';
1191 1191
 
1192
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>';
1192
+            echo '<option  '.$option_selected.' alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" _hc="'.$has_child.'" >'.ucfirst($cat_term->name).'</option>';
1193 1193
         }
1194 1194
         echo '</select>';
1195 1195
     }
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
             2 => __('Custom field updated.', 'geodirectory'),
1221 1221
             3 => __('Custom field deleted.', 'geodirectory'),
1222 1222
             4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1223
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1223
+            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false,
1224 1224
             6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1225 1225
             7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1226 1226
             8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 
1247 1247
     global $wpdb;
1248 1248
 
1249
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1249
+    $menu_icon = geodir_plugin_url().'/geodirectory-assets/images/favicon.ico';
1250 1250
 
1251 1251
     if (!$listing_slug = get_option('geodir_listing_prefix'))
1252 1252
         $listing_slug = 'places';
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
 
1260 1260
         $gd_placetags = array();
1261 1261
         $gd_placetags['object_type'] = 'gd_place';
1262
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1262
+        $gd_placetags['listing_slug'] = $listing_slug.'/tags';
1263 1263
         $gd_placetags['args'] = array(
1264 1264
             'public' => true,
1265 1265
             'hierarchical' => false,
1266
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1266
+            'rewrite' => array('slug' => $listing_slug.'/tags', 'with_front' => false, 'hierarchical' => true),
1267 1267
             'query_var' => true,
1268 1268
 
1269 1269
             'labels' => array(
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
             'menu_icon' => $menu_icon,
1358 1358
             'public' => true,
1359 1359
             'query_var' => true,
1360
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1360
+            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1361 1361
             'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1362 1362
             'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1363 1363
 
@@ -1390,12 +1390,12 @@  discard block
 block discarded – undo
1390 1390
         return $_REQUEST['lang'];
1391 1391
     }
1392 1392
 
1393
-    $url = str_replace(array("http://","https://"),"",$url);
1393
+    $url = str_replace(array("http://", "https://"), "", $url);
1394 1394
 
1395 1395
     // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1396
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1396
+    $site_url = str_replace(array("http://", "https://"), "", site_url());
1397 1397
 
1398
-    $url = str_replace($site_url,"",$url);
1398
+    $url = str_replace($site_url, "", $url);
1399 1399
 
1400 1400
     $segments = explode('/', trim($url, '/'));
1401 1401
 
@@ -1461,9 +1461,9 @@  discard block
 block discarded – undo
1461 1461
     if (in_array($post->post_type, geodir_get_posttypes())) {
1462 1462
 
1463 1463
         // if we dont have a GD post then try to grab it
1464
-        if(!isset($post->default_category)){
1464
+        if (!isset($post->default_category)) {
1465 1465
             $gd_post = geodir_get_post_info($post->ID);
1466
-            if(!empty($gd_post)){
1466
+            if (!empty($gd_post)) {
1467 1467
                 $post = $gd_post;
1468 1468
             }
1469 1469
         }
@@ -1473,17 +1473,17 @@  discard block
 block discarded – undo
1473 1473
         $slug = $post_types[$post->post_type]['rewrite']['slug'];
1474 1474
 
1475 1475
         // Alter the CPT slug if WPML is set to do so
1476
-        if(function_exists('icl_object_id')){
1477
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1476
+        if (function_exists('icl_object_id')) {
1477
+            if (gd_wpml_slug_translation_turned_on($post->post_type) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1478 1478
 
1479 1479
                 $org_slug = $slug;
1480
-                $slug = apply_filters( 'wpml_translate_single_string',
1480
+                $slug = apply_filters('wpml_translate_single_string',
1481 1481
                     $slug,
1482 1482
                     'WordPress',
1483
-                    'URL slug: ' . $slug,
1483
+                    'URL slug: '.$slug,
1484 1484
                     $language_code);
1485 1485
 
1486
-                if(!$slug){$slug = $org_slug;}
1486
+                if (!$slug) {$slug = $org_slug; }
1487 1487
 
1488 1488
             }
1489 1489
         }
@@ -1505,11 +1505,11 @@  discard block
 block discarded – undo
1505 1505
         }
1506 1506
 
1507 1507
         $post_link = trailingslashit(
1508
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1508
+            preg_replace("/".preg_quote($slug, "/")."/", $slug."/%gd_taxonomy%", $post_link, 1)
1509 1509
         );
1510 1510
 
1511 1511
         if ($fix_url) {
1512
-            $post_link = $site_url . $post_link;
1512
+            $post_link = $site_url.$post_link;
1513 1513
         }
1514 1514
 
1515 1515
         if (isset($comment_post_cache[$post->ID])) {
@@ -1528,12 +1528,12 @@  discard block
 block discarded – undo
1528 1528
             $ID = $post->ID;
1529 1529
             $post2 = $wpdb->get_row(
1530 1530
                 $wpdb->prepare(
1531
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1531
+                    "SELECT * from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ",
1532 1532
                     array($post->ID)
1533 1533
                 )
1534 1534
             );
1535 1535
 
1536
-            $post = (object)array_merge((array)$post, (array)$post2);
1536
+            $post = (object) array_merge((array) $post, (array) $post2);
1537 1537
 
1538 1538
             $comment_post_cache[$post->ID] = $post;
1539 1539
         }
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 
1543 1543
         if (false !== strpos($post_link, '%gd_taxonomy%')) {
1544 1544
 
1545
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1545
+            if (apply_filters("geodir_add_location_url_to_url", get_option('geodir_add_location_url'), $post->post_type, $post)) {
1546 1546
                 $location_request = '';
1547 1547
 
1548 1548
 
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
                         $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1557 1557
                         $post->country_slug = str_replace(']', '', $post->country_slug);
1558 1558
 
1559
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1559
+                        $post_location = (object) array('country_slug' => $post->country_slug,
1560 1560
                             'region_slug' => $post->region_slug,
1561 1561
                             'city_slug' => $post->city_slug
1562 1562
                         );
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 
1570 1570
                     $post_location_sql = $wpdb->get_results(
1571 1571
                         $wpdb->prepare(
1572
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1572
+                            "SELECT post_locations from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ",
1573 1573
                             array($post->ID)
1574 1574
                         )
1575 1575
                     );
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
                             $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1586 1586
                             $post->country_slug = str_replace(']', '', $post->country_slug);
1587 1587
 
1588
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1588
+                            $post_location = (object) array('country_slug' => $post->country_slug,
1589 1589
                                 'region_slug' => $post->region_slug,
1590 1590
                                 'city_slug' => $post->city_slug
1591 1591
                             );
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
 					}
1615 1615
 					$location_slug[] = $city_slug;
1616 1616
 					
1617
-					$location_request .= implode('/', $location_slug) . '/';
1617
+					$location_request .= implode('/', $location_slug).'/';
1618 1618
                 }
1619 1619
             }
1620 1620
 
@@ -1630,9 +1630,9 @@  discard block
 block discarded – undo
1630 1630
                 } else {
1631 1631
                     $post_terms = '';
1632 1632
 
1633
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1633
+                    if (isset($_POST['post_default_category']) && $_POST['post_default_category']) {
1634 1634
                         $post_terms = absint($_POST['post_default_category']);
1635
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1635
+                    }elseif (isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1636 1636
                         $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
1637 1637
                         $post_terms = absint($post_terms[0]);
1638 1638
                     }elseif (isset($post->{$taxonomies})) {
@@ -1678,14 +1678,14 @@  discard block
 block discarded – undo
1678 1678
             $request_term = trim($request_term, '/');
1679 1679
             
1680 1680
             // Fix with WPML the location terms added twice when CPT slug is translated.
1681
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1681
+            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/'.$request_term.$detailurl_separator) !== false) {
1682 1682
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1683 1683
             }
1684 1684
             
1685 1685
             if (!empty($request_term))
1686
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1686
+                $post_link = str_replace('%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
1687 1687
             else
1688
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1688
+                $post_link = str_replace('/%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
1689 1689
             //echo $post_link ;
1690 1690
         }
1691 1691
         // temp cache the permalink
@@ -1760,9 +1760,9 @@  discard block
 block discarded – undo
1760 1760
                 $url_separator = '';
1761 1761
 
1762 1762
                 if (get_option('permalink_structure') != '') {
1763
-                    $old_listing_slug = '/' . $listing_slug . '/';
1763
+                    $old_listing_slug = '/'.$listing_slug.'/';
1764 1764
                     $request_term = implode("/", $location_terms);
1765
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1765
+                    $new_listing_slug = '/'.$listing_slug.'/'.$request_term.'/';
1766 1766
 
1767 1767
                     $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1768 1768
                 } else {
@@ -1782,25 +1782,25 @@  discard block
 block discarded – undo
1782 1782
         // Alter the CPT slug if WPML is set to do so
1783 1783
         if (function_exists('icl_object_id')) {
1784 1784
             $post_types = get_option('geodir_post_types');
1785
-            $post_type = str_replace("category","",$taxonomy);
1786
-            $post_type = str_replace("_tags","",$post_type);
1785
+            $post_type = str_replace("category", "", $taxonomy);
1786
+            $post_type = str_replace("_tags", "", $post_type);
1787 1787
             $slug = $post_types[$post_type]['rewrite']['slug'];
1788 1788
             if (gd_wpml_slug_translation_turned_on($post_type)) {
1789 1789
                 global $sitepress;
1790 1790
                 $default_lang = $sitepress->get_default_language();
1791 1791
                 $language_code = gd_wpml_get_lang_from_url($termlink);
1792
-                if (!$language_code ) {
1793
-                    $language_code  = $default_lang;
1792
+                if (!$language_code) {
1793
+                    $language_code = $default_lang;
1794 1794
                 }
1795 1795
 
1796 1796
                 $org_slug = $slug;
1797
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1797
+                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: '.$slug, $language_code);
1798 1798
 
1799 1799
                 if (!$slug) {
1800 1800
                     $slug = $org_slug;
1801 1801
                 }
1802 1802
 
1803
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1803
+                $termlink = trailingslashit(preg_replace("/".preg_quote($org_slug, "/")."/", $slug, $termlink, 1));
1804 1804
             }
1805 1805
         }
1806 1806
     }
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 	
1831 1831
 	if (in_array($post_type, geodir_get_posttypes())) {
1832 1832
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1833
-			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1833
+			if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1834 1834
                 $location_terms = array(
1835 1835
                     'gd_country' => $post->country_slug,
1836 1836
                     'gd_region' => $post->region_slug,
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
 					$location_terms = implode("/", $location_terms);
1848 1848
 					$location_terms = rtrim($location_terms, '/');
1849 1849
 					
1850
-					$link .= urldecode($location_terms) . '/';
1850
+					$link .= urldecode($location_terms).'/';
1851 1851
 				} else {
1852 1852
 					$link = geodir_getlink($link, $location_terms);
1853 1853
 				}
@@ -1935,9 +1935,9 @@  discard block
 block discarded – undo
1935 1935
             return 0;
1936 1936
         $where = 't.term_id = %d';
1937 1937
         if (!empty($taxonomy))
1938
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1938
+            return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1939 1939
         else
1940
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1940
+            return $wpdb->get_var($wpdb->prepare($select.$where, $term));
1941 1941
     }
1942 1942
 
1943 1943
     $term = trim(wp_unslash($term));
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 
1950 1950
     $where_fields = array($slug);
1951 1951
     if (!empty($taxonomy)) {
1952
-        $parent = (int)$parent;
1952
+        $parent = (int) $parent;
1953 1953
         if ($parent > 0) {
1954 1954
             $where_fields[] = $parent;
1955 1955
             $else_where_fields[] = $parent;
@@ -2013,13 +2013,13 @@  discard block
 block discarded – undo
2013 2013
         $post_types = geodir_get_posttypes();
2014 2014
         $tax_arr = array();
2015 2015
         foreach ($post_types as $post_type) {
2016
-            $tax_arr[] = "'" . $post_type . "category'";
2016
+            $tax_arr[] = "'".$post_type."category'";
2017 2017
         }
2018 2018
         $tax_c = implode(',', $tax_arr);
2019 2019
         $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2020 2020
         //$terms = get_terms( $taxonomy );
2021 2021
 
2022
-        if($terms) {
2022
+        if ($terms) {
2023 2023
             foreach ($terms as $term) {
2024 2024
                 $post_type = str_replace("category", "", $term->taxonomy);
2025 2025
                 $a_terms[$post_type][] = $term;
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
             }
2028 2028
         }
2029 2029
 
2030
-        if($a_terms) {
2030
+        if ($a_terms) {
2031 2031
             foreach ($a_terms as $pt => $t2) {
2032 2032
 
2033 2033
                 foreach ($t2 as $term) {
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
     }
2053 2053
 
2054 2054
     if (is_ssl()) {
2055
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2055
+        $terms_icons = str_replace("http:", "https:", $terms_icons);
2056 2056
     }
2057 2057
 
2058 2058
     return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
Please login to merge, or discard this patch.
geodirectory-functions/comments_functions.php 2 patches
Indentation   +453 added lines, -453 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function geodir_comment_meta_row_action($a)
33 33
 {
34
-    global $comment;
34
+	global $comment;
35 35
 
36
-    $rating = geodir_get_commentoverall($comment->comment_ID);
37
-    if ($rating != 0) {
38
-        echo geodir_get_rating_stars($rating, $comment->comment_ID);
39
-    }
40
-    return $a;
36
+	$rating = geodir_get_commentoverall($comment->comment_ID);
37
+	if ($rating != 0) {
38
+		echo geodir_get_rating_stars($rating, $comment->comment_ID);
39
+	}
40
+	return $a;
41 41
 }
42 42
 
43 43
 add_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function geodir_comment_add_meta_box($comment)
54 54
 {
55
-    add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
55
+	add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
56 56
 }
57 57
 
58 58
 /**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
  * @param object $comment The comment object.
67 67
  */
68 68
 function geodir_comment_rating_meta($comment) {
69
-    $post_type = get_post_type($comment->comment_post_ID);
69
+	$post_type = get_post_type($comment->comment_post_ID);
70 70
 	if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
71 71
 		$rating = geodir_get_commentoverall($comment->comment_ID);
72 72
 		
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
  * @global object $post The post object.
107 107
  */
108 108
 function geodir_comment_rating_fields() {
109
-    global $post;
109
+	global $post;
110 110
 
111
-    $post_types = geodir_get_posttypes();
111
+	$post_types = geodir_get_posttypes();
112 112
 
113
-    if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
114
-        $star_texts = array();
115
-        $star_texts[] = __('Terrible', 'geodirectory');
116
-        $star_texts[] = __('Poor', 'geodirectory');
117
-        $star_texts[] = __('Average', 'geodirectory');
118
-        $star_texts[] = __('Very Good', 'geodirectory');
119
-        $star_texts[] = __('Excellent', 'geodirectory');
113
+	if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
114
+		$star_texts = array();
115
+		$star_texts[] = __('Terrible', 'geodirectory');
116
+		$star_texts[] = __('Poor', 'geodirectory');
117
+		$star_texts[] = __('Average', 'geodirectory');
118
+		$star_texts[] = __('Very Good', 'geodirectory');
119
+		$star_texts[] = __('Excellent', 'geodirectory');
120 120
         
121
-        $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
122
-        echo $gd_rating_html;
123
-        ?>
121
+		$gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
122
+		echo $gd_rating_html;
123
+		?>
124 124
         <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/>
125 125
         <?php
126
-    }
126
+	}
127 127
 }
128 128
 
129 129
 add_filter('comment_reply_link', 'geodir_comment_replaylink');
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 function geodir_comment_replaylink($link)
140 140
 {
141 141
 
142
-    if (strpos($link, 'wp-login.php?') !== false) {
143
-        $link = str_replace(wp_login_url(),geodir_login_url(),$link);
144
-    }
145
-    $link = '<div class="gd_comment_replaylink">' . $link . '</div>';
142
+	if (strpos($link, 'wp-login.php?') !== false) {
143
+		$link = str_replace(wp_login_url(),geodir_login_url(),$link);
144
+	}
145
+	$link = '<div class="gd_comment_replaylink">' . $link . '</div>';
146 146
 
147
-    return $link;
147
+	return $link;
148 148
 }
149 149
 
150 150
 add_filter('cancel_comment_reply_link', 'geodir_cancle_replaylink');
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 function geodir_cancle_replaylink($link)
160 160
 {
161 161
 
162
-    $link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
162
+	$link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
163 163
 
164
-    return $link;
164
+	return $link;
165 165
 }
166 166
 
167 167
 add_action('comment_post', 'geodir_save_rating');
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function geodir_save_rating($comment = 0)
179 179
 {
180
-    global $wpdb, $user_ID, $plugin_prefix;
180
+	global $wpdb, $user_ID, $plugin_prefix;
181 181
 
182
-    $comment_info = get_comment($comment);
182
+	$comment_info = get_comment($comment);
183 183
 
184
-    $post_id = $comment_info->comment_post_ID;
185
-    $status = $comment_info->comment_approved;
186
-    $rating_ip = getenv("REMOTE_ADDR");
184
+	$post_id = $comment_info->comment_post_ID;
185
+	$status = $comment_info->comment_approved;
186
+	$rating_ip = getenv("REMOTE_ADDR");
187 187
 	
188
-    $post = geodir_get_post_info($post_id);
189
-    if (empty($post)) {
190
-        return;
191
-    }
192
-
193
-    if ($post->post_status == 'publish') {
194
-        $post_status = '1';
195
-    } else {
196
-        $post_status = '0';
197
-    }
188
+	$post = geodir_get_post_info($post_id);
189
+	if (empty($post)) {
190
+		return;
191
+	}
192
+
193
+	if ($post->post_status == 'publish') {
194
+		$post_status = '1';
195
+	} else {
196
+		$post_status = '0';
197
+	}
198 198
 	
199
-    if (isset($_REQUEST['geodir_overallrating'])) {
200
-        $overall_rating = $_REQUEST['geodir_overallrating'];
199
+	if (isset($_REQUEST['geodir_overallrating'])) {
200
+		$overall_rating = $_REQUEST['geodir_overallrating'];
201 201
         
202 202
 		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
203
-            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
203
+			$overall_rating = $overall_rating > 0 ? $overall_rating : '0';
204 204
 
205
-            $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
205
+			$sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
206 206
 					post_id		= %d,
207 207
 					post_type = %s,
208 208
 					post_title	= %s,
@@ -220,35 +220,35 @@  discard block
 block discarded – undo
220 220
 					post_latitude	= %s,
221 221
 					comment_content	= %s 
222 222
 					",
223
-                array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
224
-            );
225
-
226
-            $wpdb->query($sqlqry);
227
-
228
-            /**
229
-             * Called after saving the comment.
230
-             *
231
-             * @since 1.0.0
232
-             * @package GeoDirectory
233
-             * @param array $_REQUEST {
234
-             *    Attributes of the $_REQUEST variable.
235
-             *
236
-             *    @type string $geodir_overallrating Overall rating.
237
-             *    @type string $comment Comment text.
238
-             *    @type string $submit Submit button text.
239
-             *    @type string $comment_post_ID Comment post ID.
240
-             *    @type string $comment_parent Comment Parent ID.
241
-             *    @type string $_wp_unfiltered_html_comment Unfiltered html comment string.
242
-             *
243
-             * }
244
-             */
245
-            do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
246
-
247
-            if ($status) {
248
-                geodir_update_postrating($post_id);
249
-            }
250
-        }
251
-    }
223
+				array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
224
+			);
225
+
226
+			$wpdb->query($sqlqry);
227
+
228
+			/**
229
+			 * Called after saving the comment.
230
+			 *
231
+			 * @since 1.0.0
232
+			 * @package GeoDirectory
233
+			 * @param array $_REQUEST {
234
+			 *    Attributes of the $_REQUEST variable.
235
+			 *
236
+			 *    @type string $geodir_overallrating Overall rating.
237
+			 *    @type string $comment Comment text.
238
+			 *    @type string $submit Submit button text.
239
+			 *    @type string $comment_post_ID Comment post ID.
240
+			 *    @type string $comment_parent Comment Parent ID.
241
+			 *    @type string $_wp_unfiltered_html_comment Unfiltered html comment string.
242
+			 *
243
+			 * }
244
+			 */
245
+			do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
246
+
247
+			if ($status) {
248
+				geodir_update_postrating($post_id);
249
+			}
250
+		}
251
+	}
252 252
 }
253 253
 
254 254
 
@@ -266,51 +266,51 @@  discard block
 block discarded – undo
266 266
  */
267 267
 function geodir_update_rating_status_change($comment_id, $status)
268 268
 {
269
-    if ($status == 'delete') {
270
-        return;
271
-    }
272
-    global $wpdb, $plugin_prefix, $user_ID;
269
+	if ($status == 'delete') {
270
+		return;
271
+	}
272
+	global $wpdb, $plugin_prefix, $user_ID;
273 273
 
274
-    $comment_info = get_comment($comment_id);
274
+	$comment_info = get_comment($comment_id);
275 275
 
276
-    $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
276
+	$post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
277 277
 
278
-    if (!empty($comment_info))
279
-        $status = $comment_info->comment_approved;
278
+	if (!empty($comment_info))
279
+		$status = $comment_info->comment_approved;
280 280
 
281
-    if ($status == 'approve' || $status == 1) {
282
-        $status = 1;
283
-    } else {
284
-        $status = 0;
285
-    }
281
+	if ($status == 'approve' || $status == 1) {
282
+		$status = 1;
283
+	} else {
284
+		$status = 0;
285
+	}
286 286
 
287
-    $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
288
-    $old_rating = geodir_get_commentoverall($comment_info_ID);
287
+	$comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
288
+	$old_rating = geodir_get_commentoverall($comment_info_ID);
289 289
 
290
-    $post_type = get_post_type($post_id);
290
+	$post_type = get_post_type($post_id);
291 291
 
292
-    $detail_table = $plugin_prefix . $post_type . '_detail';
292
+	$detail_table = $plugin_prefix . $post_type . '_detail';
293 293
 
294
-    if ($comment_id) {
294
+	if ($comment_id) {
295 295
 
296
-        $overall_rating = $old_rating;
296
+		$overall_rating = $old_rating;
297 297
 
298
-        if (isset($old_rating)) {
298
+		if (isset($old_rating)) {
299 299
 
300
-            $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
300
+			$sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
301 301
 						overall_rating = %f,
302 302
 						status		= %s,
303 303
 						comment_content = %s 
304 304
 						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));
305 305
 
306
-            $wpdb->query($sqlqry);
306
+			$wpdb->query($sqlqry);
307 307
 
308
-            //update rating
309
-            geodir_update_postrating($post_id, $post_type);
308
+			//update rating
309
+			geodir_update_postrating($post_id, $post_type);
310 310
 
311
-        }
311
+		}
312 312
 
313
-    }
313
+	}
314 314
 
315 315
 }
316 316
 
@@ -329,41 +329,41 @@  discard block
 block discarded – undo
329 329
 function geodir_update_rating($comment_id = 0)
330 330
 {
331 331
 
332
-    global $wpdb, $plugin_prefix, $user_ID;
332
+	global $wpdb, $plugin_prefix, $user_ID;
333 333
 
334
-    $comment_info = get_comment($comment_id);
334
+	$comment_info = get_comment($comment_id);
335 335
 
336
-    $post_id = $comment_info->comment_post_ID;
337
-    $status = $comment_info->comment_approved;
338
-    $old_rating = geodir_get_commentoverall($comment_info->comment_ID);
336
+	$post_id = $comment_info->comment_post_ID;
337
+	$status = $comment_info->comment_approved;
338
+	$old_rating = geodir_get_commentoverall($comment_info->comment_ID);
339 339
 
340
-    $post_type = get_post_type($post_id);
340
+	$post_type = get_post_type($post_id);
341 341
 
342
-    $detail_table = $plugin_prefix . $post_type . '_detail';
342
+	$detail_table = $plugin_prefix . $post_type . '_detail';
343 343
 
344
-    if (isset($_REQUEST['geodir_overallrating'])) {
344
+	if (isset($_REQUEST['geodir_overallrating'])) {
345 345
 
346
-        $overall_rating = $_REQUEST['geodir_overallrating'];
346
+		$overall_rating = $_REQUEST['geodir_overallrating'];
347 347
 
348
-        if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
349
-            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
348
+		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
349
+			$overall_rating = $overall_rating > 0 ? $overall_rating : '0';
350 350
 
351
-            if (isset($old_rating)) {
351
+			if (isset($old_rating)) {
352 352
 
353
-                $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
353
+				$sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
354 354
 						overall_rating = %f,
355 355
 						status		= %s,
356 356
 						comment_content	= %s 
357 357
 						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));
358 358
 
359
-                $wpdb->query($sqlqry);
359
+				$wpdb->query($sqlqry);
360 360
 
361
-                //update rating
362
-                geodir_update_postrating($post_id, $post_type);
361
+				//update rating
362
+				geodir_update_postrating($post_id, $post_type);
363 363
 
364
-            }
365
-        }
366
-    }
364
+			}
365
+		}
366
+	}
367 367
 
368 368
 
369 369
 }
@@ -379,19 +379,19 @@  discard block
 block discarded – undo
379 379
  */
380 380
 function geodir_comment_delete_comment($comment_id)
381 381
 {
382
-    global $wpdb;
382
+	global $wpdb;
383 383
 
384
-    $review_info = geodir_get_review($comment_id);
385
-    if ($review_info) {
386
-        geodir_update_postrating($review_info->post_id);
387
-    }
384
+	$review_info = geodir_get_review($comment_id);
385
+	if ($review_info) {
386
+		geodir_update_postrating($review_info->post_id);
387
+	}
388 388
 
389
-    $wpdb->query(
390
-        $wpdb->prepare(
391
-            "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
392
-            array($comment_id)
393
-        )
394
-    );
389
+	$wpdb->query(
390
+		$wpdb->prepare(
391
+			"DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
392
+			array($comment_id)
393
+		)
394
+	);
395 395
 
396 396
 }
397 397
 
@@ -407,21 +407,21 @@  discard block
 block discarded – undo
407 407
  * @return string The comment content.
408 408
  */
409 409
 function geodir_wrap_comment_text($content, $comment = '') {
410
-    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
411
-        if (!is_admin()) {
412
-            return '<div class="description">' . $content . '</div>';
413
-        } else {
414
-            return $content;
415
-        }
416
-    } else {
417
-        $rating = 0;
418
-        if (!empty($comment))
419
-            $rating = geodir_get_commentoverall($comment->comment_ID);
420
-        if ($rating != 0 && !is_admin()) {
421
-            return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
422
-        } else
423
-            return $content;
424
-    }
410
+	if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
411
+		if (!is_admin()) {
412
+			return '<div class="description">' . $content . '</div>';
413
+		} else {
414
+			return $content;
415
+		}
416
+	} else {
417
+		$rating = 0;
418
+		if (!empty($comment))
419
+			$rating = geodir_get_commentoverall($comment->comment_ID);
420
+		if ($rating != 0 && !is_admin()) {
421
+			return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
422
+		} else
423
+			return $content;
424
+	}
425 425
 }
426 426
 
427 427
 
@@ -438,41 +438,41 @@  discard block
 block discarded – undo
438 438
  */
439 439
 function geodir_update_postrating($post_id = 0, $post_type = '', $delete = false)
440 440
 {
441
-    global $wpdb, $plugin_prefix, $comment;
442
-    if (!$post_type) {
443
-        $post_type = get_post_type($post_id);
444
-    }
445
-    $detail_table = $plugin_prefix . $post_type . '_detail';
446
-    $post_newrating = geodir_get_post_rating($post_id, 1);
447
-    $post_newrating_count = geodir_get_review_count_total($post_id);
441
+	global $wpdb, $plugin_prefix, $comment;
442
+	if (!$post_type) {
443
+		$post_type = get_post_type($post_id);
444
+	}
445
+	$detail_table = $plugin_prefix . $post_type . '_detail';
446
+	$post_newrating = geodir_get_post_rating($post_id, 1);
447
+	$post_newrating_count = geodir_get_review_count_total($post_id);
448 448
 
449 449
 
450
-    //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
450
+	//$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
451 451
 
452
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
452
+	if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
453 453
 
454
-        $wpdb->query(
455
-            $wpdb->prepare(
456
-                "UPDATE " . $detail_table . " SET
454
+		$wpdb->query(
455
+			$wpdb->prepare(
456
+				"UPDATE " . $detail_table . " SET
457 457
 						overall_rating = %f,
458 458
 						rating_count = %f
459 459
 						where post_id = %d",
460
-                array($post_newrating, $post_newrating_count, $post_id)
461
-            )
462
-        );
463
-
464
-        update_post_meta($post_id, 'overall_rating', $post_newrating);
465
-        update_post_meta($post_id, 'rating_count', $post_newrating_count);
466
-    }
467
-    /**
468
-     * Called after Updating post overall rating and rating count.
469
-     *
470
-     * @since 1.0.0
471
-     * @since 1.4.3 Added `$post_id` param.
472
-     * @package GeoDirectory
473
-     * @param int $post_id The post ID.
474
-     */
475
-    do_action('geodir_update_postrating',$post_id);
460
+				array($post_newrating, $post_newrating_count, $post_id)
461
+			)
462
+		);
463
+
464
+		update_post_meta($post_id, 'overall_rating', $post_newrating);
465
+		update_post_meta($post_id, 'rating_count', $post_newrating_count);
466
+	}
467
+	/**
468
+	 * Called after Updating post overall rating and rating count.
469
+	 *
470
+	 * @since 1.0.0
471
+	 * @since 1.4.3 Added `$post_id` param.
472
+	 * @package GeoDirectory
473
+	 * @param int $post_id The post ID.
474
+	 */
475
+	do_action('geodir_update_postrating',$post_id);
476 476
 
477 477
 }
478 478
 
@@ -490,29 +490,29 @@  discard block
 block discarded – undo
490 490
  */
491 491
 function geodir_get_postoverall($post_id = 0)
492 492
 {
493
-    global $wpdb, $plugin_prefix;
493
+	global $wpdb, $plugin_prefix;
494 494
 
495
-    $post_type = get_post_type($post_id);
496
-    $detail_table = $plugin_prefix . $post_type . '_detail';
495
+	$post_type = get_post_type($post_id);
496
+	$detail_table = $plugin_prefix . $post_type . '_detail';
497 497
 
498
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
498
+	if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
499 499
 
500
-        $post_ratings = $wpdb->get_var(
501
-            $wpdb->prepare(
502
-                "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
503
-                array($post_id)
504
-            )
505
-        );
500
+		$post_ratings = $wpdb->get_var(
501
+			$wpdb->prepare(
502
+				"SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
503
+				array($post_id)
504
+			)
505
+		);
506 506
 
507 507
 
508
-    } else {
509
-        $post_ratings = get_post_meta($post_id, 'overall_rating');
510
-    }
508
+	} else {
509
+		$post_ratings = get_post_meta($post_id, 'overall_rating');
510
+	}
511 511
 
512
-    if ($post_ratings)
513
-        return $post_ratings;
514
-    else
515
-        return false;
512
+	if ($post_ratings)
513
+		return $post_ratings;
514
+	else
515
+		return false;
516 516
 }
517 517
 
518 518
 
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
  */
530 530
 function geodir_get_review($comment_id = 0)
531 531
 {
532
-    global $wpdb;
533
-
534
-    $reatings = $wpdb->get_row(
535
-        $wpdb->prepare(
536
-            "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
537
-            array($comment_id)
538
-        )
539
-    );
540
-
541
-    if (!empty($reatings))
542
-        return $reatings;
543
-    else
544
-        return false;
532
+	global $wpdb;
533
+
534
+	$reatings = $wpdb->get_row(
535
+		$wpdb->prepare(
536
+			"SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
537
+			array($comment_id)
538
+		)
539
+	);
540
+
541
+	if (!empty($reatings))
542
+		return $reatings;
543
+	else
544
+		return false;
545 545
 }
546 546
 
547 547
 /**
@@ -557,19 +557,19 @@  discard block
 block discarded – undo
557 557
  */
558 558
 function geodir_get_review_total($post_id = 0)
559 559
 {
560
-    global $wpdb;
561
-
562
-    $results = $wpdb->get_var(
563
-        $wpdb->prepare(
564
-            "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
565
-            array($post_id)
566
-        )
567
-    );
568
-
569
-    if (!empty($results))
570
-        return $results;
571
-    else
572
-        return false;
560
+	global $wpdb;
561
+
562
+	$results = $wpdb->get_var(
563
+		$wpdb->prepare(
564
+			"SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
565
+			array($post_id)
566
+		)
567
+	);
568
+
569
+	if (!empty($results))
570
+		return $results;
571
+	else
572
+		return false;
573 573
 }
574 574
 
575 575
 /**
@@ -585,18 +585,18 @@  discard block
 block discarded – undo
585 585
  */
586 586
 function geodir_get_review_count_by_user_id($user_id = 0)
587 587
 {
588
-    global $wpdb;
589
-    $results = $wpdb->get_var(
590
-        $wpdb->prepare(
591
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
592
-            array($user_id)
593
-        )
594
-    );
595
-
596
-    if (!empty($results))
597
-        return $results;
598
-    else
599
-        return false;
588
+	global $wpdb;
589
+	$results = $wpdb->get_var(
590
+		$wpdb->prepare(
591
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
592
+			array($user_id)
593
+		)
594
+	);
595
+
596
+	if (!empty($results))
597
+		return $results;
598
+	else
599
+		return false;
600 600
 }
601 601
 
602 602
 /**
@@ -614,27 +614,27 @@  discard block
 block discarded – undo
614 614
  */
615 615
 function geodir_get_post_rating($post_id = 0, $force_query = 0)
616 616
 {
617
-    global $wpdb, $post;
618
-
619
-    if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
620
-        if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
621
-            return $post->overall_rating;
622
-        } else {
623
-            return 0;
624
-        }
625
-    }
626
-
627
-    $results = $wpdb->get_var(
628
-        $wpdb->prepare(
629
-            "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
630
-            array($post_id)
631
-        )
632
-    );
633
-
634
-    if (!empty($results))
635
-        return $results;
636
-    else
637
-        return false;
617
+	global $wpdb, $post;
618
+
619
+	if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
620
+		if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
621
+			return $post->overall_rating;
622
+		} else {
623
+			return 0;
624
+		}
625
+	}
626
+
627
+	$results = $wpdb->get_var(
628
+		$wpdb->prepare(
629
+			"SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
630
+			array($post_id)
631
+		)
632
+	);
633
+
634
+	if (!empty($results))
635
+		return $results;
636
+	else
637
+		return false;
638 638
 }
639 639
 
640 640
 /**
@@ -650,19 +650,19 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function geodir_get_review_count_total($post_id = 0)
652 652
 {
653
-    global $wpdb;
654
-
655
-    $results = $wpdb->get_var(
656
-        $wpdb->prepare(
657
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
658
-            array($post_id)
659
-        )
660
-    );
661
-
662
-    if (!empty($results))
663
-        return $results;
664
-    else
665
-        return false;
653
+	global $wpdb;
654
+
655
+	$results = $wpdb->get_var(
656
+		$wpdb->prepare(
657
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
658
+			array($post_id)
659
+		)
660
+	);
661
+
662
+	if (!empty($results))
663
+		return $results;
664
+	else
665
+		return false;
666 666
 }
667 667
 
668 668
 /**
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function geodir_get_comments_number($post_id = 0)
681 681
 {
682
-    global $wpdb;
682
+	global $wpdb;
683 683
 
684
-    $results = $wpdb->get_var(
685
-        $wpdb->prepare(
686
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
687
-            array($post_id)
688
-        )
689
-    );
684
+	$results = $wpdb->get_var(
685
+		$wpdb->prepare(
686
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
687
+			array($post_id)
688
+		)
689
+	);
690 690
 
691 691
 
692
-    if (!empty($results))
693
-        return $results;
694
-    else
695
-        return false;
692
+	if (!empty($results))
693
+		return $results;
694
+	else
695
+		return false;
696 696
 }
697 697
 
698 698
 /**
@@ -708,19 +708,19 @@  discard block
 block discarded – undo
708 708
  */
709 709
 function geodir_get_commentoverall($comment_id = 0)
710 710
 {
711
-    global $wpdb;
712
-
713
-    $reatings = $wpdb->get_var(
714
-        $wpdb->prepare(
715
-            "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
716
-            array($comment_id)
717
-        )
718
-    );
719
-
720
-    if ($reatings)
721
-        return $reatings;
722
-    else
723
-        return false;
711
+	global $wpdb;
712
+
713
+	$reatings = $wpdb->get_var(
714
+		$wpdb->prepare(
715
+			"SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
716
+			array($comment_id)
717
+		)
718
+	);
719
+
720
+	if ($reatings)
721
+		return $reatings;
722
+	else
723
+		return false;
724 724
 }
725 725
 
726 726
 /**
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
  */
735 735
 function geodir_get_commentoverall_number($post_id = 0)
736 736
 {
737
-    return geodir_get_post_rating($post_id);
737
+	return geodir_get_post_rating($post_id);
738 738
 }
739 739
 
740 740
 
@@ -752,102 +752,102 @@  discard block
 block discarded – undo
752 752
  */
753 753
 function geodir_comment_template($comment_template)
754 754
 {
755
-    global $post;
755
+	global $post;
756 756
 
757
-    $post_types = geodir_get_posttypes();
757
+	$post_types = geodir_get_posttypes();
758 758
 
759
-    if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
760
-        return;
761
-    }
762
-    if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
763
-        if (geodir_cpt_has_rating_disabled($post->post_type)) {
764
-            return $comment_template;
765
-        }
759
+	if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
760
+		return;
761
+	}
762
+	if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
763
+		if (geodir_cpt_has_rating_disabled($post->post_type)) {
764
+			return $comment_template;
765
+		}
766 766
         
767
-        $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768
-        if (!$template) {
769
-            $template = dirname(__FILE__) . '/reviews.php';
770
-        }
771
-        return $template;
772
-    }
767
+		$template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768
+		if (!$template) {
769
+			$template = dirname(__FILE__) . '/reviews.php';
770
+		}
771
+		return $template;
772
+	}
773 773
 }
774 774
 
775 775
 add_filter("comments_template", "geodir_comment_template");
776 776
 
777 777
 
778 778
 if (!function_exists('geodir_comment')) {
779
-    /**
780
-     * Comment HTML markup.
781
-     *
782
-     * @since 1.0.0
783
-     * @package GeoDirectory
784
-     * @global object $post The current post object.
785
-     * @param object $comment The comment object.
786
-     * @param string|array $args {
787
-     *     Optional. Formatting options.
788
-     *
789
-     *     @type object $walker            Instance of a Walker class to list comments. Default null.
790
-     *     @type int    $max_depth         The maximum comments depth. Default empty.
791
-     *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
792
-     *     @type string $callback          Callback function to use. Default null.
793
-     *     @type string $end-callback      Callback function to use at the end. Default null.
794
-     *     @type string $type              Type of comments to list.
795
-     *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
796
-     *     @type int    $page              Page ID to list comments for. Default empty.
797
-     *     @type int    $per_page          Number of comments to list per page. Default empty.
798
-     *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
799
-     *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
800
-     *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
801
-     *     @type string $format            How to format the comments list.
802
-     *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
803
-     *     @type bool   $short_ping        Whether to output short pings. Default false.
804
-     *     @type bool   $echo              Whether to echo the output or return it. Default true.
805
-     * }
806
-     * @param int $depth Depth of comment.
807
-     */
808
-    function geodir_comment($comment, $args, $depth)
809
-    {
810
-        $GLOBALS['comment'] = $comment;
811
-        switch ($comment->comment_type) :
812
-            case 'pingback' :
813
-            case 'trackback' :
814
-                // Display trackbacks differently than normal comments.
815
-                ?>
779
+	/**
780
+	 * Comment HTML markup.
781
+	 *
782
+	 * @since 1.0.0
783
+	 * @package GeoDirectory
784
+	 * @global object $post The current post object.
785
+	 * @param object $comment The comment object.
786
+	 * @param string|array $args {
787
+	 *     Optional. Formatting options.
788
+	 *
789
+	 *     @type object $walker            Instance of a Walker class to list comments. Default null.
790
+	 *     @type int    $max_depth         The maximum comments depth. Default empty.
791
+	 *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
792
+	 *     @type string $callback          Callback function to use. Default null.
793
+	 *     @type string $end-callback      Callback function to use at the end. Default null.
794
+	 *     @type string $type              Type of comments to list.
795
+	 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
796
+	 *     @type int    $page              Page ID to list comments for. Default empty.
797
+	 *     @type int    $per_page          Number of comments to list per page. Default empty.
798
+	 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
799
+	 *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
800
+	 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
801
+	 *     @type string $format            How to format the comments list.
802
+	 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
803
+	 *     @type bool   $short_ping        Whether to output short pings. Default false.
804
+	 *     @type bool   $echo              Whether to echo the output or return it. Default true.
805
+	 * }
806
+	 * @param int $depth Depth of comment.
807
+	 */
808
+	function geodir_comment($comment, $args, $depth)
809
+	{
810
+		$GLOBALS['comment'] = $comment;
811
+		switch ($comment->comment_type) :
812
+			case 'pingback' :
813
+			case 'trackback' :
814
+				// Display trackbacks differently than normal comments.
815
+				?>
816 816
                 <li <?php comment_class('geodir-comment'); ?> id="comment-<?php comment_ID(); ?>">
817 817
                 <p><?php _e('Pingback:', 'geodirectory'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'geodirectory'), '<span class="edit-link">', '</span>'); ?></p>
818 818
                 <?php
819
-                break;
820
-            default :
821
-                // Proceed with normal comments.
822
-                global $post;
823
-                ?>
819
+				break;
820
+			default :
821
+				// Proceed with normal comments.
822
+				global $post;
823
+				?>
824 824
             <li <?php comment_class('geodir-comment'); ?> id="li-comment-<?php comment_ID(); ?>">
825 825
                 <article id="comment-<?php comment_ID(); ?>" class="comment">
826 826
                     <header class="comment-meta comment-author vcard">
827 827
                         <?php
828
-                        /**
829
-                         * Filter to modify comment avatar size
830
-                         *
831
-                         * You can use this filter to change comment avatar size.
832
-                         *
833
-                         * @since 1.0.0
834
-                         * @package GeoDirectory
835
-                         */
836
-                        $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
837
-                        echo get_avatar($comment, $avatar_size);
838
-                        printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839
-                            get_comment_author_link(),
840
-                            // If current post author is also comment author, make it known visually.
841
-                            ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
842
-                        );
843
-                        echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844
-                        printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
845
-                            esc_url(get_comment_link($comment->comment_ID)),
846
-                            get_comment_time('c'),
847
-                            /* translators: 1: date, 2: time */
848
-                            sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
849
-                        );
850
-                        ?>
828
+						/**
829
+						 * Filter to modify comment avatar size
830
+						 *
831
+						 * You can use this filter to change comment avatar size.
832
+						 *
833
+						 * @since 1.0.0
834
+						 * @package GeoDirectory
835
+						 */
836
+						$avatar_size = apply_filters('geodir_comment_avatar_size', 44);
837
+						echo get_avatar($comment, $avatar_size);
838
+						printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839
+							get_comment_author_link(),
840
+							// If current post author is also comment author, make it known visually.
841
+							($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
842
+						);
843
+						echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844
+						printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
845
+							esc_url(get_comment_link($comment->comment_ID)),
846
+							get_comment_time('c'),
847
+							/* translators: 1: date, 2: time */
848
+							sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
849
+						);
850
+						?>
851 851
                     </header>
852 852
                     <!-- .comment-meta -->
853 853
 
@@ -871,47 +871,47 @@  discard block
 block discarded – undo
871 871
                 </article>
872 872
                 <!-- #comment-## -->
873 873
                 <?php
874
-                break;
875
-        endswitch; // end comment_type check
876
-    }
874
+				break;
875
+		endswitch; // end comment_type check
876
+	}
877 877
 }
878 878
 
879 879
 
880 880
 add_filter('get_comments_number', 'geodir_fix_comment_count', 10, 2);
881 881
 if (!function_exists('geodir_fix_comment_count')) {
882
-    /**
883
-     * Fix comment count by not listing replies as reviews
884
-     *
885
-     * @since 1.0.0
886
-     * @package GeoDirectory
887
-     * @global object $post The current post object.
888
-     * @param int $count The comment count.
889
-     * @param int $post_id The post ID.
890
-     * @todo $post is unreachable since the function return the count before that variable.
891
-     * @return bool|null|string The comment count.
892
-     */
893
-    function geodir_fix_comment_count($count, $post_id)
894
-    {
895
-        if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
896
-            global $post;
897
-            $post_types = geodir_get_posttypes();
898
-
899
-            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
900
-                $review_count = geodir_get_review_count_total($post_id);
901
-                return $review_count;
902
-
903
-                if ($post && isset($post->rating_count)) {
904
-                    return $post->rating_count;
905
-                } else {
906
-                    return geodir_get_comments_number($post_id);
907
-                }
908
-            } else {
909
-                return $count;
910
-            }
911
-        } else {
912
-            return $count;
913
-        }
914
-    }
882
+	/**
883
+	 * Fix comment count by not listing replies as reviews
884
+	 *
885
+	 * @since 1.0.0
886
+	 * @package GeoDirectory
887
+	 * @global object $post The current post object.
888
+	 * @param int $count The comment count.
889
+	 * @param int $post_id The post ID.
890
+	 * @todo $post is unreachable since the function return the count before that variable.
891
+	 * @return bool|null|string The comment count.
892
+	 */
893
+	function geodir_fix_comment_count($count, $post_id)
894
+	{
895
+		if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
896
+			global $post;
897
+			$post_types = geodir_get_posttypes();
898
+
899
+			if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
900
+				$review_count = geodir_get_review_count_total($post_id);
901
+				return $review_count;
902
+
903
+				if ($post && isset($post->rating_count)) {
904
+					return $post->rating_count;
905
+				} else {
906
+					return geodir_get_comments_number($post_id);
907
+				}
908
+			} else {
909
+				return $count;
910
+			}
911
+		} else {
912
+			return $count;
913
+		}
914
+	}
915 915
 }
916 916
 
917 917
 /**
@@ -929,14 +929,14 @@  discard block
 block discarded – undo
929 929
  */
930 930
 function geodir_get_rating_stars($rating, $post_id, $small = false)
931 931
 {
932
-    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
933
-        return NULL;
934
-    }
935
-    $a_rating = $rating / 5 * 100;
936
-
937
-    if ($small) {
938
-        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
939
-    } else {
932
+	if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
933
+		return NULL;
934
+	}
935
+	$a_rating = $rating / 5 * 100;
936
+
937
+	if ($small) {
938
+		$r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
939
+	} else {
940 940
 		if (function_exists('geodir_reviewrating_draw_overall_rating')) {
941 941
 			// Show rating stars from review rating manager
942 942
 			$r_html = geodir_reviewrating_draw_overall_rating($rating);
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 			}
954 954
 			$r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>';
955 955
 		}
956
-    }
957
-    return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
956
+	}
957
+	return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
958 958
 }
959 959
 
960 960
 /**
@@ -968,23 +968,23 @@  discard block
 block discarded – undo
968 968
 function geodir_is_reviews_show($pageview = '')
969 969
 {
970 970
 
971
-    $active_tabs = get_option('geodir_detail_page_tabs_excluded');
972
-
973
-    $is_display = true;
974
-    if (!empty($active_tabs) && in_array('reviews', $active_tabs))
975
-        $is_display = false;
976
-
977
-    /**
978
-     * Filter to change display value.
979
-     *
980
-     * You can use this filter to change the is_display value.
981
-     *
982
-     * @since 1.0.0
983
-     * @package GeoDirectory
984
-     * @param bool $is_display Display ratings when set to true.
985
-     * @param string $pageview The view template. Ex: listview, gridview etc.
986
-     */
987
-    return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
971
+	$active_tabs = get_option('geodir_detail_page_tabs_excluded');
972
+
973
+	$is_display = true;
974
+	if (!empty($active_tabs) && in_array('reviews', $active_tabs))
975
+		$is_display = false;
976
+
977
+	/**
978
+	 * Filter to change display value.
979
+	 *
980
+	 * You can use this filter to change the is_display value.
981
+	 *
982
+	 * @since 1.0.0
983
+	 * @package GeoDirectory
984
+	 * @param bool $is_display Display ratings when set to true.
985
+	 * @param string $pageview The view template. Ex: listview, gridview etc.
986
+	 */
987
+	return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
988 988
 }
989 989
 
990 990
 
@@ -992,9 +992,9 @@  discard block
 block discarded – undo
992 992
  * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types
993 993
  */
994 994
 if(function_exists('dsq_can_replace')) {
995
-    remove_filter('comments_template', 'dsq_comments_template');
996
-    add_filter('comments_template', 'dsq_comments_template', 100);
997
-    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
995
+	remove_filter('comments_template', 'dsq_comments_template');
996
+	add_filter('comments_template', 'dsq_comments_template', 100);
997
+	add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
998 998
 }
999 999
 
1000 1000
 
@@ -1008,14 +1008,14 @@  discard block
 block discarded – undo
1008 1008
  * @return string `1` if active `0` if disabled.
1009 1009
  */
1010 1010
 function geodir_option_disqus_active($disqus_active){
1011
-    global $post;
1012
-    $all_postypes = geodir_get_posttypes();
1011
+	global $post;
1012
+	$all_postypes = geodir_get_posttypes();
1013 1013
 
1014
-    if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1015
-        $disqus_active = '0';
1016
-    }
1014
+	if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1015
+		$disqus_active = '0';
1016
+	}
1017 1017
 
1018
-    return $disqus_active;
1018
+	return $disqus_active;
1019 1019
 }
1020 1020
 
1021 1021
 /**
@@ -1029,22 +1029,22 @@  discard block
 block discarded – undo
1029 1029
  * @return array Modified tabs array.
1030 1030
  */
1031 1031
 function geodir_detail_reviews_tab_title($tabs_arr) {
1032
-    $post_type = geodir_get_current_posttype();
1032
+	$post_type = geodir_get_current_posttype();
1033 1033
 
1034
-    if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
1035
-        $label_reviews = __('Comments', 'geodirectory');
1034
+	if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
1035
+		$label_reviews = __('Comments', 'geodirectory');
1036 1036
         
1037
-        if (defined('GEODIR_CP_VERSION')) {
1038
-            $post_types = geodir_get_posttypes('array');
1037
+		if (defined('GEODIR_CP_VERSION')) {
1038
+			$post_types = geodir_get_posttypes('array');
1039 1039
             
1040
-            if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
1041
-                $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory'));
1042
-            }
1043
-        }
1040
+			if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
1041
+				$label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory'));
1042
+			}
1043
+		}
1044 1044
         
1045
-        $tabs_arr['reviews']['heading_text'] = $label_reviews;
1046
-    }
1045
+		$tabs_arr['reviews']['heading_text'] = $label_reviews;
1046
+	}
1047 1047
     
1048
-    return $tabs_arr;
1048
+	return $tabs_arr;
1049 1049
 }
1050 1050
 add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_reviews_tab_title', 1000, 1);
1051 1051
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function geodir_comment_rating_meta($comment) {
69 69
     $post_type = get_post_type($comment->comment_post_ID);
70
-	if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
70
+	if (in_array($post_type, (array) geodir_get_posttypes()) && (int) $comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
71 71
 		$rating = geodir_get_commentoverall($comment->comment_ID);
72 72
 		
73
-		if ((int)get_option('geodir_reviewrating_enable_font_awesome') == 1) {
73
+		if ((int) get_option('geodir_reviewrating_enable_font_awesome') == 1) {
74 74
 			$star_texts = array();
75 75
 			$star_texts[] = __('Terrible', 'geodirectory');
76 76
 			$star_texts[] = __('Poor', 'geodirectory');
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 			echo geodir_font_awesome_rating_form_html('', $star_texts, $rating);
82 82
 		} else {			
83 83
 			if ($rating) {
84
-				echo '<div class="gd_rating" data-average="' . $rating . '" data-id="5">';
84
+				echo '<div class="gd_rating" data-average="'.$rating.'" data-id="5">';
85 85
 
86 86
 			} else {
87 87
 				echo '<div class="gd_rating" data-average="0" data-id="5"></div>';
88 88
 			}
89 89
 		}
90
-		echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="' . $rating . '"  />';
90
+		echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="'.$rating.'"  />';
91 91
 	}
92 92
 }
93 93
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 {
141 141
 
142 142
     if (strpos($link, 'wp-login.php?') !== false) {
143
-        $link = str_replace(wp_login_url(),geodir_login_url(),$link);
143
+        $link = str_replace(wp_login_url(), geodir_login_url(), $link);
144 144
     }
145
-    $link = '<div class="gd_comment_replaylink">' . $link . '</div>';
145
+    $link = '<div class="gd_comment_replaylink">'.$link.'</div>';
146 146
 
147 147
     return $link;
148 148
 }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 function geodir_cancle_replaylink($link)
160 160
 {
161 161
 
162
-    $link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
162
+    $link = '<span class="gd-cancel-replaylink">'.$link.'</span>';
163 163
 
164 164
     return $link;
165 165
 }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     if (isset($_REQUEST['geodir_overallrating'])) {
200 200
         $overall_rating = $_REQUEST['geodir_overallrating'];
201 201
         
202
-		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
202
+		if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
203 203
             $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
204 204
 
205
-            $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
205
+            $sqlqry = $wpdb->prepare("INSERT INTO ".GEODIR_REVIEW_TABLE." SET
206 206
 					post_id		= %d,
207 207
 					post_type = %s,
208 208
 					post_title	= %s,
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
     $post_type = get_post_type($post_id);
291 291
 
292
-    $detail_table = $plugin_prefix . $post_type . '_detail';
292
+    $detail_table = $plugin_prefix.$post_type.'_detail';
293 293
 
294 294
     if ($comment_id) {
295 295
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
         if (isset($old_rating)) {
299 299
 
300
-            $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
300
+            $sqlqry = $wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET
301 301
 						overall_rating = %f,
302 302
 						status		= %s,
303 303
 						comment_content = %s 
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
 
340 340
     $post_type = get_post_type($post_id);
341 341
 
342
-    $detail_table = $plugin_prefix . $post_type . '_detail';
342
+    $detail_table = $plugin_prefix.$post_type.'_detail';
343 343
 
344 344
     if (isset($_REQUEST['geodir_overallrating'])) {
345 345
 
346 346
         $overall_rating = $_REQUEST['geodir_overallrating'];
347 347
 
348
-        if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
348
+        if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
349 349
             $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
350 350
 
351 351
             if (isset($old_rating)) {
352 352
 
353
-                $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
353
+                $sqlqry = $wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET
354 354
 						overall_rating = %f,
355 355
 						status		= %s,
356 356
 						comment_content	= %s 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
     $wpdb->query(
390 390
         $wpdb->prepare(
391
-            "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
391
+            "DELETE FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d",
392 392
             array($comment_id)
393 393
         )
394 394
     );
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
  * @return string The comment content.
408 408
  */
409 409
 function geodir_wrap_comment_text($content, $comment = '') {
410
-    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
410
+    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int) $comment->comment_post_ID)) {
411 411
         if (!is_admin()) {
412
-            return '<div class="description">' . $content . '</div>';
412
+            return '<div class="description">'.$content.'</div>';
413 413
         } else {
414 414
             return $content;
415 415
         }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
         if (!empty($comment))
419 419
             $rating = geodir_get_commentoverall($comment->comment_ID);
420 420
         if ($rating != 0 && !is_admin()) {
421
-            return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
421
+            return '<div><div class="gd-rating-text">'.__('Overall Rating', 'geodirectory').': <div class="rating">'.$rating.'</div></div>'.geodir_get_rating_stars($rating, $comment->comment_ID).'</div><div class="description">'.$content.'</div>';
422 422
         } else
423 423
             return $content;
424 424
     }
@@ -442,18 +442,18 @@  discard block
 block discarded – undo
442 442
     if (!$post_type) {
443 443
         $post_type = get_post_type($post_id);
444 444
     }
445
-    $detail_table = $plugin_prefix . $post_type . '_detail';
445
+    $detail_table = $plugin_prefix.$post_type.'_detail';
446 446
     $post_newrating = geodir_get_post_rating($post_id, 1);
447 447
     $post_newrating_count = geodir_get_review_count_total($post_id);
448 448
 
449 449
 
450 450
     //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
451 451
 
452
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
452
+    if ($wpdb->get_var("SHOW TABLES LIKE '".$detail_table."'") == $detail_table) {
453 453
 
454 454
         $wpdb->query(
455 455
             $wpdb->prepare(
456
-                "UPDATE " . $detail_table . " SET
456
+                "UPDATE ".$detail_table." SET
457 457
 						overall_rating = %f,
458 458
 						rating_count = %f
459 459
 						where post_id = %d",
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      * @package GeoDirectory
473 473
      * @param int $post_id The post ID.
474 474
      */
475
-    do_action('geodir_update_postrating',$post_id);
475
+    do_action('geodir_update_postrating', $post_id);
476 476
 
477 477
 }
478 478
 
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
     global $wpdb, $plugin_prefix;
494 494
 
495 495
     $post_type = get_post_type($post_id);
496
-    $detail_table = $plugin_prefix . $post_type . '_detail';
496
+    $detail_table = $plugin_prefix.$post_type.'_detail';
497 497
 
498
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
498
+    if ($wpdb->get_var("SHOW TABLES LIKE '".$detail_table."'") == $detail_table) {
499 499
 
500 500
         $post_ratings = $wpdb->get_var(
501 501
             $wpdb->prepare(
502
-                "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
502
+                "SELECT overall_rating FROM ".$detail_table." WHERE post_id = %d",
503 503
                 array($post_id)
504 504
             )
505 505
         );
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
     $reatings = $wpdb->get_row(
535 535
         $wpdb->prepare(
536
-            "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
536
+            "SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id = %d",
537 537
             array($comment_id)
538 538
         )
539 539
     );
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 
562 562
     $results = $wpdb->get_var(
563 563
         $wpdb->prepare(
564
-            "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
564
+            "SELECT SUM(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
565 565
             array($post_id)
566 566
         )
567 567
     );
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
     global $wpdb;
589 589
     $results = $wpdb->get_var(
590 590
         $wpdb->prepare(
591
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
591
+            "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE user_id = %d AND status=1 AND overall_rating>0",
592 592
             array($user_id)
593 593
         )
594 594
     );
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 
627 627
     $results = $wpdb->get_var(
628 628
         $wpdb->prepare(
629
-            "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
629
+            "SELECT COALESCE(avg(overall_rating),0) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
630 630
             array($post_id)
631 631
         )
632 632
     );
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 
655 655
     $results = $wpdb->get_var(
656 656
         $wpdb->prepare(
657
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
657
+            "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
658 658
             array($post_id)
659 659
         )
660 660
     );
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 
684 684
     $results = $wpdb->get_var(
685 685
         $wpdb->prepare(
686
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
686
+            "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
687 687
             array($post_id)
688 688
         )
689 689
     );
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 
713 713
     $reatings = $wpdb->get_var(
714 714
         $wpdb->prepare(
715
-            "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
715
+            "SELECT overall_rating FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id = %d",
716 716
             array($comment_id)
717 717
         )
718 718
     );
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
         
767 767
         $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768 768
         if (!$template) {
769
-            $template = dirname(__FILE__) . '/reviews.php';
769
+            $template = dirname(__FILE__).'/reviews.php';
770 770
         }
771 771
         return $template;
772 772
     }
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
                         printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839 839
                             get_comment_author_link(),
840 840
                             // If current post author is also comment author, make it known visually.
841
-                            ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
841
+                            ($comment->user_id === $post->post_author) ? '<span>'.__('Post author', 'geodirectory').'</span>' : ''
842 842
                         );
843 843
                         echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844 844
                         printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
             global $post;
897 897
             $post_types = geodir_get_posttypes();
898 898
 
899
-            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
899
+            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int) $post_id)) {
900 900
                 $review_count = geodir_get_review_count_total($post_id);
901 901
                 return $review_count;
902 902
 
@@ -929,29 +929,29 @@  discard block
 block discarded – undo
929 929
  */
930 930
 function geodir_get_rating_stars($rating, $post_id, $small = false)
931 931
 {
932
-    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
932
+    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int) $post_id)) {
933 933
         return NULL;
934 934
     }
935 935
     $a_rating = $rating / 5 * 100;
936 936
 
937 937
     if ($small) {
938
-        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
938
+        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="'.$rating.'" data-id="'.$post_id.'"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: '.$a_rating.'%;"></div><div class="geodir_Star_small"></div></div></div>';
939 939
     } else {
940 940
 		if (function_exists('geodir_reviewrating_draw_overall_rating')) {
941 941
 			// Show rating stars from review rating manager
942 942
 			$r_html = geodir_reviewrating_draw_overall_rating($rating);
943 943
 		} else {
944
-			$rating_img = '<img alt="rating icon" src="' . get_option('geodir_default_rating_star_icon') . '" />';
944
+			$rating_img = '<img alt="rating icon" src="'.get_option('geodir_default_rating_star_icon').'" />';
945 945
 			
946 946
 			/* fix rating star for safari */
947 947
 			$star_width = 23 * 5;
948 948
 			
949 949
 			if ($star_width > 0) {
950
-				$attach_style = 'max-width:' . $star_width . 'px';
950
+				$attach_style = 'max-width:'.$star_width.'px';
951 951
 			} else {
952 952
 				$attach_style = '';
953 953
 			}
954
-			$r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>';
954
+			$r_html = '<div class="geodir-rating" style="'.$attach_style.'"><div class="gd_rating_show" data-average="'.$rating.'" data-id="'.$post_id.'"><div class="geodir_RatingAverage" style="width: '.$a_rating.'%;"></div><div class="geodir_Star">'.$rating_img.$rating_img.$rating_img.$rating_img.$rating_img.'</div></div></div>';
955 955
 		}
956 956
     }
957 957
     return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
@@ -991,10 +991,10 @@  discard block
 block discarded – undo
991 991
 /*
992 992
  * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types
993 993
  */
994
-if(function_exists('dsq_can_replace')) {
994
+if (function_exists('dsq_can_replace')) {
995 995
     remove_filter('comments_template', 'dsq_comments_template');
996 996
     add_filter('comments_template', 'dsq_comments_template', 100);
997
-    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
997
+    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active', 10, 1);
998 998
 }
999 999
 
1000 1000
 
@@ -1007,11 +1007,11 @@  discard block
 block discarded – undo
1007 1007
  * @param string $disqus_active Hook called before DB call for option so this is empty.
1008 1008
  * @return string `1` if active `0` if disabled.
1009 1009
  */
1010
-function geodir_option_disqus_active($disqus_active){
1010
+function geodir_option_disqus_active($disqus_active) {
1011 1011
     global $post;
1012 1012
     $all_postypes = geodir_get_posttypes();
1013 1013
 
1014
-    if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1014
+    if (isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
1015 1015
         $disqus_active = '0';
1016 1016
     }
1017 1017
 
Please login to merge, or discard this patch.