Test Failed
Pull Request — master (#239)
by Viruthagiri
14:39
created
geodirectory-functions/template_functions.php 1 patch
Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function geodir_locate_template($template = '')
21 21
 {
22
-    global $post_type, $wp, $post;
23
-    $fields = array();
22
+	global $post_type, $wp, $post;
23
+	$fields = array();
24 24
 
25
-    switch ($template):
26
-        case 'signup':
27
-            return $template = locate_template(array("geodirectory/geodir-signup.php"));
28
-            break;
29
-        case 'add-listing':
25
+	switch ($template):
26
+		case 'signup':
27
+			return $template = locate_template(array("geodirectory/geodir-signup.php"));
28
+			break;
29
+		case 'add-listing':
30 30
 
31
-            $sc_post_type = '';
31
+			$sc_post_type = '';
32 32
 			if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
33
-                $listing_page_id = $post->ID;
33
+				$listing_page_id = $post->ID;
34 34
 				
35 35
 				$regex_pattern = get_shortcode_regex();
36 36
 				preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches);
@@ -39,100 +39,100 @@  discard block
 block discarded – undo
39 39
 					$shortcode_atts = shortcode_parse_atts($regex_matches[3]);
40 40
 					$sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : '';
41 41
 				}
42
-            } else {
43
-                $listing_page_id = geodir_add_listing_page_id();
44
-            }
42
+			} else {
43
+				$listing_page_id = geodir_add_listing_page_id();
44
+			}
45 45
 			
46 46
 			$is_wpml = function_exists('icl_object_id') ? true : false;
47 47
 
48
-            if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type'])
49
-                && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
50
-            )
51
-                $post_type = sanitize_text_field($_REQUEST['listing_type']);
52
-            if (empty($post_type) && !isset($_REQUEST['pid'])) {
53
-                $pagename = $wp->query_vars['pagename'];
54
-                $post_types = geodir_get_posttypes();
55
-                if (!empty($post_types))
56
-                    $post_type = $post_types[0];
48
+			if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type'])
49
+				&& in_array($_REQUEST['listing_type'], geodir_get_posttypes())
50
+			)
51
+				$post_type = sanitize_text_field($_REQUEST['listing_type']);
52
+			if (empty($post_type) && !isset($_REQUEST['pid'])) {
53
+				$pagename = $wp->query_vars['pagename'];
54
+				$post_types = geodir_get_posttypes();
55
+				if (!empty($post_types))
56
+					$post_type = $post_types[0];
57 57
 					
58 58
 				if($sc_post_type != '' )
59 59
 					$post_type = $sc_post_type;
60 60
 				
61
-                if ($is_wpml && !empty($wp->query_vars['page_id'])) {
61
+				if ($is_wpml && !empty($wp->query_vars['page_id'])) {
62 62
 					wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type)));
63 63
 				} else {
64 64
 					wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type);
65 65
 				}
66
-                gd_die();
67
-            }
68
-            return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php"));
69
-            break;
70
-        case 'success':
71
-            $success_page_id = geodir_success_page_id();
72
-            if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type'])
73
-                && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
74
-            )
75
-                $post_type = sanitize_text_field($_REQUEST['listing_type']);
76
-            return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php"));
77
-            break;
78
-        case 'detail':
79
-        case 'preview':
80
-            if (in_array(get_post_type(), geodir_get_posttypes()))
81
-                $post_type = get_post_type();
82
-            return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php"));
83
-            break;
84
-        case 'listing':
85
-            $templates = array();
86
-            if (is_post_type_archive() && in_array(get_post_type(), geodir_get_posttypes())) {
87
-                $post_type = get_post_type();
88
-                $templates[] = "geodirectory/archive-$post_type.php";
89
-            }
90
-
91
-
92
-            if (is_tax() && geodir_get_taxonomy_posttype()) {
93
-                $query_obj = get_queried_object();
94
-                $curr_taxonomy = isset($query_obj->taxonomy) ? $query_obj->taxonomy : '';
95
-                $curr_term = isset($query_obj->slug) ? $query_obj->slug : '';
96
-                $templates[] = "geodirectory/taxonomy-$curr_taxonomy-$curr_term.php";
97
-                $templates[] = "geodirectory/taxonomy-$curr_taxonomy.php";
98
-            }
99
-
100
-            $templates[] = "geodirectory/geodir-listing.php";
101
-
102
-            return $template = locate_template($templates);
103
-            break;
104
-        case 'information':
105
-            return $template = locate_template(array("geodirectory/geodir-information.php"));
106
-            break;
107
-        case 'author':
108
-            return $template = locate_template(array("geodirectory/geodir-author.php"));
109
-            break;
110
-        case 'search':
111
-            return $template = locate_template(array("geodirectory/geodir-search.php"));
112
-            break;
113
-        case 'location':
114
-            return $template = locate_template(array("geodirectory/geodir-location.php"));
115
-            break;
116
-        case 'geodir-home':
117
-            return $template = locate_template(array("geodirectory/geodir-home.php"));
118
-            break;
119
-        case 'listing-listview':
120
-            $template = locate_template(array("geodirectory/listing-listview.php"));
121
-            if (!$template) {
122
-                $template = geodir_plugin_path() . '/geodirectory-templates/listing-listview.php';
123
-            }
124
-            return $template;
125
-            break;
126
-        case 'widget-listing-listview':
127
-            $template = locate_template(array("geodirectory/widget-listing-listview.php"));
128
-            if (!$template) {
129
-                $template = geodir_plugin_path() . '/geodirectory-templates/widget-listing-listview.php';
130
-            }
131
-            return $template;
132
-            break;
133
-    endswitch;
134
-
135
-    return false;
66
+				gd_die();
67
+			}
68
+			return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php"));
69
+			break;
70
+		case 'success':
71
+			$success_page_id = geodir_success_page_id();
72
+			if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type'])
73
+				&& in_array($_REQUEST['listing_type'], geodir_get_posttypes())
74
+			)
75
+				$post_type = sanitize_text_field($_REQUEST['listing_type']);
76
+			return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php"));
77
+			break;
78
+		case 'detail':
79
+		case 'preview':
80
+			if (in_array(get_post_type(), geodir_get_posttypes()))
81
+				$post_type = get_post_type();
82
+			return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php"));
83
+			break;
84
+		case 'listing':
85
+			$templates = array();
86
+			if (is_post_type_archive() && in_array(get_post_type(), geodir_get_posttypes())) {
87
+				$post_type = get_post_type();
88
+				$templates[] = "geodirectory/archive-$post_type.php";
89
+			}
90
+
91
+
92
+			if (is_tax() && geodir_get_taxonomy_posttype()) {
93
+				$query_obj = get_queried_object();
94
+				$curr_taxonomy = isset($query_obj->taxonomy) ? $query_obj->taxonomy : '';
95
+				$curr_term = isset($query_obj->slug) ? $query_obj->slug : '';
96
+				$templates[] = "geodirectory/taxonomy-$curr_taxonomy-$curr_term.php";
97
+				$templates[] = "geodirectory/taxonomy-$curr_taxonomy.php";
98
+			}
99
+
100
+			$templates[] = "geodirectory/geodir-listing.php";
101
+
102
+			return $template = locate_template($templates);
103
+			break;
104
+		case 'information':
105
+			return $template = locate_template(array("geodirectory/geodir-information.php"));
106
+			break;
107
+		case 'author':
108
+			return $template = locate_template(array("geodirectory/geodir-author.php"));
109
+			break;
110
+		case 'search':
111
+			return $template = locate_template(array("geodirectory/geodir-search.php"));
112
+			break;
113
+		case 'location':
114
+			return $template = locate_template(array("geodirectory/geodir-location.php"));
115
+			break;
116
+		case 'geodir-home':
117
+			return $template = locate_template(array("geodirectory/geodir-home.php"));
118
+			break;
119
+		case 'listing-listview':
120
+			$template = locate_template(array("geodirectory/listing-listview.php"));
121
+			if (!$template) {
122
+				$template = geodir_plugin_path() . '/geodirectory-templates/listing-listview.php';
123
+			}
124
+			return $template;
125
+			break;
126
+		case 'widget-listing-listview':
127
+			$template = locate_template(array("geodirectory/widget-listing-listview.php"));
128
+			if (!$template) {
129
+				$template = geodir_plugin_path() . '/geodirectory-templates/widget-listing-listview.php';
130
+			}
131
+			return $template;
132
+			break;
133
+	endswitch;
134
+
135
+	return false;
136 136
 
137 137
 }
138 138
 
@@ -151,238 +151,238 @@  discard block
 block discarded – undo
151 151
 function geodir_template_loader($template)
152 152
 {
153 153
 
154
-    global $wp_query;
155
-
156
-    /**
157
-     * Filter the custom page list.
158
-     *
159
-     * @since 1.0.0
160
-     */
161
-    $geodir_custom_page_list = apply_filters('geodir_set_custom_pages', array(
162
-        'geodir_signup_page' =>
163
-            apply_filters('geodir_set_custom_signup_page', false),
164
-        'geodir_add_listing_page' =>
165
-            apply_filters('geodir_set_custom_add_listing_page', false),
166
-        'geodir_preview_page' =>
167
-            apply_filters('geodir_set_custom_preview_page', false),
168
-        'geodir_listing_success_page' =>
169
-            apply_filters('geodir_set_custom_listing_success_page', false),
170
-        'geodir_listing_detail_page' =>
171
-            apply_filters('geodir_set_custom_listing_detail_page', false),
172
-        'geodir_listing_page' =>
173
-            apply_filters('geodir_set_custom_listing_page', false),
174
-        'geodir_search_page' =>
175
-            apply_filters('geodir_set_custom_search_page', false),
176
-        'geodir_author_page' =>
177
-            apply_filters('geodir_set_custom_author_page', false),
178
-        'geodir_home_map_page' =>
179
-            apply_filters('geodir_set_custom_home_map_page', false)
180
-    ));
181
-
182
-
183
-    if (geodir_is_page('login') || $geodir_custom_page_list['geodir_signup_page']) {
184
-
185
-        $template = geodir_locate_template('signup');
186
-
187
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php';
188
-
189
-        /**
190
-         * Filter the signup template path.
191
-         *
192
-         * @since 1.0.0
193
-         * @param string $template The template path.
194
-         */
195
-        return $template = apply_filters('geodir_template_signup', $template);
196
-    }
197
-
198
-    if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) {
199
-        if (!geodir_is_default_location_set()) {
200
-            global $information;
201
-            $information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>');
202
-
203
-            $template = geodir_locate_template('information');
204
-
205
-            if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php';
206
-            /**
207
-             * Filter the information template path.
208
-             *
209
-             * @since 1.0.0
210
-             * @param string $template The template path.
211
-             */
212
-            return $template = apply_filters('geodir_template_information', $template);
213
-        }
214
-        // check if pid exists in the record if yes then check if this post belongs to the user who is logged in.
215
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
216
-            global $information;
217
-            $information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory');
218
-            $is_current_user_owner = geodir_listing_belong_to_current_user();
219
-            if (!$is_current_user_owner) {
220
-                $template = geodir_locate_template('information');
221
-
222
-                if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php';
223
-                /**
224
-                 * Filter the information template path.
225
-                 *
226
-                 * @since 1.0.0
227
-                 * @param string $template The template path.
228
-                 */
229
-                return $template = apply_filters('geodir_template_information', $template);
230
-            }
231
-
232
-
233
-        }
234
-
235
-        //geodir_is_login(true);
236
-        global $current_user;
237
-        if (!$current_user->ID) {
238
-            wp_redirect(geodir_login_url(array('redirect_add_listing'=>urlencode(geodir_curPageURL()))), 302);
239
-            exit;
240
-        }
241
-
242
-        $template = geodir_locate_template('add-listing');
243
-
244
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php';
245
-        /**
246
-         * Filter the add listing template path.
247
-         *
248
-         * @since 1.0.0
249
-         * @param string $template The template path.
250
-         */
251
-        return $template = apply_filters('geodir_template_add_listing', $template);
252
-    }
253
-
254
-
255
-    if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) {
256
-        global $preview;
257
-        $preview = true;
258
-
259
-        $template = geodir_locate_template('preview');
260
-
261
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php';
262
-        /**
263
-         * Filter the preview template path.
264
-         *
265
-         * @since 1.0.0
266
-         * @param string $template The template path.
267
-         */
268
-        return $template = apply_filters('geodir_template_preview', $template);
269
-
270
-    }
271
-
272
-
273
-    if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) {
274
-
275
-        $template = geodir_locate_template('success');
276
-
277
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php';
278
-        /**
279
-         * Filter the success template path.
280
-         *
281
-         * @since 1.0.0
282
-         * @param string $template The template path.
283
-         */
284
-        return $template = apply_filters('geodir_template_success', $template);
285
-
286
-    }
287
-
288
-    if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) {
289
-
290
-        $template = geodir_locate_template('detail');
291
-
292
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php';
293
-        /**
294
-         * Filter the detail template path.
295
-         *
296
-         * @since 1.0.0
297
-         * @param string $template The template path.
298
-         */
299
-        return $template = apply_filters('geodir_template_detail', $template);
300
-
301
-    }
302
-
303
-    if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) {
304
-
305
-        $template = geodir_locate_template('listing');
306
-
307
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php';
308
-        /**
309
-         * Filter the listing template path.
310
-         *
311
-         * @since 1.0.0
312
-         * @param string $template The template path.
313
-         */
314
-        return $template = apply_filters('geodir_template_listing', $template);
154
+	global $wp_query;
315 155
 
316
-    }
156
+	/**
157
+	 * Filter the custom page list.
158
+	 *
159
+	 * @since 1.0.0
160
+	 */
161
+	$geodir_custom_page_list = apply_filters('geodir_set_custom_pages', array(
162
+		'geodir_signup_page' =>
163
+			apply_filters('geodir_set_custom_signup_page', false),
164
+		'geodir_add_listing_page' =>
165
+			apply_filters('geodir_set_custom_add_listing_page', false),
166
+		'geodir_preview_page' =>
167
+			apply_filters('geodir_set_custom_preview_page', false),
168
+		'geodir_listing_success_page' =>
169
+			apply_filters('geodir_set_custom_listing_success_page', false),
170
+		'geodir_listing_detail_page' =>
171
+			apply_filters('geodir_set_custom_listing_detail_page', false),
172
+		'geodir_listing_page' =>
173
+			apply_filters('geodir_set_custom_listing_page', false),
174
+		'geodir_search_page' =>
175
+			apply_filters('geodir_set_custom_search_page', false),
176
+		'geodir_author_page' =>
177
+			apply_filters('geodir_set_custom_author_page', false),
178
+		'geodir_home_map_page' =>
179
+			apply_filters('geodir_set_custom_home_map_page', false)
180
+	));
181
+
182
+
183
+	if (geodir_is_page('login') || $geodir_custom_page_list['geodir_signup_page']) {
184
+
185
+		$template = geodir_locate_template('signup');
186
+
187
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php';
188
+
189
+		/**
190
+		 * Filter the signup template path.
191
+		 *
192
+		 * @since 1.0.0
193
+		 * @param string $template The template path.
194
+		 */
195
+		return $template = apply_filters('geodir_template_signup', $template);
196
+	}
317 197
 
318
-    if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) {
198
+	if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) {
199
+		if (!geodir_is_default_location_set()) {
200
+			global $information;
201
+			$information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>');
202
+
203
+			$template = geodir_locate_template('information');
204
+
205
+			if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php';
206
+			/**
207
+			 * Filter the information template path.
208
+			 *
209
+			 * @since 1.0.0
210
+			 * @param string $template The template path.
211
+			 */
212
+			return $template = apply_filters('geodir_template_information', $template);
213
+		}
214
+		// check if pid exists in the record if yes then check if this post belongs to the user who is logged in.
215
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
216
+			global $information;
217
+			$information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory');
218
+			$is_current_user_owner = geodir_listing_belong_to_current_user();
219
+			if (!$is_current_user_owner) {
220
+				$template = geodir_locate_template('information');
221
+
222
+				if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php';
223
+				/**
224
+				 * Filter the information template path.
225
+				 *
226
+				 * @since 1.0.0
227
+				 * @param string $template The template path.
228
+				 */
229
+				return $template = apply_filters('geodir_template_information', $template);
230
+			}
319 231
 
320
-        $template = geodir_locate_template('search');
321 232
 
322
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php';
323
-        /**
324
-         * Filter the search template path.
325
-         *
326
-         * @since 1.0.0
327
-         * @param string $template The template path.
328
-         */
329
-        return $template = apply_filters('geodir_template_search', $template);
233
+		}
234
+
235
+		//geodir_is_login(true);
236
+		global $current_user;
237
+		if (!$current_user->ID) {
238
+			wp_redirect(geodir_login_url(array('redirect_add_listing'=>urlencode(geodir_curPageURL()))), 302);
239
+			exit;
240
+		}
241
+
242
+		$template = geodir_locate_template('add-listing');
243
+
244
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php';
245
+		/**
246
+		 * Filter the add listing template path.
247
+		 *
248
+		 * @since 1.0.0
249
+		 * @param string $template The template path.
250
+		 */
251
+		return $template = apply_filters('geodir_template_add_listing', $template);
252
+	}
330 253
 
331
-    }
332 254
 
333
-    if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) {
255
+	if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) {
256
+		global $preview;
257
+		$preview = true;
334 258
 
335
-        $template = geodir_locate_template('author');
259
+		$template = geodir_locate_template('preview');
336 260
 
337
-        if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php';
338
-        /**
339
-         * Filter the author template path.
340
-         *
341
-         * @since 1.0.0
342
-         * @param string $template The template path.
343
-         */
344
-        return $template = apply_filters('geodir_template_author', $template);
261
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php';
262
+		/**
263
+		 * Filter the preview template path.
264
+		 *
265
+		 * @since 1.0.0
266
+		 * @param string $template The template path.
267
+		 */
268
+		return $template = apply_filters('geodir_template_preview', $template);
345 269
 
346
-    }
270
+	}
347 271
 
348
-    if (get_option('geodir_set_as_home') || geodir_is_page('home') || geodir_is_page('location')) {
349 272
 
350
-        global $post, $wp_query;
273
+	if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) {
351 274
 
352
-        if (geodir_is_page('home') || ('page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front'))
353
-            || (is_home() && !$wp_query->is_posts_page)
354
-        ) {
275
+		$template = geodir_locate_template('success');
355 276
 
356
-            $template = geodir_locate_template('geodir-home');
277
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php';
278
+		/**
279
+		 * Filter the success template path.
280
+		 *
281
+		 * @since 1.0.0
282
+		 * @param string $template The template path.
283
+		 */
284
+		return $template = apply_filters('geodir_template_success', $template);
357 285
 
358
-            if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php';
359
-            /**
360
-             * Filter the home page template path.
361
-             *
362
-             * @since 1.0.0
363
-             * @param string $template The template path.
364
-             */
365
-            return $template = apply_filters('geodir_template_homepage', $template);
286
+	}
366 287
 
367
-        } elseif (geodir_is_page('location')) {
288
+	if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) {
368 289
 
369
-            $template = geodir_locate_template('location');
290
+		$template = geodir_locate_template('detail');
370 291
 
371
-            if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php';
372
-            /**
373
-             * Filter the location template path.
374
-             *
375
-             * @since 1.0.0
376
-             * @param string $template The template path.
377
-             */
378
-            return $template = apply_filters('geodir_template_location', $template);
292
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php';
293
+		/**
294
+		 * Filter the detail template path.
295
+		 *
296
+		 * @since 1.0.0
297
+		 * @param string $template The template path.
298
+		 */
299
+		return $template = apply_filters('geodir_template_detail', $template);
300
+
301
+	}
302
+
303
+	if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) {
304
+
305
+		$template = geodir_locate_template('listing');
306
+
307
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php';
308
+		/**
309
+		 * Filter the listing template path.
310
+		 *
311
+		 * @since 1.0.0
312
+		 * @param string $template The template path.
313
+		 */
314
+		return $template = apply_filters('geodir_template_listing', $template);
315
+
316
+	}
379 317
 
380
-        } else
381
-            return $template;
318
+	if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) {
382 319
 
383
-    }
320
+		$template = geodir_locate_template('search');
384 321
 
385
-    return $template;
322
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php';
323
+		/**
324
+		 * Filter the search template path.
325
+		 *
326
+		 * @since 1.0.0
327
+		 * @param string $template The template path.
328
+		 */
329
+		return $template = apply_filters('geodir_template_search', $template);
330
+
331
+	}
332
+
333
+	if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) {
334
+
335
+		$template = geodir_locate_template('author');
336
+
337
+		if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php';
338
+		/**
339
+		 * Filter the author template path.
340
+		 *
341
+		 * @since 1.0.0
342
+		 * @param string $template The template path.
343
+		 */
344
+		return $template = apply_filters('geodir_template_author', $template);
345
+
346
+	}
347
+
348
+	if (get_option('geodir_set_as_home') || geodir_is_page('home') || geodir_is_page('location')) {
349
+
350
+		global $post, $wp_query;
351
+
352
+		if (geodir_is_page('home') || ('page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front'))
353
+			|| (is_home() && !$wp_query->is_posts_page)
354
+		) {
355
+
356
+			$template = geodir_locate_template('geodir-home');
357
+
358
+			if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php';
359
+			/**
360
+			 * Filter the home page template path.
361
+			 *
362
+			 * @since 1.0.0
363
+			 * @param string $template The template path.
364
+			 */
365
+			return $template = apply_filters('geodir_template_homepage', $template);
366
+
367
+		} elseif (geodir_is_page('location')) {
368
+
369
+			$template = geodir_locate_template('location');
370
+
371
+			if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php';
372
+			/**
373
+			 * Filter the location template path.
374
+			 *
375
+			 * @since 1.0.0
376
+			 * @param string $template The template path.
377
+			 */
378
+			return $template = apply_filters('geodir_template_location', $template);
379
+
380
+		} else
381
+			return $template;
382
+
383
+	}
384
+
385
+	return $template;
386 386
 }
387 387
 
388 388
 /**
@@ -397,44 +397,44 @@  discard block
 block discarded – undo
397 397
  */
398 398
 function geodir_get_template_part($slug = '', $name = NULL)
399 399
 {
400
-    global $geodirectory, $post;
401
-    /**
402
-     * Called at the start for the geodir_get_template_part() function.
403
-     *
404
-     * Used dynamic hook name: geodir_get_template_part_{$slug}
405
-     *
406
-     * @since 1.0.0
407
-     * @package GeoDirectory
408
-     * @param string $slug The template slug.
409
-     * @param string $name The template name.
410
-     */
411
-    do_action("geodir_get_template_part_{$slug}", $slug, $name);
412
-    $templates = array();
413
-    $name = (string)$name;
414
-    if ('' !== $name) {
415
-        $template_name = "{$slug}-{$name}.php";
416
-
417
-    } else {
418
-        $template_name = "{$slug}.php";
419
-    }
420
-
421
-    if (!locate_template(array("geodirectory/" . $template_name))) :
422
-        /**
423
-         * Filter the template part with slug and name.
424
-         *
425
-         * @since 1.0.0
426
-         * @param string $template_name The template name.
427
-         */
428
-        $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name);
429
-        /**
430
-         * Includes the template part with slug and name.
431
-         *
432
-         * @since 1.0.0
433
-         */
434
-        include($template);
435
-    else:
436
-        locate_template(array("geodirectory/" . $template_name), true, false);
437
-    endif;
400
+	global $geodirectory, $post;
401
+	/**
402
+	 * Called at the start for the geodir_get_template_part() function.
403
+	 *
404
+	 * Used dynamic hook name: geodir_get_template_part_{$slug}
405
+	 *
406
+	 * @since 1.0.0
407
+	 * @package GeoDirectory
408
+	 * @param string $slug The template slug.
409
+	 * @param string $name The template name.
410
+	 */
411
+	do_action("geodir_get_template_part_{$slug}", $slug, $name);
412
+	$templates = array();
413
+	$name = (string)$name;
414
+	if ('' !== $name) {
415
+		$template_name = "{$slug}-{$name}.php";
416
+
417
+	} else {
418
+		$template_name = "{$slug}.php";
419
+	}
420
+
421
+	if (!locate_template(array("geodirectory/" . $template_name))) :
422
+		/**
423
+		 * Filter the template part with slug and name.
424
+		 *
425
+		 * @since 1.0.0
426
+		 * @param string $template_name The template name.
427
+		 */
428
+		$template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name);
429
+		/**
430
+		 * Includes the template part with slug and name.
431
+		 *
432
+		 * @since 1.0.0
433
+		 */
434
+		include($template);
435
+	else:
436
+		locate_template(array("geodirectory/" . $template_name), true, false);
437
+	endif;
438 438
 
439 439
 }
440 440
 
@@ -450,23 +450,23 @@  discard block
 block discarded – undo
450 450
  */
451 451
 function geodir_core_post_view_extra_class($class, $all_postypes = '')
452 452
 {
453
-    global $post;
453
+	global $post;
454 454
 
455
-    if (!$all_postypes) {
456
-        $all_postypes = geodir_get_posttypes();
457
-    }
455
+	if (!$all_postypes) {
456
+		$all_postypes = geodir_get_posttypes();
457
+	}
458 458
 
459
-    $gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL;
460
-    $gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL;
461
-    $gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL;
459
+	$gdp_post_id = !empty($post) && isset($post->ID) ? $post->ID : NULL;
460
+	$gdp_post_type = $gdp_post_id > 0 && isset($post->post_type) ? $post->post_type : NULL;
461
+	$gdp_post_type = $gdp_post_type != '' && !empty($all_postypes) && in_array($gdp_post_type, $all_postypes) ? $gdp_post_type : NULL;
462 462
 
463
-    if ($gdp_post_id && $gdp_post_type) {
464
-        $append_class = 'gd-post-' . $gdp_post_type;
465
-        $append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : '';
466
-        $class = $class != '' ? $class . ' ' . $append_class : $append_class;
467
-    }
463
+	if ($gdp_post_id && $gdp_post_type) {
464
+		$append_class = 'gd-post-' . $gdp_post_type;
465
+		$append_class .= isset($post->is_featured) && $post->is_featured > 0 ? ' gd-post-featured' : '';
466
+		$class = $class != '' ? $class . ' ' . $append_class : $append_class;
467
+	}
468 468
 
469
-    return $class;
469
+	return $class;
470 470
 }
471 471
 
472 472
 /**
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
  * @param bool $favorite Listing Optional. Are favorite listings results? Default: false.
481 481
  */
482 482
 function geodir_display_message_not_found_on_listing($template_listview = 'listing-listview', $favorite = false) {
483
-    if ($favorite) {
483
+	if ($favorite) {
484 484
 		$message = __('No favorite listings found which match your selection.', 'geodirectory');
485 485
 	} else {
486 486
 		$message = __('No listings found which match your selection.', 'geodirectory');
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 1 patch
Indentation   +3356 added lines, -3356 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 function geodir_plugin_url()
29 29
 {
30 30
 
31
-    if (is_ssl()) :
32
-        return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
-    else :
34
-        return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
35
-    endif;
31
+	if (is_ssl()) :
32
+		return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
33
+	else :
34
+		return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__)));
35
+	endif;
36 36
 }
37 37
 
38 38
 
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_plugin_path()
49 49
 {
50
-    if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
-        return dirname(dirname(__FILE__));
52
-    } else {
53
-        return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
54
-    }
50
+	if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
51
+		return dirname(dirname(__FILE__));
52
+	} else {
53
+		return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__)));
54
+	}
55 55
 }
56 56
 
57 57
 /**
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
  */
66 66
 function geodir_is_plugin_active($plugin)
67 67
 {
68
-    $active_plugins = get_option('active_plugins');
69
-    foreach ($active_plugins as $key => $active_plugin) {
70
-        if (strstr($active_plugin, $plugin)) return true;
71
-    }
72
-    return false;
68
+	$active_plugins = get_option('active_plugins');
69
+	foreach ($active_plugins as $key => $active_plugin) {
70
+		if (strstr($active_plugin, $plugin)) return true;
71
+	}
72
+	return false;
73 73
 }
74 74
 
75 75
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_get_formated_date($date)
87 87
 {
88
-    return mysql2date(get_option('date_format'), $date);
88
+	return mysql2date(get_option('date_format'), $date);
89 89
 }
90 90
 
91 91
 /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_get_formated_time($time)
102 102
 {
103
-    return mysql2date(get_option('time_format'), $time, $translate = true);
103
+	return mysql2date(get_option('time_format'), $time, $translate = true);
104 104
 }
105 105
 
106 106
 
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function geodir_getlink($url, $params = array(), $use_existing_arguments = false)
120 120
 {
121
-    if ($use_existing_arguments) $params = $params + $_GET;
122
-    if (!$params) return $url;
123
-    $link = $url;
124
-    if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
-    elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
-    elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
127
-
128
-    $params_arr = array();
129
-    foreach ($params as $key => $value) {
130
-        if (gettype($value) == 'array') { //Handle array data properly
131
-            foreach ($value as $val) {
132
-                $params_arr[] = $key . '[]=' . urlencode($val);
133
-            }
134
-        } else {
135
-            $params_arr[] = $key . '=' . urlencode($value);
136
-        }
137
-    }
138
-    $link .= implode('&', $params_arr);
139
-
140
-    return $link;
121
+	if ($use_existing_arguments) $params = $params + $_GET;
122
+	if (!$params) return $url;
123
+	$link = $url;
124
+	if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end
125
+	elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&amp;'; //If there is no '&' at the END, add one.
126
+	elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
127
+
128
+	$params_arr = array();
129
+	foreach ($params as $key => $value) {
130
+		if (gettype($value) == 'array') { //Handle array data properly
131
+			foreach ($value as $val) {
132
+				$params_arr[] = $key . '[]=' . urlencode($val);
133
+			}
134
+		} else {
135
+			$params_arr[] = $key . '=' . urlencode($value);
136
+		}
137
+	}
138
+	$link .= implode('&', $params_arr);
139
+
140
+	return $link;
141 141
 }
142 142
 
143 143
 
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
  */
153 153
 function geodir_get_addlisting_link($post_type = '')
154 154
 {
155
-    global $wpdb;
155
+	global $wpdb;
156 156
 
157
-    //$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
158
-    $check_pkg = 1;
159
-    if (post_type_exists($post_type) && $check_pkg) {
157
+	//$check_pkg  = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
158
+	$check_pkg = 1;
159
+	if (post_type_exists($post_type) && $check_pkg) {
160 160
 
161
-        $add_listing_link = get_page_link(geodir_add_listing_page_id());
161
+		$add_listing_link = get_page_link(geodir_add_listing_page_id());
162 162
 
163
-        return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
-    } else
165
-        return get_bloginfo('url');
163
+		return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
164
+	} else
165
+		return get_bloginfo('url');
166 166
 }
167 167
 
168 168
 /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
  */
176 176
 function geodir_curPageURL()
177 177
 {
178
-    $pageURL = 'http';
179
-    if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
180
-        $pageURL .= "s";
181
-    }
182
-    $pageURL .= "://";
183
-    $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
184
-    /**
185
-     * Filter the current page URL returned by function geodir_curPageURL().
186
-     *
187
-     * @since 1.4.1
188
-     * @param string $pageURL The URL of the current page.
189
-     */
190
-    return apply_filters('geodir_curPageURL', $pageURL);
178
+	$pageURL = 'http';
179
+	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
180
+		$pageURL .= "s";
181
+	}
182
+	$pageURL .= "://";
183
+	$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
184
+	/**
185
+	 * Filter the current page URL returned by function geodir_curPageURL().
186
+	 *
187
+	 * @since 1.4.1
188
+	 * @param string $pageURL The URL of the current page.
189
+	 */
190
+	return apply_filters('geodir_curPageURL', $pageURL);
191 191
 }
192 192
 
193 193
 
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 function geodir_clean($string)
205 205
 {
206 206
 
207
-    $string = trim(strip_tags(stripslashes($string)));
208
-    $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
209
-    $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
210
-    $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
207
+	$string = trim(strip_tags(stripslashes($string)));
208
+	$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
209
+	$string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
210
+	$string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
211 211
 
212
-    return $string;
212
+	return $string;
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  */
222 222
 function geodir_get_weekday()
223 223
 {
224
-    return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
224
+	return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
225 225
 }
226 226
 
227 227
 /**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function geodir_get_weeks()
235 235
 {
236
-    return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
236
+	return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
237 237
 }
238 238
 
239 239
 
@@ -252,103 +252,103 @@  discard block
 block discarded – undo
252 252
 function geodir_is_page($gdpage = '')
253 253
 {
254 254
 
255
-    global $wp_query, $post,$wp;
256
-    //if(!is_admin()):
257
-
258
-    switch ($gdpage):
259
-        case 'add-listing':
260
-
261
-            if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
262
-                return true;
263
-            } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
264
-                return true;
265
-            }
266
-
267
-            break;
268
-        case 'preview':
269
-            if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270
-                && in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
-            )
272
-                return true;
273
-            break;
274
-        case 'listing-success':
275
-            if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
-                return true;
277
-            break;
278
-        case 'detail':
279
-            $post_type = get_query_var('post_type');
280
-            if(is_array($post_type)){$post_type = reset($post_type);}
281
-            if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
-                return true;
283
-            break;
284
-        case 'pt':
285
-            $post_type = get_query_var('post_type');
286
-            if(is_array($post_type)){$post_type = reset($post_type);}
287
-            if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
-                return true;
289
-
290
-            break;
291
-        case 'listing':
292
-            if (is_tax() && geodir_get_taxonomy_posttype()) {
293
-                global $current_term, $taxonomy, $term;
294
-
295
-                return true;
296
-            }
297
-            $post_type = get_query_var('post_type');
298
-            if(is_array($post_type)){$post_type = reset($post_type);}
299
-            if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
-                return true;
301
-
302
-            break;
303
-        case 'home':
304
-
305
-            if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
-                return true;
307
-
308
-            break;
309
-        case 'location':
310
-            if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
-                return true;
312
-            break;
313
-        case 'author':
314
-            if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
-                return true;
255
+	global $wp_query, $post,$wp;
256
+	//if(!is_admin()):
257
+
258
+	switch ($gdpage):
259
+		case 'add-listing':
260
+
261
+			if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
262
+				return true;
263
+			} elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
264
+				return true;
265
+			}
266
+
267
+			break;
268
+		case 'preview':
269
+			if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
270
+				&& in_array($_REQUEST['listing_type'], geodir_get_posttypes())
271
+			)
272
+				return true;
273
+			break;
274
+		case 'listing-success':
275
+			if (is_page() && get_query_var('page_id') == geodir_success_page_id())
276
+				return true;
277
+			break;
278
+		case 'detail':
279
+			$post_type = get_query_var('post_type');
280
+			if(is_array($post_type)){$post_type = reset($post_type);}
281
+			if (is_single() && in_array($post_type, geodir_get_posttypes()))
282
+				return true;
283
+			break;
284
+		case 'pt':
285
+			$post_type = get_query_var('post_type');
286
+			if(is_array($post_type)){$post_type = reset($post_type);}
287
+			if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax())
288
+				return true;
289
+
290
+			break;
291
+		case 'listing':
292
+			if (is_tax() && geodir_get_taxonomy_posttype()) {
293
+				global $current_term, $taxonomy, $term;
294
+
295
+				return true;
296
+			}
297
+			$post_type = get_query_var('post_type');
298
+			if(is_array($post_type)){$post_type = reset($post_type);}
299
+			if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()))
300
+				return true;
301
+
302
+			break;
303
+		case 'home':
304
+
305
+			if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
306
+				return true;
307
+
308
+			break;
309
+		case 'location':
310
+			if (is_page() && get_query_var('page_id') == geodir_location_page_id())
311
+				return true;
312
+			break;
313
+		case 'author':
314
+			if (is_author() && isset($_REQUEST['geodir_dashbord']))
315
+				return true;
316 316
 			
317 317
 			if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
318 318
 				if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
319 319
 					return true;
320 320
 				}
321 321
 			}
322
-            break;
323
-        case 'search':
324
-            if (is_search() && isset($_REQUEST['geodir_search']))
325
-                return true;
326
-            break;
327
-        case 'info':
328
-            if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
-                return true;
330
-            break;
331
-        case 'login':
332
-            if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
-                return true;
334
-            break;
335
-        case 'checkout':
336
-            if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
-                return true;
338
-            break;
339
-        case 'invoices':
340
-            if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
-                return true;
342
-            break;
343
-        default:
344
-            return false;
345
-            break;
346
-
347
-    endswitch;
348
-
349
-    //endif;
350
-
351
-    return false;
322
+			break;
323
+		case 'search':
324
+			if (is_search() && isset($_REQUEST['geodir_search']))
325
+				return true;
326
+			break;
327
+		case 'info':
328
+			if (is_page() && get_query_var('page_id') == geodir_info_page_id())
329
+				return true;
330
+			break;
331
+		case 'login':
332
+			if (is_page() && get_query_var('page_id') == geodir_login_page_id())
333
+				return true;
334
+			break;
335
+		case 'checkout':
336
+			if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
337
+				return true;
338
+			break;
339
+		case 'invoices':
340
+			if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
341
+				return true;
342
+			break;
343
+		default:
344
+			return false;
345
+			break;
346
+
347
+	endswitch;
348
+
349
+	//endif;
350
+
351
+	return false;
352 352
 }
353 353
 
354 354
 /**
@@ -362,97 +362,97 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function geodir_set_is_geodir_page($wp)
364 364
 {
365
-    if (!is_admin()) {
366
-        //$wp->query_vars['gd_is_geodir_page'] = false;
367
-        //print_r()
368
-        if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
-            if (get_option('geodir_set_as_home'))
370
-                $wp->query_vars['gd_is_geodir_page'] = true;
371
-            if(geodir_is_page('home')){
372
-                $wp->query_vars['gd_is_geodir_page'] = true;
373
-            }
374
-
375
-
376
-        }
377
-
378
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
379
-            if (
380
-                $wp->query_vars['page_id'] == geodir_add_listing_page_id()
381
-                || $wp->query_vars['page_id'] == geodir_preview_page_id()
382
-                || $wp->query_vars['page_id'] == geodir_success_page_id()
383
-                || $wp->query_vars['page_id'] == geodir_location_page_id()
384
-                || $wp->query_vars['page_id'] == geodir_home_page_id()
385
-                || $wp->query_vars['page_id'] == geodir_info_page_id()
386
-                || $wp->query_vars['page_id'] == geodir_login_page_id()
387
-                || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388
-                || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
-            )
390
-                $wp->query_vars['gd_is_geodir_page'] = true;
391
-        }
392
-
393
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
394
-            $page = get_page_by_path($wp->query_vars['pagename']);
395
-
396
-            if (!empty($page) && (
397
-                    $page->ID == geodir_add_listing_page_id()
398
-                    || $page->ID == geodir_preview_page_id()
399
-                    || $page->ID == geodir_success_page_id()
400
-                    || $page->ID == geodir_location_page_id()
401
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
402
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
403
-                    || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
404
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405
-                    || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406
-                )
407
-            )
408
-                $wp->query_vars['gd_is_geodir_page'] = true;
409
-        }
410
-
411
-
412
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
413
-            $requested_post_type = $wp->query_vars['post_type'];
414
-            // check if this post type is geodirectory post types 
415
-            $post_type_array = geodir_get_posttypes();
416
-            if (in_array($requested_post_type, $post_type_array)) {
417
-                $wp->query_vars['gd_is_geodir_page'] = true;
418
-            }
419
-        }
420
-
421
-        if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422
-            $geodir_taxonomis = geodir_get_taxonomies('', true);
423
-            if(!empty($geodir_taxonomis)){
424
-                foreach ($geodir_taxonomis as $taxonomy) {
425
-                    if (array_key_exists($taxonomy, $wp->query_vars)) {
426
-                        $wp->query_vars['gd_is_geodir_page'] = true;
427
-                        break;
428
-                    }
429
-                }
430
-            }
431
-
432
-        }
433
-
434
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
-            $wp->query_vars['gd_is_geodir_page'] = true;
436
-
437
-
438
-        if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
-            $wp->query_vars['gd_is_geodir_page'] = true;
365
+	if (!is_admin()) {
366
+		//$wp->query_vars['gd_is_geodir_page'] = false;
367
+		//print_r()
368
+		if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
369
+			if (get_option('geodir_set_as_home'))
370
+				$wp->query_vars['gd_is_geodir_page'] = true;
371
+			if(geodir_is_page('home')){
372
+				$wp->query_vars['gd_is_geodir_page'] = true;
373
+			}
374
+
375
+
376
+		}
377
+
378
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
379
+			if (
380
+				$wp->query_vars['page_id'] == geodir_add_listing_page_id()
381
+				|| $wp->query_vars['page_id'] == geodir_preview_page_id()
382
+				|| $wp->query_vars['page_id'] == geodir_success_page_id()
383
+				|| $wp->query_vars['page_id'] == geodir_location_page_id()
384
+				|| $wp->query_vars['page_id'] == geodir_home_page_id()
385
+				|| $wp->query_vars['page_id'] == geodir_info_page_id()
386
+				|| $wp->query_vars['page_id'] == geodir_login_page_id()
387
+				|| (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
388
+				|| (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
389
+			)
390
+				$wp->query_vars['gd_is_geodir_page'] = true;
391
+		}
392
+
393
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
394
+			$page = get_page_by_path($wp->query_vars['pagename']);
395
+
396
+			if (!empty($page) && (
397
+					$page->ID == geodir_add_listing_page_id()
398
+					|| $page->ID == geodir_preview_page_id()
399
+					|| $page->ID == geodir_success_page_id()
400
+					|| $page->ID == geodir_location_page_id()
401
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id())
402
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id())
403
+					|| (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id())
404
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
405
+					|| (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
406
+				)
407
+			)
408
+				$wp->query_vars['gd_is_geodir_page'] = true;
409
+		}
410
+
411
+
412
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
413
+			$requested_post_type = $wp->query_vars['post_type'];
414
+			// check if this post type is geodirectory post types 
415
+			$post_type_array = geodir_get_posttypes();
416
+			if (in_array($requested_post_type, $post_type_array)) {
417
+				$wp->query_vars['gd_is_geodir_page'] = true;
418
+			}
419
+		}
420
+
421
+		if (!isset($wp->query_vars['gd_is_geodir_page'])) {
422
+			$geodir_taxonomis = geodir_get_taxonomies('', true);
423
+			if(!empty($geodir_taxonomis)){
424
+				foreach ($geodir_taxonomis as $taxonomy) {
425
+					if (array_key_exists($taxonomy, $wp->query_vars)) {
426
+						$wp->query_vars['gd_is_geodir_page'] = true;
427
+						break;
428
+					}
429
+				}
430
+			}
431
+
432
+		}
433
+
434
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord']))
435
+			$wp->query_vars['gd_is_geodir_page'] = true;
436
+
437
+
438
+		if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search']))
439
+			$wp->query_vars['gd_is_geodir_page'] = true;
440 440
 
441 441
 
442 442
 //check if homepage
443
-        if(!isset($wp->query_vars['gd_is_geodir_page'])
444
-            && !isset($wp->query_vars['page_id'])
445
-            && !isset($wp->query_vars['pagename'])
446
-            && is_page_geodir_home()){
447
-            $wp->query_vars['gd_is_geodir_page'] = true;
448
-        }
449
-        //echo $wp->query_vars['gd_is_geodir_page'] ;
450
-        /*echo "<pre>" ;
443
+		if(!isset($wp->query_vars['gd_is_geodir_page'])
444
+			&& !isset($wp->query_vars['page_id'])
445
+			&& !isset($wp->query_vars['pagename'])
446
+			&& is_page_geodir_home()){
447
+			$wp->query_vars['gd_is_geodir_page'] = true;
448
+		}
449
+		//echo $wp->query_vars['gd_is_geodir_page'] ;
450
+		/*echo "<pre>" ;
451 451
 		print_r($wp) ;
452 452
 		echo "</pre>" ;
453 453
 	//	exit();
454 454
 			*/
455
-    } // end of is admin
455
+	} // end of is admin
456 456
 }
457 457
 
458 458
 /**
@@ -465,56 +465,56 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function geodir_is_geodir_page()
467 467
 {
468
-    global $wp;
469
-    if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
-        return true;
471
-    else
472
-        return false;
468
+	global $wp;
469
+	if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page'])
470
+		return true;
471
+	else
472
+		return false;
473 473
 }
474 474
 
475 475
 if (!function_exists('geodir_get_imagesize')) {
476
-    /**
477
-     * Get image size using the size key .
478
-     *
479
-     * @since 1.0.0
480
-     * @package GeoDirectory
481
-     * @param string $size The image size key.
482
-     * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
483
-     */
484
-    function geodir_get_imagesize($size = '')
485
-    {
486
-
487
-        $imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
488
-            'thumbnail' => array('w' => 125, 'h' => 125),
489
-            'widget-thumb' => array('w' => 50, 'h' => 50),
490
-            'slider-thumb' => array('w' => 100, 'h' => 100)
491
-        );
492
-
493
-        /**
494
-         * Filter the image sizes array.
495
-         *
496
-         * @since 1.0.0
497
-         * @param array $imagesizes Image size array.
498
-         */
499
-        $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
500
-
501
-        if (!empty($size) && array_key_exists($size, $imagesizes)) {
502
-            /**
503
-             * Filters image size of the passed key.
504
-             *
505
-             * @since 1.0.0
506
-             * @param array $imagesizes[$size] Image size array of the passed key.
507
-             */
508
-            return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
509
-
510
-        } elseif (!empty($size)) {
511
-
512
-            return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
513
-
514
-        }
515
-
516
-        return $imagesizes;
517
-    }
476
+	/**
477
+	 * Get image size using the size key .
478
+	 *
479
+	 * @since 1.0.0
480
+	 * @package GeoDirectory
481
+	 * @param string $size The image size key.
482
+	 * @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
483
+	 */
484
+	function geodir_get_imagesize($size = '')
485
+	{
486
+
487
+		$imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
488
+			'thumbnail' => array('w' => 125, 'h' => 125),
489
+			'widget-thumb' => array('w' => 50, 'h' => 50),
490
+			'slider-thumb' => array('w' => 100, 'h' => 100)
491
+		);
492
+
493
+		/**
494
+		 * Filter the image sizes array.
495
+		 *
496
+		 * @since 1.0.0
497
+		 * @param array $imagesizes Image size array.
498
+		 */
499
+		$imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
500
+
501
+		if (!empty($size) && array_key_exists($size, $imagesizes)) {
502
+			/**
503
+			 * Filters image size of the passed key.
504
+			 *
505
+			 * @since 1.0.0
506
+			 * @param array $imagesizes[$size] Image size array of the passed key.
507
+			 */
508
+			return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
509
+
510
+		} elseif (!empty($size)) {
511
+
512
+			return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
513
+
514
+		}
515
+
516
+		return $imagesizes;
517
+	}
518 518
 }
519 519
 
520 520
 /**
@@ -534,151 +534,151 @@  discard block
 block discarded – undo
534 534
 
535 535
 
536 536
 if (!function_exists('createRandomString')) {
537
-    /**
538
-     * Creates random string.
539
-     *
540
-     * @since 1.0.0
541
-     * @package GeoDirectory
542
-     * @return string Random string.
543
-     */
544
-    function createRandomString()
545
-    {
546
-        $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
-        srand((double)microtime() * 1000000);
548
-        $i = 0;
549
-        $rstring = '';
550
-        while ($i <= 25) {
551
-            $num = rand() % 33;
552
-            $tmp = substr($chars, $num, 1);
553
-            $rstring = $rstring . $tmp;
554
-            $i++;
555
-        }
556
-        return $rstring;
557
-    }
537
+	/**
538
+	 * Creates random string.
539
+	 *
540
+	 * @since 1.0.0
541
+	 * @package GeoDirectory
542
+	 * @return string Random string.
543
+	 */
544
+	function createRandomString()
545
+	{
546
+		$chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
547
+		srand((double)microtime() * 1000000);
548
+		$i = 0;
549
+		$rstring = '';
550
+		while ($i <= 25) {
551
+			$num = rand() % 33;
552
+			$tmp = substr($chars, $num, 1);
553
+			$rstring = $rstring . $tmp;
554
+			$i++;
555
+		}
556
+		return $rstring;
557
+	}
558 558
 }
559 559
 
560 560
 if (!function_exists('geodir_getDistanceRadius')) {
561
-    /**
562
-     * Calculates the distance radius.
563
-     *
564
-     * @since 1.0.0
565
-     * @package GeoDirectory
566
-     * @param string $uom Measurement unit type.
567
-     * @return float The mean radius.
568
-     */
569
-    function geodir_getDistanceRadius($uom = 'km')
570
-    {
561
+	/**
562
+	 * Calculates the distance radius.
563
+	 *
564
+	 * @since 1.0.0
565
+	 * @package GeoDirectory
566
+	 * @param string $uom Measurement unit type.
567
+	 * @return float The mean radius.
568
+	 */
569
+	function geodir_getDistanceRadius($uom = 'km')
570
+	{
571 571
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
572
-        switch (geodir_strtolower($uom)):
573
-            case 'km'    :
574
-                $earthMeanRadius = 6371.009; // km
575
-                break;
576
-            case 'm'    :
577
-            case 'meters'    :
578
-                $earthMeanRadius = 6371.009 * 1000; // km
579
-                break;
580
-            case 'miles'    :
581
-                $earthMeanRadius = 3958.761; // miles
582
-                break;
583
-            case 'yards'    :
584
-            case 'yds'    :
585
-                $earthMeanRadius = 3958.761 * 1760; // yards
586
-                break;
587
-            case 'feet'    :
588
-            case 'ft'    :
589
-                $earthMeanRadius = 3958.761 * 1760 * 3; // feet
590
-                break;
591
-            case 'nm'    :
592
-                $earthMeanRadius = 3440.069; //  miles
593
-                break;
594
-            default:
595
-                $earthMeanRadius = 3958.761; // miles
596
-                break;
597
-        endswitch;
598
-        return $earthMeanRadius;
599
-    }
572
+		switch (geodir_strtolower($uom)):
573
+			case 'km'    :
574
+				$earthMeanRadius = 6371.009; // km
575
+				break;
576
+			case 'm'    :
577
+			case 'meters'    :
578
+				$earthMeanRadius = 6371.009 * 1000; // km
579
+				break;
580
+			case 'miles'    :
581
+				$earthMeanRadius = 3958.761; // miles
582
+				break;
583
+			case 'yards'    :
584
+			case 'yds'    :
585
+				$earthMeanRadius = 3958.761 * 1760; // yards
586
+				break;
587
+			case 'feet'    :
588
+			case 'ft'    :
589
+				$earthMeanRadius = 3958.761 * 1760 * 3; // feet
590
+				break;
591
+			case 'nm'    :
592
+				$earthMeanRadius = 3440.069; //  miles
593
+				break;
594
+			default:
595
+				$earthMeanRadius = 3958.761; // miles
596
+				break;
597
+		endswitch;
598
+		return $earthMeanRadius;
599
+	}
600 600
 }
601 601
 
602 602
 
603 603
 if (!function_exists('geodir_calculateDistanceFromLatLong')) {
604
-    /**
605
-     * Calculate the great circle distance between two points identified by longitude and latitude.
606
-     *
607
-     * @since 1.0.0
608
-     * @package GeoDirectory
609
-     * @param array $point1 Latitude and Longitude of point 1.
610
-     * @param array $point2 Latitude and Longitude of point 2.
611
-     * @param string $uom Unit of measurement.
612
-     * @return float The distance.
613
-     */
614
-    function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
615
-    {
604
+	/**
605
+	 * Calculate the great circle distance between two points identified by longitude and latitude.
606
+	 *
607
+	 * @since 1.0.0
608
+	 * @package GeoDirectory
609
+	 * @param array $point1 Latitude and Longitude of point 1.
610
+	 * @param array $point2 Latitude and Longitude of point 2.
611
+	 * @param string $uom Unit of measurement.
612
+	 * @return float The distance.
613
+	 */
614
+	function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km')
615
+	{
616 616
 //	Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
617 617
 
618
-        $earthMeanRadius = geodir_getDistanceRadius($uom);
618
+		$earthMeanRadius = geodir_getDistanceRadius($uom);
619 619
 
620
-        $deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']);
621
-        $deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']);
622
-        $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
623
-            cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) *
624
-            sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
625
-        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
626
-        $distance = $earthMeanRadius * $c;
627
-        return $distance;
620
+		$deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']);
621
+		$deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']);
622
+		$a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
623
+			cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) *
624
+			sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
625
+		$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
626
+		$distance = $earthMeanRadius * $c;
627
+		return $distance;
628 628
 
629
-    }
629
+	}
630 630
 }
631 631
 
632 632
 
633 633
 if (!function_exists('geodir_sendEmail')) {
634
-    /**
635
-     * The main function that send transactional emails using the args provided.
636
-     *
637
-     * @since 1.0.0
638
-     * @since 1.5.7 Added db translations for notifications subject and content.
639
-     * @package GeoDirectory
640
-     * @param string $fromEmail Sender email address.
641
-     * @param string $fromEmailName Sender name.
642
-     * @param string $toEmail Receiver email address.
643
-     * @param string $toEmailName Receiver name.
644
-     * @param string $to_subject Email subject.
645
-     * @param string $to_message Email content.
646
-     * @param string $extra Not being used.
647
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
648
-     * @param string $post_id The post ID.
649
-     * @param string $user_id The user ID.
650
-     */
651
-    function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
652
-        $login_details = '';
653
-
654
-        // strip slashes from subject & message text
655
-        $to_subject = stripslashes_deep($to_subject);
656
-        $to_message = stripslashes_deep($to_message);
657
-
658
-        if ($message_type == 'send_friend') {
659
-            $subject = get_option('geodir_email_friend_subject');
660
-            $message = get_option('geodir_email_friend_content');
661
-        } elseif ($message_type == 'send_enquiry') {
662
-            $subject = get_option('geodir_email_enquiry_subject');
663
-            $message = get_option('geodir_email_enquiry_content');
664
-        } elseif ($message_type == 'forgot_password') {
665
-            $subject = get_option('geodir_forgot_password_subject');
666
-            $message = get_option('geodir_forgot_password_content');
667
-            $login_details = $to_message;
668
-        } elseif ($message_type == 'registration') {
669
-            $subject = get_option('geodir_registration_success_email_subject');
670
-            $message = get_option('geodir_registration_success_email_content');
671
-            $login_details = $to_message;
672
-        } elseif ($message_type == 'post_submit') {
673
-            $subject = get_option('geodir_post_submited_success_email_subject');
674
-            $message = get_option('geodir_post_submited_success_email_content');
675
-        } elseif ($message_type == 'listing_published') {
676
-            $subject = get_option('geodir_post_published_email_subject');
677
-            $message = get_option('geodir_post_published_email_content');
678
-        } elseif ($message_type == 'listing_edited') {
679
-            $subject = get_option('geodir_post_edited_email_subject_admin');
680
-            $message = get_option('geodir_post_edited_email_content_admin');
681
-        }
634
+	/**
635
+	 * The main function that send transactional emails using the args provided.
636
+	 *
637
+	 * @since 1.0.0
638
+	 * @since 1.5.7 Added db translations for notifications subject and content.
639
+	 * @package GeoDirectory
640
+	 * @param string $fromEmail Sender email address.
641
+	 * @param string $fromEmailName Sender name.
642
+	 * @param string $toEmail Receiver email address.
643
+	 * @param string $toEmailName Receiver name.
644
+	 * @param string $to_subject Email subject.
645
+	 * @param string $to_message Email content.
646
+	 * @param string $extra Not being used.
647
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
648
+	 * @param string $post_id The post ID.
649
+	 * @param string $user_id The user ID.
650
+	 */
651
+	function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
652
+		$login_details = '';
653
+
654
+		// strip slashes from subject & message text
655
+		$to_subject = stripslashes_deep($to_subject);
656
+		$to_message = stripslashes_deep($to_message);
657
+
658
+		if ($message_type == 'send_friend') {
659
+			$subject = get_option('geodir_email_friend_subject');
660
+			$message = get_option('geodir_email_friend_content');
661
+		} elseif ($message_type == 'send_enquiry') {
662
+			$subject = get_option('geodir_email_enquiry_subject');
663
+			$message = get_option('geodir_email_enquiry_content');
664
+		} elseif ($message_type == 'forgot_password') {
665
+			$subject = get_option('geodir_forgot_password_subject');
666
+			$message = get_option('geodir_forgot_password_content');
667
+			$login_details = $to_message;
668
+		} elseif ($message_type == 'registration') {
669
+			$subject = get_option('geodir_registration_success_email_subject');
670
+			$message = get_option('geodir_registration_success_email_content');
671
+			$login_details = $to_message;
672
+		} elseif ($message_type == 'post_submit') {
673
+			$subject = get_option('geodir_post_submited_success_email_subject');
674
+			$message = get_option('geodir_post_submited_success_email_content');
675
+		} elseif ($message_type == 'listing_published') {
676
+			$subject = get_option('geodir_post_published_email_subject');
677
+			$message = get_option('geodir_post_published_email_content');
678
+		} elseif ($message_type == 'listing_edited') {
679
+			$subject = get_option('geodir_post_edited_email_subject_admin');
680
+			$message = get_option('geodir_post_edited_email_content_admin');
681
+		}
682 682
 		
683 683
 		if (!empty($subject)) {
684 684
 			$subject = __(stripslashes_deep($subject),'geodirectory');
@@ -688,203 +688,203 @@  discard block
 block discarded – undo
688 688
 			$message = __(stripslashes_deep($message),'geodirectory');
689 689
 		}
690 690
 
691
-        $to_message = nl2br($to_message);
692
-        $sitefromEmail = get_option('site_email');
693
-        $sitefromEmailName = get_site_emailName();
694
-        $productlink = get_permalink($post_id);
695
-
696
-        $user_login = '';
697
-        if ($user_id > 0 && $user_info = get_userdata($user_id)) {
698
-            $user_login = $user_info->user_login;
699
-        }
700
-
701
-        $posted_date = '';
702
-        $listingLink = '';
703
-
704
-        $post_info = get_post($post_id);
705
-
706
-        if ($post_info) {
707
-            $posted_date = $post_info->post_date;
708
-            $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
709
-        }
710
-        $siteurl = home_url();
711
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
712
-        $loginurl = geodir_login_url();
713
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
691
+		$to_message = nl2br($to_message);
692
+		$sitefromEmail = get_option('site_email');
693
+		$sitefromEmailName = get_site_emailName();
694
+		$productlink = get_permalink($post_id);
695
+
696
+		$user_login = '';
697
+		if ($user_id > 0 && $user_info = get_userdata($user_id)) {
698
+			$user_login = $user_info->user_login;
699
+		}
700
+
701
+		$posted_date = '';
702
+		$listingLink = '';
703
+
704
+		$post_info = get_post($post_id);
705
+
706
+		if ($post_info) {
707
+			$posted_date = $post_info->post_date;
708
+			$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
709
+		}
710
+		$siteurl = home_url();
711
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
712
+		$loginurl = geodir_login_url();
713
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
714 714
         
715
-        $post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716
-        $post_author_name = geodir_get_client_name($post_author_id);
717
-        $current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
718
-
719
-        if ($fromEmail == '') {
720
-            $fromEmail = get_option('site_email');
721
-        }
722
-
723
-        if ($fromEmailName == '') {
724
-            $fromEmailName = get_option('site_email_name');
725
-        }
726
-
727
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729
-        $message = str_replace($search_array, $replace_array, $message);
730
-
731
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733
-        $subject = str_replace($search_array, $replace_array, $subject);
734
-
735
-        $headers = 'MIME-Version: 1.0' . "\r\n";
736
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
738
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
739
-
740
-        $to = $toEmail;
741
-
742
-        /**
743
-         * Filter the client email to address.
744
-         *
745
-         * @since 1.6.1
746
-         * @package GeoDirectory
747
-         * @param string $to The email address the email is being sent to.
748
-         * @param string $fromEmail Sender email address.
749
-         * @param string $fromEmailName Sender name.
750
-         * @param string $toEmail Receiver email address.
751
-         * @param string $toEmailName Receiver name.
752
-         * @param string $to_subject Email subject.
753
-         * @param string $to_message Email content.
754
-         * @param string $extra Not being used.
755
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
756
-         * @param string $post_id The post ID.
757
-         * @param string $user_id The user ID.
758
-         */
759
-        $to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
760
-        /**
761
-         * Filter the client email subject.
762
-         *
763
-         * @since 1.6.1
764
-         * @package GeoDirectory_Payment_Manager
765
-         * @param string $subject The email subject.
766
-         * @param string $fromEmail Sender email address.
767
-         * @param string $fromEmailName Sender name.
768
-         * @param string $toEmail Receiver email address.
769
-         * @param string $toEmailName Receiver name.
770
-         * @param string $to_subject Email subject.
771
-         * @param string $to_message Email content.
772
-         * @param string $extra Not being used.
773
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
774
-         * @param string $post_id The post ID.
775
-         * @param string $user_id The user ID.
776
-         */
777
-        $subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
778
-        /**
779
-         * Filter the client email message.
780
-         *
781
-         * @since 1.6.1
782
-         * @package GeoDirectory_Payment_Manager
783
-         * @param string $message The email message text.
784
-         * @param string $fromEmail Sender email address.
785
-         * @param string $fromEmailName Sender name.
786
-         * @param string $toEmail Receiver email address.
787
-         * @param string $toEmailName Receiver name.
788
-         * @param string $to_subject Email subject.
789
-         * @param string $to_message Email content.
790
-         * @param string $extra Not being used.
791
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
792
-         * @param string $post_id The post ID.
793
-         * @param string $user_id The user ID.
794
-         */
795
-        $message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
796
-        /**
797
-         * Filter the client email headers.
798
-         *
799
-         * @since 1.6.1
800
-         * @package GeoDirectory_Payment_Manager
801
-         * @param string $headers The email headers.
802
-         * @param string $fromEmail Sender email address.
803
-         * @param string $fromEmailName Sender name.
804
-         * @param string $toEmail Receiver email address.
805
-         * @param string $toEmailName Receiver name.
806
-         * @param string $to_subject Email subject.
807
-         * @param string $to_message Email content.
808
-         * @param string $extra Not being used.
809
-         * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
810
-         * @param string $post_id The post ID.
811
-         * @param string $user_id The user ID.
812
-         */
813
-        $headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
814
-
815
-        $sent = wp_mail($to, $subject, $message, $headers);
816
-
817
-        if( ! $sent ) {
818
-            if ( is_array( $to ) ) {
819
-                $to = implode( ',', $to );
820
-            }
821
-            $log_message = sprintf(
822
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
823
-                $message_type,
824
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
825
-                $to,
826
-                $subject
827
-            );
828
-            geodir_error_log( $log_message );
829
-        }
830
-
831
-        ///////// ADMIN BCC EMIALS
832
-        $adminEmail = get_bloginfo('admin_email');
833
-        $to = $adminEmail;
834
-
835
-        $admin_bcc = false;
836
-        if ($message_type == 'post_submit') {
837
-            $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
838
-            $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
839
-
840
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
841
-            $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login);
842
-            $message = str_replace($search_array, $replace_array, $message);
843
-
844
-            $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
845
-            $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
846
-            $subject = str_replace($search_array, $replace_array, $subject);
847
-
848
-            $subject .= ' - ADMIN BCC COPY';
849
-            $admin_bcc = true;
850
-
851
-        }
852
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
853
-            $subject .= ' - ADMIN BCC COPY';
854
-            $admin_bcc = true;
855
-        }
856
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
857
-            $subject .= ' - ADMIN BCC COPY';
858
-            $admin_bcc = true;
859
-        }
860
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
861
-            $subject .= ' - ADMIN BCC COPY';
862
-            $admin_bcc = true;
863
-        }
864
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
865
-            $subject .= ' - ADMIN BCC COPY';
866
-            $admin_bcc = true;
867
-        }
868
-
869
-        if($admin_bcc===true){
870
-            $sent = wp_mail($to, $subject, $message, $headers);
871
-
872
-            if( ! $sent ) {
873
-                if ( is_array( $to ) ) {
874
-                    $to = implode( ',', $to );
875
-                }
876
-                $log_message = sprintf(
877
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
878
-                    $message_type,
879
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
880
-                    $to,
881
-                    $subject
882
-                );
883
-                geodir_error_log( $log_message );
884
-            }
885
-        }
886
-
887
-    }
715
+		$post_author_id = !empty($post_info) ? $post_info->post_author : 0;
716
+		$post_author_name = geodir_get_client_name($post_author_id);
717
+		$current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
718
+
719
+		if ($fromEmail == '') {
720
+			$fromEmail = get_option('site_email');
721
+		}
722
+
723
+		if ($fromEmailName == '') {
724
+			$fromEmailName = get_option('site_email_name');
725
+		}
726
+
727
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
728
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
729
+		$message = str_replace($search_array, $replace_array, $message);
730
+
731
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
732
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date);
733
+		$subject = str_replace($search_array, $replace_array, $subject);
734
+
735
+		$headers = 'MIME-Version: 1.0' . "\r\n";
736
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
737
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
738
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
739
+
740
+		$to = $toEmail;
741
+
742
+		/**
743
+		 * Filter the client email to address.
744
+		 *
745
+		 * @since 1.6.1
746
+		 * @package GeoDirectory
747
+		 * @param string $to The email address the email is being sent to.
748
+		 * @param string $fromEmail Sender email address.
749
+		 * @param string $fromEmailName Sender name.
750
+		 * @param string $toEmail Receiver email address.
751
+		 * @param string $toEmailName Receiver name.
752
+		 * @param string $to_subject Email subject.
753
+		 * @param string $to_message Email content.
754
+		 * @param string $extra Not being used.
755
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
756
+		 * @param string $post_id The post ID.
757
+		 * @param string $user_id The user ID.
758
+		 */
759
+		$to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
760
+		/**
761
+		 * Filter the client email subject.
762
+		 *
763
+		 * @since 1.6.1
764
+		 * @package GeoDirectory_Payment_Manager
765
+		 * @param string $subject The email subject.
766
+		 * @param string $fromEmail Sender email address.
767
+		 * @param string $fromEmailName Sender name.
768
+		 * @param string $toEmail Receiver email address.
769
+		 * @param string $toEmailName Receiver name.
770
+		 * @param string $to_subject Email subject.
771
+		 * @param string $to_message Email content.
772
+		 * @param string $extra Not being used.
773
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
774
+		 * @param string $post_id The post ID.
775
+		 * @param string $user_id The user ID.
776
+		 */
777
+		$subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
778
+		/**
779
+		 * Filter the client email message.
780
+		 *
781
+		 * @since 1.6.1
782
+		 * @package GeoDirectory_Payment_Manager
783
+		 * @param string $message The email message text.
784
+		 * @param string $fromEmail Sender email address.
785
+		 * @param string $fromEmailName Sender name.
786
+		 * @param string $toEmail Receiver email address.
787
+		 * @param string $toEmailName Receiver name.
788
+		 * @param string $to_subject Email subject.
789
+		 * @param string $to_message Email content.
790
+		 * @param string $extra Not being used.
791
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
792
+		 * @param string $post_id The post ID.
793
+		 * @param string $user_id The user ID.
794
+		 */
795
+		$message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
796
+		/**
797
+		 * Filter the client email headers.
798
+		 *
799
+		 * @since 1.6.1
800
+		 * @package GeoDirectory_Payment_Manager
801
+		 * @param string $headers The email headers.
802
+		 * @param string $fromEmail Sender email address.
803
+		 * @param string $fromEmailName Sender name.
804
+		 * @param string $toEmail Receiver email address.
805
+		 * @param string $toEmailName Receiver name.
806
+		 * @param string $to_subject Email subject.
807
+		 * @param string $to_message Email content.
808
+		 * @param string $extra Not being used.
809
+		 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
810
+		 * @param string $post_id The post ID.
811
+		 * @param string $user_id The user ID.
812
+		 */
813
+		$headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
814
+
815
+		$sent = wp_mail($to, $subject, $message, $headers);
816
+
817
+		if( ! $sent ) {
818
+			if ( is_array( $to ) ) {
819
+				$to = implode( ',', $to );
820
+			}
821
+			$log_message = sprintf(
822
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
823
+				$message_type,
824
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
825
+				$to,
826
+				$subject
827
+			);
828
+			geodir_error_log( $log_message );
829
+		}
830
+
831
+		///////// ADMIN BCC EMIALS
832
+		$adminEmail = get_bloginfo('admin_email');
833
+		$to = $adminEmail;
834
+
835
+		$admin_bcc = false;
836
+		if ($message_type == 'post_submit') {
837
+			$subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
838
+			$message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
839
+
840
+			$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
841
+			$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login);
842
+			$message = str_replace($search_array, $replace_array, $message);
843
+
844
+			$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
845
+			$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login);
846
+			$subject = str_replace($search_array, $replace_array, $subject);
847
+
848
+			$subject .= ' - ADMIN BCC COPY';
849
+			$admin_bcc = true;
850
+
851
+		}
852
+		elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
853
+			$subject .= ' - ADMIN BCC COPY';
854
+			$admin_bcc = true;
855
+		}
856
+		elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
857
+			$subject .= ' - ADMIN BCC COPY';
858
+			$admin_bcc = true;
859
+		}
860
+		elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
861
+			$subject .= ' - ADMIN BCC COPY';
862
+			$admin_bcc = true;
863
+		}
864
+		elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
865
+			$subject .= ' - ADMIN BCC COPY';
866
+			$admin_bcc = true;
867
+		}
868
+
869
+		if($admin_bcc===true){
870
+			$sent = wp_mail($to, $subject, $message, $headers);
871
+
872
+			if( ! $sent ) {
873
+				if ( is_array( $to ) ) {
874
+					$to = implode( ',', $to );
875
+				}
876
+				$log_message = sprintf(
877
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
878
+					$message_type,
879
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
880
+					$to,
881
+					$subject
882
+				);
883
+				geodir_error_log( $log_message );
884
+			}
885
+		}
886
+
887
+	}
888 888
 }
889 889
 
890 890
 
@@ -897,27 +897,27 @@  discard block
 block discarded – undo
897 897
 function geodir_taxonomy_breadcrumb()
898 898
 {
899 899
 
900
-    $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
901
-    $parent = $term->parent;
900
+	$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
901
+	$parent = $term->parent;
902 902
 
903
-    while ($parent):
904
-        $parents[] = $parent;
905
-        $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
906
-        $parent = $new_parent->parent;
907
-    endwhile;
903
+	while ($parent):
904
+		$parents[] = $parent;
905
+		$new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
906
+		$parent = $new_parent->parent;
907
+	endwhile;
908 908
 
909
-    if (!empty($parents)):
910
-        $parents = array_reverse($parents);
909
+	if (!empty($parents)):
910
+		$parents = array_reverse($parents);
911 911
 
912
-        foreach ($parents as $parent):
913
-            $item = get_term_by('id', $parent, get_query_var('taxonomy'));
914
-            $url = get_term_link($item, get_query_var('taxonomy'));
915
-            echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
916
-        endforeach;
912
+		foreach ($parents as $parent):
913
+			$item = get_term_by('id', $parent, get_query_var('taxonomy'));
914
+			$url = get_term_link($item, get_query_var('taxonomy'));
915
+			echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
916
+		endforeach;
917 917
 
918
-    endif;
918
+	endif;
919 919
 
920
-    echo '<li> > ' . $term->name . '</li>';
920
+	echo '<li> > ' . $term->name . '</li>';
921 921
 }
922 922
 
923 923
 
@@ -933,365 +933,365 @@  discard block
 block discarded – undo
933 933
  */
934 934
 function geodir_breadcrumb()
935 935
 {
936
-    global $wp_query, $geodir_add_location_url;
937
-
938
-    /**
939
-     * Filter breadcrumb separator.
940
-     *
941
-     * @since 1.0.0
942
-     */
943
-    $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
944
-
945
-    if (!geodir_is_page('home')) {
946
-        $breadcrumb = '';
947
-        $url_categoris = '';
948
-        $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
949
-        /**
950
-         * Filter breadcrumb's first link.
951
-         *
952
-         * @since 1.0.0
953
-         */
954
-        $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
955
-
956
-        $gd_post_type = geodir_get_current_posttype();
957
-        $post_type_info = get_post_type_object($gd_post_type);
958
-
959
-        remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
960
-
961
-        $listing_link = get_post_type_archive_link($gd_post_type);
962
-
963
-        add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
964
-        $listing_link = rtrim($listing_link, '/');
965
-        $listing_link .= '/';
966
-
967
-        $post_type_for_location_link = $listing_link;
968
-        $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
969
-
970
-        global $wp, $gd_session;
971
-        $location_link = $post_type_for_location_link;
972
-
973
-        if (geodir_is_page('detail') || geodir_is_page('listing')) {
974
-            global $post;
975
-            $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
936
+	global $wp_query, $geodir_add_location_url;
937
+
938
+	/**
939
+	 * Filter breadcrumb separator.
940
+	 *
941
+	 * @since 1.0.0
942
+	 */
943
+	$separator = apply_filters('geodir_breadcrumb_separator', ' > ');
944
+
945
+	if (!geodir_is_page('home')) {
946
+		$breadcrumb = '';
947
+		$url_categoris = '';
948
+		$breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
949
+		/**
950
+		 * Filter breadcrumb's first link.
951
+		 *
952
+		 * @since 1.0.0
953
+		 */
954
+		$breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
955
+
956
+		$gd_post_type = geodir_get_current_posttype();
957
+		$post_type_info = get_post_type_object($gd_post_type);
958
+
959
+		remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
960
+
961
+		$listing_link = get_post_type_archive_link($gd_post_type);
962
+
963
+		add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
964
+		$listing_link = rtrim($listing_link, '/');
965
+		$listing_link .= '/';
966
+
967
+		$post_type_for_location_link = $listing_link;
968
+		$location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
969
+
970
+		global $wp, $gd_session;
971
+		$location_link = $post_type_for_location_link;
972
+
973
+		if (geodir_is_page('detail') || geodir_is_page('listing')) {
974
+			global $post;
975
+			$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
976 976
 			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
977 977
 				
978 978
 			if(geodir_is_page('detail') && isset($post->country_slug)){
979
-                $location_terms = array(
980
-                    'gd_country' => $post->country_slug,
981
-                    'gd_region' => $post->region_slug,
982
-                    'gd_city' => $post->city_slug
983
-                );
979
+				$location_terms = array(
980
+					'gd_country' => $post->country_slug,
981
+					'gd_region' => $post->region_slug,
982
+					'gd_city' => $post->city_slug
983
+				);
984 984
 				
985 985
 				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
986 986
 					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
987 987
 				}
988
-            }
989
-
990
-            $geodir_show_location_url = get_option('geodir_show_location_url');
991
-
992
-            $hide_url_part = array();
993
-            if ($location_manager) {
994
-                $hide_country_part = get_option('geodir_location_hide_country_part');
995
-                $hide_region_part = get_option('geodir_location_hide_region_part');
996
-
997
-                if ($hide_region_part && $hide_country_part) {
998
-                    $hide_url_part = array('gd_country', 'gd_region');
999
-                } else if ($hide_region_part && !$hide_country_part) {
1000
-                    $hide_url_part = array('gd_region');
1001
-                } else if (!$hide_region_part && $hide_country_part) {
1002
-                    $hide_url_part = array('gd_country');
1003
-                }
1004
-            }
1005
-
1006
-            $hide_text_part = array();
1007
-            if ($geodir_show_location_url == 'country_city') {
1008
-                $hide_text_part = array('gd_region');
1009
-
1010
-                if (isset($location_terms['gd_region']) && !$location_manager) {
1011
-                    unset($location_terms['gd_region']);
1012
-                }
1013
-            } else if ($geodir_show_location_url == 'region_city') {
1014
-                $hide_text_part = array('gd_country');
1015
-
1016
-                if (isset($location_terms['gd_country']) && !$location_manager) {
1017
-                    unset($location_terms['gd_country']);
1018
-                }
1019
-            } else if ($geodir_show_location_url == 'city') {
1020
-                $hide_text_part = array('gd_country', 'gd_region');
1021
-
1022
-                if (isset($location_terms['gd_country']) && !$location_manager) {
1023
-                    unset($location_terms['gd_country']);
1024
-                }
1025
-                if (isset($location_terms['gd_region']) && !$location_manager) {
1026
-                    unset($location_terms['gd_region']);
1027
-                }
1028
-            }
1029
-
1030
-            $is_location_last = '';
1031
-            $is_taxonomy_last = '';
1032
-            $breadcrumb .= '<li>';
1033
-            if (get_query_var($gd_post_type . 'category'))
1034
-                $gd_taxonomy = $gd_post_type . 'category';
1035
-            elseif (get_query_var($gd_post_type . '_tags'))
1036
-                $gd_taxonomy = $gd_post_type . '_tags';
1037
-
1038
-            $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1039
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040
-                $is_location_last = false;
1041
-            else
1042
-                $is_location_last = true;
1043
-
1044
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
1045
-                $is_taxonomy_last = true;
1046
-            else
1047
-                $is_taxonomy_last = false;
1048
-
1049
-            if (!empty($location_terms)) {
1050
-                $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
1051
-
1052
-                foreach ($location_terms as $key => $location_term) {
1053
-                    if ($location_term != '') {
1054
-                        if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
1055
-                            continue;
1056
-                        }
988
+			}
1057 989
 
1058
-                        $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
1059
-                        $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
1060
-                        $gd_location_link_text = ucfirst($gd_location_link_text);
1061
-
1062
-                        $location_term_actual_country = '';
1063
-                        $location_term_actual_region = '';
1064
-                        $location_term_actual_city = '';
1065
-                        if ($geodir_get_locations) {
1066
-                            if ($key == 'gd_country') {
1067
-                                $location_term_actual_country = get_actual_location_name('country', $location_term, true);
1068
-                            } else if ($key == 'gd_region') {
1069
-                                $location_term_actual_region = get_actual_location_name('region', $location_term, true);
1070
-                            } else if ($key == 'gd_city') {
1071
-                                $location_term_actual_city = get_actual_location_name('city', $location_term, true);
1072
-                            }
1073
-                        } else {
1074
-                            $location_info = geodir_get_location();
1075
-
1076
-                            if (!empty($location_info) && isset($location_info->location_id)) {
1077
-                                if ($key == 'gd_country') {
1078
-                                    $location_term_actual_country = __($location_info->country, 'geodirectory');
1079
-                                } else if ($key == 'gd_region') {
1080
-                                    $location_term_actual_region = __($location_info->region, 'geodirectory');
1081
-                                } else if ($key == 'gd_city') {
1082
-                                    $location_term_actual_city = __($location_info->city, 'geodirectory');
1083
-                                }
1084
-                            }
1085
-                        }
990
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1086 991
 
1087
-                        if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1088
-                            $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1089
-                        } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1090
-                            $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1091
-                        } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1092
-                            $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1093
-                        } else if ($is_location_last && $key == 'gd_neighbourhood') {
1094
-                            $breadcrumb .= $separator . $gd_location_link_text;
1095
-                        } else {
1096
-                            if (get_option('permalink_structure') != '') {
1097
-                                $location_link .= $location_term . '/';
1098
-                            } else {
1099
-                                $location_link .= "&$key=" . $location_term;
1100
-                            }
992
+			$hide_url_part = array();
993
+			if ($location_manager) {
994
+				$hide_country_part = get_option('geodir_location_hide_country_part');
995
+				$hide_region_part = get_option('geodir_location_hide_region_part');
1101 996
 
1102
-                            if ($key == 'gd_country' && $location_term_actual_country != '') {
1103
-                                $gd_location_link_text = $location_term_actual_country;
1104
-                            } else if ($key == 'gd_region' && $location_term_actual_region != '') {
1105
-                                $gd_location_link_text = $location_term_actual_region;
1106
-                            } else if ($key == 'gd_city' && $location_term_actual_city != '') {
1107
-                                $gd_location_link_text = $location_term_actual_city;
1108
-                            }
997
+				if ($hide_region_part && $hide_country_part) {
998
+					$hide_url_part = array('gd_country', 'gd_region');
999
+				} else if ($hide_region_part && !$hide_country_part) {
1000
+					$hide_url_part = array('gd_region');
1001
+				} else if (!$hide_region_part && $hide_country_part) {
1002
+					$hide_url_part = array('gd_country');
1003
+				}
1004
+			}
1005
+
1006
+			$hide_text_part = array();
1007
+			if ($geodir_show_location_url == 'country_city') {
1008
+				$hide_text_part = array('gd_region');
1009
+
1010
+				if (isset($location_terms['gd_region']) && !$location_manager) {
1011
+					unset($location_terms['gd_region']);
1012
+				}
1013
+			} else if ($geodir_show_location_url == 'region_city') {
1014
+				$hide_text_part = array('gd_country');
1015
+
1016
+				if (isset($location_terms['gd_country']) && !$location_manager) {
1017
+					unset($location_terms['gd_country']);
1018
+				}
1019
+			} else if ($geodir_show_location_url == 'city') {
1020
+				$hide_text_part = array('gd_country', 'gd_region');
1021
+
1022
+				if (isset($location_terms['gd_country']) && !$location_manager) {
1023
+					unset($location_terms['gd_country']);
1024
+				}
1025
+				if (isset($location_terms['gd_region']) && !$location_manager) {
1026
+					unset($location_terms['gd_region']);
1027
+				}
1028
+			}
1109 1029
 
1110
-                            /*
1030
+			$is_location_last = '';
1031
+			$is_taxonomy_last = '';
1032
+			$breadcrumb .= '<li>';
1033
+			if (get_query_var($gd_post_type . 'category'))
1034
+				$gd_taxonomy = $gd_post_type . 'category';
1035
+			elseif (get_query_var($gd_post_type . '_tags'))
1036
+				$gd_taxonomy = $gd_post_type . '_tags';
1037
+
1038
+			$breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1039
+			if (!empty($gd_taxonomy) || geodir_is_page('detail'))
1040
+				$is_location_last = false;
1041
+			else
1042
+				$is_location_last = true;
1043
+
1044
+			if (!empty($gd_taxonomy) && geodir_is_page('listing'))
1045
+				$is_taxonomy_last = true;
1046
+			else
1047
+				$is_taxonomy_last = false;
1048
+
1049
+			if (!empty($location_terms)) {
1050
+				$geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
1051
+
1052
+				foreach ($location_terms as $key => $location_term) {
1053
+					if ($location_term != '') {
1054
+						if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
1055
+							continue;
1056
+						}
1057
+
1058
+						$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
1059
+						$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
1060
+						$gd_location_link_text = ucfirst($gd_location_link_text);
1061
+
1062
+						$location_term_actual_country = '';
1063
+						$location_term_actual_region = '';
1064
+						$location_term_actual_city = '';
1065
+						if ($geodir_get_locations) {
1066
+							if ($key == 'gd_country') {
1067
+								$location_term_actual_country = get_actual_location_name('country', $location_term, true);
1068
+							} else if ($key == 'gd_region') {
1069
+								$location_term_actual_region = get_actual_location_name('region', $location_term, true);
1070
+							} else if ($key == 'gd_city') {
1071
+								$location_term_actual_city = get_actual_location_name('city', $location_term, true);
1072
+							}
1073
+						} else {
1074
+							$location_info = geodir_get_location();
1075
+
1076
+							if (!empty($location_info) && isset($location_info->location_id)) {
1077
+								if ($key == 'gd_country') {
1078
+									$location_term_actual_country = __($location_info->country, 'geodirectory');
1079
+								} else if ($key == 'gd_region') {
1080
+									$location_term_actual_region = __($location_info->region, 'geodirectory');
1081
+								} else if ($key == 'gd_city') {
1082
+									$location_term_actual_city = __($location_info->city, 'geodirectory');
1083
+								}
1084
+							}
1085
+						}
1086
+
1087
+						if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1088
+							$breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
1089
+						} else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
1090
+							$breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
1091
+						} else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
1092
+							$breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
1093
+						} else if ($is_location_last && $key == 'gd_neighbourhood') {
1094
+							$breadcrumb .= $separator . $gd_location_link_text;
1095
+						} else {
1096
+							if (get_option('permalink_structure') != '') {
1097
+								$location_link .= $location_term . '/';
1098
+							} else {
1099
+								$location_link .= "&$key=" . $location_term;
1100
+							}
1101
+
1102
+							if ($key == 'gd_country' && $location_term_actual_country != '') {
1103
+								$gd_location_link_text = $location_term_actual_country;
1104
+							} else if ($key == 'gd_region' && $location_term_actual_region != '') {
1105
+								$gd_location_link_text = $location_term_actual_region;
1106
+							} else if ($key == 'gd_city' && $location_term_actual_city != '') {
1107
+								$gd_location_link_text = $location_term_actual_city;
1108
+							}
1109
+
1110
+							/*
1111 1111
                             if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
1112 1112
                                 continue;
1113 1113
                             }
1114 1114
                             */
1115 1115
 
1116
-                            $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1117
-                        }
1118
-                    }
1119
-                }
1120
-            }
1121
-
1122
-            if (!empty($gd_taxonomy)) {
1123
-                $term_index = 1;
1124
-
1125
-                //if(get_option('geodir_add_categories_url'))
1126
-                {
1127
-                    if (get_query_var($gd_post_type . '_tags')) {
1128
-                        $cat_link = $listing_link . 'tags/';
1129
-                    } else
1130
-                        $cat_link = $listing_link;
1131
-
1132
-                    foreach ($location_terms as $key => $location_term) {
1133
-                        if ($location_manager && in_array($key, $hide_url_part)) {
1134
-                            continue;
1135
-                        }
1116
+							$breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
1117
+						}
1118
+					}
1119
+				}
1120
+			}
1136 1121
 
1137
-                        if ($location_term != '') {
1138
-                            if (get_option('permalink_structure') != '') {
1139
-                                $cat_link .= $location_term . '/';
1140
-                            }
1141
-                        }
1142
-                    }
1143
-
1144
-                    $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1145
-                    foreach ($term_array as $term) {
1146
-                        $term_link_text = preg_replace('/-(\d+)$/', '', $term);
1147
-                        $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1148
-
1149
-                        // get term actual name
1150
-                        $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1151
-                        if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1152
-                            $term_link_text = urldecode($term_info['name']);
1153
-                        } else {
1154
-                            $term_link_text = geodir_ucwords(urldecode($term_link_text));
1155
-                        }
1122
+			if (!empty($gd_taxonomy)) {
1123
+				$term_index = 1;
1156 1124
 
1157
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1158
-                            $breadcrumb .= $separator . $term_link_text;
1159
-                        else {
1160
-                            $cat_link .= $term . '/';
1161
-                            $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1162
-                        }
1163
-                        $term_index++;
1164
-                    }
1165
-                }
1166
-
1167
-
1168
-            }
1169
-
1170
-            if (geodir_is_page('detail'))
1171
-                $breadcrumb .= $separator . get_the_title();
1172
-
1173
-            $breadcrumb .= '</li>';
1174
-
1175
-
1176
-        } elseif (geodir_is_page('author')) {
1177
-            $user_id = get_current_user_id();
1178
-            $author_link = get_author_posts_url($user_id);
1179
-            $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1180
-
1181
-            /**
1182
-             * Filter author page link.
1183
-             *
1184
-             * @since 1.0.0
1185
-             * @param string $default_author_link Default author link.
1186
-             * @param int $user_id Author ID.
1187
-             */
1188
-            $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1189
-
1190
-            $breadcrumb .= '<li>';
1191
-            $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1192
-
1193
-            if (isset($_REQUEST['list'])) {
1194
-                $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1195
-
1196
-                /**
1197
-                 * Filter author page link.
1198
-                 *
1199
-                 * @since 1.0.0
1200
-                 * @param string $author_link Author page link.
1201
-                 * @param int $user_id Author ID.
1202
-                 * @param string $_REQUEST['stype'] Post type.
1203
-                 */
1204
-                $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1205
-
1206
-                $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207
-                $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1208
-            } else
1209
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1210
-
1211
-            $breadcrumb .= '</li>';
1212
-        } elseif (is_category() || is_single()) {
1213
-            $category = get_the_category();
1214
-            if (is_category()) {
1215
-                $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1216
-            }
1217
-            if (is_single()) {
1218
-                $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1219
-                $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1220
-            }
1221
-            /* End of my version ##################################################### */
1222
-        } else if (is_page()) {
1223
-            $page_title = get_the_title();
1224
-
1225
-            if (geodir_is_page('location')) {
1226
-                $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1227
-            }
1228
-
1229
-            $breadcrumb .= '<li>' . $separator;
1230
-            $breadcrumb .= stripslashes_deep($page_title);
1231
-            $breadcrumb .= '</li>';
1232
-        } else if (is_tag()) {
1233
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1234
-        } else if (is_day()) {
1235
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1236
-            the_time('F jS, Y');
1237
-            $breadcrumb .= '</li>';
1238
-        } else if (is_month()) {
1239
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
-            the_time('F, Y');
1241
-            $breadcrumb .= '</li>';
1242
-        } else if (is_year()) {
1243
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
-            the_time('Y');
1245
-            $breadcrumb .= '</li>';
1246
-        } else if (is_author()) {
1247
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1248
-            $breadcrumb .= '</li>';
1249
-        } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1250
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1251
-            $breadcrumb .= '</li>';
1252
-        } else if (is_search()) {
1253
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1254
-            $breadcrumb .= '</li>';
1255
-        }
1256
-        $breadcrumb .= '</ul></div>';
1257
-
1258
-        /**
1259
-         * Filter breadcrumb html output.
1260
-         *
1261
-         * @since 1.0.0
1262
-         * @param string $breadcrumb Breadcrumb HTML.
1263
-         * @param string $separator Breadcrumb separator.
1264
-         */
1265
-        echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1266
-    }
1125
+				//if(get_option('geodir_add_categories_url'))
1126
+				{
1127
+					if (get_query_var($gd_post_type . '_tags')) {
1128
+						$cat_link = $listing_link . 'tags/';
1129
+					} else
1130
+						$cat_link = $listing_link;
1131
+
1132
+					foreach ($location_terms as $key => $location_term) {
1133
+						if ($location_manager && in_array($key, $hide_url_part)) {
1134
+							continue;
1135
+						}
1136
+
1137
+						if ($location_term != '') {
1138
+							if (get_option('permalink_structure') != '') {
1139
+								$cat_link .= $location_term . '/';
1140
+							}
1141
+						}
1142
+					}
1143
+
1144
+					$term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
1145
+					foreach ($term_array as $term) {
1146
+						$term_link_text = preg_replace('/-(\d+)$/', '', $term);
1147
+						$term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
1148
+
1149
+						// get term actual name
1150
+						$term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
1151
+						if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
1152
+							$term_link_text = urldecode($term_info['name']);
1153
+						} else {
1154
+							$term_link_text = geodir_ucwords(urldecode($term_link_text));
1155
+						}
1156
+
1157
+						if ($term_index == count($term_array) && $is_taxonomy_last)
1158
+							$breadcrumb .= $separator . $term_link_text;
1159
+						else {
1160
+							$cat_link .= $term . '/';
1161
+							$breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1162
+						}
1163
+						$term_index++;
1164
+					}
1165
+				}
1166
+
1167
+
1168
+			}
1169
+
1170
+			if (geodir_is_page('detail'))
1171
+				$breadcrumb .= $separator . get_the_title();
1172
+
1173
+			$breadcrumb .= '</li>';
1174
+
1175
+
1176
+		} elseif (geodir_is_page('author')) {
1177
+			$user_id = get_current_user_id();
1178
+			$author_link = get_author_posts_url($user_id);
1179
+			$default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
1180
+
1181
+			/**
1182
+			 * Filter author page link.
1183
+			 *
1184
+			 * @since 1.0.0
1185
+			 * @param string $default_author_link Default author link.
1186
+			 * @param int $user_id Author ID.
1187
+			 */
1188
+			$default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
1189
+
1190
+			$breadcrumb .= '<li>';
1191
+			$breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
1192
+
1193
+			if (isset($_REQUEST['list'])) {
1194
+				$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
1195
+
1196
+				/**
1197
+				 * Filter author page link.
1198
+				 *
1199
+				 * @since 1.0.0
1200
+				 * @param string $author_link Author page link.
1201
+				 * @param int $user_id Author ID.
1202
+				 * @param string $_REQUEST['stype'] Post type.
1203
+				 */
1204
+				$author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
1205
+
1206
+				$breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1207
+				$breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1208
+			} else
1209
+				$breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1210
+
1211
+			$breadcrumb .= '</li>';
1212
+		} elseif (is_category() || is_single()) {
1213
+			$category = get_the_category();
1214
+			if (is_category()) {
1215
+				$breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
1216
+			}
1217
+			if (is_single()) {
1218
+				$breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>';
1219
+				$breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
1220
+			}
1221
+			/* End of my version ##################################################### */
1222
+		} else if (is_page()) {
1223
+			$page_title = get_the_title();
1224
+
1225
+			if (geodir_is_page('location')) {
1226
+				$page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1227
+			}
1228
+
1229
+			$breadcrumb .= '<li>' . $separator;
1230
+			$breadcrumb .= stripslashes_deep($page_title);
1231
+			$breadcrumb .= '</li>';
1232
+		} else if (is_tag()) {
1233
+			$breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1234
+		} else if (is_day()) {
1235
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1236
+			the_time('F jS, Y');
1237
+			$breadcrumb .= '</li>';
1238
+		} else if (is_month()) {
1239
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
+			the_time('F, Y');
1241
+			$breadcrumb .= '</li>';
1242
+		} else if (is_year()) {
1243
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
+			the_time('Y');
1245
+			$breadcrumb .= '</li>';
1246
+		} else if (is_author()) {
1247
+			$breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1248
+			$breadcrumb .= '</li>';
1249
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1250
+			$breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1251
+			$breadcrumb .= '</li>';
1252
+		} else if (is_search()) {
1253
+			$breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1254
+			$breadcrumb .= '</li>';
1255
+		}
1256
+		$breadcrumb .= '</ul></div>';
1257
+
1258
+		/**
1259
+		 * Filter breadcrumb html output.
1260
+		 *
1261
+		 * @since 1.0.0
1262
+		 * @param string $breadcrumb Breadcrumb HTML.
1263
+		 * @param string $separator Breadcrumb separator.
1264
+		 */
1265
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1266
+	}
1267 1267
 }
1268 1268
 
1269 1269
 
1270 1270
 add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1271 1271
 if (!function_exists('geodir_allow_wpadmin')) {
1272
-    /**
1273
-     * Allow only admins to access wp-admin.
1274
-     *
1275
-     * Normal users will be redirected to home page.
1276
-     *
1277
-     * @since 1.0.0
1278
-     * @package GeoDirectory
1279
-     * @global object $wpdb WordPress Database object.
1280
-     */
1281
-    function geodir_allow_wpadmin()
1282
-    {
1283
-        global $wpdb;
1284
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1285
-        {
1286
-            if (current_user_can('manage_options')) {
1287
-            } else {
1288
-
1289
-                wp_redirect(home_url());
1290
-                exit;
1291
-            }
1292
-
1293
-        }
1294
-    }
1272
+	/**
1273
+	 * Allow only admins to access wp-admin.
1274
+	 *
1275
+	 * Normal users will be redirected to home page.
1276
+	 *
1277
+	 * @since 1.0.0
1278
+	 * @package GeoDirectory
1279
+	 * @global object $wpdb WordPress Database object.
1280
+	 */
1281
+	function geodir_allow_wpadmin()
1282
+	{
1283
+		global $wpdb;
1284
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1285
+		{
1286
+			if (current_user_can('manage_options')) {
1287
+			} else {
1288
+
1289
+				wp_redirect(home_url());
1290
+				exit;
1291
+			}
1292
+
1293
+		}
1294
+	}
1295 1295
 }
1296 1296
 
1297 1297
 
@@ -1305,50 +1305,50 @@  discard block
 block discarded – undo
1305 1305
  */
1306 1306
 function fetch_remote_file($url)
1307 1307
 {
1308
-    // extract the file name and extension from the url
1309
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1310
-    $file_name = basename($url);
1311
-    if (strpos($file_name, '?') !== false) {
1312
-        list($file_name) = explode('?', $file_name);
1313
-    }
1314
-
1315
-
1316
-    // get placeholder file in the upload dir with a unique, sanitized filename
1317
-
1318
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1319
-
1320
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1321
-    if ($upload['error'])
1322
-        return new WP_Error('upload_dir_error', $upload['error']);
1323
-
1324
-    // fetch the remote url and write it to the placeholder file
1325
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1326
-
1327
-    $log_message = '';
1328
-    $filesize = filesize($upload['file']);
1329
-    // request failed
1330
-    if (!$headers) {
1331
-        $log_message = __('Remote server did not respond', 'geodirectory');
1332
-    }
1333
-    // make sure the fetch was successful
1334
-    elseif ($headers['response']['code'] != '200') {
1335
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1336
-    }
1337
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1338
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1339
-    }
1340
-    elseif (0 == $filesize) {
1341
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1342
-    }
1343
-
1344
-    if($log_message){
1345
-        $del = unlink($upload['file']);
1346
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1347
-        return new WP_Error('import_file_error',$log_message );
1348
-    }
1349
-
1350
-
1351
-    return $upload;
1308
+	// extract the file name and extension from the url
1309
+	require_once(ABSPATH . 'wp-includes/pluggable.php');
1310
+	$file_name = basename($url);
1311
+	if (strpos($file_name, '?') !== false) {
1312
+		list($file_name) = explode('?', $file_name);
1313
+	}
1314
+
1315
+
1316
+	// get placeholder file in the upload dir with a unique, sanitized filename
1317
+
1318
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1319
+
1320
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1321
+	if ($upload['error'])
1322
+		return new WP_Error('upload_dir_error', $upload['error']);
1323
+
1324
+	// fetch the remote url and write it to the placeholder file
1325
+	$headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1326
+
1327
+	$log_message = '';
1328
+	$filesize = filesize($upload['file']);
1329
+	// request failed
1330
+	if (!$headers) {
1331
+		$log_message = __('Remote server did not respond', 'geodirectory');
1332
+	}
1333
+	// make sure the fetch was successful
1334
+	elseif ($headers['response']['code'] != '200') {
1335
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1336
+	}
1337
+	elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1338
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1339
+	}
1340
+	elseif (0 == $filesize) {
1341
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1342
+	}
1343
+
1344
+	if($log_message){
1345
+		$del = unlink($upload['file']);
1346
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1347
+		return new WP_Error('import_file_error',$log_message );
1348
+	}
1349
+
1350
+
1351
+	return $upload;
1352 1352
 }
1353 1353
 
1354 1354
 /**
@@ -1360,21 +1360,21 @@  discard block
 block discarded – undo
1360 1360
  */
1361 1361
 function geodir_max_upload_size()
1362 1362
 {
1363
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1364
-
1365
-    if ($max_filesize > 0 && $max_filesize < 1) {
1366
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1367
-    } else {
1368
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1369
-    }
1370
-
1371
-    /**
1372
-     * Filter default image upload size limit.
1373
-     *
1374
-     * @since 1.0.0
1375
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1376
-     */
1377
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1363
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1364
+
1365
+	if ($max_filesize > 0 && $max_filesize < 1) {
1366
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1367
+	} else {
1368
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1369
+	}
1370
+
1371
+	/**
1372
+	 * Filter default image upload size limit.
1373
+	 *
1374
+	 * @since 1.0.0
1375
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1376
+	 */
1377
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1378 1378
 }
1379 1379
 
1380 1380
 /**
@@ -1388,11 +1388,11 @@  discard block
 block discarded – undo
1388 1388
  */
1389 1389
 function geodir_dummy_folder_exists()
1390 1390
 {
1391
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1392
-    if (!is_dir($path))
1393
-        return false;
1394
-    else
1395
-        return true;
1391
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1392
+	if (!is_dir($path))
1393
+		return false;
1394
+	else
1395
+		return true;
1396 1396
 
1397 1397
 }
1398 1398
 
@@ -1407,290 +1407,290 @@  discard block
 block discarded – undo
1407 1407
  */
1408 1408
 function  geodir_get_author_info($aid)
1409 1409
 {
1410
-    global $wpdb;
1411
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1412
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1413
-    $info = $wpdb->get_results($infosql);
1414
-    if ($info) {
1415
-        return $info[0];
1416
-    }
1410
+	global $wpdb;
1411
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1412
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1413
+	$info = $wpdb->get_results($infosql);
1414
+	if ($info) {
1415
+		return $info[0];
1416
+	}
1417 1417
 }
1418 1418
 
1419 1419
 if (!function_exists('adminEmail')) {
1420
-    /**
1421
-     * Send emails to client on post submission, renew etc.
1422
-     *
1423
-     * @since 1.0.0
1424
-     * @package GeoDirectory
1425
-     * @global object $wpdb WordPress Database object.
1426
-     * @param int|string $page_id Page ID.
1427
-     * @param int|string $user_id User ID.
1428
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1429
-     * @param string $custom_1 Custom data to be sent.
1430
-     */
1431
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1432
-    {
1433
-        global $wpdb;
1434
-        if ($message_type == 'expiration') {
1435
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1436
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1437
-        } elseif ($message_type == 'post_submited') {
1438
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1439
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1440
-        } elseif ($message_type == 'renew') {
1441
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1442
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1443
-        } elseif ($message_type == 'upgrade') {
1444
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1445
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1446
-        } elseif ($message_type == 'claim_approved') {
1447
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1448
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1449
-        } elseif ($message_type == 'claim_rejected') {
1450
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1451
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1452
-        } elseif ($message_type == 'claim_requested') {
1453
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1454
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1455
-        } elseif ($message_type == 'auto_claim') {
1456
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1457
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1458
-        } elseif ($message_type == 'payment_success') {
1459
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1460
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1461
-        } elseif ($message_type == 'payment_fail') {
1462
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1463
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1464
-        }
1465
-        $transaction_details = $custom_1;
1466
-        $fromEmail = get_option('site_email');
1467
-        $fromEmailName = get_site_emailName();
1420
+	/**
1421
+	 * Send emails to client on post submission, renew etc.
1422
+	 *
1423
+	 * @since 1.0.0
1424
+	 * @package GeoDirectory
1425
+	 * @global object $wpdb WordPress Database object.
1426
+	 * @param int|string $page_id Page ID.
1427
+	 * @param int|string $user_id User ID.
1428
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1429
+	 * @param string $custom_1 Custom data to be sent.
1430
+	 */
1431
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1432
+	{
1433
+		global $wpdb;
1434
+		if ($message_type == 'expiration') {
1435
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1436
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1437
+		} elseif ($message_type == 'post_submited') {
1438
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1439
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1440
+		} elseif ($message_type == 'renew') {
1441
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1442
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1443
+		} elseif ($message_type == 'upgrade') {
1444
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1445
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1446
+		} elseif ($message_type == 'claim_approved') {
1447
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1448
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1449
+		} elseif ($message_type == 'claim_rejected') {
1450
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1451
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1452
+		} elseif ($message_type == 'claim_requested') {
1453
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1454
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1455
+		} elseif ($message_type == 'auto_claim') {
1456
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1457
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1458
+		} elseif ($message_type == 'payment_success') {
1459
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1460
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1461
+		} elseif ($message_type == 'payment_fail') {
1462
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1463
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1464
+		}
1465
+		$transaction_details = $custom_1;
1466
+		$fromEmail = get_option('site_email');
1467
+		$fromEmailName = get_site_emailName();
1468 1468
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1469
-        $pkg_limit = get_property_price_info_listing($page_id);
1470
-        $alivedays = $pkg_limit['days'];
1471
-        $productlink = get_permalink($page_id);
1472
-        $post_info = get_post($page_id);
1473
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1474
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1475
-        $loginurl = geodir_login_url();
1476
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1477
-        $siteurl = home_url();
1478
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1479
-        $user_info = get_userdata($user_id);
1480
-        $user_email = $user_info->user_email;
1481
-        $display_name = geodir_get_client_name($user_id);
1482
-        $user_login = $user_info->user_login;
1483
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1484
-        if ($number_of_grace_days == '') {
1485
-            $number_of_grace_days = 1;
1486
-        }
1487
-        if ($post_info->post_type == 'event') {
1488
-            $post_type = 'event';
1489
-        } else {
1490
-            $post_type = 'listing';
1491
-        }
1492
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1493
-        $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
1494
-        $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details);
1495
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1496
-        $subject = str_replace($search_array, $replace_array, $subject);
1497
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1498
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1499
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1500
-
1501
-        $to = $fromEmail;
1502
-        $message = $client_message;
1503
-
1504
-
1505
-        /**
1506
-         * Filter the admin email to address.
1507
-         *
1508
-         * @since 1.6.1
1509
-         * @package GeoDirectory
1510
-         * @param string $to The email address the email is being sent to.
1511
-         * @param int|string $page_id Page ID.
1512
-         * @param int|string $user_id User ID.
1513
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1514
-         * @param string $custom_1 Custom data to be sent.
1515
-         */
1516
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1517
-        /**
1518
-         * Filter the admin email subject.
1519
-         *
1520
-         * @since 1.6.1
1521
-         * @package GeoDirectory_Payment_Manager
1522
-         * @param string $subject The email subject.
1523
-         * @param int|string $page_id Page ID.
1524
-         * @param int|string $user_id User ID.
1525
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1526
-         * @param string $custom_1 Custom data to be sent.
1527
-         */
1528
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1529
-        /**
1530
-         * Filter the admin email message.
1531
-         *
1532
-         * @since 1.6.1
1533
-         * @package GeoDirectory_Payment_Manager
1534
-         * @param string $message The email message text.
1535
-         * @param int|string $page_id Page ID.
1536
-         * @param int|string $user_id User ID.
1537
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1538
-         * @param string $custom_1 Custom data to be sent.
1539
-         */
1540
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1541
-        /**
1542
-         * Filter the admin email headers.
1543
-         *
1544
-         * @since 1.6.1
1545
-         * @package GeoDirectory_Payment_Manager
1546
-         * @param string $headers The email headers.
1547
-         * @param int|string $page_id Page ID.
1548
-         * @param int|string $user_id User ID.
1549
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1550
-         * @param string $custom_1 Custom data to be sent.
1551
-         */
1552
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1553
-
1554
-
1555
-
1556
-        $sent = wp_mail($to, $subject, $message, $headers);
1557
-        if( ! $sent ) {
1558
-            if ( is_array( $to ) ) {
1559
-                $to = implode( ',', $to );
1560
-            }
1561
-            $log_message = sprintf(
1562
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1563
-                $message_type,
1564
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1565
-                $to,
1566
-                $subject
1567
-            );
1568
-            geodir_error_log( $log_message );
1569
-        }
1570
-    }
1469
+		$pkg_limit = get_property_price_info_listing($page_id);
1470
+		$alivedays = $pkg_limit['days'];
1471
+		$productlink = get_permalink($page_id);
1472
+		$post_info = get_post($page_id);
1473
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1474
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1475
+		$loginurl = geodir_login_url();
1476
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1477
+		$siteurl = home_url();
1478
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1479
+		$user_info = get_userdata($user_id);
1480
+		$user_email = $user_info->user_email;
1481
+		$display_name = geodir_get_client_name($user_id);
1482
+		$user_login = $user_info->user_login;
1483
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1484
+		if ($number_of_grace_days == '') {
1485
+			$number_of_grace_days = 1;
1486
+		}
1487
+		if ($post_info->post_type == 'event') {
1488
+			$post_type = 'event';
1489
+		} else {
1490
+			$post_type = 'listing';
1491
+		}
1492
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1493
+		$search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
1494
+		$replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details);
1495
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1496
+		$subject = str_replace($search_array, $replace_array, $subject);
1497
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1498
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1499
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1500
+
1501
+		$to = $fromEmail;
1502
+		$message = $client_message;
1503
+
1504
+
1505
+		/**
1506
+		 * Filter the admin email to address.
1507
+		 *
1508
+		 * @since 1.6.1
1509
+		 * @package GeoDirectory
1510
+		 * @param string $to The email address the email is being sent to.
1511
+		 * @param int|string $page_id Page ID.
1512
+		 * @param int|string $user_id User ID.
1513
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1514
+		 * @param string $custom_1 Custom data to be sent.
1515
+		 */
1516
+		$to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1517
+		/**
1518
+		 * Filter the admin email subject.
1519
+		 *
1520
+		 * @since 1.6.1
1521
+		 * @package GeoDirectory_Payment_Manager
1522
+		 * @param string $subject The email subject.
1523
+		 * @param int|string $page_id Page ID.
1524
+		 * @param int|string $user_id User ID.
1525
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1526
+		 * @param string $custom_1 Custom data to be sent.
1527
+		 */
1528
+		$subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1529
+		/**
1530
+		 * Filter the admin email message.
1531
+		 *
1532
+		 * @since 1.6.1
1533
+		 * @package GeoDirectory_Payment_Manager
1534
+		 * @param string $message The email message text.
1535
+		 * @param int|string $page_id Page ID.
1536
+		 * @param int|string $user_id User ID.
1537
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1538
+		 * @param string $custom_1 Custom data to be sent.
1539
+		 */
1540
+		$message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1541
+		/**
1542
+		 * Filter the admin email headers.
1543
+		 *
1544
+		 * @since 1.6.1
1545
+		 * @package GeoDirectory_Payment_Manager
1546
+		 * @param string $headers The email headers.
1547
+		 * @param int|string $page_id Page ID.
1548
+		 * @param int|string $user_id User ID.
1549
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1550
+		 * @param string $custom_1 Custom data to be sent.
1551
+		 */
1552
+		$headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1553
+
1554
+
1555
+
1556
+		$sent = wp_mail($to, $subject, $message, $headers);
1557
+		if( ! $sent ) {
1558
+			if ( is_array( $to ) ) {
1559
+				$to = implode( ',', $to );
1560
+			}
1561
+			$log_message = sprintf(
1562
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1563
+				$message_type,
1564
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1565
+				$to,
1566
+				$subject
1567
+			);
1568
+			geodir_error_log( $log_message );
1569
+		}
1570
+	}
1571 1571
 }
1572 1572
 
1573 1573
 if (!function_exists('sendEmail')) {
1574
-    /**
1575
-     * @todo could be a duplicate of geodir_sendEmail.
1576
-     *
1577
-     * @since 1.0.0
1578
-     * @package GeoDirectory
1579
-     * @param string $fromEmail Sender email address.
1580
-     * @param string $fromEmailName Sender name.
1581
-     * @param string $toEmail Receiver email address.
1582
-     * @param string $toEmailName Receiver name.
1583
-     * @param string $to_subject Email subject.
1584
-     * @param string $to_message Email content.
1585
-     * @param string $extra Not being used.
1586
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1587
-     * @param string $post_id The post ID.
1588
-     * @param string $user_id The user ID.
1589
-     */
1590
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1591
-    {
1592
-        $login_details = '';
1593
-        if ($message_type == 'send_friend') {
1594
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1595
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1596
-        } elseif ($message_type == 'send_enquiry') {
1597
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1598
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1599
-        } elseif ($message_type == 'forgot_password') {
1600
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1601
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1602
-            $login_details = $to_message;
1603
-        } elseif ($message_type == 'registration') {
1604
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1605
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1606
-            $login_details = $to_message;
1607
-        }
1608
-        $to_message = nl2br($to_message);
1609
-        $sitefromEmail = get_option('site_email');
1610
-        $sitefromEmailName = get_site_emailName();
1611
-        $productlink = get_permalink($post_id);
1612
-        $post_info = get_post($post_id);
1613
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1614
-        $siteurl = home_url();
1615
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1616
-        $loginurl = geodir_login_url();
1617
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1618
-        if ($fromEmail == '') {
1619
-            $fromEmail = get_option('site_email');
1620
-        }
1621
-        if ($fromEmailName == '') {
1622
-            $fromEmailName = get_option('site_email_name');
1623
-        }
1624
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1625
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1626
-        $message = str_replace($search_array, $replace_array, $message);
1627
-
1628
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1629
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1630
-        $subject = str_replace($search_array, $replace_array, $subject);
1631
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1632
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1633
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1634
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1635
-
1636
-        $to = $toEmail;
1637
-
1638
-        $sent = wp_mail($to, $subject, $message, $headers);
1639
-        if( ! $sent ) {
1640
-            if ( is_array( $to ) ) {
1641
-                $to = implode( ',', $to );
1642
-            }
1643
-            $log_message = sprintf(
1644
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1645
-                $message_type,
1646
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1647
-                $to,
1648
-                $subject
1649
-            );
1650
-            geodir_error_log( $log_message );
1651
-        }
1652
-
1653
-        ///////// ADMIN BCC EMIALS
1654
-        $admin_bcc = false;
1655
-        if ($message_type == 'registration') {
1656
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1657
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1658
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1659
-        }
1660
-        $adminEmail = get_bloginfo('admin_email');
1661
-        $to = $adminEmail;
1662
-
1663
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1664
-            $subject .= ' - ADMIN BCC COPY';
1665
-            $admin_bcc = true;
1666
-        }
1667
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1668
-            $subject .= ' - ADMIN BCC COPY';
1669
-            $admin_bcc = true;
1670
-        }
1671
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1672
-            $subject .= ' - ADMIN BCC COPY';
1673
-            $admin_bcc = true;
1674
-        }
1675
-
1676
-        if($admin_bcc === true){
1677
-            $sent = wp_mail($to, $subject, $message, $headers);
1678
-            if( ! $sent ) {
1679
-                if ( is_array( $to ) ) {
1680
-                    $to = implode( ',', $to );
1681
-                }
1682
-                $log_message = sprintf(
1683
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1684
-                    $message_type,
1685
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1686
-                    $to,
1687
-                    $subject
1688
-                );
1689
-                geodir_error_log( $log_message );
1690
-            }
1691
-        }
1692
-
1693
-    }
1574
+	/**
1575
+	 * @todo could be a duplicate of geodir_sendEmail.
1576
+	 *
1577
+	 * @since 1.0.0
1578
+	 * @package GeoDirectory
1579
+	 * @param string $fromEmail Sender email address.
1580
+	 * @param string $fromEmailName Sender name.
1581
+	 * @param string $toEmail Receiver email address.
1582
+	 * @param string $toEmailName Receiver name.
1583
+	 * @param string $to_subject Email subject.
1584
+	 * @param string $to_message Email content.
1585
+	 * @param string $extra Not being used.
1586
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1587
+	 * @param string $post_id The post ID.
1588
+	 * @param string $user_id The user ID.
1589
+	 */
1590
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1591
+	{
1592
+		$login_details = '';
1593
+		if ($message_type == 'send_friend') {
1594
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1595
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1596
+		} elseif ($message_type == 'send_enquiry') {
1597
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1598
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1599
+		} elseif ($message_type == 'forgot_password') {
1600
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1601
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1602
+			$login_details = $to_message;
1603
+		} elseif ($message_type == 'registration') {
1604
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1605
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1606
+			$login_details = $to_message;
1607
+		}
1608
+		$to_message = nl2br($to_message);
1609
+		$sitefromEmail = get_option('site_email');
1610
+		$sitefromEmailName = get_site_emailName();
1611
+		$productlink = get_permalink($post_id);
1612
+		$post_info = get_post($post_id);
1613
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1614
+		$siteurl = home_url();
1615
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1616
+		$loginurl = geodir_login_url();
1617
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1618
+		if ($fromEmail == '') {
1619
+			$fromEmail = get_option('site_email');
1620
+		}
1621
+		if ($fromEmailName == '') {
1622
+			$fromEmailName = get_option('site_email_name');
1623
+		}
1624
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1625
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1626
+		$message = str_replace($search_array, $replace_array, $message);
1627
+
1628
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1629
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1630
+		$subject = str_replace($search_array, $replace_array, $subject);
1631
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1632
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1633
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1634
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1635
+
1636
+		$to = $toEmail;
1637
+
1638
+		$sent = wp_mail($to, $subject, $message, $headers);
1639
+		if( ! $sent ) {
1640
+			if ( is_array( $to ) ) {
1641
+				$to = implode( ',', $to );
1642
+			}
1643
+			$log_message = sprintf(
1644
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1645
+				$message_type,
1646
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1647
+				$to,
1648
+				$subject
1649
+			);
1650
+			geodir_error_log( $log_message );
1651
+		}
1652
+
1653
+		///////// ADMIN BCC EMIALS
1654
+		$admin_bcc = false;
1655
+		if ($message_type == 'registration') {
1656
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1657
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1658
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1659
+		}
1660
+		$adminEmail = get_bloginfo('admin_email');
1661
+		$to = $adminEmail;
1662
+
1663
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1664
+			$subject .= ' - ADMIN BCC COPY';
1665
+			$admin_bcc = true;
1666
+		}
1667
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1668
+			$subject .= ' - ADMIN BCC COPY';
1669
+			$admin_bcc = true;
1670
+		}
1671
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1672
+			$subject .= ' - ADMIN BCC COPY';
1673
+			$admin_bcc = true;
1674
+		}
1675
+
1676
+		if($admin_bcc === true){
1677
+			$sent = wp_mail($to, $subject, $message, $headers);
1678
+			if( ! $sent ) {
1679
+				if ( is_array( $to ) ) {
1680
+					$to = implode( ',', $to );
1681
+				}
1682
+				$log_message = sprintf(
1683
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1684
+					$message_type,
1685
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1686
+					$to,
1687
+					$subject
1688
+				);
1689
+				geodir_error_log( $log_message );
1690
+			}
1691
+		}
1692
+
1693
+	}
1694 1694
 }
1695 1695
 
1696 1696
 /*
@@ -1708,16 +1708,16 @@  discard block
 block discarded – undo
1708 1708
  */
1709 1709
 function gd_lang_object_ids($ids_array, $type)
1710 1710
 {
1711
-    if (function_exists('icl_object_id')) {
1712
-        $res = array();
1713
-        foreach ($ids_array as $id) {
1714
-            $xlat = icl_object_id($id, $type, false);
1715
-            if (!is_null($xlat)) $res[] = $xlat;
1716
-        }
1717
-        return $res;
1718
-    } else {
1719
-        return $ids_array;
1720
-    }
1711
+	if (function_exists('icl_object_id')) {
1712
+		$res = array();
1713
+		foreach ($ids_array as $id) {
1714
+			$xlat = icl_object_id($id, $type, false);
1715
+			if (!is_null($xlat)) $res[] = $xlat;
1716
+		}
1717
+		return $res;
1718
+	} else {
1719
+		return $ids_array;
1720
+	}
1721 1721
 }
1722 1722
 
1723 1723
 
@@ -1732,31 +1732,31 @@  discard block
 block discarded – undo
1732 1732
  * @return array Modified Body CSS classes.
1733 1733
  */
1734 1734
 function geodir_custom_posts_body_class($classes) {
1735
-    global $wpdb, $wp;
1736
-    $post_types = geodir_get_posttypes('object');
1737
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1738
-        $classes[] = 'geodir_custom_posts';
1739
-    }
1740
-
1741
-    // fix body class for signup page
1742
-    if (geodir_is_page('login')) {
1743
-        $new_classes = array();
1744
-        $new_classes[] = 'signup page-geodir-signup';
1745
-        if (!empty($classes)) {
1746
-            foreach ($classes as $class) {
1747
-                if ($class && $class != 'home' && $class != 'blog') {
1748
-                    $new_classes[] = $class;
1749
-                }
1750
-            }
1751
-        }
1752
-        $classes = $new_classes;
1753
-    }
1754
-
1755
-    if (geodir_is_geodir_page()) {
1756
-        $classes[] = 'geodir-page';
1757
-    }
1758
-
1759
-    return $classes;
1735
+	global $wpdb, $wp;
1736
+	$post_types = geodir_get_posttypes('object');
1737
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1738
+		$classes[] = 'geodir_custom_posts';
1739
+	}
1740
+
1741
+	// fix body class for signup page
1742
+	if (geodir_is_page('login')) {
1743
+		$new_classes = array();
1744
+		$new_classes[] = 'signup page-geodir-signup';
1745
+		if (!empty($classes)) {
1746
+			foreach ($classes as $class) {
1747
+				if ($class && $class != 'home' && $class != 'blog') {
1748
+					$new_classes[] = $class;
1749
+				}
1750
+			}
1751
+		}
1752
+		$classes = $new_classes;
1753
+	}
1754
+
1755
+	if (geodir_is_geodir_page()) {
1756
+		$classes[] = 'geodir-page';
1757
+	}
1758
+
1759
+	return $classes;
1760 1760
 }
1761 1761
 
1762 1762
 add_filter('body_class', 'geodir_custom_posts_body_class'); // let's add a class to the body so we can style the new addition to the search
@@ -1771,12 +1771,12 @@  discard block
 block discarded – undo
1771 1771
  */
1772 1772
 function geodir_map_zoom_level()
1773 1773
 {
1774
-    /**
1775
-     * Filter GD map zoom level.
1776
-     *
1777
-     * @since 1.0.0
1778
-     */
1779
-    return apply_filters('geodir_map_zoom_level', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
1774
+	/**
1775
+	 * Filter GD map zoom level.
1776
+	 *
1777
+	 * @since 1.0.0
1778
+	 */
1779
+	return apply_filters('geodir_map_zoom_level', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
1780 1780
 
1781 1781
 }
1782 1782
 
@@ -1790,12 +1790,12 @@  discard block
 block discarded – undo
1790 1790
  */
1791 1791
 function geodir_option_version_backup($geodir_option_name)
1792 1792
 {
1793
-    $version_date = time();
1794
-    $geodir_option = get_option($geodir_option_name);
1793
+	$version_date = time();
1794
+	$geodir_option = get_option($geodir_option_name);
1795 1795
 
1796
-    if (!empty($geodir_option)) {
1797
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1798
-    }
1796
+	if (!empty($geodir_option)) {
1797
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1798
+	}
1799 1799
 }
1800 1800
 
1801 1801
 /**
@@ -1808,11 +1808,11 @@  discard block
 block discarded – undo
1808 1808
  */
1809 1809
 function get_page_id_geodir_add_listing_page($page_id)
1810 1810
 {
1811
-    if (geodir_wpml_multilingual_status()) {
1812
-        $post_type = 'post_page';
1813
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1814
-    }
1815
-    return $page_id;
1811
+	if (geodir_wpml_multilingual_status()) {
1812
+		$post_type = 'post_page';
1813
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1814
+	}
1815
+	return $page_id;
1816 1816
 }
1817 1817
 
1818 1818
 /**
@@ -1824,10 +1824,10 @@  discard block
 block discarded – undo
1824 1824
  */
1825 1825
 function geodir_wpml_multilingual_status()
1826 1826
 {
1827
-    if (function_exists('icl_object_id')) {
1828
-        return true;
1829
-    }
1830
-    return false;
1827
+	if (function_exists('icl_object_id')) {
1828
+		return true;
1829
+	}
1830
+	return false;
1831 1831
 }
1832 1832
 
1833 1833
 /**
@@ -1841,22 +1841,22 @@  discard block
 block discarded – undo
1841 1841
  */
1842 1842
 function geodir_get_wpml_element_id($page_id, $post_type)
1843 1843
 {
1844
-    global $sitepress;
1845
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1846
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1847
-
1848
-        if ($trid > 0) {
1849
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1850
-
1851
-            $lang = $sitepress->get_current_language();
1852
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1853
-
1854
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1855
-                $page_id = $translations[$lang]->element_id;
1856
-            }
1857
-        }
1858
-    }
1859
-    return $page_id;
1844
+	global $sitepress;
1845
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1846
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1847
+
1848
+		if ($trid > 0) {
1849
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1850
+
1851
+			$lang = $sitepress->get_current_language();
1852
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1853
+
1854
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1855
+				$page_id = $translations[$lang]->element_id;
1856
+			}
1857
+		}
1858
+	}
1859
+	return $page_id;
1860 1860
 }
1861 1861
 
1862 1862
 /**
@@ -1868,20 +1868,20 @@  discard block
 block discarded – undo
1868 1868
  */
1869 1869
 function geodir_wpml_check_element_id()
1870 1870
 {
1871
-    global $sitepress;
1872
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1873
-        $el_type = 'post_page';
1874
-        $el_id = get_option('geodir_add_listing_page');
1875
-        $default_lang = $sitepress->get_default_language();
1876
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1877
-
1878
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1879
-            if (!$el_details->source_language_code) {
1880
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1881
-                $sitepress->icl_translations_cache->clear();
1882
-            }
1883
-        }
1884
-    }
1871
+	global $sitepress;
1872
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1873
+		$el_type = 'post_page';
1874
+		$el_id = get_option('geodir_add_listing_page');
1875
+		$default_lang = $sitepress->get_default_language();
1876
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1877
+
1878
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1879
+			if (!$el_details->source_language_code) {
1880
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1881
+				$sitepress->icl_translations_cache->clear();
1882
+			}
1883
+		}
1884
+	}
1885 1885
 }
1886 1886
 
1887 1887
 /**
@@ -1896,44 +1896,44 @@  discard block
 block discarded – undo
1896 1896
  */
1897 1897
 function geodir_widget_listings_get_order($query_args)
1898 1898
 {
1899
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1900
-
1901
-    $query_args = $gd_query_args_widgets;
1902
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1903
-        return $wpdb->posts . ".post_date DESC, ";
1904
-    }
1905
-
1906
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1907
-    $table = $plugin_prefix . $post_type . '_detail';
1908
-
1909
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1910
-
1911
-    switch ($sort_by) {
1912
-        case 'latest':
1913
-        case 'newest':
1914
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1915
-            break;
1916
-        case 'featured':
1917
-            $orderby = $table . ".is_featured ASC, ";
1918
-            break;
1919
-        case 'az':
1920
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1921
-            break;
1922
-        case 'high_review':
1923
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1924
-            break;
1925
-        case 'high_rating':
1926
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1927
-            break;
1928
-        case 'random':
1929
-            $orderby = "RAND(), ";
1930
-            break;
1931
-        default:
1932
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1933
-            break;
1934
-    }
1935
-
1936
-    return $orderby;
1899
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1900
+
1901
+	$query_args = $gd_query_args_widgets;
1902
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1903
+		return $wpdb->posts . ".post_date DESC, ";
1904
+	}
1905
+
1906
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1907
+	$table = $plugin_prefix . $post_type . '_detail';
1908
+
1909
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1910
+
1911
+	switch ($sort_by) {
1912
+		case 'latest':
1913
+		case 'newest':
1914
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1915
+			break;
1916
+		case 'featured':
1917
+			$orderby = $table . ".is_featured ASC, ";
1918
+			break;
1919
+		case 'az':
1920
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1921
+			break;
1922
+		case 'high_review':
1923
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1924
+			break;
1925
+		case 'high_rating':
1926
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1927
+			break;
1928
+		case 'random':
1929
+			$orderby = "RAND(), ";
1930
+			break;
1931
+		default:
1932
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1933
+			break;
1934
+	}
1935
+
1936
+	return $orderby;
1937 1937
 }
1938 1938
 
1939 1939
 /**
@@ -1951,126 +1951,126 @@  discard block
 block discarded – undo
1951 1951
  */
1952 1952
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1953 1953
 {
1954
-    global $wpdb, $plugin_prefix, $table_prefix;
1955
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1956
-    $gd_query_args_widgets = $query_args;
1957
-
1958
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1959
-    $table = $plugin_prefix . $post_type . '_detail';
1960
-
1961
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1962
-    /**
1963
-     * Filter widget listing fields string part that is being used for query.
1964
-     *
1965
-     * @since 1.0.0
1966
-     * @param string $fields Fields string.
1967
-     * @param string $table Table name.
1968
-     * @param string $post_type Post type.
1969
-     */
1970
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1971
-
1972
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1954
+	global $wpdb, $plugin_prefix, $table_prefix;
1955
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1956
+	$gd_query_args_widgets = $query_args;
1957
+
1958
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1959
+	$table = $plugin_prefix . $post_type . '_detail';
1960
+
1961
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
1962
+	/**
1963
+	 * Filter widget listing fields string part that is being used for query.
1964
+	 *
1965
+	 * @since 1.0.0
1966
+	 * @param string $fields Fields string.
1967
+	 * @param string $table Table name.
1968
+	 * @param string $post_type Post type.
1969
+	 */
1970
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1971
+
1972
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1973
+
1974
+	########### WPML ###########
1975
+
1976
+	if (function_exists('icl_object_id')) {
1977
+		global $sitepress;
1978
+		$lang_code = ICL_LANGUAGE_CODE;
1979
+		if ($lang_code) {
1980
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1981
+		}
1982
+	}
1973 1983
 
1974
-    ########### WPML ###########
1984
+	########### WPML ###########
1975 1985
 
1976
-    if (function_exists('icl_object_id')) {
1977
-        global $sitepress;
1978
-        $lang_code = ICL_LANGUAGE_CODE;
1979
-        if ($lang_code) {
1980
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1981
-        }
1982
-    }
1986
+	/**
1987
+	 * Filter widget listing join clause string part that is being used for query.
1988
+	 *
1989
+	 * @since 1.0.0
1990
+	 * @param string $join Join clause string.
1991
+	 * @param string $post_type Post type.
1992
+	 */
1993
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1983 1994
 
1984
-    ########### WPML ###########
1995
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1985 1996
 
1986
-    /**
1987
-     * Filter widget listing join clause string part that is being used for query.
1988
-     *
1989
-     * @since 1.0.0
1990
-     * @param string $join Join clause string.
1991
-     * @param string $post_type Post type.
1992
-     */
1993
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1994
-
1995
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1996
-
1997
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1998
-
1999
-    ########### WPML ###########
2000
-    if (function_exists('icl_object_id')) {
2001
-        if ($lang_code) {
2002
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2003
-        }
2004
-    }
2005
-    ########### WPML ###########
2006
-    /**
2007
-     * Filter widget listing where clause string part that is being used for query.
2008
-     *
2009
-     * @since 1.0.0
2010
-     * @param string $where Where clause string.
2011
-     * @param string $post_type Post type.
2012
-     */
2013
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2014
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2015
-
2016
-    $groupby = " GROUP BY $wpdb->posts.ID ";
2017
-    /**
2018
-     * Filter widget listing groupby clause string part that is being used for query.
2019
-     *
2020
-     * @since 1.0.0
2021
-     * @param string $groupby Group by clause string.
2022
-     * @param string $post_type Post type.
2023
-     */
2024
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
1997
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2025 1998
 
2026
-    if ($count_only) {
2027
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1999
+	########### WPML ###########
2000
+	if (function_exists('icl_object_id')) {
2001
+		if ($lang_code) {
2002
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2003
+		}
2004
+	}
2005
+	########### WPML ###########
2006
+	/**
2007
+	 * Filter widget listing where clause string part that is being used for query.
2008
+	 *
2009
+	 * @since 1.0.0
2010
+	 * @param string $where Where clause string.
2011
+	 * @param string $post_type Post type.
2012
+	 */
2013
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2014
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
2015
+
2016
+	$groupby = " GROUP BY $wpdb->posts.ID ";
2017
+	/**
2018
+	 * Filter widget listing groupby clause string part that is being used for query.
2019
+	 *
2020
+	 * @since 1.0.0
2021
+	 * @param string $groupby Group by clause string.
2022
+	 * @param string $post_type Post type.
2023
+	 */
2024
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2025
+
2026
+	if ($count_only) {
2027
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2028 2028
 			" . $join . "
2029 2029
 			" . $where;
2030
-        $rows = (int)$wpdb->get_var($sql);
2031
-    } else {
2032
-        $orderby = geodir_widget_listings_get_order($query_args);
2033
-        /**
2034
-         * Filter widget listing orderby clause string part that is being used for query.
2035
-         *
2036
-         * @since 1.0.0
2037
-         * @param string $orderby Order by clause string.
2038
-         * @param string $table Table name.
2039
-         * @param string $post_type Post type.
2040
-         */
2041
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2042
-        $orderby .= $wpdb->posts . ".post_title ASC";
2043
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2044
-
2045
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2046
-        /**
2047
-         * Filter widget listing limit that is being used for query.
2048
-         *
2049
-         * @since 1.0.0
2050
-         * @param int $limit Query results limit.
2051
-         * @param string $post_type Post type.
2052
-         */
2053
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2054
-
2055
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2056
-        if ( !$page )
2057
-            $page = 1;
2058
-
2059
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2060
-
2061
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2030
+		$rows = (int)$wpdb->get_var($sql);
2031
+	} else {
2032
+		$orderby = geodir_widget_listings_get_order($query_args);
2033
+		/**
2034
+		 * Filter widget listing orderby clause string part that is being used for query.
2035
+		 *
2036
+		 * @since 1.0.0
2037
+		 * @param string $orderby Order by clause string.
2038
+		 * @param string $table Table name.
2039
+		 * @param string $post_type Post type.
2040
+		 */
2041
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2042
+		$orderby .= $wpdb->posts . ".post_title ASC";
2043
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2044
+
2045
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2046
+		/**
2047
+		 * Filter widget listing limit that is being used for query.
2048
+		 *
2049
+		 * @since 1.0.0
2050
+		 * @param int $limit Query results limit.
2051
+		 * @param string $post_type Post type.
2052
+		 */
2053
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2054
+
2055
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2056
+		if ( !$page )
2057
+			$page = 1;
2058
+
2059
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2060
+
2061
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2062 2062
 			" . $join . "
2063 2063
 			" . $where . "
2064 2064
 			" . $groupby . "
2065 2065
 			" . $orderby . "
2066 2066
 			" . $limit;
2067
-        $rows = $wpdb->get_results($sql);
2068
-    }
2067
+		$rows = $wpdb->get_results($sql);
2068
+	}
2069 2069
 
2070
-    unset($GLOBALS['gd_query_args_widgets']);
2071
-    unset($gd_query_args_widgets);
2070
+	unset($GLOBALS['gd_query_args_widgets']);
2071
+	unset($gd_query_args_widgets);
2072 2072
 
2073
-    return $rows;
2073
+	return $rows;
2074 2074
 }
2075 2075
 
2076 2076
 /**
@@ -2085,14 +2085,14 @@  discard block
 block discarded – undo
2085 2085
  */
2086 2086
 function geodir_function_widget_listings_fields($fields)
2087 2087
 {
2088
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2088
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2089 2089
 
2090
-    $query_args = $gd_query_args_widgets;
2091
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2092
-        return $fields;
2093
-    }
2090
+	$query_args = $gd_query_args_widgets;
2091
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2092
+		return $fields;
2093
+	}
2094 2094
     
2095
-    return $fields;
2095
+	return $fields;
2096 2096
 }
2097 2097
 
2098 2098
 /**
@@ -2107,28 +2107,28 @@  discard block
 block discarded – undo
2107 2107
  */
2108 2108
 function geodir_function_widget_listings_join($join)
2109 2109
 {
2110
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2110
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2111 2111
 
2112
-    $query_args = $gd_query_args_widgets;
2113
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2114
-        return $join;
2115
-    }
2112
+	$query_args = $gd_query_args_widgets;
2113
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2114
+		return $join;
2115
+	}
2116 2116
 
2117
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2118
-    $table = $plugin_prefix . $post_type . '_detail';
2117
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2118
+	$table = $plugin_prefix . $post_type . '_detail';
2119 2119
 
2120
-    if (!empty($query_args['with_pics_only'])) {
2121
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2122
-    }
2120
+	if (!empty($query_args['with_pics_only'])) {
2121
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2122
+	}
2123 2123
 
2124
-    if (!empty($query_args['tax_query'])) {
2125
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2126
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2127
-            $join .= $tax_queries['join'];
2128
-        }
2129
-    }
2124
+	if (!empty($query_args['tax_query'])) {
2125
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2126
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2127
+			$join .= $tax_queries['join'];
2128
+		}
2129
+	}
2130 2130
 
2131
-    return $join;
2131
+	return $join;
2132 2132
 }
2133 2133
 
2134 2134
 /**
@@ -2143,58 +2143,58 @@  discard block
 block discarded – undo
2143 2143
  */
2144 2144
 function geodir_function_widget_listings_where($where)
2145 2145
 {
2146
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2147
-
2148
-    $query_args = $gd_query_args_widgets;
2149
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2150
-        return $where;
2151
-    }
2152
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2153
-    $table = $plugin_prefix . $post_type . '_detail';
2154
-
2155
-    if (!empty($query_args)) {
2156
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2157
-            $where = geodir_default_location_where($where, $table);
2158
-        }
2159
-
2160
-        if (!empty($query_args['post_author'])) {
2161
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2162
-        }
2163
-        
2164
-        if (!empty($query_args['show_featured_only'])) {
2165
-            $where .= " AND " . $table . ".is_featured = '1'";
2166
-        }
2146
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2167 2147
 
2168
-        if (!empty($query_args['show_special_only'])) {
2169
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2170
-        }
2148
+	$query_args = $gd_query_args_widgets;
2149
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2150
+		return $where;
2151
+	}
2152
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2153
+	$table = $plugin_prefix . $post_type . '_detail';
2171 2154
 
2172
-        if (!empty($query_args['with_pics_only'])) {
2173
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2174
-        }
2155
+	if (!empty($query_args)) {
2156
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2157
+			$where = geodir_default_location_where($where, $table);
2158
+		}
2175 2159
 
2176
-        if (!empty($query_args['featured_image_only'])) {
2177
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2178
-        }
2160
+		if (!empty($query_args['post_author'])) {
2161
+			$where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2162
+		}
2163
+        
2164
+		if (!empty($query_args['show_featured_only'])) {
2165
+			$where .= " AND " . $table . ".is_featured = '1'";
2166
+		}
2179 2167
 
2180
-        if (!empty($query_args['with_videos_only'])) {
2181
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2182
-        }
2168
+		if (!empty($query_args['show_special_only'])) {
2169
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2170
+		}
2183 2171
 
2184
-        if (!empty($query_args['tax_query'])) {
2185
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2172
+		if (!empty($query_args['with_pics_only'])) {
2173
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2174
+		}
2186 2175
 
2187
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2188
-                $where .= $tax_queries['where'];
2189
-            }
2190
-        }
2191
-    }
2176
+		if (!empty($query_args['featured_image_only'])) {
2177
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2178
+		}
2192 2179
 
2193
-    return $where;
2194
-}
2180
+		if (!empty($query_args['with_videos_only'])) {
2181
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2182
+		}
2195 2183
 
2196
-/**
2197
- * Listing query orderby clause SQL part for widgets.
2184
+		if (!empty($query_args['tax_query'])) {
2185
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2186
+
2187
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2188
+				$where .= $tax_queries['where'];
2189
+			}
2190
+		}
2191
+	}
2192
+
2193
+	return $where;
2194
+}
2195
+
2196
+/**
2197
+ * Listing query orderby clause SQL part for widgets.
2198 2198
  *
2199 2199
  * @since 1.0.0
2200 2200
  * @package GeoDirectory
@@ -2205,14 +2205,14 @@  discard block
 block discarded – undo
2205 2205
  */
2206 2206
 function geodir_function_widget_listings_orderby($orderby)
2207 2207
 {
2208
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2208
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2209 2209
 
2210
-    $query_args = $gd_query_args_widgets;
2211
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2212
-        return $orderby;
2213
-    }
2210
+	$query_args = $gd_query_args_widgets;
2211
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2212
+		return $orderby;
2213
+	}
2214 2214
 
2215
-    return $orderby;
2215
+	return $orderby;
2216 2216
 }
2217 2217
 
2218 2218
 /**
@@ -2227,18 +2227,18 @@  discard block
 block discarded – undo
2227 2227
  */
2228 2228
 function geodir_function_widget_listings_limit($limit)
2229 2229
 {
2230
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2230
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2231 2231
 
2232
-    $query_args = $gd_query_args_widgets;
2233
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2234
-        return $limit;
2235
-    }
2232
+	$query_args = $gd_query_args_widgets;
2233
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2234
+		return $limit;
2235
+	}
2236 2236
 
2237
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2238
-        $limit = (int)$query_args['posts_per_page'];
2239
-    }
2237
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2238
+		$limit = (int)$query_args['posts_per_page'];
2239
+	}
2240 2240
 
2241
-    return $limit;
2241
+	return $limit;
2242 2242
 }
2243 2243
 
2244 2244
 /**
@@ -2252,24 +2252,24 @@  discard block
 block discarded – undo
2252 2252
  */
2253 2253
 function geodir_media_image_large_width($default = 800, $params = '')
2254 2254
 {
2255
-    $large_size_w = get_option('large_size_w');
2256
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2257
-    $large_size_w = absint($large_size_w);
2258
-
2259
-    if (!get_option('geodir_use_wp_media_large_size')) {
2260
-        $large_size_w = 800;
2261
-    }
2262
-
2263
-    /**
2264
-     * Filter large image width.
2265
-     *
2266
-     * @since 1.0.0
2267
-     * @param int $large_size_w Large image width.
2268
-     * @param int $default Default width.
2269
-     * @param string|array $params Image parameters.
2270
-     */
2271
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2272
-    return $large_size_w;
2255
+	$large_size_w = get_option('large_size_w');
2256
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2257
+	$large_size_w = absint($large_size_w);
2258
+
2259
+	if (!get_option('geodir_use_wp_media_large_size')) {
2260
+		$large_size_w = 800;
2261
+	}
2262
+
2263
+	/**
2264
+	 * Filter large image width.
2265
+	 *
2266
+	 * @since 1.0.0
2267
+	 * @param int $large_size_w Large image width.
2268
+	 * @param int $default Default width.
2269
+	 * @param string|array $params Image parameters.
2270
+	 */
2271
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2272
+	return $large_size_w;
2273 2273
 }
2274 2274
 
2275 2275
 /**
@@ -2283,25 +2283,25 @@  discard block
 block discarded – undo
2283 2283
  */
2284 2284
 function geodir_media_image_large_height($default = 800, $params = '')
2285 2285
 {
2286
-    $large_size_h = get_option('large_size_h');
2287
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2288
-    $large_size_h = absint($large_size_h);
2289
-
2290
-    if (!get_option('geodir_use_wp_media_large_size')) {
2291
-        $large_size_h = 800;
2292
-    }
2293
-
2294
-    /**
2295
-     * Filter large image height.
2296
-     *
2297
-     * @since 1.0.0
2298
-     * @param int $large_size_h Large image height.
2299
-     * @param int $default Default height.
2300
-     * @param string|array $params Image parameters.
2301
-     */
2302
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2286
+	$large_size_h = get_option('large_size_h');
2287
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2288
+	$large_size_h = absint($large_size_h);
2303 2289
 
2304
-    return $large_size_h;
2290
+	if (!get_option('geodir_use_wp_media_large_size')) {
2291
+		$large_size_h = 800;
2292
+	}
2293
+
2294
+	/**
2295
+	 * Filter large image height.
2296
+	 *
2297
+	 * @since 1.0.0
2298
+	 * @param int $large_size_h Large image height.
2299
+	 * @param int $default Default height.
2300
+	 * @param string|array $params Image parameters.
2301
+	 */
2302
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2303
+
2304
+	return $large_size_h;
2305 2305
 }
2306 2306
 
2307 2307
 /**
@@ -2316,25 +2316,25 @@  discard block
 block discarded – undo
2316 2316
  */
2317 2317
 function geodir_sanitize_location_name($type, $name, $translate = true)
2318 2318
 {
2319
-    if ($name == '') {
2320
-        return NULL;
2321
-    }
2322
-
2323
-    $type = $type == 'gd_country' ? 'country' : $type;
2324
-    $type = $type == 'gd_region' ? 'region' : $type;
2325
-    $type = $type == 'gd_city' ? 'city' : $type;
2326
-
2327
-    $return = $name;
2328
-    if (function_exists('get_actual_location_name')) {
2329
-        $return = get_actual_location_name($type, $name, $translate);
2330
-    } else {
2331
-        $return = preg_replace('/-(\d+)$/', '', $return);
2332
-        $return = preg_replace('/[_-]/', ' ', $return);
2333
-        $return = geodir_ucwords($return);
2334
-        $return = $translate ? __($return, 'geodirectory') : $return;
2335
-    }
2336
-
2337
-    return $return;
2319
+	if ($name == '') {
2320
+		return NULL;
2321
+	}
2322
+
2323
+	$type = $type == 'gd_country' ? 'country' : $type;
2324
+	$type = $type == 'gd_region' ? 'region' : $type;
2325
+	$type = $type == 'gd_city' ? 'city' : $type;
2326
+
2327
+	$return = $name;
2328
+	if (function_exists('get_actual_location_name')) {
2329
+		$return = get_actual_location_name($type, $name, $translate);
2330
+	} else {
2331
+		$return = preg_replace('/-(\d+)$/', '', $return);
2332
+		$return = preg_replace('/[_-]/', ' ', $return);
2333
+		$return = geodir_ucwords($return);
2334
+		$return = $translate ? __($return, 'geodirectory') : $return;
2335
+	}
2336
+
2337
+	return $return;
2338 2338
 }
2339 2339
 
2340 2340
 
@@ -2348,14 +2348,14 @@  discard block
 block discarded – undo
2348 2348
 function geodir_comments_number($number)
2349 2349
 {
2350 2350
 
2351
-    if ($number > 1) {
2352
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2353
-    } elseif ($number == 0 || $number == '') {
2354
-        $output = __('No Reviews', 'geodirectory');
2355
-    } else { // must be one
2356
-        $output = __('1 Review', 'geodirectory');
2357
-    }
2358
-    echo $output;
2351
+	if ($number > 1) {
2352
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2353
+	} elseif ($number == 0 || $number == '') {
2354
+		$output = __('No Reviews', 'geodirectory');
2355
+	} else { // must be one
2356
+		$output = __('1 Review', 'geodirectory');
2357
+	}
2358
+	echo $output;
2359 2359
 }
2360 2360
 
2361 2361
 /**
@@ -2368,23 +2368,23 @@  discard block
 block discarded – undo
2368 2368
  */
2369 2369
 function is_page_geodir_home()
2370 2370
 {
2371
-    global $wpdb;
2372
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2373
-    if (function_exists('geodir_location_geo_home_link')) {
2374
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2375
-    }
2376
-    $home_url = home_url('', 'http');
2377
-    if (function_exists('geodir_location_geo_home_link')) {
2378
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2379
-    }
2380
-    $home_url = str_replace("www.", "", $home_url);
2381
-    if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2382
-        return true;
2383
-    }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2384
-        return true;
2385
-    } else {
2386
-        return false;
2387
-    }
2371
+	global $wpdb;
2372
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2373
+	if (function_exists('geodir_location_geo_home_link')) {
2374
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2375
+	}
2376
+	$home_url = home_url('', 'http');
2377
+	if (function_exists('geodir_location_geo_home_link')) {
2378
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2379
+	}
2380
+	$home_url = str_replace("www.", "", $home_url);
2381
+	if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
2382
+		return true;
2383
+	}elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
2384
+		return true;
2385
+	} else {
2386
+		return false;
2387
+	}
2388 2388
 
2389 2389
 }
2390 2390
 
@@ -2400,13 +2400,13 @@  discard block
 block discarded – undo
2400 2400
  */
2401 2401
 function geodir_wpseo_homepage_canonical($url)
2402 2402
 {
2403
-    global $post;
2403
+	global $post;
2404 2404
 
2405
-    if (is_page_geodir_home()) {
2406
-        return home_url();
2407
-    }
2405
+	if (is_page_geodir_home()) {
2406
+		return home_url();
2407
+	}
2408 2408
 
2409
-    return $url;
2409
+	return $url;
2410 2410
 }
2411 2411
 
2412 2412
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2423,16 +2423,16 @@  discard block
 block discarded – undo
2423 2423
  */
2424 2424
 function geodir_googlemap_script_extra_details_page($extra)
2425 2425
 {
2426
-    global $post;
2427
-    $add_google_places_api = false;
2428
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2429
-        $add_google_places_api = true;
2430
-    }
2431
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2432
-        $extra .= "&amp;libraries=places";
2433
-    }
2434
-
2435
-    return $extra;
2426
+	global $post;
2427
+	$add_google_places_api = false;
2428
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2429
+		$add_google_places_api = true;
2430
+	}
2431
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2432
+		$extra .= "&amp;libraries=places";
2433
+	}
2434
+
2435
+	return $extra;
2436 2436
 }
2437 2437
 
2438 2438
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2452,92 +2452,92 @@  discard block
 block discarded – undo
2452 2452
  */
2453 2453
 function geodir_popular_post_category_output($args = '', $instance = '')
2454 2454
 {
2455
-    // prints the widget
2456
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2457
-    extract($args, EXTR_SKIP);
2458
-
2459
-    echo $before_widget;
2460
-
2461
-    /** This filter is documented in geodirectory_widgets.php */
2462
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2463
-
2464
-    $gd_post_type = geodir_get_current_posttype();
2465
-
2466
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2467
-    $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2468
-
2469
-    $taxonomy = array();
2470
-    if (!empty($gd_post_type)) {
2471
-        $taxonomy[] = $gd_post_type . "category";
2472
-    } else {
2473
-        $default_post_type = geodir_get_posttypes()[0];
2474
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2475
-    }
2476
-
2477
-    $terms = get_terms($taxonomy);
2478
-    $a_terms = array();
2479
-    $b_terms = array();
2480
-
2481
-    foreach ($terms as $term) {
2482
-        if ($term->count > 0) {
2483
-            $a_terms[$term->taxonomy][] = $term;
2484
-        }
2485
-    }
2486
-
2487
-    if (!empty($a_terms)) {
2488
-        foreach ($a_terms as $b_key => $b_val) {
2489
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2490
-        }
2491
-
2492
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2493
-
2494
-        $tax_change_output = '';
2495
-        if (count($b_terms) > 1) {
2496
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2497
-            foreach ($b_terms as $key => $val) {
2498
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2499
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2500
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2501
-            }
2502
-            $tax_change_output .= "</select>";
2503
-        }
2504
-
2505
-        if (!empty($b_terms)) {
2506
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2507
-            global $cat_count;//make global so we can change via function
2508
-            $cat_count = 0;
2509
-            ?>
2455
+	// prints the widget
2456
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2457
+	extract($args, EXTR_SKIP);
2458
+
2459
+	echo $before_widget;
2460
+
2461
+	/** This filter is documented in geodirectory_widgets.php */
2462
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2463
+
2464
+	$gd_post_type = geodir_get_current_posttype();
2465
+
2466
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2467
+	$default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2468
+
2469
+	$taxonomy = array();
2470
+	if (!empty($gd_post_type)) {
2471
+		$taxonomy[] = $gd_post_type . "category";
2472
+	} else {
2473
+		$default_post_type = geodir_get_posttypes()[0];
2474
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2475
+	}
2476
+
2477
+	$terms = get_terms($taxonomy);
2478
+	$a_terms = array();
2479
+	$b_terms = array();
2480
+
2481
+	foreach ($terms as $term) {
2482
+		if ($term->count > 0) {
2483
+			$a_terms[$term->taxonomy][] = $term;
2484
+		}
2485
+	}
2486
+
2487
+	if (!empty($a_terms)) {
2488
+		foreach ($a_terms as $b_key => $b_val) {
2489
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2490
+		}
2491
+
2492
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2493
+
2494
+		$tax_change_output = '';
2495
+		if (count($b_terms) > 1) {
2496
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2497
+			foreach ($b_terms as $key => $val) {
2498
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2499
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2500
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2501
+			}
2502
+			$tax_change_output .= "</select>";
2503
+		}
2504
+
2505
+		if (!empty($b_terms)) {
2506
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2507
+			global $cat_count;//make global so we can change via function
2508
+			$cat_count = 0;
2509
+			?>
2510 2510
             <div class="geodir-category-list-in clearfix">
2511 2511
                 <div class="geodir-cat-list clearfix">
2512 2512
                     <?php
2513
-                    echo $before_title . __($title) . $after_title;
2513
+					echo $before_title . __($title) . $after_title;
2514 2514
 
2515
-                    echo $tax_change_output;
2515
+					echo $tax_change_output;
2516 2516
 
2517
-                    echo '<ul class="geodir-popular-cat-list">';
2517
+					echo '<ul class="geodir-popular-cat-list">';
2518 2518
 
2519
-                    geodir_helper_cat_list_output($terms, $category_limit);
2519
+					geodir_helper_cat_list_output($terms, $category_limit);
2520 2520
 
2521
-                    echo '</ul>';
2522
-                    ?>
2521
+					echo '</ul>';
2522
+					?>
2523 2523
                 </div>
2524 2524
                 <?php
2525
-                $hide = '';
2526
-                if ($cat_count < $category_limit) {
2527
-                    $hide = 'style="display:none;"';
2528
-                }
2529
-                echo "<div class='geodir-cat-list-more' $hide >";
2530
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2531
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2532
-                echo "</div>";
2533
-                /* add scripts */
2534
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2535
-                ?>
2525
+				$hide = '';
2526
+				if ($cat_count < $category_limit) {
2527
+					$hide = 'style="display:none;"';
2528
+				}
2529
+				echo "<div class='geodir-cat-list-more' $hide >";
2530
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2531
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2532
+				echo "</div>";
2533
+				/* add scripts */
2534
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2535
+				?>
2536 2536
             </div>
2537 2537
         <?php
2538
-        }
2539
-    }
2540
-    echo $after_widget;
2538
+		}
2539
+	}
2540
+	echo $after_widget;
2541 2541
 }
2542 2542
 
2543 2543
 /**
@@ -2551,38 +2551,38 @@  discard block
 block discarded – undo
2551 2551
  */
2552 2552
 function geodir_helper_cat_list_output($terms, $category_limit)
2553 2553
 {
2554
-    global $geodir_post_category_str, $cat_count;
2555
-    $term_icons = geodir_get_term_icon();
2554
+	global $geodir_post_category_str, $cat_count;
2555
+	$term_icons = geodir_get_term_icon();
2556 2556
 
2557
-    $geodir_post_category_str = array();
2557
+	$geodir_post_category_str = array();
2558 2558
 
2559 2559
 
2560
-    foreach ($terms as $cat) {
2561
-        $post_type = str_replace("category", "", $cat->taxonomy);
2562
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2560
+	foreach ($terms as $cat) {
2561
+		$post_type = str_replace("category", "", $cat->taxonomy);
2562
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2563 2563
 
2564
-        $cat_count++;
2564
+		$cat_count++;
2565 2565
 
2566
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2566
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2567 2567
 
2568
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2569
-        $total_post = $cat->count;
2568
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2569
+		$total_post = $cat->count;
2570 2570
 
2571
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2572
-        /**
2573
-         * Filer the category term link.
2574
-         *
2575
-         * @since 1.4.5
2576
-         * @param string $term_link The term permalink.
2577
-         * @param int    $cat->term_id The term id.
2578
-         * @param string $post_type Wordpress post type.
2579
-         */
2580
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2571
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2572
+		/**
2573
+		 * Filer the category term link.
2574
+		 *
2575
+		 * @since 1.4.5
2576
+		 * @param string $term_link The term permalink.
2577
+		 * @param int    $cat->term_id The term id.
2578
+		 * @param string $post_type Wordpress post type.
2579
+		 */
2580
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2581 2581
 
2582
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2583
-        echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
2584
-        echo '</a></li>';
2585
-    }
2582
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2583
+		echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
2584
+		echo '</a></li>';
2585
+	}
2586 2586
 }
2587 2587
 
2588 2588
 /**
@@ -2596,108 +2596,108 @@  discard block
 block discarded – undo
2596 2596
  */
2597 2597
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2598 2598
 {
2599
-    // prints the widget
2600
-    extract($args, EXTR_SKIP);
2601
-
2602
-    echo $before_widget;
2603
-
2604
-    /** This filter is documented in geodirectory_widgets.php */
2605
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2606
-    /**
2607
-     * Filter the widget post type.
2608
-     *
2609
-     * @since 1.0.0
2610
-     * @param string $instance['post_type'] Post type of listing.
2611
-     */
2612
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2613
-    /**
2614
-     * Filter the widget's term.
2615
-     *
2616
-     * @since 1.0.0
2617
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2618
-     */
2619
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2620
-    /**
2621
-     * Filter the widget listings limit.
2622
-     *
2623
-     * @since 1.0.0
2624
-     * @param string $instance['post_number'] Number of listings to display.
2625
-     */
2626
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2627
-    /**
2628
-     * Filter the widget listings limit shown at one time.
2629
-     *
2630
-     * @since 1.5.0
2631
-     * @param string $instance['max_show'] Number of listings to display on screen.
2632
-     */
2633
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2634
-    /**
2635
-     * Filter the widget slide width.
2636
-     *
2637
-     * @since 1.5.0
2638
-     * @param string $instance['slide_width'] Width of the slides shown.
2639
-     */
2640
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2641
-    /**
2642
-     * Filter widget's "show title" value.
2643
-     *
2644
-     * @since 1.0.0
2645
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2646
-     */
2647
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2648
-    /**
2649
-     * Filter widget's "slideshow" value.
2650
-     *
2651
-     * @since 1.0.0
2652
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2653
-     */
2654
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2655
-    /**
2656
-     * Filter widget's "animationLoop" value.
2657
-     *
2658
-     * @since 1.0.0
2659
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2660
-     */
2661
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2662
-    /**
2663
-     * Filter widget's "directionNav" value.
2664
-     *
2665
-     * @since 1.0.0
2666
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2667
-     */
2668
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2669
-    /**
2670
-     * Filter widget's "slideshowSpeed" value.
2671
-     *
2672
-     * @since 1.0.0
2673
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2674
-     */
2675
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2676
-    /**
2677
-     * Filter widget's "animationSpeed" value.
2678
-     *
2679
-     * @since 1.0.0
2680
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2681
-     */
2682
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2683
-    /**
2684
-     * Filter widget's "animation" value.
2685
-     *
2686
-     * @since 1.0.0
2687
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2688
-     */
2689
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2690
-    /**
2691
-     * Filter widget's "list_sort" type.
2692
-     *
2693
-     * @since 1.0.0
2694
-     * @param string $instance['list_sort'] Listing sort by type.
2695
-     */
2696
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2697
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2698
-
2699
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2700
-    ?>
2599
+	// prints the widget
2600
+	extract($args, EXTR_SKIP);
2601
+
2602
+	echo $before_widget;
2603
+
2604
+	/** This filter is documented in geodirectory_widgets.php */
2605
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2606
+	/**
2607
+	 * Filter the widget post type.
2608
+	 *
2609
+	 * @since 1.0.0
2610
+	 * @param string $instance['post_type'] Post type of listing.
2611
+	 */
2612
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2613
+	/**
2614
+	 * Filter the widget's term.
2615
+	 *
2616
+	 * @since 1.0.0
2617
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2618
+	 */
2619
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2620
+	/**
2621
+	 * Filter the widget listings limit.
2622
+	 *
2623
+	 * @since 1.0.0
2624
+	 * @param string $instance['post_number'] Number of listings to display.
2625
+	 */
2626
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2627
+	/**
2628
+	 * Filter the widget listings limit shown at one time.
2629
+	 *
2630
+	 * @since 1.5.0
2631
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2632
+	 */
2633
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2634
+	/**
2635
+	 * Filter the widget slide width.
2636
+	 *
2637
+	 * @since 1.5.0
2638
+	 * @param string $instance['slide_width'] Width of the slides shown.
2639
+	 */
2640
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2641
+	/**
2642
+	 * Filter widget's "show title" value.
2643
+	 *
2644
+	 * @since 1.0.0
2645
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2646
+	 */
2647
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2648
+	/**
2649
+	 * Filter widget's "slideshow" value.
2650
+	 *
2651
+	 * @since 1.0.0
2652
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2653
+	 */
2654
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2655
+	/**
2656
+	 * Filter widget's "animationLoop" value.
2657
+	 *
2658
+	 * @since 1.0.0
2659
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2660
+	 */
2661
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2662
+	/**
2663
+	 * Filter widget's "directionNav" value.
2664
+	 *
2665
+	 * @since 1.0.0
2666
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2667
+	 */
2668
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2669
+	/**
2670
+	 * Filter widget's "slideshowSpeed" value.
2671
+	 *
2672
+	 * @since 1.0.0
2673
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2674
+	 */
2675
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2676
+	/**
2677
+	 * Filter widget's "animationSpeed" value.
2678
+	 *
2679
+	 * @since 1.0.0
2680
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2681
+	 */
2682
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2683
+	/**
2684
+	 * Filter widget's "animation" value.
2685
+	 *
2686
+	 * @since 1.0.0
2687
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2688
+	 */
2689
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2690
+	/**
2691
+	 * Filter widget's "list_sort" type.
2692
+	 *
2693
+	 * @since 1.0.0
2694
+	 * @param string $instance['list_sort'] Listing sort by type.
2695
+	 */
2696
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2697
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2698
+
2699
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2700
+	?>
2701 2701
     <script type="text/javascript">
2702 2702
         jQuery(window).load(function () {
2703 2703
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2738,86 +2738,86 @@  discard block
 block discarded – undo
2738 2738
         });
2739 2739
     </script>
2740 2740
     <?php
2741
-    $query_args = array(
2742
-        'posts_per_page' => $post_number,
2743
-        'is_geodir_loop' => true,
2744
-        'post_type' => $post_type,
2745
-        'order_by' => $list_sort
2746
-    );
2747
-    if ($show_featured_only) {
2748
-        $query_args['show_featured_only'] = 1;
2749
-    }
2750
-
2751
-    if ($category != 0 || $category != '') {
2752
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2753
-        $tax_query = array(
2754
-            'taxonomy' => $category_taxonomy[0],
2755
-            'field' => 'id',
2756
-            'terms' => $category
2757
-        );
2758
-
2759
-        $query_args['tax_query'] = array($tax_query);
2760
-    }
2761
-
2762
-    // we want listings with featured image only
2763
-    $query_args['featured_image_only'] = 1;
2764
-
2765
-    if ($post_type == 'gd_event') {
2766
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2767
-    }// show only upcomming events
2768
-
2769
-    $widget_listings = geodir_get_widget_listings($query_args);
2770
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2771
-        if ($title) {
2772
-            echo $before_title . $title . $after_title;
2773
-        }
2774
-
2775
-        global $post;
2776
-
2777
-        $current_post = $post;// keep current post info
2778
-
2779
-        $widget_main_slides = '';
2780
-        $nav_slides = '';
2781
-        $widget_slides = 0;
2782
-
2783
-        foreach ($widget_listings as $widget_listing) {
2784
-            global $gd_widget_listing_type;
2785
-            $post = $widget_listing;
2786
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2787
-
2788
-            if (!empty($widget_image)) {
2789
-                if ($widget_image->height >= 200) {
2790
-                    $widget_spacer_height = 0;
2791
-                } else {
2792
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2793
-                }
2794
-
2795
-                $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />';
2796
-
2797
-                $title = '';
2798
-                if ($show_title) {
2799
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2800
-                    $post_id = $post->ID;
2801
-                    $post_permalink = get_permalink($post->ID);
2802
-                    $post_title = get_the_title($post->ID);
2803
-                    /**
2804
-                     * Filter the listing slider widget title.
2805
-                     *
2806
-                     * @since 1.6.1
2807
-                     * @param string $title_html The html output of the title.
2808
-                     * @param int $post_id The post id.
2809
-                     * @param string $post_permalink The post permalink url.
2810
-                     * @param string $post_title The post title text.
2811
-                     */
2812
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2813
-                }
2814
-
2815
-                $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>';
2816
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2817
-                $widget_slides++;
2818
-            }
2819
-        }
2820
-        ?>
2741
+	$query_args = array(
2742
+		'posts_per_page' => $post_number,
2743
+		'is_geodir_loop' => true,
2744
+		'post_type' => $post_type,
2745
+		'order_by' => $list_sort
2746
+	);
2747
+	if ($show_featured_only) {
2748
+		$query_args['show_featured_only'] = 1;
2749
+	}
2750
+
2751
+	if ($category != 0 || $category != '') {
2752
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2753
+		$tax_query = array(
2754
+			'taxonomy' => $category_taxonomy[0],
2755
+			'field' => 'id',
2756
+			'terms' => $category
2757
+		);
2758
+
2759
+		$query_args['tax_query'] = array($tax_query);
2760
+	}
2761
+
2762
+	// we want listings with featured image only
2763
+	$query_args['featured_image_only'] = 1;
2764
+
2765
+	if ($post_type == 'gd_event') {
2766
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2767
+	}// show only upcomming events
2768
+
2769
+	$widget_listings = geodir_get_widget_listings($query_args);
2770
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2771
+		if ($title) {
2772
+			echo $before_title . $title . $after_title;
2773
+		}
2774
+
2775
+		global $post;
2776
+
2777
+		$current_post = $post;// keep current post info
2778
+
2779
+		$widget_main_slides = '';
2780
+		$nav_slides = '';
2781
+		$widget_slides = 0;
2782
+
2783
+		foreach ($widget_listings as $widget_listing) {
2784
+			global $gd_widget_listing_type;
2785
+			$post = $widget_listing;
2786
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2787
+
2788
+			if (!empty($widget_image)) {
2789
+				if ($widget_image->height >= 200) {
2790
+					$widget_spacer_height = 0;
2791
+				} else {
2792
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2793
+				}
2794
+
2795
+				$widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />';
2796
+
2797
+				$title = '';
2798
+				if ($show_title) {
2799
+					$title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2800
+					$post_id = $post->ID;
2801
+					$post_permalink = get_permalink($post->ID);
2802
+					$post_title = get_the_title($post->ID);
2803
+					/**
2804
+					 * Filter the listing slider widget title.
2805
+					 *
2806
+					 * @since 1.6.1
2807
+					 * @param string $title_html The html output of the title.
2808
+					 * @param int $post_id The post id.
2809
+					 * @param string $post_permalink The post permalink url.
2810
+					 * @param string $post_title The post title text.
2811
+					 */
2812
+					$title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2813
+				}
2814
+
2815
+				$widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>';
2816
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2817
+				$widget_slides++;
2818
+			}
2819
+		}
2820
+		?>
2821 2821
         <div class="flex-container" style="min-height:200px;">
2822 2822
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2823 2823
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2830,10 +2830,10 @@  discard block
 block discarded – undo
2830 2830
             <?php } ?>
2831 2831
         </div>
2832 2832
         <?php
2833
-        $GLOBALS['post'] = $current_post;
2834
-        setup_postdata($current_post);
2835
-    }
2836
-    echo $after_widget;
2833
+		$GLOBALS['post'] = $current_post;
2834
+		setup_postdata($current_post);
2835
+	}
2836
+	echo $after_widget;
2837 2837
 }
2838 2838
 
2839 2839
 
@@ -2848,65 +2848,65 @@  discard block
 block discarded – undo
2848 2848
  */
2849 2849
 function geodir_loginwidget_output($args = '', $instance = '')
2850 2850
 {
2851
-    //print_r($args);
2852
-    //print_r($instance);
2853
-    // prints the widget
2854
-    extract($args, EXTR_SKIP);
2851
+	//print_r($args);
2852
+	//print_r($instance);
2853
+	// prints the widget
2854
+	extract($args, EXTR_SKIP);
2855 2855
 
2856
-    /** This filter is documented in geodirectory_widgets.php */
2857
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2856
+	/** This filter is documented in geodirectory_widgets.php */
2857
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2858 2858
 
2859
-    echo $before_widget;
2860
-    echo $before_title . $title . $after_title;
2859
+	echo $before_widget;
2860
+	echo $before_title . $title . $after_title;
2861 2861
 
2862
-    if (is_user_logged_in()) {
2863
-        global $current_user;
2862
+	if (is_user_logged_in()) {
2863
+		global $current_user;
2864 2864
 
2865
-        $author_link = get_author_posts_url($current_user->data->ID);
2866
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2865
+		$author_link = get_author_posts_url($current_user->data->ID);
2866
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2867 2867
 
2868
-        echo '<ul class="geodir-loginbox-list">';
2869
-        ob_start();
2870
-        ?>
2868
+		echo '<ul class="geodir-loginbox-list">';
2869
+		ob_start();
2870
+		?>
2871 2871
         <li><a class="signin"
2872 2872
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2873 2873
         <?php
2874
-        $post_types = geodir_get_posttypes('object');
2875
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2876
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2874
+		$post_types = geodir_get_posttypes('object');
2875
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2876
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2877 2877
 
2878
-        if (!empty($show_add_listing_post_types_main_nav)) {
2879
-            $addlisting_links = '';
2880
-            foreach ($post_types as $key => $postobj) {
2878
+		if (!empty($show_add_listing_post_types_main_nav)) {
2879
+			$addlisting_links = '';
2880
+			foreach ($post_types as $key => $postobj) {
2881 2881
 
2882
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2882
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2883 2883
 
2884
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2884
+					if ($add_link = geodir_get_addlisting_link($key)) {
2885 2885
 
2886
-                        $name = $postobj->labels->name;
2886
+						$name = $postobj->labels->name;
2887 2887
 
2888
-                        $selected = '';
2889
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2890
-                            $selected = 'selected="selected"';
2888
+						$selected = '';
2889
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2890
+							$selected = 'selected="selected"';
2891 2891
 
2892
-                        /**
2893
-                         * Filter add listing link.
2894
-                         *
2895
-                         * @since 1.0.0
2896
-                         * @param string $add_link Add listing link.
2897
-                         * @param string $key Add listing array key.
2898
-                         * @param int $current_user->ID Current user ID.
2899
-                         */
2900
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2892
+						/**
2893
+						 * Filter add listing link.
2894
+						 *
2895
+						 * @since 1.0.0
2896
+						 * @param string $add_link Add listing link.
2897
+						 * @param string $key Add listing array key.
2898
+						 * @param int $current_user->ID Current user ID.
2899
+						 */
2900
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2901 2901
 
2902
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2902
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2903 2903
 
2904
-                    }
2905
-                }
2904
+					}
2905
+				}
2906 2906
 
2907
-            }
2907
+			}
2908 2908
 
2909
-            if ($addlisting_links != '') { ?>
2909
+			if ($addlisting_links != '') { ?>
2910 2910
 
2911 2911
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2912 2912
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2915,42 +2915,42 @@  discard block
 block discarded – undo
2915 2915
                         <?php echo $addlisting_links; ?>
2916 2916
                     </select></li> <?php
2917 2917
 
2918
-            }
2919
-
2920
-        }
2921
-        // My Favourites in Dashboard
2922
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2923
-        $user_favourite = geodir_user_favourite_listing_count();
2924
-
2925
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2926
-            $favourite_links = '';
2927
-
2928
-            foreach ($post_types as $key => $postobj) {
2929
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2930
-                    $name = $postobj->labels->name;
2931
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2932
-
2933
-                    $selected = '';
2934
-
2935
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2936
-                        $selected = 'selected="selected"';
2937
-                    }
2938
-                    /**
2939
-                     * Filter favorite listing link.
2940
-                     *
2941
-                     * @since 1.0.0
2942
-                     * @param string $post_type_link Favorite listing link.
2943
-                     * @param string $key Favorite listing array key.
2944
-                     * @param int $current_user->ID Current user ID.
2945
-                     */
2946
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2947
-
2948
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2949
-                }
2950
-            }
2951
-
2952
-            if ($favourite_links != '') {
2953
-                ?>
2918
+			}
2919
+
2920
+		}
2921
+		// My Favourites in Dashboard
2922
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2923
+		$user_favourite = geodir_user_favourite_listing_count();
2924
+
2925
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2926
+			$favourite_links = '';
2927
+
2928
+			foreach ($post_types as $key => $postobj) {
2929
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2930
+					$name = $postobj->labels->name;
2931
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2932
+
2933
+					$selected = '';
2934
+
2935
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2936
+						$selected = 'selected="selected"';
2937
+					}
2938
+					/**
2939
+					 * Filter favorite listing link.
2940
+					 *
2941
+					 * @since 1.0.0
2942
+					 * @param string $post_type_link Favorite listing link.
2943
+					 * @param string $key Favorite listing array key.
2944
+					 * @param int $current_user->ID Current user ID.
2945
+					 */
2946
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2947
+
2948
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2949
+				}
2950
+			}
2951
+
2952
+			if ($favourite_links != '') {
2953
+				?>
2954 2954
                 <li>
2955 2955
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
2956 2956
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -2960,42 +2960,42 @@  discard block
 block discarded – undo
2960 2960
                     </select>
2961 2961
                 </li>
2962 2962
             <?php
2963
-            }
2964
-        }
2965
-
2966
-
2967
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2968
-        $user_listing = geodir_user_post_listing_count();
2969
-
2970
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2971
-            $listing_links = '';
2972
-
2973
-            foreach ($post_types as $key => $postobj) {
2974
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2975
-                    $name = $postobj->labels->name;
2976
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2977
-
2978
-                    $selected = '';
2979
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2980
-                        $selected = 'selected="selected"';
2981
-                    }
2982
-
2983
-                    /**
2984
-                     * Filter my listing link.
2985
-                     *
2986
-                     * @since 1.0.0
2987
-                     * @param string $listing_link My listing link.
2988
-                     * @param string $key My listing array key.
2989
-                     * @param int $current_user->ID Current user ID.
2990
-                     */
2991
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2992
-
2993
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2994
-                }
2995
-            }
2996
-
2997
-            if ($listing_links != '') {
2998
-                ?>
2963
+			}
2964
+		}
2965
+
2966
+
2967
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2968
+		$user_listing = geodir_user_post_listing_count();
2969
+
2970
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2971
+			$listing_links = '';
2972
+
2973
+			foreach ($post_types as $key => $postobj) {
2974
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2975
+					$name = $postobj->labels->name;
2976
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2977
+
2978
+					$selected = '';
2979
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2980
+						$selected = 'selected="selected"';
2981
+					}
2982
+
2983
+					/**
2984
+					 * Filter my listing link.
2985
+					 *
2986
+					 * @since 1.0.0
2987
+					 * @param string $listing_link My listing link.
2988
+					 * @param string $key My listing array key.
2989
+					 * @param int $current_user->ID Current user ID.
2990
+					 */
2991
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2992
+
2993
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2994
+				}
2995
+			}
2996
+
2997
+			if ($listing_links != '') {
2998
+				?>
2999 2999
                 <li>
3000 3000
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
3001 3001
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -3005,27 +3005,27 @@  discard block
 block discarded – undo
3005 3005
                     </select>
3006 3006
                 </li>
3007 3007
             <?php
3008
-            }
3009
-        }
3010
-
3011
-        $dashboard_link = ob_get_clean();
3012
-        /**
3013
-         * Filter dashboard links HTML.
3014
-         *
3015
-         * @since 1.0.0
3016
-         * @param string $dashboard_link Dashboard links HTML.
3017
-         */
3018
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
3019
-        echo '</ul>';
3020
-    } else {
3021
-        ?>
3008
+			}
3009
+		}
3010
+
3011
+		$dashboard_link = ob_get_clean();
3012
+		/**
3013
+		 * Filter dashboard links HTML.
3014
+		 *
3015
+		 * @since 1.0.0
3016
+		 * @param string $dashboard_link Dashboard links HTML.
3017
+		 */
3018
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
3019
+		echo '</ul>';
3020
+	} else {
3021
+		?>
3022 3022
         <?php
3023
-        /**
3024
-         * Filter signup form action link.
3025
-         *
3026
-         * @since 1.0.0
3027
-         */
3028
-        ?>
3023
+		/**
3024
+		 * Filter signup form action link.
3025
+		 *
3026
+		 * @since 1.0.0
3027
+		 */
3028
+		?>
3029 3029
         <form name="loginform" class="loginform1"
3030 3030
               action="<?php echo geodir_login_url(); ?>"
3031 3031
               method="post">
@@ -3045,28 +3045,28 @@  discard block
 block discarded – undo
3045 3045
 
3046 3046
                 <p class="geodir-new-forgot-link">
3047 3047
                     <?php
3048
-                    /**
3049
-                     * Filter signup page register form link.
3050
-                     *
3051
-                     * @since 1.0.0
3052
-                     */
3053
-                    ?>
3048
+					/**
3049
+					 * Filter signup page register form link.
3050
+					 *
3051
+					 * @since 1.0.0
3052
+					 */
3053
+					?>
3054 3054
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
3055 3055
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
3056 3056
 
3057 3057
                     <?php
3058
-                    /**
3059
-                     * Filter signup page forgot password form link.
3060
-                     *
3061
-                     * @since 1.0.0
3062
-                     */
3063
-                    ?>
3058
+					/**
3059
+					 * Filter signup page forgot password form link.
3060
+					 *
3061
+					 * @since 1.0.0
3062
+					 */
3063
+					?>
3064 3064
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
3065 3065
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
3066 3066
         </form>
3067 3067
     <?php }
3068 3068
 
3069
-    echo $after_widget;
3069
+	echo $after_widget;
3070 3070
 }
3071 3071
 
3072 3072
 
@@ -3085,284 +3085,284 @@  discard block
 block discarded – undo
3085 3085
  * @param array|string $instance The settings for the particular instance of the widget.
3086 3086
  */
3087 3087
 function geodir_popular_postview_output($args = '', $instance = '') {
3088
-    global $gd_session;
3088
+	global $gd_session;
3089 3089
 	
3090
-    // prints the widget
3091
-    extract($args, EXTR_SKIP);
3092
-
3093
-    echo $before_widget;
3094
-
3095
-    /** This filter is documented in geodirectory_widgets.php */
3096
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3097
-    /**
3098
-     * Filter the widget post type.
3099
-     *
3100
-     * @since 1.0.0
3101
-     * @param string $instance['post_type'] Post type of listing.
3102
-     */
3103
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3104
-    /**
3105
-     * Filter the widget's term.
3106
-     *
3107
-     * @since 1.0.0
3108
-     * @param string $instance['category'] Filter by term. Can be any valid term.
3109
-     */
3110
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3111
-    /**
3112
-     * Filter the widget listings limit.
3113
-     *
3114
-     * @since 1.0.0
3115
-     * @param string $instance['post_number'] Number of listings to display.
3116
-     */
3117
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3118
-    /**
3119
-     * Filter widget's "layout" type.
3120
-     *
3121
-     * @since 1.0.0
3122
-     * @param string $instance['layout'] Widget layout type.
3123
-     */
3124
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3125
-    /**
3126
-     * Filter widget's "add_location_filter" value.
3127
-     *
3128
-     * @since 1.0.0
3129
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3130
-     */
3131
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3132
-    /**
3133
-     * Filter widget's listing width.
3134
-     *
3135
-     * @since 1.0.0
3136
-     * @param string $instance['listing_width'] Listing width.
3137
-     */
3138
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3139
-    /**
3140
-     * Filter widget's "list_sort" type.
3141
-     *
3142
-     * @since 1.0.0
3143
-     * @param string $instance['list_sort'] Listing sort by type.
3144
-     */
3145
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3146
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3147
-
3148
-    // set post type to current viewing post type
3149
-    if ($use_viewing_post_type) {
3150
-        $current_post_type = geodir_get_current_posttype();
3151
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3152
-            $post_type = $current_post_type;
3153
-            $category = array(); // old post type category will not work for current changed post type
3154
-        }
3155
-    }
3156
-    // replace widget title dynamically
3157
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3158
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3159
-
3160
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3161
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3162
-
3163
-    if (isset($instance['character_count'])) {
3164
-        /**
3165
-         * Filter the widget's excerpt character count.
3166
-         *
3167
-         * @since 1.0.0
3168
-         * @param int $instance['character_count'] Excerpt character count.
3169
-         */
3170
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3171
-    } else {
3172
-        $character_count = '';
3173
-    }
3174
-
3175
-    if (empty($title) || $title == 'All') {
3176
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3177
-    }
3178
-
3179
-    $location_url = array();
3180
-    $city = get_query_var('gd_city');
3181
-    if (!empty($city)) {
3182
-        $country = get_query_var('gd_country');
3183
-        $region = get_query_var('gd_region');
3184
-
3185
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3186
-
3187
-        if ($geodir_show_location_url == 'all') {
3188
-            if ($country != '') {
3189
-                $location_url[] = $country;
3190
-            }
3191
-
3192
-            if ($region != '') {
3193
-                $location_url[] = $region;
3194
-            }
3195
-        } else if ($geodir_show_location_url == 'country_city') {
3196
-            if ($country != '') {
3197
-                $location_url[] = $country;
3198
-            }
3199
-        } else if ($geodir_show_location_url == 'region_city') {
3200
-            if ($region != '') {
3201
-                $location_url[] = $region;
3202
-            }
3203
-        }
3204
-
3205
-        $location_url[] = $city;
3206
-    }
3207
-
3208
-    $location_url = implode('/', $location_url);
3209
-    $skip_location = false;
3210
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3211
-        $skip_location = true;
3212
-        $gd_session->un_set('gd_multi_location');
3213
-    }
3214
-
3215
-    if (get_option('permalink_structure')) {
3216
-        $viewall_url = get_post_type_archive_link($post_type);
3217
-    } else {
3218
-        $viewall_url = get_post_type_archive_link($post_type);
3219
-    }
3220
-
3221
-    if (!empty($category) && $category[0] != '0') {
3222
-        global $geodir_add_location_url;
3223
-
3224
-        $geodir_add_location_url = '0';
3225
-
3226
-        if ($add_location_filter != '0') {
3227
-            $geodir_add_location_url = '1';
3228
-        }
3229
-
3230
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3231
-
3232
-        $geodir_add_location_url = NULL;
3233
-    }
3234
-    if ($skip_location) {
3235
-        $gd_session->set('gd_multi_location', 1);
3236
-    }
3237
-
3238
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3239
-
3240
-    $query_args = array(
3241
-        'posts_per_page' => $post_number,
3242
-        'is_geodir_loop' => true,
3243
-        'gd_location' => $add_location_filter ? true : false,
3244
-        'post_type' => $post_type,
3245
-        'order_by' => $list_sort
3246
-    );
3247
-
3248
-    if ($character_count) {
3249
-        $query_args['excerpt_length'] = $character_count;
3250
-    }
3251
-
3252
-    if (!empty($instance['show_featured_only'])) {
3253
-        $query_args['show_featured_only'] = 1;
3254
-    }
3255
-
3256
-    if (!empty($instance['show_special_only'])) {
3257
-        $query_args['show_special_only'] = 1;
3258
-    }
3259
-
3260
-    if (!empty($instance['with_pics_only'])) {
3261
-        $query_args['with_pics_only'] = 0;
3262
-        $query_args['featured_image_only'] = 1;
3263
-    }
3264
-
3265
-    if (!empty($instance['with_videos_only'])) {
3266
-        $query_args['with_videos_only'] = 1;
3267
-    }
3268
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3269
-
3270
-    if (!empty($category) && $category[0] != '0') {
3271
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3272
-
3273
-        ######### WPML #########
3274
-        if (function_exists('icl_object_id')) {
3275
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3276
-        }
3277
-        ######### WPML #########
3278
-
3279
-        $tax_query = array(
3280
-            'taxonomy' => $category_taxonomy[0],
3281
-            'field' => 'id',
3282
-            'terms' => $category
3283
-        );
3284
-
3285
-        $query_args['tax_query'] = array($tax_query);
3286
-    }
3287
-
3288
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3289
-
3290
-    $widget_listings = geodir_get_widget_listings($query_args);
3291
-
3292
-    if (!empty($widget_listings) || $with_no_results) {
3293
-        ?>
3090
+	// prints the widget
3091
+	extract($args, EXTR_SKIP);
3092
+
3093
+	echo $before_widget;
3094
+
3095
+	/** This filter is documented in geodirectory_widgets.php */
3096
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3097
+	/**
3098
+	 * Filter the widget post type.
3099
+	 *
3100
+	 * @since 1.0.0
3101
+	 * @param string $instance['post_type'] Post type of listing.
3102
+	 */
3103
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3104
+	/**
3105
+	 * Filter the widget's term.
3106
+	 *
3107
+	 * @since 1.0.0
3108
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
3109
+	 */
3110
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3111
+	/**
3112
+	 * Filter the widget listings limit.
3113
+	 *
3114
+	 * @since 1.0.0
3115
+	 * @param string $instance['post_number'] Number of listings to display.
3116
+	 */
3117
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3118
+	/**
3119
+	 * Filter widget's "layout" type.
3120
+	 *
3121
+	 * @since 1.0.0
3122
+	 * @param string $instance['layout'] Widget layout type.
3123
+	 */
3124
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3125
+	/**
3126
+	 * Filter widget's "add_location_filter" value.
3127
+	 *
3128
+	 * @since 1.0.0
3129
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3130
+	 */
3131
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3132
+	/**
3133
+	 * Filter widget's listing width.
3134
+	 *
3135
+	 * @since 1.0.0
3136
+	 * @param string $instance['listing_width'] Listing width.
3137
+	 */
3138
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3139
+	/**
3140
+	 * Filter widget's "list_sort" type.
3141
+	 *
3142
+	 * @since 1.0.0
3143
+	 * @param string $instance['list_sort'] Listing sort by type.
3144
+	 */
3145
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3146
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3147
+
3148
+	// set post type to current viewing post type
3149
+	if ($use_viewing_post_type) {
3150
+		$current_post_type = geodir_get_current_posttype();
3151
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3152
+			$post_type = $current_post_type;
3153
+			$category = array(); // old post type category will not work for current changed post type
3154
+		}
3155
+	}
3156
+	// replace widget title dynamically
3157
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3158
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3159
+
3160
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3161
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3162
+
3163
+	if (isset($instance['character_count'])) {
3164
+		/**
3165
+		 * Filter the widget's excerpt character count.
3166
+		 *
3167
+		 * @since 1.0.0
3168
+		 * @param int $instance['character_count'] Excerpt character count.
3169
+		 */
3170
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3171
+	} else {
3172
+		$character_count = '';
3173
+	}
3174
+
3175
+	if (empty($title) || $title == 'All') {
3176
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3177
+	}
3178
+
3179
+	$location_url = array();
3180
+	$city = get_query_var('gd_city');
3181
+	if (!empty($city)) {
3182
+		$country = get_query_var('gd_country');
3183
+		$region = get_query_var('gd_region');
3184
+
3185
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3186
+
3187
+		if ($geodir_show_location_url == 'all') {
3188
+			if ($country != '') {
3189
+				$location_url[] = $country;
3190
+			}
3191
+
3192
+			if ($region != '') {
3193
+				$location_url[] = $region;
3194
+			}
3195
+		} else if ($geodir_show_location_url == 'country_city') {
3196
+			if ($country != '') {
3197
+				$location_url[] = $country;
3198
+			}
3199
+		} else if ($geodir_show_location_url == 'region_city') {
3200
+			if ($region != '') {
3201
+				$location_url[] = $region;
3202
+			}
3203
+		}
3204
+
3205
+		$location_url[] = $city;
3206
+	}
3207
+
3208
+	$location_url = implode('/', $location_url);
3209
+	$skip_location = false;
3210
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3211
+		$skip_location = true;
3212
+		$gd_session->un_set('gd_multi_location');
3213
+	}
3214
+
3215
+	if (get_option('permalink_structure')) {
3216
+		$viewall_url = get_post_type_archive_link($post_type);
3217
+	} else {
3218
+		$viewall_url = get_post_type_archive_link($post_type);
3219
+	}
3220
+
3221
+	if (!empty($category) && $category[0] != '0') {
3222
+		global $geodir_add_location_url;
3223
+
3224
+		$geodir_add_location_url = '0';
3225
+
3226
+		if ($add_location_filter != '0') {
3227
+			$geodir_add_location_url = '1';
3228
+		}
3229
+
3230
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3231
+
3232
+		$geodir_add_location_url = NULL;
3233
+	}
3234
+	if ($skip_location) {
3235
+		$gd_session->set('gd_multi_location', 1);
3236
+	}
3237
+
3238
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3239
+
3240
+	$query_args = array(
3241
+		'posts_per_page' => $post_number,
3242
+		'is_geodir_loop' => true,
3243
+		'gd_location' => $add_location_filter ? true : false,
3244
+		'post_type' => $post_type,
3245
+		'order_by' => $list_sort
3246
+	);
3247
+
3248
+	if ($character_count) {
3249
+		$query_args['excerpt_length'] = $character_count;
3250
+	}
3251
+
3252
+	if (!empty($instance['show_featured_only'])) {
3253
+		$query_args['show_featured_only'] = 1;
3254
+	}
3255
+
3256
+	if (!empty($instance['show_special_only'])) {
3257
+		$query_args['show_special_only'] = 1;
3258
+	}
3259
+
3260
+	if (!empty($instance['with_pics_only'])) {
3261
+		$query_args['with_pics_only'] = 0;
3262
+		$query_args['featured_image_only'] = 1;
3263
+	}
3264
+
3265
+	if (!empty($instance['with_videos_only'])) {
3266
+		$query_args['with_videos_only'] = 1;
3267
+	}
3268
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3269
+
3270
+	if (!empty($category) && $category[0] != '0') {
3271
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3272
+
3273
+		######### WPML #########
3274
+		if (function_exists('icl_object_id')) {
3275
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3276
+		}
3277
+		######### WPML #########
3278
+
3279
+		$tax_query = array(
3280
+			'taxonomy' => $category_taxonomy[0],
3281
+			'field' => 'id',
3282
+			'terms' => $category
3283
+		);
3284
+
3285
+		$query_args['tax_query'] = array($tax_query);
3286
+	}
3287
+
3288
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3289
+
3290
+	$widget_listings = geodir_get_widget_listings($query_args);
3291
+
3292
+	if (!empty($widget_listings) || $with_no_results) {
3293
+		?>
3294 3294
         <div class="geodir_locations geodir_location_listing">
3295 3295
 
3296 3296
             <?php
3297
-            /**
3298
-             * Called before the div containing the title and view all link in popular post view widget.
3299
-             *
3300
-             * @since 1.0.0
3301
-             */
3302
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3297
+			/**
3298
+			 * Called before the div containing the title and view all link in popular post view widget.
3299
+			 *
3300
+			 * @since 1.0.0
3301
+			 */
3302
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3303 3303
             <div class="geodir_list_heading clearfix">
3304 3304
                 <?php echo $before_title . $title . $after_title; ?>
3305 3305
                 <a href="<?php echo $viewall_url; ?>"
3306 3306
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3307 3307
             </div>
3308 3308
             <?php
3309
-            /**
3310
-             * Called after the div containing the title and view all link in popular post view widget.
3311
-             *
3312
-             * @since 1.0.0
3313
-             */
3314
-            do_action('geodir_after_view_all_link_in_widget'); ?>
3309
+			/**
3310
+			 * Called after the div containing the title and view all link in popular post view widget.
3311
+			 *
3312
+			 * @since 1.0.0
3313
+			 */
3314
+			do_action('geodir_after_view_all_link_in_widget'); ?>
3315 3315
             <?php
3316
-            if (strstr($layout, 'gridview')) {
3317
-                $listing_view_exp = explode('_', $layout);
3318
-                $gridview_columns_widget = $layout;
3319
-                $layout = $listing_view_exp[0];
3320
-            } else {
3321
-                $gridview_columns_widget = '';
3322
-            }
3323
-
3324
-            /**
3325
-             * Filter the widget listing listview template path.
3326
-             *
3327
-             * @since 1.0.0
3328
-             */
3329
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3330
-            if (!isset($character_count)) {
3331
-                /**
3332
-                 * Filter the widget's excerpt character count.
3333
-                 *
3334
-                 * @since 1.0.0
3335
-                 * @param int $instance['character_count'] Excerpt character count.
3336
-                 */
3337
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3338
-            }
3339
-
3340
-            global $post, $map_jason, $map_canvas_arr;
3341
-
3342
-            $current_post = $post;
3343
-            $current_map_jason = $map_jason;
3344
-            $current_map_canvas_arr = $map_canvas_arr;
3345
-            $geodir_is_widget_listing = true;
3346
-
3347
-            /**
3348
-             * Includes related listing listview template.
3349
-             *
3350
-             * @since 1.0.0
3351
-             */
3352
-            include($template);
3353
-
3354
-            $geodir_is_widget_listing = false;
3355
-
3356
-            $GLOBALS['post'] = $current_post;
3357
-            if (!empty($current_post))
3358
-                setup_postdata($current_post);
3359
-            $map_jason = $current_map_jason;
3360
-            $map_canvas_arr = $current_map_canvas_arr;
3361
-            ?>
3316
+			if (strstr($layout, 'gridview')) {
3317
+				$listing_view_exp = explode('_', $layout);
3318
+				$gridview_columns_widget = $layout;
3319
+				$layout = $listing_view_exp[0];
3320
+			} else {
3321
+				$gridview_columns_widget = '';
3322
+			}
3323
+
3324
+			/**
3325
+			 * Filter the widget listing listview template path.
3326
+			 *
3327
+			 * @since 1.0.0
3328
+			 */
3329
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3330
+			if (!isset($character_count)) {
3331
+				/**
3332
+				 * Filter the widget's excerpt character count.
3333
+				 *
3334
+				 * @since 1.0.0
3335
+				 * @param int $instance['character_count'] Excerpt character count.
3336
+				 */
3337
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3338
+			}
3339
+
3340
+			global $post, $map_jason, $map_canvas_arr;
3341
+
3342
+			$current_post = $post;
3343
+			$current_map_jason = $map_jason;
3344
+			$current_map_canvas_arr = $map_canvas_arr;
3345
+			$geodir_is_widget_listing = true;
3346
+
3347
+			/**
3348
+			 * Includes related listing listview template.
3349
+			 *
3350
+			 * @since 1.0.0
3351
+			 */
3352
+			include($template);
3353
+
3354
+			$geodir_is_widget_listing = false;
3355
+
3356
+			$GLOBALS['post'] = $current_post;
3357
+			if (!empty($current_post))
3358
+				setup_postdata($current_post);
3359
+			$map_jason = $current_map_jason;
3360
+			$map_canvas_arr = $current_map_canvas_arr;
3361
+			?>
3362 3362
         </div>
3363 3363
     <?php
3364
-    }
3365
-    echo $after_widget;
3364
+	}
3365
+	echo $after_widget;
3366 3366
 
3367 3367
 }
3368 3368
 
@@ -3385,26 +3385,26 @@  discard block
 block discarded – undo
3385 3385
  */
3386 3386
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3387 3387
 {
3388
-    global $wpdb, $plugin_prefix;
3388
+	global $wpdb, $plugin_prefix;
3389 3389
 
3390
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3390
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3391 3391
 
3392
-    $sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
3392
+	$sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
3393 3393
 
3394
-    /**
3395
-     * Filter count review sql query.
3396
-     *
3397
-     * @since 1.5.1
3398
-     * @param string $sql Database sql query..
3399
-     * @param int $term_id The term ID.
3400
-     * @param int $taxonomy The taxonomy Id.
3401
-     * @param string $post_type The post type.
3402
-     */
3403
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3394
+	/**
3395
+	 * Filter count review sql query.
3396
+	 *
3397
+	 * @since 1.5.1
3398
+	 * @param string $sql Database sql query..
3399
+	 * @param int $term_id The term ID.
3400
+	 * @param int $taxonomy The taxonomy Id.
3401
+	 * @param string $post_type The post type.
3402
+	 */
3403
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3404 3404
 
3405
-    $count = $wpdb->get_var($sql);
3405
+	$count = $wpdb->get_var($sql);
3406 3406
 
3407
-    return $count;
3407
+	return $count;
3408 3408
 }
3409 3409
 
3410 3410
 /**
@@ -3420,91 +3420,91 @@  discard block
 block discarded – undo
3420 3420
  * @return array Term array data.
3421 3421
  */
3422 3422
 function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
3423
-    /**
3424
-     * Filter review count option data.
3425
-     *
3426
-     * @since 1.0.0
3427
-     * @since 1.6.1 Added $post_ID param.
3428
-     * @param bool $force_update Force update option value?. Default.false.
3429
-     * @param int $post_ID The post id to update if any.
3430
-     */
3431
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3432
-    if (!empty($option_data)) {
3433
-        return $option_data;
3434
-    }
3423
+	/**
3424
+	 * Filter review count option data.
3425
+	 *
3426
+	 * @since 1.0.0
3427
+	 * @since 1.6.1 Added $post_ID param.
3428
+	 * @param bool $force_update Force update option value?. Default.false.
3429
+	 * @param int $post_ID The post id to update if any.
3430
+	 */
3431
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3432
+	if (!empty($option_data)) {
3433
+		return $option_data;
3434
+	}
3435 3435
 
3436
-    $option_data = get_option('geodir_global_review_count');
3436
+	$option_data = get_option('geodir_global_review_count');
3437 3437
 
3438
-    if (!$option_data || $force_update) {
3439
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3440
-            global $gd_session;
3438
+	if (!$option_data || $force_update) {
3439
+		if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3440
+			global $gd_session;
3441 3441
                         
3442
-            $term_array = (array)$option_data;
3443
-            $post_type = get_post_type($post_ID);
3444
-            $taxonomy = $post_type . 'category';
3445
-            $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3446
-
3447
-            if (!empty($terms) && !is_wp_error($terms)) {
3448
-                foreach ($terms as $term_id) {
3449
-                    $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3450
-                    $children = get_term_children($term_id, $taxonomy);
3451
-                    $term_array[$term_id] = $count;
3452
-                }
3453
-            }
3442
+			$term_array = (array)$option_data;
3443
+			$post_type = get_post_type($post_ID);
3444
+			$taxonomy = $post_type . 'category';
3445
+			$terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3446
+
3447
+			if (!empty($terms) && !is_wp_error($terms)) {
3448
+				foreach ($terms as $term_id) {
3449
+					$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3450
+					$children = get_term_children($term_id, $taxonomy);
3451
+					$term_array[$term_id] = $count;
3452
+				}
3453
+			}
3454 3454
             
3455
-            $session_listing = $gd_session->get('listing');
3455
+			$session_listing = $gd_session->get('listing');
3456 3456
             
3457
-            $terms = array();
3458
-            if (isset($_POST['post_category'][$taxonomy])) {
3459
-                $terms = (array)$_POST['post_category'][$taxonomy];
3460
-            } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3461
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3462
-            }
3457
+			$terms = array();
3458
+			if (isset($_POST['post_category'][$taxonomy])) {
3459
+				$terms = (array)$_POST['post_category'][$taxonomy];
3460
+			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3461
+				$terms = (array)$session_listing['post_category'][$taxonomy];
3462
+			}
3463 3463
             
3464
-            if (!empty($terms)) {
3465
-                foreach ($terms as $term_id) {
3466
-                    if ($term_id > 0) {
3467
-                        $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3468
-                        $children = get_term_children($term_id, $taxonomy);
3469
-                        $term_array[$term_id] = $count;
3470
-                    }
3471
-                }
3472
-            }
3473
-        } else { // Update reviews count for all post categories.
3474
-            $term_array = array();
3475
-            $post_types = geodir_get_posttypes();
3476
-            foreach ($post_types as $post_type) {
3477
-
3478
-                $taxonomy = geodir_get_taxonomies($post_type);
3479
-                $taxonomy = $taxonomy[0];
3480
-
3481
-                $args = array(
3482
-                    'hide_empty' => false
3483
-                );
3484
-
3485
-                $terms = get_terms($taxonomy, $args);
3486
-
3487
-                foreach ($terms as $term) {
3488
-                    $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3489
-                    $children = get_term_children($term->term_id, $taxonomy);
3490
-                    /*if ( is_array( $children ) ) {
3464
+			if (!empty($terms)) {
3465
+				foreach ($terms as $term_id) {
3466
+					if ($term_id > 0) {
3467
+						$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3468
+						$children = get_term_children($term_id, $taxonomy);
3469
+						$term_array[$term_id] = $count;
3470
+					}
3471
+				}
3472
+			}
3473
+		} else { // Update reviews count for all post categories.
3474
+			$term_array = array();
3475
+			$post_types = geodir_get_posttypes();
3476
+			foreach ($post_types as $post_type) {
3477
+
3478
+				$taxonomy = geodir_get_taxonomies($post_type);
3479
+				$taxonomy = $taxonomy[0];
3480
+
3481
+				$args = array(
3482
+					'hide_empty' => false
3483
+				);
3484
+
3485
+				$terms = get_terms($taxonomy, $args);
3486
+
3487
+				foreach ($terms as $term) {
3488
+					$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3489
+					$children = get_term_children($term->term_id, $taxonomy);
3490
+					/*if ( is_array( $children ) ) {
3491 3491
                         foreach ( $children as $child_id ) {
3492 3492
                             $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3493 3493
                             $count = $count + $child_count;
3494 3494
                         }
3495 3495
                     }*/
3496
-                    $term_array[$term->term_id] = $count;
3497
-                }
3498
-            }
3499
-        }
3500
-
3501
-        update_option('geodir_global_review_count', $term_array);
3502
-        //clear cache
3503
-        wp_cache_delete('geodir_global_review_count');
3504
-        return $term_array;
3505
-    } else {
3506
-        return $option_data;
3507
-    }
3496
+					$term_array[$term->term_id] = $count;
3497
+				}
3498
+			}
3499
+		}
3500
+
3501
+		update_option('geodir_global_review_count', $term_array);
3502
+		//clear cache
3503
+		wp_cache_delete('geodir_global_review_count');
3504
+		return $term_array;
3505
+	} else {
3506
+		return $option_data;
3507
+	}
3508 3508
 }
3509 3509
 
3510 3510
 /**
@@ -3516,34 +3516,34 @@  discard block
 block discarded – undo
3516 3516
  * @return bool
3517 3517
  */
3518 3518
 function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
3519
-    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3520
-        return; // do not run if importing listings
3521
-    }
3519
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3520
+		return; // do not run if importing listings
3521
+	}
3522 3522
     
3523
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3524
-        return;
3525
-    }
3526
-
3527
-    $post_ID = 0;
3528
-    if (!empty($post)) {
3529
-        if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3530
-            return;
3531
-        }
3523
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3524
+		return;
3525
+	}
3526
+
3527
+	$post_ID = 0;
3528
+	if (!empty($post)) {
3529
+		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3530
+			return;
3531
+		}
3532 3532
         
3533
-        if ($new_status == 'auto-draft' && $old_status == 'new') {
3534
-            return;
3535
-        }
3533
+		if ($new_status == 'auto-draft' && $old_status == 'new') {
3534
+			return;
3535
+		}
3536 3536
         
3537
-        if (!empty($post->ID)) {
3538
-            $post_ID = $post->ID;
3539
-        }
3540
-    }
3537
+		if (!empty($post->ID)) {
3538
+			$post_ID = $post->ID;
3539
+		}
3540
+	}
3541 3541
 
3542
-    if ($new_status != $old_status) {
3543
-        geodir_count_reviews_by_terms(true, $post_ID);
3544
-    }
3542
+	if ($new_status != $old_status) {
3543
+		geodir_count_reviews_by_terms(true, $post_ID);
3544
+	}
3545 3545
 
3546
-    return true;
3546
+	return true;
3547 3547
 }
3548 3548
 
3549 3549
 /*-----------------------------------------------------------------------------------*/
@@ -3561,15 +3561,15 @@  discard block
 block discarded – undo
3561 3561
 function geodir_count_posts_by_term($data, $term)
3562 3562
 {
3563 3563
 
3564
-    if ($data) {
3565
-        if (isset($data[$term->term_id])) {
3566
-            return $data[$term->term_id];
3567
-        } else {
3568
-            return 0;
3569
-        }
3570
-    } else {
3571
-        return $term->count;
3572
-    }
3564
+	if ($data) {
3565
+		if (isset($data[$term->term_id])) {
3566
+			return $data[$term->term_id];
3567
+		} else {
3568
+			return 0;
3569
+		}
3570
+	} else {
3571
+		return $term->count;
3572
+	}
3573 3573
 }
3574 3574
 
3575 3575
 /**
@@ -3582,8 +3582,8 @@  discard block
 block discarded – undo
3582 3582
  */
3583 3583
 function geodir_sort_terms_by_count($terms)
3584 3584
 {
3585
-    usort($terms, "geodir_sort_by_count_obj");
3586
-    return $terms;
3585
+	usort($terms, "geodir_sort_by_count_obj");
3586
+	return $terms;
3587 3587
 }
3588 3588
 
3589 3589
 /**
@@ -3596,8 +3596,8 @@  discard block
 block discarded – undo
3596 3596
  */
3597 3597
 function geodir_sort_terms_by_review_count($terms)
3598 3598
 {
3599
-    usort($terms, "geodir_sort_by_review_count_obj");
3600
-    return $terms;
3599
+	usort($terms, "geodir_sort_by_review_count_obj");
3600
+	return $terms;
3601 3601
 }
3602 3602
 
3603 3603
 /**
@@ -3611,12 +3611,12 @@  discard block
 block discarded – undo
3611 3611
  */
3612 3612
 function geodir_sort_terms($terms, $sort = 'count')
3613 3613
 {
3614
-    if ($sort == 'count') {
3615
-        return geodir_sort_terms_by_count($terms);
3616
-    }
3617
-    if ($sort == 'review_count') {
3618
-        return geodir_sort_terms_by_review_count($terms);
3619
-    }
3614
+	if ($sort == 'count') {
3615
+		return geodir_sort_terms_by_count($terms);
3616
+	}
3617
+	if ($sort == 'review_count') {
3618
+		return geodir_sort_terms_by_review_count($terms);
3619
+	}
3620 3620
 }
3621 3621
 
3622 3622
 /*-----------------------------------------------------------------------------------*/
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
  */
3634 3634
 function geodir_sort_by_count($a, $b)
3635 3635
 {
3636
-    return $a['count'] < $b['count'];
3636
+	return $a['count'] < $b['count'];
3637 3637
 }
3638 3638
 
3639 3639
 /**
@@ -3647,7 +3647,7 @@  discard block
 block discarded – undo
3647 3647
  */
3648 3648
 function geodir_sort_by_count_obj($a, $b)
3649 3649
 {
3650
-    return $a->count < $b->count;
3650
+	return $a->count < $b->count;
3651 3651
 }
3652 3652
 
3653 3653
 /**
@@ -3661,7 +3661,7 @@  discard block
 block discarded – undo
3661 3661
  */
3662 3662
 function geodir_sort_by_review_count_obj($a, $b)
3663 3663
 {
3664
-    return $a->review_count < $b->review_count;
3664
+	return $a->review_count < $b->review_count;
3665 3665
 }
3666 3666
 
3667 3667
 /**
@@ -3671,43 +3671,43 @@  discard block
 block discarded – undo
3671 3671
  * @package GeoDirectory
3672 3672
  */
3673 3673
 function geodir_load_textdomain() {
3674
-    /**
3675
-     * Filter the plugin locale.
3676
-     *
3677
-     * @since 1.4.2
3678
-     * @package GeoDirectory
3679
-     */
3680
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3681
-
3682
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3683
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3674
+	/**
3675
+	 * Filter the plugin locale.
3676
+	 *
3677
+	 * @since 1.4.2
3678
+	 * @package GeoDirectory
3679
+	 */
3680
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3681
+
3682
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3683
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3684
+
3685
+	/**
3686
+	 * Define language constants.
3687
+	 *
3688
+	 * @since 1.0.0
3689
+	 */
3690
+	require_once(geodir_plugin_path() . '/language.php');
3691
+
3692
+	$language_file = geodir_plugin_path() . '/db-language.php';
3693
+
3694
+	// Load language string file if not created yet
3695
+	if (!file_exists($language_file)) {
3696
+		geodirectory_load_db_language();
3697
+	}
3684 3698
 
3685
-    /**
3686
-     * Define language constants.
3687
-     *
3688
-     * @since 1.0.0
3689
-     */
3690
-    require_once(geodir_plugin_path() . '/language.php');
3691
-
3692
-    $language_file = geodir_plugin_path() . '/db-language.php';
3693
-
3694
-    // Load language string file if not created yet
3695
-    if (!file_exists($language_file)) {
3696
-        geodirectory_load_db_language();
3697
-    }
3698
-
3699
-    if (file_exists($language_file)) {
3700
-        /**
3701
-         * Language strings from database.
3702
-         *
3703
-         * @since 1.4.2
3704
-         */
3705
-        try {
3706
-            require_once($language_file);
3707
-        } catch(Exception $e) {
3708
-            error_log('Language Error: ' . $e->getMessage());
3709
-        }
3710
-    }
3699
+	if (file_exists($language_file)) {
3700
+		/**
3701
+		 * Language strings from database.
3702
+		 *
3703
+		 * @since 1.4.2
3704
+		 */
3705
+		try {
3706
+			require_once($language_file);
3707
+		} catch(Exception $e) {
3708
+			error_log('Language Error: ' . $e->getMessage());
3709
+		}
3710
+	}
3711 3711
 }
3712 3712
 
3713 3713
 /**
@@ -3721,66 +3721,66 @@  discard block
 block discarded – undo
3721 3721
  * @return bool True if file created otherwise false
3722 3722
  */
3723 3723
 function geodirectory_load_db_language() {
3724
-    global $wp_filesystem;
3725
-    if( empty( $wp_filesystem ) ) {
3726
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3727
-        WP_Filesystem();
3728
-        global $wp_filesystem;
3729
-    }
3730
-
3731
-    $language_file = geodir_plugin_path() . '/db-language.php';
3724
+	global $wp_filesystem;
3725
+	if( empty( $wp_filesystem ) ) {
3726
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3727
+		WP_Filesystem();
3728
+		global $wp_filesystem;
3729
+	}
3732 3730
 
3733
-    if(is_file($language_file) && !is_writable($language_file))
3734
-        return false; // Not possible to create.
3731
+	$language_file = geodir_plugin_path() . '/db-language.php';
3732
+
3733
+	if(is_file($language_file) && !is_writable($language_file))
3734
+		return false; // Not possible to create.
3735
+
3736
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3737
+		return false; // Not possible to create.
3738
+
3739
+	$contents_strings = array();
3740
+
3741
+	/**
3742
+	 * Filter the language string from database to translate via po editor
3743
+	 *
3744
+	 * @since 1.4.2
3745
+	 *
3746
+	 * @param array $contents_strings Array of strings.
3747
+	 */
3748
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3749
+
3750
+	$contents_strings = array_unique($contents_strings);
3751
+
3752
+	$contents_head = array();
3753
+	$contents_head[] = "<?php";
3754
+	$contents_head[] = "/**";
3755
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3756
+	$contents_head[] = " *";
3757
+	$contents_head[] = " * @package GeoDirectory";
3758
+	$contents_head[] = " * @since 1.4.2";
3759
+	$contents_head[] = " */";
3760
+	$contents_head[] = "";
3761
+	$contents_head[] = "// Language keys";
3762
+
3763
+	$contents_foot = array();
3764
+	$contents_foot[] = "";
3765
+	$contents_foot[] = "";
3766
+
3767
+	$contents = implode(PHP_EOL, $contents_head);
3768
+
3769
+	if (!empty($contents_strings)) {
3770
+		foreach ( $contents_strings as $string ) {
3771
+			if (is_scalar($string) && $string != '') {
3772
+				$string = str_replace("'", "\'", $string);
3773
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3774
+			}
3775
+		}
3776
+	}
3735 3777
 
3736
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3737
-        return false; // Not possible to create.
3778
+	$contents .= implode(PHP_EOL, $contents_foot);
3738 3779
 
3739
-    $contents_strings = array();
3780
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3781
+		return false; // Failure; could not write file.
3740 3782
 
3741
-    /**
3742
-     * Filter the language string from database to translate via po editor
3743
-     *
3744
-     * @since 1.4.2
3745
-     *
3746
-     * @param array $contents_strings Array of strings.
3747
-     */
3748
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3749
-
3750
-    $contents_strings = array_unique($contents_strings);
3751
-
3752
-    $contents_head = array();
3753
-    $contents_head[] = "<?php";
3754
-    $contents_head[] = "/**";
3755
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3756
-    $contents_head[] = " *";
3757
-    $contents_head[] = " * @package GeoDirectory";
3758
-    $contents_head[] = " * @since 1.4.2";
3759
-    $contents_head[] = " */";
3760
-    $contents_head[] = "";
3761
-    $contents_head[] = "// Language keys";
3762
-
3763
-    $contents_foot = array();
3764
-    $contents_foot[] = "";
3765
-    $contents_foot[] = "";
3766
-
3767
-    $contents = implode(PHP_EOL, $contents_head);
3768
-
3769
-    if (!empty($contents_strings)) {
3770
-        foreach ( $contents_strings as $string ) {
3771
-            if (is_scalar($string) && $string != '') {
3772
-                $string = str_replace("'", "\'", $string);
3773
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3774
-            }
3775
-        }
3776
-    }
3777
-
3778
-    $contents .= implode(PHP_EOL, $contents_foot);
3779
-
3780
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3781
-        return false; // Failure; could not write file.
3782
-
3783
-    return true;
3783
+	return true;
3784 3784
 }
3785 3785
 
3786 3786
 /**
@@ -3796,31 +3796,31 @@  discard block
 block discarded – undo
3796 3796
  * @return array Translation texts.
3797 3797
  */
3798 3798
 function geodir_load_custom_field_translation($translation_texts = array()) {
3799
-    global $wpdb;
3799
+	global $wpdb;
3800 3800
 
3801
-    // Custom fields table
3802
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3803
-    $rows = $wpdb->get_results($sql);
3801
+	// Custom fields table
3802
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3803
+	$rows = $wpdb->get_results($sql);
3804 3804
 
3805
-    if (!empty($rows)) {
3806
-        foreach($rows as $row) {
3807
-            if (!empty($row->admin_title))
3808
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3805
+	if (!empty($rows)) {
3806
+		foreach($rows as $row) {
3807
+			if (!empty($row->admin_title))
3808
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3809 3809
 			
3810
-            if (!empty($row->admin_desc))
3811
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3810
+			if (!empty($row->admin_desc))
3811
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3812 3812
 
3813
-            if (!empty($row->site_title))
3814
-                $translation_texts[] = stripslashes_deep($row->site_title);
3813
+			if (!empty($row->site_title))
3814
+				$translation_texts[] = stripslashes_deep($row->site_title);
3815 3815
 
3816
-            if (!empty($row->clabels))
3817
-                $translation_texts[] = stripslashes_deep($row->clabels);
3816
+			if (!empty($row->clabels))
3817
+				$translation_texts[] = stripslashes_deep($row->clabels);
3818 3818
 
3819
-            if (!empty($row->required_msg))
3820
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3819
+			if (!empty($row->required_msg))
3820
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3821 3821
 			
3822 3822
 			if (!empty($row->default_value))
3823
-                $translation_texts[] = stripslashes_deep($row->default_value);
3823
+				$translation_texts[] = stripslashes_deep($row->default_value);
3824 3824
 			
3825 3825
 			if (!empty($row->option_values)) {
3826 3826
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3833,25 +3833,25 @@  discard block
 block discarded – undo
3833 3833
 					}
3834 3834
 				}
3835 3835
 			}
3836
-        }
3837
-    }
3836
+		}
3837
+	}
3838 3838
 	
3839
-    // Custom sorting fields table
3840
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3841
-    $rows = $wpdb->get_results($sql);
3842
-
3843
-    if (!empty($rows)) {
3844
-        foreach($rows as $row) {
3845
-            if (!empty($row->site_title))
3846
-                $translation_texts[] = stripslashes_deep($row->site_title);
3847
-
3848
-            if (!empty($row->asc_title))
3849
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3850
-
3851
-            if (!empty($row->desc_title))
3852
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3853
-        }
3854
-    }
3839
+	// Custom sorting fields table
3840
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3841
+	$rows = $wpdb->get_results($sql);
3842
+
3843
+	if (!empty($rows)) {
3844
+		foreach($rows as $row) {
3845
+			if (!empty($row->site_title))
3846
+				$translation_texts[] = stripslashes_deep($row->site_title);
3847
+
3848
+			if (!empty($row->asc_title))
3849
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3850
+
3851
+			if (!empty($row->desc_title))
3852
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3853
+		}
3854
+	}
3855 3855
 	
3856 3856
 	// Advance search filter fields table
3857 3857
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3872,9 +3872,9 @@  discard block
 block discarded – undo
3872 3872
 		}
3873 3873
 	}
3874 3874
 
3875
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3875
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3876 3876
 
3877
-    return $translation_texts;
3877
+	return $translation_texts;
3878 3878
 }
3879 3879
 
3880 3880
 /**
@@ -3886,71 +3886,71 @@  discard block
 block discarded – undo
3886 3886
  * @return array Array of mime types.
3887 3887
  */
3888 3888
 function geodir_allowed_mime_types() {
3889
-    /**
3890
-     * Filter the list of mime types and file extensions allowed for file upload.
3891
-     *
3892
-     * @since 1.4.7
3893
-     * @package GeoDirectory
3894
-     *
3895
-     * @param array $geodir_allowed_mime_types and file extensions.
3896
-     */
3897
-    return apply_filters( 'geodir_allowed_mime_types', array(
3898
-            'Image' => array( // Image formats.
3899
-                'jpg' => 'image/jpeg',
3900
-                'jpe' => 'image/jpeg',
3901
-                'jpeg' => 'image/jpeg',
3902
-                'gif' => 'image/gif',
3903
-                'png' => 'image/png',
3904
-                'bmp' => 'image/bmp',
3905
-                'ico' => 'image/x-icon',
3906
-            ),
3907
-            'Video' => array( // Video formats.
3908
-                'asf' => 'video/x-ms-asf',
3909
-                'avi' => 'video/avi',
3910
-                'flv' => 'video/x-flv',
3911
-                'mkv' => 'video/x-matroska',
3912
-                'mp4' => 'video/mp4',
3913
-                'mpeg' => 'video/mpeg',
3914
-                'mpg' => 'video/mpeg',
3915
-                'wmv' => 'video/x-ms-wmv',
3916
-                '3gp' => 'video/3gpp',
3917
-            ),
3918
-            'Audio' => array( // Audio formats.
3919
-                'ogg' => 'audio/ogg',
3920
-                'mp3' => 'audio/mpeg',
3921
-                'wav' => 'audio/wav',
3922
-                'wma' => 'audio/x-ms-wma',
3923
-            ),
3924
-            'Text' => array( // Text formats.
3925
-                'css' => 'text/css',
3926
-                'csv' => 'text/csv',
3927
-                'htm' => 'text/html',
3928
-                'html' => 'text/html',
3929
-                'txt' => 'text/plain',
3930
-                'rtx' => 'text/richtext',
3931
-                'vtt' => 'text/vtt',
3932
-            ),
3933
-            'Application' => array( // Application formats.
3934
-                'doc' => 'application/msword',
3935
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3936
-                'exe' => 'application/x-msdownload',
3937
-                'js' => 'application/javascript',
3938
-                'odt' => 'application/vnd.oasis.opendocument.text',
3939
-                'pdf' => 'application/pdf',
3940
-                'pot' => 'application/vnd.ms-powerpoint',
3941
-                'ppt' => 'application/vnd.ms-powerpoint',
3942
-                'pptx' => 'application/vnd.ms-powerpoint',
3943
-                'psd' => 'application/octet-stream',
3944
-                'rar' => 'application/rar',
3945
-                'rtf' => 'application/rtf',
3946
-                'swf' => 'application/x-shockwave-flash',
3947
-                'tar' => 'application/x-tar',
3948
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3949
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3950
-                'zip' => 'application/zip',
3951
-            )
3952
-        )
3953
-    );
3889
+	/**
3890
+	 * Filter the list of mime types and file extensions allowed for file upload.
3891
+	 *
3892
+	 * @since 1.4.7
3893
+	 * @package GeoDirectory
3894
+	 *
3895
+	 * @param array $geodir_allowed_mime_types and file extensions.
3896
+	 */
3897
+	return apply_filters( 'geodir_allowed_mime_types', array(
3898
+			'Image' => array( // Image formats.
3899
+				'jpg' => 'image/jpeg',
3900
+				'jpe' => 'image/jpeg',
3901
+				'jpeg' => 'image/jpeg',
3902
+				'gif' => 'image/gif',
3903
+				'png' => 'image/png',
3904
+				'bmp' => 'image/bmp',
3905
+				'ico' => 'image/x-icon',
3906
+			),
3907
+			'Video' => array( // Video formats.
3908
+				'asf' => 'video/x-ms-asf',
3909
+				'avi' => 'video/avi',
3910
+				'flv' => 'video/x-flv',
3911
+				'mkv' => 'video/x-matroska',
3912
+				'mp4' => 'video/mp4',
3913
+				'mpeg' => 'video/mpeg',
3914
+				'mpg' => 'video/mpeg',
3915
+				'wmv' => 'video/x-ms-wmv',
3916
+				'3gp' => 'video/3gpp',
3917
+			),
3918
+			'Audio' => array( // Audio formats.
3919
+				'ogg' => 'audio/ogg',
3920
+				'mp3' => 'audio/mpeg',
3921
+				'wav' => 'audio/wav',
3922
+				'wma' => 'audio/x-ms-wma',
3923
+			),
3924
+			'Text' => array( // Text formats.
3925
+				'css' => 'text/css',
3926
+				'csv' => 'text/csv',
3927
+				'htm' => 'text/html',
3928
+				'html' => 'text/html',
3929
+				'txt' => 'text/plain',
3930
+				'rtx' => 'text/richtext',
3931
+				'vtt' => 'text/vtt',
3932
+			),
3933
+			'Application' => array( // Application formats.
3934
+				'doc' => 'application/msword',
3935
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3936
+				'exe' => 'application/x-msdownload',
3937
+				'js' => 'application/javascript',
3938
+				'odt' => 'application/vnd.oasis.opendocument.text',
3939
+				'pdf' => 'application/pdf',
3940
+				'pot' => 'application/vnd.ms-powerpoint',
3941
+				'ppt' => 'application/vnd.ms-powerpoint',
3942
+				'pptx' => 'application/vnd.ms-powerpoint',
3943
+				'psd' => 'application/octet-stream',
3944
+				'rar' => 'application/rar',
3945
+				'rtf' => 'application/rtf',
3946
+				'swf' => 'application/x-shockwave-flash',
3947
+				'tar' => 'application/x-tar',
3948
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3949
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3950
+				'zip' => 'application/zip',
3951
+			)
3952
+		)
3953
+	);
3954 3954
 }
3955 3955
 
3956 3956
 /**
@@ -3962,21 +3962,21 @@  discard block
 block discarded – undo
3962 3962
  * @return string User display name.
3963 3963
  */
3964 3964
 function geodir_get_client_name($user_id) {
3965
-    $client_name = '';
3965
+	$client_name = '';
3966 3966
 
3967
-    $user_data = get_userdata($user_id);
3967
+	$user_data = get_userdata($user_id);
3968 3968
 
3969
-    if (!empty($user_data)) {
3970
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3971
-            $client_name = trim($user_data->display_name);
3972
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3973
-            $client_name = trim($user_data->user_nicename);
3974
-        } else {
3975
-            $client_name = trim($user_data->user_login);
3976
-        }
3977
-    }
3969
+	if (!empty($user_data)) {
3970
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3971
+			$client_name = trim($user_data->display_name);
3972
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3973
+			$client_name = trim($user_data->user_nicename);
3974
+		} else {
3975
+			$client_name = trim($user_data->user_login);
3976
+		}
3977
+	}
3978 3978
 
3979
-    return $client_name;
3979
+	return $client_name;
3980 3980
 }
3981 3981
 
3982 3982
 
@@ -3991,125 +3991,125 @@  discard block
 block discarded – undo
3991 3991
  */
3992 3992
 function geodir_wpseo_replacements($vars){
3993 3993
 
3994
-    global $wp;
3995
-    $title = '';
3996
-    // location variables
3997
-    $gd_post_type = geodir_get_current_posttype();
3998
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3999
-    /**
4000
-     * Filter the title variables location variables array
4001
-     *
4002
-     * @since 1.5.5
4003
-     * @package GeoDirectory
4004
-     * @param array $location_array The array of location variables.
4005
-     * @param array $vars The page title variables.
4006
-     */
4007
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4008
-    $location_titles = array();
4009
-    if(get_query_var( 'gd_country_full' )){
4010
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4011
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4012
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4013
-    }
4014
-    $location_single = '';
4015
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4016
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4017
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4018
-
4019
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4020
-
4021
-    if (function_exists('get_actual_location_name')) {
4022
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4023
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4024
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4025
-    }
4026
-
4027
-    if ($gd_city != '') {
4028
-        if ($gd_city_actual != '') {
4029
-            $gd_city = $gd_city_actual;
4030
-        } else {
4031
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4032
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4033
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4034
-        }
4035
-        $location_single = $gd_city;
4036
-
4037
-    } else if ($gd_region != '') {
4038
-        if ($gd_region_actual != '') {
4039
-            $gd_region = $gd_region_actual;
4040
-        } else {
4041
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4042
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4043
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4044
-        }
4045
-
4046
-        $location_single = $gd_region;
4047
-    } else if ($gd_country != '') {
4048
-        if ($gd_country_actual != '') {
4049
-            $gd_country = $gd_country_actual;
4050
-        } else {
4051
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4052
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4053
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4054
-        }
4055
-
4056
-        $location_single = $gd_country;
4057
-    }
4058
-
4059
-    if (!empty($location_array)) {
4060
-
4061
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4062
-        $location_array = array_reverse($location_array);
4063
-
4064
-        foreach ($location_array as $location_type => $location) {
4065
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4066
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4067
-
4068
-            $location_name = geodir_ucwords($gd_location_link_text);
4069
-            $location_name = __($location_name, 'geodirectory');
4070
-
4071
-            if ($actual_location_name) {
4072
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4073
-                $location_name = get_actual_location_name($location_type, $location, true);
4074
-            }
4075
-
4076
-            $location_titles[] = $location_name;
4077
-        }
4078
-        if (!empty($location_titles)) {
4079
-            $location_titles = array_unique($location_titles);
4080
-        }
4081
-    }
4082
-
4083
-
4084
-    if(!empty($location_titles)) {
4085
-        $vars['%%location%%'] = implode(", ", $location_titles);
4086
-    }
4087
-
4088
-
4089
-    if(!empty($location_titles)) {
4090
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4091
-    }
4092
-
4093
-
4094
-
4095
-    if($location_single) {
4096
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4097
-    }
4098
-
4099
-
4100
-    if($location_single) {
4101
-        $vars['%%location_single%%'] = $location_single;
4102
-    }
4103
-
4104
-    /**
4105
-     * Filter the title variables after standard ones have been filtered for wpseo.
4106
-     *
4107
-     * @since 1.5.7
4108
-     * @package GeoDirectory
4109
-     * @param string $vars The title with variables.
4110
-     * @param array $location_array The array of location variables.
4111
-     */
4112
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3994
+	global $wp;
3995
+	$title = '';
3996
+	// location variables
3997
+	$gd_post_type = geodir_get_current_posttype();
3998
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3999
+	/**
4000
+	 * Filter the title variables location variables array
4001
+	 *
4002
+	 * @since 1.5.5
4003
+	 * @package GeoDirectory
4004
+	 * @param array $location_array The array of location variables.
4005
+	 * @param array $vars The page title variables.
4006
+	 */
4007
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4008
+	$location_titles = array();
4009
+	if(get_query_var( 'gd_country_full' )){
4010
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4011
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4012
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4013
+	}
4014
+	$location_single = '';
4015
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4016
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4017
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4018
+
4019
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4020
+
4021
+	if (function_exists('get_actual_location_name')) {
4022
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4023
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4024
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4025
+	}
4026
+
4027
+	if ($gd_city != '') {
4028
+		if ($gd_city_actual != '') {
4029
+			$gd_city = $gd_city_actual;
4030
+		} else {
4031
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4032
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4033
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4034
+		}
4035
+		$location_single = $gd_city;
4036
+
4037
+	} else if ($gd_region != '') {
4038
+		if ($gd_region_actual != '') {
4039
+			$gd_region = $gd_region_actual;
4040
+		} else {
4041
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4042
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4043
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4044
+		}
4045
+
4046
+		$location_single = $gd_region;
4047
+	} else if ($gd_country != '') {
4048
+		if ($gd_country_actual != '') {
4049
+			$gd_country = $gd_country_actual;
4050
+		} else {
4051
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4052
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4053
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4054
+		}
4055
+
4056
+		$location_single = $gd_country;
4057
+	}
4058
+
4059
+	if (!empty($location_array)) {
4060
+
4061
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4062
+		$location_array = array_reverse($location_array);
4063
+
4064
+		foreach ($location_array as $location_type => $location) {
4065
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4066
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4067
+
4068
+			$location_name = geodir_ucwords($gd_location_link_text);
4069
+			$location_name = __($location_name, 'geodirectory');
4070
+
4071
+			if ($actual_location_name) {
4072
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4073
+				$location_name = get_actual_location_name($location_type, $location, true);
4074
+			}
4075
+
4076
+			$location_titles[] = $location_name;
4077
+		}
4078
+		if (!empty($location_titles)) {
4079
+			$location_titles = array_unique($location_titles);
4080
+		}
4081
+	}
4082
+
4083
+
4084
+	if(!empty($location_titles)) {
4085
+		$vars['%%location%%'] = implode(", ", $location_titles);
4086
+	}
4087
+
4088
+
4089
+	if(!empty($location_titles)) {
4090
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4091
+	}
4092
+
4093
+
4094
+
4095
+	if($location_single) {
4096
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4097
+	}
4098
+
4099
+
4100
+	if($location_single) {
4101
+		$vars['%%location_single%%'] = $location_single;
4102
+	}
4103
+
4104
+	/**
4105
+	 * Filter the title variables after standard ones have been filtered for wpseo.
4106
+	 *
4107
+	 * @since 1.5.7
4108
+	 * @package GeoDirectory
4109
+	 * @param string $vars The title with variables.
4110
+	 * @param array $location_array The array of location variables.
4111
+	 */
4112
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4113 4113
 }
4114 4114
 
4115 4115
 
@@ -4119,10 +4119,10 @@  discard block
 block discarded – undo
4119 4119
 function geodir_filter_title_variables($title, $gd_page, $sep=''){
4120 4120
 
4121 4121
 
4122
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4123
-    global $post;
4124
-    //print_r($post);
4125
-    /*
4122
+	if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4123
+	global $post;
4124
+	//print_r($post);
4125
+	/*
4126 4126
     %%date%%	                Replaced with the date of the post/page
4127 4127
     %%title%%	                Replaced with the title of the post/page
4128 4128
     %%sitename%%	            The site's name
@@ -4149,314 +4149,314 @@  discard block
 block discarded – undo
4149 4149
     %%pagenumber%%	            Replaced with the current page number
4150 4150
      */
4151 4151
 
4152
-    if ($sep == '') {
4153
-        /**
4154
-         * Filter the page title separator.
4155
-         *
4156
-         * @since 1.0.0
4157
-         * @package GeoDirectory
4158
-         * @param string $sep The separator, default: `|`.
4159
-         */
4160
-        $sep = apply_filters('geodir_page_title_separator', '|');
4161
-    }
4162
-
4163
-
4164
-    if(strpos($title,'%%title%%') !== false){
4165
-        $title = str_replace("%%title%%",$post->post_title,$title);
4166
-    }
4167
-
4168
-    if(strpos($title,'%%sitename%%') !== false){
4169
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4170
-    }
4171
-
4172
-    if(strpos($title,'%%sitedesc%%') !== false){
4173
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4174
-    }
4175
-
4176
-    if(strpos($title,'%%excerpt%%') !== false){
4177
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4178
-    }
4179
-
4180
-    if(strpos($title,'%%pt_single%%') !== false){
4181
-        $single_name = '';
4182
-        if($gd_page=='search' || $gd_page=='author'){
4183
-            $geodir_post_types = get_option('geodir_post_types');
4184
-            $spt = esc_attr($_REQUEST['stype']);
4185
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4186
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4187
-            }
4188
-        }elseif($gd_page=='add-listing'){
4189
-            $geodir_post_types = get_option('geodir_post_types');
4190
-            $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4191
-            if(!$spt && isset($_REQUEST['pid'])){
4192
-                $spt = get_post_type( $_REQUEST['pid'] );
4193
-            }
4194
-            if(!$spt){$spt='gd_place';}
4195
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4196
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4197
-            }
4198
-        }
4199
-        elseif($post->post_type){
4200
-            $geodir_post_types = get_option('geodir_post_types');
4201
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4202
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4203
-            }
4204
-
4205
-
4206
-        }
4207
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4208
-    }
4209
-
4210
-    if(strpos($title,'%%pt_plural%%') !== false){
4211
-        $plural_name = '';
4212
-        if($gd_page=='search' || $gd_page=='author'){
4213
-            $geodir_post_types = get_option('geodir_post_types');
4214
-            $spt = esc_attr($_REQUEST['stype']);
4215
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4216
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4217
-            }
4218
-        }elseif($gd_page=='add-listing'){
4219
-            $geodir_post_types = get_option('geodir_post_types');
4220
-            $spt = sanitize_text_field($_REQUEST['listing_type']);
4221
-            if(!$spt){$spt='gd_place';}
4222
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4223
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4224
-            }
4225
-        }
4226
-        elseif(isset($post->post_type) && $post->post_type){
4227
-            $geodir_post_types = get_option('geodir_post_types');
4228
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4229
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4230
-            }
4231
-
4232
-        }
4233
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4234
-    }
4235
-
4236
-
4237
-
4238
-    if(strpos($title,'%%category%%') !== false){
4239
-        $cat_name = '';
4240
-
4241
-        if($gd_page=='detail') {
4242
-            if ($post->default_category) {
4243
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4244
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4245
-            }
4246
-        }elseif($gd_page=='listing'){
4247
-            $queried_object = get_queried_object();
4248
-            if(isset($queried_object->name)){
4249
-                $cat_name = $queried_object->name;
4250
-            }
4251
-        }
4252
-        $title = str_replace("%%category%%",$cat_name,$title);
4253
-    }
4254
-
4255
-    if(strpos($title,'%%tag%%') !== false){
4256
-        $cat_name = '';
4257
-
4258
-        if($gd_page=='detail') {
4259
-            if ($post->default_category) {
4260
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4261
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4262
-            }
4263
-        }elseif($gd_page=='listing'){
4264
-            $queried_object = get_queried_object();
4265
-            if(isset($queried_object->name)){
4266
-                $cat_name = $queried_object->name;
4267
-            }
4268
-        }
4269
-        $title = str_replace("%%tag%%",$cat_name,$title);
4270
-    }
4271
-
4272
-
4273
-
4274
-    if(strpos($title,'%%id%%') !== false){
4275
-        $ID = (isset($post->ID)) ? $post->ID : '';
4276
-        $title = str_replace("%%id%%",$ID,$title);
4277
-    }
4278
-
4279
-    if(strpos($title,'%%sep%%') !== false){
4280
-        $title = str_replace("%%sep%%",$sep,$title);
4281
-    }
4282
-
4283
-
4284
-    global $wp;
4285
-    // location variables
4286
-    $gd_post_type = geodir_get_current_posttype();
4287
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4288
-    /**
4289
-     * Filter the title variables location variables array
4290
-     *
4291
-     * @since 1.5.5
4292
-     * @package GeoDirectory
4293
-     * @param array $location_array The array of location variables.
4294
-     * @param string $title The title with variables..
4295
-     * @param string $gd_page The page being filtered.
4296
-     * @param string $sep The separator, default: `|`.
4297
-     */
4298
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4299
-    $location_titles = array();
4300
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4301
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4302
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4303
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4304
-    }
4305
-    $location_single = '';
4306
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4307
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4308
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4309
-
4310
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4311
-
4312
-    if (function_exists('get_actual_location_name')) {
4313
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4314
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4315
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4316
-    }
4317
-
4318
-    if ($gd_city != '') {
4319
-        if ($gd_city_actual != '') {
4320
-            $gd_city = $gd_city_actual;
4321
-        } else {
4322
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4323
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4324
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4325
-        }
4326
-        $location_single = $gd_city;
4327
-
4328
-    } else if ($gd_region != '') {
4329
-        if ($gd_region_actual != '') {
4330
-            $gd_region = $gd_region_actual;
4331
-        } else {
4332
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4333
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4334
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4335
-        }
4336
-
4337
-        $location_single = $gd_region;
4338
-    } else if ($gd_country != '') {
4339
-        if ($gd_country_actual != '') {
4340
-            $gd_country = $gd_country_actual;
4341
-        } else {
4342
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4343
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4344
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4345
-        }
4346
-
4347
-        $location_single = $gd_country;
4348
-    }
4349
-
4350
-    if (!empty($location_array)) {
4351
-
4352
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4353
-        $location_array = array_reverse($location_array);
4354
-
4355
-        foreach ($location_array as $location_type => $location) {
4356
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4357
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4358
-
4359
-            $location_name = geodir_ucwords($gd_location_link_text);
4360
-            $location_name = __($location_name, 'geodirectory');
4361
-
4362
-            if ($actual_location_name) {
4363
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4364
-                $location_name = get_actual_location_name($location_type, $location, true);
4365
-            }
4366
-
4367
-            $location_titles[] = $location_name;
4368
-        }
4369
-        if (!empty($location_titles)) {
4370
-            $location_titles = array_unique($location_titles);
4371
-        }
4372
-    }
4373
-
4374
-
4375
-    if(strpos($title,'%%location%%') !== false){
4376
-        $location = '';
4377
-        if($location_titles) {
4378
-            $location = implode(", ", $location_titles);
4379
-        }
4380
-        $title = str_replace("%%location%%",$location,$title);
4381
-    }
4382
-
4383
-    if(strpos($title,'%%in_location%%') !== false){
4384
-        $location = '';
4385
-        if($location_titles) {
4386
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4387
-        }
4388
-        $title = str_replace("%%in_location%%",$location,$title);
4389
-    }
4390
-
4391
-    if(strpos($title,'%%in_location_single%%') !== false){
4392
-        if($location_single) {
4393
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4394
-        }
4395
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4396
-    }
4397
-
4398
-    if(strpos($title,'%%location_single%%') !== false){
4399
-        $title = str_replace("%%location_single%%",$location_single,$title);
4400
-    }
4401
-
4402
-
4403
-    if(strpos($title,'%%search_term%%') !== false){
4404
-        $search_term = '';
4405
-        if(isset($_REQUEST['s'])){
4406
-            $search_term = esc_attr($_REQUEST['s']);
4407
-        }
4408
-        $title = str_replace("%%search_term%%",$search_term,$title);
4409
-    }
4410
-
4411
-    if(strpos($title,'%%search_near%%') !== false){
4412
-        $search_term = '';
4413
-        if(isset($_REQUEST['snear'])){
4414
-            $search_term = esc_attr($_REQUEST['snear']);
4415
-        }
4416
-        $title = str_replace("%%search_near%%",$search_term,$title);
4417
-    }
4418
-
4419
-    if(strpos($title,'%%name%%') !== false){
4420
-        $author_name = get_the_author();
4421
-        if (!$author_name || $author_name === '') {
4422
-            $queried_object = get_queried_object();
4152
+	if ($sep == '') {
4153
+		/**
4154
+		 * Filter the page title separator.
4155
+		 *
4156
+		 * @since 1.0.0
4157
+		 * @package GeoDirectory
4158
+		 * @param string $sep The separator, default: `|`.
4159
+		 */
4160
+		$sep = apply_filters('geodir_page_title_separator', '|');
4161
+	}
4162
+
4163
+
4164
+	if(strpos($title,'%%title%%') !== false){
4165
+		$title = str_replace("%%title%%",$post->post_title,$title);
4166
+	}
4167
+
4168
+	if(strpos($title,'%%sitename%%') !== false){
4169
+		$title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4170
+	}
4171
+
4172
+	if(strpos($title,'%%sitedesc%%') !== false){
4173
+		$title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4174
+	}
4175
+
4176
+	if(strpos($title,'%%excerpt%%') !== false){
4177
+		$title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4178
+	}
4179
+
4180
+	if(strpos($title,'%%pt_single%%') !== false){
4181
+		$single_name = '';
4182
+		if($gd_page=='search' || $gd_page=='author'){
4183
+			$geodir_post_types = get_option('geodir_post_types');
4184
+			$spt = esc_attr($_REQUEST['stype']);
4185
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4186
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4187
+			}
4188
+		}elseif($gd_page=='add-listing'){
4189
+			$geodir_post_types = get_option('geodir_post_types');
4190
+			$spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4191
+			if(!$spt && isset($_REQUEST['pid'])){
4192
+				$spt = get_post_type( $_REQUEST['pid'] );
4193
+			}
4194
+			if(!$spt){$spt='gd_place';}
4195
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4196
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4197
+			}
4198
+		}
4199
+		elseif($post->post_type){
4200
+			$geodir_post_types = get_option('geodir_post_types');
4201
+			if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4202
+				$single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4203
+			}
4204
+
4205
+
4206
+		}
4207
+		$title = str_replace("%%pt_single%%",$single_name,$title);
4208
+	}
4209
+
4210
+	if(strpos($title,'%%pt_plural%%') !== false){
4211
+		$plural_name = '';
4212
+		if($gd_page=='search' || $gd_page=='author'){
4213
+			$geodir_post_types = get_option('geodir_post_types');
4214
+			$spt = esc_attr($_REQUEST['stype']);
4215
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4216
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4217
+			}
4218
+		}elseif($gd_page=='add-listing'){
4219
+			$geodir_post_types = get_option('geodir_post_types');
4220
+			$spt = sanitize_text_field($_REQUEST['listing_type']);
4221
+			if(!$spt){$spt='gd_place';}
4222
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4223
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4224
+			}
4225
+		}
4226
+		elseif(isset($post->post_type) && $post->post_type){
4227
+			$geodir_post_types = get_option('geodir_post_types');
4228
+			if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4229
+				$plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4230
+			}
4231
+
4232
+		}
4233
+		$title = str_replace("%%pt_plural%%",$plural_name,$title);
4234
+	}
4235
+
4236
+
4237
+
4238
+	if(strpos($title,'%%category%%') !== false){
4239
+		$cat_name = '';
4240
+
4241
+		if($gd_page=='detail') {
4242
+			if ($post->default_category) {
4243
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4244
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4245
+			}
4246
+		}elseif($gd_page=='listing'){
4247
+			$queried_object = get_queried_object();
4248
+			if(isset($queried_object->name)){
4249
+				$cat_name = $queried_object->name;
4250
+			}
4251
+		}
4252
+		$title = str_replace("%%category%%",$cat_name,$title);
4253
+	}
4254
+
4255
+	if(strpos($title,'%%tag%%') !== false){
4256
+		$cat_name = '';
4257
+
4258
+		if($gd_page=='detail') {
4259
+			if ($post->default_category) {
4260
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4261
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4262
+			}
4263
+		}elseif($gd_page=='listing'){
4264
+			$queried_object = get_queried_object();
4265
+			if(isset($queried_object->name)){
4266
+				$cat_name = $queried_object->name;
4267
+			}
4268
+		}
4269
+		$title = str_replace("%%tag%%",$cat_name,$title);
4270
+	}
4271
+
4272
+
4273
+
4274
+	if(strpos($title,'%%id%%') !== false){
4275
+		$ID = (isset($post->ID)) ? $post->ID : '';
4276
+		$title = str_replace("%%id%%",$ID,$title);
4277
+	}
4278
+
4279
+	if(strpos($title,'%%sep%%') !== false){
4280
+		$title = str_replace("%%sep%%",$sep,$title);
4281
+	}
4282
+
4283
+
4284
+	global $wp;
4285
+	// location variables
4286
+	$gd_post_type = geodir_get_current_posttype();
4287
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4288
+	/**
4289
+	 * Filter the title variables location variables array
4290
+	 *
4291
+	 * @since 1.5.5
4292
+	 * @package GeoDirectory
4293
+	 * @param array $location_array The array of location variables.
4294
+	 * @param string $title The title with variables..
4295
+	 * @param string $gd_page The page being filtered.
4296
+	 * @param string $sep The separator, default: `|`.
4297
+	 */
4298
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4299
+	$location_titles = array();
4300
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4301
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4302
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4303
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4304
+	}
4305
+	$location_single = '';
4306
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4307
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4308
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4309
+
4310
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4311
+
4312
+	if (function_exists('get_actual_location_name')) {
4313
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4314
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4315
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4316
+	}
4317
+
4318
+	if ($gd_city != '') {
4319
+		if ($gd_city_actual != '') {
4320
+			$gd_city = $gd_city_actual;
4321
+		} else {
4322
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4323
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4324
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4325
+		}
4326
+		$location_single = $gd_city;
4327
+
4328
+	} else if ($gd_region != '') {
4329
+		if ($gd_region_actual != '') {
4330
+			$gd_region = $gd_region_actual;
4331
+		} else {
4332
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4333
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4334
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4335
+		}
4336
+
4337
+		$location_single = $gd_region;
4338
+	} else if ($gd_country != '') {
4339
+		if ($gd_country_actual != '') {
4340
+			$gd_country = $gd_country_actual;
4341
+		} else {
4342
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4343
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4344
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4345
+		}
4346
+
4347
+		$location_single = $gd_country;
4348
+	}
4349
+
4350
+	if (!empty($location_array)) {
4351
+
4352
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4353
+		$location_array = array_reverse($location_array);
4354
+
4355
+		foreach ($location_array as $location_type => $location) {
4356
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4357
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4358
+
4359
+			$location_name = geodir_ucwords($gd_location_link_text);
4360
+			$location_name = __($location_name, 'geodirectory');
4361
+
4362
+			if ($actual_location_name) {
4363
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4364
+				$location_name = get_actual_location_name($location_type, $location, true);
4365
+			}
4366
+
4367
+			$location_titles[] = $location_name;
4368
+		}
4369
+		if (!empty($location_titles)) {
4370
+			$location_titles = array_unique($location_titles);
4371
+		}
4372
+	}
4373
+
4374
+
4375
+	if(strpos($title,'%%location%%') !== false){
4376
+		$location = '';
4377
+		if($location_titles) {
4378
+			$location = implode(", ", $location_titles);
4379
+		}
4380
+		$title = str_replace("%%location%%",$location,$title);
4381
+	}
4382
+
4383
+	if(strpos($title,'%%in_location%%') !== false){
4384
+		$location = '';
4385
+		if($location_titles) {
4386
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4387
+		}
4388
+		$title = str_replace("%%in_location%%",$location,$title);
4389
+	}
4390
+
4391
+	if(strpos($title,'%%in_location_single%%') !== false){
4392
+		if($location_single) {
4393
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4394
+		}
4395
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4396
+	}
4397
+
4398
+	if(strpos($title,'%%location_single%%') !== false){
4399
+		$title = str_replace("%%location_single%%",$location_single,$title);
4400
+	}
4401
+
4402
+
4403
+	if(strpos($title,'%%search_term%%') !== false){
4404
+		$search_term = '';
4405
+		if(isset($_REQUEST['s'])){
4406
+			$search_term = esc_attr($_REQUEST['s']);
4407
+		}
4408
+		$title = str_replace("%%search_term%%",$search_term,$title);
4409
+	}
4410
+
4411
+	if(strpos($title,'%%search_near%%') !== false){
4412
+		$search_term = '';
4413
+		if(isset($_REQUEST['snear'])){
4414
+			$search_term = esc_attr($_REQUEST['snear']);
4415
+		}
4416
+		$title = str_replace("%%search_near%%",$search_term,$title);
4417
+	}
4418
+
4419
+	if(strpos($title,'%%name%%') !== false){
4420
+		$author_name = get_the_author();
4421
+		if (!$author_name || $author_name === '') {
4422
+			$queried_object = get_queried_object();
4423 4423
             
4424
-            if (isset($queried_object->data->user_nicename)) {
4425
-                $author_name = $queried_object->data->user_nicename;
4426
-            }
4427
-        }
4428
-        $title = str_replace("%%name%%", $author_name, $title);
4429
-    }
4424
+			if (isset($queried_object->data->user_nicename)) {
4425
+				$author_name = $queried_object->data->user_nicename;
4426
+			}
4427
+		}
4428
+		$title = str_replace("%%name%%", $author_name, $title);
4429
+	}
4430 4430
     
4431
-    if (strpos($title, '%%page%%') !== false) {
4432
-        $page = geodir_title_meta_page($sep);
4433
-        $title = str_replace("%%page%%", $page, $title);
4434
-    }
4435
-    if (strpos($title, '%%pagenumber%%') !== false) {
4436
-        $pagenumber = geodir_title_meta_pagenumber();
4437
-        $title = str_replace("%%pagenumber%%", $pagenumber, $title);
4438
-    }
4439
-    if (strpos($title, '%%pagetotal%%') !== false) {
4440
-        $pagetotal = geodir_title_meta_pagetotal();
4441
-        $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4442
-    }
4443
-
4444
-    $title = wptexturize( $title );
4445
-    $title = convert_chars( $title );
4446
-    $title = esc_html( $title );
4447
-
4448
-    /**
4449
-     * Filter the title variables after standard ones have been filtered.
4450
-     *
4451
-     * @since 1.5.7
4452
-     * @package GeoDirectory
4453
-     * @param string $title The title with variables.
4454
-     * @param array $location_array The array of location variables.
4455
-     * @param string $gd_page The page being filtered.
4456
-     * @param string $sep The separator, default: `|`.
4457
-     */
4431
+	if (strpos($title, '%%page%%') !== false) {
4432
+		$page = geodir_title_meta_page($sep);
4433
+		$title = str_replace("%%page%%", $page, $title);
4434
+	}
4435
+	if (strpos($title, '%%pagenumber%%') !== false) {
4436
+		$pagenumber = geodir_title_meta_pagenumber();
4437
+		$title = str_replace("%%pagenumber%%", $pagenumber, $title);
4438
+	}
4439
+	if (strpos($title, '%%pagetotal%%') !== false) {
4440
+		$pagetotal = geodir_title_meta_pagetotal();
4441
+		$title = str_replace("%%pagetotal%%", $pagetotal, $title);
4442
+	}
4458 4443
 
4459
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4444
+	$title = wptexturize( $title );
4445
+	$title = convert_chars( $title );
4446
+	$title = esc_html( $title );
4447
+
4448
+	/**
4449
+	 * Filter the title variables after standard ones have been filtered.
4450
+	 *
4451
+	 * @since 1.5.7
4452
+	 * @package GeoDirectory
4453
+	 * @param string $title The title with variables.
4454
+	 * @param array $location_array The array of location variables.
4455
+	 * @param string $gd_page The page being filtered.
4456
+	 * @param string $sep The separator, default: `|`.
4457
+	 */
4458
+
4459
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4460 4460
 }
4461 4461
 
4462 4462
 /**
@@ -4469,65 +4469,65 @@  discard block
 block discarded – undo
4469 4469
  * @return array Translation texts.
4470 4470
  */
4471 4471
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4472
-    $gd_post_types = geodir_get_posttypes('array');
4473
-
4474
-    if (!empty($gd_post_types)) {
4475
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4476
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4477
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4478
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4479
-
4480
-            if (!empty($labels)) {
4481
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4482
-                    $translation_texts[] = $labels['name'];
4483
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4484
-                    $translation_texts[] = $labels['singular_name'];
4485
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4486
-                    $translation_texts[] = $labels['add_new'];
4487
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4488
-                    $translation_texts[] = $labels['add_new_item'];
4489
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4490
-                    $translation_texts[] = $labels['edit_item'];
4491
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4492
-                    $translation_texts[] = $labels['new_item'];
4493
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4494
-                    $translation_texts[] = $labels['view_item'];
4495
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4496
-                    $translation_texts[] = $labels['search_items'];
4497
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4498
-                    $translation_texts[] = $labels['not_found'];
4499
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4500
-                    $translation_texts[] = $labels['not_found_in_trash'];
4501
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4502
-                    $translation_texts[] = $labels['label_post_profile'];
4503
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4504
-                    $translation_texts[] = $labels['label_post_info'];
4505
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4506
-                    $translation_texts[] = $labels['label_post_images'];
4507
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4508
-                    $translation_texts[] = $labels['label_post_map'];
4509
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4510
-                    $translation_texts[] = $labels['label_reviews'];
4511
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4512
-                    $translation_texts[] = $labels['label_related_listing'];
4513
-            }
4514
-
4515
-            if ($description != '' && !in_array($description, $translation_texts)) {
4516
-                $translation_texts[] = normalize_whitespace($description);
4517
-            }
4518
-
4519
-            if (!empty($seo)) {
4520
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4521
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4522
-
4523
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4524
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4525
-            }
4526
-        }
4527
-    }
4528
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4529
-
4530
-    return $translation_texts;
4472
+	$gd_post_types = geodir_get_posttypes('array');
4473
+
4474
+	if (!empty($gd_post_types)) {
4475
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4476
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4477
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4478
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4479
+
4480
+			if (!empty($labels)) {
4481
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4482
+					$translation_texts[] = $labels['name'];
4483
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4484
+					$translation_texts[] = $labels['singular_name'];
4485
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4486
+					$translation_texts[] = $labels['add_new'];
4487
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4488
+					$translation_texts[] = $labels['add_new_item'];
4489
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4490
+					$translation_texts[] = $labels['edit_item'];
4491
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4492
+					$translation_texts[] = $labels['new_item'];
4493
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4494
+					$translation_texts[] = $labels['view_item'];
4495
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4496
+					$translation_texts[] = $labels['search_items'];
4497
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4498
+					$translation_texts[] = $labels['not_found'];
4499
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4500
+					$translation_texts[] = $labels['not_found_in_trash'];
4501
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4502
+					$translation_texts[] = $labels['label_post_profile'];
4503
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4504
+					$translation_texts[] = $labels['label_post_info'];
4505
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4506
+					$translation_texts[] = $labels['label_post_images'];
4507
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4508
+					$translation_texts[] = $labels['label_post_map'];
4509
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4510
+					$translation_texts[] = $labels['label_reviews'];
4511
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4512
+					$translation_texts[] = $labels['label_related_listing'];
4513
+			}
4514
+
4515
+			if ($description != '' && !in_array($description, $translation_texts)) {
4516
+				$translation_texts[] = normalize_whitespace($description);
4517
+			}
4518
+
4519
+			if (!empty($seo)) {
4520
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4521
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4522
+
4523
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4524
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4525
+			}
4526
+		}
4527
+	}
4528
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4529
+
4530
+	return $translation_texts;
4531 4531
 }
4532 4532
 
4533 4533
 /**
@@ -4540,27 +4540,27 @@  discard block
 block discarded – undo
4540 4540
  * @return array Location terms.
4541 4541
  */
4542 4542
 function geodir_remove_location_terms($location_terms = array()) {
4543
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4544
-
4545
-    if (!empty($location_terms) && $location_manager) {
4546
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4547
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4548
-
4549
-        if ($hide_region_part && $hide_country_part) {
4550
-            if (isset($location_terms['gd_country']))
4551
-                unset($location_terms['gd_country']);
4552
-            if (isset($location_terms['gd_region']))
4553
-                unset($location_terms['gd_region']);
4554
-        } else if ($hide_region_part && !$hide_country_part) {
4555
-            if (isset($location_terms['gd_region']))
4556
-                unset($location_terms['gd_region']);
4557
-        } else if (!$hide_region_part && $hide_country_part) {
4558
-            if (isset($location_terms['gd_country']))
4559
-                unset($location_terms['gd_country']);
4560
-        }
4561
-    }
4562
-
4563
-    return $location_terms;
4543
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4544
+
4545
+	if (!empty($location_terms) && $location_manager) {
4546
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4547
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4548
+
4549
+		if ($hide_region_part && $hide_country_part) {
4550
+			if (isset($location_terms['gd_country']))
4551
+				unset($location_terms['gd_country']);
4552
+			if (isset($location_terms['gd_region']))
4553
+				unset($location_terms['gd_region']);
4554
+		} else if ($hide_region_part && !$hide_country_part) {
4555
+			if (isset($location_terms['gd_region']))
4556
+				unset($location_terms['gd_region']);
4557
+		} else if (!$hide_region_part && $hide_country_part) {
4558
+			if (isset($location_terms['gd_country']))
4559
+				unset($location_terms['gd_country']);
4560
+		}
4561
+	}
4562
+
4563
+	return $location_terms;
4564 4564
 }
4565 4565
 
4566 4566
 /**
@@ -4574,47 +4574,47 @@  discard block
 block discarded – undo
4574 4574
  * @param bool $update Whether this is an existing listing being updated or not.
4575 4575
  */
4576 4576
 function geodir_on_wp_insert_post($post_ID, $post, $update) {
4577
-    if (!$update) {
4578
-        return;
4579
-    }
4577
+	if (!$update) {
4578
+		return;
4579
+	}
4580 4580
     
4581
-    $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4582
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4583
-    $inline_save = $action == 'inline-save' ? true : false;
4581
+	$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4582
+	$is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4583
+	$inline_save = $action == 'inline-save' ? true : false;
4584 4584
 
4585
-    if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4586
-        return;
4587
-    }
4585
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4586
+		return;
4587
+	}
4588 4588
     
4589
-    if ($action != '' && in_array($action, array('geodir_import_export'))) {
4590
-        return;
4591
-    }
4589
+	if ($action != '' && in_array($action, array('geodir_import_export'))) {
4590
+		return;
4591
+	}
4592 4592
 
4593
-    $user_id = (int)get_current_user_id();
4593
+	$user_id = (int)get_current_user_id();
4594 4594
         
4595
-    if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4596
-        $author_id = !empty($post->post_author) ? $post->post_author : 0;
4595
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4596
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
4597 4597
         
4598
-        if ($user_id == $author_id && !is_super_admin()) {
4599
-            $from_email = get_option('site_email');
4600
-            $from_name = get_site_emailName();
4601
-            $to_email = get_option('admin_email');
4602
-            $to_name = get_option('name');
4603
-            $message_type = 'listing_edited';
4598
+		if ($user_id == $author_id && !is_super_admin()) {
4599
+			$from_email = get_option('site_email');
4600
+			$from_name = get_site_emailName();
4601
+			$to_email = get_option('admin_email');
4602
+			$to_name = get_option('name');
4603
+			$message_type = 'listing_edited';
4604 4604
             
4605
-            $notify_edited = true;
4606
-            /**
4607
-             * Send notification when listing edited by author?
4608
-             *
4609
-             * @since 1.6.0
4610
-             * @param bool $notify_edited Notify on listing edited by author?
4611
-             * @param object $post The current post object.
4612
-             */
4613
-            $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4605
+			$notify_edited = true;
4606
+			/**
4607
+			 * Send notification when listing edited by author?
4608
+			 *
4609
+			 * @since 1.6.0
4610
+			 * @param bool $notify_edited Notify on listing edited by author?
4611
+			 * @param object $post The current post object.
4612
+			 */
4613
+			$notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4614 4614
             
4615
-            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4616
-        }
4617
-    }
4615
+			geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4616
+		}
4617
+	}
4618 4618
 }
4619 4619
 
4620 4620
 /**
@@ -4628,16 +4628,16 @@  discard block
 block discarded – undo
4628 4628
  * @return string|null The current page start & end numbering.
4629 4629
  */
4630 4630
 function geodir_title_meta_page($sep) {
4631
-    $replacement = null;
4631
+	$replacement = null;
4632 4632
 
4633
-    $max = geodir_title_meta_pagenumbering('max');
4634
-    $nr  = geodir_title_meta_pagenumbering('nr');
4633
+	$max = geodir_title_meta_pagenumbering('max');
4634
+	$nr  = geodir_title_meta_pagenumbering('nr');
4635 4635
 
4636
-    if ($max > 1 && $nr > 1) {
4637
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4638
-    }
4636
+	if ($max > 1 && $nr > 1) {
4637
+		$replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4638
+	}
4639 4639
 
4640
-    return $replacement;
4640
+	return $replacement;
4641 4641
 }
4642 4642
 
4643 4643
 /**
@@ -4649,14 +4649,14 @@  discard block
 block discarded – undo
4649 4649
  * @return string|null The current page number.
4650 4650
  */
4651 4651
 function geodir_title_meta_pagenumber() {
4652
-    $replacement = null;
4652
+	$replacement = null;
4653 4653
 
4654
-    $nr = geodir_title_meta_pagenumbering('nr');
4655
-    if (isset($nr) && $nr > 0) {
4656
-        $replacement = (string)$nr;
4657
-    }
4654
+	$nr = geodir_title_meta_pagenumbering('nr');
4655
+	if (isset($nr) && $nr > 0) {
4656
+		$replacement = (string)$nr;
4657
+	}
4658 4658
 
4659
-    return $replacement;
4659
+	return $replacement;
4660 4660
 }
4661 4661
 
4662 4662
 /**
@@ -4668,14 +4668,14 @@  discard block
 block discarded – undo
4668 4668
  * @return string|null The current page total.
4669 4669
  */
4670 4670
 function geodir_title_meta_pagetotal() {
4671
-    $replacement = null;
4671
+	$replacement = null;
4672 4672
 
4673
-    $max = geodir_title_meta_pagenumbering('max');
4674
-    if (isset($max) && $max > 0) {
4675
-        $replacement = (string)$max;
4676
-    }
4673
+	$max = geodir_title_meta_pagenumbering('max');
4674
+	if (isset($max) && $max > 0) {
4675
+		$replacement = (string)$max;
4676
+	}
4677 4677
 
4678
-    return $replacement;
4678
+	return $replacement;
4679 4679
 }
4680 4680
 
4681 4681
 /**
@@ -4692,44 +4692,44 @@  discard block
 block discarded – undo
4692 4692
  * @return int|null The current page numbering.
4693 4693
  */
4694 4694
 function geodir_title_meta_pagenumbering($request = 'nr') {
4695
-    global $wp_query, $post;
4696
-    $max_num_pages = null;
4697
-    $page_number   = null;
4698
-
4699
-    $max_num_pages = 1;
4700
-
4701
-    if (!is_singular()) {
4702
-        $page_number = get_query_var('paged');
4703
-        if ($page_number === 0 || $page_number === '') {
4704
-            $page_number = 1;
4705
-        }
4706
-
4707
-        if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4708
-            $max_num_pages = $wp_query->max_num_pages;
4709
-        }
4710
-    } else {
4711
-        $page_number = get_query_var('page');
4712
-        if ($page_number === 0 || $page_number === '') {
4713
-            $page_number = 1;
4714
-        }
4715
-
4716
-        if (isset($post->post_content)) {
4717
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4718
-        }
4719
-    }
4720
-
4721
-    $return = null;
4722
-
4723
-    switch ($request) {
4724
-        case 'nr':
4725
-            $return = $page_number;
4726
-            break;
4727
-        case 'max':
4728
-            $return = $max_num_pages;
4729
-            break;
4730
-    }
4731
-
4732
-    return $return;
4695
+	global $wp_query, $post;
4696
+	$max_num_pages = null;
4697
+	$page_number   = null;
4698
+
4699
+	$max_num_pages = 1;
4700
+
4701
+	if (!is_singular()) {
4702
+		$page_number = get_query_var('paged');
4703
+		if ($page_number === 0 || $page_number === '') {
4704
+			$page_number = 1;
4705
+		}
4706
+
4707
+		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4708
+			$max_num_pages = $wp_query->max_num_pages;
4709
+		}
4710
+	} else {
4711
+		$page_number = get_query_var('page');
4712
+		if ($page_number === 0 || $page_number === '') {
4713
+			$page_number = 1;
4714
+		}
4715
+
4716
+		if (isset($post->post_content)) {
4717
+			$max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4718
+		}
4719
+	}
4720
+
4721
+	$return = null;
4722
+
4723
+	switch ($request) {
4724
+		case 'nr':
4725
+			$return = $page_number;
4726
+			break;
4727
+		case 'max':
4728
+			$return = $max_num_pages;
4729
+			break;
4730
+	}
4731
+
4732
+	return $return;
4733 4733
 }
4734 4734
 
4735 4735
 /**
@@ -4741,15 +4741,15 @@  discard block
 block discarded – undo
4741 4741
  * @return array Terms.
4742 4742
  */
4743 4743
 function geodir_filter_empty_terms($terms) {
4744
-    if (empty($terms)) {
4745
-        return $terms;
4746
-    }
4747
-
4748
-    $return = array();
4749
-    foreach ($terms as $term) {
4750
-        if (isset($term->count) && $term->count > 0) {
4751
-            $return[] = $term;
4752
-        }
4753
-    }
4754
-    return $return;
4744
+	if (empty($terms)) {
4745
+		return $terms;
4746
+	}
4747
+
4748
+	$return = array();
4749
+	foreach ($terms as $term) {
4750
+		if (isset($term->count) && $term->count > 0) {
4751
+			$return[] = $term;
4752
+		}
4753
+	}
4754
+	return $return;
4755 4755
 }
4756 4756
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-widgets/geodirectory_cpt_categories_widget.php 1 patch
Indentation   +394 added lines, -394 removed lines patch added patch discarded remove patch
@@ -13,210 +13,210 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class geodir_cpt_categories_widget extends WP_Widget {
15 15
 
16
-    /**
17
-     * Register the cpt categories with WordPress.
18
-     *
19
-     * @since 1.5.4
20
-     */
21
-    public function __construct() {
22
-        $widget_ops = array('classname' => 'geodir_cpt_categories_widget', 'description' => __('A list of GeoDirectory CPT categories.', 'geodirectory'));
23
-        parent::__construct('geodir_cpt_categories_widget', __('GD > CPT Categories', 'geodirectory'), $widget_ops);
24
-    }
25
-
26
-    /**
27
-     * Front-end display content for cpt categories widget.
28
-     *
29
-     * @since 1.5.4
30
-     *
31
-     * @param array $args Widget arguments.
32
-     * @param array $instance Saved values from database.
33
-     */
34
-    public function widget($args, $instance) {
35
-        $params = array();
36
-        /**
37
-         * Filter the widget title.
38
-         *
39
-         * @since 1.5.4
40
-         *
41
-         * @param string $title The widget title. Default empty.
42
-         * @param array  $instance An array of the widget's settings.
43
-         * @param mixed  $id_base The widget ID.
44
-         */
45
-        $params['title'] = apply_filters('geodir_cpt_categories_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
46
-
47
-        /**
48
-         * Filter the widget setting post type.
49
-         *
50
-         * @since 1.5.4
51
-         *
52
-         * @param array $post_type The post types to display categories.
53
-         * @param array $instance An array of the widget's settings.
54
-         * @param mixed $id_base The widget ID.
55
-         */
56
-        $params['post_type'] = apply_filters('geodir_cpt_categories_widget_post_type', empty($instance['post_type']) ? array() : $instance['post_type'], $instance, $this->id_base);
57
-
58
-        /**
59
-         * Filter the widget setting to hide empty categories.
60
-         *
61
-         * @since 1.5.4
62
-         *
63
-         * @param bool  $hide_empty If true then empty category will be not displayed.
64
-         * @param array $instance An array of the widget's settings.
65
-         * @param mixed $id_base The widget ID.
66
-         */
67
-        $params['hide_empty'] = apply_filters('geodir_cpt_categories_widget_hide_empty', empty($instance['hide_empty']) ? 0 : 1, $instance, $this->id_base);
68
-
69
-        /**
70
-         * Filter the widget setting to show/hide category count.
71
-         *
72
-         * @since 1.5.4
73
-         *
74
-         * @param bool  $show_count If true then category count will be displayed.
75
-         * @param array $instance An array of the widget's settings.
76
-         * @param mixed $id_base The widget ID.
77
-         */
78
-        $params['show_count'] = apply_filters('geodir_cpt_categories_widget_show_count', empty($instance['show_count']) ? 0 : 1, $instance, $this->id_base);
79
-
80
-        /**
81
-         * Filter the widget setting to show/hide category icon.
82
-         *
83
-         * @since 1.5.4
84
-         *
85
-         * @param bool  $hide_icon If true then category icon will be not displayed.
86
-         * @param array $instance An array of the widget's settings.
87
-         * @param mixed $id_base The widget ID.
88
-         */
89
-        $params['hide_icon'] = apply_filters('geodir_cpt_categories_widget_hide_icon', empty($instance['hide_icon']) ? 0 : 1, $instance, $this->id_base);
90
-
91
-        /**
92
-         * Filter the widget setting to show CPT inline or not.
93
-         *
94
-         * @since 1.5.4
95
-         *
96
-         * @param bool  $cpt_left If true then CPT will be displayed inline.
97
-         * @param array $instance An array of the widget's settings.
98
-         * @param mixed $id_base The widget ID.
99
-         */
100
-        $params['cpt_left'] = apply_filters('geodir_cpt_categories_widget_cpt_left', empty($instance['cpt_left']) ? 0 : 1, $instance, $this->id_base);
101
-
102
-        /**
103
-         * Filter the widget categories sorting order settings.
104
-         *
105
-         * @since 1.5.4
106
-         *
107
-         * @param string $max_count Widget max no of sub-categories count. Default 'count'.
108
-         * @param array       $instance An array of the widget's settings.
109
-         * @param mixed       $id_base The widget ID.
110
-         */
111
-        $params['sort_by'] = apply_filters('geodir_cpt_categories_widget_sort_by', isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count', $instance, $this->id_base);
112
-
113
-        /**
114
-         * Filter the widget max no of sub-categories count.
115
-         *
116
-         * @since 1.5.4
117
-         *
118
-         * @param bool|string $max_count Widget max no of sub-categories count.
119
-         * @param array       $instance An array of the widget's settings.
120
-         * @param mixed       $id_base The widget ID.
121
-         */
122
-        $params['max_count'] = apply_filters('geodir_cpt_categories_widget_max_count', !isset($instance['max_count']) ? 'all' : strip_tags($instance['max_count']), $instance, $this->id_base);
123
-
124
-        /**
125
-         * Filter the widget max sub-categories depth.
126
-         *
127
-         * @since 1.5.4
128
-         *
129
-         * @param bool|string $max_level Widget max sub-categories depth.
130
-         * @param array       $instance An array of the widget's settings.
131
-         * @param mixed       $id_base The widget ID.
132
-         */
133
-        $params['max_level'] = apply_filters('geodir_cpt_categories_widget_max_level', !isset($instance['max_level']) ? 'all' : strip_tags($instance['max_level']), $instance, $this->id_base);
134
-
135
-        /**
136
-         * Filter the widget parameters.
137
-         *
138
-         * @since 1.5.4
139
-         *
140
-         * @param array $params The widget parameters.
141
-         * @param array $instance An array of the widget's settings.
142
-         * @param mixed $id_base The widget ID.
143
-         */
144
-        $params = apply_filters('geodir_cpt_categories_widget_params', $params, $instance, $this->id_base);
145
-
146
-        $output = geodir_cpt_categories_output($params);
147
-
148
-        echo $args['before_widget'];
149
-        if ( $params['title'] ) {
150
-            echo '<div class="geodir_list_heading clearfix">';
151
-            echo $args['before_title'] . $params['title'] . $args['after_title'];
152
-            echo '</div>';
153
-        }
154
-        echo '<div class="gd-cptcats-widget">';
155
-        echo $output;
156
-        echo '</div>';
157
-        echo $args['after_widget'];
158
-    }
159
-
160
-    /**
161
-     * Sanitize cpt categories widget values as they are saved.
162
-     *
163
-     * @since 1.5.4
164
-     *
165
-     * @param array $new_instance Values just sent to be saved.
166
-     * @param array $old_instance Previously saved values from database.
167
-     *
168
-     * @return array Updated safe values to be saved.
169
-     */
170
-    public function update($new_instance, $old_instance) {
171
-        $new_instance['post_type'] = is_array($new_instance['post_type']) && in_array('0', $new_instance['post_type']) ? array('0') : $new_instance['post_type'];
172
-        $instance = $old_instance;
173
-        $instance['title'] = strip_tags($new_instance['title']);
174
-        $instance['post_type'] = isset($new_instance['post_type']) ? $new_instance['post_type'] : array('0');
175
-        $instance['hide_empty'] = !empty($new_instance['hide_empty']) ? 1 : 0;
176
-        $instance['show_count'] = !empty($new_instance['show_count']) ? 1 : 0;
177
-        $instance['hide_icon'] = !empty($new_instance['hide_icon']) ? 1 : 0;
178
-        $instance['cpt_left'] = !empty($new_instance['cpt_left']) ? 1 : 0;
179
-        $instance['sort_by'] = isset($new_instance['sort_by']) && in_array($new_instance['sort_by'], array('az', 'count')) ? $new_instance['sort_by'] : 'count';
180
-        $instance['max_count'] = strip_tags($new_instance['max_count']);
181
-        $instance['max_level'] = strip_tags($new_instance['max_level']);
182
-
183
-        return $instance;
184
-    }
185
-
186
-    /**
187
-     * Back-end cpt categories settings form.
188
-     *
189
-     * @since 1.5.4
190
-     *
191
-     * @param array $instance Previously saved values from database.
192
-     */
193
-    public function form($instance) {
194
-        $instance = wp_parse_args( (array)$instance,
195
-            array(
196
-                'title' => '',
197
-                'post_type' => array(), // NULL for all
198
-                'hide_empty' => '',
199
-                'show_count' => '',
200
-                'hide_icon' => '',
201
-                'cpt_left' => '',
202
-                'sort_by' => 'count',
203
-                'max_count' => 'all',
204
-                'max_level' => '1'
205
-            )
206
-        );
207
-
208
-        $title = strip_tags($instance['title']);
209
-        $post_type = $instance['post_type'];
210
-        $hide_empty = !empty($instance['hide_empty']) ? true : false;
211
-        $show_count = !empty($instance['show_count']) ? true : false;
212
-        $hide_icon = !empty($instance['hide_icon']) ? true : false;
213
-        $cpt_left = !empty($instance['cpt_left']) ? true : false;
214
-        $max_count = strip_tags($instance['max_count']);
215
-        $max_level = strip_tags($instance['max_level']);
216
-        $sort_by = isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count';
217
-
218
-        $post_type_options = geodir_get_posttypes('options');
219
-        ?>
16
+	/**
17
+	 * Register the cpt categories with WordPress.
18
+	 *
19
+	 * @since 1.5.4
20
+	 */
21
+	public function __construct() {
22
+		$widget_ops = array('classname' => 'geodir_cpt_categories_widget', 'description' => __('A list of GeoDirectory CPT categories.', 'geodirectory'));
23
+		parent::__construct('geodir_cpt_categories_widget', __('GD > CPT Categories', 'geodirectory'), $widget_ops);
24
+	}
25
+
26
+	/**
27
+	 * Front-end display content for cpt categories widget.
28
+	 *
29
+	 * @since 1.5.4
30
+	 *
31
+	 * @param array $args Widget arguments.
32
+	 * @param array $instance Saved values from database.
33
+	 */
34
+	public function widget($args, $instance) {
35
+		$params = array();
36
+		/**
37
+		 * Filter the widget title.
38
+		 *
39
+		 * @since 1.5.4
40
+		 *
41
+		 * @param string $title The widget title. Default empty.
42
+		 * @param array  $instance An array of the widget's settings.
43
+		 * @param mixed  $id_base The widget ID.
44
+		 */
45
+		$params['title'] = apply_filters('geodir_cpt_categories_widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
46
+
47
+		/**
48
+		 * Filter the widget setting post type.
49
+		 *
50
+		 * @since 1.5.4
51
+		 *
52
+		 * @param array $post_type The post types to display categories.
53
+		 * @param array $instance An array of the widget's settings.
54
+		 * @param mixed $id_base The widget ID.
55
+		 */
56
+		$params['post_type'] = apply_filters('geodir_cpt_categories_widget_post_type', empty($instance['post_type']) ? array() : $instance['post_type'], $instance, $this->id_base);
57
+
58
+		/**
59
+		 * Filter the widget setting to hide empty categories.
60
+		 *
61
+		 * @since 1.5.4
62
+		 *
63
+		 * @param bool  $hide_empty If true then empty category will be not displayed.
64
+		 * @param array $instance An array of the widget's settings.
65
+		 * @param mixed $id_base The widget ID.
66
+		 */
67
+		$params['hide_empty'] = apply_filters('geodir_cpt_categories_widget_hide_empty', empty($instance['hide_empty']) ? 0 : 1, $instance, $this->id_base);
68
+
69
+		/**
70
+		 * Filter the widget setting to show/hide category count.
71
+		 *
72
+		 * @since 1.5.4
73
+		 *
74
+		 * @param bool  $show_count If true then category count will be displayed.
75
+		 * @param array $instance An array of the widget's settings.
76
+		 * @param mixed $id_base The widget ID.
77
+		 */
78
+		$params['show_count'] = apply_filters('geodir_cpt_categories_widget_show_count', empty($instance['show_count']) ? 0 : 1, $instance, $this->id_base);
79
+
80
+		/**
81
+		 * Filter the widget setting to show/hide category icon.
82
+		 *
83
+		 * @since 1.5.4
84
+		 *
85
+		 * @param bool  $hide_icon If true then category icon will be not displayed.
86
+		 * @param array $instance An array of the widget's settings.
87
+		 * @param mixed $id_base The widget ID.
88
+		 */
89
+		$params['hide_icon'] = apply_filters('geodir_cpt_categories_widget_hide_icon', empty($instance['hide_icon']) ? 0 : 1, $instance, $this->id_base);
90
+
91
+		/**
92
+		 * Filter the widget setting to show CPT inline or not.
93
+		 *
94
+		 * @since 1.5.4
95
+		 *
96
+		 * @param bool  $cpt_left If true then CPT will be displayed inline.
97
+		 * @param array $instance An array of the widget's settings.
98
+		 * @param mixed $id_base The widget ID.
99
+		 */
100
+		$params['cpt_left'] = apply_filters('geodir_cpt_categories_widget_cpt_left', empty($instance['cpt_left']) ? 0 : 1, $instance, $this->id_base);
101
+
102
+		/**
103
+		 * Filter the widget categories sorting order settings.
104
+		 *
105
+		 * @since 1.5.4
106
+		 *
107
+		 * @param string $max_count Widget max no of sub-categories count. Default 'count'.
108
+		 * @param array       $instance An array of the widget's settings.
109
+		 * @param mixed       $id_base The widget ID.
110
+		 */
111
+		$params['sort_by'] = apply_filters('geodir_cpt_categories_widget_sort_by', isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count', $instance, $this->id_base);
112
+
113
+		/**
114
+		 * Filter the widget max no of sub-categories count.
115
+		 *
116
+		 * @since 1.5.4
117
+		 *
118
+		 * @param bool|string $max_count Widget max no of sub-categories count.
119
+		 * @param array       $instance An array of the widget's settings.
120
+		 * @param mixed       $id_base The widget ID.
121
+		 */
122
+		$params['max_count'] = apply_filters('geodir_cpt_categories_widget_max_count', !isset($instance['max_count']) ? 'all' : strip_tags($instance['max_count']), $instance, $this->id_base);
123
+
124
+		/**
125
+		 * Filter the widget max sub-categories depth.
126
+		 *
127
+		 * @since 1.5.4
128
+		 *
129
+		 * @param bool|string $max_level Widget max sub-categories depth.
130
+		 * @param array       $instance An array of the widget's settings.
131
+		 * @param mixed       $id_base The widget ID.
132
+		 */
133
+		$params['max_level'] = apply_filters('geodir_cpt_categories_widget_max_level', !isset($instance['max_level']) ? 'all' : strip_tags($instance['max_level']), $instance, $this->id_base);
134
+
135
+		/**
136
+		 * Filter the widget parameters.
137
+		 *
138
+		 * @since 1.5.4
139
+		 *
140
+		 * @param array $params The widget parameters.
141
+		 * @param array $instance An array of the widget's settings.
142
+		 * @param mixed $id_base The widget ID.
143
+		 */
144
+		$params = apply_filters('geodir_cpt_categories_widget_params', $params, $instance, $this->id_base);
145
+
146
+		$output = geodir_cpt_categories_output($params);
147
+
148
+		echo $args['before_widget'];
149
+		if ( $params['title'] ) {
150
+			echo '<div class="geodir_list_heading clearfix">';
151
+			echo $args['before_title'] . $params['title'] . $args['after_title'];
152
+			echo '</div>';
153
+		}
154
+		echo '<div class="gd-cptcats-widget">';
155
+		echo $output;
156
+		echo '</div>';
157
+		echo $args['after_widget'];
158
+	}
159
+
160
+	/**
161
+	 * Sanitize cpt categories widget values as they are saved.
162
+	 *
163
+	 * @since 1.5.4
164
+	 *
165
+	 * @param array $new_instance Values just sent to be saved.
166
+	 * @param array $old_instance Previously saved values from database.
167
+	 *
168
+	 * @return array Updated safe values to be saved.
169
+	 */
170
+	public function update($new_instance, $old_instance) {
171
+		$new_instance['post_type'] = is_array($new_instance['post_type']) && in_array('0', $new_instance['post_type']) ? array('0') : $new_instance['post_type'];
172
+		$instance = $old_instance;
173
+		$instance['title'] = strip_tags($new_instance['title']);
174
+		$instance['post_type'] = isset($new_instance['post_type']) ? $new_instance['post_type'] : array('0');
175
+		$instance['hide_empty'] = !empty($new_instance['hide_empty']) ? 1 : 0;
176
+		$instance['show_count'] = !empty($new_instance['show_count']) ? 1 : 0;
177
+		$instance['hide_icon'] = !empty($new_instance['hide_icon']) ? 1 : 0;
178
+		$instance['cpt_left'] = !empty($new_instance['cpt_left']) ? 1 : 0;
179
+		$instance['sort_by'] = isset($new_instance['sort_by']) && in_array($new_instance['sort_by'], array('az', 'count')) ? $new_instance['sort_by'] : 'count';
180
+		$instance['max_count'] = strip_tags($new_instance['max_count']);
181
+		$instance['max_level'] = strip_tags($new_instance['max_level']);
182
+
183
+		return $instance;
184
+	}
185
+
186
+	/**
187
+	 * Back-end cpt categories settings form.
188
+	 *
189
+	 * @since 1.5.4
190
+	 *
191
+	 * @param array $instance Previously saved values from database.
192
+	 */
193
+	public function form($instance) {
194
+		$instance = wp_parse_args( (array)$instance,
195
+			array(
196
+				'title' => '',
197
+				'post_type' => array(), // NULL for all
198
+				'hide_empty' => '',
199
+				'show_count' => '',
200
+				'hide_icon' => '',
201
+				'cpt_left' => '',
202
+				'sort_by' => 'count',
203
+				'max_count' => 'all',
204
+				'max_level' => '1'
205
+			)
206
+		);
207
+
208
+		$title = strip_tags($instance['title']);
209
+		$post_type = $instance['post_type'];
210
+		$hide_empty = !empty($instance['hide_empty']) ? true : false;
211
+		$show_count = !empty($instance['show_count']) ? true : false;
212
+		$hide_icon = !empty($instance['hide_icon']) ? true : false;
213
+		$cpt_left = !empty($instance['cpt_left']) ? true : false;
214
+		$max_count = strip_tags($instance['max_count']);
215
+		$max_level = strip_tags($instance['max_level']);
216
+		$sort_by = isset($instance['sort_by']) && in_array($instance['sort_by'], array('az', 'count')) ? $instance['sort_by'] : 'count';
217
+
218
+		$post_type_options = geodir_get_posttypes('options');
219
+		?>
220 220
         <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
221 221
         <p>
222 222
             <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Select CPT:', 'geodirectory'); ?></label>
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
             </select>
262 262
         </p>
263 263
     <?php
264
-    }
264
+	}
265 265
 } // class geodir_cpt_categories_widget
266 266
 
267 267
 register_widget('geodir_cpt_categories_widget');
@@ -275,152 +275,152 @@  discard block
 block discarded – undo
275 275
  * @return string CPT categories content.
276 276
  */
277 277
 function geodir_cpt_categories_output($params) {
278
-    $args = wp_parse_args((array)$params,
279
-        array(
280
-            'title' => '',
281
-            'post_type' => array(), // NULL for all
282
-            'hide_empty' => '',
283
-            'show_count' => '',
284
-            'hide_icon' => '',
285
-            'cpt_left' => '',
286
-            'sort_by' => 'count',
287
-            'max_count' => 'all',
288
-            'max_level' => '1',
289
-        )
290
-    );
291
-
292
-    $sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count';
293
-
294
-    $gd_post_types = geodir_get_posttypes('array');
295
-
296
-    $post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type'];
297
-    $current_posttype = geodir_get_current_posttype();
298
-
299
-    $is_listing = false;
300
-    $is_category = false;
301
-    if (geodir_is_page('listing')) {
302
-        $current_posttype = geodir_get_current_posttype();
303
-
304
-        if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) {
305
-            $is_listing = true;
306
-
307
-            if (is_tax()) { // category page
308
-                $current_term_id = get_queried_object_id();
309
-                $current_taxonomy = get_query_var('taxonomy');
310
-                $current_posttype = geodir_get_current_posttype();
311
-
312
-                if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') {
313
-                    $is_category = true;
314
-                }
315
-            }
316
-        }
317
-    }
318
-
319
-    $parent_category = 0;
320
-    if ($is_listing) {
321
-        $post_type_arr = array($current_posttype);
322
-
323
-        if ($is_category) {
324
-            $parent_category = $current_term_id;
325
-        }
326
-    }
327
-
328
-    $post_types = array();
329
-    if (!empty($post_type_arr)) {
330
-        if (in_array('0', $post_type_arr)) {
331
-            $post_types = $gd_post_types;
332
-        } else {
333
-            foreach ($post_type_arr as $cpt) {
334
-                if (isset($gd_post_types[$cpt])) {
335
-                    $post_types[$cpt] = $gd_post_types[$cpt];
336
-                }
337
-            }
338
-        }
339
-    }
340
-
341
-    if (empty($post_type_arr)) {
342
-        $post_types = $gd_post_types;
343
-    }
344
-
345
-    $hide_empty = !empty($args['hide_empty']) ? true : false;
346
-    $max_count = strip_tags($args['max_count']);
347
-    $all_childs = $max_count == 'all' ? true : false;
348
-    $max_count = $max_count > 0 ? (int)$max_count : 0;
349
-    $max_level = strip_tags($args['max_level']);
350
-    $show_count = !empty($args['show_count']) ? true : false;
351
-    $hide_icon = !empty($args['hide_icon']) ? true : false;
352
-    $cpt_left = !empty($args['cpt_left']) ? true : false;
353
-
354
-    if(!$cpt_left){
355
-        $cpt_left = "gd-cpt-flat";
356
-    }else{
357
-        $cpt_left = '';
358
-    }
359
-
360
-    $orderby = 'count';
361
-    $order = 'DESC';
362
-    if ($sort_by == 'az') {
363
-        $orderby = 'name';
364
-        $order = 'ASC';
365
-    }
366
-
367
-    $output = '';
368
-    if (!empty($post_types)) {
369
-        foreach ($post_types as $cpt => $cpt_info) {
370
-            $cat_taxonomy = $cpt . 'category';
371
-            $categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category));
372
-            if ($hide_empty) {
373
-                $categories = geodir_filter_empty_terms($categories);
374
-            }
375
-            if ($sort_by == 'count') {
376
-                $categories = geodir_sort_terms($categories, 'count');
377
-            }
378
-
379
-            if (!empty($categories)) {
380
-                $term_icons = !$hide_icon ? geodir_get_term_icon() : array();
381
-                $row_class = '';
382
-
383
-                if ($is_listing) {
384
-                    $row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing';
385
-                }
386
-                $cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">';
387
-
388
-                if ($is_category) {
389
-                    $term_info = get_term($current_term_id, $cat_taxonomy);
390
-
391
-                    $term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : '';
392
-                    $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
393
-
394
-                    $count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : '';
395
-                    $cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>';
396
-                } else {
397
-                    $cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>';
398
-                }
399
-                foreach ($categories as $category) {
400
-                    $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : '';
401
-                    $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
402
-
403
-                    $term_link = get_term_link( $category, $category->taxonomy );
404
-                    /** Filter documented in geodirectory-functions/general_functions.php **/
405
-                    $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt );
406
-
407
-                    $cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent  '.$cpt_left.'">';
408
-                    $cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">';
409
-                    $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : '';
410
-                    $cpt_row .= '<h3 class="gd-cptcat-cat"><a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">'  .$term_icon_url . $category->name . $count . '</a></h3>';
411
-                    if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) {
412
-                        $cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons);
413
-                    }
414
-                    $cpt_row .= '</li>';
415
-                    $cpt_row .= '</ul>';
416
-                }
417
-                $cpt_row .= '</ul></div>';
418
-
419
-                $output .= $cpt_row;
420
-            }
421
-        }
422
-    }
423
-    return $output;
278
+	$args = wp_parse_args((array)$params,
279
+		array(
280
+			'title' => '',
281
+			'post_type' => array(), // NULL for all
282
+			'hide_empty' => '',
283
+			'show_count' => '',
284
+			'hide_icon' => '',
285
+			'cpt_left' => '',
286
+			'sort_by' => 'count',
287
+			'max_count' => 'all',
288
+			'max_level' => '1',
289
+		)
290
+	);
291
+
292
+	$sort_by = isset($args['sort_by']) && in_array($args['sort_by'], array('az', 'count')) ? $args['sort_by'] : 'count';
293
+
294
+	$gd_post_types = geodir_get_posttypes('array');
295
+
296
+	$post_type_arr = !is_array($args['post_type']) ? explode(',', $args['post_type']) : $args['post_type'];
297
+	$current_posttype = geodir_get_current_posttype();
298
+
299
+	$is_listing = false;
300
+	$is_category = false;
301
+	if (geodir_is_page('listing')) {
302
+		$current_posttype = geodir_get_current_posttype();
303
+
304
+		if ($current_posttype != '' && isset($gd_post_types[$current_posttype])) {
305
+			$is_listing = true;
306
+
307
+			if (is_tax()) { // category page
308
+				$current_term_id = get_queried_object_id();
309
+				$current_taxonomy = get_query_var('taxonomy');
310
+				$current_posttype = geodir_get_current_posttype();
311
+
312
+				if ($current_term_id && $current_posttype && get_query_var('taxonomy') == $current_posttype . 'category') {
313
+					$is_category = true;
314
+				}
315
+			}
316
+		}
317
+	}
318
+
319
+	$parent_category = 0;
320
+	if ($is_listing) {
321
+		$post_type_arr = array($current_posttype);
322
+
323
+		if ($is_category) {
324
+			$parent_category = $current_term_id;
325
+		}
326
+	}
327
+
328
+	$post_types = array();
329
+	if (!empty($post_type_arr)) {
330
+		if (in_array('0', $post_type_arr)) {
331
+			$post_types = $gd_post_types;
332
+		} else {
333
+			foreach ($post_type_arr as $cpt) {
334
+				if (isset($gd_post_types[$cpt])) {
335
+					$post_types[$cpt] = $gd_post_types[$cpt];
336
+				}
337
+			}
338
+		}
339
+	}
340
+
341
+	if (empty($post_type_arr)) {
342
+		$post_types = $gd_post_types;
343
+	}
344
+
345
+	$hide_empty = !empty($args['hide_empty']) ? true : false;
346
+	$max_count = strip_tags($args['max_count']);
347
+	$all_childs = $max_count == 'all' ? true : false;
348
+	$max_count = $max_count > 0 ? (int)$max_count : 0;
349
+	$max_level = strip_tags($args['max_level']);
350
+	$show_count = !empty($args['show_count']) ? true : false;
351
+	$hide_icon = !empty($args['hide_icon']) ? true : false;
352
+	$cpt_left = !empty($args['cpt_left']) ? true : false;
353
+
354
+	if(!$cpt_left){
355
+		$cpt_left = "gd-cpt-flat";
356
+	}else{
357
+		$cpt_left = '';
358
+	}
359
+
360
+	$orderby = 'count';
361
+	$order = 'DESC';
362
+	if ($sort_by == 'az') {
363
+		$orderby = 'name';
364
+		$order = 'ASC';
365
+	}
366
+
367
+	$output = '';
368
+	if (!empty($post_types)) {
369
+		foreach ($post_types as $cpt => $cpt_info) {
370
+			$cat_taxonomy = $cpt . 'category';
371
+			$categories = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_category));
372
+			if ($hide_empty) {
373
+				$categories = geodir_filter_empty_terms($categories);
374
+			}
375
+			if ($sort_by == 'count') {
376
+				$categories = geodir_sort_terms($categories, 'count');
377
+			}
378
+
379
+			if (!empty($categories)) {
380
+				$term_icons = !$hide_icon ? geodir_get_term_icon() : array();
381
+				$row_class = '';
382
+
383
+				if ($is_listing) {
384
+					$row_class = $is_category ? ' gd-cptcat-categ' : ' gd-cptcat-listing';
385
+				}
386
+				$cpt_row = '<div class="gd-cptcat-row gd-cptcat-' . $cpt . $row_class . ' '.$cpt_left.'">';
387
+
388
+				if ($is_category) {
389
+					$term_info = get_term($current_term_id, $cat_taxonomy);
390
+
391
+					$term_icon_url = !empty($term_icons) && isset($term_icons[$term_info->term_id]) ? $term_icons[$term_info->term_id] : '';
392
+					$term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($term_info->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
393
+
394
+					$count = $show_count ? ' <span class="gd-cptcat-count">(' . $term_info->count . ')</span>' : '';
395
+					$cpt_row .= '<h2 class="gd-cptcat-title">' . $term_icon_url . $term_info->name . $count . '</h2>';
396
+				} else {
397
+					$cpt_row .= '<h2 class="gd-cptcat-title">' . __($cpt_info['labels']['name'], 'geodirectory') . '</h2>';
398
+				}
399
+				foreach ($categories as $category) {
400
+					$term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : '';
401
+					$term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
402
+
403
+					$term_link = get_term_link( $category, $category->taxonomy );
404
+					/** Filter documented in geodirectory-functions/general_functions.php **/
405
+					$term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt );
406
+
407
+					$cpt_row .= '<ul class="gd-cptcat-ul gd-cptcat-parent  '.$cpt_left.'">';
408
+					$cpt_row .= '<li class="gd-cptcat-li gd-cptcat-li-main">';
409
+					$count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : '';
410
+					$cpt_row .= '<h3 class="gd-cptcat-cat"><a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">'  .$term_icon_url . $category->name . $count . '</a></h3>';
411
+					if (($all_childs || $max_count > 0) && ($max_level == 'all' || (int)$max_level > 0)) {
412
+						$cpt_row .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons);
413
+					}
414
+					$cpt_row .= '</li>';
415
+					$cpt_row .= '</ul>';
416
+				}
417
+				$cpt_row .= '</ul></div>';
418
+
419
+				$output .= $cpt_row;
420
+			}
421
+		}
422
+	}
423
+	return $output;
424 424
 }
425 425
 
426 426
 /**
@@ -440,48 +440,48 @@  discard block
 block discarded – undo
440 440
  * @return string Html content.
441 441
  */
442 442
 function geodir_cpt_categories_child_cats($parent_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth = 1) {
443
-    $cat_taxonomy = $cpt . 'category';
444
-
445
-    $orderby = 'count';
446
-    $order = 'DESC';
447
-    if ($sort_by == 'az') {
448
-        $orderby = 'name';
449
-        $order = 'ASC';
450
-    }
451
-
452
-    if ($max_level != 'all' && $depth > (int)$max_level ) {
453
-        return '';
454
-    }
455
-
456
-    $child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count));
457
-    if ($hide_empty) {
458
-        $child_cats = geodir_filter_empty_terms($child_cats);
459
-    }
460
-
461
-    if (empty($child_cats)) {
462
-        return '';
463
-    }
464
-
465
-    if ($sort_by == 'count') {
466
-        $child_cats = geodir_sort_terms($child_cats, 'count');
467
-    }
468
-
469
-    $content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">';
470
-    $depth++;
471
-    foreach ($child_cats as $category) {
472
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : '';
473
-        $term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
474
-        $term_link = get_term_link( $category, $category->taxonomy );
475
-        /** Filter documented in geodirectory-functions/general_functions.php **/
476
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt );
477
-        $count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : '';
478
-
479
-        $content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">';
480
-        $content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>';
481
-        $content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth);
482
-    }
483
-    $content .= '</li></ul>';
484
-
485
-    return $content;
443
+	$cat_taxonomy = $cpt . 'category';
444
+
445
+	$orderby = 'count';
446
+	$order = 'DESC';
447
+	if ($sort_by == 'az') {
448
+		$orderby = 'name';
449
+		$order = 'ASC';
450
+	}
451
+
452
+	if ($max_level != 'all' && $depth > (int)$max_level ) {
453
+		return '';
454
+	}
455
+
456
+	$child_cats = get_terms($cat_taxonomy, array('orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'parent' => $parent_id, 'number' => $max_count));
457
+	if ($hide_empty) {
458
+		$child_cats = geodir_filter_empty_terms($child_cats);
459
+	}
460
+
461
+	if (empty($child_cats)) {
462
+		return '';
463
+	}
464
+
465
+	if ($sort_by == 'count') {
466
+		$child_cats = geodir_sort_terms($child_cats, 'count');
467
+	}
468
+
469
+	$content = '<li class="gd-cptcat-li gd-cptcat-li-sub"><ul class="gd-cptcat-ul gd-cptcat-sub gd-cptcat-sub-' . $depth . '">';
470
+	$depth++;
471
+	foreach ($child_cats as $category) {
472
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$category->term_id]) ? $term_icons[$category->term_id] : '';
473
+		$term_icon_url = $term_icon_url != '' ? '<img alt="' . esc_attr($category->name) . ' icon" src="' . $term_icon_url . '" /> ' : '';
474
+		$term_link = get_term_link( $category, $category->taxonomy );
475
+		/** Filter documented in geodirectory-functions/general_functions.php **/
476
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $category->term_id, $cpt );
477
+		$count = $show_count ? ' <span class="gd-cptcat-count">(' . $category->count . ')</span>' : '';
478
+
479
+		$content .= '<li class="gd-cptcat-li gd-cptcat-li-sub">';
480
+		$content .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($category->name) . '">' . $term_icon_url . $category->name . $count . '</a></li>';
481
+		$content .= geodir_cpt_categories_child_cats($category->term_id, $cpt, $hide_empty, $show_count, $sort_by, $max_count, $max_level, $term_icons, $depth);
482
+	}
483
+	$content .= '</li></ul>';
484
+
485
+	return $content;
486 486
 }
487 487
 ?>
488 488
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-templates/listing-filter-form.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 
15 15
 $curr_post_type = geodir_get_current_posttype();
16 16
 if (function_exists('geodir_location_geo_home_link')) {
17
-    remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
17
+	remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
18 18
 }
19 19
 $search_url = trailingslashit(get_home_url());
20 20
 if (function_exists('geodir_location_geo_home_link')) {
21
-    add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
21
+	add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
22 22
 }
23 23
 ?>
24 24
 
@@ -37,104 +37,104 @@  discard block
 block discarded – undo
37 37
     <div class="geodir-loc-bar">
38 38
 
39 39
         <?php
40
-        /**
41
-         * Called inside the search form but before any of the fields.
42
-         *
43
-         * @since 1.0.0
44
-         */
45
-        do_action('geodir_before_search_form') ?>
40
+		/**
41
+		 * Called inside the search form but before any of the fields.
42
+		 *
43
+		 * @since 1.0.0
44
+		 */
45
+		do_action('geodir_before_search_form') ?>
46 46
 
47 47
         <div class="clearfix geodir-loc-bar-in">
48 48
             <div class="geodir-search">
49 49
 
50 50
                 <?php
51 51
 
52
-                $default_search_for_text = SEARCH_FOR_TEXT;
53
-                if (get_option('geodir_search_field_default_text'))
54
-                    $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
52
+				$default_search_for_text = SEARCH_FOR_TEXT;
53
+				if (get_option('geodir_search_field_default_text'))
54
+					$default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
55 55
 
56
-                $default_near_text = NEAR_TEXT;
57
-                if (get_option('geodir_near_field_default_text'))
58
-                    $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
56
+				$default_near_text = NEAR_TEXT;
57
+				if (get_option('geodir_near_field_default_text'))
58
+					$default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
59 59
 
60
-                $default_search_button_label = __('Search', 'geodirectory');
61
-                if (get_option('geodir_search_button_label'))
62
-                    $default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory');
60
+				$default_search_button_label = __('Search', 'geodirectory');
61
+				if (get_option('geodir_search_button_label'))
62
+					$default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory');
63 63
 
64
-                $post_types = apply_filters('geodir_search_form_post_types', geodir_get_posttypes('object'));
64
+				$post_types = apply_filters('geodir_search_form_post_types', geodir_get_posttypes('object'));
65 65
 
66
-                if (!empty($post_types) && count((array)$post_types) > 1):
67
-                    ?>
66
+				if (!empty($post_types) && count((array)$post_types) > 1):
67
+					?>
68 68
                     <select name="stype" class="search_by_post">
69 69
                         <?php foreach ($post_types as $post_type => $info):
70
-                            global $wpdb;
71
-                            $has_posts = '';
72
-                            $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
73
-                            if (!$has_posts) {
74
-                                continue;
75
-                            }
76
-                            ?>
70
+							global $wpdb;
71
+							$has_posts = '';
72
+							$has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
73
+							if (!$has_posts) {
74
+								continue;
75
+							}
76
+							?>
77 77
 
78 78
                             <option data-label="<?php echo get_post_type_archive_link($post_type);?>"
79 79
                                     value="<?php echo $post_type;?>" <?php if (isset($_REQUEST['stype'])) {
80
-                                if ($post_type == $_REQUEST['stype']) {
81
-                                    echo 'selected="selected"';
82
-                                }
83
-                            } elseif ($curr_post_type == $post_type) {
84
-                                echo 'selected="selected"';
85
-                            }?>><?php _e(ucfirst($info->labels->name), 'geodirectory');?></option>
80
+								if ($post_type == $_REQUEST['stype']) {
81
+									echo 'selected="selected"';
82
+								}
83
+							} elseif ($curr_post_type == $post_type) {
84
+								echo 'selected="selected"';
85
+							}?>><?php _e(ucfirst($info->labels->name), 'geodirectory');?></option>
86 86
 
87 87
                         <?php endforeach; ?>
88 88
                     </select>
89 89
                 <?php elseif (!empty($post_types)):
90
-                    echo '<input type="hidden" name="stype" value="' . key($post_types) . '"  />';
91
-                endif; ?>
90
+					echo '<input type="hidden" name="stype" value="' . key($post_types) . '"  />';
91
+				endif; ?>
92 92
 
93 93
                 <input class="search_text" name="s"
94 94
                        value="<?php if (isset($_REQUEST['s']) && trim($_REQUEST['s']) != '') {
95
-                           echo esc_attr(stripslashes_deep($_REQUEST['s']));
96
-                       } else {
97
-                           echo $default_search_for_text;
98
-                       } ?>" type="text"
95
+						   echo esc_attr(stripslashes_deep($_REQUEST['s']));
96
+					   } else {
97
+						   echo $default_search_for_text;
98
+					   } ?>" type="text"
99 99
                        onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql($default_search_for_text); ?>';}"
100 100
                        onfocus="if (this.value == '<?php echo esc_sql($default_search_for_text); ?>') {this.value = '';}"
101 101
                        onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);">
102 102
 
103 103
 
104 104
                 <?php
105
-                if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
106
-                    $near = esc_attr(stripslashes_deep($_REQUEST['snear']));
107
-                } else {
108
-                    $near = $default_near_text;
109
-                }
110
-                /**
111
-                 * Filter the "Near" text value for the search form.
112
-                 *
113
-                 * This is the input "value" attribute and can change depending on what the user searches and is not always the default value.
114
-                 *
115
-                 * @since 1.0.0
116
-                 * @param string $near The current near value.
117
-                 * @param string $default_near_text The default near value.
118
-                 */
119
-                $near = apply_filters('geodir_search_near_text', $near, $default_near_text);
120
-                /**
121
-                 * Filter the default "Near" text value for the search form.
122
-                 *
123
-                 * This is the default value if nothing has been searched.
124
-                 *
125
-                 * @since 1.0.0
126
-                 * @param string $near The current near value.
127
-                 * @param string $default_near_text The default near value.
128
-                 */
129
-                $default_near_text = apply_filters('geodir_search_default_near_text', $default_near_text, $near);
130
-                /**
131
-                 * Filter the class for the near search input.
132
-                 *
133
-                 * @since 1.0.0
134
-                 * @param string $class The class for the HTML near input, default is blank.
135
-                 */
136
-                $near_class = apply_filters('geodir_search_near_class', '');
137
-                ?>
105
+				if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
106
+					$near = esc_attr(stripslashes_deep($_REQUEST['snear']));
107
+				} else {
108
+					$near = $default_near_text;
109
+				}
110
+				/**
111
+				 * Filter the "Near" text value for the search form.
112
+				 *
113
+				 * This is the input "value" attribute and can change depending on what the user searches and is not always the default value.
114
+				 *
115
+				 * @since 1.0.0
116
+				 * @param string $near The current near value.
117
+				 * @param string $default_near_text The default near value.
118
+				 */
119
+				$near = apply_filters('geodir_search_near_text', $near, $default_near_text);
120
+				/**
121
+				 * Filter the default "Near" text value for the search form.
122
+				 *
123
+				 * This is the default value if nothing has been searched.
124
+				 *
125
+				 * @since 1.0.0
126
+				 * @param string $near The current near value.
127
+				 * @param string $default_near_text The default near value.
128
+				 */
129
+				$default_near_text = apply_filters('geodir_search_default_near_text', $default_near_text, $near);
130
+				/**
131
+				 * Filter the class for the near search input.
132
+				 *
133
+				 * @since 1.0.0
134
+				 * @param string $class The class for the HTML near input, default is blank.
135
+				 */
136
+				$near_class = apply_filters('geodir_search_near_class', '');
137
+				?>
138 138
 
139 139
                 <input name="snear" class="snear <?php echo $near_class; ?>" type="text" value="<?php echo $near; ?>"
140 140
                        onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql($near); ?>' != '' ? '<?php echo esc_sql($near); ?>' : '<?php echo $default_near_text; ?>');}"
@@ -142,42 +142,42 @@  discard block
 block discarded – undo
142 142
                        onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);"/>
143 143
 
144 144
                 <?php
145
-                /**
146
-                 * Called on the GD search form just before the search button.
147
-                 *
148
-                 * @since 1.0.0
149
-                 */
150
-                do_action('geodir_before_search_button');
151
-
152
-                /**
153
-                 * Filter the default search button text value for the search form.
154
-                 *
155
-                 * This text can be changed via an option in settings, this is a last resort.
156
-                 *
157
-                 * @since 1.5.5
158
-                 * @param string $default_search_button_label The current search button text.
159
-                 */
160
-                $default_search_button_label = apply_filters('geodir_search_default_search_button_text', $default_search_button_label);?>
145
+				/**
146
+				 * Called on the GD search form just before the search button.
147
+				 *
148
+				 * @since 1.0.0
149
+				 */
150
+				do_action('geodir_before_search_button');
151
+
152
+				/**
153
+				 * Filter the default search button text value for the search form.
154
+				 *
155
+				 * This text can be changed via an option in settings, this is a last resort.
156
+				 *
157
+				 * @since 1.5.5
158
+				 * @param string $default_search_button_label The current search button text.
159
+				 */
160
+				$default_search_button_label = apply_filters('geodir_search_default_search_button_text', $default_search_button_label);?>
161 161
 				<input type="button" value="<?php esc_attr_e($default_search_button_label); ?>" class="geodir_submit_search" />
162 162
                 <?php
163
-                /**
164
-                 * Called on the GD search form just after the search button.
165
-                 *
166
-                 * @since 1.0.0
167
-                 */
168
-                do_action('geodir_after_search_button'); ?>
163
+				/**
164
+				 * Called on the GD search form just after the search button.
165
+				 *
166
+				 * @since 1.0.0
167
+				 */
168
+				do_action('geodir_after_search_button'); ?>
169 169
             </div>
170 170
 
171 171
 
172 172
         </div>
173 173
 
174 174
         <?php
175
-        /**
176
-         * Called inside the search form but after all the input fields.
177
-         *
178
-         * @since 1.0.0
179
-         */
180
-        do_action('geodir_after_search_form') ?>
175
+		/**
176
+		 * Called inside the search form but after all the input fields.
177
+		 *
178
+		 * @since 1.0.0
179
+		 */
180
+		do_action('geodir_after_search_form') ?>
181 181
 
182 182
 
183 183
     </div>
Please login to merge, or discard this patch.