Test Failed
Push — master ( 85b89f...604a51 )
by Stiofan
08:02
created
geodirectory-functions/post_functions.php 1 patch
Indentation   +2223 added lines, -2223 removed lines patch added patch discarded remove patch
@@ -20,479 +20,479 @@  discard block
 block discarded – undo
20 20
 function geodir_set_postcat_structure($post_id, $taxonomy, $default_cat = '', $category_str = '')
21 21
 {
22 22
 
23
-    $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy);
24
-    if (!empty($post_cat_ids))
25
-        $post_cat_array = explode(",", trim($post_cat_ids, ","));
26
-
27
-    if (!isset($default_cat) || empty($default_cat)) {
28
-        $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
-        if(!is_int($default_cat)){
31
-            $category = get_term_by('name', $default_cat, $taxonomy);
32
-            if(isset($category->term_id)){
33
-                $default_cat =  $category->term_id;
34
-            }
35
-        }
23
+	$post_cat_ids = geodir_get_post_meta($post_id, $taxonomy);
24
+	if (!empty($post_cat_ids))
25
+		$post_cat_array = explode(",", trim($post_cat_ids, ","));
26
+
27
+	if (!isset($default_cat) || empty($default_cat)) {
28
+		$default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
+	}else{
30
+		if(!is_int($default_cat)){
31
+			$category = get_term_by('name', $default_cat, $taxonomy);
32
+			if(isset($category->term_id)){
33
+				$default_cat =  $category->term_id;
34
+			}
35
+		}
36 36
 
37
-    }
37
+	}
38 38
 
39 39
 
40
-    geodir_save_post_meta($post_id, 'default_category', $default_cat);
40
+	geodir_save_post_meta($post_id, 'default_category', $default_cat);
41 41
 
42
-    if (isset($category_str) && empty($category_str)) {
42
+	if (isset($category_str) && empty($category_str)) {
43 43
 
44
-        $post_cat_str = '';
45
-        $post_categories = array();
46
-        if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
47
-            $post_cat_str = implode(",y:#", $post_cat_array);
48
-            $post_cat_str .= ",y:";
49
-            $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
50
-        }
51
-        $post_categories[$taxonomy] = $post_cat_str;
52
-        $category_str = $post_categories;
53
-    }
44
+		$post_cat_str = '';
45
+		$post_categories = array();
46
+		if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
47
+			$post_cat_str = implode(",y:#", $post_cat_array);
48
+			$post_cat_str .= ",y:";
49
+			$post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
50
+		}
51
+		$post_categories[$taxonomy] = $post_cat_str;
52
+		$category_str = $post_categories;
53
+	}
54 54
 
55
-    $change_cat_str = $category_str[$taxonomy];
55
+	$change_cat_str = $category_str[$taxonomy];
56 56
 
57
-    $default_pos = strpos($change_cat_str, 'd:');
57
+	$default_pos = strpos($change_cat_str, 'd:');
58 58
 
59
-    if ($default_pos === false) {
59
+	if ($default_pos === false) {
60 60
 
61
-        $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str);
61
+		$change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str);
62 62
 
63
-    }
63
+	}
64 64
 
65
-    $category_str[$taxonomy] = $change_cat_str;
65
+	$category_str[$taxonomy] = $change_cat_str;
66 66
 
67
-    update_post_meta($post_id, 'post_categories', $category_str);
67
+	update_post_meta($post_id, 'post_categories', $category_str);
68 68
 
69 69
 }
70 70
 
71 71
 
72 72
 if (!function_exists('geodir_save_listing')) {
73
-    /**
74
-     * Saves listing in the database using given information.
75
-     *
76
-     * @since 1.0.0
77
-     * @since 1.5.4 New parameter $wp_error added.
78
-     * @package GeoDirectory
79
-     * @global object $wpdb WordPress Database object.
80
-     * @global object $post The current post object.
81
-     * @global object $current_user Current user object.
73
+	/**
74
+	 * Saves listing in the database using given information.
75
+	 *
76
+	 * @since 1.0.0
77
+	 * @since 1.5.4 New parameter $wp_error added.
78
+	 * @package GeoDirectory
79
+	 * @global object $wpdb WordPress Database object.
80
+	 * @global object $post The current post object.
81
+	 * @global object $current_user Current user object.
82 82
 	 * @global object $gd_session GeoDirectory Session object.
83
-     * @param array $request_info {
84
-     *    Array of request info arguments.
85
-     *
86
-     *    @type string $action                                  Ajax action name.
87
-     *    @type string $geodir_ajax                             Ajax type.
88
-     *    @type string $ajax_action                             Ajax action.
89
-     *    @type string $listing_type                            Listing type.
90
-     *    @type string $pid                                     Default Post ID.
91
-     *    @type string $preview                                 Todo Desc needed.
92
-     *    @type string $add_listing_page_id                     Add listing page ID.
93
-     *    @type string $post_title                              Listing title.
94
-     *    @type string $post_desc                               Listing Description.
95
-     *    @type string $post_tags                               Listing tags.
96
-     *    @type array  $cat_limit                               Category limit.
97
-     *    @type array  $post_category                           Category IDs.
98
-     *    @type array  $post_category_str                       Category string.
99
-     *    @type string $post_default_category                   Default category ID.
100
-     *    @type string $post_address                            Listing address.
101
-     *    @type string $geodir_location_add_listing_country_val Add listing country value.
102
-     *    @type string $post_country                            Listing country.
103
-     *    @type string $geodir_location_add_listing_region_val  Add listing region value.
104
-     *    @type string $post_region                             Listing region.
105
-     *    @type string $geodir_location_add_listing_city_val    Add listing city value.
106
-     *    @type string $post_city                               Listing city.
107
-     *    @type string $post_zip                                Listing zip.
108
-     *    @type string $post_latitude                           Listing latitude.
109
-     *    @type string $post_longitude                          Listing longitude.
110
-     *    @type string $post_mapview                            Listing mapview. Default "ROADMAP".
111
-     *    @type string $post_mapzoom                            Listing mapzoom Default "9".
112
-     *    @type string $geodir_timing                           Business timing info.
113
-     *    @type string $geodir_contact                          Contact number.
114
-     *    @type string $geodir_email                            Business contact email.
115
-     *    @type string $geodir_website                          Business website.
116
-     *    @type string $geodir_twitter                          Twitter link.
117
-     *    @type string $geodir_facebook                         Facebook link.
118
-     *    @type string $geodir_video                            Video link.
119
-     *    @type string $geodir_special_offers                   Speacial offers.
120
-     *    @type string $post_images                             Post image urls.
121
-     *    @type string $post_imagesimage_limit                  Post images limit.
122
-     *    @type string $post_imagestotImg                       Todo Desc needed.
123
-     *    @type string $geodir_accept_term_condition            Has accepted terms and conditions?.
124
-     *    @type string $geodir_spamblocker                      Todo Desc needed.
125
-     *    @type string $geodir_filled_by_spam_bot               Todo Desc needed.
126
-     *
127
-     * }
128
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
129
-     * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false.
130
-     * @return int|string|WP_Error Created post id or WP_Error on failure.
131
-     */
132
-    function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false)
133
-    {
134
-        global $wpdb, $current_user, $gd_session;
135
-
136
-        $last_post_id = '';
137
-
138
-        if ($gd_session->get('listing') && !$dummy) {
139
-            $request_info = array();
140
-            $request_session = $gd_session->get('listing');
141
-            $request_info = array_merge($_REQUEST, $request_session);
142
-        } else if (!$gd_session->get('listing') && !$dummy) {
143
-            global $post;
144
-            $request_info['pid'] = !empty($post->ID) ? $post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL);
145
-            $request_info['post_title'] = $request_info['post_title'];
146
-            $request_info['listing_type'] = $post->post_type;
147
-            $request_info['post_desc'] = $request_info['content'];
148
-        } else if (!$dummy) {
149
-            return false;
150
-        }
151
-
152
-        /**
153
-         * Filter the request_info array.
154
-         *
155
-         * You can use this filter to modify request_info array.
156
-         *
157
-         * @since 1.0.0
158
-         * @package GeoDirectory
159
-         * @param array $request_info See {@see geodir_save_listing()} for accepted args.
160
-         */
161
-        $request_info = apply_filters('geodir_action_get_request_info', $request_info);
162
-
163
-        // Check if we need to save post location as new location
164
-        $location_result = geodir_get_default_location();
165
-
166
-        if ($location_result->location_id > 0) {
167
-            if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
168
-                $request_info['post_location'] = array(
169
-                    'city' => $request_info['post_city'],
170
-                    'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '',
171
-                    'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '',
172
-                    'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '',
173
-                    'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : ''
174
-                );
175
-
176
-                $post_location_info = $request_info['post_location'];
177
-
178
-                if ($location_id = geodir_add_new_location($post_location_info)) {
179
-                    $post_location_id = $location_id;
180
-                }
181
-            } else {
182
-                $post_location_id = $location_result->location_id;
183
-            }
184
-        } else {
185
-            $post_location_id = $location_result->location_id;
186
-        }
187
-
188
-        if ($dummy) {
189
-            $post_status = 'publish';
190
-        } else {
191
-            $post_status = geodir_new_post_default_status();
192
-        }
193
-
194
-        if (isset($request_info['pid']) && $request_info['pid'] != '') {
195
-            $post_status = get_post_status($request_info['pid']);
196
-        }
197
-
198
-        /* fix change of slug on every title edit */
199
-        if (!isset($request_info['post_name'])) {
200
-            $request_info['post_name'] = $request_info['post_title'];
201
-
202
-            if (!empty($request_info['pid'])) {
203
-                $post_info = get_post($request_info['pid']);
204
-
205
-                if (!empty($post_info) && isset($post_info->post_name)) {
206
-                    $request_info['post_name'] = $post_info->post_name;
207
-                }
208
-            }
209
-        }
210
-
211
-        $post = array(
212
-            'post_content' => $request_info['post_desc'],
213
-            'post_status' => $post_status,
214
-            'post_title' => $request_info['post_title'],
215
-            'post_name' => $request_info['post_name'],
216
-            'post_type' => $request_info['listing_type']
217
-        );
218
-
219
-        /**
220
-         * Called before a listing is saved to the database.
221
-         *
222
-         * @since 1.0.0
223
-         * @param object $post The post object.
224
-         */
225
-        do_action_ref_array('geodir_before_save_listing', $post);
83
+	 * @param array $request_info {
84
+	 *    Array of request info arguments.
85
+	 *
86
+	 *    @type string $action                                  Ajax action name.
87
+	 *    @type string $geodir_ajax                             Ajax type.
88
+	 *    @type string $ajax_action                             Ajax action.
89
+	 *    @type string $listing_type                            Listing type.
90
+	 *    @type string $pid                                     Default Post ID.
91
+	 *    @type string $preview                                 Todo Desc needed.
92
+	 *    @type string $add_listing_page_id                     Add listing page ID.
93
+	 *    @type string $post_title                              Listing title.
94
+	 *    @type string $post_desc                               Listing Description.
95
+	 *    @type string $post_tags                               Listing tags.
96
+	 *    @type array  $cat_limit                               Category limit.
97
+	 *    @type array  $post_category                           Category IDs.
98
+	 *    @type array  $post_category_str                       Category string.
99
+	 *    @type string $post_default_category                   Default category ID.
100
+	 *    @type string $post_address                            Listing address.
101
+	 *    @type string $geodir_location_add_listing_country_val Add listing country value.
102
+	 *    @type string $post_country                            Listing country.
103
+	 *    @type string $geodir_location_add_listing_region_val  Add listing region value.
104
+	 *    @type string $post_region                             Listing region.
105
+	 *    @type string $geodir_location_add_listing_city_val    Add listing city value.
106
+	 *    @type string $post_city                               Listing city.
107
+	 *    @type string $post_zip                                Listing zip.
108
+	 *    @type string $post_latitude                           Listing latitude.
109
+	 *    @type string $post_longitude                          Listing longitude.
110
+	 *    @type string $post_mapview                            Listing mapview. Default "ROADMAP".
111
+	 *    @type string $post_mapzoom                            Listing mapzoom Default "9".
112
+	 *    @type string $geodir_timing                           Business timing info.
113
+	 *    @type string $geodir_contact                          Contact number.
114
+	 *    @type string $geodir_email                            Business contact email.
115
+	 *    @type string $geodir_website                          Business website.
116
+	 *    @type string $geodir_twitter                          Twitter link.
117
+	 *    @type string $geodir_facebook                         Facebook link.
118
+	 *    @type string $geodir_video                            Video link.
119
+	 *    @type string $geodir_special_offers                   Speacial offers.
120
+	 *    @type string $post_images                             Post image urls.
121
+	 *    @type string $post_imagesimage_limit                  Post images limit.
122
+	 *    @type string $post_imagestotImg                       Todo Desc needed.
123
+	 *    @type string $geodir_accept_term_condition            Has accepted terms and conditions?.
124
+	 *    @type string $geodir_spamblocker                      Todo Desc needed.
125
+	 *    @type string $geodir_filled_by_spam_bot               Todo Desc needed.
126
+	 *
127
+	 * }
128
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
129
+	 * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false.
130
+	 * @return int|string|WP_Error Created post id or WP_Error on failure.
131
+	 */
132
+	function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false)
133
+	{
134
+		global $wpdb, $current_user, $gd_session;
135
+
136
+		$last_post_id = '';
137
+
138
+		if ($gd_session->get('listing') && !$dummy) {
139
+			$request_info = array();
140
+			$request_session = $gd_session->get('listing');
141
+			$request_info = array_merge($_REQUEST, $request_session);
142
+		} else if (!$gd_session->get('listing') && !$dummy) {
143
+			global $post;
144
+			$request_info['pid'] = !empty($post->ID) ? $post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL);
145
+			$request_info['post_title'] = $request_info['post_title'];
146
+			$request_info['listing_type'] = $post->post_type;
147
+			$request_info['post_desc'] = $request_info['content'];
148
+		} else if (!$dummy) {
149
+			return false;
150
+		}
151
+
152
+		/**
153
+		 * Filter the request_info array.
154
+		 *
155
+		 * You can use this filter to modify request_info array.
156
+		 *
157
+		 * @since 1.0.0
158
+		 * @package GeoDirectory
159
+		 * @param array $request_info See {@see geodir_save_listing()} for accepted args.
160
+		 */
161
+		$request_info = apply_filters('geodir_action_get_request_info', $request_info);
162
+
163
+		// Check if we need to save post location as new location
164
+		$location_result = geodir_get_default_location();
165
+
166
+		if ($location_result->location_id > 0) {
167
+			if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
168
+				$request_info['post_location'] = array(
169
+					'city' => $request_info['post_city'],
170
+					'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '',
171
+					'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '',
172
+					'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '',
173
+					'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : ''
174
+				);
175
+
176
+				$post_location_info = $request_info['post_location'];
177
+
178
+				if ($location_id = geodir_add_new_location($post_location_info)) {
179
+					$post_location_id = $location_id;
180
+				}
181
+			} else {
182
+				$post_location_id = $location_result->location_id;
183
+			}
184
+		} else {
185
+			$post_location_id = $location_result->location_id;
186
+		}
226 187
 
227
-        $send_post_submit_mail = false;
188
+		if ($dummy) {
189
+			$post_status = 'publish';
190
+		} else {
191
+			$post_status = geodir_new_post_default_status();
192
+		}
228 193
 
229
-        // unhook this function so it doesn't loop infinitely
230
-        remove_action('save_post', 'geodir_post_information_save',10,2);
194
+		if (isset($request_info['pid']) && $request_info['pid'] != '') {
195
+			$post_status = get_post_status($request_info['pid']);
196
+		}
231 197
 
232
-        if (isset($request_info['pid']) && $request_info['pid'] != '') {
233
-            $post['ID'] = $request_info['pid'];
198
+		/* fix change of slug on every title edit */
199
+		if (!isset($request_info['post_name'])) {
200
+			$request_info['post_name'] = $request_info['post_title'];
234 201
 
235
-            $last_post_id = wp_update_post($post, $wp_error);
236
-        } else {
237
-            $last_post_id = wp_insert_post($post, $wp_error);
202
+			if (!empty($request_info['pid'])) {
203
+				$post_info = get_post($request_info['pid']);
238 204
 
239
-            if (!$dummy && $last_post_id) {
240
-                $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email)
241
-                //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
242
-            }
243
-        }
205
+				if (!empty($post_info) && isset($post_info->post_name)) {
206
+					$request_info['post_name'] = $post_info->post_name;
207
+				}
208
+			}
209
+		}
210
+
211
+		$post = array(
212
+			'post_content' => $request_info['post_desc'],
213
+			'post_status' => $post_status,
214
+			'post_title' => $request_info['post_title'],
215
+			'post_name' => $request_info['post_name'],
216
+			'post_type' => $request_info['listing_type']
217
+		);
218
+
219
+		/**
220
+		 * Called before a listing is saved to the database.
221
+		 *
222
+		 * @since 1.0.0
223
+		 * @param object $post The post object.
224
+		 */
225
+		do_action_ref_array('geodir_before_save_listing', $post);
226
+
227
+		$send_post_submit_mail = false;
228
+
229
+		// unhook this function so it doesn't loop infinitely
230
+		remove_action('save_post', 'geodir_post_information_save',10,2);
231
+
232
+		if (isset($request_info['pid']) && $request_info['pid'] != '') {
233
+			$post['ID'] = $request_info['pid'];
234
+
235
+			$last_post_id = wp_update_post($post, $wp_error);
236
+		} else {
237
+			$last_post_id = wp_insert_post($post, $wp_error);
238
+
239
+			if (!$dummy && $last_post_id) {
240
+				$send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email)
241
+				//geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
242
+			}
243
+		}
244 244
 
245
-        if ($wp_error && is_wp_error($last_post_id)) {
246
-            return $last_post_id; // Return WP_Error on save failure.
247
-        }
245
+		if ($wp_error && is_wp_error($last_post_id)) {
246
+			return $last_post_id; // Return WP_Error on save failure.
247
+		}
248 248
 
249
-        if (!$last_post_id) {
250
-            return false; // Save failure.
251
-        }
249
+		if (!$last_post_id) {
250
+			return false; // Save failure.
251
+		}
252 252
 
253
-        // re-hook this function
254
-        add_action('save_post', 'geodir_post_information_save',10,2);
253
+		// re-hook this function
254
+		add_action('save_post', 'geodir_post_information_save',10,2);
255 255
 
256
-        $post_tags = '';
257
-        if (!isset($request_info['post_tags'])) {
256
+		$post_tags = '';
257
+		if (!isset($request_info['post_tags'])) {
258 258
 
259
-            $post_type = $request_info['listing_type'];
260
-            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
259
+			$post_type = $request_info['listing_type'];
260
+			$post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
261 261
 
262
-        }
262
+		}
263 263
 
264
-        $gd_post_info = array(
265
-            "post_title" => $request_info['post_title'],
266
-            "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags,
267
-            "post_status" => $post_status,
268
-            "post_location_id" => $post_location_id,
269
-            "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '',
270
-            "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '',
271
-            "submit_time" => time(),
272
-            "submit_ip" => $_SERVER['REMOTE_ADDR'],
273
-        );
264
+		$gd_post_info = array(
265
+			"post_title" => $request_info['post_title'],
266
+			"post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags,
267
+			"post_status" => $post_status,
268
+			"post_location_id" => $post_location_id,
269
+			"claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '',
270
+			"businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '',
271
+			"submit_time" => time(),
272
+			"submit_ip" => $_SERVER['REMOTE_ADDR'],
273
+		);
274 274
 
275
-        $payment_info = array();
276
-        $package_info = array();
275
+		$payment_info = array();
276
+		$package_info = array();
277 277
 
278
-        $package_info = (array)geodir_post_package_info($package_info, $post);
278
+		$package_info = (array)geodir_post_package_info($package_info, $post);
279 279
 
280
-        $post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
280
+		$post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
281 281
 
282
-        if (!empty($package_info) && !$post_package_id) {
283
-            if (isset($package_info['days']) && $package_info['days'] != 0) {
284
-                $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
285
-            } else {
286
-                $payment_info['expire_date'] = 'Never';
287
-            }
282
+		if (!empty($package_info) && !$post_package_id) {
283
+			if (isset($package_info['days']) && $package_info['days'] != 0) {
284
+				$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
285
+			} else {
286
+				$payment_info['expire_date'] = 'Never';
287
+			}
288 288
 
289
-            $payment_info['package_id'] = $package_info['pid'];
290
-            $payment_info['alive_days'] = $package_info['days'];
291
-            $payment_info['is_featured'] = $package_info['is_featured'];
289
+			$payment_info['package_id'] = $package_info['pid'];
290
+			$payment_info['alive_days'] = $package_info['days'];
291
+			$payment_info['is_featured'] = $package_info['is_featured'];
292 292
 
293
-            $gd_post_info = array_merge($gd_post_info, $payment_info);
294
-        }
293
+			$gd_post_info = array_merge($gd_post_info, $payment_info);
294
+		}
295 295
 
296
-        $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
296
+		$custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
297 297
 
298
-        foreach ($custom_metaboxes as $key => $val):
298
+		foreach ($custom_metaboxes as $key => $val):
299 299
 
300
-            $name = $val['name'];
301
-            $type = $val['type'];
302
-            $extrafields = $val['extra_fields'];
300
+			$name = $val['name'];
301
+			$type = $val['type'];
302
+			$extrafields = $val['extra_fields'];
303 303
 
304
-            if (trim($type) == 'address') {
305
-                $prefix = $name . '_';
306
-                $address = $prefix . 'address';
304
+			if (trim($type) == 'address') {
305
+				$prefix = $name . '_';
306
+				$address = $prefix . 'address';
307 307
 
308
-                if (isset($request_info[$address]) && $request_info[$address] != '') {
309
-                    $gd_post_info[$address] = wp_slash($request_info[$address]);
310
-                }
308
+				if (isset($request_info[$address]) && $request_info[$address] != '') {
309
+					$gd_post_info[$address] = wp_slash($request_info[$address]);
310
+				}
311 311
 
312
-                if ($extrafields != '') {
313
-                    $extrafields = unserialize($extrafields);
312
+				if ($extrafields != '') {
313
+					$extrafields = unserialize($extrafields);
314 314
 
315 315
 
316
-                    if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
316
+					if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
317 317
 
318
-                        $location_result = geodir_get_default_location();
318
+						$location_result = geodir_get_default_location();
319 319
 
320
-                        $gd_post_info[$prefix . 'city'] = $location_result->city;
321
-                        $gd_post_info[$prefix . 'region'] = $location_result->region;
322
-                        $gd_post_info[$prefix . 'country'] = $location_result->country;
320
+						$gd_post_info[$prefix . 'city'] = $location_result->city;
321
+						$gd_post_info[$prefix . 'region'] = $location_result->region;
322
+						$gd_post_info[$prefix . 'country'] = $location_result->country;
323 323
 
324
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
324
+						$gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
325 325
 
326
-                    } else {
326
+					} else {
327 327
 
328
-                        $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
329
-                        $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
330
-                        $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
328
+						$gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
329
+						$gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
330
+						$gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
331 331
 
332
-                        //----------set post locations when import dummy data-------
333
-                        $location_result = geodir_get_default_location();
332
+						//----------set post locations when import dummy data-------
333
+						$location_result = geodir_get_default_location();
334 334
 
335
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
336
-                        //-----------------------------------------------------------------
335
+						$gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
336
+						//-----------------------------------------------------------------
337 337
 
338
-                    }
338
+					}
339 339
 
340 340
 
341
-                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
342
-                        $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
343
-                    }
341
+					if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
342
+						$gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
343
+					}
344 344
 
345 345
 
346
-                    if (isset($extrafields['show_map']) && $extrafields['show_map']) {
346
+					if (isset($extrafields['show_map']) && $extrafields['show_map']) {
347 347
 
348
-                        if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
349
-                            $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
350
-                        }
348
+						if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
349
+							$gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
350
+						}
351 351
 
352
-                        if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
353
-                            $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
354
-                        }
352
+						if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
353
+							$gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
354
+						}
355 355
 
356
-                        if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
357
-                            $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
358
-                        }
356
+						if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
357
+							$gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
358
+						}
359 359
 
360
-                        if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
361
-                            $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
362
-                        }
360
+						if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
361
+							$gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
362
+						}
363 363
 
364
-                    }
364
+					}
365 365
 
366
-                    // show lat lng
367
-                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
368
-                        $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
369
-                    }
370
-                }
366
+					// show lat lng
367
+					if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
368
+						$gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
369
+					}
370
+				}
371 371
 
372
-            } elseif (trim($type) == 'file') {
373
-                if (isset($request_info[$name])) {
374
-                    $request_files = array();
375
-                    if ($request_info[$name] != '')
376
-                        $request_files = explode(",", $request_info[$name]);
372
+			} elseif (trim($type) == 'file') {
373
+				if (isset($request_info[$name])) {
374
+					$request_files = array();
375
+					if ($request_info[$name] != '')
376
+						$request_files = explode(",", $request_info[$name]);
377 377
 
378
-                    $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
379
-                    geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
378
+					$extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
379
+					geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
380 380
 
381
-                }
382
-            } elseif (trim($type) == 'datepicker') {
383
-                $datetime = '';
384
-                if (isset($request_info[$name]) && $request_info[$name] != '') {
385
-                    $date_format = geodir_default_date_format();
386
-                    if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
387
-                        $extra_fields = unserialize($val['extra_fields']);
388
-                        $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format;
389
-                    }
381
+				}
382
+			} elseif (trim($type) == 'datepicker') {
383
+				$datetime = '';
384
+				if (isset($request_info[$name]) && $request_info[$name] != '') {
385
+					$date_format = geodir_default_date_format();
386
+					if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
387
+						$extra_fields = unserialize($val['extra_fields']);
388
+						$date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format;
389
+					}
390 390
 
391
-                    // check if we need to change the format or not
392
-                    $date_format_len = strlen(str_replace(' ', '', $date_format));
393
-                    if($date_format_len>5){// if greater then 5 then it's the old style format.
391
+					// check if we need to change the format or not
392
+					$date_format_len = strlen(str_replace(' ', '', $date_format));
393
+					if($date_format_len>5){// if greater then 5 then it's the old style format.
394 394
 
395
-                        $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
396
-                        $replace = array('d','j','l','m','n','F','Y');//PHP date format
395
+						$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
396
+						$replace = array('d','j','l','m','n','F','Y');//PHP date format
397 397
 
398
-                        $date_format = str_replace($search, $replace, $date_format);
398
+						$date_format = str_replace($search, $replace, $date_format);
399 399
 
400
-                        $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
400
+						$post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
401 401
 
402
-                    }else{
403
-                        $post_htmlvar_value = $request_info[$name];
404
-                    }
402
+					}else{
403
+						$post_htmlvar_value = $request_info[$name];
404
+					}
405 405
 
406
-                    $post_htmlvar_value =  geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated
406
+					$post_htmlvar_value =  geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated
407 407
 
408
-                    $datetime = date("Y-m-d", strtotime($post_htmlvar_value)); // save as sql format Y-m-d
408
+					$datetime = date("Y-m-d", strtotime($post_htmlvar_value)); // save as sql format Y-m-d
409 409
 
410
-                }
411
-                $gd_post_info[$name] = $datetime;
412
-            } else if ($type == 'multiselect') {
413
-                if (isset($request_info[$name])) {
414
-                    $gd_post_info[$name] = $request_info[$name];
415
-                } else {
416
-                    if (isset($request_info['gd_field_' . $name])) {
417
-                        $gd_post_info[$name] = ''; /* fix de-select for multiselect */
418
-                    }
419
-                }
420
-            } else if (isset($request_info[$name])) {
421
-                $gd_post_info[$name] = $request_info[$name];
422
-            }
410
+				}
411
+				$gd_post_info[$name] = $datetime;
412
+			} else if ($type == 'multiselect') {
413
+				if (isset($request_info[$name])) {
414
+					$gd_post_info[$name] = $request_info[$name];
415
+				} else {
416
+					if (isset($request_info['gd_field_' . $name])) {
417
+						$gd_post_info[$name] = ''; /* fix de-select for multiselect */
418
+					}
419
+				}
420
+			} else if (isset($request_info[$name])) {
421
+				$gd_post_info[$name] = $request_info[$name];
422
+			}
423 423
 
424
-        endforeach;
424
+		endforeach;
425 425
 
426
-        if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
427
-            $gd_post_info['post_dummy'] = $request_info['post_dummy'];
428
-        }
426
+		if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
427
+			$gd_post_info['post_dummy'] = $request_info['post_dummy'];
428
+		}
429 429
 
430
-        // Save post detail info in detail table
431
-        if (!empty($gd_post_info)) {
432
-            geodir_save_post_info($last_post_id, $gd_post_info);
433
-        }
430
+		// Save post detail info in detail table
431
+		if (!empty($gd_post_info)) {
432
+			geodir_save_post_info($last_post_id, $gd_post_info);
433
+		}
434 434
 
435 435
 
436
-        // Set categories to the listing
437
-        if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
438
-            $post_category = array();
436
+		// Set categories to the listing
437
+		if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
438
+			$post_category = array();
439 439
 
440
-            foreach ($request_info['post_category'] as $taxonomy => $cat) {
440
+			foreach ($request_info['post_category'] as $taxonomy => $cat) {
441 441
 
442
-                if ($dummy)
443
-                    $post_category = $cat;
444
-                else {
442
+				if ($dummy)
443
+					$post_category = $cat;
444
+				else {
445 445
 
446
-                    if (!is_array($cat) && strstr($cat, ','))
447
-                        $cat = explode(',', $cat);
446
+					if (!is_array($cat) && strstr($cat, ','))
447
+						$cat = explode(',', $cat);
448 448
 
449
-                    if (!empty($cat) && is_array($cat))
450
-                        $post_category = array_map('intval', $cat);
451
-                }
449
+					if (!empty($cat) && is_array($cat))
450
+						$post_category = array_map('intval', $cat);
451
+				}
452 452
 
453
-                wp_set_object_terms($last_post_id, $post_category, $taxonomy);
454
-            }
453
+				wp_set_object_terms($last_post_id, $post_category, $taxonomy);
454
+			}
455 455
 
456
-            $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : '';
456
+			$post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : '';
457 457
 
458
-            $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : '';
459
-            geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str);
458
+			$post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : '';
459
+			geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str);
460 460
 
461
-        }
461
+		}
462 462
 
463
-        $post_tags = '';
464
-        // Set tags to the listing
465
-        if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
466
-            $post_tags = explode(",", $request_info['post_tags']);
467
-        } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
468
-            if ($dummy)
469
-                $post_tags = $request_info['post_tags'];
470
-        } else {
471
-            if ($dummy)
472
-                $post_tags = array($request_info['post_title']);
473
-        }
463
+		$post_tags = '';
464
+		// Set tags to the listing
465
+		if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
466
+			$post_tags = explode(",", $request_info['post_tags']);
467
+		} elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
468
+			if ($dummy)
469
+				$post_tags = $request_info['post_tags'];
470
+		} else {
471
+			if ($dummy)
472
+				$post_tags = array($request_info['post_title']);
473
+		}
474 474
 
475
-        if (is_array($post_tags)) {
476
-            $taxonomy = $request_info['listing_type'] . '_tags';
477
-            wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
478
-        }
475
+		if (is_array($post_tags)) {
476
+			$taxonomy = $request_info['listing_type'] . '_tags';
477
+			wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
478
+		}
479 479
 
480 480
 
481
-        // Insert attechment
481
+		// Insert attechment
482 482
 
483
-        if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
484
-            if (!$dummy) {
485
-                $tmpimgArr = trim($request_info['post_images'], ",");
486
-                $tmpimgArr = explode(",", $tmpimgArr);
487
-                geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
488
-            } else{
489
-                geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
490
-            }
483
+		if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
484
+			if (!$dummy) {
485
+				$tmpimgArr = trim($request_info['post_images'], ",");
486
+				$tmpimgArr = explode(",", $tmpimgArr);
487
+				geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
488
+			} else{
489
+				geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
490
+			}
491 491
 
492 492
 
493
-        } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
493
+		} elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
494 494
 
495
-            /* Delete Attachments
495
+			/* Delete Attachments
496 496
 			$postcurr_images = geodir_get_images($last_post_id);
497 497
 
498 498
 			$wpdb->query(
@@ -508,34 +508,34 @@  discard block
 block discarded – undo
508 508
 			geodir_save_post_info($last_post_id, $gd_post_featured_img);
509 509
 			*/
510 510
 
511
-        }
511
+		}
512 512
 
513
-        geodir_remove_temp_images();
514
-        geodir_set_wp_featured_image($last_post_id);
513
+		geodir_remove_temp_images();
514
+		geodir_set_wp_featured_image($last_post_id);
515 515
 
516
-        /**
517
-         * Called after a listing is saved to the database and before any email have been sent.
518
-         *
519
-         * @since 1.0.0
520
-         * @param int $last_post_id The saved post ID.
521
-         * @param array $request_info The post details in an array.
522
-         * @see 'geodir_after_save_listinginfo'
523
-         */
524
-        do_action('geodir_after_save_listing', $last_post_id, $request_info);
516
+		/**
517
+		 * Called after a listing is saved to the database and before any email have been sent.
518
+		 *
519
+		 * @since 1.0.0
520
+		 * @param int $last_post_id The saved post ID.
521
+		 * @param array $request_info The post details in an array.
522
+		 * @see 'geodir_after_save_listinginfo'
523
+		 */
524
+		do_action('geodir_after_save_listing', $last_post_id, $request_info);
525 525
 
526
-        //die;
526
+		//die;
527 527
 
528
-        if ($send_post_submit_mail) { // if new post send out email
529
-            $to_name = geodir_get_client_name($current_user->ID);
530
-            geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
531
-        }
532
-        /*
528
+		if ($send_post_submit_mail) { // if new post send out email
529
+			$to_name = geodir_get_client_name($current_user->ID);
530
+			geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
531
+		}
532
+		/*
533 533
          * Unset the session so we don't loop.
534 534
          */
535
-        $gd_session->un_set('listing');
536
-        return $last_post_id;
535
+		$gd_session->un_set('listing');
536
+		return $last_post_id;
537 537
 
538
-    }
538
+	}
539 539
 
540 540
 }
541 541
 
@@ -554,585 +554,585 @@  discard block
 block discarded – undo
554 554
 function geodir_get_post_info($post_id = '')
555 555
 {
556 556
 
557
-    global $wpdb, $plugin_prefix, $post, $post_info;
557
+	global $wpdb, $plugin_prefix, $post, $post_info;
558 558
 
559
-    if ($post_id == '' && !empty($post))
560
-        $post_id = $post->ID;
559
+	if ($post_id == '' && !empty($post))
560
+		$post_id = $post->ID;
561 561
 
562
-    $post_type = get_post_type($post_id);
562
+	$post_type = get_post_type($post_id);
563 563
 
564
-    $all_postypes = geodir_get_posttypes();
564
+	$all_postypes = geodir_get_posttypes();
565 565
 
566
-    if (!in_array($post_type, $all_postypes))
567
-        return false;
566
+	if (!in_array($post_type, $all_postypes))
567
+		return false;
568 568
 
569
-    $table = $plugin_prefix . $post_type . '_detail';
569
+	$table = $plugin_prefix . $post_type . '_detail';
570 570
 
571
-    /**
572
-     * Apply Filter to change Post info
573
-     *
574
-     * You can use this filter to change Post info.
575
-     *
576
-     * @since 1.0.0
577
-     * @package GeoDirectory
578
-     */
579
-    $query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
571
+	/**
572
+	 * Apply Filter to change Post info
573
+	 *
574
+	 * You can use this filter to change Post info.
575
+	 *
576
+	 * @since 1.0.0
577
+	 * @package GeoDirectory
578
+	 */
579
+	$query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
580 580
 			  WHERE p.ID = pd.post_id
581 581
 			  AND post_id = " . $post_id);
582 582
 
583
-    $post_detail = $wpdb->get_row($query);
583
+	$post_detail = $wpdb->get_row($query);
584 584
 
585
-    return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;
585
+	return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;
586 586
 
587 587
 }
588 588
 
589 589
 
590 590
 if (!function_exists('geodir_save_post_info')) {
591
-    /**
592
-     * Saves post detail info in detail table.
593
-     *
594
-     * @since 1.0.0
595
-     * @package GeoDirectory
596
-     * @global object $wpdb WordPress Database object.
597
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
598
-     * @param int $post_id The post ID.
599
-     * @param array $postinfo_array {
600
-     *    Post info that needs to be saved in detail table.
601
-     *
602
-     *    @type string $post_title              Listing title.
603
-     *    @type string $post_tags               Listing tags.
604
-     *    @type string $post_status             Listing post status.
605
-     *    @type string $post_location_id        Listing location ID.
606
-     *    @type string $claimed                 Todo Desc needed.
607
-     *    @type string $businesses              Todo Desc needed.
608
-     *    @type int    $submit_time             Submitted time in unix timestamp.
609
-     *    @type string $submit_ip               Submitted IP.
610
-     *    @type string $expire_date             Listing expiration date.
611
-     *    @type int    $package_id              Listing package ID.
612
-     *    @type int    $alive_days              Todo Desc needed.
613
-     *    @type int    $is_featured             Is this a featured listing?.
614
-     *    @type string $post_address            Listing address.
615
-     *    @type string $post_city               Listing city.
616
-     *    @type string $post_region             Listing region.
617
-     *    @type string $post_country            Listing country.
618
-     *    @type string $post_locations          Listing locations.
619
-     *    @type string $post_zip                Listing zip.
620
-     *    @type string $post_latitude           Listing latitude.
621
-     *    @type string $post_longitude          Listing longitude.
622
-     *    @type string $post_mapview            Listing mapview. Default "ROADMAP".
623
-     *    @type string $post_mapzoom            Listing mapzoom Default "9".
624
-     *    @type string $geodir_timing           Business timing info.
625
-     *    @type string $geodir_contact          Contact number.
626
-     *    @type string $geodir_email            Business contact email.
627
-     *    @type string $geodir_website          Business website.
628
-     *    @type string $geodir_twitter          Twitter link.
629
-     *    @type string $geodir_facebook         Facebook link.
630
-     *    @type string $geodir_video            Video link.
631
-     *    @type string $geodir_special_offers   Speacial offers.
632
-     *
633
-     * }
634
-     * @return bool
635
-     */
636
-    function geodir_save_post_info($post_id, $postinfo_array = array())
637
-    {
638
-        global $wpdb, $plugin_prefix;
639
-
640
-        $post_type = get_post_type($post_id);
641
-
642
-        $table = $plugin_prefix . $post_type . '_detail';
643
-
644
-        /**
645
-         * Filter to change Post info
646
-         *
647
-         * You can use this filter to change Post info.
648
-         *
649
-         * @since 1.0.0
650
-         * @package GeoDirectory
651
-         * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
652
-         * @param int $post_id The post ID.
653
-         */
654
-        $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
591
+	/**
592
+	 * Saves post detail info in detail table.
593
+	 *
594
+	 * @since 1.0.0
595
+	 * @package GeoDirectory
596
+	 * @global object $wpdb WordPress Database object.
597
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
598
+	 * @param int $post_id The post ID.
599
+	 * @param array $postinfo_array {
600
+	 *    Post info that needs to be saved in detail table.
601
+	 *
602
+	 *    @type string $post_title              Listing title.
603
+	 *    @type string $post_tags               Listing tags.
604
+	 *    @type string $post_status             Listing post status.
605
+	 *    @type string $post_location_id        Listing location ID.
606
+	 *    @type string $claimed                 Todo Desc needed.
607
+	 *    @type string $businesses              Todo Desc needed.
608
+	 *    @type int    $submit_time             Submitted time in unix timestamp.
609
+	 *    @type string $submit_ip               Submitted IP.
610
+	 *    @type string $expire_date             Listing expiration date.
611
+	 *    @type int    $package_id              Listing package ID.
612
+	 *    @type int    $alive_days              Todo Desc needed.
613
+	 *    @type int    $is_featured             Is this a featured listing?.
614
+	 *    @type string $post_address            Listing address.
615
+	 *    @type string $post_city               Listing city.
616
+	 *    @type string $post_region             Listing region.
617
+	 *    @type string $post_country            Listing country.
618
+	 *    @type string $post_locations          Listing locations.
619
+	 *    @type string $post_zip                Listing zip.
620
+	 *    @type string $post_latitude           Listing latitude.
621
+	 *    @type string $post_longitude          Listing longitude.
622
+	 *    @type string $post_mapview            Listing mapview. Default "ROADMAP".
623
+	 *    @type string $post_mapzoom            Listing mapzoom Default "9".
624
+	 *    @type string $geodir_timing           Business timing info.
625
+	 *    @type string $geodir_contact          Contact number.
626
+	 *    @type string $geodir_email            Business contact email.
627
+	 *    @type string $geodir_website          Business website.
628
+	 *    @type string $geodir_twitter          Twitter link.
629
+	 *    @type string $geodir_facebook         Facebook link.
630
+	 *    @type string $geodir_video            Video link.
631
+	 *    @type string $geodir_special_offers   Speacial offers.
632
+	 *
633
+	 * }
634
+	 * @return bool
635
+	 */
636
+	function geodir_save_post_info($post_id, $postinfo_array = array())
637
+	{
638
+		global $wpdb, $plugin_prefix;
639
+
640
+		$post_type = get_post_type($post_id);
641
+
642
+		$table = $plugin_prefix . $post_type . '_detail';
643
+
644
+		/**
645
+		 * Filter to change Post info
646
+		 *
647
+		 * You can use this filter to change Post info.
648
+		 *
649
+		 * @since 1.0.0
650
+		 * @package GeoDirectory
651
+		 * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
652
+		 * @param int $post_id The post ID.
653
+		 */
654
+		$postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
655
+
656
+		if (!empty($postmeta) && $post_id) {
657
+			$post_meta_set_query = '';
658
+
659
+			foreach ($postmeta as $mkey => $mval) {
660
+				if (geodir_column_exist($table, $mkey)) {
661
+					if (is_array($mval)) {
662
+						$mval = implode(",", $mval);
663
+					}
664
+
665
+					$post_meta_set_query .= $mkey . " = '" . $mval . "', ";
666
+				}
667
+			}
655 668
 
656
-        if (!empty($postmeta) && $post_id) {
657
-            $post_meta_set_query = '';
669
+			$post_meta_set_query = trim($post_meta_set_query, ", ");
658 670
 
659
-            foreach ($postmeta as $mkey => $mval) {
660
-                if (geodir_column_exist($table, $mkey)) {
661
-                    if (is_array($mval)) {
662
-                        $mval = implode(",", $mval);
663
-                    }
671
+			$post_meta_set_query = str_replace('%', '%%', $post_meta_set_query);// escape %
664 672
 
665
-                    $post_meta_set_query .= $mkey . " = '" . $mval . "', ";
666
-                }
667
-            }
673
+			/**
674
+			 * Called before saving the listing info.
675
+			 *
676
+			 * @since 1.0.0
677
+			 * @package GeoDirectory
678
+			 * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
679
+			 * @param int $post_id The post ID.
680
+			 */
681
+			do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
668 682
 
669
-            $post_meta_set_query = trim($post_meta_set_query, ", ");
683
+			if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
670 684
 
671
-            $post_meta_set_query = str_replace('%', '%%', $post_meta_set_query);// escape %
685
+				$wpdb->query(
686
+					$wpdb->prepare(
687
+						"UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id =%d",
688
+						array($post_id)
689
+					)
690
+				);
672 691
 
673
-            /**
674
-             * Called before saving the listing info.
675
-             *
676
-             * @since 1.0.0
677
-             * @package GeoDirectory
678
-             * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
679
-             * @param int $post_id The post ID.
680
-             */
681
-            do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
682 692
 
683
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
693
+			} else {
684 694
 
685
-                $wpdb->query(
686
-                    $wpdb->prepare(
687
-                        "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id =%d",
688
-                        array($post_id)
689
-                    )
690
-                );
695
+				$wpdb->query(
696
+					$wpdb->prepare(
697
+						"INSERT INTO " . $table . " SET post_id = %d," . $post_meta_set_query,
698
+						array($post_id)
699
+					)
700
+				);
691 701
 
702
+			}
692 703
 
693
-            } else {
704
+			/**
705
+			 * Called after saving the listing info.
706
+			 *
707
+			 * @since 1.0.0
708
+			 * @package GeoDirectory
709
+			 * @param array $postinfo_array Post info that needs to be saved in detail table.
710
+			 * @param int $post_id The post ID.
711
+			 * @see 'geodir_after_save_listing'
712
+			 */
713
+			do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
714
+
715
+			return true;
716
+		} else
717
+			return false;
694 718
 
695
-                $wpdb->query(
696
-                    $wpdb->prepare(
697
-                        "INSERT INTO " . $table . " SET post_id = %d," . $post_meta_set_query,
698
-                        array($post_id)
699
-                    )
700
-                );
719
+	}
720
+}
701 721
 
702
-            }
703 722
 
704
-            /**
705
-             * Called after saving the listing info.
706
-             *
707
-             * @since 1.0.0
708
-             * @package GeoDirectory
709
-             * @param array $postinfo_array Post info that needs to be saved in detail table.
710
-             * @param int $post_id The post ID.
711
-             * @see 'geodir_after_save_listing'
712
-             */
713
-            do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
723
+if (!function_exists('geodir_save_post_meta')) {
724
+	/**
725
+	 * Save or update post custom fields.
726
+	 *
727
+	 * @since 1.0.0
728
+	 * @package GeoDirectory
729
+	 * @global object $wpdb WordPress Database object.
730
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
731
+	 * @param int $post_id The post ID.
732
+	 * @param string $postmeta Detail table column name.
733
+	 * @param string $meta_value Detail table column value.
734
+	 * @return void|bool
735
+	 */
736
+	function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
737
+	{
738
+
739
+		global $wpdb, $plugin_prefix;
740
+
741
+		$post_type = get_post_type($post_id);
742
+
743
+		$table = $plugin_prefix . $post_type . '_detail';
744
+
745
+		if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
746
+
747
+			if (is_array($meta_value)) {
748
+				$meta_value = implode(",", $meta_value);
749
+			}
714 750
 
715
-            return true;
716
-        } else
717
-            return false;
751
+			if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
718 752
 
719
-    }
720
-}
753
+				$wpdb->query(
754
+					$wpdb->prepare(
755
+						"UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
756
+						array($post_id)
757
+					)
758
+				);
721 759
 
760
+			} else {
722 761
 
723
-if (!function_exists('geodir_save_post_meta')) {
724
-    /**
725
-     * Save or update post custom fields.
726
-     *
727
-     * @since 1.0.0
728
-     * @package GeoDirectory
729
-     * @global object $wpdb WordPress Database object.
730
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
731
-     * @param int $post_id The post ID.
732
-     * @param string $postmeta Detail table column name.
733
-     * @param string $meta_value Detail table column value.
734
-     * @return void|bool
735
-     */
736
-    function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
737
-    {
738
-
739
-        global $wpdb, $plugin_prefix;
740
-
741
-        $post_type = get_post_type($post_id);
742
-
743
-        $table = $plugin_prefix . $post_type . '_detail';
744
-
745
-        if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
746
-
747
-            if (is_array($meta_value)) {
748
-                $meta_value = implode(",", $meta_value);
749
-            }
750
-
751
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
752
-
753
-                $wpdb->query(
754
-                    $wpdb->prepare(
755
-                        "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
756
-                        array($post_id)
757
-                    )
758
-                );
759
-
760
-            } else {
761
-
762
-                $wpdb->query(
763
-                    $wpdb->prepare(
764
-                        "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
765
-                        array($post_id)
766
-                    )
767
-                );
768
-            }
769
-
770
-
771
-        } else
772
-            return false;
773
-    }
762
+				$wpdb->query(
763
+					$wpdb->prepare(
764
+						"INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
765
+						array($post_id)
766
+					)
767
+				);
768
+			}
769
+
770
+
771
+		} else
772
+			return false;
773
+	}
774 774
 }
775 775
 
776 776
 if (!function_exists('geodir_delete_post_meta')) {
777
-    /**
778
-     * Delete post custom fields.
779
-     *
780
-     * @since 1.0.0
781
-     * @package GeoDirectory
782
-     * @global object $wpdb WordPress Database object.
783
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
784
-     * @param int $post_id The post ID.
785
-     * @param string $postmeta Detail table column name.
786
-     * @todo check if this is depreciated
787
-     * @todo Fix unknown variable mval
788
-     * @return bool
789
-     */
790
-    function geodir_delete_post_meta($post_id, $postmeta)
791
-    {
792
-
793
-        global $wpdb, $plugin_prefix;
794
-
795
-        $post_type = get_post_type($post_id);
796
-
797
-        $table = $plugin_prefix . $post_type . '_detail';
798
-
799
-        if (is_array($postmeta) && !empty($postmeta) && $post_id) {
800
-            $post_meta_set_query = '';
801
-
802
-            foreach ($postmeta as $mkey) {
803
-                if ($mval != '')
804
-                    $post_meta_set_query .= $mkey . " = '', ";
805
-            }
806
-
807
-            $post_meta_set_query = trim($post_meta_set_query, ", ");
808
-
809
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
810
-
811
-                $wpdb->query(
812
-                    $wpdb->prepare(
813
-                        "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
814
-                        array($post_id)
815
-                    )
816
-                );
817
-
818
-                return true;
819
-            }
820
-
821
-        } elseif ($postmeta != '' && $post_id) {
822
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
823
-
824
-                $wpdb->query(
825
-                    $wpdb->prepare(
826
-                        "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
827
-                        array($post_id)
828
-                    )
829
-                );
830
-
831
-                return true;
832
-            }
833
-
834
-        } else
835
-            return false;
836
-    }
777
+	/**
778
+	 * Delete post custom fields.
779
+	 *
780
+	 * @since 1.0.0
781
+	 * @package GeoDirectory
782
+	 * @global object $wpdb WordPress Database object.
783
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
784
+	 * @param int $post_id The post ID.
785
+	 * @param string $postmeta Detail table column name.
786
+	 * @todo check if this is depreciated
787
+	 * @todo Fix unknown variable mval
788
+	 * @return bool
789
+	 */
790
+	function geodir_delete_post_meta($post_id, $postmeta)
791
+	{
792
+
793
+		global $wpdb, $plugin_prefix;
794
+
795
+		$post_type = get_post_type($post_id);
796
+
797
+		$table = $plugin_prefix . $post_type . '_detail';
798
+
799
+		if (is_array($postmeta) && !empty($postmeta) && $post_id) {
800
+			$post_meta_set_query = '';
801
+
802
+			foreach ($postmeta as $mkey) {
803
+				if ($mval != '')
804
+					$post_meta_set_query .= $mkey . " = '', ";
805
+			}
806
+
807
+			$post_meta_set_query = trim($post_meta_set_query, ", ");
808
+
809
+			if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
810
+
811
+				$wpdb->query(
812
+					$wpdb->prepare(
813
+						"UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
814
+						array($post_id)
815
+					)
816
+				);
817
+
818
+				return true;
819
+			}
820
+
821
+		} elseif ($postmeta != '' && $post_id) {
822
+			if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
823
+
824
+				$wpdb->query(
825
+					$wpdb->prepare(
826
+						"UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
827
+						array($post_id)
828
+					)
829
+				);
830
+
831
+				return true;
832
+			}
833
+
834
+		} else
835
+			return false;
836
+	}
837 837
 }
838 838
 
839 839
 
840 840
 if (!function_exists('geodir_get_post_meta')) {
841
-    /**
842
-     * Get post custom meta.
843
-     *
844
-     * @since 1.0.0
845
-     * @package GeoDirectory
846
-     * @global object $wpdb WordPress Database object.
847
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
848
-     * @param int $post_id The post ID.
849
-     * @param string $meta_key The meta key to retrieve.
850
-     * @param bool $single Optional. Whether to return a single value. Default false.
851
-     * @todo single variable not yet implemented.
852
-     * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
853
-     */
854
-    function geodir_get_post_meta($post_id, $meta_key, $single = false)
855
-    {
856
-        if (!$post_id) {
857
-            return false;
858
-        }
859
-        global $wpdb, $plugin_prefix;
860
-
861
-        $all_postypes = geodir_get_posttypes();
862
-
863
-        $post_type = get_post_type($post_id);
864
-
865
-        if (!in_array($post_type, $all_postypes))
866
-            return false;
867
-
868
-        $table = $plugin_prefix . $post_type . '_detail';
869
-
870
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
871
-            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
841
+	/**
842
+	 * Get post custom meta.
843
+	 *
844
+	 * @since 1.0.0
845
+	 * @package GeoDirectory
846
+	 * @global object $wpdb WordPress Database object.
847
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
848
+	 * @param int $post_id The post ID.
849
+	 * @param string $meta_key The meta key to retrieve.
850
+	 * @param bool $single Optional. Whether to return a single value. Default false.
851
+	 * @todo single variable not yet implemented.
852
+	 * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
853
+	 */
854
+	function geodir_get_post_meta($post_id, $meta_key, $single = false)
855
+	{
856
+		if (!$post_id) {
857
+			return false;
858
+		}
859
+		global $wpdb, $plugin_prefix;
860
+
861
+		$all_postypes = geodir_get_posttypes();
862
+
863
+		$post_type = get_post_type($post_id);
864
+
865
+		if (!in_array($post_type, $all_postypes))
866
+			return false;
867
+
868
+		$table = $plugin_prefix . $post_type . '_detail';
869
+
870
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
871
+			$meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
872 872
             
873
-            if ($meta_value && $meta_value !== '') {
874
-                return maybe_serialize($meta_value);
875
-            } else
876
-                return $meta_value;
877
-        } else {
878
-            return false;
879
-        }
880
-    }
873
+			if ($meta_value && $meta_value !== '') {
874
+				return maybe_serialize($meta_value);
875
+			} else
876
+				return $meta_value;
877
+		} else {
878
+			return false;
879
+		}
880
+	}
881 881
 }
882 882
 
883 883
 
884 884
 if (!function_exists('geodir_save_post_images')) {
885
-    /**
886
-     * Save post attachments.
887
-     *
888
-     * @since 1.0.0
889
-     * @package GeoDirectory
890
-     * @global object $wpdb WordPress Database object.
891
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
892
-     * @global object $current_user Current user object.
893
-     * @param int $post_id The post ID.
894
-     * @param array $post_image Post image urls as an array.
895
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
896
-     */
897
-    function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
898
-    {
899
-
885
+	/**
886
+	 * Save post attachments.
887
+	 *
888
+	 * @since 1.0.0
889
+	 * @package GeoDirectory
890
+	 * @global object $wpdb WordPress Database object.
891
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
892
+	 * @global object $current_user Current user object.
893
+	 * @param int $post_id The post ID.
894
+	 * @param array $post_image Post image urls as an array.
895
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
896
+	 */
897
+	function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
898
+	{
900 899
 
901
-        global $wpdb, $plugin_prefix, $current_user;
902 900
 
903
-        $post_type = get_post_type($post_id);
901
+		global $wpdb, $plugin_prefix, $current_user;
904 902
 
905
-        $table = $plugin_prefix . $post_type . '_detail';
903
+		$post_type = get_post_type($post_id);
906 904
 
907
-        $post_images = geodir_get_images($post_id);
905
+		$table = $plugin_prefix . $post_type . '_detail';
908 906
 
909
-        $wpdb->query(
910
-            $wpdb->prepare(
911
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
912
-                array($post_id)
913
-            )
914
-        );
907
+		$post_images = geodir_get_images($post_id);
915 908
 
916
-        $invalid_files = $post_images;
917
-        $valid_file_ids = array();
918
-        $valid_files_condition = '';
919
-        $geodir_uploaddir = '';
909
+		$wpdb->query(
910
+			$wpdb->prepare(
911
+				"UPDATE " . $table . " SET featured_image = '' where post_id =%d",
912
+				array($post_id)
913
+			)
914
+		);
920 915
 
921
-        $remove_files = array();
916
+		$invalid_files = $post_images;
917
+		$valid_file_ids = array();
918
+		$valid_files_condition = '';
919
+		$geodir_uploaddir = '';
922 920
 
923
-        if (!empty($post_image)) {
921
+		$remove_files = array();
924 922
 
925
-            $uploads = wp_upload_dir();
926
-            $uploads_dir = $uploads['path'];
923
+		if (!empty($post_image)) {
927 924
 
928
-            $geodir_uploadpath = $uploads['path'];
929
-            $geodir_uploadurl = $uploads['url'];
930
-            $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
925
+			$uploads = wp_upload_dir();
926
+			$uploads_dir = $uploads['path'];
931 927
 
932
-            $invalid_files = array();
933
-            $postcurr_images = array();
928
+			$geodir_uploadpath = $uploads['path'];
929
+			$geodir_uploadurl = $uploads['url'];
930
+			$sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
934 931
 
935
-            for ($m = 0; $m < count($post_image); $m++) {
936
-                $menu_order = $m + 1;
932
+			$invalid_files = array();
933
+			$postcurr_images = array();
937 934
 
938
-                $file_path = '';
939
-                /* --------- start ------- */
935
+			for ($m = 0; $m < count($post_image); $m++) {
936
+				$menu_order = $m + 1;
940 937
 
941
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
938
+				$file_path = '';
939
+				/* --------- start ------- */
942 940
 
943
-                $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
941
+				$split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
944 942
 
943
+				$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
945 944
 
946
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
947 945
 
948
-                    /* --------- end ------- */
949
-                    $curr_img_url = $post_image[$m];
946
+				if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
950 947
 
951
-                    $image_name_arr = explode('/', $curr_img_url);
948
+					/* --------- end ------- */
949
+					$curr_img_url = $post_image[$m];
952 950
 
953
-                    $count_image_name_arr = count($image_name_arr) - 2;
951
+					$image_name_arr = explode('/', $curr_img_url);
954 952
 
955
-                    $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
953
+					$count_image_name_arr = count($image_name_arr) - 2;
956 954
 
957
-                    $curr_img_dir = $image_name_arr[$count_image_name_arr];
955
+					$count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
958 956
 
959
-                    $filename = end($image_name_arr);
960
-                    if (strpos($filename, '?') !== false) {
961
-                        list($filename) = explode('?', $filename);
962
-                    }
957
+					$curr_img_dir = $image_name_arr[$count_image_name_arr];
963 958
 
964
-                    $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
965
-                    $curr_img_dir = str_replace($filename, "", $curr_img_dir);
959
+					$filename = end($image_name_arr);
960
+					if (strpos($filename, '?') !== false) {
961
+						list($filename) = explode('?', $filename);
962
+					}
966 963
 
967
-                    $img_name_arr = explode('.', $filename);
964
+					$curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
965
+					$curr_img_dir = str_replace($filename, "", $curr_img_dir);
968 966
 
969
-                    $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
970
-                    if (!empty($img_name_arr) && count($img_name_arr) > 2) {
971
-                        $new_img_name_arr = $img_name_arr;
972
-                        if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
973
-                            unset($new_img_name_arr[count($img_name_arr) - 1]);
974
-                            $file_title = implode('.', $new_img_name_arr);
975
-                        }
976
-                    }
977
-                    $file_title = sanitize_file_name($file_title);
978
-                    $file_name = sanitize_file_name($filename);
967
+					$img_name_arr = explode('.', $filename);
979 968
 
980
-                    $arr_file_type = wp_check_filetype($filename);
969
+					$file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
970
+					if (!empty($img_name_arr) && count($img_name_arr) > 2) {
971
+						$new_img_name_arr = $img_name_arr;
972
+						if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
973
+							unset($new_img_name_arr[count($img_name_arr) - 1]);
974
+							$file_title = implode('.', $new_img_name_arr);
975
+						}
976
+					}
977
+					$file_title = sanitize_file_name($file_title);
978
+					$file_name = sanitize_file_name($filename);
981 979
 
982
-                    $uploaded_file_type = $arr_file_type['type'];
980
+					$arr_file_type = wp_check_filetype($filename);
983 981
 
984
-                    // Set an array containing a list of acceptable formats
985
-                    $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
982
+					$uploaded_file_type = $arr_file_type['type'];
986 983
 
987
-                    // If the uploaded file is the right format
988
-                    if (in_array($uploaded_file_type, $allowed_file_types)) {
989
-                        if (!function_exists('wp_handle_upload')) {
990
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
991
-                        }
984
+					// Set an array containing a list of acceptable formats
985
+					$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
992 986
 
993
-                        if (!is_dir($geodir_uploadpath)) {
994
-                            mkdir($geodir_uploadpath);
995
-                        }
987
+					// If the uploaded file is the right format
988
+					if (in_array($uploaded_file_type, $allowed_file_types)) {
989
+						if (!function_exists('wp_handle_upload')) {
990
+							require_once(ABSPATH . 'wp-admin/includes/file.php');
991
+						}
996 992
 
997
-                        $external_img = false;
998
-                        if (strpos(str_replace(array('http://','https://'),'',$curr_img_url), str_replace(array('http://','https://'),'',$uploads['baseurl'])) !== false) {
999
-                        } else {
1000
-                            $external_img = true;
1001
-                        }
993
+						if (!is_dir($geodir_uploadpath)) {
994
+							mkdir($geodir_uploadpath);
995
+						}
1002 996
 
1003
-                        if ($dummy || $external_img) {
1004
-                            $uploaded_file = array();
1005
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
997
+						$external_img = false;
998
+						if (strpos(str_replace(array('http://','https://'),'',$curr_img_url), str_replace(array('http://','https://'),'',$uploads['baseurl'])) !== false) {
999
+						} else {
1000
+							$external_img = true;
1001
+						}
1006 1002
 
1007
-                            if (isset($uploaded['error']) && empty($uploaded['error'])) {
1008
-                                $new_name = basename($uploaded['file']);
1009
-                                $uploaded_file = $uploaded;
1010
-                            }else{
1011
-                                print_r($uploaded);exit;
1012
-                            }
1013
-                            $external_img = false;
1014
-                        } else {
1015
-                            $new_name = $post_id . '_' . $file_name;
1003
+						if ($dummy || $external_img) {
1004
+							$uploaded_file = array();
1005
+							$uploaded = (array)fetch_remote_file($curr_img_url);
1016 1006
 
1017
-                            if ($curr_img_dir == $sub_dir) {
1018
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1019
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1020
-                            } else {
1021
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1022
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1023
-                            }
1007
+							if (isset($uploaded['error']) && empty($uploaded['error'])) {
1008
+								$new_name = basename($uploaded['file']);
1009
+								$uploaded_file = $uploaded;
1010
+							}else{
1011
+								print_r($uploaded);exit;
1012
+							}
1013
+							$external_img = false;
1014
+						} else {
1015
+							$new_name = $post_id . '_' . $file_name;
1024 1016
 
1025
-                            $uploaded_file = '';
1017
+							if ($curr_img_dir == $sub_dir) {
1018
+								$img_path = $geodir_uploadpath . '/' . $filename;
1019
+								$img_url = $geodir_uploadurl . '/' . $filename;
1020
+							} else {
1021
+								$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1022
+								$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1023
+							}
1026 1024
 
1027
-                            if (file_exists($img_path)) {
1028
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1029
-                                $file_path = '';
1030
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1031
-                                $uploaded_file = true;
1032
-                                $file_path = $curr_img_dir . '/' . $filename;
1033
-                            }
1025
+							$uploaded_file = '';
1034 1026
 
1035
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1036
-                                unlink($img_path);
1037
-                        }
1027
+							if (file_exists($img_path)) {
1028
+								$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1029
+								$file_path = '';
1030
+							} else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1031
+								$uploaded_file = true;
1032
+								$file_path = $curr_img_dir . '/' . $filename;
1033
+							}
1038 1034
 
1039
-                        if (!empty($uploaded_file)) {
1040
-                            if (!isset($file_path) || !$file_path) {
1041
-                                $file_path = $sub_dir . '/' . $new_name;
1042
-                            }
1035
+							if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1036
+								unlink($img_path);
1037
+						}
1043 1038
 
1044
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1039
+						if (!empty($uploaded_file)) {
1040
+							if (!isset($file_path) || !$file_path) {
1041
+								$file_path = $sub_dir . '/' . $new_name;
1042
+							}
1045 1043
 
1046
-                            if ($menu_order == 1) {
1044
+							$postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1047 1045
 
1048
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1046
+							if ($menu_order == 1) {
1049 1047
 
1050
-                            }
1048
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1051 1049
 
1052
-                            // Set up options array to add this file as an attachment
1053
-                            $attachment = array();
1054
-                            $attachment['post_id'] = $post_id;
1055
-                            $attachment['title'] = $file_title;
1056
-                            $attachment['content'] = '';
1057
-                            $attachment['file'] = $file_path;
1058
-                            $attachment['mime_type'] = $uploaded_file_type;
1059
-                            $attachment['menu_order'] = $menu_order;
1060
-                            $attachment['is_featured'] = 0;
1050
+							}
1061 1051
 
1062
-                            $attachment_set = '';
1052
+							// Set up options array to add this file as an attachment
1053
+							$attachment = array();
1054
+							$attachment['post_id'] = $post_id;
1055
+							$attachment['title'] = $file_title;
1056
+							$attachment['content'] = '';
1057
+							$attachment['file'] = $file_path;
1058
+							$attachment['mime_type'] = $uploaded_file_type;
1059
+							$attachment['menu_order'] = $menu_order;
1060
+							$attachment['is_featured'] = 0;
1063 1061
 
1064
-                            foreach ($attachment as $key => $val) {
1065
-                                if ($val != '')
1066
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1067
-                            }
1062
+							$attachment_set = '';
1068 1063
 
1069
-                            $attachment_set = trim($attachment_set, ", ");
1064
+							foreach ($attachment as $key => $val) {
1065
+								if ($val != '')
1066
+									$attachment_set .= $key . " = '" . $val . "', ";
1067
+							}
1070 1068
 
1071
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1069
+							$attachment_set = trim($attachment_set, ", ");
1070
+
1071
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1072 1072
 
1073
-                            $valid_file_ids[] = $wpdb->insert_id;
1074
-                        }
1073
+							$valid_file_ids[] = $wpdb->insert_id;
1074
+						}
1075 1075
 
1076
-                    }
1076
+					}
1077 1077
 
1078 1078
 
1079
-                } else {
1080
-                    $valid_file_ids[] = $find_image;
1079
+				} else {
1080
+					$valid_file_ids[] = $find_image;
1081 1081
 
1082
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1082
+					$postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1083 1083
 
1084
-                    $wpdb->query(
1085
-                        $wpdb->prepare(
1086
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1087
-                            array($menu_order, $split_img_path[1], $post_id)
1088
-                        )
1089
-                    );
1084
+					$wpdb->query(
1085
+						$wpdb->prepare(
1086
+							"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1087
+							array($menu_order, $split_img_path[1], $post_id)
1088
+						)
1089
+					);
1090 1090
 
1091
-                    if ($menu_order == 1)
1092
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1091
+					if ($menu_order == 1)
1092
+						$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1093 1093
 
1094
-                }
1094
+				}
1095 1095
 
1096 1096
 
1097
-            }
1097
+			}
1098 1098
 
1099
-            if (!empty($valid_file_ids)) {
1099
+			if (!empty($valid_file_ids)) {
1100 1100
 
1101
-                $remove_files = $valid_file_ids;
1101
+				$remove_files = $valid_file_ids;
1102 1102
 
1103
-                $remove_files_length = count($remove_files);
1104
-                $remove_files_format = array_fill(0, $remove_files_length, '%d');
1105
-                $format = implode(',', $remove_files_format);
1106
-                $valid_files_condition = " ID NOT IN ($format) AND ";
1103
+				$remove_files_length = count($remove_files);
1104
+				$remove_files_format = array_fill(0, $remove_files_length, '%d');
1105
+				$format = implode(',', $remove_files_format);
1106
+				$valid_files_condition = " ID NOT IN ($format) AND ";
1107 1107
 
1108
-            }
1108
+			}
1109 1109
 
1110
-            //Get and remove all old images of post from database to set by new order
1110
+			//Get and remove all old images of post from database to set by new order
1111 1111
 
1112
-            if (!empty($post_images)) {
1112
+			if (!empty($post_images)) {
1113 1113
 
1114
-                foreach ($post_images as $img) {
1114
+				foreach ($post_images as $img) {
1115 1115
 
1116
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1116
+					if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1117 1117
 
1118
-                        $invalid_files[] = (object)array('src' => $img->src);
1118
+						$invalid_files[] = (object)array('src' => $img->src);
1119 1119
 
1120
-                    }
1120
+					}
1121 1121
 
1122
-                }
1122
+				}
1123 1123
 
1124
-            }
1124
+			}
1125 1125
 
1126
-            $invalid_files = (object)$invalid_files;
1127
-        }
1126
+			$invalid_files = (object)$invalid_files;
1127
+		}
1128 1128
 
1129
-        $remove_files[] = $post_id;
1129
+		$remove_files[] = $post_id;
1130 1130
 
1131
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1131
+		$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1132 1132
 
1133
-        if (!empty($invalid_files))
1134
-            geodir_remove_attachments($invalid_files);
1135
-    }
1133
+		if (!empty($invalid_files))
1134
+			geodir_remove_attachments($invalid_files);
1135
+	}
1136 1136
 
1137 1137
 }
1138 1138
 
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 function geodir_remove_temp_images()
1147 1147
 {
1148 1148
 
1149
-    global $current_user;
1149
+	global $current_user;
1150 1150
 
1151
-    $uploads = wp_upload_dir();
1152
-    $uploads_dir = $uploads['path'];
1151
+	$uploads = wp_upload_dir();
1152
+	$uploads_dir = $uploads['path'];
1153 1153
 
1154
-    /*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1154
+	/*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1155 1155
 
1156 1156
 			$dirPath = $uploads_dir.'/temp_'.$current_user->data->ID;
1157 1157
 			if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 			rmdir($dirPath);
1169 1169
 	}	*/
1170 1170
 
1171
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1172
-    geodir_delete_directory($dirname);
1171
+	$dirname = $uploads_dir . '/temp_' . $current_user->ID;
1172
+	geodir_delete_directory($dirname);
1173 1173
 }
1174 1174
 
1175 1175
 
@@ -1183,116 +1183,116 @@  discard block
 block discarded – undo
1183 1183
  */
1184 1184
 function geodir_delete_directory($dirname)
1185 1185
 {
1186
-    $dir_handle = '';
1187
-    if (is_dir($dirname))
1188
-        $dir_handle = opendir($dirname);
1189
-    if (!$dir_handle)
1190
-        return false;
1191
-    while ($file = readdir($dir_handle)) {
1192
-        if ($file != "." && $file != "..") {
1193
-            if (!is_dir($dirname . "/" . $file))
1194
-                unlink($dirname . "/" . $file);
1195
-            else
1196
-                geodir_delete_directory($dirname . '/' . $file);
1197
-        }
1198
-    }
1199
-    closedir($dir_handle);
1200
-    rmdir($dirname);
1201
-    return true;
1186
+	$dir_handle = '';
1187
+	if (is_dir($dirname))
1188
+		$dir_handle = opendir($dirname);
1189
+	if (!$dir_handle)
1190
+		return false;
1191
+	while ($file = readdir($dir_handle)) {
1192
+		if ($file != "." && $file != "..") {
1193
+			if (!is_dir($dirname . "/" . $file))
1194
+				unlink($dirname . "/" . $file);
1195
+			else
1196
+				geodir_delete_directory($dirname . '/' . $file);
1197
+		}
1198
+	}
1199
+	closedir($dir_handle);
1200
+	rmdir($dirname);
1201
+	return true;
1202 1202
 
1203 1203
 }
1204 1204
 
1205 1205
 
1206 1206
 if (!function_exists('geodir_remove_attachments')) {
1207
-    /**
1208
-     * Remove post attachments.
1209
-     *
1210
-     * @since 1.0.0
1211
-     * @package GeoDirectory
1212
-     * @param array $postcurr_images Array of image objects.
1213
-     */
1214
-    function geodir_remove_attachments($postcurr_images = array())
1215
-    {
1216
-        // Unlink all past images of post
1217
-        if (!empty($postcurr_images)) {
1218
-
1219
-            $uploads = wp_upload_dir();
1220
-            $uploads_dir = $uploads['path'];
1221
-
1222
-            foreach ($postcurr_images as $postimg) {
1223
-                $image_name_arr = explode('/', $postimg->src);
1224
-                $filename = end($image_name_arr);
1225
-                if (file_exists($uploads_dir . '/' . $filename))
1226
-                    unlink($uploads_dir . '/' . $filename);
1227
-            }
1228
-
1229
-        } // endif
1230
-        // Unlink all past images of post end
1231
-    }
1207
+	/**
1208
+	 * Remove post attachments.
1209
+	 *
1210
+	 * @since 1.0.0
1211
+	 * @package GeoDirectory
1212
+	 * @param array $postcurr_images Array of image objects.
1213
+	 */
1214
+	function geodir_remove_attachments($postcurr_images = array())
1215
+	{
1216
+		// Unlink all past images of post
1217
+		if (!empty($postcurr_images)) {
1218
+
1219
+			$uploads = wp_upload_dir();
1220
+			$uploads_dir = $uploads['path'];
1221
+
1222
+			foreach ($postcurr_images as $postimg) {
1223
+				$image_name_arr = explode('/', $postimg->src);
1224
+				$filename = end($image_name_arr);
1225
+				if (file_exists($uploads_dir . '/' . $filename))
1226
+					unlink($uploads_dir . '/' . $filename);
1227
+			}
1228
+
1229
+		} // endif
1230
+		// Unlink all past images of post end
1231
+	}
1232 1232
 }
1233 1233
 
1234 1234
 if (!function_exists('geodir_get_featured_image')) {
1235
-    /**
1236
-     * Gets the post featured image.
1237
-     *
1238
-     * @since 1.0.0
1239
-     * @package GeoDirectory
1240
-     * @global object $wpdb WordPress Database object.
1241
-     * @global object $post The current post object.
1242
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1243
-     * @param int|string $post_id The post ID.
1244
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1245
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1246
-     * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1247
-     * @return bool|object Image details as an object.
1248
-     */
1249
-    function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1250
-    {
1251
-
1252
-        /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1235
+	/**
1236
+	 * Gets the post featured image.
1237
+	 *
1238
+	 * @since 1.0.0
1239
+	 * @package GeoDirectory
1240
+	 * @global object $wpdb WordPress Database object.
1241
+	 * @global object $post The current post object.
1242
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1243
+	 * @param int|string $post_id The post ID.
1244
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1245
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1246
+	 * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1247
+	 * @return bool|object Image details as an object.
1248
+	 */
1249
+	function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1250
+	{
1251
+
1252
+		/*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1253 1253
         $img_arr['path'] = '';
1254 1254
         $img_arr['width'] = '';
1255 1255
         $img_arr['height'] = '';
1256 1256
         $img_arr['title'] = '';
1257 1257
         return (object)$img_arr;*/
1258
-        global $wpdb, $plugin_prefix, $post;
1258
+		global $wpdb, $plugin_prefix, $post;
1259 1259
 
1260
-        if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1261
-            $post_type = $post->post_type;
1262
-        } else {
1263
-            $post_type = get_post_type($post_id);
1264
-        }
1260
+		if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1261
+			$post_type = $post->post_type;
1262
+		} else {
1263
+			$post_type = get_post_type($post_id);
1264
+		}
1265 1265
 
1266
-        if (!in_array($post_type, geodir_get_posttypes())) {
1267
-            return false;// if not a GD CPT return;
1268
-        }
1266
+		if (!in_array($post_type, geodir_get_posttypes())) {
1267
+			return false;// if not a GD CPT return;
1268
+		}
1269 1269
 
1270
-        $table = $plugin_prefix . $post_type . '_detail';
1270
+		$table = $plugin_prefix . $post_type . '_detail';
1271 1271
 
1272
-        if (!$file) {
1273
-            if (isset($post->featured_image)) {
1274
-                $file = $post->featured_image;
1275
-            } else {
1276
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1277
-            }
1278
-        }
1272
+		if (!$file) {
1273
+			if (isset($post->featured_image)) {
1274
+				$file = $post->featured_image;
1275
+			} else {
1276
+				$file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1277
+			}
1278
+		}
1279 1279
 
1280
-        if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1281
-            $img_arr = array();
1280
+		if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1281
+			$img_arr = array();
1282 1282
 
1283
-            $file_info = pathinfo($file);
1284
-            $sub_dir = '';
1285
-            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1286
-                $sub_dir = stripslashes_deep($file_info['dirname']);
1283
+			$file_info = pathinfo($file);
1284
+			$sub_dir = '';
1285
+			if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1286
+				$sub_dir = stripslashes_deep($file_info['dirname']);
1287 1287
 
1288
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1289
-            $uploads_baseurl = $uploads['baseurl'];
1290
-            $uploads_path = $uploads['path'];
1288
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1289
+			$uploads_baseurl = $uploads['baseurl'];
1290
+			$uploads_path = $uploads['path'];
1291 1291
 
1292
-            $file_name = $file_info['basename'];
1292
+			$file_name = $file_info['basename'];
1293 1293
 
1294
-            $uploads_url = $uploads_baseurl . $sub_dir;
1295
-            /*
1294
+			$uploads_url = $uploads_baseurl . $sub_dir;
1295
+			/*
1296 1296
              * Allows the filter of image src for such things as CDN change.
1297 1297
              *
1298 1298
              * @since 1.5.7
@@ -1301,158 +1301,158 @@  discard block
 block discarded – undo
1301 1301
              * @param string $uploads_url The server upload directory url.
1302 1302
              * @param string $uploads_baseurl The uploads dir base url.
1303 1303
              */
1304
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1305
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1306
-            $width = 0;
1307
-            $height = 0;
1308
-            if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1309
-                $imagesize = getimagesize($img_arr['path']);
1310
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1311
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1312
-            }
1313
-            $img_arr['width'] = $width;
1314
-            $img_arr['height'] = $height;
1315
-            $img_arr['title'] = '';
1316
-        } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1317
-            foreach ($post_images as $image) {
1318
-                return $image;
1319
-            }
1320
-        } else if ($no_image) {
1321
-            $img_arr = array();
1322
-
1323
-            $default_img = '';
1324
-            if (isset($post->default_category) && $post->default_category) {
1325
-                $default_cat = $post->default_category;
1326
-            } else {
1327
-                $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1328
-            }
1329
-
1330
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1331
-                $default_img = $default_catimg['src'];
1332
-            elseif ($no_image) {
1333
-                $default_img = get_option('geodir_listing_no_img');
1334
-            }
1335
-
1336
-            if (!empty($default_img)) {
1337
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1338
-                $uploads_baseurl = $uploads['baseurl'];
1339
-                $uploads_path = $uploads['path'];
1340
-
1341
-                $img_arr = array();
1342
-
1343
-                $file_info = pathinfo($default_img);
1344
-
1345
-                $file_name = $file_info['basename'];
1346
-
1347
-                $img_arr['src'] = $default_img;
1348
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1349
-
1350
-                $width = 0;
1351
-                $height = 0;
1352
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1353
-                    $imagesize = getimagesize($img_arr['path']);
1354
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1355
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1356
-                }
1357
-                $img_arr['width'] = $width;
1358
-                $img_arr['height'] = $height;
1359
-
1360
-                $img_arr['title'] = ''; // add the title to the array
1361
-            }
1362
-        }
1363
-
1364
-        if (!empty($img_arr))
1365
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1366
-        else
1367
-            return false;
1368
-    }
1304
+			$img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1305
+			$img_arr['path'] = $uploads_path . '/' . $file_name;
1306
+			$width = 0;
1307
+			$height = 0;
1308
+			if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1309
+				$imagesize = getimagesize($img_arr['path']);
1310
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1311
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1312
+			}
1313
+			$img_arr['width'] = $width;
1314
+			$img_arr['height'] = $height;
1315
+			$img_arr['title'] = '';
1316
+		} elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1317
+			foreach ($post_images as $image) {
1318
+				return $image;
1319
+			}
1320
+		} else if ($no_image) {
1321
+			$img_arr = array();
1322
+
1323
+			$default_img = '';
1324
+			if (isset($post->default_category) && $post->default_category) {
1325
+				$default_cat = $post->default_category;
1326
+			} else {
1327
+				$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1328
+			}
1329
+
1330
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1331
+				$default_img = $default_catimg['src'];
1332
+			elseif ($no_image) {
1333
+				$default_img = get_option('geodir_listing_no_img');
1334
+			}
1335
+
1336
+			if (!empty($default_img)) {
1337
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1338
+				$uploads_baseurl = $uploads['baseurl'];
1339
+				$uploads_path = $uploads['path'];
1340
+
1341
+				$img_arr = array();
1342
+
1343
+				$file_info = pathinfo($default_img);
1344
+
1345
+				$file_name = $file_info['basename'];
1346
+
1347
+				$img_arr['src'] = $default_img;
1348
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1349
+
1350
+				$width = 0;
1351
+				$height = 0;
1352
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1353
+					$imagesize = getimagesize($img_arr['path']);
1354
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1355
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1356
+				}
1357
+				$img_arr['width'] = $width;
1358
+				$img_arr['height'] = $height;
1359
+
1360
+				$img_arr['title'] = ''; // add the title to the array
1361
+			}
1362
+		}
1363
+
1364
+		if (!empty($img_arr))
1365
+			return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1366
+		else
1367
+			return false;
1368
+	}
1369 1369
 }
1370 1370
 
1371 1371
 if (!function_exists('geodir_show_featured_image')) {
1372
-    /**
1373
-     * Gets the post featured image.
1374
-     *
1375
-     * @since 1.0.0
1376
-     * @package GeoDirectory
1377
-     * @param int|string $post_id The post ID.
1378
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1379
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1380
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1381
-     * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1382
-     * @return bool|string Returns image html.
1383
-     */
1384
-    function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1385
-    {
1386
-        $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1387
-
1388
-        $html = geodir_show_image($image, $size, $no_image, false);
1389
-
1390
-        if (!empty($html) && $echo) {
1391
-            echo $html;
1392
-        } elseif (!empty($html)) {
1393
-            return $html;
1394
-        } else
1395
-            return false;
1396
-    }
1372
+	/**
1373
+	 * Gets the post featured image.
1374
+	 *
1375
+	 * @since 1.0.0
1376
+	 * @package GeoDirectory
1377
+	 * @param int|string $post_id The post ID.
1378
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1379
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1380
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1381
+	 * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1382
+	 * @return bool|string Returns image html.
1383
+	 */
1384
+	function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1385
+	{
1386
+		$image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1387
+
1388
+		$html = geodir_show_image($image, $size, $no_image, false);
1389
+
1390
+		if (!empty($html) && $echo) {
1391
+			echo $html;
1392
+		} elseif (!empty($html)) {
1393
+			return $html;
1394
+		} else
1395
+			return false;
1396
+	}
1397 1397
 }
1398 1398
 
1399 1399
 if (!function_exists('geodir_get_images')) {
1400
-    /**
1401
-     * Gets the post images.
1402
-     *
1403
-     * @since 1.0.0
1404
-     * @package GeoDirectory
1405
-     * @global object $wpdb WordPress Database object.
1406
-     * @param int $post_id The post ID.
1407
-     * @param string $img_size Optional. Thumbnail size.
1408
-     * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1409
-     * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1410
-     * @param int|string $limit Optional. Number of images.
1411
-     * @return array|bool Returns images as an array. Each item is an object.
1412
-     */
1413
-    function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1414
-    {
1415
-        global $wpdb;
1416
-        if ($limit) {
1417
-            $limit_q = " LIMIT $limit ";
1418
-        } else {
1419
-            $limit_q = '';
1420
-        }
1421
-        $not_featured = '';
1422
-        $sub_dir = '';
1423
-        if (!$add_featured)
1424
-            $not_featured = " AND is_featured = 0 ";
1425
-
1426
-        $arrImages = $wpdb->get_results(
1427
-            $wpdb->prepare(
1428
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ",
1429
-                array('%image%', $post_id)
1430
-            )
1431
-        );
1432
-
1433
-        $counter = 0;
1434
-        $return_arr = array();
1435
-
1436
-        if (!empty($arrImages)) {
1437
-            foreach ($arrImages as $attechment) {
1438
-
1439
-                $img_arr = array();
1440
-                $img_arr['id'] = $attechment->ID;
1441
-                $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1442
-
1443
-                $file_info = pathinfo($attechment->file);
1444
-
1445
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1446
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1447
-
1448
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1449
-                $uploads_baseurl = $uploads['baseurl'];
1450
-                $uploads_path = $uploads['path'];
1451
-
1452
-                $file_name = $file_info['basename'];
1453
-
1454
-                $uploads_url = $uploads_baseurl . $sub_dir;
1455
-                /*
1400
+	/**
1401
+	 * Gets the post images.
1402
+	 *
1403
+	 * @since 1.0.0
1404
+	 * @package GeoDirectory
1405
+	 * @global object $wpdb WordPress Database object.
1406
+	 * @param int $post_id The post ID.
1407
+	 * @param string $img_size Optional. Thumbnail size.
1408
+	 * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1409
+	 * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1410
+	 * @param int|string $limit Optional. Number of images.
1411
+	 * @return array|bool Returns images as an array. Each item is an object.
1412
+	 */
1413
+	function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1414
+	{
1415
+		global $wpdb;
1416
+		if ($limit) {
1417
+			$limit_q = " LIMIT $limit ";
1418
+		} else {
1419
+			$limit_q = '';
1420
+		}
1421
+		$not_featured = '';
1422
+		$sub_dir = '';
1423
+		if (!$add_featured)
1424
+			$not_featured = " AND is_featured = 0 ";
1425
+
1426
+		$arrImages = $wpdb->get_results(
1427
+			$wpdb->prepare(
1428
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ",
1429
+				array('%image%', $post_id)
1430
+			)
1431
+		);
1432
+
1433
+		$counter = 0;
1434
+		$return_arr = array();
1435
+
1436
+		if (!empty($arrImages)) {
1437
+			foreach ($arrImages as $attechment) {
1438
+
1439
+				$img_arr = array();
1440
+				$img_arr['id'] = $attechment->ID;
1441
+				$img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1442
+
1443
+				$file_info = pathinfo($attechment->file);
1444
+
1445
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1446
+					$sub_dir = stripslashes_deep($file_info['dirname']);
1447
+
1448
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1449
+				$uploads_baseurl = $uploads['baseurl'];
1450
+				$uploads_path = $uploads['path'];
1451
+
1452
+				$file_name = $file_info['basename'];
1453
+
1454
+				$uploads_url = $uploads_baseurl . $sub_dir;
1455
+				/*
1456 1456
                 * Allows the filter of image src for such things as CDN change.
1457 1457
                 *
1458 1458
                 * @since 1.5.7
@@ -1461,534 +1461,534 @@  discard block
 block discarded – undo
1461 1461
                 * @param string $uploads_url The server upload directory url.
1462 1462
                 * @param string $uploads_baseurl The uploads dir base url.
1463 1463
                 */
1464
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1465
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1466
-                $width = 0;
1467
-                $height = 0;
1468
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1469
-                    $imagesize = getimagesize($img_arr['path']);
1470
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1471
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1472
-                }
1473
-                $img_arr['width'] = $width;
1474
-                $img_arr['height'] = $height;
1475
-
1476
-                $img_arr['file'] = $file_name; // add the title to the array
1477
-                $img_arr['title'] = $attechment->title; // add the title to the array
1478
-                $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1479
-                $img_arr['content'] = $attechment->content; // add the description to the array
1480
-                $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1481
-
1482
-                $return_arr[] = (object)$img_arr;
1483
-
1484
-                $counter++;
1485
-            }
1486
-            return (object)$return_arr;
1487
-        } else if ($no_images) {
1488
-            $default_img = '';
1489
-            $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1490
-            $post_type = get_post_type($post_id);
1491
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1492
-                $default_img = $default_catimg['src'];
1493
-            elseif ($no_images) {
1494
-                $default_img = get_option('geodir_listing_no_img');
1495
-            }
1496
-
1497
-            if (!empty($default_img)) {
1498
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1464
+				$img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1465
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1466
+				$width = 0;
1467
+				$height = 0;
1468
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1469
+					$imagesize = getimagesize($img_arr['path']);
1470
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1471
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1472
+				}
1473
+				$img_arr['width'] = $width;
1474
+				$img_arr['height'] = $height;
1475
+
1476
+				$img_arr['file'] = $file_name; // add the title to the array
1477
+				$img_arr['title'] = $attechment->title; // add the title to the array
1478
+				$img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1479
+				$img_arr['content'] = $attechment->content; // add the description to the array
1480
+				$img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1481
+
1482
+				$return_arr[] = (object)$img_arr;
1483
+
1484
+				$counter++;
1485
+			}
1486
+			return (object)$return_arr;
1487
+		} else if ($no_images) {
1488
+			$default_img = '';
1489
+			$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1490
+			$post_type = get_post_type($post_id);
1491
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1492
+				$default_img = $default_catimg['src'];
1493
+			elseif ($no_images) {
1494
+				$default_img = get_option('geodir_listing_no_img');
1495
+			}
1496
+
1497
+			if (!empty($default_img)) {
1498
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1499 1499
                 
1500
-                $image_path = $default_img;
1501
-                if (!path_is_absolute($image_path)) {
1502
-                    $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1503
-                }
1504
-
1505
-                $file_info = pathinfo($default_img);
1506
-                $file_name = $file_info['basename'];
1507
-
1508
-                $width = '';
1509
-                $height = '';
1510
-                if (is_file($image_path) && file_exists($image_path)) {
1511
-                    $imagesize = getimagesize($image_path);
1512
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1513
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1514
-                }
1500
+				$image_path = $default_img;
1501
+				if (!path_is_absolute($image_path)) {
1502
+					$image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1503
+				}
1504
+
1505
+				$file_info = pathinfo($default_img);
1506
+				$file_name = $file_info['basename'];
1507
+
1508
+				$width = '';
1509
+				$height = '';
1510
+				if (is_file($image_path) && file_exists($image_path)) {
1511
+					$imagesize = getimagesize($image_path);
1512
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1513
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1514
+				}
1515 1515
                 
1516
-                $img_arr = array();
1517
-                $img_arr['src'] = $default_img;
1518
-                $img_arr['path'] = $image_path;
1519
-                $img_arr['width'] = $width;
1520
-                $img_arr['height'] = $height;
1521
-                $img_arr['file'] = $file_name; // add the title to the array
1522
-                $img_arr['title'] = $file_info['filename']; // add the title to the array
1523
-                $img_arr['content'] = $file_info['filename']; // add the description to the array
1524
-
1525
-                $return_arr[] = (object)$img_arr;
1526
-
1527
-                return $return_arr;
1528
-            } else
1529
-                return false;
1530
-        }
1531
-    }
1516
+				$img_arr = array();
1517
+				$img_arr['src'] = $default_img;
1518
+				$img_arr['path'] = $image_path;
1519
+				$img_arr['width'] = $width;
1520
+				$img_arr['height'] = $height;
1521
+				$img_arr['file'] = $file_name; // add the title to the array
1522
+				$img_arr['title'] = $file_info['filename']; // add the title to the array
1523
+				$img_arr['content'] = $file_info['filename']; // add the description to the array
1524
+
1525
+				$return_arr[] = (object)$img_arr;
1526
+
1527
+				return $return_arr;
1528
+			} else
1529
+				return false;
1530
+		}
1531
+	}
1532 1532
 }
1533 1533
 
1534 1534
 if (!function_exists('geodir_show_image')) {
1535
-    /**
1536
-     * Show image using image details.
1537
-     *
1538
-     * @since 1.0.0
1539
-     * @package GeoDirectory
1540
-     * @param array|object $request Image info either as an array or object.
1541
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1542
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1543
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1544
-     * @return bool|string Returns image html.
1545
-     */
1546
-    function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1547
-    {
1548
-        $image = new stdClass();
1549
-
1550
-        $html = '';
1551
-        if (!empty($request)) {
1552
-            if (!is_object($request)){
1553
-                $request = (object)$request;
1554
-            }
1555
-
1556
-            if (isset($request->src) && !isset($request->path)) {
1557
-                $request->path = $request->src;
1558
-            }
1559
-
1560
-            /*
1535
+	/**
1536
+	 * Show image using image details.
1537
+	 *
1538
+	 * @since 1.0.0
1539
+	 * @package GeoDirectory
1540
+	 * @param array|object $request Image info either as an array or object.
1541
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1542
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1543
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1544
+	 * @return bool|string Returns image html.
1545
+	 */
1546
+	function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1547
+	{
1548
+		$image = new stdClass();
1549
+
1550
+		$html = '';
1551
+		if (!empty($request)) {
1552
+			if (!is_object($request)){
1553
+				$request = (object)$request;
1554
+			}
1555
+
1556
+			if (isset($request->src) && !isset($request->path)) {
1557
+				$request->path = $request->src;
1558
+			}
1559
+
1560
+			/*
1561 1561
              * getimagesize() works faster from path than url so we try and get path if we can.
1562 1562
              */
1563
-            $upload_dir = wp_upload_dir();
1564
-            $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1565
-            $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1566
-            if (strpos($img_no_http, $upload_no_http) !== false) {
1567
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1568
-            }
1563
+			$upload_dir = wp_upload_dir();
1564
+			$img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1565
+			$upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1566
+			if (strpos($img_no_http, $upload_no_http) !== false) {
1567
+				$request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1568
+			}
1569 1569
             
1570
-            $width = 0;
1571
-            $height = 0;
1572
-            if (is_file($request->path) && file_exists($request->path)) {
1573
-                $imagesize = getimagesize($request->path);
1574
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1575
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1576
-            }
1577
-
1578
-            $image->src = $request->src;
1579
-            $image->width = $width;
1580
-            $image->height = $height;
1581
-
1582
-            $max_size = (object)geodir_get_imagesize($size);
1583
-
1584
-            if (!is_wp_error($max_size)) {
1585
-                if ($image->width) {
1586
-                    if ($image->height >= $image->width) {
1587
-                        $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1588
-                    } else if ($image->width < ($max_size->h)) {
1589
-                        $width_per = round((($image->width / $max_size->w) * 100), 2);
1590
-                    } else
1591
-                        $width_per = 100;
1592
-                }
1593
-
1594
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1595
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1596
-                } else {
1597
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1598
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1599
-                    }else{
1600
-                        //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1601
-                        //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1602
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1603
-
1604
-                    }
1605
-
1606
-                }
1607
-            }
1608
-        }
1609
-
1610
-        if (!empty($html) && $echo) {
1611
-            echo $html;
1612
-        } elseif (!empty($html)) {
1613
-            return $html;
1614
-        } else
1615
-            return false;
1616
-    }
1617
-}
1570
+			$width = 0;
1571
+			$height = 0;
1572
+			if (is_file($request->path) && file_exists($request->path)) {
1573
+				$imagesize = getimagesize($request->path);
1574
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1575
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1576
+			}
1618 1577
 
1619
-if (!function_exists('geodir_set_post_terms')) {
1620
-    /**
1621
-     * Set post Categories.
1622
-     *
1623
-     * @since 1.0.0
1624
-     * @package GeoDirectory
1625
-     * @global object $wpdb WordPress Database object.
1626
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1627
-     * @param int $post_id The post ID.
1628
-     * @param array $terms An array of term objects.
1629
-     * @param array $tt_ids An array of term taxonomy IDs.
1630
-     * @param string $taxonomy Taxonomy slug.
1631
-     */
1632
-    function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1633
-    {
1634
-        global $wpdb, $plugin_prefix;
1578
+			$image->src = $request->src;
1579
+			$image->width = $width;
1580
+			$image->height = $height;
1635 1581
 
1636
-        $post_type = get_post_type($post_id);
1582
+			$max_size = (object)geodir_get_imagesize($size);
1637 1583
 
1638
-        $table = $plugin_prefix . $post_type . '_detail';
1584
+			if (!is_wp_error($max_size)) {
1585
+				if ($image->width) {
1586
+					if ($image->height >= $image->width) {
1587
+						$width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1588
+					} else if ($image->width < ($max_size->h)) {
1589
+						$width_per = round((($image->width / $max_size->w) * 100), 2);
1590
+					} else
1591
+						$width_per = 100;
1592
+				}
1593
+
1594
+				if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1595
+					$html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1596
+				} else {
1597
+					if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1598
+						$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1599
+					}else{
1600
+						//$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1601
+						//$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1602
+						$html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1603
+
1604
+					}
1639 1605
 
1640
-        if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1606
+				}
1607
+			}
1608
+		}
1609
+
1610
+		if (!empty($html) && $echo) {
1611
+			echo $html;
1612
+		} elseif (!empty($html)) {
1613
+			return $html;
1614
+		} else
1615
+			return false;
1616
+	}
1617
+}
1641 1618
 
1642
-            if ($taxonomy == $post_type . '_tags') {
1643
-                if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1644
-                    geodir_save_post_meta($post_id, 'post_tags', $terms);
1645
-                }
1646
-            } elseif ($taxonomy == $post_type . 'category') {
1647
-                $srcharr = array('"', '\\');
1648
-                $replarr = array("&quot;", '');
1619
+if (!function_exists('geodir_set_post_terms')) {
1620
+	/**
1621
+	 * Set post Categories.
1622
+	 *
1623
+	 * @since 1.0.0
1624
+	 * @package GeoDirectory
1625
+	 * @global object $wpdb WordPress Database object.
1626
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1627
+	 * @param int $post_id The post ID.
1628
+	 * @param array $terms An array of term objects.
1629
+	 * @param array $tt_ids An array of term taxonomy IDs.
1630
+	 * @param string $taxonomy Taxonomy slug.
1631
+	 */
1632
+	function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1633
+	{
1634
+		global $wpdb, $plugin_prefix;
1635
+
1636
+		$post_type = get_post_type($post_id);
1637
+
1638
+		$table = $plugin_prefix . $post_type . '_detail';
1639
+
1640
+		if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1641
+
1642
+			if ($taxonomy == $post_type . '_tags') {
1643
+				if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1644
+					geodir_save_post_meta($post_id, 'post_tags', $terms);
1645
+				}
1646
+			} elseif ($taxonomy == $post_type . 'category') {
1647
+				$srcharr = array('"', '\\');
1648
+				$replarr = array("&quot;", '');
1649 1649
 
1650
-                $post_obj = get_post($post_id);
1650
+				$post_obj = get_post($post_id);
1651 1651
 
1652
-                $cat_ids = array('0');
1653
-                if (is_array($tt_ids))
1654
-                    $cat_ids = $tt_ids;
1652
+				$cat_ids = array('0');
1653
+				if (is_array($tt_ids))
1654
+					$cat_ids = $tt_ids;
1655 1655
 
1656 1656
 
1657
-                if (!empty($cat_ids)) {
1658
-                    $cat_ids_array = $cat_ids;
1659
-                    $cat_ids_length = count($cat_ids_array);
1660
-                    $cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1661
-                    $format = implode(',', $cat_ids_format);
1657
+				if (!empty($cat_ids)) {
1658
+					$cat_ids_array = $cat_ids;
1659
+					$cat_ids_length = count($cat_ids_array);
1660
+					$cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1661
+					$format = implode(',', $cat_ids_format);
1662 1662
 
1663
-                    $cat_ids_array_del = $cat_ids_array;
1664
-                    $cat_ids_array_del[] = $post_id;
1663
+					$cat_ids_array_del = $cat_ids_array;
1664
+					$cat_ids_array_del[] = $post_id;
1665 1665
 
1666
-                    $wpdb->get_var(
1667
-                        $wpdb->prepare(
1668
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1669
-                            $cat_ids_array_del
1670
-                        )
1671
-                    );
1666
+					$wpdb->get_var(
1667
+						$wpdb->prepare(
1668
+							"DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1669
+							$cat_ids_array_del
1670
+						)
1671
+					);
1672 1672
 
1673 1673
 
1674
-                    $post_term = $wpdb->get_col(
1675
-                        $wpdb->prepare(
1676
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1677
-                            $cat_ids_array
1678
-                        )
1679
-                    );
1674
+					$post_term = $wpdb->get_col(
1675
+						$wpdb->prepare(
1676
+							"SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1677
+							$cat_ids_array
1678
+						)
1679
+					);
1680 1680
 
1681
-                }
1681
+				}
1682 1682
 
1683
-                $post_marker_json = '';
1683
+				$post_marker_json = '';
1684 1684
 
1685
-                if (!empty($post_term)):
1685
+				if (!empty($post_term)):
1686 1686
 
1687
-                    foreach ($post_term as $cat_id):
1687
+					foreach ($post_term as $cat_id):
1688 1688
 
1689
-                        $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1690
-                        $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1689
+						$term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1690
+						$term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1691 1691
 
1692
-                        $post_title = $post_obj->title;
1693
-                        $title = str_replace($srcharr, $replarr, $post_title);
1692
+						$post_title = $post_obj->title;
1693
+						$title = str_replace($srcharr, $replarr, $post_title);
1694 1694
 
1695
-                        $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1696
-                        $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1695
+						$lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1696
+						$lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1697 1697
 
1698
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1699
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1698
+						$timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1699
+						$timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1700 1700
 
1701
-                        $json = '{';
1702
-                        $json .= '"id":"' . $post_id . '",';
1703
-                        $json .= '"lat_pos": "' . $lat . '",';
1704
-                        $json .= '"long_pos": "' . $lng . '",';
1705
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1706
-                        $json .= '"icon":"' . $term_icon . '",';
1707
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1708
-                        $json .= '}';
1701
+						$json = '{';
1702
+						$json .= '"id":"' . $post_id . '",';
1703
+						$json .= '"lat_pos": "' . $lat . '",';
1704
+						$json .= '"long_pos": "' . $lng . '",';
1705
+						$json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1706
+						$json .= '"icon":"' . $term_icon . '",';
1707
+						$json .= '"group":"catgroup' . $cat_id . '"';
1708
+						$json .= '}';
1709 1709
 
1710 1710
 
1711
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1712
-                            $post_marker_json = $json;
1711
+						if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1712
+							$post_marker_json = $json;
1713 1713
 
1714 1714
 
1715
-                        if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
1715
+						if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
1716 1716
 
1717
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1717
+							$json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1718 1718
 										post_title = %s,
1719 1719
 										json = %s
1720 1720
 										WHERE post_id = %d AND cat_id = %d ",
1721
-                                array($post_title, $json, $post_id, $cat_id));
1721
+								array($post_title, $json, $post_id, $cat_id));
1722 1722
 
1723
-                        } else {
1723
+						} else {
1724 1724
 
1725
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1725
+							$json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1726 1726
 										post_id = %d,
1727 1727
 										post_title = %s,
1728 1728
 										cat_id = %d,
1729 1729
 										json = %s",
1730
-                                array($post_id, $post_title, $cat_id, $json));
1730
+								array($post_id, $post_title, $cat_id, $json));
1731 1731
 
1732
-                        }
1732
+						}
1733 1733
 
1734
-                        $wpdb->query($json_query);
1734
+						$wpdb->query($json_query);
1735 1735
 
1736
-                    endforeach;
1736
+					endforeach;
1737 1737
 
1738
-                endif;
1738
+				endif;
1739 1739
 
1740
-                if (!empty($post_term) && is_array($post_term)) {
1741
-                    $categories = implode(',', $post_term);
1740
+				if (!empty($post_term) && is_array($post_term)) {
1741
+					$categories = implode(',', $post_term);
1742 1742
 
1743
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1743
+					if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1744 1744
 
1745
-                    if (empty($post_marker_json))
1746
-                        $post_marker_json = isset($json) ? $json : '';
1745
+					if (empty($post_marker_json))
1746
+						$post_marker_json = isset($json) ? $json : '';
1747 1747
 
1748
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1748
+					if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1749 1749
 
1750
-                        $wpdb->query(
1751
-                            $wpdb->prepare(
1752
-                                "UPDATE " . $table . " SET
1750
+						$wpdb->query(
1751
+							$wpdb->prepare(
1752
+								"UPDATE " . $table . " SET
1753 1753
 								" . $taxonomy . " = %s,
1754 1754
 								marker_json = %s
1755 1755
 								where post_id = %d",
1756
-                                array($categories, $post_marker_json, $post_id)
1757
-                            )
1758
-                        );
1756
+								array($categories, $post_marker_json, $post_id)
1757
+							)
1758
+						);
1759 1759
 
1760
-                        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1760
+						if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1761 1761
 
1762
-                            $categories = trim($categories, ',');
1762
+							$categories = trim($categories, ',');
1763 1763
 
1764
-                            if ($categories) {
1764
+							if ($categories) {
1765 1765
 
1766
-                                $categories = explode(',', $categories);
1766
+								$categories = explode(',', $categories);
1767 1767
 
1768
-                                $default_category = geodir_get_post_meta($post_id, 'default_category', true);
1768
+								$default_category = geodir_get_post_meta($post_id, 'default_category', true);
1769 1769
 
1770
-                                if (!in_array($default_category, $categories)) {
1770
+								if (!in_array($default_category, $categories)) {
1771 1771
 
1772
-                                    $wpdb->query(
1773
-                                        $wpdb->prepare(
1774
-                                            "UPDATE " . $table . " SET
1772
+									$wpdb->query(
1773
+										$wpdb->prepare(
1774
+											"UPDATE " . $table . " SET
1775 1775
 											default_category = %s
1776 1776
 											where post_id = %d",
1777
-                                            array($categories[0], $post_id)
1778
-                                        )
1779
-                                    );
1777
+											array($categories[0], $post_id)
1778
+										)
1779
+									);
1780 1780
 
1781
-                                    $default_category = $categories[0];
1781
+									$default_category = $categories[0];
1782 1782
 
1783
-                                }
1783
+								}
1784 1784
 
1785
-                                if ($default_category == '')
1786
-                                    $default_category = $categories[0];
1785
+								if ($default_category == '')
1786
+									$default_category = $categories[0];
1787 1787
 
1788
-                                geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1788
+								geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1789 1789
 
1790
-                            }
1790
+							}
1791 1791
 
1792
-                        }
1792
+						}
1793 1793
 
1794 1794
 
1795
-                    } else {
1795
+					} else {
1796 1796
 
1797
-                        $wpdb->query(
1798
-                            $wpdb->prepare(
1799
-                                "INSERT INTO " . $table . " SET
1797
+						$wpdb->query(
1798
+							$wpdb->prepare(
1799
+								"INSERT INTO " . $table . " SET
1800 1800
 								post_id = %d,
1801 1801
 								" . $taxonomy . " = %s,
1802 1802
 								marker_json = %s ",
1803 1803
 
1804
-                                array($post_id, $categories, $post_marker_json)
1805
-                            )
1806
-                        );
1807
-                    }
1808
-                }
1809
-            }
1810
-        }
1811
-    }
1804
+								array($post_id, $categories, $post_marker_json)
1805
+							)
1806
+						);
1807
+					}
1808
+				}
1809
+			}
1810
+		}
1811
+	}
1812 1812
 }
1813 1813
 
1814 1814
 if (!function_exists('geodir_get_infowindow_html')) {
1815
-    /**
1816
-     * Set post Map Marker info html.
1817
-     *
1818
-     * @since 1.0.0
1819
-     * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1820
-     * @package GeoDirectory
1821
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
1822
-     * @global object $gd_session GeoDirectory Session object.
1823
-     * @param object $postinfo_obj The post details object.
1824
-     * @param string $post_preview Is this a post preview?.
1825
-     * @return mixed|string|void
1826
-     */
1827
-    function geodir_get_infowindow_html($postinfo_obj, $post_preview = '')
1828
-    {
1829
-        global $preview, $gd_session;
1830
-        $srcharr = array("'", "/", "-", '"', '\\');
1831
-        $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1832
-
1833
-        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1834
-            $ID = '';
1835
-            $plink = '';
1836
-
1837
-            if (isset($postinfo_obj->pid)) {
1838
-                $ID = $postinfo_obj->pid;
1839
-                $plink = get_permalink($ID);
1840
-            }
1841
-
1842
-            $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1843
-            $lat = $postinfo_obj->post_latitude;
1844
-            $lng = $postinfo_obj->post_longitude;
1845
-            $address = str_replace($srcharr, $replarr, ($postinfo_obj->post_address));
1846
-            $contact = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_contact));
1847
-            $timing = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_timing));
1848
-        } else {
1849
-            $ID = $postinfo_obj->post_id;
1850
-            $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1851
-            $plink = get_permalink($ID);
1852
-            $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1853
-            $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1854
-            $address = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'post_address', true), ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1855
-            $contact = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'geodir_contact', true), ENT_COMPAT, 'UTF-8'));
1856
-            $timing = str_replace($srcharr, $replarr, (geodir_get_post_meta($ID, 'geodir_timing', true)));
1857
-        }
1858
-
1859
-        // filter field as per price package
1860
-        global $geodir_addon_list;
1861
-        if (isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
1862
-            $post_type = get_post_type($ID);
1863
-            $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1864
-            $field_name = 'geodir_contact';
1865
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1866
-                $contact = '';
1867
-            }
1868
-
1869
-            $field_name = 'geodir_timing';
1870
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1871
-                $timing = '';
1872
-            }
1873
-        }
1874
-
1875
-        if ($lat && $lng) {
1876
-            ob_start(); ?>
1815
+	/**
1816
+	 * Set post Map Marker info html.
1817
+	 *
1818
+	 * @since 1.0.0
1819
+	 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1820
+	 * @package GeoDirectory
1821
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
1822
+	 * @global object $gd_session GeoDirectory Session object.
1823
+	 * @param object $postinfo_obj The post details object.
1824
+	 * @param string $post_preview Is this a post preview?.
1825
+	 * @return mixed|string|void
1826
+	 */
1827
+	function geodir_get_infowindow_html($postinfo_obj, $post_preview = '')
1828
+	{
1829
+		global $preview, $gd_session;
1830
+		$srcharr = array("'", "/", "-", '"', '\\');
1831
+		$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1832
+
1833
+		if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1834
+			$ID = '';
1835
+			$plink = '';
1836
+
1837
+			if (isset($postinfo_obj->pid)) {
1838
+				$ID = $postinfo_obj->pid;
1839
+				$plink = get_permalink($ID);
1840
+			}
1841
+
1842
+			$title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1843
+			$lat = $postinfo_obj->post_latitude;
1844
+			$lng = $postinfo_obj->post_longitude;
1845
+			$address = str_replace($srcharr, $replarr, ($postinfo_obj->post_address));
1846
+			$contact = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_contact));
1847
+			$timing = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_timing));
1848
+		} else {
1849
+			$ID = $postinfo_obj->post_id;
1850
+			$title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1851
+			$plink = get_permalink($ID);
1852
+			$lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1853
+			$lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1854
+			$address = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'post_address', true), ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1855
+			$contact = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'geodir_contact', true), ENT_COMPAT, 'UTF-8'));
1856
+			$timing = str_replace($srcharr, $replarr, (geodir_get_post_meta($ID, 'geodir_timing', true)));
1857
+		}
1858
+
1859
+		// filter field as per price package
1860
+		global $geodir_addon_list;
1861
+		if (isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
1862
+			$post_type = get_post_type($ID);
1863
+			$package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1864
+			$field_name = 'geodir_contact';
1865
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1866
+				$contact = '';
1867
+			}
1868
+
1869
+			$field_name = 'geodir_timing';
1870
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1871
+				$timing = '';
1872
+			}
1873
+		}
1874
+
1875
+		if ($lat && $lng) {
1876
+			ob_start(); ?>
1877 1877
             <div class="gd-bubble" style="">
1878 1878
                 <div class="gd-bubble-inside">
1879 1879
                     <?php
1880
-                    $comment_count = '';
1881
-                    $rating_star = '';
1882
-                    if ($ID != '') {
1883
-                        $rating_star = '';
1884
-                        $comment_count = geodir_get_review_count_total($ID);
1885
-
1886
-                        if (!$preview) {
1887
-                            $post_avgratings = geodir_get_post_rating($ID);
1888
-
1889
-                            $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1890
-
1891
-                            /**
1892
-                             * Filter to change rating stars
1893
-                             *
1894
-                             * You can use this filter to change Rating stars.
1895
-                             *
1896
-                             * @since 1.0.0
1897
-                             * @package GeoDirectory
1898
-                             * @param string $rating_star Rating stars.
1899
-                             * @param float $post_avgratings Average ratings of the post.
1900
-                             * @param int $ID The post ID.
1901
-                             */
1902
-                            $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1903
-                        }
1904
-                    }
1905
-                    ?>
1880
+					$comment_count = '';
1881
+					$rating_star = '';
1882
+					if ($ID != '') {
1883
+						$rating_star = '';
1884
+						$comment_count = geodir_get_review_count_total($ID);
1885
+
1886
+						if (!$preview) {
1887
+							$post_avgratings = geodir_get_post_rating($ID);
1888
+
1889
+							$rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1890
+
1891
+							/**
1892
+							 * Filter to change rating stars
1893
+							 *
1894
+							 * You can use this filter to change Rating stars.
1895
+							 *
1896
+							 * @since 1.0.0
1897
+							 * @package GeoDirectory
1898
+							 * @param string $rating_star Rating stars.
1899
+							 * @param float $post_avgratings Average ratings of the post.
1900
+							 * @param int $ID The post ID.
1901
+							 */
1902
+							$rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1903
+						}
1904
+					}
1905
+					?>
1906 1906
                     <div class="geodir-bubble_desc">
1907 1907
                         <h4>
1908 1908
                             <a href="<?php if ($plink != '') {
1909
-                                echo $plink;
1910
-                            } else {
1911
-                                echo 'javascript:void(0);';
1912
-                            } ?>"><?php echo $title; ?></a>
1909
+								echo $plink;
1910
+							} else {
1911
+								echo 'javascript:void(0);';
1912
+							} ?>"><?php echo $title; ?></a>
1913 1913
                         </h4>
1914 1914
                         <?php
1915
-                        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1916
-                            $post_images = array();
1917
-                            if (!empty($postinfo_obj->post_images)) {
1918
-                                $post_images = explode(",", $postinfo_obj->post_images);
1919
-                            }
1920
-
1921
-                            if (!empty($post_images)) {
1922
-                                ?>
1915
+						if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1916
+							$post_images = array();
1917
+							if (!empty($postinfo_obj->post_images)) {
1918
+								$post_images = explode(",", $postinfo_obj->post_images);
1919
+							}
1920
+
1921
+							if (!empty($post_images)) {
1922
+								?>
1923 1923
                                 <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
1924
-                                        echo $plink;
1925
-                                    } else {
1926
-                                        echo 'javascript:void(0);';
1927
-                                    } ?>"><img alt="bubble image" style="max-height:50px;"
1924
+										echo $plink;
1925
+									} else {
1926
+										echo 'javascript:void(0);';
1927
+									} ?>"><img alt="bubble image" style="max-height:50px;"
1928 1928
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1929 1929
                             <?php
1930
-                            }else{
1931
-                                echo '<div class="geodir-bubble_image"></div>';
1932
-                            }
1933
-                        } else {
1934
-                            if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1935
-                                ?>
1930
+							}else{
1931
+								echo '<div class="geodir-bubble_image"></div>';
1932
+							}
1933
+						} else {
1934
+							if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1935
+								?>
1936 1936
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1937 1937
                             <?php
1938
-                            }else{
1939
-                                echo '<div class="geodir-bubble_image"></div>';
1940
-                            }
1941
-                        }
1942
-                        ?>
1938
+							}else{
1939
+								echo '<div class="geodir-bubble_image"></div>';
1940
+							}
1941
+						}
1942
+						?>
1943 1943
                         <div class="geodir-bubble-meta-side">
1944 1944
                             <?php
1945
-                            /**
1946
-                             * Fires before the meta info in the map info window.
1947
-                             *
1948
-                             * This can be used to add more info to the map info window before the normal meta info.
1949
-                             *
1950
-                             * @since 1.5.4
1951
-                             * @param int $ID The post id.
1952
-                             * @param object $postinfo_obj The posts info as an object.
1953
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1954
-                             */
1955
-                            do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1956
-                            ?>
1945
+							/**
1946
+							 * Fires before the meta info in the map info window.
1947
+							 *
1948
+							 * This can be used to add more info to the map info window before the normal meta info.
1949
+							 *
1950
+							 * @since 1.5.4
1951
+							 * @param int $ID The post id.
1952
+							 * @param object $postinfo_obj The posts info as an object.
1953
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1954
+							 */
1955
+							do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1956
+							?>
1957 1957
                             <span class="geodir_address"><i class="fa fa-home"></i> <?php echo $address; ?></span>
1958 1958
                             <?php if ($contact) { ?><span class="geodir_contact"><i
1959 1959
                                 class="fa fa-phone"></i>
1960 1960
                                 <?php
1961
-                                $tel_link = apply_filters('geodir_map_bubble_tel_linkable', false);
1962
-                                if ($tel_link) {
1963
-                                    ?>
1961
+								$tel_link = apply_filters('geodir_map_bubble_tel_linkable', false);
1962
+								if ($tel_link) {
1963
+									?>
1964 1964
                                     <a href="tel:<?php echo preg_replace('/[^0-9+]/', '', $contact); ?>"><?php echo stripslashes($contact); ?></a>
1965 1965
                                     <?php
1966
-                                } else {
1967
-                                    echo $contact;
1968
-                                }
1969
-                                ?>
1966
+								} else {
1967
+									echo $contact;
1968
+								}
1969
+								?>
1970 1970
                                 </span><?php } ?>
1971 1971
                             <?php if ($timing) { ?><span class="geodir_timing"><i
1972 1972
                                 class="fa fa-clock-o"></i> <?php echo $timing; ?></span><?php }
1973 1973
 
1974
-                            /**
1975
-                             * Fires after the meta info in the map info window.
1976
-                             *
1977
-                             * This can be used to add more info to the map info window after the normal meta info.
1978
-                             *
1979
-                             * @since 1.4.2
1980
-                             * @param object $postinfo_obj The posts info as an object.
1981
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1982
-                             */
1983
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1984
-                            ?>
1974
+							/**
1975
+							 * Fires after the meta info in the map info window.
1976
+							 *
1977
+							 * This can be used to add more info to the map info window after the normal meta info.
1978
+							 *
1979
+							 * @since 1.4.2
1980
+							 * @param object $postinfo_obj The posts info as an object.
1981
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1982
+							 */
1983
+							do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1984
+							?>
1985 1985
                         </div>
1986 1986
                         <?php
1987 1987
 
1988
-                        if ($ID) {
1988
+						if ($ID) {
1989 1989
 
1990
-                            $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
1991
-                            ?>
1990
+							$post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
1991
+							?>
1992 1992
                             <div class="geodir-bubble-meta-fade"></div>
1993 1993
 
1994 1994
                             <div class="geodir-bubble-meta-bottom">
@@ -2008,69 +2008,69 @@  discard block
 block discarded – undo
2008 2008
                 </div>
2009 2009
             </div>
2010 2010
             <?php
2011
-            $html = ob_get_clean();
2012
-            /**
2013
-             * Filter to change infowindow html
2014
-             *
2015
-             * You can use this filter to change infowindow html.
2016
-             *
2017
-             * @since 1.0.0
2018
-             * @package GeoDirectory
2019
-             * @param string $html Infowindow html.
2020
-             * @param object $postinfo_obj The Post object.
2021
-             * @param bool|string $post_preview Is this a post preview?
2022
-             */
2023
-            $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2024
-            return $html;
2025
-        }
2026
-    }
2011
+			$html = ob_get_clean();
2012
+			/**
2013
+			 * Filter to change infowindow html
2014
+			 *
2015
+			 * You can use this filter to change infowindow html.
2016
+			 *
2017
+			 * @since 1.0.0
2018
+			 * @package GeoDirectory
2019
+			 * @param string $html Infowindow html.
2020
+			 * @param object $postinfo_obj The Post object.
2021
+			 * @param bool|string $post_preview Is this a post preview?
2022
+			 */
2023
+			$html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2024
+			return $html;
2025
+		}
2026
+	}
2027 2027
 }
2028 2028
 
2029 2029
 
2030 2030
 if (!function_exists('geodir_new_post_default_status')) {
2031
-    /**
2032
-     * Default post status for new posts.
2033
-     *
2034
-     * @since 1.0.0
2035
-     * @package GeoDirectory
2036
-     * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2037
-     */
2038
-    function geodir_new_post_default_status()
2039
-    {
2040
-        if (get_option('geodir_new_post_default_status'))
2041
-            return get_option('geodir_new_post_default_status');
2042
-        else
2043
-            return 'publish';
2044
-
2045
-    }
2031
+	/**
2032
+	 * Default post status for new posts.
2033
+	 *
2034
+	 * @since 1.0.0
2035
+	 * @package GeoDirectory
2036
+	 * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2037
+	 */
2038
+	function geodir_new_post_default_status()
2039
+	{
2040
+		if (get_option('geodir_new_post_default_status'))
2041
+			return get_option('geodir_new_post_default_status');
2042
+		else
2043
+			return 'publish';
2044
+
2045
+	}
2046 2046
 }
2047 2047
 
2048 2048
 if (!function_exists('geodir_change_post_status')) {
2049
-    /**
2050
-     * Change post status of a post.
2051
-     *
2052
-     * @global object $wpdb WordPress Database object.
2053
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2054
-     * @param int|string $post_id The post ID.
2055
-     * @param string $status New post status. Ex: draft, publish etc.
2056
-     */
2057
-    function geodir_change_post_status($post_id = '', $status = '')
2058
-    {
2059
-        global $wpdb, $plugin_prefix;
2060
-
2061
-        $post_type = get_post_type($post_id);
2062
-
2063
-        $table = $plugin_prefix . $post_type . '_detail';
2064
-
2065
-        $wpdb->query(
2066
-            $wpdb->prepare(
2067
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2068
-                array($status, $post_id)
2069
-            )
2070
-        );
2071
-
2072
-
2073
-    }
2049
+	/**
2050
+	 * Change post status of a post.
2051
+	 *
2052
+	 * @global object $wpdb WordPress Database object.
2053
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2054
+	 * @param int|string $post_id The post ID.
2055
+	 * @param string $status New post status. Ex: draft, publish etc.
2056
+	 */
2057
+	function geodir_change_post_status($post_id = '', $status = '')
2058
+	{
2059
+		global $wpdb, $plugin_prefix;
2060
+
2061
+		$post_type = get_post_type($post_id);
2062
+
2063
+		$table = $plugin_prefix . $post_type . '_detail';
2064
+
2065
+		$wpdb->query(
2066
+			$wpdb->prepare(
2067
+				"UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2068
+				array($status, $post_id)
2069
+			)
2070
+		);
2071
+
2072
+
2073
+	}
2074 2074
 }
2075 2075
 
2076 2076
 /**
@@ -2084,13 +2084,13 @@  discard block
 block discarded – undo
2084 2084
  */
2085 2085
 function geodir_set_post_status($pid, $status)
2086 2086
 {
2087
-    if ($pid) {
2088
-        global $wpdb;
2089
-        $my_post = array();
2090
-        $my_post['post_status'] = $status;
2091
-        $my_post['ID'] = $pid;
2092
-        $last_postid = wp_update_post($my_post);
2093
-    }
2087
+	if ($pid) {
2088
+		global $wpdb;
2089
+		$my_post = array();
2090
+		$my_post['post_status'] = $status;
2091
+		$my_post['ID'] = $pid;
2092
+		$last_postid = wp_update_post($my_post);
2093
+	}
2094 2094
 }
2095 2095
 
2096 2096
 
@@ -2106,384 +2106,384 @@  discard block
 block discarded – undo
2106 2106
  */
2107 2107
 function geodir_update_poststatus($new_status, $old_status, $post)
2108 2108
 {
2109
-    global $wpdb;
2109
+	global $wpdb;
2110 2110
 
2111
-    $geodir_posttypes = geodir_get_posttypes();
2111
+	$geodir_posttypes = geodir_get_posttypes();
2112 2112
 
2113
-    if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2113
+	if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2114 2114
 
2115
-        geodir_change_post_status($post->ID, $new_status);
2116
-    }
2115
+		geodir_change_post_status($post->ID, $new_status);
2116
+	}
2117 2117
 }
2118 2118
 
2119 2119
 
2120 2120
 if (!function_exists('geodir_update_listing_info')) {
2121
-    /**
2122
-     * Update post info.
2123
-     *
2124
-     * @since 1.0.0
2125
-     * @package GeoDirectory
2126
-     * @global object $wpdb WordPress Database object.
2127
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2128
-     * @param int $updatingpost The updating post ID.
2129
-     * @param int $temppost The temporary post ID.
2130
-     * @todo fix post_id variable
2131
-     */
2132
-    function geodir_update_listing_info($updatingpost, $temppost)
2133
-    {
2134
-
2135
-        global $wpdb, $plugin_prefix;
2136
-
2137
-        $post_type = get_post_type($post_id);
2138
-
2139
-        $table = $plugin_prefix . $post_type . '_detail';
2140
-
2141
-        $wpdb->query(
2142
-            $wpdb->prepare(
2143
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2144
-                array($updatingpost, $temppost)
2145
-            )
2146
-        );
2147
-
2148
-        $wpdb->query(
2149
-            $wpdb->prepare(
2150
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2151
-                array($updatingpost, $temppost)
2152
-            )
2153
-        );
2154
-
2155
-        /* Update Attachments*/
2156
-
2157
-        $wpdb->query(
2158
-            $wpdb->prepare(
2159
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2160
-                array($updatingpost, $temppost)
2161
-            )
2162
-        );
2163
-
2164
-    }
2121
+	/**
2122
+	 * Update post info.
2123
+	 *
2124
+	 * @since 1.0.0
2125
+	 * @package GeoDirectory
2126
+	 * @global object $wpdb WordPress Database object.
2127
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2128
+	 * @param int $updatingpost The updating post ID.
2129
+	 * @param int $temppost The temporary post ID.
2130
+	 * @todo fix post_id variable
2131
+	 */
2132
+	function geodir_update_listing_info($updatingpost, $temppost)
2133
+	{
2134
+
2135
+		global $wpdb, $plugin_prefix;
2136
+
2137
+		$post_type = get_post_type($post_id);
2138
+
2139
+		$table = $plugin_prefix . $post_type . '_detail';
2140
+
2141
+		$wpdb->query(
2142
+			$wpdb->prepare(
2143
+				"UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2144
+				array($updatingpost, $temppost)
2145
+			)
2146
+		);
2147
+
2148
+		$wpdb->query(
2149
+			$wpdb->prepare(
2150
+				"UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2151
+				array($updatingpost, $temppost)
2152
+			)
2153
+		);
2154
+
2155
+		/* Update Attachments*/
2156
+
2157
+		$wpdb->query(
2158
+			$wpdb->prepare(
2159
+				"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2160
+				array($updatingpost, $temppost)
2161
+			)
2162
+		);
2163
+
2164
+	}
2165 2165
 }
2166 2166
 
2167 2167
 
2168 2168
 if (!function_exists('geodir_delete_listing_info')) {
2169
-    /**
2170
-     * Delete Listing info from details table for the given post id.
2171
-     *
2172
-     * @since 1.0.0
2173
-     * @package GeoDirectory
2174
-     * @global object $wpdb WordPress Database object.
2175
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2176
-     * @param int $deleted_postid The post ID.
2177
-     * @param bool $force Optional. Do you want to force delete it? Default: false.
2178
-     * @return bool|void
2179
-     */
2180
-    function geodir_delete_listing_info($deleted_postid, $force = false)
2181
-    {
2182
-        global $wpdb, $plugin_prefix;
2183
-
2184
-        // check for multisite deletions
2185
-        if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2186
-        } else {
2187
-            return;
2188
-        }
2189
-
2190
-        $post_type = get_post_type($deleted_postid);
2191
-
2192
-        $all_postypes = geodir_get_posttypes();
2193
-
2194
-        if (!in_array($post_type, $all_postypes))
2195
-            return false;
2196
-
2197
-        $table = $plugin_prefix . $post_type . '_detail';
2198
-
2199
-        /* Delete custom post meta*/
2200
-        $wpdb->query(
2201
-            $wpdb->prepare(
2202
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2203
-                array($deleted_postid)
2204
-            )
2205
-        );
2206
-
2207
-        /* Delete post map icons*/
2208
-
2209
-        $wpdb->query(
2210
-            $wpdb->prepare(
2211
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2212
-                array($deleted_postid)
2213
-            )
2214
-        );
2215
-
2216
-        /* Delete Attachments*/
2217
-        $postcurr_images = geodir_get_images($deleted_postid);
2218
-
2219
-        $wpdb->query(
2220
-            $wpdb->prepare(
2221
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2222
-                array($deleted_postid)
2223
-            )
2224
-        );
2225
-        geodir_remove_attachments($postcurr_images);
2226
-
2227
-    }
2169
+	/**
2170
+	 * Delete Listing info from details table for the given post id.
2171
+	 *
2172
+	 * @since 1.0.0
2173
+	 * @package GeoDirectory
2174
+	 * @global object $wpdb WordPress Database object.
2175
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2176
+	 * @param int $deleted_postid The post ID.
2177
+	 * @param bool $force Optional. Do you want to force delete it? Default: false.
2178
+	 * @return bool|void
2179
+	 */
2180
+	function geodir_delete_listing_info($deleted_postid, $force = false)
2181
+	{
2182
+		global $wpdb, $plugin_prefix;
2183
+
2184
+		// check for multisite deletions
2185
+		if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2186
+		} else {
2187
+			return;
2188
+		}
2189
+
2190
+		$post_type = get_post_type($deleted_postid);
2191
+
2192
+		$all_postypes = geodir_get_posttypes();
2193
+
2194
+		if (!in_array($post_type, $all_postypes))
2195
+			return false;
2196
+
2197
+		$table = $plugin_prefix . $post_type . '_detail';
2198
+
2199
+		/* Delete custom post meta*/
2200
+		$wpdb->query(
2201
+			$wpdb->prepare(
2202
+				"DELETE FROM " . $table . " WHERE `post_id` = %d",
2203
+				array($deleted_postid)
2204
+			)
2205
+		);
2206
+
2207
+		/* Delete post map icons*/
2208
+
2209
+		$wpdb->query(
2210
+			$wpdb->prepare(
2211
+				"DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2212
+				array($deleted_postid)
2213
+			)
2214
+		);
2215
+
2216
+		/* Delete Attachments*/
2217
+		$postcurr_images = geodir_get_images($deleted_postid);
2218
+
2219
+		$wpdb->query(
2220
+			$wpdb->prepare(
2221
+				"DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2222
+				array($deleted_postid)
2223
+			)
2224
+		);
2225
+		geodir_remove_attachments($postcurr_images);
2226
+
2227
+	}
2228 2228
 }
2229 2229
 
2230 2230
 
2231 2231
 if (!function_exists('geodir_add_to_favorite')) {
2232
-    /**
2233
-     * This function would add listing to favorite listing.
2234
-     *
2235
-     * @since 1.0.0
2236
-     * @package GeoDirectory
2237
-     * @global object $current_user Current user object.
2238
-     * @param int $post_id The post ID.
2239
-     */
2240
-    function geodir_add_to_favorite($post_id)
2241
-    {
2242
-
2243
-        global $current_user;
2244
-
2245
-        /**
2246
-         * Filter to modify "Unfavorite" text
2247
-         *
2248
-         * You can use this filter to rename "Unfavorite" text to something else.
2249
-         *
2250
-         * @since 1.0.0
2251
-         * @package GeoDirectory
2252
-         */
2253
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2254
-
2255
-        /**
2256
-         * Filter to modify "Remove from Favorites" text
2257
-         *
2258
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2259
-         *
2260
-         * @since 1.0.0
2261
-         * @package GeoDirectory
2262
-         */
2263
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2264
-
2265
-        /**
2266
-         * Filter to modify "fa fa-heart" icon
2267
-         *
2268
-         * You can use this filter to change "fa fa-heart" icon to something else.
2269
-         *
2270
-         * @since 1.0.0
2271
-         * @package GeoDirectory
2272
-         */
2273
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2274
-
2275
-        $user_meta_data = array();
2276
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2232
+	/**
2233
+	 * This function would add listing to favorite listing.
2234
+	 *
2235
+	 * @since 1.0.0
2236
+	 * @package GeoDirectory
2237
+	 * @global object $current_user Current user object.
2238
+	 * @param int $post_id The post ID.
2239
+	 */
2240
+	function geodir_add_to_favorite($post_id)
2241
+	{
2242
+
2243
+		global $current_user;
2244
+
2245
+		/**
2246
+		 * Filter to modify "Unfavorite" text
2247
+		 *
2248
+		 * You can use this filter to rename "Unfavorite" text to something else.
2249
+		 *
2250
+		 * @since 1.0.0
2251
+		 * @package GeoDirectory
2252
+		 */
2253
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2254
+
2255
+		/**
2256
+		 * Filter to modify "Remove from Favorites" text
2257
+		 *
2258
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2259
+		 *
2260
+		 * @since 1.0.0
2261
+		 * @package GeoDirectory
2262
+		 */
2263
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2264
+
2265
+		/**
2266
+		 * Filter to modify "fa fa-heart" icon
2267
+		 *
2268
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2269
+		 *
2270
+		 * @since 1.0.0
2271
+		 * @package GeoDirectory
2272
+		 */
2273
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2274
+
2275
+		$user_meta_data = array();
2276
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2277
+
2278
+		if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2279
+			$user_meta_data[] = $post_id;
2280
+		}
2281
+
2282
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2283
+
2284
+		/**
2285
+		 * Called before adding the post from favourites.
2286
+		 *
2287
+		 * @since 1.0.0
2288
+		 * @package GeoDirectory
2289
+		 * @param int $post_id The post ID.
2290
+		 */
2291
+		do_action('geodir_before_add_from_favorite', $post_id);
2292
+
2293
+		echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-addtofav geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2294
+
2295
+		/**
2296
+		 * Called after adding the post from favourites.
2297
+		 *
2298
+		 * @since 1.0.0
2299
+		 * @package GeoDirectory
2300
+		 * @param int $post_id The post ID.
2301
+		 */
2302
+		do_action('geodir_after_add_from_favorite', $post_id);
2277 2303
 
2278
-        if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2279
-            $user_meta_data[] = $post_id;
2280
-        }
2281
-
2282
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2283
-
2284
-        /**
2285
-         * Called before adding the post from favourites.
2286
-         *
2287
-         * @since 1.0.0
2288
-         * @package GeoDirectory
2289
-         * @param int $post_id The post ID.
2290
-         */
2291
-        do_action('geodir_before_add_from_favorite', $post_id);
2292
-
2293
-        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-addtofav geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2294
-
2295
-        /**
2296
-         * Called after adding the post from favourites.
2297
-         *
2298
-         * @since 1.0.0
2299
-         * @package GeoDirectory
2300
-         * @param int $post_id The post ID.
2301
-         */
2302
-        do_action('geodir_after_add_from_favorite', $post_id);
2303
-
2304
-    }
2304
+	}
2305 2305
 }
2306 2306
 
2307 2307
 if (!function_exists('geodir_remove_from_favorite')) {
2308
-    /**
2309
-     * This function would remove the favourited property earlier.
2310
-     *
2311
-     * @since 1.0.0
2312
-     * @package GeoDirectory
2313
-     * @global object $current_user Current user object.
2314
-     * @param int $post_id The post ID.
2315
-     */
2316
-    function geodir_remove_from_favorite($post_id)
2317
-    {
2318
-        global $current_user;
2319
-
2320
-        /**
2321
-         * Filter to modify "Add to Favorites" text
2322
-         *
2323
-         * You can use this filter to rename "Add to Favorites" text to something else.
2324
-         *
2325
-         * @since 1.0.0
2326
-         * @package GeoDirectory
2327
-         */
2328
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2329
-
2330
-        /**
2331
-         * Filter to modify "Favourite" text
2332
-         *
2333
-         * You can use this filter to rename "Favourite" text to something else.
2334
-         *
2335
-         * @since 1.0.0
2336
-         * @package GeoDirectory
2337
-         */
2338
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2339
-
2340
-        /**
2341
-         * Filter to modify "fa fa-heart" icon
2342
-         *
2343
-         * You can use this filter to change "fa fa-heart" icon to something else.
2344
-         *
2345
-         * @since 1.0.0
2346
-         * @package GeoDirectory
2347
-         */
2348
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2349
-
2350
-        $user_meta_data = array();
2351
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2352
-
2353
-        if (!empty($user_meta_data)) {
2354
-
2355
-            if (($key = array_search($post_id, $user_meta_data)) !== false) {
2356
-                unset($user_meta_data[$key]);
2357
-            }
2308
+	/**
2309
+	 * This function would remove the favourited property earlier.
2310
+	 *
2311
+	 * @since 1.0.0
2312
+	 * @package GeoDirectory
2313
+	 * @global object $current_user Current user object.
2314
+	 * @param int $post_id The post ID.
2315
+	 */
2316
+	function geodir_remove_from_favorite($post_id)
2317
+	{
2318
+		global $current_user;
2319
+
2320
+		/**
2321
+		 * Filter to modify "Add to Favorites" text
2322
+		 *
2323
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2324
+		 *
2325
+		 * @since 1.0.0
2326
+		 * @package GeoDirectory
2327
+		 */
2328
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2329
+
2330
+		/**
2331
+		 * Filter to modify "Favourite" text
2332
+		 *
2333
+		 * You can use this filter to rename "Favourite" text to something else.
2334
+		 *
2335
+		 * @since 1.0.0
2336
+		 * @package GeoDirectory
2337
+		 */
2338
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2339
+
2340
+		/**
2341
+		 * Filter to modify "fa fa-heart" icon
2342
+		 *
2343
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2344
+		 *
2345
+		 * @since 1.0.0
2346
+		 * @package GeoDirectory
2347
+		 */
2348
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2349
+
2350
+		$user_meta_data = array();
2351
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2352
+
2353
+		if (!empty($user_meta_data)) {
2354
+
2355
+			if (($key = array_search($post_id, $user_meta_data)) !== false) {
2356
+				unset($user_meta_data[$key]);
2357
+			}
2358 2358
 
2359
-        }
2359
+		}
2360 2360
 
2361
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2361
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2362 2362
 
2363
-        /**
2364
-         * Called before removing the post from favourites.
2365
-         *
2366
-         * @since 1.0.0
2367
-         * @package GeoDirectory
2368
-         * @param int $post_id The post ID.
2369
-         */
2370
-        do_action('geodir_before_remove_from_favorite', $post_id);
2363
+		/**
2364
+		 * Called before removing the post from favourites.
2365
+		 *
2366
+		 * @since 1.0.0
2367
+		 * @package GeoDirectory
2368
+		 * @param int $post_id The post ID.
2369
+		 */
2370
+		do_action('geodir_before_remove_from_favorite', $post_id);
2371 2371
 
2372
-        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2372
+		echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2373 2373
 
2374
-        /**
2375
-         * Called after removing the post from favourites.
2376
-         *
2377
-         * @since 1.0.0
2378
-         * @package GeoDirectory
2379
-         * @param int $post_id The post ID.
2380
-         */
2381
-        do_action('geodir_after_remove_from_favorite', $post_id);
2374
+		/**
2375
+		 * Called after removing the post from favourites.
2376
+		 *
2377
+		 * @since 1.0.0
2378
+		 * @package GeoDirectory
2379
+		 * @param int $post_id The post ID.
2380
+		 */
2381
+		do_action('geodir_after_remove_from_favorite', $post_id);
2382 2382
 
2383
-    }
2383
+	}
2384 2384
 }
2385 2385
 
2386 2386
 if (!function_exists('geodir_favourite_html')) {
2387
-    /**
2388
-     * This function would display the html content for add to favorite or remove from favorite.
2389
-     *
2390
-     * @since 1.0.0
2391
-     * @package GeoDirectory
2392
-     * @global object $current_user Current user object.
2393
-     * @global object $post The current post object.
2394
-     * @param int $user_id The user ID.
2395
-     * @param int $post_id The post ID.
2396
-     */
2397
-    function geodir_favourite_html($user_id, $post_id)
2398
-    {
2399
-
2400
-        global $current_user, $post;
2401
-
2402
-        /**
2403
-         * Filter to modify "Add to Favorites" text
2404
-         *
2405
-         * You can use this filter to rename "Add to Favorites" text to something else.
2406
-         *
2407
-         * @since 1.0.0
2408
-         * @package GeoDirectory
2409
-         */
2410
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2411
-
2412
-        /**
2413
-         * Filter to modify "Favourite" text
2414
-         *
2415
-         * You can use this filter to rename "Favourite" text to something else.
2416
-         *
2417
-         * @since 1.0.0
2418
-         * @package GeoDirectory
2419
-         */
2420
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2421
-
2422
-        /**
2423
-         * Filter to modify "Unfavorite" text
2424
-         *
2425
-         * You can use this filter to rename "Unfavorite" text to something else.
2426
-         *
2427
-         * @since 1.0.0
2428
-         * @package GeoDirectory
2429
-         */
2430
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2431
-
2432
-        /**
2433
-         * Filter to modify "Remove from Favorites" text
2434
-         *
2435
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2436
-         *
2437
-         * @since 1.0.0
2438
-         * @package GeoDirectory
2439
-         */
2440
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2441
-
2442
-        /**
2443
-         * Filter to modify "fa fa-heart" icon
2444
-         *
2445
-         * You can use this filter to change "fa fa-heart" icon to something else.
2446
-         *
2447
-         * @since 1.0.0
2448
-         * @package GeoDirectory
2449
-         */
2450
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2451
-
2452
-        /**
2453
-         * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2454
-         *
2455
-         * You can use this filter to change "fa fa-heart" icon to something else.
2456
-         *
2457
-         * @since 1.0.0
2458
-         * @package GeoDirectory
2459
-         */
2460
-        $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2461
-
2462
-        $user_meta_data = '';
2463
-        if (isset($current_user->data->ID))
2464
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2465
-
2466
-        if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2467
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2387
+	/**
2388
+	 * This function would display the html content for add to favorite or remove from favorite.
2389
+	 *
2390
+	 * @since 1.0.0
2391
+	 * @package GeoDirectory
2392
+	 * @global object $current_user Current user object.
2393
+	 * @global object $post The current post object.
2394
+	 * @param int $user_id The user ID.
2395
+	 * @param int $post_id The post ID.
2396
+	 */
2397
+	function geodir_favourite_html($user_id, $post_id)
2398
+	{
2399
+
2400
+		global $current_user, $post;
2401
+
2402
+		/**
2403
+		 * Filter to modify "Add to Favorites" text
2404
+		 *
2405
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2406
+		 *
2407
+		 * @since 1.0.0
2408
+		 * @package GeoDirectory
2409
+		 */
2410
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2411
+
2412
+		/**
2413
+		 * Filter to modify "Favourite" text
2414
+		 *
2415
+		 * You can use this filter to rename "Favourite" text to something else.
2416
+		 *
2417
+		 * @since 1.0.0
2418
+		 * @package GeoDirectory
2419
+		 */
2420
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2421
+
2422
+		/**
2423
+		 * Filter to modify "Unfavorite" text
2424
+		 *
2425
+		 * You can use this filter to rename "Unfavorite" text to something else.
2426
+		 *
2427
+		 * @since 1.0.0
2428
+		 * @package GeoDirectory
2429
+		 */
2430
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2431
+
2432
+		/**
2433
+		 * Filter to modify "Remove from Favorites" text
2434
+		 *
2435
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2436
+		 *
2437
+		 * @since 1.0.0
2438
+		 * @package GeoDirectory
2439
+		 */
2440
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2441
+
2442
+		/**
2443
+		 * Filter to modify "fa fa-heart" icon
2444
+		 *
2445
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2446
+		 *
2447
+		 * @since 1.0.0
2448
+		 * @package GeoDirectory
2449
+		 */
2450
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2451
+
2452
+		/**
2453
+		 * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2454
+		 *
2455
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2456
+		 *
2457
+		 * @since 1.0.0
2458
+		 * @package GeoDirectory
2459
+		 */
2460
+		$unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2461
+
2462
+		$user_meta_data = '';
2463
+		if (isset($current_user->data->ID))
2464
+			$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2465
+
2466
+		if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2467
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2468 2468
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2469 2469
                 onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2470 2470
                 title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2471 2471
             </a>   </span><?php
2472 2472
 
2473
-        } else {
2473
+		} else {
2474 2474
 
2475
-            if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2476
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2477
-            } else
2478
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2475
+			if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2476
+				$script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2477
+			} else
2478
+				$script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2479 2479
 
2480
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2480
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2481 2481
                                                                                         href="javascript:void(0);"
2482 2482
                                                                                         onclick="<?php echo $script_text;?>"
2483 2483
                                                                                         title="<?php echo $add_favourite_text;?>"><i
2484 2484
                     class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2485 2485
         <?php }
2486
-    }
2486
+	}
2487 2487
 }
2488 2488
 
2489 2489
 
@@ -2500,54 +2500,54 @@  discard block
 block discarded – undo
2500 2500
 function geodir_get_cat_postcount($term = array())
2501 2501
 {
2502 2502
 
2503
-    if (!empty($term)) {
2503
+	if (!empty($term)) {
2504 2504
 
2505
-        global $wpdb, $plugin_prefix;
2505
+		global $wpdb, $plugin_prefix;
2506 2506
 
2507
-        $where = '';
2508
-        $join = '';
2509
-        if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2510
-            $taxonomy_obj = get_taxonomy($term->taxonomy);
2507
+		$where = '';
2508
+		$join = '';
2509
+		if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2510
+			$taxonomy_obj = get_taxonomy($term->taxonomy);
2511 2511
 
2512
-            $post_type = $taxonomy_obj->object_type[0];
2512
+			$post_type = $taxonomy_obj->object_type[0];
2513 2513
 
2514
-            $table = $plugin_prefix . $post_type . '_detail';
2514
+			$table = $plugin_prefix . $post_type . '_detail';
2515 2515
 
2516
-            /**
2517
-             * Filter to modify the 'join' query
2518
-             *
2519
-             * @since 1.0.0
2520
-             * @package GeoDirectory
2521
-             * @param object|array $term category / term object that need to be processed.
2522
-             * @param string $join The join query.
2523
-             */
2524
-            $join = apply_filters('geodir_cat_post_count_join', $join, $term);
2516
+			/**
2517
+			 * Filter to modify the 'join' query
2518
+			 *
2519
+			 * @since 1.0.0
2520
+			 * @package GeoDirectory
2521
+			 * @param object|array $term category / term object that need to be processed.
2522
+			 * @param string $join The join query.
2523
+			 */
2524
+			$join = apply_filters('geodir_cat_post_count_join', $join, $term);
2525 2525
 
2526
-            /**
2527
-             * Filter to modify the 'where' query
2528
-             *
2529
-             * @since 1.0.0
2530
-             * @package GeoDirectory
2531
-             * @param object|array $term category / term object that need to be processed.
2532
-             * @param string $where The where query.
2533
-             */
2534
-            $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2526
+			/**
2527
+			 * Filter to modify the 'where' query
2528
+			 *
2529
+			 * @since 1.0.0
2530
+			 * @package GeoDirectory
2531
+			 * @param object|array $term category / term object that need to be processed.
2532
+			 * @param string $where The where query.
2533
+			 */
2534
+			$where = apply_filters('geodir_cat_post_count_where', $where, $term);
2535 2535
 
2536
-            $count_query = "SELECT count(post_id) FROM
2536
+			$count_query = "SELECT count(post_id) FROM
2537 2537
 							" . $table . " as pd " . $join . "
2538 2538
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2539 2539
 
2540
-            $cat_post_count = $wpdb->get_var($count_query);
2541
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2542
-                $cat_post_count = 0;
2540
+			$cat_post_count = $wpdb->get_var($count_query);
2541
+			if (empty($cat_post_count) || is_wp_error($cat_post_count))
2542
+				$cat_post_count = 0;
2543 2543
 
2544
-            return $cat_post_count;
2544
+			return $cat_post_count;
2545 2545
 
2546
-        } else
2546
+		} else
2547 2547
 
2548
-            return $term->count;
2549
-    }
2550
-    return false;
2548
+			return $term->count;
2549
+	}
2550
+	return false;
2551 2551
 
2552 2552
 }
2553 2553
 
@@ -2560,17 +2560,17 @@  discard block
 block discarded – undo
2560 2560
  */
2561 2561
 function geodir_allow_post_type_frontend()
2562 2562
 {
2563
-    $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2563
+	$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2564 2564
 
2565
-    if (!is_admin() && isset($_REQUEST['listing_type'])
2566
-        && !empty($geodir_allow_posttype_frontend)
2567
-        && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2568
-    ) {
2565
+	if (!is_admin() && isset($_REQUEST['listing_type'])
2566
+		&& !empty($geodir_allow_posttype_frontend)
2567
+		&& !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2568
+	) {
2569 2569
 
2570
-        wp_redirect(home_url());
2571
-        exit;
2570
+		wp_redirect(home_url());
2571
+		exit;
2572 2572
 
2573
-    }
2573
+	}
2574 2574
 
2575 2575
 }
2576 2576
 
@@ -2587,20 +2587,20 @@  discard block
 block discarded – undo
2587 2587
  */
2588 2588
 function geodir_excerpt_length($length)
2589 2589
 {
2590
-    global $wp_query, $geodir_is_widget_listing;
2590
+	global $wp_query, $geodir_is_widget_listing;
2591 2591
 	if ($geodir_is_widget_listing) {
2592 2592
 		return $length;
2593 2593
 	}
2594 2594
 	
2595
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2596
-        $length = get_option('geodir_desc_word_limit');
2597
-    elseif (get_query_var('excerpt_length'))
2598
-        $length = get_query_var('excerpt_length');
2595
+	if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2596
+		$length = get_option('geodir_desc_word_limit');
2597
+	elseif (get_query_var('excerpt_length'))
2598
+		$length = get_query_var('excerpt_length');
2599 2599
 
2600
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2601
-        $length = get_option('geodir_author_desc_word_limit');
2600
+	if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2601
+		$length = get_option('geodir_author_desc_word_limit');
2602 2602
 
2603
-    return $length;
2603
+	return $length;
2604 2604
 }
2605 2605
 
2606 2606
 /**
@@ -2615,13 +2615,13 @@  discard block
 block discarded – undo
2615 2615
  */
2616 2616
 function geodir_excerpt_more($more)
2617 2617
 {
2618
-    global $post;
2619
-    $all_postypes = geodir_get_posttypes();
2620
-    if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2621
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2622
-    }
2618
+	global $post;
2619
+	$all_postypes = geodir_get_posttypes();
2620
+	if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2621
+		return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2622
+	}
2623 2623
 
2624
-    return $more;
2624
+	return $more;
2625 2625
 }
2626 2626
 
2627 2627
 
@@ -2638,63 +2638,63 @@  discard block
 block discarded – undo
2638 2638
  */
2639 2639
 function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
2640 2640
 {
2641
-    global $plugin_prefix, $wpdb;
2641
+	global $plugin_prefix, $wpdb;
2642 2642
 
2643
-    $gd_taxonomies = geodir_get_taxonomies();
2643
+	$gd_taxonomies = geodir_get_taxonomies();
2644 2644
 
2645
-    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2645
+	if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2646 2646
 
2647
-        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2648
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2647
+		$geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2648
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
2649 2649
 
2650
-        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2651
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2650
+		$path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2651
+		$term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2652 2652
 
2653
-        $posts = $wpdb->get_results(
2654
-            $wpdb->prepare(
2655
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2656
-                array($term_id, $taxonomy)
2657
-            )
2658
-        );
2653
+		$posts = $wpdb->get_results(
2654
+			$wpdb->prepare(
2655
+				"SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2656
+				array($term_id, $taxonomy)
2657
+			)
2658
+		);
2659 2659
 
2660
-        if (!empty($posts)):
2661
-            foreach ($posts as $post_obj) {
2660
+		if (!empty($posts)):
2661
+			foreach ($posts as $post_obj) {
2662 2662
 
2663
-                $lat = $post_obj->post_latitude;
2664
-                $lng = $post_obj->post_longitude;
2663
+				$lat = $post_obj->post_latitude;
2664
+				$lng = $post_obj->post_longitude;
2665 2665
 
2666
-                $json = '{';
2667
-                $json .= '"id":"' . $post_obj->post_id . '",';
2668
-                $json .= '"lat_pos": "' . $lat . '",';
2669
-                $json .= '"long_pos": "' . $lng . '",';
2670
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2671
-                $json .= '"icon":"' . $term_icon . '",';
2672
-                $json .= '"group":"catgroup' . $term_id . '"';
2673
-                $json .= '}';
2666
+				$json = '{';
2667
+				$json .= '"id":"' . $post_obj->post_id . '",';
2668
+				$json .= '"lat_pos": "' . $lat . '",';
2669
+				$json .= '"long_pos": "' . $lng . '",';
2670
+				$json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2671
+				$json .= '"icon":"' . $term_icon . '",';
2672
+				$json .= '"group":"catgroup' . $term_id . '"';
2673
+				$json .= '}';
2674 2674
 
2675
-                if ($post_obj->default_category == $term_id) {
2675
+				if ($post_obj->default_category == $term_id) {
2676 2676
 
2677
-                    $wpdb->query(
2678
-                        $wpdb->prepare(
2679
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2680
-                            array($json, $post_obj->post_id)
2681
-                        )
2682
-                    );
2683
-                }
2677
+					$wpdb->query(
2678
+						$wpdb->prepare(
2679
+							"UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2680
+							array($json, $post_obj->post_id)
2681
+						)
2682
+					);
2683
+				}
2684 2684
 
2685
-                $wpdb->query(
2686
-                    $wpdb->prepare(
2687
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2688
-                        array($json, $post_obj->post_id, $term_id)
2689
-                    )
2690
-                );
2685
+				$wpdb->query(
2686
+					$wpdb->prepare(
2687
+						"UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2688
+						array($json, $post_obj->post_id, $term_id)
2689
+					)
2690
+				);
2691 2691
 
2692
-            }
2692
+			}
2693 2693
 
2694 2694
 
2695
-        endif;
2695
+		endif;
2696 2696
 
2697
-    }
2697
+	}
2698 2698
 
2699 2699
 }
2700 2700
 
@@ -2708,14 +2708,14 @@  discard block
 block discarded – undo
2708 2708
  */
2709 2709
 function geodir_get_listing_author($listing_id = '')
2710 2710
 {
2711
-    if ($listing_id == '') {
2712
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2713
-            $listing_id = $_REQUEST['pid'];
2714
-        }
2715
-    }
2716
-    $listing = get_post(strip_tags($listing_id));
2717
-    $listing_author_id = $listing->post_author;
2718
-    return $listing_author_id;
2711
+	if ($listing_id == '') {
2712
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2713
+			$listing_id = $_REQUEST['pid'];
2714
+		}
2715
+	}
2716
+	$listing = get_post(strip_tags($listing_id));
2717
+	$listing_author_id = $listing->post_author;
2718
+	return $listing_author_id;
2719 2719
 }
2720 2720
 
2721 2721
 
@@ -2730,11 +2730,11 @@  discard block
 block discarded – undo
2730 2730
  */
2731 2731
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2732 2732
 {
2733
-    $listing_author_id = geodir_get_listing_author($listing_id);
2734
-    if ($listing_author_id == $user_id)
2735
-        return true;
2736
-    else
2737
-        return false;
2733
+	$listing_author_id = geodir_get_listing_author($listing_id);
2734
+	if ($listing_author_id == $user_id)
2735
+		return true;
2736
+	else
2737
+		return false;
2738 2738
 
2739 2739
 }
2740 2740
 
@@ -2750,17 +2750,17 @@  discard block
 block discarded – undo
2750 2750
  */
2751 2751
 function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true)
2752 2752
 {
2753
-    global $current_user;
2754
-    if ($exclude_admin) {
2755
-        foreach ($current_user->caps as $key => $caps) {
2756
-            if (geodir_strtolower($key) == 'administrator') {
2757
-                return true;
2758
-                break;
2759
-            }
2760
-        }
2761
-    }
2762
-
2763
-    return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2753
+	global $current_user;
2754
+	if ($exclude_admin) {
2755
+		foreach ($current_user->caps as $key => $caps) {
2756
+			if (geodir_strtolower($key) == 'administrator') {
2757
+				return true;
2758
+				break;
2759
+			}
2760
+		}
2761
+	}
2762
+
2763
+	return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2764 2764
 }
2765 2765
 
2766 2766
 
@@ -2776,17 +2776,17 @@  discard block
 block discarded – undo
2776 2776
 function geodir_only_supportable_attachments_remove($file)
2777 2777
 {
2778 2778
 
2779
-    global $wpdb;
2779
+	global $wpdb;
2780 2780
 
2781
-    $matches = array();
2781
+	$matches = array();
2782 2782
 
2783
-    $pattern = '/-\d+x\d+\./';
2784
-    preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2783
+	$pattern = '/-\d+x\d+\./';
2784
+	preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2785 2785
 
2786
-    if (empty($matches))
2787
-        return '';
2788
-    else
2789
-        return $file;
2786
+	if (empty($matches))
2787
+		return '';
2788
+	else
2789
+		return $file;
2790 2790
 
2791 2791
 }
2792 2792
 
@@ -2803,78 +2803,78 @@  discard block
 block discarded – undo
2803 2803
 function geodir_set_wp_featured_image($post_id)
2804 2804
 {
2805 2805
 
2806
-    global $wpdb, $plugin_prefix;
2807
-    $uploads = wp_upload_dir();
2806
+	global $wpdb, $plugin_prefix;
2807
+	$uploads = wp_upload_dir();
2808 2808
 //	print_r($uploads ) ;
2809
-    $post_first_image = $wpdb->get_results(
2810
-        $wpdb->prepare(
2811
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2812
-        )
2813
-    );
2809
+	$post_first_image = $wpdb->get_results(
2810
+		$wpdb->prepare(
2811
+			"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2812
+		)
2813
+	);
2814 2814
 
2815
-    $old_attachment_name = '';
2816
-    $post_thumbnail_id = '';
2817
-    if (has_post_thumbnail($post_id)) {
2815
+	$old_attachment_name = '';
2816
+	$post_thumbnail_id = '';
2817
+	if (has_post_thumbnail($post_id)) {
2818 2818
 
2819
-        if (has_post_thumbnail($post_id)) {
2819
+		if (has_post_thumbnail($post_id)) {
2820 2820
 
2821
-            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2821
+			$post_thumbnail_id = get_post_thumbnail_id($post_id);
2822 2822
 
2823
-            $old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2823
+			$old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2824 2824
 
2825
-        }
2826
-    }
2827
-
2828
-    if (!empty($post_first_image)) {
2825
+		}
2826
+	}
2829 2827
 
2830
-        $post_type = get_post_type($post_id);
2828
+	if (!empty($post_first_image)) {
2831 2829
 
2832
-        $table_name = $plugin_prefix . $post_type . '_detail';
2830
+		$post_type = get_post_type($post_id);
2833 2831
 
2834
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2832
+		$table_name = $plugin_prefix . $post_type . '_detail';
2835 2833
 
2836
-        $new_attachment_name = basename($post_first_image[0]->file);
2834
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2837 2835
 
2838
-        if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2836
+		$new_attachment_name = basename($post_first_image[0]->file);
2839 2837
 
2840
-            if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2838
+		if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2841 2839
 
2842
-                add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2840
+			if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2843 2841
 
2844
-                wp_delete_attachment($post_thumbnail_id);
2842
+				add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2845 2843
 
2846
-            }
2847
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2844
+				wp_delete_attachment($post_thumbnail_id);
2848 2845
 
2849
-            $attachment = array(
2850
-                'post_mime_type' => $post_first_image[0]->mime_type,
2851
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2852
-                'post_parent' => $post_id,
2853
-                'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2854
-                'post_content' => ''
2855
-            );
2846
+			}
2847
+			$filename = $uploads['basedir'] . $post_first_image[0]->file;
2848
+
2849
+			$attachment = array(
2850
+				'post_mime_type' => $post_first_image[0]->mime_type,
2851
+				'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2852
+				'post_parent' => $post_id,
2853
+				'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2854
+				'post_content' => ''
2855
+			);
2856 2856
 
2857 2857
 
2858
-            $id = wp_insert_attachment($attachment, $filename, $post_id);
2858
+			$id = wp_insert_attachment($attachment, $filename, $post_id);
2859 2859
 
2860
-            if (!is_wp_error($id)) {
2860
+			if (!is_wp_error($id)) {
2861 2861
 
2862
-                set_post_thumbnail($post_id, $id);
2862
+				set_post_thumbnail($post_id, $id);
2863 2863
 
2864
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2865
-                wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2864
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
2865
+				wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2866 2866
 
2867
-            }
2867
+			}
2868 2868
 
2869
-        }
2869
+		}
2870 2870
 
2871
-    } else {
2872
-        //set_post_thumbnail($post_id,-1);
2871
+	} else {
2872
+		//set_post_thumbnail($post_id,-1);
2873 2873
 
2874
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2875
-            wp_delete_attachment($post_thumbnail_id);
2874
+		if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2875
+			wp_delete_attachment($post_thumbnail_id);
2876 2876
 
2877
-    }
2877
+	}
2878 2878
 }
2879 2879
 
2880 2880
 
@@ -2889,53 +2889,53 @@  discard block
 block discarded – undo
2889 2889
  */
2890 2890
 function gd_copy_original_translation()
2891 2891
 {
2892
-    if (function_exists('icl_object_id')) {
2893
-        global $wpdb, $table_prefix, $plugin_prefix;
2894
-        $post_id = absint($_POST['post_id']);
2895
-        $upload_dir = wp_upload_dir();
2896
-        $post_type = get_post_type($_POST['post_id']);
2897
-        $table = $plugin_prefix . $post_type . '_detail';
2898
-
2899
-        $post_arr = $wpdb->get_results($wpdb->prepare(
2900
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2901
-            array($post_id)
2902
-        )
2903
-            , ARRAY_A);
2904
-
2905
-        $arrImages = $wpdb->get_results(
2906
-            $wpdb->prepare(
2907
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2908
-                array('%image%', $post_id)
2909
-            )
2910
-        );
2911
-        if ($arrImages) {
2912
-            $image_arr = array();
2913
-            foreach ($arrImages as $img) {
2914
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2915
-            }
2916
-            $comma_separated = implode(",", $image_arr);
2917
-            $post_arr[0]['post_images'] = $comma_separated;
2918
-        }
2919
-
2920
-
2921
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2922
-        $cat_arr = array_filter(explode(",", $cats));
2923
-        $trans_cat = array();
2924
-        foreach ($cat_arr as $cat) {
2925
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2926
-        }
2927
-
2928
-
2929
-        $post_arr[0]['categories'] = array_filter($trans_cat);
2892
+	if (function_exists('icl_object_id')) {
2893
+		global $wpdb, $table_prefix, $plugin_prefix;
2894
+		$post_id = absint($_POST['post_id']);
2895
+		$upload_dir = wp_upload_dir();
2896
+		$post_type = get_post_type($_POST['post_id']);
2897
+		$table = $plugin_prefix . $post_type . '_detail';
2898
+
2899
+		$post_arr = $wpdb->get_results($wpdb->prepare(
2900
+			"SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2901
+			array($post_id)
2902
+		)
2903
+			, ARRAY_A);
2904
+
2905
+		$arrImages = $wpdb->get_results(
2906
+			$wpdb->prepare(
2907
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2908
+				array('%image%', $post_id)
2909
+			)
2910
+		);
2911
+		if ($arrImages) {
2912
+			$image_arr = array();
2913
+			foreach ($arrImages as $img) {
2914
+				$image_arr[] = $upload_dir['baseurl'] . $img->file;
2915
+			}
2916
+			$comma_separated = implode(",", $image_arr);
2917
+			$post_arr[0]['post_images'] = $comma_separated;
2918
+		}
2919
+
2920
+
2921
+		$cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2922
+		$cat_arr = array_filter(explode(",", $cats));
2923
+		$trans_cat = array();
2924
+		foreach ($cat_arr as $cat) {
2925
+			$trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2926
+		}
2927
+
2928
+
2929
+		$post_arr[0]['categories'] = array_filter($trans_cat);
2930 2930
 //print_r($image_arr);
2931
-        //print_r($arrImages);
2932
-        //echo $_REQUEST['lang'];
2931
+		//print_r($arrImages);
2932
+		//echo $_REQUEST['lang'];
2933 2933
 //print_r($post_arr);
2934 2934
 //print_r($trans_cat);
2935
-        echo json_encode($post_arr[0]);
2935
+		echo json_encode($post_arr[0]);
2936 2936
 
2937
-    }
2938
-    die();
2937
+	}
2938
+	die();
2939 2939
 }
2940 2940
 
2941 2941
 
@@ -2955,54 +2955,54 @@  discard block
 block discarded – undo
2955 2955
 function geodir_get_custom_fields_type($listing_type = '')
2956 2956
 {
2957 2957
 
2958
-    global $wpdb;
2958
+	global $wpdb;
2959 2959
 
2960
-    if ($listing_type == '')
2961
-        $listing_type = 'gd_place';
2960
+	if ($listing_type == '')
2961
+		$listing_type = 'gd_place';
2962 2962
 
2963
-    $fields_info = array();
2963
+	$fields_info = array();
2964 2964
 
2965
-    $get_data = $wpdb->get_results(
2966
-        $wpdb->prepare(
2967
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2968
-            array($listing_type)
2969
-        )
2970
-    );
2965
+	$get_data = $wpdb->get_results(
2966
+		$wpdb->prepare(
2967
+			"SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2968
+			array($listing_type)
2969
+		)
2970
+	);
2971 2971
 
2972
-    if (!empty($get_data)) {
2972
+	if (!empty($get_data)) {
2973 2973
 
2974
-        foreach ($get_data as $data) {
2974
+		foreach ($get_data as $data) {
2975 2975
 
2976
-            if ($data->field_type == 'address') {
2976
+			if ($data->field_type == 'address') {
2977 2977
 
2978
-                $extra_fields = unserialize($data->extra_fields);
2978
+				$extra_fields = unserialize($data->extra_fields);
2979 2979
 
2980
-                $prefix = $data->htmlvar_name . '_';
2980
+				$prefix = $data->htmlvar_name . '_';
2981 2981
 
2982
-                $fields_info[$prefix . 'address'] = $data->field_type;
2982
+				$fields_info[$prefix . 'address'] = $data->field_type;
2983 2983
 
2984
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2985
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
2984
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2985
+					$fields_info[$prefix . 'zip'] = $data->field_type;
2986 2986
 
2987
-            } else {
2987
+			} else {
2988 2988
 
2989
-                $fields_info[$data->htmlvar_name] = $data->field_type;
2989
+				$fields_info[$data->htmlvar_name] = $data->field_type;
2990 2990
 
2991
-            }
2991
+			}
2992 2992
 
2993
-        }
2993
+		}
2994 2994
 
2995
-    }
2995
+	}
2996 2996
 
2997
-    /**
2998
-     * Filter to modify custom fields info using listing post type.
2999
-     *
3000
-     * @since 1.0.0
3001
-     * @package GeoDirectory
3002
-     * @return array $fields_info Custom fields info.
3003
-     * @param string $listing_type The listing post type.
3004
-     */
3005
-    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
2997
+	/**
2998
+	 * Filter to modify custom fields info using listing post type.
2999
+	 *
3000
+	 * @since 1.0.0
3001
+	 * @package GeoDirectory
3002
+	 * @return array $fields_info Custom fields info.
3003
+	 * @param string $listing_type The listing post type.
3004
+	 */
3005
+	return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3006 3006
 }
3007 3007
 
3008 3008
 
@@ -3017,58 +3017,58 @@  discard block
 block discarded – undo
3017 3017
  */
3018 3018
 function geodir_function_post_updated($post_ID, $post_after, $post_before)
3019 3019
 {
3020
-    $post_type = get_post_type($post_ID);
3020
+	$post_type = get_post_type($post_ID);
3021 3021
 
3022
-    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3023
-        // send notification to client when post moves from draft to publish
3024
-        if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
3025
-            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3026
-            $post_author_data = get_userdata($post_author_id);
3022
+	if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3023
+		// send notification to client when post moves from draft to publish
3024
+		if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
3025
+			$post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3026
+			$post_author_data = get_userdata($post_author_id);
3027 3027
 
3028
-            $to_name = geodir_get_client_name($post_author_id);
3028
+			$to_name = geodir_get_client_name($post_author_id);
3029 3029
 
3030
-            $from_email = geodir_get_site_email_id();
3031
-            $from_name = get_site_emailName();
3032
-            $to_email = $post_author_data->user_email;
3030
+			$from_email = geodir_get_site_email_id();
3031
+			$from_name = get_site_emailName();
3032
+			$to_email = $post_author_data->user_email;
3033 3033
 
3034
-            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3035
-                $to_email = $post_author_data->user_email;
3036
-            }
3034
+			if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3035
+				$to_email = $post_author_data->user_email;
3036
+			}
3037 3037
 
3038
-            $message_type = 'listing_published';
3038
+			$message_type = 'listing_published';
3039 3039
 
3040
-            if (get_option('geodir_post_published_email_subject') == '') {
3041
-                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3042
-            }
3040
+			if (get_option('geodir_post_published_email_subject') == '') {
3041
+				update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3042
+			}
3043 3043
 
3044
-            if (get_option('geodir_post_published_email_content') == '') {
3045
-                update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
3046
-            }
3044
+			if (get_option('geodir_post_published_email_content') == '') {
3045
+				update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
3046
+			}
3047 3047
 
3048
-            /**
3049
-             * Called before sending the email when listing gets published.
3050
-             *
3051
-             * @since 1.0.0
3052
-             * @package GeoDirectory
3053
-             * @param object $post_after The post object after update.
3054
-             * @param object $post_before The post object before update.
3055
-             */
3056
-            do_action('geodir_before_listing_published_email', $post_after, $post_before);
3057
-            if (is_email($to_email)) {
3058
-                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3059
-            }
3048
+			/**
3049
+			 * Called before sending the email when listing gets published.
3050
+			 *
3051
+			 * @since 1.0.0
3052
+			 * @package GeoDirectory
3053
+			 * @param object $post_after The post object after update.
3054
+			 * @param object $post_before The post object before update.
3055
+			 */
3056
+			do_action('geodir_before_listing_published_email', $post_after, $post_before);
3057
+			if (is_email($to_email)) {
3058
+				geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3059
+			}
3060 3060
 
3061
-            /**
3062
-             * Called after sending the email when listing gets published.
3063
-             *
3064
-             * @since 1.0.0
3065
-             * @package GeoDirectory
3066
-             * @param object $post_after The post object after update.
3067
-             * @param object $post_before The post object before update.
3068
-             */
3069
-            do_action('geodir_after_listing_published_email', $post_after, $post_before);
3070
-        }
3071
-    }
3061
+			/**
3062
+			 * Called after sending the email when listing gets published.
3063
+			 *
3064
+			 * @since 1.0.0
3065
+			 * @package GeoDirectory
3066
+			 * @param object $post_after The post object after update.
3067
+			 * @param object $post_before The post object before update.
3068
+			 */
3069
+			do_action('geodir_after_listing_published_email', $post_after, $post_before);
3070
+		}
3071
+	}
3072 3072
 }
3073 3073
 
3074 3074
 add_action('wp_head', 'geodir_fb_like_thumbnail');
@@ -3082,14 +3082,14 @@  discard block
 block discarded – undo
3082 3082
  */
3083 3083
 function geodir_fb_like_thumbnail(){
3084 3084
 
3085
-    // return if not a single post
3086
-    if(!is_single()){return;}
3085
+	// return if not a single post
3086
+	if(!is_single()){return;}
3087 3087
 
3088
-    global $post;
3089
-    if(isset($post->featured_image) && $post->featured_image){
3090
-        $upload_dir = wp_upload_dir();
3091
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3092
-        echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3088
+	global $post;
3089
+	if(isset($post->featured_image) && $post->featured_image){
3090
+		$upload_dir = wp_upload_dir();
3091
+		$thumb = $upload_dir['baseurl'].$post->featured_image;
3092
+		echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3093 3093
 
3094
-    }
3094
+	}
3095 3095
 }
3096 3096
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/custom_functions.php 1 patch
Indentation   +1407 added lines, -1407 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * @global object $gd_session GeoDirectory Session object.
18 18
  */
19 19
 function geodir_list_view_select() {
20
-    global $gd_session;
20
+	global $gd_session;
21 21
 	?>
22 22
     <script type="text/javascript">
23 23
 	function geodir_list_view_select(list) {
@@ -86,63 +86,63 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function geodir_max_excerpt($charlength)
88 88
 {
89
-    global $post;
90
-    if ($charlength == '0') {
91
-        return;
92
-    }
93
-    $out = '';
89
+	global $post;
90
+	if ($charlength == '0') {
91
+		return;
92
+	}
93
+	$out = '';
94 94
 	
95 95
 	$temp_post = $post;
96 96
 	$excerpt = get_the_excerpt();
97 97
 
98
-    $charlength++;
99
-    $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
100
-    if (mb_strlen($excerpt) > $charlength) {
101
-        if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
102
-            $excut = -(mb_strlen($excerpt_more));
103
-            $subex = mb_substr($excerpt, 0, $excut);
104
-            if ($charlength > 0 && mb_strlen($subex) > $charlength) {
105
-                $subex = mb_substr($subex, 0, $charlength);
106
-            }
107
-            $out .= $subex;
108
-        } else {
109
-            $subex = mb_substr($excerpt, 0, $charlength - 5);
110
-            $exwords = explode(' ', $subex);
111
-            $excut = -(mb_strlen($exwords[count($exwords) - 1]));
112
-            if ($excut < 0) {
113
-                $out .= mb_substr($subex, 0, $excut);
114
-            } else {
115
-                $out .= $subex;
116
-            }
117
-        }
118
-        $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
119
-        /**
120
-         * Filter excerpt read more text.
121
-         *
122
-         * @since 1.0.0
123
-         */
124
-        $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
125
-        $out .= '</a>';
126
-
127
-    } else {
128
-        if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129
-            $excut = -(mb_strlen($excerpt_more));
130
-            $out .= mb_substr($excerpt, 0, $excut);
131
-            $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
132
-            /**
133
-             * Filter excerpt read more text.
134
-             *
135
-             * @since 1.0.0
136
-             */
137
-            $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
138
-            $out .= '</a>';
139
-        } else {
140
-            $out .= $excerpt;
141
-        }
142
-    }
98
+	$charlength++;
99
+	$excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
100
+	if (mb_strlen($excerpt) > $charlength) {
101
+		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
102
+			$excut = -(mb_strlen($excerpt_more));
103
+			$subex = mb_substr($excerpt, 0, $excut);
104
+			if ($charlength > 0 && mb_strlen($subex) > $charlength) {
105
+				$subex = mb_substr($subex, 0, $charlength);
106
+			}
107
+			$out .= $subex;
108
+		} else {
109
+			$subex = mb_substr($excerpt, 0, $charlength - 5);
110
+			$exwords = explode(' ', $subex);
111
+			$excut = -(mb_strlen($exwords[count($exwords) - 1]));
112
+			if ($excut < 0) {
113
+				$out .= mb_substr($subex, 0, $excut);
114
+			} else {
115
+				$out .= $subex;
116
+			}
117
+		}
118
+		$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
119
+		/**
120
+		 * Filter excerpt read more text.
121
+		 *
122
+		 * @since 1.0.0
123
+		 */
124
+		$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
125
+		$out .= '</a>';
126
+
127
+	} else {
128
+		if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129
+			$excut = -(mb_strlen($excerpt_more));
130
+			$out .= mb_substr($excerpt, 0, $excut);
131
+			$out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
132
+			/**
133
+			 * Filter excerpt read more text.
134
+			 *
135
+			 * @since 1.0.0
136
+			 */
137
+			$out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
138
+			$out .= '</a>';
139
+		} else {
140
+			$out .= $excerpt;
141
+		}
142
+	}
143 143
 	$post = $temp_post;
144 144
 
145
-    return $out;
145
+	return $out;
146 146
 }
147 147
 
148 148
 /**
@@ -157,34 +157,34 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function geodir_post_package_info($package_info, $post = '', $post_type = '')
159 159
 {
160
-    $package_info['pid'] = 0;
161
-    $package_info['days'] = 0;
162
-    $package_info['amount'] = 0;
163
-    $package_info['is_featured'] = 0;
164
-    $package_info['image_limit'] = '';
165
-    $package_info['google_analytics'] = 1;
166
-    $package_info['sendtofriend'] = 1;
167
-
168
-    /**
169
-     * Filter listing package info.
170
-     *
171
-     * @since 1.0.0
172
-     * @param array $package_info {
173
-     *    Attributes of the package_info.
174
-     *
175
-     *    @type int $pid Package ID. Default 0.
176
-     *    @type int $days Package validity in Days. Default 0.
177
-     *    @type int $amount Package amount. Default 0.
178
-     *    @type int $is_featured Is this featured package? Default 0.
179
-     *    @type string $image_limit Image limit for this package. Default "".
180
-     *    @type int $google_analytics Add analytics to this package. Default 1.
181
-     *    @type int $sendtofriend Send to friend. Default 1.
182
-     *
183
-     * }
184
-     * @param object|string $post The post object.
185
-     * @param string $post_type The post type.
186
-     */
187
-    return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
160
+	$package_info['pid'] = 0;
161
+	$package_info['days'] = 0;
162
+	$package_info['amount'] = 0;
163
+	$package_info['is_featured'] = 0;
164
+	$package_info['image_limit'] = '';
165
+	$package_info['google_analytics'] = 1;
166
+	$package_info['sendtofriend'] = 1;
167
+
168
+	/**
169
+	 * Filter listing package info.
170
+	 *
171
+	 * @since 1.0.0
172
+	 * @param array $package_info {
173
+	 *    Attributes of the package_info.
174
+	 *
175
+	 *    @type int $pid Package ID. Default 0.
176
+	 *    @type int $days Package validity in Days. Default 0.
177
+	 *    @type int $amount Package amount. Default 0.
178
+	 *    @type int $is_featured Is this featured package? Default 0.
179
+	 *    @type string $image_limit Image limit for this package. Default "".
180
+	 *    @type int $google_analytics Add analytics to this package. Default 1.
181
+	 *    @type int $sendtofriend Send to friend. Default 1.
182
+	 *
183
+	 * }
184
+	 * @param object|string $post The post object.
185
+	 * @param string $post_type The post type.
186
+	 */
187
+	return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
188 188
 
189 189
 }
190 190
 
@@ -212,127 +212,127 @@  discard block
 block discarded – undo
212 212
  */
213 213
 function geodir_send_inquiry($request)
214 214
 {
215
-    global $wpdb;
215
+	global $wpdb;
216 216
 
217
-    // strip slashes from text
218
-    $request = !empty($request) ? stripslashes_deep($request) : $request;
217
+	// strip slashes from text
218
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
219 219
 
220
-    $yourname = $request['inq_name'];
221
-    $youremail = $request['inq_email'];
222
-    $inq_phone = $request['inq_phone'];
223
-    $frnd_comments = $request['inq_msg'];
224
-    $pid = $request['pid'];
220
+	$yourname = $request['inq_name'];
221
+	$youremail = $request['inq_email'];
222
+	$inq_phone = $request['inq_phone'];
223
+	$frnd_comments = $request['inq_msg'];
224
+	$pid = $request['pid'];
225 225
 
226
-    $author_id = '';
227
-    $post_title = '';
226
+	$author_id = '';
227
+	$post_title = '';
228 228
 
229
-    if ($request['pid']) {
229
+	if ($request['pid']) {
230 230
 
231
-        $productinfosql = $wpdb->prepare(
232
-            "select ID,post_author,post_title from $wpdb->posts where ID =%d",
233
-            array($request['pid'])
234
-        );
235
-        $productinfo = $wpdb->get_row($productinfosql);
231
+		$productinfosql = $wpdb->prepare(
232
+			"select ID,post_author,post_title from $wpdb->posts where ID =%d",
233
+			array($request['pid'])
234
+		);
235
+		$productinfo = $wpdb->get_row($productinfosql);
236 236
 
237
-        $author_id = $productinfo->post_author;
238
-        $post_title = $productinfo->post_title;
239
-    }
237
+		$author_id = $productinfo->post_author;
238
+		$post_title = $productinfo->post_title;
239
+	}
240 240
 
241
-    $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
241
+	$post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
242 242
 
243
-    $user_info = get_userdata($author_id);
244
-    $to_email = geodir_get_post_meta($pid, 'geodir_email', true);
245
-    $to_name = geodir_get_client_name($author_id);
243
+	$user_info = get_userdata($author_id);
244
+	$to_email = geodir_get_post_meta($pid, 'geodir_email', true);
245
+	$to_name = geodir_get_client_name($author_id);
246 246
 
247
-    if ($to_email == '') {
248
-        $to_email = get_option('admin_email');
249
-    }
247
+	if ($to_email == '') {
248
+		$to_email = get_option('admin_email');
249
+	}
250 250
 
251
-    /**
252
-     * Called after the send enquiry var have been set but before the email has been sent.
253
-     *
254
-     * @since 1.0.0
255
-     * @param array $request {
256
-     *    The submitted form fields as an array.
257
-     *
258
-     *    @type string $sendact Enquiry type. Default "send_inqury".
259
-     *    @type string $pid Post ID.
260
-     *    @type string $inq_name Sender name.
261
-     *    @type string $inq_email Sender mail.
262
-     *    @type string $inq_phone Sender phone.
263
-     *    @type string $inq_msg Email message.
264
-     *
265
-     * }
266
-     * @param string $type The form type, default: `Enquiry`.
267
-     */
268
-    do_action('geodir_after_send_enquiry', $request, 'Enquiry');
269
-
270
-    $client_message = $frnd_comments;
271
-    $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
272
-    /**
273
-     * Filter client message text.
274
-     *
275
-     * @since 1.0.0
276
-     * @param string $client_message Client message text.
277
-     */
278
-    $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
279
-
280
-    /**
281
-     * Called before the send enquiry email is sent.
282
-     *
283
-     * @since 1.0.0
284
-     * @param array $request {
285
-     *    The submitted form fields as an array.
286
-     *
287
-     *    @type string $sendact Enquiry type. Default "send_inqury".
288
-     *    @type string $pid Post ID.
289
-     *    @type string $inq_name Sender name.
290
-     *    @type string $inq_email Sender mail.
291
-     *    @type string $inq_phone Sender phone.
292
-     *    @type string $inq_msg Email message.
293
-     *
294
-     * }
295
-     */
296
-    do_action('geodir_before_send_enquiry_email', $request);
297
-    if ($to_email) {
298
-        // strip slashes message
299
-        $client_message = stripslashes_deep($client_message);
300
-
301
-        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
302
-    }
251
+	/**
252
+	 * Called after the send enquiry var have been set but before the email has been sent.
253
+	 *
254
+	 * @since 1.0.0
255
+	 * @param array $request {
256
+	 *    The submitted form fields as an array.
257
+	 *
258
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
259
+	 *    @type string $pid Post ID.
260
+	 *    @type string $inq_name Sender name.
261
+	 *    @type string $inq_email Sender mail.
262
+	 *    @type string $inq_phone Sender phone.
263
+	 *    @type string $inq_msg Email message.
264
+	 *
265
+	 * }
266
+	 * @param string $type The form type, default: `Enquiry`.
267
+	 */
268
+	do_action('geodir_after_send_enquiry', $request, 'Enquiry');
303 269
 
304
-    /**
305
-     * Called after the send enquiry email is sent.
306
-     *
307
-     * @since 1.0.0
308
-     * @param array $request {
309
-     *    The submitted form fields as an array.
310
-     *
311
-     *    @type string $sendact Enquiry type. Default "send_inqury".
312
-     *    @type string $pid Post ID.
313
-     *    @type string $inq_name Sender name.
314
-     *    @type string $inq_email Sender mail.
315
-     *    @type string $inq_phone Sender phone.
316
-     *    @type string $inq_msg Email message.
317
-     *
318
-     * }
319
-     */
320
-    do_action('geodir_after_send_enquiry_email', $request);
321
-    $url = get_permalink($pid);
322
-    if (strstr($url, '?')) {
323
-        $url = $url . "&send_inquiry=success";
324
-    } else {
325
-        $url = $url . "?send_inquiry=success";
326
-    }
327
-    /**
328
-     * Filter redirect url after the send enquiry email is sent.
329
-     *
330
-     * @since 1.0.0
331
-     * @param string $url Redirect url.
332
-     */
333
-    $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
334
-    wp_redirect($url);
335
-    gd_die();
270
+	$client_message = $frnd_comments;
271
+	$client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
272
+	/**
273
+	 * Filter client message text.
274
+	 *
275
+	 * @since 1.0.0
276
+	 * @param string $client_message Client message text.
277
+	 */
278
+	$client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
279
+
280
+	/**
281
+	 * Called before the send enquiry email is sent.
282
+	 *
283
+	 * @since 1.0.0
284
+	 * @param array $request {
285
+	 *    The submitted form fields as an array.
286
+	 *
287
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
288
+	 *    @type string $pid Post ID.
289
+	 *    @type string $inq_name Sender name.
290
+	 *    @type string $inq_email Sender mail.
291
+	 *    @type string $inq_phone Sender phone.
292
+	 *    @type string $inq_msg Email message.
293
+	 *
294
+	 * }
295
+	 */
296
+	do_action('geodir_before_send_enquiry_email', $request);
297
+	if ($to_email) {
298
+		// strip slashes message
299
+		$client_message = stripslashes_deep($client_message);
300
+
301
+		geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
302
+	}
303
+
304
+	/**
305
+	 * Called after the send enquiry email is sent.
306
+	 *
307
+	 * @since 1.0.0
308
+	 * @param array $request {
309
+	 *    The submitted form fields as an array.
310
+	 *
311
+	 *    @type string $sendact Enquiry type. Default "send_inqury".
312
+	 *    @type string $pid Post ID.
313
+	 *    @type string $inq_name Sender name.
314
+	 *    @type string $inq_email Sender mail.
315
+	 *    @type string $inq_phone Sender phone.
316
+	 *    @type string $inq_msg Email message.
317
+	 *
318
+	 * }
319
+	 */
320
+	do_action('geodir_after_send_enquiry_email', $request);
321
+	$url = get_permalink($pid);
322
+	if (strstr($url, '?')) {
323
+		$url = $url . "&send_inquiry=success";
324
+	} else {
325
+		$url = $url . "?send_inquiry=success";
326
+	}
327
+	/**
328
+	 * Filter redirect url after the send enquiry email is sent.
329
+	 *
330
+	 * @since 1.0.0
331
+	 * @param string $url Redirect url.
332
+	 */
333
+	$url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
334
+	wp_redirect($url);
335
+	gd_die();
336 336
 
337 337
 }
338 338
 
@@ -361,85 +361,85 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function geodir_send_friend($request)
363 363
 {
364
-    global $wpdb;
365
-
366
-    // strip slashes from text
367
-    $request = !empty($request) ? stripslashes_deep($request) : $request;
368
-
369
-    $yourname = $request['yourname'];
370
-    $youremail = $request['youremail'];
371
-    $frnd_subject = $request['frnd_subject'];
372
-    $frnd_comments = $request['frnd_comments'];
373
-    $pid = $request['pid'];
374
-    $to_email = $request['to_email'];
375
-    $to_name = $request['to_name'];
376
-    if ($request['pid']) {
377
-        $productinfosql = $wpdb->prepare(
378
-            "select ID,post_title from $wpdb->posts where ID =%d",
379
-            array($request['pid'])
380
-        );
381
-        $productinfo = $wpdb->get_results($productinfosql);
382
-        foreach ($productinfo as $productinfoObj) {
383
-            $post_title = $productinfoObj->post_title;
384
-        }
385
-    }
364
+	global $wpdb;
365
+
366
+	// strip slashes from text
367
+	$request = !empty($request) ? stripslashes_deep($request) : $request;
368
+
369
+	$yourname = $request['yourname'];
370
+	$youremail = $request['youremail'];
371
+	$frnd_subject = $request['frnd_subject'];
372
+	$frnd_comments = $request['frnd_comments'];
373
+	$pid = $request['pid'];
374
+	$to_email = $request['to_email'];
375
+	$to_name = $request['to_name'];
376
+	if ($request['pid']) {
377
+		$productinfosql = $wpdb->prepare(
378
+			"select ID,post_title from $wpdb->posts where ID =%d",
379
+			array($request['pid'])
380
+		);
381
+		$productinfo = $wpdb->get_results($productinfosql);
382
+		foreach ($productinfo as $productinfoObj) {
383
+			$post_title = $productinfoObj->post_title;
384
+		}
385
+	}
386 386
 
387
-    /**
388
-     * Called before the send to friend email is sent.
389
-     *
390
-     * @since 1.0.0
391
-     * @param array $request {
392
-     *    The submitted form fields as an array.
393
-     *
394
-     *    @type string $sendact Enquiry type. Default "email_frnd".
395
-     *    @type string $pid Post ID.
396
-     *    @type string $to_name Friend name.
397
-     *    @type string $to_email Friend email.
398
-     *    @type string $yourname Sender name.
399
-     *    @type string $youremail Sender email.
400
-     *    @type string $frnd_subject Email subject.
401
-     *    @type string $frnd_comments Email Message.
402
-     *
403
-     * }
404
-     */
405
-    do_action('geodir_before_send_to_friend_email', $request);
406
-    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
407
-
408
-    /**
409
-     * Called after the send to friend email is sent.
410
-     *
411
-     * @since 1.0.0
412
-     * @param array $request {
413
-     *    The submitted form fields as an array.
414
-     *
415
-     *    @type string $sendact Enquiry type. Default "email_frnd".
416
-     *    @type string $pid Post ID.
417
-     *    @type string $to_name Friend name.
418
-     *    @type string $to_email Friend email.
419
-     *    @type string $yourname Sender name.
420
-     *    @type string $youremail Sender email.
421
-     *    @type string $frnd_subject Email subject.
422
-     *    @type string $frnd_comments Email Message.
423
-     *
424
-     * }
425
-     */
426
-    do_action('geodir_after_send_to_friend_email', $request);
427
-
428
-    $url = get_permalink($pid);
429
-    if (strstr($url, '?')) {
430
-        $url = $url . "&sendtofrnd=success";
431
-    } else {
432
-        $url = $url . "?sendtofrnd=success";
433
-    }
434
-    /**
435
-     * Filter redirect url after the send to friend email is sent.
436
-     *
437
-     * @since 1.0.0
438
-     * @param string $url Redirect url.
439
-     */
440
-    $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
441
-    wp_redirect($url);
442
-    gd_die();
387
+	/**
388
+	 * Called before the send to friend email is sent.
389
+	 *
390
+	 * @since 1.0.0
391
+	 * @param array $request {
392
+	 *    The submitted form fields as an array.
393
+	 *
394
+	 *    @type string $sendact Enquiry type. Default "email_frnd".
395
+	 *    @type string $pid Post ID.
396
+	 *    @type string $to_name Friend name.
397
+	 *    @type string $to_email Friend email.
398
+	 *    @type string $yourname Sender name.
399
+	 *    @type string $youremail Sender email.
400
+	 *    @type string $frnd_subject Email subject.
401
+	 *    @type string $frnd_comments Email Message.
402
+	 *
403
+	 * }
404
+	 */
405
+	do_action('geodir_before_send_to_friend_email', $request);
406
+	geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
407
+
408
+	/**
409
+	 * Called after the send to friend email is sent.
410
+	 *
411
+	 * @since 1.0.0
412
+	 * @param array $request {
413
+	 *    The submitted form fields as an array.
414
+	 *
415
+	 *    @type string $sendact Enquiry type. Default "email_frnd".
416
+	 *    @type string $pid Post ID.
417
+	 *    @type string $to_name Friend name.
418
+	 *    @type string $to_email Friend email.
419
+	 *    @type string $yourname Sender name.
420
+	 *    @type string $youremail Sender email.
421
+	 *    @type string $frnd_subject Email subject.
422
+	 *    @type string $frnd_comments Email Message.
423
+	 *
424
+	 * }
425
+	 */
426
+	do_action('geodir_after_send_to_friend_email', $request);
427
+
428
+	$url = get_permalink($pid);
429
+	if (strstr($url, '?')) {
430
+		$url = $url . "&sendtofrnd=success";
431
+	} else {
432
+		$url = $url . "?sendtofrnd=success";
433
+	}
434
+	/**
435
+	 * Filter redirect url after the send to friend email is sent.
436
+	 *
437
+	 * @since 1.0.0
438
+	 * @param string $url Redirect url.
439
+	 */
440
+	$url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
441
+	wp_redirect($url);
442
+	gd_die();
443 443
 }
444 444
 
445 445
 /**
@@ -453,28 +453,28 @@  discard block
 block discarded – undo
453 453
  */
454 454
 function geodir_before_tab_content($hash_key)
455 455
 {
456
-    switch ($hash_key) {
457
-        case 'post_info' :
458
-            echo '<div class="geodir-company_info field-group">';
459
-            break;
460
-        case 'post_images' :
461
-            /**
462
-             * Filter post gallery HTML id.
463
-             *
464
-             * @since 1.0.0
465
-             */
466
-            echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
467
-            break;
468
-        case 'reviews' :
469
-            echo '<div id="reviews-wrap" class="clearfix"> ';
470
-            break;
471
-        case 'post_video':
472
-            echo ' <div id="post_video-wrap" class="clearfix">';
473
-            break;
474
-        case 'special_offers':
475
-            echo '<div id="special_offers-wrap" class="clearfix">';
476
-            break;
477
-    }
456
+	switch ($hash_key) {
457
+		case 'post_info' :
458
+			echo '<div class="geodir-company_info field-group">';
459
+			break;
460
+		case 'post_images' :
461
+			/**
462
+			 * Filter post gallery HTML id.
463
+			 *
464
+			 * @since 1.0.0
465
+			 */
466
+			echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
467
+			break;
468
+		case 'reviews' :
469
+			echo '<div id="reviews-wrap" class="clearfix"> ';
470
+			break;
471
+		case 'post_video':
472
+			echo ' <div id="post_video-wrap" class="clearfix">';
473
+			break;
474
+		case 'special_offers':
475
+			echo '<div id="special_offers-wrap" class="clearfix">';
476
+			break;
477
+	}
478 478
 }
479 479
 
480 480
 /**
@@ -488,23 +488,23 @@  discard block
 block discarded – undo
488 488
  */
489 489
 function geodir_after_tab_content($hash_key)
490 490
 {
491
-    switch ($hash_key) {
492
-        case 'post_info' :
493
-            echo '</div>';
494
-            break;
495
-        case 'post_images' :
496
-            echo '</div>';
497
-            break;
498
-        case 'reviews' :
499
-            echo '</div>';
500
-            break;
501
-        case 'post_video':
502
-            echo '</div>';
503
-            break;
504
-        case 'special_offers':
505
-            echo '</div>';
506
-            break;
507
-    }
491
+	switch ($hash_key) {
492
+		case 'post_info' :
493
+			echo '</div>';
494
+			break;
495
+		case 'post_images' :
496
+			echo '</div>';
497
+			break;
498
+		case 'reviews' :
499
+			echo '</div>';
500
+			break;
501
+		case 'post_video':
502
+			echo '</div>';
503
+			break;
504
+		case 'special_offers':
505
+			echo '</div>';
506
+			break;
507
+	}
508 508
 }
509 509
 
510 510
 
@@ -520,21 +520,21 @@  discard block
 block discarded – undo
520 520
 function geodir_get_posts_default_sort($post_type)
521 521
 {
522 522
 
523
-    global $wpdb;
523
+	global $wpdb;
524 524
 
525
-    if ($post_type != '') {
525
+	if ($post_type != '') {
526 526
 
527
-        $all_postypes = geodir_get_posttypes();
527
+		$all_postypes = geodir_get_posttypes();
528 528
 
529
-        if (!in_array($post_type, $all_postypes))
530
-            return false;
529
+		if (!in_array($post_type, $all_postypes))
530
+			return false;
531 531
 
532
-        $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
532
+		$sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 533
 
534
-        if (!empty($sort_field_info))
535
-            return $sort_field_info;
534
+		if (!empty($sort_field_info))
535
+			return $sort_field_info;
536 536
 
537
-    }
537
+	}
538 538
 
539 539
 }
540 540
 
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
  * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false.
550 550
  */
551 551
 function geodir_get_sort_options($post_type) {
552
-    global $wpdb;
553
-
554
-    if ($post_type != '') {
555
-        $all_postypes = geodir_get_posttypes();
556
-
557
-        if (!in_array($post_type, $all_postypes))
558
-            return false;
559
-
560
-        $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561
-        /**
562
-         * Filter post sort options.
563
-         *
564
-         * @since 1.0.0
565
-         * @param array $sort_field_info Unfiltered sort field array.
566
-         * @param string $post_type Post type.
567
-         */
568
-        return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
569
-    }
552
+	global $wpdb;
553
+
554
+	if ($post_type != '') {
555
+		$all_postypes = geodir_get_posttypes();
556
+
557
+		if (!in_array($post_type, $all_postypes))
558
+			return false;
559
+
560
+		$sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561
+		/**
562
+		 * Filter post sort options.
563
+		 *
564
+		 * @since 1.0.0
565
+		 * @param array $sort_field_info Unfiltered sort field array.
566
+		 * @param string $post_type Post type.
567
+		 */
568
+		return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
569
+	}
570 570
 
571 571
 }
572 572
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
  */
581 581
 function geodir_display_sort_options()
582 582
 {
583
-    global $wp_query;
583
+	global $wp_query;
584 584
 	
585 585
 	/**
586 586
 	 * On search pages there should be no sort options, sorting is done by search criteria.
@@ -591,57 +591,57 @@  discard block
 block discarded – undo
591 591
 		return;
592 592
 	}
593 593
 
594
-    $sort_by = '';
594
+	$sort_by = '';
595 595
 
596
-    if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
596
+	if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
597 597
 
598
-    $gd_post_type = geodir_get_current_posttype();
598
+	$gd_post_type = geodir_get_current_posttype();
599 599
 
600
-    $sort_options = geodir_get_sort_options($gd_post_type);
600
+	$sort_options = geodir_get_sort_options($gd_post_type);
601 601
 
602 602
 
603
-    $sort_field_options = '';
603
+	$sort_field_options = '';
604 604
 
605
-    if (!empty($sort_options)) {
606
-        foreach ($sort_options as $sort) {
605
+	if (!empty($sort_options)) {
606
+		foreach ($sort_options as $sort) {
607 607
 			$sort = stripslashes_deep($sort); // strip slashes
608 608
 
609
-            $label = __($sort->site_title, 'geodirectory');
609
+			$label = __($sort->site_title, 'geodirectory');
610 610
 
611
-            if ($sort->field_type == 'random') {
612
-                $key = $sort->field_type;
613
-                ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
615
-            }
611
+			if ($sort->field_type == 'random') {
612
+				$key = $sort->field_type;
613
+				($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
615
+			}
616 616
 
617
-            if ($sort->htmlvar_name == 'comment_count') {
618
-                $sort->htmlvar_name = 'rating_count';
619
-            }
617
+			if ($sort->htmlvar_name == 'comment_count') {
618
+				$sort->htmlvar_name = 'rating_count';
619
+			}
620 620
 
621
-            if ($sort->sort_asc) {
622
-                $key = $sort->htmlvar_name . '_asc';
623
-                $label = $sort->site_title;
624
-                if ($sort->asc_title)
625
-                    $label = $sort->asc_title;
626
-                ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628
-            }
621
+			if ($sort->sort_asc) {
622
+				$key = $sort->htmlvar_name . '_asc';
623
+				$label = $sort->site_title;
624
+				if ($sort->asc_title)
625
+					$label = $sort->asc_title;
626
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628
+			}
629 629
 
630
-            if ($sort->sort_desc) {
631
-                $key = $sort->htmlvar_name . '_desc';
632
-                $label = $sort->site_title;
633
-                if ($sort->desc_title)
634
-                    $label = $sort->desc_title;
635
-                ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637
-            }
630
+			if ($sort->sort_desc) {
631
+				$key = $sort->htmlvar_name . '_desc';
632
+				$label = $sort->site_title;
633
+				if ($sort->desc_title)
634
+					$label = $sort->desc_title;
635
+				($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
+				$sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637
+			}
638 638
 
639
-        }
640
-    }
639
+		}
640
+	}
641 641
 
642
-    if ($sort_field_options != '') {
642
+	if ($sort_field_options != '') {
643 643
 
644
-        ?>
644
+		?>
645 645
 
646 646
         <div class="geodir-tax-sort">
647 647
 
@@ -650,14 +650,14 @@  discard block
 block discarded – undo
650 650
                 <option
651 651
                     value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
652 652
 
653
-                echo $sort_field_options;?>
653
+				echo $sort_field_options;?>
654 654
 
655 655
             </select>
656 656
 
657 657
         </div>
658 658
     <?php
659 659
 
660
-    }
660
+	}
661 661
 
662 662
 }
663 663
 
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
 function geodir_advance_customfields_heading($title, $field_type)
678 678
 {
679 679
 
680
-    if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
681
-        $title = '';
682
-    }
683
-    return $title;
680
+	if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
681
+		$title = '';
682
+	}
683
+	return $title;
684 684
 }
685 685
 
686 686
 
@@ -697,81 +697,81 @@  discard block
 block discarded – undo
697 697
  * @return string Returns related posts html.
698 698
  */
699 699
 function geodir_related_posts_display($request) {
700
-    if (!empty($request)) {
701
-        $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
702
-        $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
703
-
704
-        $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
705
-        $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
706
-        $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
707
-        $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
708
-        $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
709
-        $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
710
-        $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
711
-        $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
712
-
713
-        global $wpdb, $post, $gd_session, $related_nearest, $related_parent_lat, $related_parent_lon;
714
-        $related_parent_lat = $post->post_latitude;
715
-        $related_parent_lon = $post->post_longitude;
716
-        $arr_detail_page_tabs = geodir_detail_page_tabs_list();
717
-
718
-        $related_listing_array = array();
719
-        if (get_option('geodir_add_related_listing_posttypes'))
720
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
721
-        if (in_array($post->post_type, $related_listing_array)) {
722
-            $arr_detail_page_tabs['related_listing']['is_display'] = true;
723
-        }
700
+	if (!empty($request)) {
701
+		$before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
702
+		$after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
703
+
704
+		$title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
705
+		$post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
706
+		$relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
707
+		$layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
708
+		$add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
709
+		$listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
710
+		$list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
711
+		$character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
712
+
713
+		global $wpdb, $post, $gd_session, $related_nearest, $related_parent_lat, $related_parent_lon;
714
+		$related_parent_lat = $post->post_latitude;
715
+		$related_parent_lon = $post->post_longitude;
716
+		$arr_detail_page_tabs = geodir_detail_page_tabs_list();
717
+
718
+		$related_listing_array = array();
719
+		if (get_option('geodir_add_related_listing_posttypes'))
720
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
721
+		if (in_array($post->post_type, $related_listing_array)) {
722
+			$arr_detail_page_tabs['related_listing']['is_display'] = true;
723
+		}
724 724
 
725
-        $is_display = $arr_detail_page_tabs['related_listing']['is_display'];
726
-        $origi_post = $post;
727
-        $post_type = '';
728
-        $post_id = '';
729
-        $category_taxonomy = '';
730
-        $tax_field = 'id';
731
-        $category = array();
732
-
733
-        if (isset($_REQUEST['backandedit'])) {
734
-            $post = (object)$gd_session->get('listing');
735
-            $post_type = $post->listing_type;
736
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
737
-                $post_id = $_REQUEST['pid'];
738
-        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
739
-            $post = geodir_get_post_info($_REQUEST['pid']);
740
-            $post_type = $post->post_type;
741
-            $post_id = $_REQUEST['pid'];
742
-        } elseif (isset($post->post_type) && $post->post_type != '') {
743
-            $post_type = $post->post_type;
744
-            $post_id = $post->ID;
745
-        }
725
+		$is_display = $arr_detail_page_tabs['related_listing']['is_display'];
726
+		$origi_post = $post;
727
+		$post_type = '';
728
+		$post_id = '';
729
+		$category_taxonomy = '';
730
+		$tax_field = 'id';
731
+		$category = array();
732
+
733
+		if (isset($_REQUEST['backandedit'])) {
734
+			$post = (object)$gd_session->get('listing');
735
+			$post_type = $post->listing_type;
736
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
737
+				$post_id = $_REQUEST['pid'];
738
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
739
+			$post = geodir_get_post_info($_REQUEST['pid']);
740
+			$post_type = $post->post_type;
741
+			$post_id = $_REQUEST['pid'];
742
+		} elseif (isset($post->post_type) && $post->post_type != '') {
743
+			$post_type = $post->post_type;
744
+			$post_id = $post->ID;
745
+		}
746 746
 
747
-        if ($relate_to == 'category') {
747
+		if ($relate_to == 'category') {
748 748
 
749
-            $category_taxonomy = $post_type . $relate_to;
750
-            if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
751
-                $category = explode(',', trim($post->{$category_taxonomy}, ','));
749
+			$category_taxonomy = $post_type . $relate_to;
750
+			if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
751
+				$category = explode(',', trim($post->{$category_taxonomy}, ','));
752 752
 
753
-        } elseif ($relate_to == 'tags') {
753
+		} elseif ($relate_to == 'tags') {
754 754
 
755
-            $category_taxonomy = $post_type . '_' . $relate_to;
756
-            if ($post->post_tags != '')
757
-                $category = explode(',', trim($post->post_tags, ','));
758
-            $tax_field = 'name';
759
-        }
755
+			$category_taxonomy = $post_type . '_' . $relate_to;
756
+			if ($post->post_tags != '')
757
+				$category = explode(',', trim($post->post_tags, ','));
758
+			$tax_field = 'name';
759
+		}
760 760
 
761
-        /* --- return false in invalid request --- */
762
-        if (empty($category))
763
-            return false;
761
+		/* --- return false in invalid request --- */
762
+		if (empty($category))
763
+			return false;
764 764
 
765
-        $all_postypes = geodir_get_posttypes();
765
+		$all_postypes = geodir_get_posttypes();
766 766
 
767
-        if (!in_array($post_type, $all_postypes))
768
-            return false;
767
+		if (!in_array($post_type, $all_postypes))
768
+			return false;
769 769
 
770
-        /* --- return false in invalid request --- */
770
+		/* --- return false in invalid request --- */
771 771
 
772
-       $location_url = '';
773
-        if ($add_location_filter != '0') {
774
-            $location_url = array();
772
+	   $location_url = '';
773
+		if ($add_location_filter != '0') {
774
+			$location_url = array();
775 775
 			$geodir_show_location_url = get_option('geodir_show_location_url');
776 776
 			
777 777
 			$gd_city = get_query_var('gd_city');
@@ -779,13 +779,13 @@  discard block
 block discarded – undo
779 779
 			if ($gd_city) {
780 780
 				$gd_country = get_query_var('gd_country');
781 781
 				$gd_region = get_query_var('gd_region');
782
-            } else {
783
-                $location = geodir_get_default_location();
782
+			} else {
783
+				$location = geodir_get_default_location();
784 784
 				
785 785
 				$gd_country = isset($location->country_slug) ? $location->country_slug : '';
786 786
 				$gd_region = isset($location->region_slug) ? $location->region_slug : '';
787 787
 				$gd_city = isset($location->city_slug) ? $location->city_slug : '';
788
-            }
788
+			}
789 789
 			
790 790
 			if ($geodir_show_location_url == 'all') {
791 791
 				$location_url[] = $gd_country;
@@ -798,100 +798,100 @@  discard block
 block discarded – undo
798 798
 			
799 799
 			$location_url[] = $gd_city;
800 800
 
801
-            $location_url = implode('/', $location_url);
802
-        }
801
+			$location_url = implode('/', $location_url);
802
+		}
803 803
 
804 804
 
805
-        if (!empty($category)) {
806
-            global $geodir_add_location_url;
807
-            $geodir_add_location_url = '0';
808
-            if ($add_location_filter != '0') {
809
-                $geodir_add_location_url = '1';
810
-            }
811
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
812
-            $geodir_add_location_url = NULL;
813
-        }
814
-        ob_start();
815
-        ?>
805
+		if (!empty($category)) {
806
+			global $geodir_add_location_url;
807
+			$geodir_add_location_url = '0';
808
+			if ($add_location_filter != '0') {
809
+				$geodir_add_location_url = '1';
810
+			}
811
+			$viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
812
+			$geodir_add_location_url = NULL;
813
+		}
814
+		ob_start();
815
+		?>
816 816
 
817 817
 
818 818
         <div class="geodir_locations geodir_location_listing">
819 819
 
820 820
             <?php
821
-            if (isset($request['is_widget']) && $request['is_widget'] == '1') {
822
-                /** geodir_before_title filter Documented in geodirectory_widgets.php */
823
-                $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
824
-                /** geodir_after_title filter Documented in geodirectory_widgets.php */
825
-                $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
826
-                ?>
821
+			if (isset($request['is_widget']) && $request['is_widget'] == '1') {
822
+				/** geodir_before_title filter Documented in geodirectory_widgets.php */
823
+				$before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
824
+				/** geodir_after_title filter Documented in geodirectory_widgets.php */
825
+				$after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
826
+				?>
827 827
                 <div class="location_list_heading clearfix">
828 828
                     <?php echo $before_title . $title . $after_title; ?>
829 829
                 </div>
830 830
             <?php
831
-            }
832
-            $query_args = array(
833
-                'posts_per_page' => $post_number,
834
-                'is_geodir_loop' => true,
835
-                'gd_location' => ($add_location_filter) ? true : false,
836
-                'post_type' => $post_type,
837
-                'order_by' => $list_sort,
838
-                'post__not_in' => array($post_id),
839
-                'excerpt_length' => $character_count,
840
-                'related_listings' => $is_display
841
-            );
831
+			}
832
+			$query_args = array(
833
+				'posts_per_page' => $post_number,
834
+				'is_geodir_loop' => true,
835
+				'gd_location' => ($add_location_filter) ? true : false,
836
+				'post_type' => $post_type,
837
+				'order_by' => $list_sort,
838
+				'post__not_in' => array($post_id),
839
+				'excerpt_length' => $character_count,
840
+				'related_listings' => $is_display
841
+			);
842 842
 
843
-            $tax_query = array('taxonomy' => $category_taxonomy,
844
-                'field' => $tax_field,
845
-                'terms' => $category
846
-            );
843
+			$tax_query = array('taxonomy' => $category_taxonomy,
844
+				'field' => $tax_field,
845
+				'terms' => $category
846
+			);
847 847
 
848
-            $query_args['tax_query'] = array($tax_query);
848
+			$query_args['tax_query'] = array($tax_query);
849 849
 
850 850
 
851
-            global $gridview_columns, $post;
851
+			global $gridview_columns, $post;
852 852
 
853 853
 
854
-            query_posts($query_args);
854
+			query_posts($query_args);
855 855
 
856
-            if (strstr($layout, 'gridview')) {
857
-                $listing_view_exp = explode('_', $layout);
858
-                $gridview_columns = $layout;
859
-                $layout = $listing_view_exp[0];
860
-            } else if ($layout == 'list') {
861
-                $gridview_columns = '';
862
-            }
863
-            $related_posts = true;
856
+			if (strstr($layout, 'gridview')) {
857
+				$listing_view_exp = explode('_', $layout);
858
+				$gridview_columns = $layout;
859
+				$layout = $listing_view_exp[0];
860
+			} else if ($layout == 'list') {
861
+				$gridview_columns = '';
862
+			}
863
+			$related_posts = true;
864 864
 
865
-            $related_nearest = false;
866
-            if ($list_sort == 'nearest') {
867
-                $related_nearest = true;
868
-            }
865
+			$related_nearest = false;
866
+			if ($list_sort == 'nearest') {
867
+				$related_nearest = true;
868
+			}
869 869
 
870 870
 
871
-            /**
872
-             * Filters related listing listview template.
873
-             *
874
-             * @since 1.0.0
875
-             */
876
-            $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
871
+			/**
872
+			 * Filters related listing listview template.
873
+			 *
874
+			 * @since 1.0.0
875
+			 */
876
+			$template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
877 877
 
878
-            /**
879
-             * Includes related listing listview template.
880
-             *
881
-             * @since 1.0.0
882
-             */
883
-            include($template);
878
+			/**
879
+			 * Includes related listing listview template.
880
+			 *
881
+			 * @since 1.0.0
882
+			 */
883
+			include($template);
884 884
 
885
-            wp_reset_query();
886
-            $post = $origi_post;
887
-            $related_nearest = false;
888
-            ?>
885
+			wp_reset_query();
886
+			$post = $origi_post;
887
+			$related_nearest = false;
888
+			?>
889 889
 
890 890
         </div>
891 891
         <?php
892
-        return $html = ob_get_clean();
892
+		return $html = ob_get_clean();
893 893
 
894
-    }
894
+	}
895 895
 
896 896
 }
897 897
 
@@ -907,17 +907,17 @@  discard block
 block discarded – undo
907 907
  */
908 908
 function geodir_category_count_script()
909 909
 {
910
-    global $geodir_post_category_str;
910
+	global $geodir_post_category_str;
911 911
 
912
-    if (!empty($geodir_post_category_str)) {
913
-        $geodir_post_category_str = serialize($geodir_post_category_str);
914
-    }
912
+	if (!empty($geodir_post_category_str)) {
913
+		$geodir_post_category_str = serialize($geodir_post_category_str);
914
+	}
915 915
 
916
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
917
-    $script = "var post_category_array = " . json_encode($all_var) . ';';
918
-    echo '<script>';
919
-    echo $script;
920
-    echo '</script>';
916
+	$all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
917
+	$script = "var post_category_array = " . json_encode($all_var) . ';';
918
+	echo '<script>';
919
+	echo $script;
920
+	echo '</script>';
921 921
 
922 922
 }
923 923
 
@@ -930,16 +930,16 @@  discard block
 block discarded – undo
930 930
  */
931 931
 function geodir_get_map_default_language()
932 932
 {
933
-    $geodir_default_map_language = get_option('geodir_default_map_language');
934
-    if (empty($geodir_default_map_language))
935
-        $geodir_default_map_language = 'en';
936
-    /**
937
-     * Filter default map language.
938
-     *
939
-     * @since 1.0.0
940
-     * @param string $geodir_default_map_language Default map language.
941
-     */
942
-    return apply_filters('geodir_default_map_language', $geodir_default_map_language);
933
+	$geodir_default_map_language = get_option('geodir_default_map_language');
934
+	if (empty($geodir_default_map_language))
935
+		$geodir_default_map_language = 'en';
936
+	/**
937
+	 * Filter default map language.
938
+	 *
939
+	 * @since 1.0.0
940
+	 * @param string $geodir_default_map_language Default map language.
941
+	 */
942
+	return apply_filters('geodir_default_map_language', $geodir_default_map_language);
943 943
 }
944 944
 
945 945
 /**
@@ -951,14 +951,14 @@  discard block
 block discarded – undo
951 951
  */
952 952
 function geodir_get_map_api_key()
953 953
 {
954
-    $key = get_option('geodir_google_api_key');
955
-    /**
956
-     * Filter Google maps api key.
957
-     *
958
-     * @since 1.6.4
959
-     * @param string $key Google maps api key.
960
-     */
961
-    return apply_filters('geodir_google_api_key', $key);
954
+	$key = get_option('geodir_google_api_key');
955
+	/**
956
+	 * Filter Google maps api key.
957
+	 *
958
+	 * @since 1.6.4
959
+	 * @param string $key Google maps api key.
960
+	 */
961
+	return apply_filters('geodir_google_api_key', $key);
962 962
 }
963 963
 
964 964
 
@@ -975,12 +975,12 @@  discard block
 block discarded – undo
975 975
  */
976 976
 function geodir_add_meta_keywords()
977 977
 {
978
-    global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
978
+	global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
979 979
 
980
-    $is_geodir_page = geodir_is_geodir_page();
981
-    if (!$is_geodir_page) {
982
-        return;
983
-    }// if non GD page, bail
980
+	$is_geodir_page = geodir_is_geodir_page();
981
+	if (!$is_geodir_page) {
982
+		return;
983
+	}// if non GD page, bail
984 984
 
985 985
 	$use_gd_meta = true;
986 986
 	if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
@@ -995,182 +995,182 @@  discard block
 block discarded – undo
995 995
 		return;
996 996
 	}// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active.
997 997
 
998
-    $current_term = $wp_query->get_queried_object();
998
+	$current_term = $wp_query->get_queried_object();
999 999
 
1000
-    $all_postypes = geodir_get_posttypes();
1000
+	$all_postypes = geodir_get_posttypes();
1001 1001
 
1002
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1002
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1003 1003
 
1004
-    $meta_desc = '';
1005
-    $meta_key = '';
1006
-    if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
1007
-        /**
1008
-         * Filter SEO meta location description.
1009
-         *
1010
-         * @since 1.0.0
1011
-         */
1012
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
1013
-        $meta_desc .= '';
1014
-    }
1015
-    if (have_posts() && is_single() OR is_page()) {
1016
-        while (have_posts()) {
1017
-            the_post();
1018
-
1019
-            if (has_excerpt()) {
1020
-                $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
1021
-                if (empty($out_excerpt)) {
1022
-                    $out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
1023
-                }
1024
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
1025
-            } else {
1026
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
1027
-                $out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
1028
-                if (empty($out_excerpt)) {
1029
-                    $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
1030
-                }
1031
-                $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
1032
-            }
1004
+	$meta_desc = '';
1005
+	$meta_key = '';
1006
+	if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
1007
+		/**
1008
+		 * Filter SEO meta location description.
1009
+		 *
1010
+		 * @since 1.0.0
1011
+		 */
1012
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', '');
1013
+		$meta_desc .= '';
1014
+	}
1015
+	if (have_posts() && is_single() OR is_page()) {
1016
+		while (have_posts()) {
1017
+			the_post();
1018
+
1019
+			if (has_excerpt()) {
1020
+				$out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
1021
+				if (empty($out_excerpt)) {
1022
+					$out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
1023
+				}
1024
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
1025
+			} else {
1026
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
1027
+				$out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
1028
+				if (empty($out_excerpt)) {
1029
+					$out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
1030
+				}
1031
+				$out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
1032
+			}
1033 1033
 
1034
-            $meta_desc .= $out_excerpt;
1035
-        }
1036
-    } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1037
-        if (is_category()) {
1038
-            $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1039
-        } elseif (is_tag()) {
1040
-            $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1041
-        }
1042
-    } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1043
-        $meta_desc .= isset($current_term->description) ? $current_term->description : '';
1044
-    }
1034
+			$meta_desc .= $out_excerpt;
1035
+		}
1036
+	} elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1037
+		if (is_category()) {
1038
+			$meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1039
+		} elseif (is_tag()) {
1040
+			$meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1041
+		}
1042
+	} elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1043
+		$meta_desc .= isset($current_term->description) ? $current_term->description : '';
1044
+	}
1045 1045
 
1046 1046
 
1047
-    $geodir_post_type = geodir_get_current_posttype();
1048
-    $geodir_post_type_info = get_post_type_object($geodir_post_type);
1049
-    $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1050
-
1051
-    $category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1052
-    $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1053
-
1054
-    $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1055
-    $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1056
-
1057
-    $geodir_is_search = geodir_is_page('search') ? true : false;
1058
-    $geodir_is_location = geodir_is_page('location') ? true : false;
1059
-    $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1060
-    $godir_location_terms = geodir_get_current_location_terms('query_vars');
1061
-    $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1062
-    $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1063
-    $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1064
-    $replace_location = __('Everywhere', 'geodirectory');
1065
-    $location_id = NULL;
1066
-    if ($geodir_location_manager) {
1067
-        $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1068
-        $location_id = (int)$wpdb->get_var($sql);
1069
-        $location_type = geodir_what_is_current_location();
1070
-        if ($location_type == 'city') {
1071
-            $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1072
-        } elseif ($location_type == 'region') {
1073
-            $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1074
-        } elseif ($location_type == 'country') {
1075
-            $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1076
-            $replace_location = __($replace_location, 'geodirectory');
1077
-        }
1078
-        $country = get_query_var('gd_country');
1079
-        $region = get_query_var('gd_region');
1080
-        $city = get_query_var('gd_city');
1081
-        $current_location = '';
1082
-        if ($country != '') {
1083
-            $current_location = get_actual_location_name('country', $country, true);
1084
-        }
1085
-        if ($region != '') {
1086
-            $current_location = get_actual_location_name('region', $region);
1087
-        }
1088
-        if ($city != '') {
1089
-            $current_location = get_actual_location_name('city', $city);
1090
-        }
1091
-        $replace_location = $current_location != '' ? $current_location : $replace_location;
1092
-    }
1047
+	$geodir_post_type = geodir_get_current_posttype();
1048
+	$geodir_post_type_info = get_post_type_object($geodir_post_type);
1049
+	$geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1050
+
1051
+	$category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1052
+	$tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1053
+
1054
+	$geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1055
+	$geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1056
+
1057
+	$geodir_is_search = geodir_is_page('search') ? true : false;
1058
+	$geodir_is_location = geodir_is_page('location') ? true : false;
1059
+	$geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1060
+	$godir_location_terms = geodir_get_current_location_terms('query_vars');
1061
+	$gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1062
+	$gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1063
+	$gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1064
+	$replace_location = __('Everywhere', 'geodirectory');
1065
+	$location_id = NULL;
1066
+	if ($geodir_location_manager) {
1067
+		$sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1068
+		$location_id = (int)$wpdb->get_var($sql);
1069
+		$location_type = geodir_what_is_current_location();
1070
+		if ($location_type == 'city') {
1071
+			$replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1072
+		} elseif ($location_type == 'region') {
1073
+			$replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1074
+		} elseif ($location_type == 'country') {
1075
+			$replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1076
+			$replace_location = __($replace_location, 'geodirectory');
1077
+		}
1078
+		$country = get_query_var('gd_country');
1079
+		$region = get_query_var('gd_region');
1080
+		$city = get_query_var('gd_city');
1081
+		$current_location = '';
1082
+		if ($country != '') {
1083
+			$current_location = get_actual_location_name('country', $country, true);
1084
+		}
1085
+		if ($region != '') {
1086
+			$current_location = get_actual_location_name('region', $region);
1087
+		}
1088
+		if ($city != '') {
1089
+			$current_location = get_actual_location_name('city', $city);
1090
+		}
1091
+		$replace_location = $current_location != '' ? $current_location : $replace_location;
1092
+	}
1093 1093
 
1094
-    $geodir_meta_keys = '';
1095
-    $geodir_meta_desc = '';
1096
-    if ($is_geodir_page && !empty($geodir_post_type_info)) {
1097
-        if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1098
-            $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1099
-
1100
-            $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1101
-            $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1102
-
1103
-            if ($geodir_is_category) {
1104
-                $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1105
-                if (isset($category->term_id) && !empty($category->term_id)) {
1106
-                    $category_id = $category->term_id;
1107
-                    $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1108
-                    if ($location_id) {
1109
-                        $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1110
-                        $cat_loc_option = get_option($option_name);
1111
-
1112
-                        $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1113
-                        if (!$gd_cat_loc_default) {
1114
-                            $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1115
-                            $option = get_option($option_name);
1116
-                            $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1117
-                        }
1118
-                    }
1119
-                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1120
-                }
1121
-            } else if ($geodir_is_tag) {
1122
-                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1123
-            }
1124
-        }
1125
-    }
1094
+	$geodir_meta_keys = '';
1095
+	$geodir_meta_desc = '';
1096
+	if ($is_geodir_page && !empty($geodir_post_type_info)) {
1097
+		if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1098
+			$geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1099
+
1100
+			$geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1101
+			$geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1102
+
1103
+			if ($geodir_is_category) {
1104
+				$category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1105
+				if (isset($category->term_id) && !empty($category->term_id)) {
1106
+					$category_id = $category->term_id;
1107
+					$category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1108
+					if ($location_id) {
1109
+						$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1110
+						$cat_loc_option = get_option($option_name);
1111
+
1112
+						$gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1113
+						if (!$gd_cat_loc_default) {
1114
+							$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1115
+							$option = get_option($option_name);
1116
+							$category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1117
+						}
1118
+					}
1119
+					$geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1120
+				}
1121
+			} else if ($geodir_is_tag) {
1122
+				$geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1123
+			}
1124
+		}
1125
+	}
1126 1126
 
1127 1127
 
1128
-    $gd_page = '';
1129
-    if(geodir_is_page('home')){
1130
-        $gd_page = 'home';
1131
-        $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1132
-    }
1133
-    elseif(geodir_is_page('detail')){
1134
-        $gd_page = 'detail';
1135
-        $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1136
-    }
1137
-    elseif(geodir_is_page('pt')){
1138
-        $gd_page = 'pt';
1139
-        $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1140
-    }
1141
-    elseif(geodir_is_page('listing')){
1142
-        $gd_page = 'listing';
1143
-        $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1144
-    }
1145
-    elseif(geodir_is_page('location')){
1146
-        $gd_page = 'location';
1147
-        $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1148
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1128
+	$gd_page = '';
1129
+	if(geodir_is_page('home')){
1130
+		$gd_page = 'home';
1131
+		$meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1132
+	}
1133
+	elseif(geodir_is_page('detail')){
1134
+		$gd_page = 'detail';
1135
+		$meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1136
+	}
1137
+	elseif(geodir_is_page('pt')){
1138
+		$gd_page = 'pt';
1139
+		$meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1140
+	}
1141
+	elseif(geodir_is_page('listing')){
1142
+		$gd_page = 'listing';
1143
+		$meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1144
+	}
1145
+	elseif(geodir_is_page('location')){
1146
+		$gd_page = 'location';
1147
+		$meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1148
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1149 1149
 
1150
-    }
1151
-    elseif(geodir_is_page('search')){
1152
-        $gd_page = 'search';
1153
-        $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1154
-    }
1155
-    elseif(geodir_is_page('add-listing')){
1156
-        $gd_page = 'add-listing';
1157
-        $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1158
-    }
1159
-    elseif(geodir_is_page('author')){
1160
-        $gd_page = 'author';
1161
-        $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1162
-    }
1163
-    elseif(geodir_is_page('login')){
1164
-        $gd_page = 'login';
1165
-        $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1166
-    }
1167
-    elseif(geodir_is_page('listing-success')){
1168
-        $gd_page = 'listing-success';
1169
-        $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1170
-    }
1150
+	}
1151
+	elseif(geodir_is_page('search')){
1152
+		$gd_page = 'search';
1153
+		$meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1154
+	}
1155
+	elseif(geodir_is_page('add-listing')){
1156
+		$gd_page = 'add-listing';
1157
+		$meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1158
+	}
1159
+	elseif(geodir_is_page('author')){
1160
+		$gd_page = 'author';
1161
+		$meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1162
+	}
1163
+	elseif(geodir_is_page('login')){
1164
+		$gd_page = 'login';
1165
+		$meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1166
+	}
1167
+	elseif(geodir_is_page('listing-success')){
1168
+		$gd_page = 'listing-success';
1169
+		$meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1170
+	}
1171 1171
 
1172 1172
 
1173
-    /*
1173
+	/*
1174 1174
     $geodir_meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc;
1175 1175
     if ($geodir_meta_desc != '') {
1176 1176
         $geodir_meta_desc = strip_tags($geodir_meta_desc);
@@ -1183,74 +1183,74 @@  discard block
 block discarded – undo
1183 1183
     */
1184 1184
 
1185 1185
 
1186
-    if ($meta_desc) {
1187
-        $meta_desc = stripslashes_deep($meta_desc);
1188
-        /**
1189
-         * Filter page description to replace variables.
1190
-         *
1191
-         * @since 1.5.4
1192
-         * @param string $title The page description including variables.
1193
-         * @param string $gd_page The GeoDirectory page type if any.
1194
-         */
1195
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1196
-
1197
-        /**
1198
-         * Filter SEO meta description.
1199
-         *
1200
-         * @since 1.0.0
1201
-         * @param string $meta_desc Meta description content.
1202
-         */
1203
-        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1204
-    }
1186
+	if ($meta_desc) {
1187
+		$meta_desc = stripslashes_deep($meta_desc);
1188
+		/**
1189
+		 * Filter page description to replace variables.
1190
+		 *
1191
+		 * @since 1.5.4
1192
+		 * @param string $title The page description including variables.
1193
+		 * @param string $gd_page The GeoDirectory page type if any.
1194
+		 */
1195
+		$meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1196
+
1197
+		/**
1198
+		 * Filter SEO meta description.
1199
+		 *
1200
+		 * @since 1.0.0
1201
+		 * @param string $meta_desc Meta description content.
1202
+		 */
1203
+		echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1204
+	}
1205 1205
 
1206
-    // meta keywords
1207
-    if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1208
-        $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1209
-        $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1210
-
1211
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1212
-    } else {
1213
-        $posttags = get_the_tags();
1214
-        if ($posttags) {
1215
-            foreach ($posttags as $tag) {
1216
-                $meta_key .= $tag->name . ' ';
1217
-            }
1218
-        } else {
1219
-            $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1220
-            $xt = 1;
1206
+	// meta keywords
1207
+	if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1208
+		$place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1209
+		$place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1210
+
1211
+		$meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1212
+	} else {
1213
+		$posttags = get_the_tags();
1214
+		if ($posttags) {
1215
+			foreach ($posttags as $tag) {
1216
+				$meta_key .= $tag->name . ' ';
1217
+			}
1218
+		} else {
1219
+			$tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1220
+			$xt = 1;
1221 1221
 
1222
-            foreach ($tags as $tag) {
1223
-                if ($xt <= 20) {
1224
-                    $meta_key .= $tag->name . ", ";
1225
-                }
1222
+			foreach ($tags as $tag) {
1223
+				if ($xt <= 20) {
1224
+					$meta_key .= $tag->name . ", ";
1225
+				}
1226 1226
 
1227
-                $xt++;
1228
-            }
1229
-        }
1230
-    }
1227
+				$xt++;
1228
+			}
1229
+		}
1230
+	}
1231 1231
 
1232
-    $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1233
-    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1234
-    if ($geodir_meta_keys != '') {
1235
-        $geodir_meta_keys = strip_tags($geodir_meta_keys);
1236
-        $geodir_meta_keys = esc_html($geodir_meta_keys);
1237
-        $geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1238
-        $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1239
-        $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1232
+	$meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1233
+	$geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1234
+	if ($geodir_meta_keys != '') {
1235
+		$geodir_meta_keys = strip_tags($geodir_meta_keys);
1236
+		$geodir_meta_keys = esc_html($geodir_meta_keys);
1237
+		$geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1238
+		$geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1239
+		$geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1240 1240
 
1241
-        $meta_key = rtrim(trim($geodir_meta_keys), ",");
1242
-    }
1241
+		$meta_key = rtrim(trim($geodir_meta_keys), ",");
1242
+	}
1243 1243
 
1244
-    if ($meta_key) {
1245
-        $meta_key = stripslashes_deep($meta_key);
1246
-        /**
1247
-         * Filter SEO meta keywords.
1248
-         *
1249
-         * @since 1.0.0
1250
-         * @param string $meta_desc Meta keywords.
1251
-         */
1252
-        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1253
-    }
1244
+	if ($meta_key) {
1245
+		$meta_key = stripslashes_deep($meta_key);
1246
+		/**
1247
+		 * Filter SEO meta keywords.
1248
+		 *
1249
+		 * @since 1.0.0
1250
+		 * @param string $meta_desc Meta keywords.
1251
+		 */
1252
+		echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1253
+	}
1254 1254
 
1255 1255
 }
1256 1256
 
@@ -1265,14 +1265,14 @@  discard block
 block discarded – undo
1265 1265
  */
1266 1266
 function geodir_detail_page_tabs_key_value_array()
1267 1267
 {
1268
-    $geodir_detail_page_tabs_key_value_array = array();
1268
+	$geodir_detail_page_tabs_key_value_array = array();
1269 1269
 
1270
-    $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1270
+	$geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1271 1271
 
1272
-    foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1273
-        $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1274
-    }
1275
-    return $geodir_detail_page_tabs_key_value_array;
1272
+	foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1273
+		$geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1274
+	}
1275
+	return $geodir_detail_page_tabs_key_value_array;
1276 1276
 }
1277 1277
 
1278 1278
 /**
@@ -1285,73 +1285,73 @@  discard block
 block discarded – undo
1285 1285
 function geodir_detail_page_tabs_array()
1286 1286
 {
1287 1287
 
1288
-    $arr_tabs = array();
1289
-    /**
1290
-     * Filter detail page tab display.
1291
-     *
1292
-     * @since 1.0.0
1293
-     */
1294
-    $arr_tabs['post_profile'] = array(
1295
-        'heading_text' => __('Profile', 'geodirectory'),
1296
-        'is_active_tab' => true,
1297
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1298
-        'tab_content' => ''
1299
-    );
1300
-    $arr_tabs['post_info'] = array(
1301
-        'heading_text' => __('More Info', 'geodirectory'),
1302
-        'is_active_tab' => false,
1303
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1304
-        'tab_content' => ''
1305
-    );
1306
-
1307
-    $arr_tabs['post_images'] = array(
1308
-        'heading_text' => __('Photo', 'geodirectory'),
1309
-        'is_active_tab' => false,
1310
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1311
-        'tab_content' => ''
1312
-    );
1313
-
1314
-    $arr_tabs['post_video'] = array(
1315
-        'heading_text' => __('Video', 'geodirectory'),
1316
-        'is_active_tab' => false,
1317
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1318
-        'tab_content' => ''
1319
-    );
1320
-
1321
-    $arr_tabs['special_offers'] = array(
1322
-        'heading_text' => __('Special Offers', 'geodirectory'),
1323
-        'is_active_tab' => false,
1324
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1325
-        'tab_content' => ''
1326
-    );
1327
-
1328
-    $arr_tabs['post_map'] = array(
1329
-        'heading_text' => __('Map', 'geodirectory'),
1330
-        'is_active_tab' => false,
1331
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1332
-        'tab_content' => ''
1333
-    );
1334
-
1335
-    $arr_tabs['reviews'] = array(
1336
-        'heading_text' => __('Reviews', 'geodirectory'),
1337
-        'is_active_tab' => false,
1338
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1339
-        'tab_content' => 'review display'
1340
-    );
1341
-
1342
-    $arr_tabs['related_listing'] = array(
1343
-        'heading_text' => __('Related Listing', 'geodirectory'),
1344
-        'is_active_tab' => false,
1345
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1346
-        'tab_content' => ''
1347
-    );
1348
-
1349
-    /**
1350
-     * Filter the tabs array.
1351
-     *
1352
-     * @since 1.0.0
1353
-     */
1354
-    return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1288
+	$arr_tabs = array();
1289
+	/**
1290
+	 * Filter detail page tab display.
1291
+	 *
1292
+	 * @since 1.0.0
1293
+	 */
1294
+	$arr_tabs['post_profile'] = array(
1295
+		'heading_text' => __('Profile', 'geodirectory'),
1296
+		'is_active_tab' => true,
1297
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1298
+		'tab_content' => ''
1299
+	);
1300
+	$arr_tabs['post_info'] = array(
1301
+		'heading_text' => __('More Info', 'geodirectory'),
1302
+		'is_active_tab' => false,
1303
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1304
+		'tab_content' => ''
1305
+	);
1306
+
1307
+	$arr_tabs['post_images'] = array(
1308
+		'heading_text' => __('Photo', 'geodirectory'),
1309
+		'is_active_tab' => false,
1310
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1311
+		'tab_content' => ''
1312
+	);
1313
+
1314
+	$arr_tabs['post_video'] = array(
1315
+		'heading_text' => __('Video', 'geodirectory'),
1316
+		'is_active_tab' => false,
1317
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1318
+		'tab_content' => ''
1319
+	);
1320
+
1321
+	$arr_tabs['special_offers'] = array(
1322
+		'heading_text' => __('Special Offers', 'geodirectory'),
1323
+		'is_active_tab' => false,
1324
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1325
+		'tab_content' => ''
1326
+	);
1327
+
1328
+	$arr_tabs['post_map'] = array(
1329
+		'heading_text' => __('Map', 'geodirectory'),
1330
+		'is_active_tab' => false,
1331
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1332
+		'tab_content' => ''
1333
+	);
1334
+
1335
+	$arr_tabs['reviews'] = array(
1336
+		'heading_text' => __('Reviews', 'geodirectory'),
1337
+		'is_active_tab' => false,
1338
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1339
+		'tab_content' => 'review display'
1340
+	);
1341
+
1342
+	$arr_tabs['related_listing'] = array(
1343
+		'heading_text' => __('Related Listing', 'geodirectory'),
1344
+		'is_active_tab' => false,
1345
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1346
+		'tab_content' => ''
1347
+	);
1348
+
1349
+	/**
1350
+	 * Filter the tabs array.
1351
+	 *
1352
+	 * @since 1.0.0
1353
+	 */
1354
+	return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1355 1355
 
1356 1356
 
1357 1357
 }
@@ -1366,15 +1366,15 @@  discard block
 block discarded – undo
1366 1366
  */
1367 1367
 function geodir_detail_page_tabs_list()
1368 1368
 {
1369
-    $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1370
-    $tabs_array = geodir_detail_page_tabs_array();
1371
-    if (!empty($tabs_excluded)) {
1372
-        foreach ($tabs_excluded as $tab) {
1373
-            if (array_key_exists($tab, $tabs_array))
1374
-                unset($tabs_array[$tab]);
1375
-        }
1376
-    }
1377
-    return $tabs_array;
1369
+	$tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1370
+	$tabs_array = geodir_detail_page_tabs_array();
1371
+	if (!empty($tabs_excluded)) {
1372
+		foreach ($tabs_excluded as $tab) {
1373
+			if (array_key_exists($tab, $tabs_array))
1374
+				unset($tabs_array[$tab]);
1375
+		}
1376
+	}
1377
+	return $tabs_array;
1378 1378
 }
1379 1379
 
1380 1380
 
@@ -1392,160 +1392,160 @@  discard block
 block discarded – undo
1392 1392
  */
1393 1393
 function geodir_show_detail_page_tabs()
1394 1394
 {
1395
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1395
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1396 1396
 
1397
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1398
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1399
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1397
+	$post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1398
+	$request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1399
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1400 1400
 
1401
-    if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1402
-        $post = geodir_get_post_info($request_post_id);
1403
-        setup_postdata($post);
1404
-    }
1401
+	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1402
+		$post = geodir_get_post_info($request_post_id);
1403
+		setup_postdata($post);
1404
+	}
1405 1405
 
1406
-    $geodir_post_detail_fields = geodir_show_listing_info('detail');
1406
+	$geodir_post_detail_fields = geodir_show_listing_info('detail');
1407 1407
 
1408
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1408
+	$arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1409 1409
 
1410
-    if (geodir_is_page('detail')) {
1411
-        $video = geodir_get_video($post->ID);
1412
-        $special_offers = geodir_get_special_offers($post->ID);
1413
-        $related_listing_array = array();
1414
-        if (get_option('geodir_add_related_listing_posttypes'))
1415
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1410
+	if (geodir_is_page('detail')) {
1411
+		$video = geodir_get_video($post->ID);
1412
+		$special_offers = geodir_get_special_offers($post->ID);
1413
+		$related_listing_array = array();
1414
+		if (get_option('geodir_add_related_listing_posttypes'))
1415
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
1416 1416
 
1417
-        if (in_array($post->post_type, $related_listing_array) && isset($arr_detail_page_tabs['related_listing'])) {
1418
-            $arr_detail_page_tabs['related_listing']['is_display'] = true;
1419
-        }
1417
+		if (in_array($post->post_type, $related_listing_array) && isset($arr_detail_page_tabs['related_listing'])) {
1418
+			$arr_detail_page_tabs['related_listing']['is_display'] = true;
1419
+		}
1420 1420
 
1421
-        $related_listing = '';
1422
-        if (in_array($post->post_type, $related_listing_array) && isset($arr_detail_page_tabs['related_listing']['is_display']) && $arr_detail_page_tabs['related_listing']['is_display']) {
1423
-            $request = array('post_number' => get_option('geodir_related_post_count'),
1424
-                'relate_to' => get_option('geodir_related_post_relate_to'),
1425
-                'layout' => get_option('geodir_related_post_listing_view'),
1426
-                'add_location_filter' => get_option('geodir_related_post_location_filter'),
1427
-                'list_sort' => get_option('geodir_related_post_sortby'),
1428
-                'character_count' => get_option('geodir_related_post_excerpt'));
1429
-
1430
-            if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1431
-                $related_listing = geodir_get_detail_page_related_events($request);
1432
-            } else {
1433
-                $related_listing = geodir_related_posts_display($request);
1434
-            }
1421
+		$related_listing = '';
1422
+		if (in_array($post->post_type, $related_listing_array) && isset($arr_detail_page_tabs['related_listing']['is_display']) && $arr_detail_page_tabs['related_listing']['is_display']) {
1423
+			$request = array('post_number' => get_option('geodir_related_post_count'),
1424
+				'relate_to' => get_option('geodir_related_post_relate_to'),
1425
+				'layout' => get_option('geodir_related_post_listing_view'),
1426
+				'add_location_filter' => get_option('geodir_related_post_location_filter'),
1427
+				'list_sort' => get_option('geodir_related_post_sortby'),
1428
+				'character_count' => get_option('geodir_related_post_excerpt'));
1429
+
1430
+			if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1431
+				$related_listing = geodir_get_detail_page_related_events($request);
1432
+			} else {
1433
+				$related_listing = geodir_related_posts_display($request);
1434
+			}
1435 1435
 
1436
-        }
1436
+		}
1437 1437
 
1438
-        $post_images = geodir_get_images($post->ID, 'thumbnail');
1439
-        $thumb_image = '';
1440
-        if (!empty($post_images)) {
1441
-            foreach ($post_images as $image) {
1442
-                $caption = (!empty($image->caption)) ? $image->caption : '';
1443
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1444
-                $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1445
-                $thumb_image .= '</a>';
1446
-            }
1447
-        }
1438
+		$post_images = geodir_get_images($post->ID, 'thumbnail');
1439
+		$thumb_image = '';
1440
+		if (!empty($post_images)) {
1441
+			foreach ($post_images as $image) {
1442
+				$caption = (!empty($image->caption)) ? $image->caption : '';
1443
+				$thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1444
+				$thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1445
+				$thumb_image .= '</a>';
1446
+			}
1447
+		}
1448 1448
 
1449
-        $map_args = array();
1450
-        $map_args['map_canvas_name'] = 'detail_page_map_canvas';
1451
-        $map_args['width'] = '600';
1452
-        $map_args['height'] = '300';
1453
-        if ($post->post_mapzoom) {
1454
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1455
-        }
1456
-        $map_args['autozoom'] = false;
1457
-        $map_args['child_collapse'] = '0';
1458
-        $map_args['enable_cat_filters'] = false;
1459
-        $map_args['enable_text_search'] = false;
1460
-        $map_args['enable_post_type_filters'] = false;
1461
-        $map_args['enable_location_filters'] = false;
1462
-        $map_args['enable_jason_on_load'] = true;
1463
-        $map_args['enable_map_direction'] = true;
1464
-        $map_args['map_class_name'] = 'geodir-map-detail-page';
1465
-        $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1466
-    } else if (geodir_is_page('preview')) {
1467
-        $video = isset($post->geodir_video) ? $post->geodir_video : '';
1468
-        $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1469
-
1470
-        if (isset($post->post_images))
1471
-            $post->post_images = trim($post->post_images, ",");
1472
-
1473
-        if (isset($post->post_images) && !empty($post->post_images))
1474
-            $post_images = explode(",", $post->post_images);
1475
-
1476
-        $thumb_image = '';
1477
-        if (!empty($post_images)) {
1478
-            foreach ($post_images as $image) {
1479
-                if ($image != '') {
1480
-                    $thumb_image .= '<a href="' . $image . '">';
1481
-                    $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1482
-                    $thumb_image .= '</a>';
1483
-                }
1484
-            }
1485
-        }
1449
+		$map_args = array();
1450
+		$map_args['map_canvas_name'] = 'detail_page_map_canvas';
1451
+		$map_args['width'] = '600';
1452
+		$map_args['height'] = '300';
1453
+		if ($post->post_mapzoom) {
1454
+			$map_args['zoom'] = '' . $post->post_mapzoom . '';
1455
+		}
1456
+		$map_args['autozoom'] = false;
1457
+		$map_args['child_collapse'] = '0';
1458
+		$map_args['enable_cat_filters'] = false;
1459
+		$map_args['enable_text_search'] = false;
1460
+		$map_args['enable_post_type_filters'] = false;
1461
+		$map_args['enable_location_filters'] = false;
1462
+		$map_args['enable_jason_on_load'] = true;
1463
+		$map_args['enable_map_direction'] = true;
1464
+		$map_args['map_class_name'] = 'geodir-map-detail-page';
1465
+		$map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1466
+	} else if (geodir_is_page('preview')) {
1467
+		$video = isset($post->geodir_video) ? $post->geodir_video : '';
1468
+		$special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1469
+
1470
+		if (isset($post->post_images))
1471
+			$post->post_images = trim($post->post_images, ",");
1472
+
1473
+		if (isset($post->post_images) && !empty($post->post_images))
1474
+			$post_images = explode(",", $post->post_images);
1475
+
1476
+		$thumb_image = '';
1477
+		if (!empty($post_images)) {
1478
+			foreach ($post_images as $image) {
1479
+				if ($image != '') {
1480
+					$thumb_image .= '<a href="' . $image . '">';
1481
+					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1482
+					$thumb_image .= '</a>';
1483
+				}
1484
+			}
1485
+		}
1486 1486
 
1487
-        global $map_jason;
1488
-        $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1489
-        $marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1490
-        $icon_size = geodir_get_marker_size($marker_icon);
1491
-        $marker_json['w'] = $icon_size['w'];
1492
-        $marker_json['h'] = $icon_size['h'];
1493
-        $map_jason[] = json_encode($marker_json);
1494
-
1495
-        $address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1496
-        $address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1497
-        $mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1498
-        $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1499
-        if (!$mapzoom) {
1500
-            $mapzoom = 12;
1501
-        }
1487
+		global $map_jason;
1488
+		$marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1489
+		$marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1490
+		$icon_size = geodir_get_marker_size($marker_icon);
1491
+		$marker_json['w'] = $icon_size['w'];
1492
+		$marker_json['h'] = $icon_size['h'];
1493
+		$map_jason[] = json_encode($marker_json);
1494
+
1495
+		$address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1496
+		$address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1497
+		$mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1498
+		$mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1499
+		if (!$mapzoom) {
1500
+			$mapzoom = 12;
1501
+		}
1502 1502
 
1503
-        $map_args = array();
1504
-        $map_args['map_canvas_name'] = 'preview_map_canvas';
1505
-        $map_args['width'] = '950';
1506
-        $map_args['height'] = '300';
1507
-        $map_args['child_collapse'] = '0';
1508
-        $map_args['maptype'] = $mapview;
1509
-        $map_args['autozoom'] = false;
1510
-        $map_args['zoom'] = "$mapzoom";
1511
-        $map_args['latitude'] = $address_latitude;
1512
-        $map_args['longitude'] = $address_longitude;
1513
-        $map_args['enable_cat_filters'] = false;
1514
-        $map_args['enable_text_search'] = false;
1515
-        $map_args['enable_post_type_filters'] = false;
1516
-        $map_args['enable_location_filters'] = false;
1517
-        $map_args['enable_jason_on_load'] = true;
1518
-        $map_args['enable_map_direction'] = true;
1519
-        $map_args['map_class_name'] = 'geodir-map-preview-page';
1520
-    }
1503
+		$map_args = array();
1504
+		$map_args['map_canvas_name'] = 'preview_map_canvas';
1505
+		$map_args['width'] = '950';
1506
+		$map_args['height'] = '300';
1507
+		$map_args['child_collapse'] = '0';
1508
+		$map_args['maptype'] = $mapview;
1509
+		$map_args['autozoom'] = false;
1510
+		$map_args['zoom'] = "$mapzoom";
1511
+		$map_args['latitude'] = $address_latitude;
1512
+		$map_args['longitude'] = $address_longitude;
1513
+		$map_args['enable_cat_filters'] = false;
1514
+		$map_args['enable_text_search'] = false;
1515
+		$map_args['enable_post_type_filters'] = false;
1516
+		$map_args['enable_location_filters'] = false;
1517
+		$map_args['enable_jason_on_load'] = true;
1518
+		$map_args['enable_map_direction'] = true;
1519
+		$map_args['map_class_name'] = 'geodir-map-preview-page';
1520
+	}
1521 1521
 
1522
-    $active_tab = '';
1523
-    $active_tab_name = '';
1524
-    $default_tab = '';
1525
-    $default_tab_name = '';
1526
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1527
-        if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1528
-            $active_tab = $tab_index;
1529
-            $active_tab_name = __($tabs['heading_text'], 'geodirectory');
1530
-        }
1522
+	$active_tab = '';
1523
+	$active_tab_name = '';
1524
+	$default_tab = '';
1525
+	$default_tab_name = '';
1526
+	foreach($arr_detail_page_tabs as $tab_index => $tabs){
1527
+		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1528
+			$active_tab = $tab_index;
1529
+			$active_tab_name = __($tabs['heading_text'], 'geodirectory');
1530
+		}
1531 1531
         
1532
-        if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1533
-            $default_tab = $tab_index;
1534
-            $default_tab_name = __($tabs['heading_text'], 'geodirectory');
1535
-        }
1536
-    }
1532
+		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1533
+			$default_tab = $tab_index;
1534
+			$default_tab_name = __($tabs['heading_text'], 'geodirectory');
1535
+		}
1536
+	}
1537 1537
     
1538
-    if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1539
-        if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1540
-            $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1541
-        }
1538
+	if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1539
+		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1540
+			$arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1541
+		}
1542 1542
         
1543
-        $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1544
-        $active_tab = $default_tab;
1545
-        $active_tab_name = $default_tab_name;
1546
-    }
1547
-    $tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1548
-    ?>
1543
+		$arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1544
+		$active_tab = $default_tab;
1545
+		$active_tab_name = $default_tab_name;
1546
+	}
1547
+	$tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1548
+	?>
1549 1549
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1550 1550
         <?php if(!$tab_list){ ?>
1551 1551
         <div id="geodir-tab-mobile-menu">
@@ -1555,166 +1555,166 @@  discard block
 block discarded – undo
1555 1555
         </div>
1556 1556
         <dl class="geodir-tab-head">
1557 1557
             <?php
1558
-            }
1559
-            /**
1560
-             * Called before the details page tab list headings, inside the `dl` tag.
1561
-             *
1562
-             * @since 1.0.0
1563
-             * @see 'geodir_after_tab_list'
1564
-             */
1565
-            do_action('geodir_before_tab_list'); ?>
1558
+			}
1559
+			/**
1560
+			 * Called before the details page tab list headings, inside the `dl` tag.
1561
+			 *
1562
+			 * @since 1.0.0
1563
+			 * @see 'geodir_after_tab_list'
1564
+			 */
1565
+			do_action('geodir_before_tab_list'); ?>
1566 1566
             <?php
1567 1567
 
1568
-            foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1569
-                if ($detail_page_tab['is_display']) {
1568
+			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1569
+				if ($detail_page_tab['is_display']) {
1570 1570
 
1571
-                    if(!$tab_list) {
1572
-                        ?>
1571
+					if(!$tab_list) {
1572
+						?>
1573 1573
                         <dt></dt> <!-- added to comply with validation -->
1574 1574
                         <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php } ?> ><a
1575 1575
                                 data-tab="#<?php echo $tab_index; ?>"
1576 1576
                                 data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1577 1577
                         </dd>
1578 1578
                         <?php
1579
-                    }
1580
-                    ob_start() // start tab content buffering
1581
-                    ?>
1579
+					}
1580
+					ob_start() // start tab content buffering
1581
+					?>
1582 1582
                     <li id="<?php echo $tab_index;?>Tab">
1583 1583
                         <?php if($tab_list){
1584
-                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1585
-                            /**
1586
-                             * Filter the tab list title html.
1587
-                             *
1588
-                             * @since 1.6.1
1589
-                             * @param string $tab_title The html for the tab title.
1590
-                             * @param string $tab_index The tab index type.
1591
-                             * @param array $detail_page_tab The array of values including title text.
1592
-                             */
1593
-                            echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1594
-                        }?>
1584
+							$tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1585
+							/**
1586
+							 * Filter the tab list title html.
1587
+							 *
1588
+							 * @since 1.6.1
1589
+							 * @param string $tab_title The html for the tab title.
1590
+							 * @param string $tab_index The tab index type.
1591
+							 * @param array $detail_page_tab The array of values including title text.
1592
+							 */
1593
+							echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1594
+						}?>
1595 1595
                         <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1596 1596
                         <?php
1597
-                        /**
1598
-                         * Called before the details tab content is output per tab.
1599
-                         *
1600
-                         * @since 1.0.0
1601
-                         * @param string $tab_index The tab name ID.
1602
-                         */
1603
-                        do_action('geodir_before_tab_content', $tab_index);
1604
-
1605
-                        /**
1606
-                         * Called before the details tab content is output per tab.
1607
-                         *
1608
-                         * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1609
-                         *
1610
-                         * @since 1.0.0
1611
-                         * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1612
-                         */
1613
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1614
-                        /// write a code to generate content of each tab
1615
-                        switch ($tab_index) {
1616
-                            case 'post_profile':
1617
-                                /**
1618
-                                 * Called before the listing description content on the details page tab.
1619
-                                 *
1620
-                                 * @since 1.0.0
1621
-                                 */
1622
-                                do_action('geodir_before_description_on_listing_detail');
1623
-                                if (geodir_is_page('detail')) {
1624
-                                    the_content();
1625
-                                } else {
1626
-                                    /** This action is documented in geodirectory_template_actions.php */
1627
-                                    echo apply_filters('the_content', stripslashes($post->post_desc));
1628
-                                }
1629
-
1630
-                                /**
1631
-                                 * Called after the listing description content on the details page tab.
1632
-                                 *
1633
-                                 * @since 1.0.0
1634
-                                 */
1635
-                                do_action('geodir_after_description_on_listing_detail');
1636
-                                break;
1637
-                            case 'post_info':
1638
-                                echo $geodir_post_detail_fields;
1639
-                                break;
1640
-                            case 'post_images':
1641
-                                echo $thumb_image;
1642
-                                break;
1643
-                            case 'post_video':
1644
-                                /** This action is documented in geodirectory_template_actions.php */
1645
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1646
-                                break;
1647
-                            case 'special_offers':
1648
-                                echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1649
-
1650
-                                break;
1651
-                            case 'post_map':
1652
-                                geodir_draw_map($map_args);
1653
-                                break;
1654
-                            case 'reviews':
1655
-                                comments_template();
1656
-                                break;
1657
-                            case 'related_listing':
1658
-                                echo $related_listing;
1659
-                                break;
1660
-                            default: {
1661
-                                if ((isset($post->{$tab_index}) || (!isset($post->{$tab_index}) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
1662
-                                    echo $detail_page_tab['tab_content'];
1663
-                                }
1664
-                            }
1665
-                                break;
1666
-                        }
1667
-
1668
-                        /**
1669
-                         * Called after the details tab content is output per tab.
1670
-                         *
1671
-                         * @since 1.0.0
1672
-                         */
1673
-                        do_action('geodir_after_tab_content', $tab_index);
1674
-
1675
-                        /**
1676
-                         * Called after the details tab content is output per tab.
1677
-                         *
1678
-                         * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1679
-                         *
1680
-                         * @since 1.0.0
1681
-                         * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1682
-                         */
1683
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1684
-                        ?> </li>
1597
+						/**
1598
+						 * Called before the details tab content is output per tab.
1599
+						 *
1600
+						 * @since 1.0.0
1601
+						 * @param string $tab_index The tab name ID.
1602
+						 */
1603
+						do_action('geodir_before_tab_content', $tab_index);
1604
+
1605
+						/**
1606
+						 * Called before the details tab content is output per tab.
1607
+						 *
1608
+						 * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1609
+						 *
1610
+						 * @since 1.0.0
1611
+						 * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1612
+						 */
1613
+						do_action('geodir_before_' . $tab_index . '_tab_content');
1614
+						/// write a code to generate content of each tab
1615
+						switch ($tab_index) {
1616
+							case 'post_profile':
1617
+								/**
1618
+								 * Called before the listing description content on the details page tab.
1619
+								 *
1620
+								 * @since 1.0.0
1621
+								 */
1622
+								do_action('geodir_before_description_on_listing_detail');
1623
+								if (geodir_is_page('detail')) {
1624
+									the_content();
1625
+								} else {
1626
+									/** This action is documented in geodirectory_template_actions.php */
1627
+									echo apply_filters('the_content', stripslashes($post->post_desc));
1628
+								}
1629
+
1630
+								/**
1631
+								 * Called after the listing description content on the details page tab.
1632
+								 *
1633
+								 * @since 1.0.0
1634
+								 */
1635
+								do_action('geodir_after_description_on_listing_detail');
1636
+								break;
1637
+							case 'post_info':
1638
+								echo $geodir_post_detail_fields;
1639
+								break;
1640
+							case 'post_images':
1641
+								echo $thumb_image;
1642
+								break;
1643
+							case 'post_video':
1644
+								/** This action is documented in geodirectory_template_actions.php */
1645
+								echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1646
+								break;
1647
+							case 'special_offers':
1648
+								echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1649
+
1650
+								break;
1651
+							case 'post_map':
1652
+								geodir_draw_map($map_args);
1653
+								break;
1654
+							case 'reviews':
1655
+								comments_template();
1656
+								break;
1657
+							case 'related_listing':
1658
+								echo $related_listing;
1659
+								break;
1660
+							default: {
1661
+								if ((isset($post->{$tab_index}) || (!isset($post->{$tab_index}) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
1662
+									echo $detail_page_tab['tab_content'];
1663
+								}
1664
+							}
1665
+								break;
1666
+						}
1667
+
1668
+						/**
1669
+						 * Called after the details tab content is output per tab.
1670
+						 *
1671
+						 * @since 1.0.0
1672
+						 */
1673
+						do_action('geodir_after_tab_content', $tab_index);
1674
+
1675
+						/**
1676
+						 * Called after the details tab content is output per tab.
1677
+						 *
1678
+						 * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1679
+						 *
1680
+						 * @since 1.0.0
1681
+						 * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1682
+						 */
1683
+						do_action('geodir_after_' . $tab_index . '_tab_content');
1684
+						?> </li>
1685 1685
                     <?php
1686
-                    /**
1687
-                     * Filter the current tab content.
1688
-                     *
1689
-                     * @since 1.0.0
1690
-                     */
1691
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1692
-                } // end of if for is_display
1693
-            }// end of foreach
1694
-
1695
-            /**
1696
-             * Called after the details page tab list headings, inside the `dl` tag.
1697
-             *
1698
-             * @since 1.0.0
1699
-             * @see 'geodir_before_tab_list'
1700
-             */
1701
-            do_action('geodir_after_tab_list');
1702
-            ?>
1686
+					/**
1687
+					 * Filter the current tab content.
1688
+					 *
1689
+					 * @since 1.0.0
1690
+					 */
1691
+					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1692
+				} // end of if for is_display
1693
+			}// end of foreach
1694
+
1695
+			/**
1696
+			 * Called after the details page tab list headings, inside the `dl` tag.
1697
+			 *
1698
+			 * @since 1.0.0
1699
+			 * @see 'geodir_before_tab_list'
1700
+			 */
1701
+			do_action('geodir_after_tab_list');
1702
+			?>
1703 1703
             <?php if(!$tab_list){?></dl><?php }?>
1704 1704
         <ul class="geodir-tabs-content entry-content <?php if($tab_list){?>geodir-tabs-list<?php }?>" style="position:relative;">
1705 1705
             <?php
1706
-            foreach ($arr_detail_page_tabs as $detail_page_tab) {
1707
-                if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1708
-                    echo $detail_page_tab['tab_content'];
1709
-                }// end of if
1710
-            }// end of foreach
1711
-
1712
-            /**
1713
-             * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1714
-             *
1715
-             * @since 1.0.0
1716
-             */
1717
-            do_action('geodir_add_tab_content'); ?>
1706
+			foreach ($arr_detail_page_tabs as $detail_page_tab) {
1707
+				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1708
+					echo $detail_page_tab['tab_content'];
1709
+				}// end of if
1710
+			}// end of foreach
1711
+
1712
+			/**
1713
+			 * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1714
+			 *
1715
+			 * @since 1.0.0
1716
+			 */
1717
+			do_action('geodir_add_tab_content'); ?>
1718 1718
         </ul>
1719 1719
         <!--gd-tabs-content ul end-->
1720 1720
     </div>
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
         });
1738 1738
     </script>
1739 1739
     <?php
1740
-    }
1740
+	}
1741 1741
 }
1742 1742
 
1743 1743
 /**
@@ -1750,127 +1750,127 @@  discard block
 block discarded – undo
1750 1750
  */
1751 1751
 function geodir_exif($file)
1752 1752
 {
1753
-    if (empty($file) || !is_array($file)) {
1754
-        return $file;
1755
-    }
1753
+	if (empty($file) || !is_array($file)) {
1754
+		return $file;
1755
+	}
1756 1756
     
1757
-    $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1758
-    if (!($file_path && file_exists($file_path))) {
1759
-        return $file;
1760
-    }
1761
-    $file['file'] = $file_path;
1757
+	$file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1758
+	if (!($file_path && file_exists($file_path))) {
1759
+		return $file;
1760
+	}
1761
+	$file['file'] = $file_path;
1762 1762
     
1763
-    if (!file_is_valid_image($file_path)) {
1764
-        return $file; // Bail if file is not an image.
1765
-    }
1763
+	if (!file_is_valid_image($file_path)) {
1764
+		return $file; // Bail if file is not an image.
1765
+	}
1766 1766
     
1767
-    if (!function_exists('wp_get_image_editor')) {
1768
-        return $file;
1769
-    }
1767
+	if (!function_exists('wp_get_image_editor')) {
1768
+		return $file;
1769
+	}
1770 1770
    
1771
-    $mime_type = $file['type'];
1772
-    $exif = array();
1773
-    if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1774
-        try {
1775
-            $exif = exif_read_data($file_path);
1776
-        } catch(Exception $e) {
1777
-            $exif = array();
1778
-        }
1779
-    }
1771
+	$mime_type = $file['type'];
1772
+	$exif = array();
1773
+	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1774
+		try {
1775
+			$exif = exif_read_data($file_path);
1776
+		} catch(Exception $e) {
1777
+			$exif = array();
1778
+		}
1779
+	}
1780 1780
     
1781
-    $rotate = false;
1782
-    $flip = false;
1783
-    $modify = false;
1784
-    $orientation = 0;
1785
-    if (!empty($exif) && isset($exif['Orientation'])) {
1786
-        switch ((int)$exif['Orientation']) {
1787
-            case 1:
1788
-                // do nothing
1789
-                break;
1790
-            case 2:
1791
-                $flip = array(false, true);
1792
-                $modify = true;
1793
-                break;
1794
-            case 3:
1795
-                $orientation = -180;
1796
-                $rotate = true;
1797
-                $modify = true;
1798
-                break;
1799
-            case 4:
1800
-                $flip = array(true, false);
1801
-                $modify = true;
1802
-                break;
1803
-            case 5:
1804
-                $orientation = -90;
1805
-                $rotate = true;
1806
-                $flip = array(false, true);
1807
-                $modify = true;
1808
-                break;
1809
-            case 6:
1810
-                $orientation = -90;
1811
-                $rotate = true;
1812
-                $modify = true;
1813
-                break;
1814
-            case 7:
1815
-                $orientation = -270;
1816
-                $rotate = true;
1817
-                $flip = array(false, true);
1818
-                $modify = true;
1819
-                break;
1820
-            case 8:
1821
-            case 9:
1822
-                $orientation = -270;
1823
-                $rotate = true;
1824
-                $modify = true;
1825
-                break;
1826
-            default:
1827
-                $orientation = 0;
1828
-                $rotate = true;
1829
-                $modify = true;
1830
-                break;
1831
-        }
1832
-    }
1781
+	$rotate = false;
1782
+	$flip = false;
1783
+	$modify = false;
1784
+	$orientation = 0;
1785
+	if (!empty($exif) && isset($exif['Orientation'])) {
1786
+		switch ((int)$exif['Orientation']) {
1787
+			case 1:
1788
+				// do nothing
1789
+				break;
1790
+			case 2:
1791
+				$flip = array(false, true);
1792
+				$modify = true;
1793
+				break;
1794
+			case 3:
1795
+				$orientation = -180;
1796
+				$rotate = true;
1797
+				$modify = true;
1798
+				break;
1799
+			case 4:
1800
+				$flip = array(true, false);
1801
+				$modify = true;
1802
+				break;
1803
+			case 5:
1804
+				$orientation = -90;
1805
+				$rotate = true;
1806
+				$flip = array(false, true);
1807
+				$modify = true;
1808
+				break;
1809
+			case 6:
1810
+				$orientation = -90;
1811
+				$rotate = true;
1812
+				$modify = true;
1813
+				break;
1814
+			case 7:
1815
+				$orientation = -270;
1816
+				$rotate = true;
1817
+				$flip = array(false, true);
1818
+				$modify = true;
1819
+				break;
1820
+			case 8:
1821
+			case 9:
1822
+				$orientation = -270;
1823
+				$rotate = true;
1824
+				$modify = true;
1825
+				break;
1826
+			default:
1827
+				$orientation = 0;
1828
+				$rotate = true;
1829
+				$modify = true;
1830
+				break;
1831
+		}
1832
+	}
1833 1833
     
1834
-    $quality = null;
1835
-    /**
1836
-     * Filter the image quality.
1837
-     *
1838
-     * @since 1.5.7
1839
-     * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1840
-     * @param string $quality Image mime type.
1841
-     */
1842
-    $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1843
-    if ($quality !== null) {
1844
-        $modify = true;
1845
-    }
1834
+	$quality = null;
1835
+	/**
1836
+	 * Filter the image quality.
1837
+	 *
1838
+	 * @since 1.5.7
1839
+	 * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1840
+	 * @param string $quality Image mime type.
1841
+	 */
1842
+	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1843
+	if ($quality !== null) {
1844
+		$modify = true;
1845
+	}
1846 1846
 
1847
-    if (!$modify) {
1848
-        return $file; // no change
1849
-    }
1847
+	if (!$modify) {
1848
+		return $file; // no change
1849
+	}
1850 1850
 
1851
-    $image = wp_get_image_editor($file_path);
1852
-    if (!is_wp_error($image)) {
1853
-        if ($rotate) {
1854
-            $image->rotate($orientation);
1855
-        }
1851
+	$image = wp_get_image_editor($file_path);
1852
+	if (!is_wp_error($image)) {
1853
+		if ($rotate) {
1854
+			$image->rotate($orientation);
1855
+		}
1856 1856
         
1857
-        if (!empty($flip)) {
1858
-            $image->flip($flip[0], $flip[1]);
1859
-        }
1857
+		if (!empty($flip)) {
1858
+			$image->flip($flip[0], $flip[1]);
1859
+		}
1860 1860
         
1861
-        if ($quality !== null) {
1862
-            $image->set_quality((int)$quality);
1863
-        }
1861
+		if ($quality !== null) {
1862
+			$image->set_quality((int)$quality);
1863
+		}
1864 1864
         
1865
-       $result = $image->save($file_path);
1866
-       if (!is_wp_error($result)) {
1867
-           $file['file'] = $result['path'];
1868
-           $file['tmp_name'] = $result['path'];
1869
-       }
1870
-    }
1865
+	   $result = $image->save($file_path);
1866
+	   if (!is_wp_error($result)) {
1867
+		   $file['file'] = $result['path'];
1868
+		   $file['tmp_name'] = $result['path'];
1869
+	   }
1870
+	}
1871 1871
     
1872
-    // The image orientation is fixed, pass it back for further processing
1873
-    return $file;
1872
+	// The image orientation is fixed, pass it back for further processing
1873
+	return $file;
1874 1874
 }
1875 1875
 
1876 1876
 /**
@@ -1889,138 +1889,138 @@  discard block
 block discarded – undo
1889 1889
  * @return string Returns the recent reviews html.
1890 1890
  */
1891 1891
 function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
1892
-    global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1893
-    $tablecomments = $wpdb->comments;
1894
-    $tableposts = $wpdb->posts;
1895
-
1896
-    $comments_echo = '';
1897
-    $city_filter = '';
1898
-    $region_filter = '';
1899
-    $country_filter = '';
1900
-
1901
-    if ($gd_session->get('gd_multi_location')) {
1902
-        if ($gd_ses_country = $gd_session->get('gd_country')) {
1903
-            $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1904
-        }
1892
+	global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1893
+	$tablecomments = $wpdb->comments;
1894
+	$tableposts = $wpdb->posts;
1895
+
1896
+	$comments_echo = '';
1897
+	$city_filter = '';
1898
+	$region_filter = '';
1899
+	$country_filter = '';
1900
+
1901
+	if ($gd_session->get('gd_multi_location')) {
1902
+		if ($gd_ses_country = $gd_session->get('gd_country')) {
1903
+			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1904
+		}
1905 1905
 
1906
-        if ($gd_ses_region = $gd_session->get('gd_region')) {
1907
-            $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1908
-        }
1906
+		if ($gd_ses_region = $gd_session->get('gd_region')) {
1907
+			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1908
+		}
1909 1909
 
1910
-        if ($gd_ses_city = $gd_session->get('gd_city')) {
1911
-            $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1912
-        }
1913
-    }
1910
+		if ($gd_ses_city = $gd_session->get('gd_city')) {
1911
+			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1912
+		}
1913
+	}
1914 1914
 	
1915
-    $review_table = GEODIR_REVIEW_TABLE;
1916
-    $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments";
1917
-
1918
-    $comments = $wpdb->get_results($request);
1919
-
1920
-    foreach ($comments as $comment) {
1921
-        // Set the extra comment info needed.
1922
-        $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1923
-        //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1924
-        $comment->comment_content = $comment_extra->comment_content;
1925
-        $comment->comment_author = $comment_extra->comment_author;
1926
-        $comment->comment_author_email = $comment_extra->comment_author_email;
1927
-
1928
-        $comment_id = '';
1929
-        $comment_id = $comment->comment_ID;
1930
-        $comment_content = strip_tags($comment->comment_content);
1931
-
1932
-        $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1933
-
1934
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1935
-        $comment_author_email = $comment->comment_author_email;
1936
-        $comment_post_ID = $comment->post_id;
1937
-
1938
-        $na = true;
1939
-        if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1940
-            $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1941
-            if ($comment_post_ID == $comment_post_ID2) {
1942
-            } else {
1943
-                $na = false;
1944
-            }
1945
-        }
1915
+	$review_table = GEODIR_REVIEW_TABLE;
1916
+	$request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments";
1917
+
1918
+	$comments = $wpdb->get_results($request);
1919
+
1920
+	foreach ($comments as $comment) {
1921
+		// Set the extra comment info needed.
1922
+		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1923
+		//echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1924
+		$comment->comment_content = $comment_extra->comment_content;
1925
+		$comment->comment_author = $comment_extra->comment_author;
1926
+		$comment->comment_author_email = $comment_extra->comment_author_email;
1927
+
1928
+		$comment_id = '';
1929
+		$comment_id = $comment->comment_ID;
1930
+		$comment_content = strip_tags($comment->comment_content);
1931
+
1932
+		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1933
+
1934
+		$permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1935
+		$comment_author_email = $comment->comment_author_email;
1936
+		$comment_post_ID = $comment->post_id;
1937
+
1938
+		$na = true;
1939
+		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1940
+			$comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1941
+			if ($comment_post_ID == $comment_post_ID2) {
1942
+			} else {
1943
+				$na = false;
1944
+			}
1945
+		}
1946 1946
 
1947
-        $post_title = get_the_title($comment_post_ID);
1948
-        $permalink = get_permalink($comment_post_ID);
1949
-        $comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1950
-        $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1947
+		$post_title = get_the_title($comment_post_ID);
1948
+		$permalink = get_permalink($comment_post_ID);
1949
+		$comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1950
+		$read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1951 1951
 
1952
-        $comment_content_length = strlen($comment_content);
1953
-        if ($comment_content_length > $comment_lenth) {
1954
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1955
-        } else {
1956
-            $comment_excerpt = $comment_content;
1957
-        }
1952
+		$comment_content_length = strlen($comment_content);
1953
+		if ($comment_content_length > $comment_lenth) {
1954
+			$comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1955
+		} else {
1956
+			$comment_excerpt = $comment_content;
1957
+		}
1958 1958
 
1959
-        if ($comment->user_id) {
1960
-            $user_profile_url = get_author_posts_url($comment->user_id);
1961
-        } else {
1962
-            $user_profile_url = '';
1963
-        }
1959
+		if ($comment->user_id) {
1960
+			$user_profile_url = get_author_posts_url($comment->user_id);
1961
+		} else {
1962
+			$user_profile_url = '';
1963
+		}
1964 1964
 
1965
-        if ($comment_id && $na) {
1966
-            $comments_echo .= '<li class="clearfix">';
1967
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1968
-            if (function_exists('get_avatar')) {
1969
-                if (!isset($comment->comment_type)) {
1970
-                    if ($user_profile_url) {
1971
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1972
-                    }
1973
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1974
-                    if ($user_profile_url) {
1975
-                        $comments_echo .= '</a>';
1976
-                    }
1977
-                } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1978
-                    if ($user_profile_url) {
1979
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1980
-                    }
1981
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1982
-                }
1983
-            } elseif (function_exists('gravatar')) {
1984
-                if ($user_profile_url) {
1985
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1986
-                }
1987
-                $comments_echo .= "<img src=\"";
1988
-                if ('' == $comment->comment_type) {
1989
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1990
-                    if ($user_profile_url) {
1991
-                        $comments_echo .= '</a>';
1992
-                    }
1993
-                } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1994
-                    if ($user_profile_url) {
1995
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1996
-                    }
1997
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1998
-                    if ($user_profile_url) {
1999
-                        $comments_echo .= '</a>';
2000
-                    }
2001
-                }
2002
-                $comments_echo .= "\" alt=\"\" class=\"avatar\" />";
2003
-            }
1965
+		if ($comment_id && $na) {
1966
+			$comments_echo .= '<li class="clearfix">';
1967
+			$comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1968
+			if (function_exists('get_avatar')) {
1969
+				if (!isset($comment->comment_type)) {
1970
+					if ($user_profile_url) {
1971
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1972
+					}
1973
+					$comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1974
+					if ($user_profile_url) {
1975
+						$comments_echo .= '</a>';
1976
+					}
1977
+				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1978
+					if ($user_profile_url) {
1979
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1980
+					}
1981
+					$comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1982
+				}
1983
+			} elseif (function_exists('gravatar')) {
1984
+				if ($user_profile_url) {
1985
+					$comments_echo .= '<a href="' . $user_profile_url . '">';
1986
+				}
1987
+				$comments_echo .= "<img src=\"";
1988
+				if ('' == $comment->comment_type) {
1989
+					$comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1990
+					if ($user_profile_url) {
1991
+						$comments_echo .= '</a>';
1992
+					}
1993
+				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1994
+					if ($user_profile_url) {
1995
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1996
+					}
1997
+					$comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1998
+					if ($user_profile_url) {
1999
+						$comments_echo .= '</a>';
2000
+					}
2001
+				}
2002
+				$comments_echo .= "\" alt=\"\" class=\"avatar\" />";
2003
+			}
2004 2004
 
2005
-            $comments_echo .= "</span>\n";
2006
-
2007
-            $comments_echo .= '<span class="geodir_reviewer_content">';
2008
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
2009
-            $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
2010
-            if($comment->user_id){$comments_echo .= '</a>';}
2011
-            $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
2012
-            $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
2013
-            $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
2014
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
2015
-            //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
2016
-            $comments_echo .= '</p>';
2017
-
2018
-            $comments_echo .= "</span>\n";
2019
-            $comments_echo .= '</li>';
2020
-        }
2021
-    }
2005
+			$comments_echo .= "</span>\n";
2006
+
2007
+			$comments_echo .= '<span class="geodir_reviewer_content">';
2008
+			if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
2009
+			$comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
2010
+			if($comment->user_id){$comments_echo .= '</a>';}
2011
+			$comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
2012
+			$comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
2013
+			$comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
2014
+			$comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
2015
+			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
2016
+			$comments_echo .= '</p>';
2017
+
2018
+			$comments_echo .= "</span>\n";
2019
+			$comments_echo .= '</li>';
2020
+		}
2021
+	}
2022 2022
 
2023
-    return $comments_echo;
2023
+	return $comments_echo;
2024 2024
 }
2025 2025
 
2026 2026
 /**
@@ -2032,29 +2032,29 @@  discard block
 block discarded – undo
2032 2032
  */
2033 2033
 function geodir_home_map_cats_key_value_array()
2034 2034
 {
2035
-    $post_types = geodir_get_posttypes('object');
2036
-
2037
-    $return = array();
2038
-    if (!empty($post_types)) {
2039
-        foreach ($post_types as $key => $post_type) {
2040
-            $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
2041
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
2042
-            $taxonomies = geodir_get_taxonomies($key);
2043
-            $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2044
-            $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2045
-
2046
-            if (!empty($cat_terms)) {
2047
-                $return['optgroup_start-' . $key] = $post_type_name;
2048
-
2049
-                foreach ($cat_terms as $cat_term) {
2050
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2051
-                }
2035
+	$post_types = geodir_get_posttypes('object');
2052 2036
 
2053
-                $return['optgroup_end-' . $key] = $post_type_name;
2054
-            }
2055
-        }
2056
-    }
2057
-    return $return;
2037
+	$return = array();
2038
+	if (!empty($post_types)) {
2039
+		foreach ($post_types as $key => $post_type) {
2040
+			$cpt_name = __($post_type->labels->singular_name, 'geodirectory');
2041
+			$post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
2042
+			$taxonomies = geodir_get_taxonomies($key);
2043
+			$cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2044
+			$cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2045
+
2046
+			if (!empty($cat_terms)) {
2047
+				$return['optgroup_start-' . $key] = $post_type_name;
2048
+
2049
+				foreach ($cat_terms as $cat_term) {
2050
+					$return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2051
+				}
2052
+
2053
+				$return['optgroup_end-' . $key] = $post_type_name;
2054
+			}
2055
+		}
2056
+	}
2057
+	return $return;
2058 2058
 }
2059 2059
 
2060 2060
 /**
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
  */
2067 2067
 function geodir_twitter_tweet_button()
2068 2068
 {
2069
-    ?>
2069
+	?>
2070 2070
     <a href="http://twitter.com/share"
2071 2071
        class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
2072 2072
     <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
@@ -2083,11 +2083,11 @@  discard block
 block discarded – undo
2083 2083
  * @global object $post The current post object.
2084 2084
  */
2085 2085
 function geodir_fb_like_button() {
2086
-    global $post;
2087
-    ?>
2086
+	global $post;
2087
+	?>
2088 2088
     <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
2089
-        echo 'allowtransparency="true"';
2090
-    } ?> class="facebook"
2089
+		echo 'allowtransparency="true"';
2090
+	} ?> class="facebook"
2091 2091
          src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light"
2092 2092
          style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
2093 2093
     <?php
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
  * @package GeoDirectory
2103 2103
  */
2104 2104
 function geodir_google_plus_button() {
2105
-    ?>
2105
+	?>
2106 2106
     <div id="plusone-div" class="g-plusone" data-size="medium"></div>
2107 2107
     <script type="text/javascript">
2108 2108
         (function () {
@@ -2127,8 +2127,8 @@  discard block
 block discarded – undo
2127 2127
  * @global object $post The current post object.
2128 2128
  */
2129 2129
 function geodir_share_this_button_code() {
2130
-    global $post;
2131
-    ?>
2130
+	global $post;
2131
+	?>
2132 2132
     <div class="addthis_toolbox addthis_default_style">
2133 2133
         <span id='st_sharethis'></span>
2134 2134
         <script type="text/javascript">var switchTo5x = false;</script>
@@ -2153,8 +2153,8 @@  discard block
 block discarded – undo
2153 2153
 }
2154 2154
 
2155 2155
 function geodir_listing_bounce_map_pin_on_hover() {
2156
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2157
-        ?>
2156
+	if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2157
+		?>
2158 2158
         <script>
2159 2159
             jQuery(function ($) {
2160 2160
                 if (typeof(animate_marker) == 'function') {
@@ -2171,27 +2171,27 @@  discard block
 block discarded – undo
2171 2171
             });
2172 2172
         </script>
2173 2173
         <?php
2174
-    }
2174
+	}
2175 2175
 }
2176 2176
 add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2177 2177
 
2178 2178
 add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2179 2179
 function geodir_output_favourite_html_listings( $post_id){
2180
-    geodir_favourite_html('', $post_id);
2180
+	geodir_favourite_html('', $post_id);
2181 2181
 }
2182 2182
 
2183 2183
 add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2184 2184
 function geodir_output_pinpoint_html_listings( $post_id, $post){
2185
-    global $wp_query;
2185
+	global $wp_query;
2186 2186
 
2187
-    $show_pin_point = $wp_query->is_main_query();
2187
+	$show_pin_point = $wp_query->is_main_query();
2188 2188
     
2189
-    if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2190
-        $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2191
-        $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2192
-        ?>
2189
+	if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2190
+		$term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2191
+		$marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2192
+		?>
2193 2193
         <span class="geodir-pinpoint" style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?></span>
2194 2194
         <a class="geodir-pinpoint-link" href="javascript:void(0)" onclick="openMarker('listing_map_canvas' ,'<?php echo $post->ID; ?>')" onmouseover="animate_marker('listing_map_canvas' ,'<?php echo $post->ID; ?>')" onmouseout="stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')"><?php _e('Pinpoint', 'geodirectory'); ?></a>
2195 2195
         <?php
2196
-    }
2196
+	}
2197 2197
 }
2198 2198
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 1 patch
Indentation   +3377 added lines, -3377 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,369 +933,369 @@  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
-                $location_page_id = geodir_location_page_id();
1227
-                $loc_post = get_post( $location_page_id );
1228
-                $post_name = $loc_post->post_name;
1229
-                $slug= ucwords(str_replace('-',' ',$post_name));
1230
-                $page_title = !empty($slug )? $slug : __('Location', 'geodirectory');
1231
-            }
1232
-
1233
-            $breadcrumb .= '<li>' . $separator;
1234
-            $breadcrumb .= stripslashes_deep($page_title);
1235
-            $breadcrumb .= '</li>';
1236
-        } else if (is_tag()) {
1237
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1238
-        } else if (is_day()) {
1239
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
-            the_time('F jS, Y');
1241
-            $breadcrumb .= '</li>';
1242
-        } else if (is_month()) {
1243
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
-            the_time('F, Y');
1245
-            $breadcrumb .= '</li>';
1246
-        } else if (is_year()) {
1247
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1248
-            the_time('Y');
1249
-            $breadcrumb .= '</li>';
1250
-        } else if (is_author()) {
1251
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1252
-            $breadcrumb .= '</li>';
1253
-        } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1254
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1255
-            $breadcrumb .= '</li>';
1256
-        } else if (is_search()) {
1257
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1258
-            $breadcrumb .= '</li>';
1259
-        }
1260
-        $breadcrumb .= '</ul></div>';
1261
-
1262
-        /**
1263
-         * Filter breadcrumb html output.
1264
-         *
1265
-         * @since 1.0.0
1266
-         * @param string $breadcrumb Breadcrumb HTML.
1267
-         * @param string $separator Breadcrumb separator.
1268
-         */
1269
-        echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1270
-    }
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
+				$location_page_id = geodir_location_page_id();
1227
+				$loc_post = get_post( $location_page_id );
1228
+				$post_name = $loc_post->post_name;
1229
+				$slug= ucwords(str_replace('-',' ',$post_name));
1230
+				$page_title = !empty($slug )? $slug : __('Location', 'geodirectory');
1231
+			}
1232
+
1233
+			$breadcrumb .= '<li>' . $separator;
1234
+			$breadcrumb .= stripslashes_deep($page_title);
1235
+			$breadcrumb .= '</li>';
1236
+		} else if (is_tag()) {
1237
+			$breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1238
+		} else if (is_day()) {
1239
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
+			the_time('F jS, Y');
1241
+			$breadcrumb .= '</li>';
1242
+		} else if (is_month()) {
1243
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
+			the_time('F, Y');
1245
+			$breadcrumb .= '</li>';
1246
+		} else if (is_year()) {
1247
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1248
+			the_time('Y');
1249
+			$breadcrumb .= '</li>';
1250
+		} else if (is_author()) {
1251
+			$breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1252
+			$breadcrumb .= '</li>';
1253
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1254
+			$breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1255
+			$breadcrumb .= '</li>';
1256
+		} else if (is_search()) {
1257
+			$breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1258
+			$breadcrumb .= '</li>';
1259
+		}
1260
+		$breadcrumb .= '</ul></div>';
1261
+
1262
+		/**
1263
+		 * Filter breadcrumb html output.
1264
+		 *
1265
+		 * @since 1.0.0
1266
+		 * @param string $breadcrumb Breadcrumb HTML.
1267
+		 * @param string $separator Breadcrumb separator.
1268
+		 */
1269
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1270
+	}
1271 1271
 }
1272 1272
 
1273 1273
 
1274 1274
 add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1275 1275
 if (!function_exists('geodir_allow_wpadmin')) {
1276
-    /**
1277
-     * Allow only admins to access wp-admin.
1278
-     *
1279
-     * Normal users will be redirected to home page.
1280
-     *
1281
-     * @since 1.0.0
1282
-     * @package GeoDirectory
1283
-     * @global object $wpdb WordPress Database object.
1284
-     */
1285
-    function geodir_allow_wpadmin()
1286
-    {
1287
-        global $wpdb;
1288
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1289
-        {
1290
-            if (current_user_can('manage_options')) {
1291
-            } else {
1292
-
1293
-                wp_redirect(home_url());
1294
-                exit;
1295
-            }
1296
-
1297
-        }
1298
-    }
1276
+	/**
1277
+	 * Allow only admins to access wp-admin.
1278
+	 *
1279
+	 * Normal users will be redirected to home page.
1280
+	 *
1281
+	 * @since 1.0.0
1282
+	 * @package GeoDirectory
1283
+	 * @global object $wpdb WordPress Database object.
1284
+	 */
1285
+	function geodir_allow_wpadmin()
1286
+	{
1287
+		global $wpdb;
1288
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1289
+		{
1290
+			if (current_user_can('manage_options')) {
1291
+			} else {
1292
+
1293
+				wp_redirect(home_url());
1294
+				exit;
1295
+			}
1296
+
1297
+		}
1298
+	}
1299 1299
 }
1300 1300
 
1301 1301
 
@@ -1309,84 +1309,84 @@  discard block
 block discarded – undo
1309 1309
  */
1310 1310
 function fetch_remote_file($url)
1311 1311
 {
1312
-    // extract the file name and extension from the url
1313
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1314
-    $file_name = basename($url);
1315
-    if (strpos($file_name, '?') !== false) {
1316
-        list($file_name) = explode('?', $file_name);
1317
-    }
1318
-    $dummy = false;
1319
-    $add_to_cache = false;
1320
-    $key = null;
1321
-    if (strpos($url, '/dummy/') !== false) {
1322
-        $dummy = true;
1323
-        $key = "dummy_".str_replace('.', '_', $file_name);
1324
-        $value = get_transient('cached_dummy_images');
1325
-        if ($value) {
1326
-            if (isset($value[$key])) {
1327
-                return $value[$key];
1328
-            } else {
1329
-                $add_to_cache = true;
1330
-            }
1331
-        } else {
1332
-            $add_to_cache = true;
1333
-        }
1334
-    }
1335
-
1336
-    // get placeholder file in the upload dir with a unique, sanitized filename
1337
-
1338
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1339
-
1340
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1341
-    if ($upload['error'])
1342
-        return new WP_Error('upload_dir_error', $upload['error']);
1343
-
1344
-
1345
-    sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
1346
-
1347
-    // fetch the remote url and write it to the placeholder file
1348
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1349
-
1350
-    $log_message = '';
1351
-    if( is_wp_error( $headers  ) ) {
1352
-        echo 'file: '.$url;
1353
-        return new WP_Error('import_file_error',$headers->get_error_message());
1354
-    }
1355
-
1356
-    $filesize = filesize($upload['file']);
1357
-    // request failed
1358
-    if (!$headers) {
1359
-        $log_message = __('Remote server did not respond', 'geodirectory');
1360
-    }
1361
-    // make sure the fetch was successful
1362
-    elseif ($headers['response']['code'] != '200') {
1363
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1364
-    }
1365
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1366
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1367
-    }
1368
-    elseif (0 == $filesize) {
1369
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1370
-    }
1371
-
1372
-    if($log_message){
1373
-        $del = unlink($upload['file']);
1374
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1375
-        return new WP_Error('import_file_error',$log_message );
1376
-    }
1377
-
1378
-    if ($dummy && $add_to_cache && is_array($upload)) {
1379
-        $images = get_transient('cached_dummy_images');
1380
-        if(is_array($images))
1381
-            $images[$key] = $upload;
1382
-        else
1383
-            $images = array($key => $upload);
1384
-
1385
-        //setting the cache using the WP Transient API
1386
-        set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1387
-    }
1388
-
1389
-    return $upload;
1312
+	// extract the file name and extension from the url
1313
+	require_once(ABSPATH . 'wp-includes/pluggable.php');
1314
+	$file_name = basename($url);
1315
+	if (strpos($file_name, '?') !== false) {
1316
+		list($file_name) = explode('?', $file_name);
1317
+	}
1318
+	$dummy = false;
1319
+	$add_to_cache = false;
1320
+	$key = null;
1321
+	if (strpos($url, '/dummy/') !== false) {
1322
+		$dummy = true;
1323
+		$key = "dummy_".str_replace('.', '_', $file_name);
1324
+		$value = get_transient('cached_dummy_images');
1325
+		if ($value) {
1326
+			if (isset($value[$key])) {
1327
+				return $value[$key];
1328
+			} else {
1329
+				$add_to_cache = true;
1330
+			}
1331
+		} else {
1332
+			$add_to_cache = true;
1333
+		}
1334
+	}
1335
+
1336
+	// get placeholder file in the upload dir with a unique, sanitized filename
1337
+
1338
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1339
+
1340
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1341
+	if ($upload['error'])
1342
+		return new WP_Error('upload_dir_error', $upload['error']);
1343
+
1344
+
1345
+	sleep(0.3);// if multiple remote file this can cause the remote server to timeout so we add a slight delay
1346
+
1347
+	// fetch the remote url and write it to the placeholder file
1348
+	$headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1349
+
1350
+	$log_message = '';
1351
+	if( is_wp_error( $headers  ) ) {
1352
+		echo 'file: '.$url;
1353
+		return new WP_Error('import_file_error',$headers->get_error_message());
1354
+	}
1355
+
1356
+	$filesize = filesize($upload['file']);
1357
+	// request failed
1358
+	if (!$headers) {
1359
+		$log_message = __('Remote server did not respond', 'geodirectory');
1360
+	}
1361
+	// make sure the fetch was successful
1362
+	elseif ($headers['response']['code'] != '200') {
1363
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1364
+	}
1365
+	elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1366
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1367
+	}
1368
+	elseif (0 == $filesize) {
1369
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1370
+	}
1371
+
1372
+	if($log_message){
1373
+		$del = unlink($upload['file']);
1374
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1375
+		return new WP_Error('import_file_error',$log_message );
1376
+	}
1377
+
1378
+	if ($dummy && $add_to_cache && is_array($upload)) {
1379
+		$images = get_transient('cached_dummy_images');
1380
+		if(is_array($images))
1381
+			$images[$key] = $upload;
1382
+		else
1383
+			$images = array($key => $upload);
1384
+
1385
+		//setting the cache using the WP Transient API
1386
+		set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1387
+	}
1388
+
1389
+	return $upload;
1390 1390
 }
1391 1391
 
1392 1392
 /**
@@ -1398,21 +1398,21 @@  discard block
 block discarded – undo
1398 1398
  */
1399 1399
 function geodir_max_upload_size()
1400 1400
 {
1401
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1402
-
1403
-    if ($max_filesize > 0 && $max_filesize < 1) {
1404
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1405
-    } else {
1406
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1407
-    }
1408
-
1409
-    /**
1410
-     * Filter default image upload size limit.
1411
-     *
1412
-     * @since 1.0.0
1413
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1414
-     */
1415
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1401
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1402
+
1403
+	if ($max_filesize > 0 && $max_filesize < 1) {
1404
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1405
+	} else {
1406
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1407
+	}
1408
+
1409
+	/**
1410
+	 * Filter default image upload size limit.
1411
+	 *
1412
+	 * @since 1.0.0
1413
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1414
+	 */
1415
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1416 1416
 }
1417 1417
 
1418 1418
 /**
@@ -1426,11 +1426,11 @@  discard block
 block discarded – undo
1426 1426
  */
1427 1427
 function geodir_dummy_folder_exists()
1428 1428
 {
1429
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1430
-    if (!is_dir($path))
1431
-        return false;
1432
-    else
1433
-        return true;
1429
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1430
+	if (!is_dir($path))
1431
+		return false;
1432
+	else
1433
+		return true;
1434 1434
 
1435 1435
 }
1436 1436
 
@@ -1445,290 +1445,290 @@  discard block
 block discarded – undo
1445 1445
  */
1446 1446
 function  geodir_get_author_info($aid)
1447 1447
 {
1448
-    global $wpdb;
1449
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1450
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1451
-    $info = $wpdb->get_results($infosql);
1452
-    if ($info) {
1453
-        return $info[0];
1454
-    }
1448
+	global $wpdb;
1449
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1450
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1451
+	$info = $wpdb->get_results($infosql);
1452
+	if ($info) {
1453
+		return $info[0];
1454
+	}
1455 1455
 }
1456 1456
 
1457 1457
 if (!function_exists('adminEmail')) {
1458
-    /**
1459
-     * Send emails to client on post submission, renew etc.
1460
-     *
1461
-     * @since 1.0.0
1462
-     * @package GeoDirectory
1463
-     * @global object $wpdb WordPress Database object.
1464
-     * @param int|string $page_id Page ID.
1465
-     * @param int|string $user_id User ID.
1466
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1467
-     * @param string $custom_1 Custom data to be sent.
1468
-     */
1469
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1470
-    {
1471
-        global $wpdb;
1472
-        if ($message_type == 'expiration') {
1473
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1474
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1475
-        } elseif ($message_type == 'post_submited') {
1476
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1477
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1478
-        } elseif ($message_type == 'renew') {
1479
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1480
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1481
-        } elseif ($message_type == 'upgrade') {
1482
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1483
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1484
-        } elseif ($message_type == 'claim_approved') {
1485
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1486
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1487
-        } elseif ($message_type == 'claim_rejected') {
1488
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1489
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1490
-        } elseif ($message_type == 'claim_requested') {
1491
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1492
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1493
-        } elseif ($message_type == 'auto_claim') {
1494
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1495
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1496
-        } elseif ($message_type == 'payment_success') {
1497
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1498
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1499
-        } elseif ($message_type == 'payment_fail') {
1500
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1501
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1502
-        }
1503
-        $transaction_details = $custom_1;
1504
-        $fromEmail = get_option('site_email');
1505
-        $fromEmailName = get_site_emailName();
1458
+	/**
1459
+	 * Send emails to client on post submission, renew etc.
1460
+	 *
1461
+	 * @since 1.0.0
1462
+	 * @package GeoDirectory
1463
+	 * @global object $wpdb WordPress Database object.
1464
+	 * @param int|string $page_id Page ID.
1465
+	 * @param int|string $user_id User ID.
1466
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1467
+	 * @param string $custom_1 Custom data to be sent.
1468
+	 */
1469
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1470
+	{
1471
+		global $wpdb;
1472
+		if ($message_type == 'expiration') {
1473
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1474
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1475
+		} elseif ($message_type == 'post_submited') {
1476
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1477
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1478
+		} elseif ($message_type == 'renew') {
1479
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1480
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1481
+		} elseif ($message_type == 'upgrade') {
1482
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1483
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1484
+		} elseif ($message_type == 'claim_approved') {
1485
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1486
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1487
+		} elseif ($message_type == 'claim_rejected') {
1488
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1489
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1490
+		} elseif ($message_type == 'claim_requested') {
1491
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1492
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1493
+		} elseif ($message_type == 'auto_claim') {
1494
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1495
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1496
+		} elseif ($message_type == 'payment_success') {
1497
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1498
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1499
+		} elseif ($message_type == 'payment_fail') {
1500
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1501
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1502
+		}
1503
+		$transaction_details = $custom_1;
1504
+		$fromEmail = get_option('site_email');
1505
+		$fromEmailName = get_site_emailName();
1506 1506
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1507
-        $pkg_limit = get_property_price_info_listing($page_id);
1508
-        $alivedays = $pkg_limit['days'];
1509
-        $productlink = get_permalink($page_id);
1510
-        $post_info = get_post($page_id);
1511
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1512
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1513
-        $loginurl = geodir_login_url();
1514
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1515
-        $siteurl = home_url();
1516
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1517
-        $user_info = get_userdata($user_id);
1518
-        $user_email = $user_info->user_email;
1519
-        $display_name = geodir_get_client_name($user_id);
1520
-        $user_login = $user_info->user_login;
1521
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1522
-        if ($number_of_grace_days == '') {
1523
-            $number_of_grace_days = 1;
1524
-        }
1525
-        if ($post_info->post_type == 'event') {
1526
-            $post_type = 'event';
1527
-        } else {
1528
-            $post_type = 'listing';
1529
-        }
1530
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1531
-        $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#]');
1532
-        $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);
1533
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1534
-        $subject = str_replace($search_array, $replace_array, $subject);
1535
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1536
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1537
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1538
-
1539
-        $to = $fromEmail;
1540
-        $message = $client_message;
1541
-
1542
-
1543
-        /**
1544
-         * Filter the admin email to address.
1545
-         *
1546
-         * @since 1.6.1
1547
-         * @package GeoDirectory
1548
-         * @param string $to The email address the email is being sent to.
1549
-         * @param int|string $page_id Page ID.
1550
-         * @param int|string $user_id User ID.
1551
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1552
-         * @param string $custom_1 Custom data to be sent.
1553
-         */
1554
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1555
-        /**
1556
-         * Filter the admin email subject.
1557
-         *
1558
-         * @since 1.6.1
1559
-         * @package GeoDirectory_Payment_Manager
1560
-         * @param string $subject The email subject.
1561
-         * @param int|string $page_id Page ID.
1562
-         * @param int|string $user_id User ID.
1563
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1564
-         * @param string $custom_1 Custom data to be sent.
1565
-         */
1566
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1567
-        /**
1568
-         * Filter the admin email message.
1569
-         *
1570
-         * @since 1.6.1
1571
-         * @package GeoDirectory_Payment_Manager
1572
-         * @param string $message The email message text.
1573
-         * @param int|string $page_id Page ID.
1574
-         * @param int|string $user_id User ID.
1575
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1576
-         * @param string $custom_1 Custom data to be sent.
1577
-         */
1578
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1579
-        /**
1580
-         * Filter the admin email headers.
1581
-         *
1582
-         * @since 1.6.1
1583
-         * @package GeoDirectory_Payment_Manager
1584
-         * @param string $headers The email headers.
1585
-         * @param int|string $page_id Page ID.
1586
-         * @param int|string $user_id User ID.
1587
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1588
-         * @param string $custom_1 Custom data to be sent.
1589
-         */
1590
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1591
-
1592
-
1593
-
1594
-        $sent = wp_mail($to, $subject, $message, $headers);
1595
-        if( ! $sent ) {
1596
-            if ( is_array( $to ) ) {
1597
-                $to = implode( ',', $to );
1598
-            }
1599
-            $log_message = sprintf(
1600
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1601
-                $message_type,
1602
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1603
-                $to,
1604
-                $subject
1605
-            );
1606
-            geodir_error_log( $log_message );
1607
-        }
1608
-    }
1507
+		$pkg_limit = get_property_price_info_listing($page_id);
1508
+		$alivedays = $pkg_limit['days'];
1509
+		$productlink = get_permalink($page_id);
1510
+		$post_info = get_post($page_id);
1511
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1512
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1513
+		$loginurl = geodir_login_url();
1514
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1515
+		$siteurl = home_url();
1516
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1517
+		$user_info = get_userdata($user_id);
1518
+		$user_email = $user_info->user_email;
1519
+		$display_name = geodir_get_client_name($user_id);
1520
+		$user_login = $user_info->user_login;
1521
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1522
+		if ($number_of_grace_days == '') {
1523
+			$number_of_grace_days = 1;
1524
+		}
1525
+		if ($post_info->post_type == 'event') {
1526
+			$post_type = 'event';
1527
+		} else {
1528
+			$post_type = 'listing';
1529
+		}
1530
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1531
+		$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#]');
1532
+		$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);
1533
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1534
+		$subject = str_replace($search_array, $replace_array, $subject);
1535
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1536
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1537
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1538
+
1539
+		$to = $fromEmail;
1540
+		$message = $client_message;
1541
+
1542
+
1543
+		/**
1544
+		 * Filter the admin email to address.
1545
+		 *
1546
+		 * @since 1.6.1
1547
+		 * @package GeoDirectory
1548
+		 * @param string $to The email address the email is being sent to.
1549
+		 * @param int|string $page_id Page ID.
1550
+		 * @param int|string $user_id User ID.
1551
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1552
+		 * @param string $custom_1 Custom data to be sent.
1553
+		 */
1554
+		$to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1555
+		/**
1556
+		 * Filter the admin email subject.
1557
+		 *
1558
+		 * @since 1.6.1
1559
+		 * @package GeoDirectory_Payment_Manager
1560
+		 * @param string $subject The email subject.
1561
+		 * @param int|string $page_id Page ID.
1562
+		 * @param int|string $user_id User ID.
1563
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1564
+		 * @param string $custom_1 Custom data to be sent.
1565
+		 */
1566
+		$subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1567
+		/**
1568
+		 * Filter the admin email message.
1569
+		 *
1570
+		 * @since 1.6.1
1571
+		 * @package GeoDirectory_Payment_Manager
1572
+		 * @param string $message The email message text.
1573
+		 * @param int|string $page_id Page ID.
1574
+		 * @param int|string $user_id User ID.
1575
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1576
+		 * @param string $custom_1 Custom data to be sent.
1577
+		 */
1578
+		$message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1579
+		/**
1580
+		 * Filter the admin email headers.
1581
+		 *
1582
+		 * @since 1.6.1
1583
+		 * @package GeoDirectory_Payment_Manager
1584
+		 * @param string $headers The email headers.
1585
+		 * @param int|string $page_id Page ID.
1586
+		 * @param int|string $user_id User ID.
1587
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1588
+		 * @param string $custom_1 Custom data to be sent.
1589
+		 */
1590
+		$headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1591
+
1592
+
1593
+
1594
+		$sent = wp_mail($to, $subject, $message, $headers);
1595
+		if( ! $sent ) {
1596
+			if ( is_array( $to ) ) {
1597
+				$to = implode( ',', $to );
1598
+			}
1599
+			$log_message = sprintf(
1600
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1601
+				$message_type,
1602
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1603
+				$to,
1604
+				$subject
1605
+			);
1606
+			geodir_error_log( $log_message );
1607
+		}
1608
+	}
1609 1609
 }
1610 1610
 
1611 1611
 if (!function_exists('sendEmail')) {
1612
-    /**
1613
-     * @todo could be a duplicate of geodir_sendEmail.
1614
-     *
1615
-     * @since 1.0.0
1616
-     * @package GeoDirectory
1617
-     * @param string $fromEmail Sender email address.
1618
-     * @param string $fromEmailName Sender name.
1619
-     * @param string $toEmail Receiver email address.
1620
-     * @param string $toEmailName Receiver name.
1621
-     * @param string $to_subject Email subject.
1622
-     * @param string $to_message Email content.
1623
-     * @param string $extra Not being used.
1624
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1625
-     * @param string $post_id The post ID.
1626
-     * @param string $user_id The user ID.
1627
-     */
1628
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1629
-    {
1630
-        $login_details = '';
1631
-        if ($message_type == 'send_friend') {
1632
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1633
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1634
-        } elseif ($message_type == 'send_enquiry') {
1635
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1636
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1637
-        } elseif ($message_type == 'forgot_password') {
1638
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1639
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1640
-            $login_details = $to_message;
1641
-        } elseif ($message_type == 'registration') {
1642
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1643
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1644
-            $login_details = $to_message;
1645
-        }
1646
-        $to_message = nl2br($to_message);
1647
-        $sitefromEmail = get_option('site_email');
1648
-        $sitefromEmailName = get_site_emailName();
1649
-        $productlink = get_permalink($post_id);
1650
-        $post_info = get_post($post_id);
1651
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1652
-        $siteurl = home_url();
1653
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1654
-        $loginurl = geodir_login_url();
1655
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1656
-        if ($fromEmail == '') {
1657
-            $fromEmail = get_option('site_email');
1658
-        }
1659
-        if ($fromEmailName == '') {
1660
-            $fromEmailName = get_option('site_email_name');
1661
-        }
1662
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1663
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1664
-        $message = str_replace($search_array, $replace_array, $message);
1665
-
1666
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1667
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1668
-        $subject = str_replace($search_array, $replace_array, $subject);
1669
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1670
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1671
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1672
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1673
-
1674
-        $to = $toEmail;
1675
-
1676
-        $sent = wp_mail($to, $subject, $message, $headers);
1677
-        if( ! $sent ) {
1678
-            if ( is_array( $to ) ) {
1679
-                $to = implode( ',', $to );
1680
-            }
1681
-            $log_message = sprintf(
1682
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1683
-                $message_type,
1684
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1685
-                $to,
1686
-                $subject
1687
-            );
1688
-            geodir_error_log( $log_message );
1689
-        }
1690
-
1691
-        ///////// ADMIN BCC EMIALS
1692
-        $admin_bcc = false;
1693
-        if ($message_type == 'registration') {
1694
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1695
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1696
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1697
-        }
1698
-        $adminEmail = get_bloginfo('admin_email');
1699
-        $to = $adminEmail;
1700
-
1701
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1702
-            $subject .= ' - ADMIN BCC COPY';
1703
-            $admin_bcc = true;
1704
-        }
1705
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1706
-            $subject .= ' - ADMIN BCC COPY';
1707
-            $admin_bcc = true;
1708
-        }
1709
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1710
-            $subject .= ' - ADMIN BCC COPY';
1711
-            $admin_bcc = true;
1712
-        }
1713
-
1714
-        if($admin_bcc === true){
1715
-            $sent = wp_mail($to, $subject, $message, $headers);
1716
-            if( ! $sent ) {
1717
-                if ( is_array( $to ) ) {
1718
-                    $to = implode( ',', $to );
1719
-                }
1720
-                $log_message = sprintf(
1721
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1722
-                    $message_type,
1723
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1724
-                    $to,
1725
-                    $subject
1726
-                );
1727
-                geodir_error_log( $log_message );
1728
-            }
1729
-        }
1730
-
1731
-    }
1612
+	/**
1613
+	 * @todo could be a duplicate of geodir_sendEmail.
1614
+	 *
1615
+	 * @since 1.0.0
1616
+	 * @package GeoDirectory
1617
+	 * @param string $fromEmail Sender email address.
1618
+	 * @param string $fromEmailName Sender name.
1619
+	 * @param string $toEmail Receiver email address.
1620
+	 * @param string $toEmailName Receiver name.
1621
+	 * @param string $to_subject Email subject.
1622
+	 * @param string $to_message Email content.
1623
+	 * @param string $extra Not being used.
1624
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1625
+	 * @param string $post_id The post ID.
1626
+	 * @param string $user_id The user ID.
1627
+	 */
1628
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1629
+	{
1630
+		$login_details = '';
1631
+		if ($message_type == 'send_friend') {
1632
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1633
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1634
+		} elseif ($message_type == 'send_enquiry') {
1635
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1636
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1637
+		} elseif ($message_type == 'forgot_password') {
1638
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1639
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1640
+			$login_details = $to_message;
1641
+		} elseif ($message_type == 'registration') {
1642
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1643
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1644
+			$login_details = $to_message;
1645
+		}
1646
+		$to_message = nl2br($to_message);
1647
+		$sitefromEmail = get_option('site_email');
1648
+		$sitefromEmailName = get_site_emailName();
1649
+		$productlink = get_permalink($post_id);
1650
+		$post_info = get_post($post_id);
1651
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1652
+		$siteurl = home_url();
1653
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1654
+		$loginurl = geodir_login_url();
1655
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1656
+		if ($fromEmail == '') {
1657
+			$fromEmail = get_option('site_email');
1658
+		}
1659
+		if ($fromEmailName == '') {
1660
+			$fromEmailName = get_option('site_email_name');
1661
+		}
1662
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1663
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1664
+		$message = str_replace($search_array, $replace_array, $message);
1665
+
1666
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1667
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1668
+		$subject = str_replace($search_array, $replace_array, $subject);
1669
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1670
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1671
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1672
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1673
+
1674
+		$to = $toEmail;
1675
+
1676
+		$sent = wp_mail($to, $subject, $message, $headers);
1677
+		if( ! $sent ) {
1678
+			if ( is_array( $to ) ) {
1679
+				$to = implode( ',', $to );
1680
+			}
1681
+			$log_message = sprintf(
1682
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1683
+				$message_type,
1684
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1685
+				$to,
1686
+				$subject
1687
+			);
1688
+			geodir_error_log( $log_message );
1689
+		}
1690
+
1691
+		///////// ADMIN BCC EMIALS
1692
+		$admin_bcc = false;
1693
+		if ($message_type == 'registration') {
1694
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1695
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1696
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1697
+		}
1698
+		$adminEmail = get_bloginfo('admin_email');
1699
+		$to = $adminEmail;
1700
+
1701
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1702
+			$subject .= ' - ADMIN BCC COPY';
1703
+			$admin_bcc = true;
1704
+		}
1705
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1706
+			$subject .= ' - ADMIN BCC COPY';
1707
+			$admin_bcc = true;
1708
+		}
1709
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1710
+			$subject .= ' - ADMIN BCC COPY';
1711
+			$admin_bcc = true;
1712
+		}
1713
+
1714
+		if($admin_bcc === true){
1715
+			$sent = wp_mail($to, $subject, $message, $headers);
1716
+			if( ! $sent ) {
1717
+				if ( is_array( $to ) ) {
1718
+					$to = implode( ',', $to );
1719
+				}
1720
+				$log_message = sprintf(
1721
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1722
+					$message_type,
1723
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1724
+					$to,
1725
+					$subject
1726
+				);
1727
+				geodir_error_log( $log_message );
1728
+			}
1729
+		}
1730
+
1731
+	}
1732 1732
 }
1733 1733
 
1734 1734
 /*
@@ -1746,16 +1746,16 @@  discard block
 block discarded – undo
1746 1746
  */
1747 1747
 function gd_lang_object_ids($ids_array, $type)
1748 1748
 {
1749
-    if (function_exists('icl_object_id')) {
1750
-        $res = array();
1751
-        foreach ($ids_array as $id) {
1752
-            $xlat = icl_object_id($id, $type, false);
1753
-            if (!is_null($xlat)) $res[] = $xlat;
1754
-        }
1755
-        return $res;
1756
-    } else {
1757
-        return $ids_array;
1758
-    }
1749
+	if (function_exists('icl_object_id')) {
1750
+		$res = array();
1751
+		foreach ($ids_array as $id) {
1752
+			$xlat = icl_object_id($id, $type, false);
1753
+			if (!is_null($xlat)) $res[] = $xlat;
1754
+		}
1755
+		return $res;
1756
+	} else {
1757
+		return $ids_array;
1758
+	}
1759 1759
 }
1760 1760
 
1761 1761
 
@@ -1770,31 +1770,31 @@  discard block
 block discarded – undo
1770 1770
  * @return array Modified Body CSS classes.
1771 1771
  */
1772 1772
 function geodir_custom_posts_body_class($classes) {
1773
-    global $wpdb, $wp;
1774
-    $post_types = geodir_get_posttypes('object');
1775
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1776
-        $classes[] = 'geodir_custom_posts';
1777
-    }
1778
-
1779
-    // fix body class for signup page
1780
-    if (geodir_is_page('login')) {
1781
-        $new_classes = array();
1782
-        $new_classes[] = 'signup page-geodir-signup';
1783
-        if (!empty($classes)) {
1784
-            foreach ($classes as $class) {
1785
-                if ($class && $class != 'home' && $class != 'blog') {
1786
-                    $new_classes[] = $class;
1787
-                }
1788
-            }
1789
-        }
1790
-        $classes = $new_classes;
1791
-    }
1792
-
1793
-    if (geodir_is_geodir_page()) {
1794
-        $classes[] = 'geodir-page';
1795
-    }
1796
-
1797
-    return $classes;
1773
+	global $wpdb, $wp;
1774
+	$post_types = geodir_get_posttypes('object');
1775
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1776
+		$classes[] = 'geodir_custom_posts';
1777
+	}
1778
+
1779
+	// fix body class for signup page
1780
+	if (geodir_is_page('login')) {
1781
+		$new_classes = array();
1782
+		$new_classes[] = 'signup page-geodir-signup';
1783
+		if (!empty($classes)) {
1784
+			foreach ($classes as $class) {
1785
+				if ($class && $class != 'home' && $class != 'blog') {
1786
+					$new_classes[] = $class;
1787
+				}
1788
+			}
1789
+		}
1790
+		$classes = $new_classes;
1791
+	}
1792
+
1793
+	if (geodir_is_geodir_page()) {
1794
+		$classes[] = 'geodir-page';
1795
+	}
1796
+
1797
+	return $classes;
1798 1798
 }
1799 1799
 
1800 1800
 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
@@ -1809,12 +1809,12 @@  discard block
 block discarded – undo
1809 1809
  */
1810 1810
 function geodir_map_zoom_level()
1811 1811
 {
1812
-    /**
1813
-     * Filter GD map zoom level.
1814
-     *
1815
-     * @since 1.0.0
1816
-     */
1817
-    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));
1812
+	/**
1813
+	 * Filter GD map zoom level.
1814
+	 *
1815
+	 * @since 1.0.0
1816
+	 */
1817
+	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));
1818 1818
 
1819 1819
 }
1820 1820
 
@@ -1828,12 +1828,12 @@  discard block
 block discarded – undo
1828 1828
  */
1829 1829
 function geodir_option_version_backup($geodir_option_name)
1830 1830
 {
1831
-    $version_date = time();
1832
-    $geodir_option = get_option($geodir_option_name);
1831
+	$version_date = time();
1832
+	$geodir_option = get_option($geodir_option_name);
1833 1833
 
1834
-    if (!empty($geodir_option)) {
1835
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1836
-    }
1834
+	if (!empty($geodir_option)) {
1835
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1836
+	}
1837 1837
 }
1838 1838
 
1839 1839
 /**
@@ -1846,11 +1846,11 @@  discard block
 block discarded – undo
1846 1846
  */
1847 1847
 function get_page_id_geodir_add_listing_page($page_id)
1848 1848
 {
1849
-    if (geodir_wpml_multilingual_status()) {
1850
-        $post_type = 'post_page';
1851
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1852
-    }
1853
-    return $page_id;
1849
+	if (geodir_wpml_multilingual_status()) {
1850
+		$post_type = 'post_page';
1851
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1852
+	}
1853
+	return $page_id;
1854 1854
 }
1855 1855
 
1856 1856
 /**
@@ -1862,10 +1862,10 @@  discard block
 block discarded – undo
1862 1862
  */
1863 1863
 function geodir_wpml_multilingual_status()
1864 1864
 {
1865
-    if (function_exists('icl_object_id')) {
1866
-        return true;
1867
-    }
1868
-    return false;
1865
+	if (function_exists('icl_object_id')) {
1866
+		return true;
1867
+	}
1868
+	return false;
1869 1869
 }
1870 1870
 
1871 1871
 /**
@@ -1879,22 +1879,22 @@  discard block
 block discarded – undo
1879 1879
  */
1880 1880
 function geodir_get_wpml_element_id($page_id, $post_type)
1881 1881
 {
1882
-    global $sitepress;
1883
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1884
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1885
-
1886
-        if ($trid > 0) {
1887
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1888
-
1889
-            $lang = $sitepress->get_current_language();
1890
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1891
-
1892
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1893
-                $page_id = $translations[$lang]->element_id;
1894
-            }
1895
-        }
1896
-    }
1897
-    return $page_id;
1882
+	global $sitepress;
1883
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1884
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1885
+
1886
+		if ($trid > 0) {
1887
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1888
+
1889
+			$lang = $sitepress->get_current_language();
1890
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1891
+
1892
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1893
+				$page_id = $translations[$lang]->element_id;
1894
+			}
1895
+		}
1896
+	}
1897
+	return $page_id;
1898 1898
 }
1899 1899
 
1900 1900
 /**
@@ -1906,20 +1906,20 @@  discard block
 block discarded – undo
1906 1906
  */
1907 1907
 function geodir_wpml_check_element_id()
1908 1908
 {
1909
-    global $sitepress;
1910
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1911
-        $el_type = 'post_page';
1912
-        $el_id = get_option('geodir_add_listing_page');
1913
-        $default_lang = $sitepress->get_default_language();
1914
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1915
-
1916
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1917
-            if (!$el_details->source_language_code) {
1918
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1919
-                $sitepress->icl_translations_cache->clear();
1920
-            }
1921
-        }
1922
-    }
1909
+	global $sitepress;
1910
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1911
+		$el_type = 'post_page';
1912
+		$el_id = get_option('geodir_add_listing_page');
1913
+		$default_lang = $sitepress->get_default_language();
1914
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1915
+
1916
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1917
+			if (!$el_details->source_language_code) {
1918
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1919
+				$sitepress->icl_translations_cache->clear();
1920
+			}
1921
+		}
1922
+	}
1923 1923
 }
1924 1924
 
1925 1925
 /**
@@ -1934,44 +1934,44 @@  discard block
 block discarded – undo
1934 1934
  */
1935 1935
 function geodir_widget_listings_get_order($query_args)
1936 1936
 {
1937
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1938
-
1939
-    $query_args = $gd_query_args_widgets;
1940
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1941
-        return $wpdb->posts . ".post_date DESC, ";
1942
-    }
1943
-
1944
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1945
-    $table = $plugin_prefix . $post_type . '_detail';
1946
-
1947
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1948
-
1949
-    switch ($sort_by) {
1950
-        case 'latest':
1951
-        case 'newest':
1952
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1953
-            break;
1954
-        case 'featured':
1955
-            $orderby = $table . ".is_featured ASC, ";
1956
-            break;
1957
-        case 'az':
1958
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1959
-            break;
1960
-        case 'high_review':
1961
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1962
-            break;
1963
-        case 'high_rating':
1964
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1965
-            break;
1966
-        case 'random':
1967
-            $orderby = "RAND(), ";
1968
-            break;
1969
-        default:
1970
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1971
-            break;
1972
-    }
1973
-
1974
-    return $orderby;
1937
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1938
+
1939
+	$query_args = $gd_query_args_widgets;
1940
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1941
+		return $wpdb->posts . ".post_date DESC, ";
1942
+	}
1943
+
1944
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1945
+	$table = $plugin_prefix . $post_type . '_detail';
1946
+
1947
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1948
+
1949
+	switch ($sort_by) {
1950
+		case 'latest':
1951
+		case 'newest':
1952
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1953
+			break;
1954
+		case 'featured':
1955
+			$orderby = $table . ".is_featured ASC, ";
1956
+			break;
1957
+		case 'az':
1958
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1959
+			break;
1960
+		case 'high_review':
1961
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1962
+			break;
1963
+		case 'high_rating':
1964
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1965
+			break;
1966
+		case 'random':
1967
+			$orderby = "RAND(), ";
1968
+			break;
1969
+		default:
1970
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1971
+			break;
1972
+	}
1973
+
1974
+	return $orderby;
1975 1975
 }
1976 1976
 
1977 1977
 /**
@@ -1989,126 +1989,126 @@  discard block
 block discarded – undo
1989 1989
  */
1990 1990
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1991 1991
 {
1992
-    global $wpdb, $plugin_prefix, $table_prefix;
1993
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1994
-    $gd_query_args_widgets = $query_args;
1995
-
1996
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1997
-    $table = $plugin_prefix . $post_type . '_detail';
1998
-
1999
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
2000
-    /**
2001
-     * Filter widget listing fields string part that is being used for query.
2002
-     *
2003
-     * @since 1.0.0
2004
-     * @param string $fields Fields string.
2005
-     * @param string $table Table name.
2006
-     * @param string $post_type Post type.
2007
-     */
2008
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
2009
-
2010
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
2011
-
2012
-    ########### WPML ###########
2013
-
2014
-    if (function_exists('icl_object_id')) {
2015
-        global $sitepress;
2016
-        $lang_code = ICL_LANGUAGE_CODE;
2017
-        if ($lang_code) {
2018
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2019
-        }
2020
-    }
2021
-
2022
-    ########### WPML ###########
2023
-
2024
-    /**
2025
-     * Filter widget listing join clause string part that is being used for query.
2026
-     *
2027
-     * @since 1.0.0
2028
-     * @param string $join Join clause string.
2029
-     * @param string $post_type Post type.
2030
-     */
2031
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2032
-
2033
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2034
-
2035
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2036
-
2037
-    ########### WPML ###########
2038
-    if (function_exists('icl_object_id')) {
2039
-        if ($lang_code) {
2040
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2041
-        }
2042
-    }
2043
-    ########### WPML ###########
2044
-    /**
2045
-     * Filter widget listing where clause string part that is being used for query.
2046
-     *
2047
-     * @since 1.0.0
2048
-     * @param string $where Where clause string.
2049
-     * @param string $post_type Post type.
2050
-     */
2051
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2052
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2053
-
2054
-    $groupby = " GROUP BY $wpdb->posts.ID ";
2055
-    /**
2056
-     * Filter widget listing groupby clause string part that is being used for query.
2057
-     *
2058
-     * @since 1.0.0
2059
-     * @param string $groupby Group by clause string.
2060
-     * @param string $post_type Post type.
2061
-     */
2062
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2063
-
2064
-    if ($count_only) {
2065
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1992
+	global $wpdb, $plugin_prefix, $table_prefix;
1993
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1994
+	$gd_query_args_widgets = $query_args;
1995
+
1996
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1997
+	$table = $plugin_prefix . $post_type . '_detail';
1998
+
1999
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
2000
+	/**
2001
+	 * Filter widget listing fields string part that is being used for query.
2002
+	 *
2003
+	 * @since 1.0.0
2004
+	 * @param string $fields Fields string.
2005
+	 * @param string $table Table name.
2006
+	 * @param string $post_type Post type.
2007
+	 */
2008
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
2009
+
2010
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
2011
+
2012
+	########### WPML ###########
2013
+
2014
+	if (function_exists('icl_object_id')) {
2015
+		global $sitepress;
2016
+		$lang_code = ICL_LANGUAGE_CODE;
2017
+		if ($lang_code) {
2018
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2019
+		}
2020
+	}
2021
+
2022
+	########### WPML ###########
2023
+
2024
+	/**
2025
+	 * Filter widget listing join clause string part that is being used for query.
2026
+	 *
2027
+	 * @since 1.0.0
2028
+	 * @param string $join Join clause string.
2029
+	 * @param string $post_type Post type.
2030
+	 */
2031
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2032
+
2033
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2034
+
2035
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2036
+
2037
+	########### WPML ###########
2038
+	if (function_exists('icl_object_id')) {
2039
+		if ($lang_code) {
2040
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2041
+		}
2042
+	}
2043
+	########### WPML ###########
2044
+	/**
2045
+	 * Filter widget listing where clause string part that is being used for query.
2046
+	 *
2047
+	 * @since 1.0.0
2048
+	 * @param string $where Where clause string.
2049
+	 * @param string $post_type Post type.
2050
+	 */
2051
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2052
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
2053
+
2054
+	$groupby = " GROUP BY $wpdb->posts.ID ";
2055
+	/**
2056
+	 * Filter widget listing groupby clause string part that is being used for query.
2057
+	 *
2058
+	 * @since 1.0.0
2059
+	 * @param string $groupby Group by clause string.
2060
+	 * @param string $post_type Post type.
2061
+	 */
2062
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2063
+
2064
+	if ($count_only) {
2065
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2066 2066
 			" . $join . "
2067 2067
 			" . $where;
2068
-        $rows = (int)$wpdb->get_var($sql);
2069
-    } else {
2070
-        $orderby = geodir_widget_listings_get_order($query_args);
2071
-        /**
2072
-         * Filter widget listing orderby clause string part that is being used for query.
2073
-         *
2074
-         * @since 1.0.0
2075
-         * @param string $orderby Order by clause string.
2076
-         * @param string $table Table name.
2077
-         * @param string $post_type Post type.
2078
-         */
2079
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2080
-        $orderby .= $wpdb->posts . ".post_title ASC";
2081
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2082
-
2083
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2084
-        /**
2085
-         * Filter widget listing limit that is being used for query.
2086
-         *
2087
-         * @since 1.0.0
2088
-         * @param int $limit Query results limit.
2089
-         * @param string $post_type Post type.
2090
-         */
2091
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2092
-
2093
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2094
-        if ( !$page )
2095
-            $page = 1;
2096
-
2097
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2098
-
2099
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2068
+		$rows = (int)$wpdb->get_var($sql);
2069
+	} else {
2070
+		$orderby = geodir_widget_listings_get_order($query_args);
2071
+		/**
2072
+		 * Filter widget listing orderby clause string part that is being used for query.
2073
+		 *
2074
+		 * @since 1.0.0
2075
+		 * @param string $orderby Order by clause string.
2076
+		 * @param string $table Table name.
2077
+		 * @param string $post_type Post type.
2078
+		 */
2079
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2080
+		$orderby .= $wpdb->posts . ".post_title ASC";
2081
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2082
+
2083
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2084
+		/**
2085
+		 * Filter widget listing limit that is being used for query.
2086
+		 *
2087
+		 * @since 1.0.0
2088
+		 * @param int $limit Query results limit.
2089
+		 * @param string $post_type Post type.
2090
+		 */
2091
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2092
+
2093
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2094
+		if ( !$page )
2095
+			$page = 1;
2096
+
2097
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2098
+
2099
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2100 2100
 			" . $join . "
2101 2101
 			" . $where . "
2102 2102
 			" . $groupby . "
2103 2103
 			" . $orderby . "
2104 2104
 			" . $limit;
2105
-        $rows = $wpdb->get_results($sql);
2106
-    }
2105
+		$rows = $wpdb->get_results($sql);
2106
+	}
2107 2107
 
2108
-    unset($GLOBALS['gd_query_args_widgets']);
2109
-    unset($gd_query_args_widgets);
2108
+	unset($GLOBALS['gd_query_args_widgets']);
2109
+	unset($gd_query_args_widgets);
2110 2110
 
2111
-    return $rows;
2111
+	return $rows;
2112 2112
 }
2113 2113
 
2114 2114
 /**
@@ -2123,14 +2123,14 @@  discard block
 block discarded – undo
2123 2123
  */
2124 2124
 function geodir_function_widget_listings_fields($fields)
2125 2125
 {
2126
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2126
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2127 2127
 
2128
-    $query_args = $gd_query_args_widgets;
2129
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2130
-        return $fields;
2131
-    }
2128
+	$query_args = $gd_query_args_widgets;
2129
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2130
+		return $fields;
2131
+	}
2132 2132
     
2133
-    return $fields;
2133
+	return $fields;
2134 2134
 }
2135 2135
 
2136 2136
 /**
@@ -2145,28 +2145,28 @@  discard block
 block discarded – undo
2145 2145
  */
2146 2146
 function geodir_function_widget_listings_join($join)
2147 2147
 {
2148
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2148
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2149 2149
 
2150
-    $query_args = $gd_query_args_widgets;
2151
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2152
-        return $join;
2153
-    }
2150
+	$query_args = $gd_query_args_widgets;
2151
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2152
+		return $join;
2153
+	}
2154 2154
 
2155
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2156
-    $table = $plugin_prefix . $post_type . '_detail';
2155
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2156
+	$table = $plugin_prefix . $post_type . '_detail';
2157 2157
 
2158
-    if (!empty($query_args['with_pics_only'])) {
2159
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2160
-    }
2158
+	if (!empty($query_args['with_pics_only'])) {
2159
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2160
+	}
2161 2161
 
2162
-    if (!empty($query_args['tax_query'])) {
2163
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2164
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2165
-            $join .= $tax_queries['join'];
2166
-        }
2167
-    }
2162
+	if (!empty($query_args['tax_query'])) {
2163
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2164
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2165
+			$join .= $tax_queries['join'];
2166
+		}
2167
+	}
2168 2168
 
2169
-    return $join;
2169
+	return $join;
2170 2170
 }
2171 2171
 
2172 2172
 /**
@@ -2181,54 +2181,54 @@  discard block
 block discarded – undo
2181 2181
  */
2182 2182
 function geodir_function_widget_listings_where($where)
2183 2183
 {
2184
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2185
-
2186
-    $query_args = $gd_query_args_widgets;
2187
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2188
-        return $where;
2189
-    }
2190
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2191
-    $table = $plugin_prefix . $post_type . '_detail';
2192
-
2193
-    if (!empty($query_args)) {
2194
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2195
-            $where = geodir_default_location_where($where, $table);
2196
-        }
2197
-
2198
-        if (!empty($query_args['post_author'])) {
2199
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2200
-        }
2184
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2185
+
2186
+	$query_args = $gd_query_args_widgets;
2187
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2188
+		return $where;
2189
+	}
2190
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2191
+	$table = $plugin_prefix . $post_type . '_detail';
2192
+
2193
+	if (!empty($query_args)) {
2194
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2195
+			$where = geodir_default_location_where($where, $table);
2196
+		}
2197
+
2198
+		if (!empty($query_args['post_author'])) {
2199
+			$where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2200
+		}
2201 2201
         
2202
-        if (!empty($query_args['show_featured_only'])) {
2203
-            $where .= " AND " . $table . ".is_featured = '1'";
2204
-        }
2202
+		if (!empty($query_args['show_featured_only'])) {
2203
+			$where .= " AND " . $table . ".is_featured = '1'";
2204
+		}
2205 2205
 
2206
-        if (!empty($query_args['show_special_only'])) {
2207
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2208
-        }
2206
+		if (!empty($query_args['show_special_only'])) {
2207
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2208
+		}
2209 2209
 
2210
-        if (!empty($query_args['with_pics_only'])) {
2211
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2212
-        }
2210
+		if (!empty($query_args['with_pics_only'])) {
2211
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2212
+		}
2213 2213
 
2214
-        if (!empty($query_args['featured_image_only'])) {
2215
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2216
-        }
2214
+		if (!empty($query_args['featured_image_only'])) {
2215
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2216
+		}
2217 2217
 
2218
-        if (!empty($query_args['with_videos_only'])) {
2219
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2220
-        }
2218
+		if (!empty($query_args['with_videos_only'])) {
2219
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2220
+		}
2221 2221
 
2222
-        if (!empty($query_args['tax_query'])) {
2223
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2222
+		if (!empty($query_args['tax_query'])) {
2223
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2224 2224
 
2225
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2226
-                $where .= $tax_queries['where'];
2227
-            }
2228
-        }
2229
-    }
2225
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2226
+				$where .= $tax_queries['where'];
2227
+			}
2228
+		}
2229
+	}
2230 2230
 
2231
-    return $where;
2231
+	return $where;
2232 2232
 }
2233 2233
 
2234 2234
 /**
@@ -2243,14 +2243,14 @@  discard block
 block discarded – undo
2243 2243
  */
2244 2244
 function geodir_function_widget_listings_orderby($orderby)
2245 2245
 {
2246
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2246
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2247 2247
 
2248
-    $query_args = $gd_query_args_widgets;
2249
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2250
-        return $orderby;
2251
-    }
2248
+	$query_args = $gd_query_args_widgets;
2249
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2250
+		return $orderby;
2251
+	}
2252 2252
 
2253
-    return $orderby;
2253
+	return $orderby;
2254 2254
 }
2255 2255
 
2256 2256
 /**
@@ -2265,18 +2265,18 @@  discard block
 block discarded – undo
2265 2265
  */
2266 2266
 function geodir_function_widget_listings_limit($limit)
2267 2267
 {
2268
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2268
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2269 2269
 
2270
-    $query_args = $gd_query_args_widgets;
2271
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2272
-        return $limit;
2273
-    }
2270
+	$query_args = $gd_query_args_widgets;
2271
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2272
+		return $limit;
2273
+	}
2274 2274
 
2275
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2276
-        $limit = (int)$query_args['posts_per_page'];
2277
-    }
2275
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2276
+		$limit = (int)$query_args['posts_per_page'];
2277
+	}
2278 2278
 
2279
-    return $limit;
2279
+	return $limit;
2280 2280
 }
2281 2281
 
2282 2282
 /**
@@ -2290,24 +2290,24 @@  discard block
 block discarded – undo
2290 2290
  */
2291 2291
 function geodir_media_image_large_width($default = 800, $params = '')
2292 2292
 {
2293
-    $large_size_w = get_option('large_size_w');
2294
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2295
-    $large_size_w = absint($large_size_w);
2296
-
2297
-    if (!get_option('geodir_use_wp_media_large_size')) {
2298
-        $large_size_w = 800;
2299
-    }
2300
-
2301
-    /**
2302
-     * Filter large image width.
2303
-     *
2304
-     * @since 1.0.0
2305
-     * @param int $large_size_w Large image width.
2306
-     * @param int $default Default width.
2307
-     * @param string|array $params Image parameters.
2308
-     */
2309
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2310
-    return $large_size_w;
2293
+	$large_size_w = get_option('large_size_w');
2294
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2295
+	$large_size_w = absint($large_size_w);
2296
+
2297
+	if (!get_option('geodir_use_wp_media_large_size')) {
2298
+		$large_size_w = 800;
2299
+	}
2300
+
2301
+	/**
2302
+	 * Filter large image width.
2303
+	 *
2304
+	 * @since 1.0.0
2305
+	 * @param int $large_size_w Large image width.
2306
+	 * @param int $default Default width.
2307
+	 * @param string|array $params Image parameters.
2308
+	 */
2309
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2310
+	return $large_size_w;
2311 2311
 }
2312 2312
 
2313 2313
 /**
@@ -2321,25 +2321,25 @@  discard block
 block discarded – undo
2321 2321
  */
2322 2322
 function geodir_media_image_large_height($default = 800, $params = '')
2323 2323
 {
2324
-    $large_size_h = get_option('large_size_h');
2325
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2326
-    $large_size_h = absint($large_size_h);
2327
-
2328
-    if (!get_option('geodir_use_wp_media_large_size')) {
2329
-        $large_size_h = 800;
2330
-    }
2331
-
2332
-    /**
2333
-     * Filter large image height.
2334
-     *
2335
-     * @since 1.0.0
2336
-     * @param int $large_size_h Large image height.
2337
-     * @param int $default Default height.
2338
-     * @param string|array $params Image parameters.
2339
-     */
2340
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2341
-
2342
-    return $large_size_h;
2324
+	$large_size_h = get_option('large_size_h');
2325
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2326
+	$large_size_h = absint($large_size_h);
2327
+
2328
+	if (!get_option('geodir_use_wp_media_large_size')) {
2329
+		$large_size_h = 800;
2330
+	}
2331
+
2332
+	/**
2333
+	 * Filter large image height.
2334
+	 *
2335
+	 * @since 1.0.0
2336
+	 * @param int $large_size_h Large image height.
2337
+	 * @param int $default Default height.
2338
+	 * @param string|array $params Image parameters.
2339
+	 */
2340
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2341
+
2342
+	return $large_size_h;
2343 2343
 }
2344 2344
 
2345 2345
 /**
@@ -2354,25 +2354,25 @@  discard block
 block discarded – undo
2354 2354
  */
2355 2355
 function geodir_sanitize_location_name($type, $name, $translate = true)
2356 2356
 {
2357
-    if ($name == '') {
2358
-        return NULL;
2359
-    }
2360
-
2361
-    $type = $type == 'gd_country' ? 'country' : $type;
2362
-    $type = $type == 'gd_region' ? 'region' : $type;
2363
-    $type = $type == 'gd_city' ? 'city' : $type;
2364
-
2365
-    $return = $name;
2366
-    if (function_exists('get_actual_location_name')) {
2367
-        $return = get_actual_location_name($type, $name, $translate);
2368
-    } else {
2369
-        $return = preg_replace('/-(\d+)$/', '', $return);
2370
-        $return = preg_replace('/[_-]/', ' ', $return);
2371
-        $return = geodir_ucwords($return);
2372
-        $return = $translate ? __($return, 'geodirectory') : $return;
2373
-    }
2374
-
2375
-    return $return;
2357
+	if ($name == '') {
2358
+		return NULL;
2359
+	}
2360
+
2361
+	$type = $type == 'gd_country' ? 'country' : $type;
2362
+	$type = $type == 'gd_region' ? 'region' : $type;
2363
+	$type = $type == 'gd_city' ? 'city' : $type;
2364
+
2365
+	$return = $name;
2366
+	if (function_exists('get_actual_location_name')) {
2367
+		$return = get_actual_location_name($type, $name, $translate);
2368
+	} else {
2369
+		$return = preg_replace('/-(\d+)$/', '', $return);
2370
+		$return = preg_replace('/[_-]/', ' ', $return);
2371
+		$return = geodir_ucwords($return);
2372
+		$return = $translate ? __($return, 'geodirectory') : $return;
2373
+	}
2374
+
2375
+	return $return;
2376 2376
 }
2377 2377
 
2378 2378
 
@@ -2386,14 +2386,14 @@  discard block
 block discarded – undo
2386 2386
 function geodir_comments_number($number)
2387 2387
 {
2388 2388
 
2389
-    if ($number > 1) {
2390
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2391
-    } elseif ($number == 0 || $number == '') {
2392
-        $output = __('No Reviews', 'geodirectory');
2393
-    } else { // must be one
2394
-        $output = __('1 Review', 'geodirectory');
2395
-    }
2396
-    echo $output;
2389
+	if ($number > 1) {
2390
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2391
+	} elseif ($number == 0 || $number == '') {
2392
+		$output = __('No Reviews', 'geodirectory');
2393
+	} else { // must be one
2394
+		$output = __('1 Review', 'geodirectory');
2395
+	}
2396
+	echo $output;
2397 2397
 }
2398 2398
 
2399 2399
 /**
@@ -2406,23 +2406,23 @@  discard block
 block discarded – undo
2406 2406
  */
2407 2407
 function is_page_geodir_home()
2408 2408
 {
2409
-    global $wpdb;
2410
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2411
-    if (function_exists('geodir_location_geo_home_link')) {
2412
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2413
-    }
2414
-    $home_url = home_url('', 'http');
2415
-    if (function_exists('geodir_location_geo_home_link')) {
2416
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2417
-    }
2418
-    $home_url = str_replace("www.", "", $home_url);
2419
-    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')) ) {
2420
-        return true;
2421
-    }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')){
2422
-        return true;
2423
-    } else {
2424
-        return false;
2425
-    }
2409
+	global $wpdb;
2410
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2411
+	if (function_exists('geodir_location_geo_home_link')) {
2412
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2413
+	}
2414
+	$home_url = home_url('', 'http');
2415
+	if (function_exists('geodir_location_geo_home_link')) {
2416
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2417
+	}
2418
+	$home_url = str_replace("www.", "", $home_url);
2419
+	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')) ) {
2420
+		return true;
2421
+	}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')){
2422
+		return true;
2423
+	} else {
2424
+		return false;
2425
+	}
2426 2426
 
2427 2427
 }
2428 2428
 
@@ -2438,13 +2438,13 @@  discard block
 block discarded – undo
2438 2438
  */
2439 2439
 function geodir_wpseo_homepage_canonical($url)
2440 2440
 {
2441
-    global $post;
2441
+	global $post;
2442 2442
 
2443
-    if (is_page_geodir_home()) {
2444
-        return home_url();
2445
-    }
2443
+	if (is_page_geodir_home()) {
2444
+		return home_url();
2445
+	}
2446 2446
 
2447
-    return $url;
2447
+	return $url;
2448 2448
 }
2449 2449
 
2450 2450
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2461,16 +2461,16 @@  discard block
 block discarded – undo
2461 2461
  */
2462 2462
 function geodir_googlemap_script_extra_details_page($extra)
2463 2463
 {
2464
-    global $post;
2465
-    $add_google_places_api = false;
2466
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2467
-        $add_google_places_api = true;
2468
-    }
2469
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2470
-        $extra .= "&amp;libraries=places";
2471
-    }
2472
-
2473
-    return $extra;
2464
+	global $post;
2465
+	$add_google_places_api = false;
2466
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2467
+		$add_google_places_api = true;
2468
+	}
2469
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2470
+		$extra .= "&amp;libraries=places";
2471
+	}
2472
+
2473
+	return $extra;
2474 2474
 }
2475 2475
 
2476 2476
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2490,98 +2490,98 @@  discard block
 block discarded – undo
2490 2490
  */
2491 2491
 function geodir_popular_post_category_output($args = '', $instance = '')
2492 2492
 {
2493
-    // prints the widget
2494
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2495
-    extract($args, EXTR_SKIP);
2496
-
2497
-    echo $before_widget;
2498
-
2499
-    /** This filter is documented in geodirectory_widgets.php */
2500
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2501
-
2502
-    $gd_post_type = geodir_get_current_posttype();
2503
-
2504
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2505
-    if(!empty($gd_post_type)){
2506
-        $default_post_type = $gd_post_type;
2507
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2508
-        $default_post_type = $instance['default_post_type'];
2509
-    }else{
2510
-        $all_gd_post_type = geodir_get_posttypes();
2511
-        $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2512
-    }
2513
-
2514
-    $taxonomy = array();
2515
-    if (!empty($gd_post_type)) {
2516
-        $taxonomy[] = $gd_post_type . "category";
2517
-    } else {
2518
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2519
-    }
2520
-
2521
-    $terms = get_terms($taxonomy);
2522
-    $a_terms = array();
2523
-    $b_terms = array();
2524
-
2525
-    foreach ($terms as $term) {
2526
-        if ($term->count > 0) {
2527
-            $a_terms[$term->taxonomy][] = $term;
2528
-        }
2529
-    }
2530
-
2531
-    if (!empty($a_terms)) {
2532
-        foreach ($a_terms as $b_key => $b_val) {
2533
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2534
-        }
2535
-
2536
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2537
-
2538
-        $tax_change_output = '';
2539
-        if (count($b_terms) > 1) {
2540
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2541
-            foreach ($b_terms as $key => $val) {
2542
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2543
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2544
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2545
-            }
2546
-            $tax_change_output .= "</select>";
2547
-        }
2548
-
2549
-        if (!empty($b_terms)) {
2550
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2551
-            global $cat_count;//make global so we can change via function
2552
-            $cat_count = 0;
2553
-            ?>
2493
+	// prints the widget
2494
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2495
+	extract($args, EXTR_SKIP);
2496
+
2497
+	echo $before_widget;
2498
+
2499
+	/** This filter is documented in geodirectory_widgets.php */
2500
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2501
+
2502
+	$gd_post_type = geodir_get_current_posttype();
2503
+
2504
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2505
+	if(!empty($gd_post_type)){
2506
+		$default_post_type = $gd_post_type;
2507
+	}elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2508
+		$default_post_type = $instance['default_post_type'];
2509
+	}else{
2510
+		$all_gd_post_type = geodir_get_posttypes();
2511
+		$default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2512
+	}
2513
+
2514
+	$taxonomy = array();
2515
+	if (!empty($gd_post_type)) {
2516
+		$taxonomy[] = $gd_post_type . "category";
2517
+	} else {
2518
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2519
+	}
2520
+
2521
+	$terms = get_terms($taxonomy);
2522
+	$a_terms = array();
2523
+	$b_terms = array();
2524
+
2525
+	foreach ($terms as $term) {
2526
+		if ($term->count > 0) {
2527
+			$a_terms[$term->taxonomy][] = $term;
2528
+		}
2529
+	}
2530
+
2531
+	if (!empty($a_terms)) {
2532
+		foreach ($a_terms as $b_key => $b_val) {
2533
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2534
+		}
2535
+
2536
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2537
+
2538
+		$tax_change_output = '';
2539
+		if (count($b_terms) > 1) {
2540
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2541
+			foreach ($b_terms as $key => $val) {
2542
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2543
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2544
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2545
+			}
2546
+			$tax_change_output .= "</select>";
2547
+		}
2548
+
2549
+		if (!empty($b_terms)) {
2550
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2551
+			global $cat_count;//make global so we can change via function
2552
+			$cat_count = 0;
2553
+			?>
2554 2554
             <div class="geodir-category-list-in clearfix">
2555 2555
                 <div class="geodir-cat-list clearfix">
2556 2556
                     <?php
2557
-                    echo $before_title . __($title) . $after_title;
2557
+					echo $before_title . __($title) . $after_title;
2558 2558
 
2559
-                    echo $tax_change_output;
2559
+					echo $tax_change_output;
2560 2560
 
2561
-                    echo '<ul class="geodir-popular-cat-list">';
2561
+					echo '<ul class="geodir-popular-cat-list">';
2562 2562
 
2563
-                    geodir_helper_cat_list_output($terms, $category_limit);
2563
+					geodir_helper_cat_list_output($terms, $category_limit);
2564 2564
 
2565
-                    echo '</ul>';
2566
-                    ?>
2565
+					echo '</ul>';
2566
+					?>
2567 2567
                 </div>
2568 2568
                 <?php
2569
-                $hide = '';
2570
-                if ($cat_count < $category_limit) {
2571
-                    $hide = 'style="display:none;"';
2572
-                }
2573
-                echo "<div class='geodir-cat-list-more' $hide >";
2574
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2575
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2576
-                echo "</div>";
2577
-                /* add scripts */
2578
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2579
-                ?>
2569
+				$hide = '';
2570
+				if ($cat_count < $category_limit) {
2571
+					$hide = 'style="display:none;"';
2572
+				}
2573
+				echo "<div class='geodir-cat-list-more' $hide >";
2574
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2575
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2576
+				echo "</div>";
2577
+				/* add scripts */
2578
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2579
+				?>
2580 2580
             </div>
2581 2581
         <?php
2582
-        }
2583
-    }
2584
-    echo $after_widget;
2582
+		}
2583
+	}
2584
+	echo $after_widget;
2585 2585
 }
2586 2586
 
2587 2587
 /**
@@ -2595,38 +2595,38 @@  discard block
 block discarded – undo
2595 2595
  */
2596 2596
 function geodir_helper_cat_list_output($terms, $category_limit)
2597 2597
 {
2598
-    global $geodir_post_category_str, $cat_count;
2599
-    $term_icons = geodir_get_term_icon();
2598
+	global $geodir_post_category_str, $cat_count;
2599
+	$term_icons = geodir_get_term_icon();
2600 2600
 
2601
-    $geodir_post_category_str = array();
2601
+	$geodir_post_category_str = array();
2602 2602
 
2603 2603
 
2604
-    foreach ($terms as $cat) {
2605
-        $post_type = str_replace("category", "", $cat->taxonomy);
2606
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2604
+	foreach ($terms as $cat) {
2605
+		$post_type = str_replace("category", "", $cat->taxonomy);
2606
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2607 2607
 
2608
-        $cat_count++;
2608
+		$cat_count++;
2609 2609
 
2610
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2610
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2611 2611
 
2612
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2613
-        $total_post = $cat->count;
2612
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2613
+		$total_post = $cat->count;
2614 2614
 
2615
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2616
-        /**
2617
-         * Filer the category term link.
2618
-         *
2619
-         * @since 1.4.5
2620
-         * @param string $term_link The term permalink.
2621
-         * @param int    $cat->term_id The term id.
2622
-         * @param string $post_type Wordpress post type.
2623
-         */
2624
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2615
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2616
+		/**
2617
+		 * Filer the category term link.
2618
+		 *
2619
+		 * @since 1.4.5
2620
+		 * @param string $term_link The term permalink.
2621
+		 * @param int    $cat->term_id The term id.
2622
+		 * @param string $post_type Wordpress post type.
2623
+		 */
2624
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2625 2625
 
2626
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2627
-        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> ';
2628
-        echo '</a></li>';
2629
-    }
2626
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2627
+		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> ';
2628
+		echo '</a></li>';
2629
+	}
2630 2630
 }
2631 2631
 
2632 2632
 /**
@@ -2640,108 +2640,108 @@  discard block
 block discarded – undo
2640 2640
  */
2641 2641
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2642 2642
 {
2643
-    // prints the widget
2644
-    extract($args, EXTR_SKIP);
2645
-
2646
-    echo $before_widget;
2647
-
2648
-    /** This filter is documented in geodirectory_widgets.php */
2649
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2650
-    /**
2651
-     * Filter the widget post type.
2652
-     *
2653
-     * @since 1.0.0
2654
-     * @param string $instance['post_type'] Post type of listing.
2655
-     */
2656
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2657
-    /**
2658
-     * Filter the widget's term.
2659
-     *
2660
-     * @since 1.0.0
2661
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2662
-     */
2663
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2664
-    /**
2665
-     * Filter the widget listings limit.
2666
-     *
2667
-     * @since 1.0.0
2668
-     * @param string $instance['post_number'] Number of listings to display.
2669
-     */
2670
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2671
-    /**
2672
-     * Filter the widget listings limit shown at one time.
2673
-     *
2674
-     * @since 1.5.0
2675
-     * @param string $instance['max_show'] Number of listings to display on screen.
2676
-     */
2677
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2678
-    /**
2679
-     * Filter the widget slide width.
2680
-     *
2681
-     * @since 1.5.0
2682
-     * @param string $instance['slide_width'] Width of the slides shown.
2683
-     */
2684
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2685
-    /**
2686
-     * Filter widget's "show title" value.
2687
-     *
2688
-     * @since 1.0.0
2689
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2690
-     */
2691
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2692
-    /**
2693
-     * Filter widget's "slideshow" value.
2694
-     *
2695
-     * @since 1.0.0
2696
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2697
-     */
2698
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2699
-    /**
2700
-     * Filter widget's "animationLoop" value.
2701
-     *
2702
-     * @since 1.0.0
2703
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2704
-     */
2705
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2706
-    /**
2707
-     * Filter widget's "directionNav" value.
2708
-     *
2709
-     * @since 1.0.0
2710
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2711
-     */
2712
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2713
-    /**
2714
-     * Filter widget's "slideshowSpeed" value.
2715
-     *
2716
-     * @since 1.0.0
2717
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2718
-     */
2719
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2720
-    /**
2721
-     * Filter widget's "animationSpeed" value.
2722
-     *
2723
-     * @since 1.0.0
2724
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2725
-     */
2726
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2727
-    /**
2728
-     * Filter widget's "animation" value.
2729
-     *
2730
-     * @since 1.0.0
2731
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2732
-     */
2733
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2734
-    /**
2735
-     * Filter widget's "list_sort" type.
2736
-     *
2737
-     * @since 1.0.0
2738
-     * @param string $instance['list_sort'] Listing sort by type.
2739
-     */
2740
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2741
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2742
-
2743
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2744
-    ?>
2643
+	// prints the widget
2644
+	extract($args, EXTR_SKIP);
2645
+
2646
+	echo $before_widget;
2647
+
2648
+	/** This filter is documented in geodirectory_widgets.php */
2649
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2650
+	/**
2651
+	 * Filter the widget post type.
2652
+	 *
2653
+	 * @since 1.0.0
2654
+	 * @param string $instance['post_type'] Post type of listing.
2655
+	 */
2656
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2657
+	/**
2658
+	 * Filter the widget's term.
2659
+	 *
2660
+	 * @since 1.0.0
2661
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2662
+	 */
2663
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2664
+	/**
2665
+	 * Filter the widget listings limit.
2666
+	 *
2667
+	 * @since 1.0.0
2668
+	 * @param string $instance['post_number'] Number of listings to display.
2669
+	 */
2670
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2671
+	/**
2672
+	 * Filter the widget listings limit shown at one time.
2673
+	 *
2674
+	 * @since 1.5.0
2675
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2676
+	 */
2677
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2678
+	/**
2679
+	 * Filter the widget slide width.
2680
+	 *
2681
+	 * @since 1.5.0
2682
+	 * @param string $instance['slide_width'] Width of the slides shown.
2683
+	 */
2684
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2685
+	/**
2686
+	 * Filter widget's "show title" value.
2687
+	 *
2688
+	 * @since 1.0.0
2689
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2690
+	 */
2691
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2692
+	/**
2693
+	 * Filter widget's "slideshow" value.
2694
+	 *
2695
+	 * @since 1.0.0
2696
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2697
+	 */
2698
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2699
+	/**
2700
+	 * Filter widget's "animationLoop" value.
2701
+	 *
2702
+	 * @since 1.0.0
2703
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2704
+	 */
2705
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2706
+	/**
2707
+	 * Filter widget's "directionNav" value.
2708
+	 *
2709
+	 * @since 1.0.0
2710
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2711
+	 */
2712
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2713
+	/**
2714
+	 * Filter widget's "slideshowSpeed" value.
2715
+	 *
2716
+	 * @since 1.0.0
2717
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2718
+	 */
2719
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2720
+	/**
2721
+	 * Filter widget's "animationSpeed" value.
2722
+	 *
2723
+	 * @since 1.0.0
2724
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2725
+	 */
2726
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2727
+	/**
2728
+	 * Filter widget's "animation" value.
2729
+	 *
2730
+	 * @since 1.0.0
2731
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2732
+	 */
2733
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2734
+	/**
2735
+	 * Filter widget's "list_sort" type.
2736
+	 *
2737
+	 * @since 1.0.0
2738
+	 * @param string $instance['list_sort'] Listing sort by type.
2739
+	 */
2740
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2741
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2742
+
2743
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2744
+	?>
2745 2745
     <script type="text/javascript">
2746 2746
         jQuery(window).load(function () {
2747 2747
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2782,86 +2782,86 @@  discard block
 block discarded – undo
2782 2782
         });
2783 2783
     </script>
2784 2784
     <?php
2785
-    $query_args = array(
2786
-        'posts_per_page' => $post_number,
2787
-        'is_geodir_loop' => true,
2788
-        'post_type' => $post_type,
2789
-        'order_by' => $list_sort
2790
-    );
2791
-    if ($show_featured_only) {
2792
-        $query_args['show_featured_only'] = 1;
2793
-    }
2794
-
2795
-    if ($category != 0 || $category != '') {
2796
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2797
-        $tax_query = array(
2798
-            'taxonomy' => $category_taxonomy[0],
2799
-            'field' => 'id',
2800
-            'terms' => $category
2801
-        );
2802
-
2803
-        $query_args['tax_query'] = array($tax_query);
2804
-    }
2805
-
2806
-    // we want listings with featured image only
2807
-    $query_args['featured_image_only'] = 1;
2808
-
2809
-    if ($post_type == 'gd_event') {
2810
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2811
-    }// show only upcoming events
2812
-
2813
-    $widget_listings = geodir_get_widget_listings($query_args);
2814
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2815
-        if ($title) {
2816
-            echo $before_title . $title . $after_title;
2817
-        }
2818
-
2819
-        global $post;
2820
-
2821
-        $current_post = $post;// keep current post info
2822
-
2823
-        $widget_main_slides = '';
2824
-        $nav_slides = '';
2825
-        $widget_slides = 0;
2826
-
2827
-        foreach ($widget_listings as $widget_listing) {
2828
-            global $gd_widget_listing_type;
2829
-            $post = $widget_listing;
2830
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2831
-
2832
-            if (!empty($widget_image)) {
2833
-                if ($widget_image->height >= 200) {
2834
-                    $widget_spacer_height = 0;
2835
-                } else {
2836
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2837
-                }
2838
-
2839
-                $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" />';
2840
-
2841
-                $title = '';
2842
-                if ($show_title) {
2843
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2844
-                    $post_id = $post->ID;
2845
-                    $post_permalink = get_permalink($post->ID);
2846
-                    $post_title = get_the_title($post->ID);
2847
-                    /**
2848
-                     * Filter the listing slider widget title.
2849
-                     *
2850
-                     * @since 1.6.1
2851
-                     * @param string $title_html The html output of the title.
2852
-                     * @param int $post_id The post id.
2853
-                     * @param string $post_permalink The post permalink url.
2854
-                     * @param string $post_title The post title text.
2855
-                     */
2856
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2857
-                }
2858
-
2859
-                $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>';
2860
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2861
-                $widget_slides++;
2862
-            }
2863
-        }
2864
-        ?>
2785
+	$query_args = array(
2786
+		'posts_per_page' => $post_number,
2787
+		'is_geodir_loop' => true,
2788
+		'post_type' => $post_type,
2789
+		'order_by' => $list_sort
2790
+	);
2791
+	if ($show_featured_only) {
2792
+		$query_args['show_featured_only'] = 1;
2793
+	}
2794
+
2795
+	if ($category != 0 || $category != '') {
2796
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2797
+		$tax_query = array(
2798
+			'taxonomy' => $category_taxonomy[0],
2799
+			'field' => 'id',
2800
+			'terms' => $category
2801
+		);
2802
+
2803
+		$query_args['tax_query'] = array($tax_query);
2804
+	}
2805
+
2806
+	// we want listings with featured image only
2807
+	$query_args['featured_image_only'] = 1;
2808
+
2809
+	if ($post_type == 'gd_event') {
2810
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2811
+	}// show only upcoming events
2812
+
2813
+	$widget_listings = geodir_get_widget_listings($query_args);
2814
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2815
+		if ($title) {
2816
+			echo $before_title . $title . $after_title;
2817
+		}
2818
+
2819
+		global $post;
2820
+
2821
+		$current_post = $post;// keep current post info
2822
+
2823
+		$widget_main_slides = '';
2824
+		$nav_slides = '';
2825
+		$widget_slides = 0;
2826
+
2827
+		foreach ($widget_listings as $widget_listing) {
2828
+			global $gd_widget_listing_type;
2829
+			$post = $widget_listing;
2830
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2831
+
2832
+			if (!empty($widget_image)) {
2833
+				if ($widget_image->height >= 200) {
2834
+					$widget_spacer_height = 0;
2835
+				} else {
2836
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2837
+				}
2838
+
2839
+				$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" />';
2840
+
2841
+				$title = '';
2842
+				if ($show_title) {
2843
+					$title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2844
+					$post_id = $post->ID;
2845
+					$post_permalink = get_permalink($post->ID);
2846
+					$post_title = get_the_title($post->ID);
2847
+					/**
2848
+					 * Filter the listing slider widget title.
2849
+					 *
2850
+					 * @since 1.6.1
2851
+					 * @param string $title_html The html output of the title.
2852
+					 * @param int $post_id The post id.
2853
+					 * @param string $post_permalink The post permalink url.
2854
+					 * @param string $post_title The post title text.
2855
+					 */
2856
+					$title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2857
+				}
2858
+
2859
+				$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>';
2860
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2861
+				$widget_slides++;
2862
+			}
2863
+		}
2864
+		?>
2865 2865
         <div class="flex-container" style="min-height:200px;">
2866 2866
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2867 2867
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2874,10 +2874,10 @@  discard block
 block discarded – undo
2874 2874
             <?php } ?>
2875 2875
         </div>
2876 2876
         <?php
2877
-        $GLOBALS['post'] = $current_post;
2878
-        setup_postdata($current_post);
2879
-    }
2880
-    echo $after_widget;
2877
+		$GLOBALS['post'] = $current_post;
2878
+		setup_postdata($current_post);
2879
+	}
2880
+	echo $after_widget;
2881 2881
 }
2882 2882
 
2883 2883
 
@@ -2892,65 +2892,65 @@  discard block
 block discarded – undo
2892 2892
  */
2893 2893
 function geodir_loginwidget_output($args = '', $instance = '')
2894 2894
 {
2895
-    //print_r($args);
2896
-    //print_r($instance);
2897
-    // prints the widget
2898
-    extract($args, EXTR_SKIP);
2895
+	//print_r($args);
2896
+	//print_r($instance);
2897
+	// prints the widget
2898
+	extract($args, EXTR_SKIP);
2899 2899
 
2900
-    /** This filter is documented in geodirectory_widgets.php */
2901
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2900
+	/** This filter is documented in geodirectory_widgets.php */
2901
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2902 2902
 
2903
-    echo $before_widget;
2904
-    echo $before_title . $title . $after_title;
2903
+	echo $before_widget;
2904
+	echo $before_title . $title . $after_title;
2905 2905
 
2906
-    if (is_user_logged_in()) {
2907
-        global $current_user;
2906
+	if (is_user_logged_in()) {
2907
+		global $current_user;
2908 2908
 
2909
-        $author_link = get_author_posts_url($current_user->data->ID);
2910
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2909
+		$author_link = get_author_posts_url($current_user->data->ID);
2910
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2911 2911
 
2912
-        echo '<ul class="geodir-loginbox-list">';
2913
-        ob_start();
2914
-        ?>
2912
+		echo '<ul class="geodir-loginbox-list">';
2913
+		ob_start();
2914
+		?>
2915 2915
         <li><a class="signin"
2916 2916
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2917 2917
         <?php
2918
-        $post_types = geodir_get_posttypes('object');
2919
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2920
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2918
+		$post_types = geodir_get_posttypes('object');
2919
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2920
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2921 2921
 
2922
-        if (!empty($show_add_listing_post_types_main_nav)) {
2923
-            $addlisting_links = '';
2924
-            foreach ($post_types as $key => $postobj) {
2922
+		if (!empty($show_add_listing_post_types_main_nav)) {
2923
+			$addlisting_links = '';
2924
+			foreach ($post_types as $key => $postobj) {
2925 2925
 
2926
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2926
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2927 2927
 
2928
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2928
+					if ($add_link = geodir_get_addlisting_link($key)) {
2929 2929
 
2930
-                        $name = $postobj->labels->name;
2930
+						$name = $postobj->labels->name;
2931 2931
 
2932
-                        $selected = '';
2933
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2934
-                            $selected = 'selected="selected"';
2932
+						$selected = '';
2933
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2934
+							$selected = 'selected="selected"';
2935 2935
 
2936
-                        /**
2937
-                         * Filter add listing link.
2938
-                         *
2939
-                         * @since 1.0.0
2940
-                         * @param string $add_link Add listing link.
2941
-                         * @param string $key Add listing array key.
2942
-                         * @param int $current_user->ID Current user ID.
2943
-                         */
2944
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2936
+						/**
2937
+						 * Filter add listing link.
2938
+						 *
2939
+						 * @since 1.0.0
2940
+						 * @param string $add_link Add listing link.
2941
+						 * @param string $key Add listing array key.
2942
+						 * @param int $current_user->ID Current user ID.
2943
+						 */
2944
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2945 2945
 
2946
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2946
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2947 2947
 
2948
-                    }
2949
-                }
2948
+					}
2949
+				}
2950 2950
 
2951
-            }
2951
+			}
2952 2952
 
2953
-            if ($addlisting_links != '') { ?>
2953
+			if ($addlisting_links != '') { ?>
2954 2954
 
2955 2955
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2956 2956
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2959,42 +2959,42 @@  discard block
 block discarded – undo
2959 2959
                         <?php echo $addlisting_links; ?>
2960 2960
                     </select></li> <?php
2961 2961
 
2962
-            }
2963
-
2964
-        }
2965
-        // My Favourites in Dashboard
2966
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2967
-        $user_favourite = geodir_user_favourite_listing_count();
2968
-
2969
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2970
-            $favourite_links = '';
2971
-
2972
-            foreach ($post_types as $key => $postobj) {
2973
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2974
-                    $name = $postobj->labels->name;
2975
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2976
-
2977
-                    $selected = '';
2978
-
2979
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2980
-                        $selected = 'selected="selected"';
2981
-                    }
2982
-                    /**
2983
-                     * Filter favorite listing link.
2984
-                     *
2985
-                     * @since 1.0.0
2986
-                     * @param string $post_type_link Favorite listing link.
2987
-                     * @param string $key Favorite listing array key.
2988
-                     * @param int $current_user->ID Current user ID.
2989
-                     */
2990
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2991
-
2992
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2993
-                }
2994
-            }
2995
-
2996
-            if ($favourite_links != '') {
2997
-                ?>
2962
+			}
2963
+
2964
+		}
2965
+		// My Favourites in Dashboard
2966
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2967
+		$user_favourite = geodir_user_favourite_listing_count();
2968
+
2969
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2970
+			$favourite_links = '';
2971
+
2972
+			foreach ($post_types as $key => $postobj) {
2973
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2974
+					$name = $postobj->labels->name;
2975
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2976
+
2977
+					$selected = '';
2978
+
2979
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2980
+						$selected = 'selected="selected"';
2981
+					}
2982
+					/**
2983
+					 * Filter favorite listing link.
2984
+					 *
2985
+					 * @since 1.0.0
2986
+					 * @param string $post_type_link Favorite listing link.
2987
+					 * @param string $key Favorite listing array key.
2988
+					 * @param int $current_user->ID Current user ID.
2989
+					 */
2990
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2991
+
2992
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2993
+				}
2994
+			}
2995
+
2996
+			if ($favourite_links != '') {
2997
+				?>
2998 2998
                 <li>
2999 2999
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
3000 3000
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -3004,42 +3004,42 @@  discard block
 block discarded – undo
3004 3004
                     </select>
3005 3005
                 </li>
3006 3006
             <?php
3007
-            }
3008
-        }
3009
-
3010
-
3011
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3012
-        $user_listing = geodir_user_post_listing_count();
3013
-
3014
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3015
-            $listing_links = '';
3016
-
3017
-            foreach ($post_types as $key => $postobj) {
3018
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3019
-                    $name = $postobj->labels->name;
3020
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
3021
-
3022
-                    $selected = '';
3023
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3024
-                        $selected = 'selected="selected"';
3025
-                    }
3026
-
3027
-                    /**
3028
-                     * Filter my listing link.
3029
-                     *
3030
-                     * @since 1.0.0
3031
-                     * @param string $listing_link My listing link.
3032
-                     * @param string $key My listing array key.
3033
-                     * @param int $current_user->ID Current user ID.
3034
-                     */
3035
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3036
-
3037
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3038
-                }
3039
-            }
3040
-
3041
-            if ($listing_links != '') {
3042
-                ?>
3007
+			}
3008
+		}
3009
+
3010
+
3011
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3012
+		$user_listing = geodir_user_post_listing_count();
3013
+
3014
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3015
+			$listing_links = '';
3016
+
3017
+			foreach ($post_types as $key => $postobj) {
3018
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3019
+					$name = $postobj->labels->name;
3020
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
3021
+
3022
+					$selected = '';
3023
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3024
+						$selected = 'selected="selected"';
3025
+					}
3026
+
3027
+					/**
3028
+					 * Filter my listing link.
3029
+					 *
3030
+					 * @since 1.0.0
3031
+					 * @param string $listing_link My listing link.
3032
+					 * @param string $key My listing array key.
3033
+					 * @param int $current_user->ID Current user ID.
3034
+					 */
3035
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3036
+
3037
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3038
+				}
3039
+			}
3040
+
3041
+			if ($listing_links != '') {
3042
+				?>
3043 3043
                 <li>
3044 3044
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
3045 3045
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -3049,27 +3049,27 @@  discard block
 block discarded – undo
3049 3049
                     </select>
3050 3050
                 </li>
3051 3051
             <?php
3052
-            }
3053
-        }
3054
-
3055
-        $dashboard_link = ob_get_clean();
3056
-        /**
3057
-         * Filter dashboard links HTML.
3058
-         *
3059
-         * @since 1.0.0
3060
-         * @param string $dashboard_link Dashboard links HTML.
3061
-         */
3062
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
3063
-        echo '</ul>';
3064
-    } else {
3065
-        ?>
3052
+			}
3053
+		}
3054
+
3055
+		$dashboard_link = ob_get_clean();
3056
+		/**
3057
+		 * Filter dashboard links HTML.
3058
+		 *
3059
+		 * @since 1.0.0
3060
+		 * @param string $dashboard_link Dashboard links HTML.
3061
+		 */
3062
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
3063
+		echo '</ul>';
3064
+	} else {
3065
+		?>
3066 3066
         <?php
3067
-        /**
3068
-         * Filter signup form action link.
3069
-         *
3070
-         * @since 1.0.0
3071
-         */
3072
-        ?>
3067
+		/**
3068
+		 * Filter signup form action link.
3069
+		 *
3070
+		 * @since 1.0.0
3071
+		 */
3072
+		?>
3073 3073
         <form name="loginform" class="loginform1"
3074 3074
               action="<?php echo geodir_login_url(); ?>"
3075 3075
               method="post">
@@ -3089,28 +3089,28 @@  discard block
 block discarded – undo
3089 3089
 
3090 3090
                 <p class="geodir-new-forgot-link">
3091 3091
                     <?php
3092
-                    /**
3093
-                     * Filter signup page register form link.
3094
-                     *
3095
-                     * @since 1.0.0
3096
-                     */
3097
-                    ?>
3092
+					/**
3093
+					 * Filter signup page register form link.
3094
+					 *
3095
+					 * @since 1.0.0
3096
+					 */
3097
+					?>
3098 3098
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
3099 3099
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
3100 3100
 
3101 3101
                     <?php
3102
-                    /**
3103
-                     * Filter signup page forgot password form link.
3104
-                     *
3105
-                     * @since 1.0.0
3106
-                     */
3107
-                    ?>
3102
+					/**
3103
+					 * Filter signup page forgot password form link.
3104
+					 *
3105
+					 * @since 1.0.0
3106
+					 */
3107
+					?>
3108 3108
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
3109 3109
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
3110 3110
         </form>
3111 3111
     <?php }
3112 3112
 
3113
-    echo $after_widget;
3113
+	echo $after_widget;
3114 3114
 }
3115 3115
 
3116 3116
 
@@ -3129,284 +3129,284 @@  discard block
 block discarded – undo
3129 3129
  * @param array|string $instance The settings for the particular instance of the widget.
3130 3130
  */
3131 3131
 function geodir_popular_postview_output($args = '', $instance = '') {
3132
-    global $gd_session;
3132
+	global $gd_session;
3133 3133
 	
3134
-    // prints the widget
3135
-    extract($args, EXTR_SKIP);
3136
-
3137
-    echo $before_widget;
3138
-
3139
-    /** This filter is documented in geodirectory_widgets.php */
3140
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3141
-    /**
3142
-     * Filter the widget post type.
3143
-     *
3144
-     * @since 1.0.0
3145
-     * @param string $instance['post_type'] Post type of listing.
3146
-     */
3147
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3148
-    /**
3149
-     * Filter the widget's term.
3150
-     *
3151
-     * @since 1.0.0
3152
-     * @param string $instance['category'] Filter by term. Can be any valid term.
3153
-     */
3154
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3155
-    /**
3156
-     * Filter the widget listings limit.
3157
-     *
3158
-     * @since 1.0.0
3159
-     * @param string $instance['post_number'] Number of listings to display.
3160
-     */
3161
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3162
-    /**
3163
-     * Filter widget's "layout" type.
3164
-     *
3165
-     * @since 1.0.0
3166
-     * @param string $instance['layout'] Widget layout type.
3167
-     */
3168
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3169
-    /**
3170
-     * Filter widget's "add_location_filter" value.
3171
-     *
3172
-     * @since 1.0.0
3173
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3174
-     */
3175
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3176
-    /**
3177
-     * Filter widget's listing width.
3178
-     *
3179
-     * @since 1.0.0
3180
-     * @param string $instance['listing_width'] Listing width.
3181
-     */
3182
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3183
-    /**
3184
-     * Filter widget's "list_sort" type.
3185
-     *
3186
-     * @since 1.0.0
3187
-     * @param string $instance['list_sort'] Listing sort by type.
3188
-     */
3189
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3190
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3191
-
3192
-    // set post type to current viewing post type
3193
-    if ($use_viewing_post_type) {
3194
-        $current_post_type = geodir_get_current_posttype();
3195
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3196
-            $post_type = $current_post_type;
3197
-            $category = array(); // old post type category will not work for current changed post type
3198
-        }
3199
-    }
3200
-    // replace widget title dynamically
3201
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3202
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3203
-
3204
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3205
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3206
-
3207
-    if (isset($instance['character_count'])) {
3208
-        /**
3209
-         * Filter the widget's excerpt character count.
3210
-         *
3211
-         * @since 1.0.0
3212
-         * @param int $instance['character_count'] Excerpt character count.
3213
-         */
3214
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3215
-    } else {
3216
-        $character_count = '';
3217
-    }
3218
-
3219
-    if (empty($title) || $title == 'All') {
3220
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3221
-    }
3222
-
3223
-    $location_url = array();
3224
-    $city = get_query_var('gd_city');
3225
-    if (!empty($city)) {
3226
-        $country = get_query_var('gd_country');
3227
-        $region = get_query_var('gd_region');
3228
-
3229
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3230
-
3231
-        if ($geodir_show_location_url == 'all') {
3232
-            if ($country != '') {
3233
-                $location_url[] = $country;
3234
-            }
3235
-
3236
-            if ($region != '') {
3237
-                $location_url[] = $region;
3238
-            }
3239
-        } else if ($geodir_show_location_url == 'country_city') {
3240
-            if ($country != '') {
3241
-                $location_url[] = $country;
3242
-            }
3243
-        } else if ($geodir_show_location_url == 'region_city') {
3244
-            if ($region != '') {
3245
-                $location_url[] = $region;
3246
-            }
3247
-        }
3248
-
3249
-        $location_url[] = $city;
3250
-    }
3251
-
3252
-    $location_url = implode('/', $location_url);
3253
-    $skip_location = false;
3254
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3255
-        $skip_location = true;
3256
-        $gd_session->un_set('gd_multi_location');
3257
-    }
3258
-
3259
-    if (get_option('permalink_structure')) {
3260
-        $viewall_url = get_post_type_archive_link($post_type);
3261
-    } else {
3262
-        $viewall_url = get_post_type_archive_link($post_type);
3263
-    }
3264
-
3265
-    if (!empty($category) && $category[0] != '0') {
3266
-        global $geodir_add_location_url;
3267
-
3268
-        $geodir_add_location_url = '0';
3269
-
3270
-        if ($add_location_filter != '0') {
3271
-            $geodir_add_location_url = '1';
3272
-        }
3273
-
3274
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3275
-
3276
-        $geodir_add_location_url = NULL;
3277
-    }
3278
-    if ($skip_location) {
3279
-        $gd_session->set('gd_multi_location', 1);
3280
-    }
3281
-
3282
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3283
-
3284
-    $query_args = array(
3285
-        'posts_per_page' => $post_number,
3286
-        'is_geodir_loop' => true,
3287
-        'gd_location' => $add_location_filter ? true : false,
3288
-        'post_type' => $post_type,
3289
-        'order_by' => $list_sort
3290
-    );
3291
-
3292
-    if ($character_count) {
3293
-        $query_args['excerpt_length'] = $character_count;
3294
-    }
3295
-
3296
-    if (!empty($instance['show_featured_only'])) {
3297
-        $query_args['show_featured_only'] = 1;
3298
-    }
3299
-
3300
-    if (!empty($instance['show_special_only'])) {
3301
-        $query_args['show_special_only'] = 1;
3302
-    }
3303
-
3304
-    if (!empty($instance['with_pics_only'])) {
3305
-        $query_args['with_pics_only'] = 0;
3306
-        $query_args['featured_image_only'] = 1;
3307
-    }
3308
-
3309
-    if (!empty($instance['with_videos_only'])) {
3310
-        $query_args['with_videos_only'] = 1;
3311
-    }
3312
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3313
-
3314
-    if (!empty($category) && $category[0] != '0') {
3315
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3316
-
3317
-        ######### WPML #########
3318
-        if (function_exists('icl_object_id')) {
3319
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3320
-        }
3321
-        ######### WPML #########
3322
-
3323
-        $tax_query = array(
3324
-            'taxonomy' => $category_taxonomy[0],
3325
-            'field' => 'id',
3326
-            'terms' => $category
3327
-        );
3328
-
3329
-        $query_args['tax_query'] = array($tax_query);
3330
-    }
3331
-
3332
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3333
-
3334
-    $widget_listings = geodir_get_widget_listings($query_args);
3335
-
3336
-    if (!empty($widget_listings) || $with_no_results) {
3337
-        ?>
3134
+	// prints the widget
3135
+	extract($args, EXTR_SKIP);
3136
+
3137
+	echo $before_widget;
3138
+
3139
+	/** This filter is documented in geodirectory_widgets.php */
3140
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3141
+	/**
3142
+	 * Filter the widget post type.
3143
+	 *
3144
+	 * @since 1.0.0
3145
+	 * @param string $instance['post_type'] Post type of listing.
3146
+	 */
3147
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3148
+	/**
3149
+	 * Filter the widget's term.
3150
+	 *
3151
+	 * @since 1.0.0
3152
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
3153
+	 */
3154
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3155
+	/**
3156
+	 * Filter the widget listings limit.
3157
+	 *
3158
+	 * @since 1.0.0
3159
+	 * @param string $instance['post_number'] Number of listings to display.
3160
+	 */
3161
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3162
+	/**
3163
+	 * Filter widget's "layout" type.
3164
+	 *
3165
+	 * @since 1.0.0
3166
+	 * @param string $instance['layout'] Widget layout type.
3167
+	 */
3168
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3169
+	/**
3170
+	 * Filter widget's "add_location_filter" value.
3171
+	 *
3172
+	 * @since 1.0.0
3173
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3174
+	 */
3175
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3176
+	/**
3177
+	 * Filter widget's listing width.
3178
+	 *
3179
+	 * @since 1.0.0
3180
+	 * @param string $instance['listing_width'] Listing width.
3181
+	 */
3182
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3183
+	/**
3184
+	 * Filter widget's "list_sort" type.
3185
+	 *
3186
+	 * @since 1.0.0
3187
+	 * @param string $instance['list_sort'] Listing sort by type.
3188
+	 */
3189
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3190
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3191
+
3192
+	// set post type to current viewing post type
3193
+	if ($use_viewing_post_type) {
3194
+		$current_post_type = geodir_get_current_posttype();
3195
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3196
+			$post_type = $current_post_type;
3197
+			$category = array(); // old post type category will not work for current changed post type
3198
+		}
3199
+	}
3200
+	// replace widget title dynamically
3201
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3202
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3203
+
3204
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3205
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3206
+
3207
+	if (isset($instance['character_count'])) {
3208
+		/**
3209
+		 * Filter the widget's excerpt character count.
3210
+		 *
3211
+		 * @since 1.0.0
3212
+		 * @param int $instance['character_count'] Excerpt character count.
3213
+		 */
3214
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3215
+	} else {
3216
+		$character_count = '';
3217
+	}
3218
+
3219
+	if (empty($title) || $title == 'All') {
3220
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3221
+	}
3222
+
3223
+	$location_url = array();
3224
+	$city = get_query_var('gd_city');
3225
+	if (!empty($city)) {
3226
+		$country = get_query_var('gd_country');
3227
+		$region = get_query_var('gd_region');
3228
+
3229
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3230
+
3231
+		if ($geodir_show_location_url == 'all') {
3232
+			if ($country != '') {
3233
+				$location_url[] = $country;
3234
+			}
3235
+
3236
+			if ($region != '') {
3237
+				$location_url[] = $region;
3238
+			}
3239
+		} else if ($geodir_show_location_url == 'country_city') {
3240
+			if ($country != '') {
3241
+				$location_url[] = $country;
3242
+			}
3243
+		} else if ($geodir_show_location_url == 'region_city') {
3244
+			if ($region != '') {
3245
+				$location_url[] = $region;
3246
+			}
3247
+		}
3248
+
3249
+		$location_url[] = $city;
3250
+	}
3251
+
3252
+	$location_url = implode('/', $location_url);
3253
+	$skip_location = false;
3254
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3255
+		$skip_location = true;
3256
+		$gd_session->un_set('gd_multi_location');
3257
+	}
3258
+
3259
+	if (get_option('permalink_structure')) {
3260
+		$viewall_url = get_post_type_archive_link($post_type);
3261
+	} else {
3262
+		$viewall_url = get_post_type_archive_link($post_type);
3263
+	}
3264
+
3265
+	if (!empty($category) && $category[0] != '0') {
3266
+		global $geodir_add_location_url;
3267
+
3268
+		$geodir_add_location_url = '0';
3269
+
3270
+		if ($add_location_filter != '0') {
3271
+			$geodir_add_location_url = '1';
3272
+		}
3273
+
3274
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3275
+
3276
+		$geodir_add_location_url = NULL;
3277
+	}
3278
+	if ($skip_location) {
3279
+		$gd_session->set('gd_multi_location', 1);
3280
+	}
3281
+
3282
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3283
+
3284
+	$query_args = array(
3285
+		'posts_per_page' => $post_number,
3286
+		'is_geodir_loop' => true,
3287
+		'gd_location' => $add_location_filter ? true : false,
3288
+		'post_type' => $post_type,
3289
+		'order_by' => $list_sort
3290
+	);
3291
+
3292
+	if ($character_count) {
3293
+		$query_args['excerpt_length'] = $character_count;
3294
+	}
3295
+
3296
+	if (!empty($instance['show_featured_only'])) {
3297
+		$query_args['show_featured_only'] = 1;
3298
+	}
3299
+
3300
+	if (!empty($instance['show_special_only'])) {
3301
+		$query_args['show_special_only'] = 1;
3302
+	}
3303
+
3304
+	if (!empty($instance['with_pics_only'])) {
3305
+		$query_args['with_pics_only'] = 0;
3306
+		$query_args['featured_image_only'] = 1;
3307
+	}
3308
+
3309
+	if (!empty($instance['with_videos_only'])) {
3310
+		$query_args['with_videos_only'] = 1;
3311
+	}
3312
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3313
+
3314
+	if (!empty($category) && $category[0] != '0') {
3315
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3316
+
3317
+		######### WPML #########
3318
+		if (function_exists('icl_object_id')) {
3319
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3320
+		}
3321
+		######### WPML #########
3322
+
3323
+		$tax_query = array(
3324
+			'taxonomy' => $category_taxonomy[0],
3325
+			'field' => 'id',
3326
+			'terms' => $category
3327
+		);
3328
+
3329
+		$query_args['tax_query'] = array($tax_query);
3330
+	}
3331
+
3332
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3333
+
3334
+	$widget_listings = geodir_get_widget_listings($query_args);
3335
+
3336
+	if (!empty($widget_listings) || $with_no_results) {
3337
+		?>
3338 3338
         <div class="geodir_locations geodir_location_listing">
3339 3339
 
3340 3340
             <?php
3341
-            /**
3342
-             * Called before the div containing the title and view all link in popular post view widget.
3343
-             *
3344
-             * @since 1.0.0
3345
-             */
3346
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3341
+			/**
3342
+			 * Called before the div containing the title and view all link in popular post view widget.
3343
+			 *
3344
+			 * @since 1.0.0
3345
+			 */
3346
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3347 3347
             <div class="geodir_list_heading clearfix">
3348 3348
                 <?php echo $before_title . $title . $after_title; ?>
3349 3349
                 <a href="<?php echo $viewall_url; ?>"
3350 3350
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3351 3351
             </div>
3352 3352
             <?php
3353
-            /**
3354
-             * Called after the div containing the title and view all link in popular post view widget.
3355
-             *
3356
-             * @since 1.0.0
3357
-             */
3358
-            do_action('geodir_after_view_all_link_in_widget'); ?>
3353
+			/**
3354
+			 * Called after the div containing the title and view all link in popular post view widget.
3355
+			 *
3356
+			 * @since 1.0.0
3357
+			 */
3358
+			do_action('geodir_after_view_all_link_in_widget'); ?>
3359 3359
             <?php
3360
-            if (strstr($layout, 'gridview')) {
3361
-                $listing_view_exp = explode('_', $layout);
3362
-                $gridview_columns_widget = $layout;
3363
-                $layout = $listing_view_exp[0];
3364
-            } else {
3365
-                $gridview_columns_widget = '';
3366
-            }
3367
-
3368
-            /**
3369
-             * Filter the widget listing listview template path.
3370
-             *
3371
-             * @since 1.0.0
3372
-             */
3373
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3374
-            if (!isset($character_count)) {
3375
-                /**
3376
-                 * Filter the widget's excerpt character count.
3377
-                 *
3378
-                 * @since 1.0.0
3379
-                 * @param int $instance['character_count'] Excerpt character count.
3380
-                 */
3381
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3382
-            }
3383
-
3384
-            global $post, $map_jason, $map_canvas_arr;
3385
-
3386
-            $current_post = $post;
3387
-            $current_map_jason = $map_jason;
3388
-            $current_map_canvas_arr = $map_canvas_arr;
3389
-            $geodir_is_widget_listing = true;
3390
-
3391
-            /**
3392
-             * Includes related listing listview template.
3393
-             *
3394
-             * @since 1.0.0
3395
-             */
3396
-            include($template);
3397
-
3398
-            $geodir_is_widget_listing = false;
3399
-
3400
-            $GLOBALS['post'] = $current_post;
3401
-            if (!empty($current_post))
3402
-                setup_postdata($current_post);
3403
-            $map_jason = $current_map_jason;
3404
-            $map_canvas_arr = $current_map_canvas_arr;
3405
-            ?>
3360
+			if (strstr($layout, 'gridview')) {
3361
+				$listing_view_exp = explode('_', $layout);
3362
+				$gridview_columns_widget = $layout;
3363
+				$layout = $listing_view_exp[0];
3364
+			} else {
3365
+				$gridview_columns_widget = '';
3366
+			}
3367
+
3368
+			/**
3369
+			 * Filter the widget listing listview template path.
3370
+			 *
3371
+			 * @since 1.0.0
3372
+			 */
3373
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3374
+			if (!isset($character_count)) {
3375
+				/**
3376
+				 * Filter the widget's excerpt character count.
3377
+				 *
3378
+				 * @since 1.0.0
3379
+				 * @param int $instance['character_count'] Excerpt character count.
3380
+				 */
3381
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3382
+			}
3383
+
3384
+			global $post, $map_jason, $map_canvas_arr;
3385
+
3386
+			$current_post = $post;
3387
+			$current_map_jason = $map_jason;
3388
+			$current_map_canvas_arr = $map_canvas_arr;
3389
+			$geodir_is_widget_listing = true;
3390
+
3391
+			/**
3392
+			 * Includes related listing listview template.
3393
+			 *
3394
+			 * @since 1.0.0
3395
+			 */
3396
+			include($template);
3397
+
3398
+			$geodir_is_widget_listing = false;
3399
+
3400
+			$GLOBALS['post'] = $current_post;
3401
+			if (!empty($current_post))
3402
+				setup_postdata($current_post);
3403
+			$map_jason = $current_map_jason;
3404
+			$map_canvas_arr = $current_map_canvas_arr;
3405
+			?>
3406 3406
         </div>
3407 3407
     <?php
3408
-    }
3409
-    echo $after_widget;
3408
+	}
3409
+	echo $after_widget;
3410 3410
 
3411 3411
 }
3412 3412
 
@@ -3429,26 +3429,26 @@  discard block
 block discarded – undo
3429 3429
  */
3430 3430
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3431 3431
 {
3432
-    global $wpdb, $plugin_prefix;
3432
+	global $wpdb, $plugin_prefix;
3433 3433
 
3434
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3434
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3435 3435
 
3436
-    $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 . ")";
3436
+	$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 . ")";
3437 3437
 
3438
-    /**
3439
-     * Filter count review sql query.
3440
-     *
3441
-     * @since 1.5.1
3442
-     * @param string $sql Database sql query..
3443
-     * @param int $term_id The term ID.
3444
-     * @param int $taxonomy The taxonomy Id.
3445
-     * @param string $post_type The post type.
3446
-     */
3447
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3438
+	/**
3439
+	 * Filter count review sql query.
3440
+	 *
3441
+	 * @since 1.5.1
3442
+	 * @param string $sql Database sql query..
3443
+	 * @param int $term_id The term ID.
3444
+	 * @param int $taxonomy The taxonomy Id.
3445
+	 * @param string $post_type The post type.
3446
+	 */
3447
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3448 3448
 
3449
-    $count = $wpdb->get_var($sql);
3449
+	$count = $wpdb->get_var($sql);
3450 3450
 
3451
-    return $count;
3451
+	return $count;
3452 3452
 }
3453 3453
 
3454 3454
 /**
@@ -3464,90 +3464,90 @@  discard block
 block discarded – undo
3464 3464
  * @return array Term array data.
3465 3465
  */
3466 3466
 function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
3467
-    /**
3468
-     * Filter review count option data.
3469
-     *
3470
-     * @since 1.0.0
3471
-     * @since 1.6.1 Added $post_ID param.
3472
-     * @param bool $force_update Force update option value?. Default.false.
3473
-     * @param int $post_ID The post id to update if any.
3474
-     */
3475
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3476
-    if (!empty($option_data)) {
3477
-        return $option_data;
3478
-    }
3479
-
3480
-    $option_data = get_option('geodir_global_review_count');
3481
-
3482
-    if (!$option_data || $force_update) {
3483
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3484
-            global $gd_session;
3485
-            $term_array = (array)$option_data;
3486
-            $post_type = get_post_type($post_ID);
3487
-            $taxonomy = $post_type . 'category';
3488
-            $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3489
-
3490
-            if (!empty($terms) && !is_wp_error($terms)) {
3491
-                foreach ($terms as $term_id) {
3492
-                    $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3493
-                    $children = get_term_children($term_id, $taxonomy);
3494
-                    $term_array[$term_id] = $count;
3495
-                }
3496
-            }
3467
+	/**
3468
+	 * Filter review count option data.
3469
+	 *
3470
+	 * @since 1.0.0
3471
+	 * @since 1.6.1 Added $post_ID param.
3472
+	 * @param bool $force_update Force update option value?. Default.false.
3473
+	 * @param int $post_ID The post id to update if any.
3474
+	 */
3475
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3476
+	if (!empty($option_data)) {
3477
+		return $option_data;
3478
+	}
3479
+
3480
+	$option_data = get_option('geodir_global_review_count');
3481
+
3482
+	if (!$option_data || $force_update) {
3483
+		if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3484
+			global $gd_session;
3485
+			$term_array = (array)$option_data;
3486
+			$post_type = get_post_type($post_ID);
3487
+			$taxonomy = $post_type . 'category';
3488
+			$terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3489
+
3490
+			if (!empty($terms) && !is_wp_error($terms)) {
3491
+				foreach ($terms as $term_id) {
3492
+					$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3493
+					$children = get_term_children($term_id, $taxonomy);
3494
+					$term_array[$term_id] = $count;
3495
+				}
3496
+			}
3497 3497
             
3498
-            $session_listing = $gd_session->get('listing');
3498
+			$session_listing = $gd_session->get('listing');
3499 3499
             
3500
-            $terms = array();
3501
-            if (isset($_POST['post_category'][$taxonomy])) {
3502
-                $terms = (array)$_POST['post_category'][$taxonomy];
3503
-            } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3504
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3505
-            }
3500
+			$terms = array();
3501
+			if (isset($_POST['post_category'][$taxonomy])) {
3502
+				$terms = (array)$_POST['post_category'][$taxonomy];
3503
+			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3504
+				$terms = (array)$session_listing['post_category'][$taxonomy];
3505
+			}
3506 3506
             
3507
-            if (!empty($terms)) {
3508
-                foreach ($terms as $term_id) {
3509
-                    if ($term_id > 0) {
3510
-                        $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3511
-                        $children = get_term_children($term_id, $taxonomy);
3512
-                        $term_array[$term_id] = $count;
3513
-                    }
3514
-                }
3515
-            }
3516
-        } else { // Update reviews count for all post categories.
3517
-            $term_array = array();
3518
-            $post_types = geodir_get_posttypes();
3519
-            foreach ($post_types as $post_type) {
3520
-
3521
-                $taxonomy = geodir_get_taxonomies($post_type);
3522
-                $taxonomy = $taxonomy[0];
3523
-
3524
-                $args = array(
3525
-                    'hide_empty' => false
3526
-                );
3527
-
3528
-                $terms = get_terms($taxonomy, $args);
3529
-
3530
-                foreach ($terms as $term) {
3531
-                    $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3532
-                    $children = get_term_children($term->term_id, $taxonomy);
3533
-                    /*if ( is_array( $children ) ) {
3507
+			if (!empty($terms)) {
3508
+				foreach ($terms as $term_id) {
3509
+					if ($term_id > 0) {
3510
+						$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3511
+						$children = get_term_children($term_id, $taxonomy);
3512
+						$term_array[$term_id] = $count;
3513
+					}
3514
+				}
3515
+			}
3516
+		} else { // Update reviews count for all post categories.
3517
+			$term_array = array();
3518
+			$post_types = geodir_get_posttypes();
3519
+			foreach ($post_types as $post_type) {
3520
+
3521
+				$taxonomy = geodir_get_taxonomies($post_type);
3522
+				$taxonomy = $taxonomy[0];
3523
+
3524
+				$args = array(
3525
+					'hide_empty' => false
3526
+				);
3527
+
3528
+				$terms = get_terms($taxonomy, $args);
3529
+
3530
+				foreach ($terms as $term) {
3531
+					$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3532
+					$children = get_term_children($term->term_id, $taxonomy);
3533
+					/*if ( is_array( $children ) ) {
3534 3534
                         foreach ( $children as $child_id ) {
3535 3535
                             $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3536 3536
                             $count = $count + $child_count;
3537 3537
                         }
3538 3538
                     }*/
3539
-                    $term_array[$term->term_id] = $count;
3540
-                }
3541
-            }
3542
-        }
3543
-
3544
-        update_option('geodir_global_review_count', $term_array);
3545
-        //clear cache
3546
-        wp_cache_delete('geodir_global_review_count');
3547
-        return $term_array;
3548
-    } else {
3549
-        return $option_data;
3550
-    }
3539
+					$term_array[$term->term_id] = $count;
3540
+				}
3541
+			}
3542
+		}
3543
+
3544
+		update_option('geodir_global_review_count', $term_array);
3545
+		//clear cache
3546
+		wp_cache_delete('geodir_global_review_count');
3547
+		return $term_array;
3548
+	} else {
3549
+		return $option_data;
3550
+	}
3551 3551
 }
3552 3552
 
3553 3553
 /**
@@ -3559,38 +3559,38 @@  discard block
 block discarded – undo
3559 3559
  * @return bool
3560 3560
  */
3561 3561
 function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
3562
-    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3563
-        return; // do not run if importing listings
3564
-    }
3562
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3563
+		return; // do not run if importing listings
3564
+	}
3565 3565
     
3566
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3567
-        return;
3568
-    }
3569
-
3570
-    $post_ID = 0;
3571
-    if (!empty($post)) {
3572
-        if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3573
-            return;
3574
-        }
3566
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3567
+		return;
3568
+	}
3569
+
3570
+	$post_ID = 0;
3571
+	if (!empty($post)) {
3572
+		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3573
+			return;
3574
+		}
3575 3575
         
3576
-        if ($new_status == 'auto-draft' && $old_status == 'new') {
3577
-            return;
3578
-        }
3576
+		if ($new_status == 'auto-draft' && $old_status == 'new') {
3577
+			return;
3578
+		}
3579 3579
         
3580
-        if (!empty($post->ID)) {
3581
-            $post_ID = $post->ID;
3582
-        }
3583
-    }
3580
+		if (!empty($post->ID)) {
3581
+			$post_ID = $post->ID;
3582
+		}
3583
+	}
3584 3584
 
3585
-    if ($new_status != $old_status) {
3586
-        geodir_count_reviews_by_terms(true, $post_ID);
3587
-    }
3585
+	if ($new_status != $old_status) {
3586
+		geodir_count_reviews_by_terms(true, $post_ID);
3587
+	}
3588 3588
 
3589
-    return true;
3589
+	return true;
3590 3590
 }
3591 3591
 
3592 3592
 function geodir_term_review_count_force_update_single_post($post_id){
3593
-    geodir_count_reviews_by_terms(true, $post_id); 
3593
+	geodir_count_reviews_by_terms(true, $post_id); 
3594 3594
 }
3595 3595
 
3596 3596
 /*-----------------------------------------------------------------------------------*/
@@ -3608,15 +3608,15 @@  discard block
 block discarded – undo
3608 3608
 function geodir_count_posts_by_term($data, $term)
3609 3609
 {
3610 3610
 
3611
-    if ($data) {
3612
-        if (isset($data[$term->term_id])) {
3613
-            return $data[$term->term_id];
3614
-        } else {
3615
-            return 0;
3616
-        }
3617
-    } else {
3618
-        return $term->count;
3619
-    }
3611
+	if ($data) {
3612
+		if (isset($data[$term->term_id])) {
3613
+			return $data[$term->term_id];
3614
+		} else {
3615
+			return 0;
3616
+		}
3617
+	} else {
3618
+		return $term->count;
3619
+	}
3620 3620
 }
3621 3621
 
3622 3622
 /**
@@ -3629,8 +3629,8 @@  discard block
 block discarded – undo
3629 3629
  */
3630 3630
 function geodir_sort_terms_by_count($terms)
3631 3631
 {
3632
-    usort($terms, "geodir_sort_by_count_obj");
3633
-    return $terms;
3632
+	usort($terms, "geodir_sort_by_count_obj");
3633
+	return $terms;
3634 3634
 }
3635 3635
 
3636 3636
 /**
@@ -3643,8 +3643,8 @@  discard block
 block discarded – undo
3643 3643
  */
3644 3644
 function geodir_sort_terms_by_review_count($terms)
3645 3645
 {
3646
-    usort($terms, "geodir_sort_by_review_count_obj");
3647
-    return $terms;
3646
+	usort($terms, "geodir_sort_by_review_count_obj");
3647
+	return $terms;
3648 3648
 }
3649 3649
 
3650 3650
 /**
@@ -3658,12 +3658,12 @@  discard block
 block discarded – undo
3658 3658
  */
3659 3659
 function geodir_sort_terms($terms, $sort = 'count')
3660 3660
 {
3661
-    if ($sort == 'count') {
3662
-        return geodir_sort_terms_by_count($terms);
3663
-    }
3664
-    if ($sort == 'review_count') {
3665
-        return geodir_sort_terms_by_review_count($terms);
3666
-    }
3661
+	if ($sort == 'count') {
3662
+		return geodir_sort_terms_by_count($terms);
3663
+	}
3664
+	if ($sort == 'review_count') {
3665
+		return geodir_sort_terms_by_review_count($terms);
3666
+	}
3667 3667
 }
3668 3668
 
3669 3669
 /*-----------------------------------------------------------------------------------*/
@@ -3680,7 +3680,7 @@  discard block
 block discarded – undo
3680 3680
  */
3681 3681
 function geodir_sort_by_count($a, $b)
3682 3682
 {
3683
-    return $a['count'] < $b['count'];
3683
+	return $a['count'] < $b['count'];
3684 3684
 }
3685 3685
 
3686 3686
 /**
@@ -3694,7 +3694,7 @@  discard block
 block discarded – undo
3694 3694
  */
3695 3695
 function geodir_sort_by_count_obj($a, $b)
3696 3696
 {
3697
-    return $a->count < $b->count;
3697
+	return $a->count < $b->count;
3698 3698
 }
3699 3699
 
3700 3700
 /**
@@ -3708,7 +3708,7 @@  discard block
 block discarded – undo
3708 3708
  */
3709 3709
 function geodir_sort_by_review_count_obj($a, $b)
3710 3710
 {
3711
-    return $a->review_count < $b->review_count;
3711
+	return $a->review_count < $b->review_count;
3712 3712
 }
3713 3713
 
3714 3714
 /**
@@ -3718,43 +3718,43 @@  discard block
 block discarded – undo
3718 3718
  * @package GeoDirectory
3719 3719
  */
3720 3720
 function geodir_load_textdomain() {
3721
-    /**
3722
-     * Filter the plugin locale.
3723
-     *
3724
-     * @since 1.4.2
3725
-     * @package GeoDirectory
3726
-     */
3727
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3728
-
3729
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3730
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3731
-
3732
-    /**
3733
-     * Define language constants.
3734
-     *
3735
-     * @since 1.0.0
3736
-     */
3737
-    require_once(geodir_plugin_path() . '/language.php');
3738
-
3739
-    $language_file = geodir_plugin_path() . '/db-language.php';
3740
-
3741
-    // Load language string file if not created yet
3742
-    if (!file_exists($language_file)) {
3743
-        geodirectory_load_db_language();
3744
-    }
3745
-
3746
-    if (file_exists($language_file)) {
3747
-        /**
3748
-         * Language strings from database.
3749
-         *
3750
-         * @since 1.4.2
3751
-         */
3752
-        try {
3753
-            require_once($language_file);
3754
-        } catch(Exception $e) {
3755
-            error_log('Language Error: ' . $e->getMessage());
3756
-        }
3757
-    }
3721
+	/**
3722
+	 * Filter the plugin locale.
3723
+	 *
3724
+	 * @since 1.4.2
3725
+	 * @package GeoDirectory
3726
+	 */
3727
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3728
+
3729
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3730
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3731
+
3732
+	/**
3733
+	 * Define language constants.
3734
+	 *
3735
+	 * @since 1.0.0
3736
+	 */
3737
+	require_once(geodir_plugin_path() . '/language.php');
3738
+
3739
+	$language_file = geodir_plugin_path() . '/db-language.php';
3740
+
3741
+	// Load language string file if not created yet
3742
+	if (!file_exists($language_file)) {
3743
+		geodirectory_load_db_language();
3744
+	}
3745
+
3746
+	if (file_exists($language_file)) {
3747
+		/**
3748
+		 * Language strings from database.
3749
+		 *
3750
+		 * @since 1.4.2
3751
+		 */
3752
+		try {
3753
+			require_once($language_file);
3754
+		} catch(Exception $e) {
3755
+			error_log('Language Error: ' . $e->getMessage());
3756
+		}
3757
+	}
3758 3758
 }
3759 3759
 
3760 3760
 /**
@@ -3768,66 +3768,66 @@  discard block
 block discarded – undo
3768 3768
  * @return bool True if file created otherwise false
3769 3769
  */
3770 3770
 function geodirectory_load_db_language() {
3771
-    global $wp_filesystem;
3772
-    if( empty( $wp_filesystem ) ) {
3773
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3774
-        WP_Filesystem();
3775
-        global $wp_filesystem;
3776
-    }
3777
-
3778
-    $language_file = geodir_plugin_path() . '/db-language.php';
3779
-
3780
-    if(is_file($language_file) && !is_writable($language_file))
3781
-        return false; // Not possible to create.
3782
-
3783
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3784
-        return false; // Not possible to create.
3785
-
3786
-    $contents_strings = array();
3787
-
3788
-    /**
3789
-     * Filter the language string from database to translate via po editor
3790
-     *
3791
-     * @since 1.4.2
3792
-     *
3793
-     * @param array $contents_strings Array of strings.
3794
-     */
3795
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3796
-
3797
-    $contents_strings = array_unique($contents_strings);
3798
-
3799
-    $contents_head = array();
3800
-    $contents_head[] = "<?php";
3801
-    $contents_head[] = "/**";
3802
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3803
-    $contents_head[] = " *";
3804
-    $contents_head[] = " * @package GeoDirectory";
3805
-    $contents_head[] = " * @since 1.4.2";
3806
-    $contents_head[] = " */";
3807
-    $contents_head[] = "";
3808
-    $contents_head[] = "// Language keys";
3809
-
3810
-    $contents_foot = array();
3811
-    $contents_foot[] = "";
3812
-    $contents_foot[] = "";
3813
-
3814
-    $contents = implode(PHP_EOL, $contents_head);
3815
-
3816
-    if (!empty($contents_strings)) {
3817
-        foreach ( $contents_strings as $string ) {
3818
-            if (is_scalar($string) && $string != '') {
3819
-                $string = str_replace("'", "\'", $string);
3820
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3821
-            }
3822
-        }
3823
-    }
3824
-
3825
-    $contents .= implode(PHP_EOL, $contents_foot);
3826
-
3827
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3828
-        return false; // Failure; could not write file.
3829
-
3830
-    return true;
3771
+	global $wp_filesystem;
3772
+	if( empty( $wp_filesystem ) ) {
3773
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3774
+		WP_Filesystem();
3775
+		global $wp_filesystem;
3776
+	}
3777
+
3778
+	$language_file = geodir_plugin_path() . '/db-language.php';
3779
+
3780
+	if(is_file($language_file) && !is_writable($language_file))
3781
+		return false; // Not possible to create.
3782
+
3783
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3784
+		return false; // Not possible to create.
3785
+
3786
+	$contents_strings = array();
3787
+
3788
+	/**
3789
+	 * Filter the language string from database to translate via po editor
3790
+	 *
3791
+	 * @since 1.4.2
3792
+	 *
3793
+	 * @param array $contents_strings Array of strings.
3794
+	 */
3795
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3796
+
3797
+	$contents_strings = array_unique($contents_strings);
3798
+
3799
+	$contents_head = array();
3800
+	$contents_head[] = "<?php";
3801
+	$contents_head[] = "/**";
3802
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3803
+	$contents_head[] = " *";
3804
+	$contents_head[] = " * @package GeoDirectory";
3805
+	$contents_head[] = " * @since 1.4.2";
3806
+	$contents_head[] = " */";
3807
+	$contents_head[] = "";
3808
+	$contents_head[] = "// Language keys";
3809
+
3810
+	$contents_foot = array();
3811
+	$contents_foot[] = "";
3812
+	$contents_foot[] = "";
3813
+
3814
+	$contents = implode(PHP_EOL, $contents_head);
3815
+
3816
+	if (!empty($contents_strings)) {
3817
+		foreach ( $contents_strings as $string ) {
3818
+			if (is_scalar($string) && $string != '') {
3819
+				$string = str_replace("'", "\'", $string);
3820
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3821
+			}
3822
+		}
3823
+	}
3824
+
3825
+	$contents .= implode(PHP_EOL, $contents_foot);
3826
+
3827
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3828
+		return false; // Failure; could not write file.
3829
+
3830
+	return true;
3831 3831
 }
3832 3832
 
3833 3833
 /**
@@ -3843,31 +3843,31 @@  discard block
 block discarded – undo
3843 3843
  * @return array Translation texts.
3844 3844
  */
3845 3845
 function geodir_load_custom_field_translation($translation_texts = array()) {
3846
-    global $wpdb;
3846
+	global $wpdb;
3847 3847
 
3848
-    // Custom fields table
3849
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3850
-    $rows = $wpdb->get_results($sql);
3848
+	// Custom fields table
3849
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3850
+	$rows = $wpdb->get_results($sql);
3851 3851
 
3852
-    if (!empty($rows)) {
3853
-        foreach($rows as $row) {
3854
-            if (!empty($row->admin_title))
3855
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3852
+	if (!empty($rows)) {
3853
+		foreach($rows as $row) {
3854
+			if (!empty($row->admin_title))
3855
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3856 3856
 			
3857
-            if (!empty($row->admin_desc))
3858
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3857
+			if (!empty($row->admin_desc))
3858
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3859 3859
 
3860
-            if (!empty($row->site_title))
3861
-                $translation_texts[] = stripslashes_deep($row->site_title);
3860
+			if (!empty($row->site_title))
3861
+				$translation_texts[] = stripslashes_deep($row->site_title);
3862 3862
 
3863
-            if (!empty($row->clabels))
3864
-                $translation_texts[] = stripslashes_deep($row->clabels);
3863
+			if (!empty($row->clabels))
3864
+				$translation_texts[] = stripslashes_deep($row->clabels);
3865 3865
 
3866
-            if (!empty($row->required_msg))
3867
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3866
+			if (!empty($row->required_msg))
3867
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3868 3868
 			
3869 3869
 			if (!empty($row->default_value))
3870
-                $translation_texts[] = stripslashes_deep($row->default_value);
3870
+				$translation_texts[] = stripslashes_deep($row->default_value);
3871 3871
 			
3872 3872
 			if (!empty($row->option_values)) {
3873 3873
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3880,25 +3880,25 @@  discard block
 block discarded – undo
3880 3880
 					}
3881 3881
 				}
3882 3882
 			}
3883
-        }
3884
-    }
3883
+		}
3884
+	}
3885 3885
 	
3886
-    // Custom sorting fields table
3887
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3888
-    $rows = $wpdb->get_results($sql);
3889
-
3890
-    if (!empty($rows)) {
3891
-        foreach($rows as $row) {
3892
-            if (!empty($row->site_title))
3893
-                $translation_texts[] = stripslashes_deep($row->site_title);
3894
-
3895
-            if (!empty($row->asc_title))
3896
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3897
-
3898
-            if (!empty($row->desc_title))
3899
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3900
-        }
3901
-    }
3886
+	// Custom sorting fields table
3887
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3888
+	$rows = $wpdb->get_results($sql);
3889
+
3890
+	if (!empty($rows)) {
3891
+		foreach($rows as $row) {
3892
+			if (!empty($row->site_title))
3893
+				$translation_texts[] = stripslashes_deep($row->site_title);
3894
+
3895
+			if (!empty($row->asc_title))
3896
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3897
+
3898
+			if (!empty($row->desc_title))
3899
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3900
+		}
3901
+	}
3902 3902
 	
3903 3903
 	// Advance search filter fields table
3904 3904
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3919,9 +3919,9 @@  discard block
 block discarded – undo
3919 3919
 		}
3920 3920
 	}
3921 3921
 
3922
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3922
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3923 3923
 
3924
-    return $translation_texts;
3924
+	return $translation_texts;
3925 3925
 }
3926 3926
 
3927 3927
 /**
@@ -3933,71 +3933,71 @@  discard block
 block discarded – undo
3933 3933
  * @return array Array of mime types.
3934 3934
  */
3935 3935
 function geodir_allowed_mime_types() {
3936
-    /**
3937
-     * Filter the list of mime types and file extensions allowed for file upload.
3938
-     *
3939
-     * @since 1.4.7
3940
-     * @package GeoDirectory
3941
-     *
3942
-     * @param array $geodir_allowed_mime_types and file extensions.
3943
-     */
3944
-    return apply_filters( 'geodir_allowed_mime_types', array(
3945
-            'Image' => array( // Image formats.
3946
-                'jpg' => 'image/jpeg',
3947
-                'jpe' => 'image/jpeg',
3948
-                'jpeg' => 'image/jpeg',
3949
-                'gif' => 'image/gif',
3950
-                'png' => 'image/png',
3951
-                'bmp' => 'image/bmp',
3952
-                'ico' => 'image/x-icon',
3953
-            ),
3954
-            'Video' => array( // Video formats.
3955
-                'asf' => 'video/x-ms-asf',
3956
-                'avi' => 'video/avi',
3957
-                'flv' => 'video/x-flv',
3958
-                'mkv' => 'video/x-matroska',
3959
-                'mp4' => 'video/mp4',
3960
-                'mpeg' => 'video/mpeg',
3961
-                'mpg' => 'video/mpeg',
3962
-                'wmv' => 'video/x-ms-wmv',
3963
-                '3gp' => 'video/3gpp',
3964
-            ),
3965
-            'Audio' => array( // Audio formats.
3966
-                'ogg' => 'audio/ogg',
3967
-                'mp3' => 'audio/mpeg',
3968
-                'wav' => 'audio/wav',
3969
-                'wma' => 'audio/x-ms-wma',
3970
-            ),
3971
-            'Text' => array( // Text formats.
3972
-                'css' => 'text/css',
3973
-                'csv' => 'text/csv',
3974
-                'htm' => 'text/html',
3975
-                'html' => 'text/html',
3976
-                'txt' => 'text/plain',
3977
-                'rtx' => 'text/richtext',
3978
-                'vtt' => 'text/vtt',
3979
-            ),
3980
-            'Application' => array( // Application formats.
3981
-                'doc' => 'application/msword',
3982
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3983
-                'exe' => 'application/x-msdownload',
3984
-                'js' => 'application/javascript',
3985
-                'odt' => 'application/vnd.oasis.opendocument.text',
3986
-                'pdf' => 'application/pdf',
3987
-                'pot' => 'application/vnd.ms-powerpoint',
3988
-                'ppt' => 'application/vnd.ms-powerpoint',
3989
-                'pptx' => 'application/vnd.ms-powerpoint',
3990
-                'psd' => 'application/octet-stream',
3991
-                'rar' => 'application/rar',
3992
-                'rtf' => 'application/rtf',
3993
-                'swf' => 'application/x-shockwave-flash',
3994
-                'tar' => 'application/x-tar',
3995
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3996
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3997
-                'zip' => 'application/zip',
3998
-            )
3999
-        )
4000
-    );
3936
+	/**
3937
+	 * Filter the list of mime types and file extensions allowed for file upload.
3938
+	 *
3939
+	 * @since 1.4.7
3940
+	 * @package GeoDirectory
3941
+	 *
3942
+	 * @param array $geodir_allowed_mime_types and file extensions.
3943
+	 */
3944
+	return apply_filters( 'geodir_allowed_mime_types', array(
3945
+			'Image' => array( // Image formats.
3946
+				'jpg' => 'image/jpeg',
3947
+				'jpe' => 'image/jpeg',
3948
+				'jpeg' => 'image/jpeg',
3949
+				'gif' => 'image/gif',
3950
+				'png' => 'image/png',
3951
+				'bmp' => 'image/bmp',
3952
+				'ico' => 'image/x-icon',
3953
+			),
3954
+			'Video' => array( // Video formats.
3955
+				'asf' => 'video/x-ms-asf',
3956
+				'avi' => 'video/avi',
3957
+				'flv' => 'video/x-flv',
3958
+				'mkv' => 'video/x-matroska',
3959
+				'mp4' => 'video/mp4',
3960
+				'mpeg' => 'video/mpeg',
3961
+				'mpg' => 'video/mpeg',
3962
+				'wmv' => 'video/x-ms-wmv',
3963
+				'3gp' => 'video/3gpp',
3964
+			),
3965
+			'Audio' => array( // Audio formats.
3966
+				'ogg' => 'audio/ogg',
3967
+				'mp3' => 'audio/mpeg',
3968
+				'wav' => 'audio/wav',
3969
+				'wma' => 'audio/x-ms-wma',
3970
+			),
3971
+			'Text' => array( // Text formats.
3972
+				'css' => 'text/css',
3973
+				'csv' => 'text/csv',
3974
+				'htm' => 'text/html',
3975
+				'html' => 'text/html',
3976
+				'txt' => 'text/plain',
3977
+				'rtx' => 'text/richtext',
3978
+				'vtt' => 'text/vtt',
3979
+			),
3980
+			'Application' => array( // Application formats.
3981
+				'doc' => 'application/msword',
3982
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3983
+				'exe' => 'application/x-msdownload',
3984
+				'js' => 'application/javascript',
3985
+				'odt' => 'application/vnd.oasis.opendocument.text',
3986
+				'pdf' => 'application/pdf',
3987
+				'pot' => 'application/vnd.ms-powerpoint',
3988
+				'ppt' => 'application/vnd.ms-powerpoint',
3989
+				'pptx' => 'application/vnd.ms-powerpoint',
3990
+				'psd' => 'application/octet-stream',
3991
+				'rar' => 'application/rar',
3992
+				'rtf' => 'application/rtf',
3993
+				'swf' => 'application/x-shockwave-flash',
3994
+				'tar' => 'application/x-tar',
3995
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3996
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3997
+				'zip' => 'application/zip',
3998
+			)
3999
+		)
4000
+	);
4001 4001
 }
4002 4002
 
4003 4003
 /**
@@ -4009,21 +4009,21 @@  discard block
 block discarded – undo
4009 4009
  * @return string User display name.
4010 4010
  */
4011 4011
 function geodir_get_client_name($user_id) {
4012
-    $client_name = '';
4012
+	$client_name = '';
4013 4013
 
4014
-    $user_data = get_userdata($user_id);
4014
+	$user_data = get_userdata($user_id);
4015 4015
 
4016
-    if (!empty($user_data)) {
4017
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4018
-            $client_name = trim($user_data->display_name);
4019
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4020
-            $client_name = trim($user_data->user_nicename);
4021
-        } else {
4022
-            $client_name = trim($user_data->user_login);
4023
-        }
4024
-    }
4016
+	if (!empty($user_data)) {
4017
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4018
+			$client_name = trim($user_data->display_name);
4019
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4020
+			$client_name = trim($user_data->user_nicename);
4021
+		} else {
4022
+			$client_name = trim($user_data->user_login);
4023
+		}
4024
+	}
4025 4025
 
4026
-    return $client_name;
4026
+	return $client_name;
4027 4027
 }
4028 4028
 
4029 4029
 
@@ -4038,125 +4038,125 @@  discard block
 block discarded – undo
4038 4038
  */
4039 4039
 function geodir_wpseo_replacements($vars){
4040 4040
 
4041
-    global $wp;
4042
-    $title = '';
4043
-    // location variables
4044
-    $gd_post_type = geodir_get_current_posttype();
4045
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4046
-    /**
4047
-     * Filter the title variables location variables array
4048
-     *
4049
-     * @since 1.5.5
4050
-     * @package GeoDirectory
4051
-     * @param array $location_array The array of location variables.
4052
-     * @param array $vars The page title variables.
4053
-     */
4054
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4055
-    $location_titles = array();
4056
-    if(get_query_var( 'gd_country_full' )){
4057
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4058
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4059
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4060
-    }
4061
-    $location_single = '';
4062
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4063
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4064
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4065
-
4066
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4067
-
4068
-    if (function_exists('get_actual_location_name')) {
4069
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4070
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4071
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4072
-    }
4073
-
4074
-    if ($gd_city != '') {
4075
-        if ($gd_city_actual != '') {
4076
-            $gd_city = $gd_city_actual;
4077
-        } else {
4078
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4079
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4080
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4081
-        }
4082
-        $location_single = $gd_city;
4083
-
4084
-    } else if ($gd_region != '') {
4085
-        if ($gd_region_actual != '') {
4086
-            $gd_region = $gd_region_actual;
4087
-        } else {
4088
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4089
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4090
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4091
-        }
4092
-
4093
-        $location_single = $gd_region;
4094
-    } else if ($gd_country != '') {
4095
-        if ($gd_country_actual != '') {
4096
-            $gd_country = $gd_country_actual;
4097
-        } else {
4098
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4099
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4100
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4101
-        }
4102
-
4103
-        $location_single = $gd_country;
4104
-    }
4105
-
4106
-    if (!empty($location_array)) {
4107
-
4108
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4109
-        $location_array = array_reverse($location_array);
4110
-
4111
-        foreach ($location_array as $location_type => $location) {
4112
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4113
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4114
-
4115
-            $location_name = geodir_ucwords($gd_location_link_text);
4116
-            $location_name = __($location_name, 'geodirectory');
4117
-
4118
-            if ($actual_location_name) {
4119
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4120
-                $location_name = get_actual_location_name($location_type, $location, true);
4121
-            }
4122
-
4123
-            $location_titles[] = $location_name;
4124
-        }
4125
-        if (!empty($location_titles)) {
4126
-            $location_titles = array_unique($location_titles);
4127
-        }
4128
-    }
4129
-
4130
-
4131
-    if(!empty($location_titles)) {
4132
-        $vars['%%location%%'] = implode(", ", $location_titles);
4133
-    }
4134
-
4135
-
4136
-    if(!empty($location_titles)) {
4137
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4138
-    }
4139
-
4140
-
4141
-
4142
-    if($location_single) {
4143
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4144
-    }
4145
-
4146
-
4147
-    if($location_single) {
4148
-        $vars['%%location_single%%'] = $location_single;
4149
-    }
4150
-
4151
-    /**
4152
-     * Filter the title variables after standard ones have been filtered for wpseo.
4153
-     *
4154
-     * @since 1.5.7
4155
-     * @package GeoDirectory
4156
-     * @param string $vars The title with variables.
4157
-     * @param array $location_array The array of location variables.
4158
-     */
4159
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4041
+	global $wp;
4042
+	$title = '';
4043
+	// location variables
4044
+	$gd_post_type = geodir_get_current_posttype();
4045
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4046
+	/**
4047
+	 * Filter the title variables location variables array
4048
+	 *
4049
+	 * @since 1.5.5
4050
+	 * @package GeoDirectory
4051
+	 * @param array $location_array The array of location variables.
4052
+	 * @param array $vars The page title variables.
4053
+	 */
4054
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4055
+	$location_titles = array();
4056
+	if(get_query_var( 'gd_country_full' )){
4057
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4058
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4059
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4060
+	}
4061
+	$location_single = '';
4062
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4063
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4064
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4065
+
4066
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4067
+
4068
+	if (function_exists('get_actual_location_name')) {
4069
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4070
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4071
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4072
+	}
4073
+
4074
+	if ($gd_city != '') {
4075
+		if ($gd_city_actual != '') {
4076
+			$gd_city = $gd_city_actual;
4077
+		} else {
4078
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4079
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4080
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4081
+		}
4082
+		$location_single = $gd_city;
4083
+
4084
+	} else if ($gd_region != '') {
4085
+		if ($gd_region_actual != '') {
4086
+			$gd_region = $gd_region_actual;
4087
+		} else {
4088
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4089
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4090
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4091
+		}
4092
+
4093
+		$location_single = $gd_region;
4094
+	} else if ($gd_country != '') {
4095
+		if ($gd_country_actual != '') {
4096
+			$gd_country = $gd_country_actual;
4097
+		} else {
4098
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4099
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4100
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4101
+		}
4102
+
4103
+		$location_single = $gd_country;
4104
+	}
4105
+
4106
+	if (!empty($location_array)) {
4107
+
4108
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4109
+		$location_array = array_reverse($location_array);
4110
+
4111
+		foreach ($location_array as $location_type => $location) {
4112
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4113
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4114
+
4115
+			$location_name = geodir_ucwords($gd_location_link_text);
4116
+			$location_name = __($location_name, 'geodirectory');
4117
+
4118
+			if ($actual_location_name) {
4119
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4120
+				$location_name = get_actual_location_name($location_type, $location, true);
4121
+			}
4122
+
4123
+			$location_titles[] = $location_name;
4124
+		}
4125
+		if (!empty($location_titles)) {
4126
+			$location_titles = array_unique($location_titles);
4127
+		}
4128
+	}
4129
+
4130
+
4131
+	if(!empty($location_titles)) {
4132
+		$vars['%%location%%'] = implode(", ", $location_titles);
4133
+	}
4134
+
4135
+
4136
+	if(!empty($location_titles)) {
4137
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4138
+	}
4139
+
4140
+
4141
+
4142
+	if($location_single) {
4143
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4144
+	}
4145
+
4146
+
4147
+	if($location_single) {
4148
+		$vars['%%location_single%%'] = $location_single;
4149
+	}
4150
+
4151
+	/**
4152
+	 * Filter the title variables after standard ones have been filtered for wpseo.
4153
+	 *
4154
+	 * @since 1.5.7
4155
+	 * @package GeoDirectory
4156
+	 * @param string $vars The title with variables.
4157
+	 * @param array $location_array The array of location variables.
4158
+	 */
4159
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4160 4160
 }
4161 4161
 
4162 4162
 
@@ -4204,286 +4204,286 @@  discard block
 block discarded – undo
4204 4204
  * @return string Title after filtered variables.
4205 4205
  */
4206 4206
 function geodir_filter_title_variables($title, $gd_page, $sep = '') {
4207
-    global $wp, $post;
4207
+	global $wp, $post;
4208 4208
 
4209
-    if (!$gd_page || !$title) {
4210
-        return $title; // if no a GD page then bail.
4211
-    }
4209
+	if (!$gd_page || !$title) {
4210
+		return $title; // if no a GD page then bail.
4211
+	}
4212 4212
     
4213
-    if ($sep == '') {
4214
-        /**
4215
-         * Filter the page title separator.
4216
-         *
4217
-         * @since 1.0.0
4218
-         * @package GeoDirectory
4219
-         * @param string $sep The separator, default: `|`.
4220
-         */
4221
-        $sep = apply_filters('geodir_page_title_separator', '|');
4222
-    }
4223
-
4224
-    if (strpos($title,'%%title%%') !== false) {
4225
-        $title = str_replace("%%title%%", $post->post_title, $title);
4226
-    }
4227
-
4228
-    if (strpos($title,'%%sitename%%') !== false) {
4229
-        $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4230
-    }
4231
-
4232
-    if (strpos($title,'%%sitedesc%%') !== false) {
4233
-        $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4234
-    }
4235
-
4236
-    if (strpos($title,'%%excerpt%%') !== false) {
4237
-        $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4238
-    }
4213
+	if ($sep == '') {
4214
+		/**
4215
+		 * Filter the page title separator.
4216
+		 *
4217
+		 * @since 1.0.0
4218
+		 * @package GeoDirectory
4219
+		 * @param string $sep The separator, default: `|`.
4220
+		 */
4221
+		$sep = apply_filters('geodir_page_title_separator', '|');
4222
+	}
4223
+
4224
+	if (strpos($title,'%%title%%') !== false) {
4225
+		$title = str_replace("%%title%%", $post->post_title, $title);
4226
+	}
4227
+
4228
+	if (strpos($title,'%%sitename%%') !== false) {
4229
+		$title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4230
+	}
4231
+
4232
+	if (strpos($title,'%%sitedesc%%') !== false) {
4233
+		$title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4234
+	}
4235
+
4236
+	if (strpos($title,'%%excerpt%%') !== false) {
4237
+		$title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4238
+	}
4239 4239
     
4240
-    if ($gd_page == 'search' || $gd_page == 'author') {
4241
-        $post_type = sanitize_text_field($_REQUEST['stype']);
4242
-    } else if ($gd_page == 'add-listing') {
4243
-        $post_type = (isset($_REQUEST['listing_type'])) ? sanitize_text_field($_REQUEST['listing_type']) : '';
4244
-        $post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int)$_REQUEST['pid']) : $post_type;
4245
-    } else if (isset($post->post_type) && $post->post_type && in_array($post->post_type , geodir_get_posttypes())) {
4246
-        $post_type = $post->post_type;
4247
-    } else {
4248
-        $post_type = get_query_var('post_type');
4249
-    }
4240
+	if ($gd_page == 'search' || $gd_page == 'author') {
4241
+		$post_type = sanitize_text_field($_REQUEST['stype']);
4242
+	} else if ($gd_page == 'add-listing') {
4243
+		$post_type = (isset($_REQUEST['listing_type'])) ? sanitize_text_field($_REQUEST['listing_type']) : '';
4244
+		$post_type = !$post_type && !empty($_REQUEST['pid']) ? get_post_type((int)$_REQUEST['pid']) : $post_type;
4245
+	} else if (isset($post->post_type) && $post->post_type && in_array($post->post_type , geodir_get_posttypes())) {
4246
+		$post_type = $post->post_type;
4247
+	} else {
4248
+		$post_type = get_query_var('post_type');
4249
+	}
4250 4250
     
4251
-    if (strpos($title, '%%pt_single%%') !== false) {        
4252
-        $singular_name = '';
4253
-        if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
4254
-            $singular_name = __($singular_name, 'geodirectory');
4255
-        }
4251
+	if (strpos($title, '%%pt_single%%') !== false) {        
4252
+		$singular_name = '';
4253
+		if ($post_type && $singular_name = get_post_type_singular_label($post_type)) {
4254
+			$singular_name = __($singular_name, 'geodirectory');
4255
+		}
4256 4256
         
4257
-        $title = str_replace("%%pt_single%%", $singular_name, $title);
4258
-    }
4259
-
4260
-    if (strpos($title, '%%pt_plural%%') !== false) {        
4261
-        $plural_name = '';
4262
-        if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
4263
-            $plural_name = __($plural_name, 'geodirectory');
4264
-        }
4257
+		$title = str_replace("%%pt_single%%", $singular_name, $title);
4258
+	}
4259
+
4260
+	if (strpos($title, '%%pt_plural%%') !== false) {        
4261
+		$plural_name = '';
4262
+		if ($post_type && $plural_name = get_post_type_plural_label($post_type)) {
4263
+			$plural_name = __($plural_name, 'geodirectory');
4264
+		}
4265 4265
         
4266
-        $title = str_replace("%%pt_plural%%", $plural_name, $title);
4267
-    }
4268
-
4269
-    if (strpos($title, '%%category%%') !== false) {
4270
-        $cat_name = '';
4271
-
4272
-        if ($gd_page=='detail') {
4273
-            if ($post->default_category) {
4274
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4275
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4276
-            }
4277
-        } else if ($gd_page == 'listing') {
4278
-            $queried_object = get_queried_object();
4279
-            if (isset($queried_object->name)) {
4280
-                $cat_name = $queried_object->name;
4281
-            }
4282
-        }
4283
-        $title = str_replace("%%category%%", $cat_name, $title);
4284
-    }
4285
-
4286
-    if (strpos($title, '%%tag%%') !== false) {
4287
-        $cat_name = '';
4288
-
4289
-        if ($gd_page=='detail') {
4290
-            if ($post->default_category) {
4291
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4292
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4293
-            }
4294
-        } else if($gd_page == 'listing') {
4295
-            $queried_object = get_queried_object();
4296
-            if (isset($queried_object->name)) {
4297
-                $cat_name = $queried_object->name;
4298
-            }
4299
-        }
4300
-        $title = str_replace("%%tag%%", $cat_name, $title);
4301
-    }
4302
-
4303
-    if (strpos($title, '%%id%%') !== false) {
4304
-        $ID = (isset($post->ID)) ? $post->ID : '';
4305
-        $title = str_replace("%%id%%", $ID, $title);
4306
-    }
4307
-
4308
-    if (strpos($title,'%%sep%%') !== false) {
4309
-        $title = str_replace("%%sep%%", $sep, $title);
4310
-    }
4311
-
4312
-    // location variables
4313
-    $gd_post_type = geodir_get_current_posttype();
4314
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4315
-    /**
4316
-     * Filter the title variables location variables array
4317
-     *
4318
-     * @since 1.5.5
4319
-     * @package GeoDirectory
4320
-     * @param array $location_array The array of location variables.
4321
-     * @param string $title The title with variables..
4322
-     * @param string $gd_page The page being filtered.
4323
-     * @param string $sep The separator, default: `|`.
4324
-     */
4325
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4326
-    $location_titles = array();
4327
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4328
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4329
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4330
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4331
-    }
4332
-    $location_single = '';
4333
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4334
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4335
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4336
-
4337
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4338
-
4339
-    if (function_exists('get_actual_location_name')) {
4340
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4341
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4342
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4343
-    }
4344
-
4345
-    if ($gd_city != '') {
4346
-        if ($gd_city_actual != '') {
4347
-            $gd_city = $gd_city_actual;
4348
-        } else {
4349
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4350
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4351
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4352
-        }
4353
-        $location_single = $gd_city;
4354
-
4355
-    } else if ($gd_region != '') {
4356
-        if ($gd_region_actual != '') {
4357
-            $gd_region = $gd_region_actual;
4358
-        } else {
4359
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4360
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4361
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4362
-        }
4363
-
4364
-        $location_single = $gd_region;
4365
-    } else if ($gd_country != '') {
4366
-        if ($gd_country_actual != '') {
4367
-            $gd_country = $gd_country_actual;
4368
-        } else {
4369
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4370
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4371
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4372
-        }
4373
-
4374
-        $location_single = $gd_country;
4375
-    }
4376
-
4377
-    if (!empty($location_array)) {
4378
-
4379
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4380
-        $location_array = array_reverse($location_array);
4381
-
4382
-        foreach ($location_array as $location_type => $location) {
4383
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4384
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4385
-
4386
-            $location_name = geodir_ucwords($gd_location_link_text);
4387
-            $location_name = __($location_name, 'geodirectory');
4388
-
4389
-            if ($actual_location_name) {
4390
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4391
-                $location_name = get_actual_location_name($location_type, $location, true);
4392
-            }
4393
-
4394
-            $location_titles[] = $location_name;
4395
-        }
4396
-        if (!empty($location_titles)) {
4397
-            $location_titles = array_unique($location_titles);
4398
-        }
4399
-    }
4400
-
4401
-
4402
-    if(strpos($title,'%%location%%') !== false){
4403
-        $location = '';
4404
-        if($location_titles) {
4405
-            $location = implode(", ", $location_titles);
4406
-        }
4407
-        $title = str_replace("%%location%%",$location,$title);
4408
-    }
4409
-
4410
-    if(strpos($title,'%%in_location%%') !== false){
4411
-        $location = '';
4412
-        if($location_titles) {
4413
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4414
-        }
4415
-        $title = str_replace("%%in_location%%",$location,$title);
4416
-    }
4417
-
4418
-    if(strpos($title,'%%in_location_single%%') !== false){
4419
-        if($location_single) {
4420
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4421
-        }
4422
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4423
-    }
4424
-
4425
-    if(strpos($title,'%%location_single%%') !== false){
4426
-        $title = str_replace("%%location_single%%",$location_single,$title);
4427
-    }
4428
-
4429
-
4430
-    if(strpos($title,'%%search_term%%') !== false){
4431
-        $search_term = '';
4432
-        if(isset($_REQUEST['s'])){
4433
-            $search_term = esc_attr($_REQUEST['s']);
4434
-        }
4435
-        $title = str_replace("%%search_term%%",$search_term,$title);
4436
-    }
4437
-
4438
-    if(strpos($title,'%%search_near%%') !== false){
4439
-        $search_term = '';
4440
-        if(isset($_REQUEST['snear'])){
4441
-            $search_term = esc_attr($_REQUEST['snear']);
4442
-        }
4443
-        $title = str_replace("%%search_near%%",$search_term,$title);
4444
-    }
4445
-
4446
-    if(strpos($title,'%%name%%') !== false){
4447
-        $author_name = get_the_author();
4448
-        if (!$author_name || $author_name === '') {
4449
-            $queried_object = get_queried_object();
4266
+		$title = str_replace("%%pt_plural%%", $plural_name, $title);
4267
+	}
4268
+
4269
+	if (strpos($title, '%%category%%') !== false) {
4270
+		$cat_name = '';
4271
+
4272
+		if ($gd_page=='detail') {
4273
+			if ($post->default_category) {
4274
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4275
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4276
+			}
4277
+		} else if ($gd_page == 'listing') {
4278
+			$queried_object = get_queried_object();
4279
+			if (isset($queried_object->name)) {
4280
+				$cat_name = $queried_object->name;
4281
+			}
4282
+		}
4283
+		$title = str_replace("%%category%%", $cat_name, $title);
4284
+	}
4285
+
4286
+	if (strpos($title, '%%tag%%') !== false) {
4287
+		$cat_name = '';
4288
+
4289
+		if ($gd_page=='detail') {
4290
+			if ($post->default_category) {
4291
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4292
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4293
+			}
4294
+		} else if($gd_page == 'listing') {
4295
+			$queried_object = get_queried_object();
4296
+			if (isset($queried_object->name)) {
4297
+				$cat_name = $queried_object->name;
4298
+			}
4299
+		}
4300
+		$title = str_replace("%%tag%%", $cat_name, $title);
4301
+	}
4302
+
4303
+	if (strpos($title, '%%id%%') !== false) {
4304
+		$ID = (isset($post->ID)) ? $post->ID : '';
4305
+		$title = str_replace("%%id%%", $ID, $title);
4306
+	}
4307
+
4308
+	if (strpos($title,'%%sep%%') !== false) {
4309
+		$title = str_replace("%%sep%%", $sep, $title);
4310
+	}
4311
+
4312
+	// location variables
4313
+	$gd_post_type = geodir_get_current_posttype();
4314
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4315
+	/**
4316
+	 * Filter the title variables location variables array
4317
+	 *
4318
+	 * @since 1.5.5
4319
+	 * @package GeoDirectory
4320
+	 * @param array $location_array The array of location variables.
4321
+	 * @param string $title The title with variables..
4322
+	 * @param string $gd_page The page being filtered.
4323
+	 * @param string $sep The separator, default: `|`.
4324
+	 */
4325
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4326
+	$location_titles = array();
4327
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4328
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4329
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4330
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4331
+	}
4332
+	$location_single = '';
4333
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4334
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4335
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4336
+
4337
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4338
+
4339
+	if (function_exists('get_actual_location_name')) {
4340
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4341
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4342
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4343
+	}
4344
+
4345
+	if ($gd_city != '') {
4346
+		if ($gd_city_actual != '') {
4347
+			$gd_city = $gd_city_actual;
4348
+		} else {
4349
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4350
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4351
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4352
+		}
4353
+		$location_single = $gd_city;
4354
+
4355
+	} else if ($gd_region != '') {
4356
+		if ($gd_region_actual != '') {
4357
+			$gd_region = $gd_region_actual;
4358
+		} else {
4359
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4360
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4361
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4362
+		}
4363
+
4364
+		$location_single = $gd_region;
4365
+	} else if ($gd_country != '') {
4366
+		if ($gd_country_actual != '') {
4367
+			$gd_country = $gd_country_actual;
4368
+		} else {
4369
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4370
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4371
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4372
+		}
4373
+
4374
+		$location_single = $gd_country;
4375
+	}
4376
+
4377
+	if (!empty($location_array)) {
4378
+
4379
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4380
+		$location_array = array_reverse($location_array);
4381
+
4382
+		foreach ($location_array as $location_type => $location) {
4383
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4384
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4385
+
4386
+			$location_name = geodir_ucwords($gd_location_link_text);
4387
+			$location_name = __($location_name, 'geodirectory');
4388
+
4389
+			if ($actual_location_name) {
4390
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4391
+				$location_name = get_actual_location_name($location_type, $location, true);
4392
+			}
4393
+
4394
+			$location_titles[] = $location_name;
4395
+		}
4396
+		if (!empty($location_titles)) {
4397
+			$location_titles = array_unique($location_titles);
4398
+		}
4399
+	}
4400
+
4401
+
4402
+	if(strpos($title,'%%location%%') !== false){
4403
+		$location = '';
4404
+		if($location_titles) {
4405
+			$location = implode(", ", $location_titles);
4406
+		}
4407
+		$title = str_replace("%%location%%",$location,$title);
4408
+	}
4409
+
4410
+	if(strpos($title,'%%in_location%%') !== false){
4411
+		$location = '';
4412
+		if($location_titles) {
4413
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4414
+		}
4415
+		$title = str_replace("%%in_location%%",$location,$title);
4416
+	}
4417
+
4418
+	if(strpos($title,'%%in_location_single%%') !== false){
4419
+		if($location_single) {
4420
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4421
+		}
4422
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4423
+	}
4424
+
4425
+	if(strpos($title,'%%location_single%%') !== false){
4426
+		$title = str_replace("%%location_single%%",$location_single,$title);
4427
+	}
4428
+
4429
+
4430
+	if(strpos($title,'%%search_term%%') !== false){
4431
+		$search_term = '';
4432
+		if(isset($_REQUEST['s'])){
4433
+			$search_term = esc_attr($_REQUEST['s']);
4434
+		}
4435
+		$title = str_replace("%%search_term%%",$search_term,$title);
4436
+	}
4437
+
4438
+	if(strpos($title,'%%search_near%%') !== false){
4439
+		$search_term = '';
4440
+		if(isset($_REQUEST['snear'])){
4441
+			$search_term = esc_attr($_REQUEST['snear']);
4442
+		}
4443
+		$title = str_replace("%%search_near%%",$search_term,$title);
4444
+	}
4445
+
4446
+	if(strpos($title,'%%name%%') !== false){
4447
+		$author_name = get_the_author();
4448
+		if (!$author_name || $author_name === '') {
4449
+			$queried_object = get_queried_object();
4450 4450
             
4451
-            if (isset($queried_object->data->user_nicename)) {
4452
-                $author_name = $queried_object->data->display_name;
4453
-            }
4454
-        }
4455
-        $title = str_replace("%%name%%", $author_name, $title);
4456
-    }
4451
+			if (isset($queried_object->data->user_nicename)) {
4452
+				$author_name = $queried_object->data->display_name;
4453
+			}
4454
+		}
4455
+		$title = str_replace("%%name%%", $author_name, $title);
4456
+	}
4457 4457
     
4458
-    if (strpos($title, '%%page%%') !== false) {
4459
-        $page = geodir_title_meta_page($sep);
4460
-        $title = str_replace("%%page%%", $page, $title);
4461
-    }
4462
-    if (strpos($title, '%%pagenumber%%') !== false) {
4463
-        $pagenumber = geodir_title_meta_pagenumber();
4464
-        $title = str_replace("%%pagenumber%%", $pagenumber, $title);
4465
-    }
4466
-    if (strpos($title, '%%pagetotal%%') !== false) {
4467
-        $pagetotal = geodir_title_meta_pagetotal();
4468
-        $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4469
-    }
4470
-
4471
-    $title = wptexturize( $title );
4472
-    $title = convert_chars( $title );
4473
-    $title = esc_html( $title );
4474
-
4475
-    /**
4476
-     * Filter the title variables after standard ones have been filtered.
4477
-     *
4478
-     * @since 1.5.7
4479
-     * @package GeoDirectory
4480
-     * @param string $title The title with variables.
4481
-     * @param array $location_array The array of location variables.
4482
-     * @param string $gd_page The page being filtered.
4483
-     * @param string $sep The separator, default: `|`.
4484
-     */
4485
-
4486
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4458
+	if (strpos($title, '%%page%%') !== false) {
4459
+		$page = geodir_title_meta_page($sep);
4460
+		$title = str_replace("%%page%%", $page, $title);
4461
+	}
4462
+	if (strpos($title, '%%pagenumber%%') !== false) {
4463
+		$pagenumber = geodir_title_meta_pagenumber();
4464
+		$title = str_replace("%%pagenumber%%", $pagenumber, $title);
4465
+	}
4466
+	if (strpos($title, '%%pagetotal%%') !== false) {
4467
+		$pagetotal = geodir_title_meta_pagetotal();
4468
+		$title = str_replace("%%pagetotal%%", $pagetotal, $title);
4469
+	}
4470
+
4471
+	$title = wptexturize( $title );
4472
+	$title = convert_chars( $title );
4473
+	$title = esc_html( $title );
4474
+
4475
+	/**
4476
+	 * Filter the title variables after standard ones have been filtered.
4477
+	 *
4478
+	 * @since 1.5.7
4479
+	 * @package GeoDirectory
4480
+	 * @param string $title The title with variables.
4481
+	 * @param array $location_array The array of location variables.
4482
+	 * @param string $gd_page The page being filtered.
4483
+	 * @param string $sep The separator, default: `|`.
4484
+	 */
4485
+
4486
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4487 4487
 }
4488 4488
 
4489 4489
 /**
@@ -4496,65 +4496,65 @@  discard block
 block discarded – undo
4496 4496
  * @return array Translation texts.
4497 4497
  */
4498 4498
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4499
-    $gd_post_types = geodir_get_posttypes('array');
4500
-
4501
-    if (!empty($gd_post_types)) {
4502
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4503
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4504
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4505
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4506
-
4507
-            if (!empty($labels)) {
4508
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4509
-                    $translation_texts[] = $labels['name'];
4510
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4511
-                    $translation_texts[] = $labels['singular_name'];
4512
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4513
-                    $translation_texts[] = $labels['add_new'];
4514
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4515
-                    $translation_texts[] = $labels['add_new_item'];
4516
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4517
-                    $translation_texts[] = $labels['edit_item'];
4518
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4519
-                    $translation_texts[] = $labels['new_item'];
4520
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4521
-                    $translation_texts[] = $labels['view_item'];
4522
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4523
-                    $translation_texts[] = $labels['search_items'];
4524
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4525
-                    $translation_texts[] = $labels['not_found'];
4526
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4527
-                    $translation_texts[] = $labels['not_found_in_trash'];
4528
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4529
-                    $translation_texts[] = $labels['label_post_profile'];
4530
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4531
-                    $translation_texts[] = $labels['label_post_info'];
4532
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4533
-                    $translation_texts[] = $labels['label_post_images'];
4534
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4535
-                    $translation_texts[] = $labels['label_post_map'];
4536
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_reviews'];
4538
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_related_listing'];
4540
-            }
4541
-
4542
-            if ($description != '' && !in_array($description, $translation_texts)) {
4543
-                $translation_texts[] = normalize_whitespace($description);
4544
-            }
4545
-
4546
-            if (!empty($seo)) {
4547
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4548
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4549
-
4550
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4551
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4552
-            }
4553
-        }
4554
-    }
4555
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4556
-
4557
-    return $translation_texts;
4499
+	$gd_post_types = geodir_get_posttypes('array');
4500
+
4501
+	if (!empty($gd_post_types)) {
4502
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4503
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4504
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4505
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4506
+
4507
+			if (!empty($labels)) {
4508
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4509
+					$translation_texts[] = $labels['name'];
4510
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4511
+					$translation_texts[] = $labels['singular_name'];
4512
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4513
+					$translation_texts[] = $labels['add_new'];
4514
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4515
+					$translation_texts[] = $labels['add_new_item'];
4516
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4517
+					$translation_texts[] = $labels['edit_item'];
4518
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4519
+					$translation_texts[] = $labels['new_item'];
4520
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4521
+					$translation_texts[] = $labels['view_item'];
4522
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4523
+					$translation_texts[] = $labels['search_items'];
4524
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4525
+					$translation_texts[] = $labels['not_found'];
4526
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4527
+					$translation_texts[] = $labels['not_found_in_trash'];
4528
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4529
+					$translation_texts[] = $labels['label_post_profile'];
4530
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4531
+					$translation_texts[] = $labels['label_post_info'];
4532
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4533
+					$translation_texts[] = $labels['label_post_images'];
4534
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4535
+					$translation_texts[] = $labels['label_post_map'];
4536
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4537
+					$translation_texts[] = $labels['label_reviews'];
4538
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4539
+					$translation_texts[] = $labels['label_related_listing'];
4540
+			}
4541
+
4542
+			if ($description != '' && !in_array($description, $translation_texts)) {
4543
+				$translation_texts[] = normalize_whitespace($description);
4544
+			}
4545
+
4546
+			if (!empty($seo)) {
4547
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4548
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4549
+
4550
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4551
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4552
+			}
4553
+		}
4554
+	}
4555
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4556
+
4557
+	return $translation_texts;
4558 4558
 }
4559 4559
 
4560 4560
 /**
@@ -4567,27 +4567,27 @@  discard block
 block discarded – undo
4567 4567
  * @return array Location terms.
4568 4568
  */
4569 4569
 function geodir_remove_location_terms($location_terms = array()) {
4570
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4571
-
4572
-    if (!empty($location_terms) && $location_manager) {
4573
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4574
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4575
-
4576
-        if ($hide_region_part && $hide_country_part) {
4577
-            if (isset($location_terms['gd_country']))
4578
-                unset($location_terms['gd_country']);
4579
-            if (isset($location_terms['gd_region']))
4580
-                unset($location_terms['gd_region']);
4581
-        } else if ($hide_region_part && !$hide_country_part) {
4582
-            if (isset($location_terms['gd_region']))
4583
-                unset($location_terms['gd_region']);
4584
-        } else if (!$hide_region_part && $hide_country_part) {
4585
-            if (isset($location_terms['gd_country']))
4586
-                unset($location_terms['gd_country']);
4587
-        }
4588
-    }
4589
-
4590
-    return $location_terms;
4570
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4571
+
4572
+	if (!empty($location_terms) && $location_manager) {
4573
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4574
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4575
+
4576
+		if ($hide_region_part && $hide_country_part) {
4577
+			if (isset($location_terms['gd_country']))
4578
+				unset($location_terms['gd_country']);
4579
+			if (isset($location_terms['gd_region']))
4580
+				unset($location_terms['gd_region']);
4581
+		} else if ($hide_region_part && !$hide_country_part) {
4582
+			if (isset($location_terms['gd_region']))
4583
+				unset($location_terms['gd_region']);
4584
+		} else if (!$hide_region_part && $hide_country_part) {
4585
+			if (isset($location_terms['gd_country']))
4586
+				unset($location_terms['gd_country']);
4587
+		}
4588
+	}
4589
+
4590
+	return $location_terms;
4591 4591
 }
4592 4592
 
4593 4593
 /**
@@ -4601,47 +4601,47 @@  discard block
 block discarded – undo
4601 4601
  * @param bool $update Whether this is an existing listing being updated or not.
4602 4602
  */
4603 4603
 function geodir_on_wp_insert_post($post_ID, $post, $update) {
4604
-    if (!$update) {
4605
-        return;
4606
-    }
4604
+	if (!$update) {
4605
+		return;
4606
+	}
4607 4607
     
4608
-    $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4609
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4610
-    $inline_save = $action == 'inline-save' ? true : false;
4608
+	$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4609
+	$is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4610
+	$inline_save = $action == 'inline-save' ? true : false;
4611 4611
 
4612
-    if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4613
-        return;
4614
-    }
4612
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4613
+		return;
4614
+	}
4615 4615
     
4616
-    if ($action != '' && in_array($action, array('geodir_import_export'))) {
4617
-        return;
4618
-    }
4616
+	if ($action != '' && in_array($action, array('geodir_import_export'))) {
4617
+		return;
4618
+	}
4619 4619
 
4620
-    $user_id = (int)get_current_user_id();
4620
+	$user_id = (int)get_current_user_id();
4621 4621
         
4622
-    if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4623
-        $author_id = !empty($post->post_author) ? $post->post_author : 0;
4622
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4623
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
4624 4624
         
4625
-        if ($user_id == $author_id && !is_super_admin()) {
4626
-            $from_email = get_option('site_email');
4627
-            $from_name = get_site_emailName();
4628
-            $to_email = get_option('admin_email');
4629
-            $to_name = get_option('name');
4630
-            $message_type = 'listing_edited';
4625
+		if ($user_id == $author_id && !is_super_admin()) {
4626
+			$from_email = get_option('site_email');
4627
+			$from_name = get_site_emailName();
4628
+			$to_email = get_option('admin_email');
4629
+			$to_name = get_option('name');
4630
+			$message_type = 'listing_edited';
4631 4631
             
4632
-            $notify_edited = true;
4633
-            /**
4634
-             * Send notification when listing edited by author?
4635
-             *
4636
-             * @since 1.6.0
4637
-             * @param bool $notify_edited Notify on listing edited by author?
4638
-             * @param object $post The current post object.
4639
-             */
4640
-            $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4632
+			$notify_edited = true;
4633
+			/**
4634
+			 * Send notification when listing edited by author?
4635
+			 *
4636
+			 * @since 1.6.0
4637
+			 * @param bool $notify_edited Notify on listing edited by author?
4638
+			 * @param object $post The current post object.
4639
+			 */
4640
+			$notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4641 4641
             
4642
-            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4643
-        }
4644
-    }
4642
+			geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4643
+		}
4644
+	}
4645 4645
 }
4646 4646
 
4647 4647
 /**
@@ -4655,16 +4655,16 @@  discard block
 block discarded – undo
4655 4655
  * @return string|null The current page start & end numbering.
4656 4656
  */
4657 4657
 function geodir_title_meta_page($sep) {
4658
-    $replacement = null;
4658
+	$replacement = null;
4659 4659
 
4660
-    $max = geodir_title_meta_pagenumbering('max');
4661
-    $nr  = geodir_title_meta_pagenumbering('nr');
4660
+	$max = geodir_title_meta_pagenumbering('max');
4661
+	$nr  = geodir_title_meta_pagenumbering('nr');
4662 4662
 
4663
-    if ($max > 1 && $nr > 1) {
4664
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4665
-    }
4663
+	if ($max > 1 && $nr > 1) {
4664
+		$replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4665
+	}
4666 4666
 
4667
-    return $replacement;
4667
+	return $replacement;
4668 4668
 }
4669 4669
 
4670 4670
 /**
@@ -4676,14 +4676,14 @@  discard block
 block discarded – undo
4676 4676
  * @return string|null The current page number.
4677 4677
  */
4678 4678
 function geodir_title_meta_pagenumber() {
4679
-    $replacement = null;
4679
+	$replacement = null;
4680 4680
 
4681
-    $nr = geodir_title_meta_pagenumbering('nr');
4682
-    if (isset($nr) && $nr > 0) {
4683
-        $replacement = (string)$nr;
4684
-    }
4681
+	$nr = geodir_title_meta_pagenumbering('nr');
4682
+	if (isset($nr) && $nr > 0) {
4683
+		$replacement = (string)$nr;
4684
+	}
4685 4685
 
4686
-    return $replacement;
4686
+	return $replacement;
4687 4687
 }
4688 4688
 
4689 4689
 /**
@@ -4695,14 +4695,14 @@  discard block
 block discarded – undo
4695 4695
  * @return string|null The current page total.
4696 4696
  */
4697 4697
 function geodir_title_meta_pagetotal() {
4698
-    $replacement = null;
4698
+	$replacement = null;
4699 4699
 
4700
-    $max = geodir_title_meta_pagenumbering('max');
4701
-    if (isset($max) && $max > 0) {
4702
-        $replacement = (string)$max;
4703
-    }
4700
+	$max = geodir_title_meta_pagenumbering('max');
4701
+	if (isset($max) && $max > 0) {
4702
+		$replacement = (string)$max;
4703
+	}
4704 4704
 
4705
-    return $replacement;
4705
+	return $replacement;
4706 4706
 }
4707 4707
 
4708 4708
 /**
@@ -4719,44 +4719,44 @@  discard block
 block discarded – undo
4719 4719
  * @return int|null The current page numbering.
4720 4720
  */
4721 4721
 function geodir_title_meta_pagenumbering($request = 'nr') {
4722
-    global $wp_query, $post;
4723
-    $max_num_pages = null;
4724
-    $page_number   = null;
4725
-
4726
-    $max_num_pages = 1;
4727
-
4728
-    if (!is_singular()) {
4729
-        $page_number = get_query_var('paged');
4730
-        if ($page_number === 0 || $page_number === '') {
4731
-            $page_number = 1;
4732
-        }
4733
-
4734
-        if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4735
-            $max_num_pages = $wp_query->max_num_pages;
4736
-        }
4737
-    } else {
4738
-        $page_number = get_query_var('page');
4739
-        if ($page_number === 0 || $page_number === '') {
4740
-            $page_number = 1;
4741
-        }
4742
-
4743
-        if (isset($post->post_content)) {
4744
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4745
-        }
4746
-    }
4747
-
4748
-    $return = null;
4749
-
4750
-    switch ($request) {
4751
-        case 'nr':
4752
-            $return = $page_number;
4753
-            break;
4754
-        case 'max':
4755
-            $return = $max_num_pages;
4756
-            break;
4757
-    }
4758
-
4759
-    return $return;
4722
+	global $wp_query, $post;
4723
+	$max_num_pages = null;
4724
+	$page_number   = null;
4725
+
4726
+	$max_num_pages = 1;
4727
+
4728
+	if (!is_singular()) {
4729
+		$page_number = get_query_var('paged');
4730
+		if ($page_number === 0 || $page_number === '') {
4731
+			$page_number = 1;
4732
+		}
4733
+
4734
+		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4735
+			$max_num_pages = $wp_query->max_num_pages;
4736
+		}
4737
+	} else {
4738
+		$page_number = get_query_var('page');
4739
+		if ($page_number === 0 || $page_number === '') {
4740
+			$page_number = 1;
4741
+		}
4742
+
4743
+		if (isset($post->post_content)) {
4744
+			$max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4745
+		}
4746
+	}
4747
+
4748
+	$return = null;
4749
+
4750
+	switch ($request) {
4751
+		case 'nr':
4752
+			$return = $page_number;
4753
+			break;
4754
+		case 'max':
4755
+			$return = $max_num_pages;
4756
+			break;
4757
+	}
4758
+
4759
+	return $return;
4760 4760
 }
4761 4761
 
4762 4762
 /**
@@ -4768,17 +4768,17 @@  discard block
 block discarded – undo
4768 4768
  * @return array Terms.
4769 4769
  */
4770 4770
 function geodir_filter_empty_terms($terms) {
4771
-    if (empty($terms)) {
4772
-        return $terms;
4773
-    }
4774
-
4775
-    $return = array();
4776
-    foreach ($terms as $term) {
4777
-        if (isset($term->count) && $term->count > 0) {
4778
-            $return[] = $term;
4779
-        }
4780
-    }
4781
-    return $return;
4771
+	if (empty($terms)) {
4772
+		return $terms;
4773
+	}
4774
+
4775
+	$return = array();
4776
+	foreach ($terms as $term) {
4777
+		if (isset($term->count) && $term->count > 0) {
4778
+			$return[] = $term;
4779
+		}
4780
+	}
4781
+	return $return;
4782 4782
 }
4783 4783
 
4784 4784
 
@@ -4791,9 +4791,9 @@  discard block
 block discarded – undo
4791 4791
  * @return array
4792 4792
  */
4793 4793
 function geodir_remove_hentry( $class ) {
4794
-    if(geodir_is_page('detail')){
4795
-        $class = array_diff( $class, array( 'hentry' ) );
4796
-    }
4797
-    return $class;
4794
+	if(geodir_is_page('detail')){
4795
+		$class = array_diff( $class, array( 'hentry' ) );
4796
+	}
4797
+	return $class;
4798 4798
 }
4799 4799
 add_filter( 'post_class', 'geodir_remove_hentry' );
4800 4800
\ No newline at end of file
Please login to merge, or discard this patch.