Test Failed
Push — master ( 2185f5...faf44c )
by Stiofan
04:27
created
geodirectory-functions/post_functions.php 3 patches
Indentation   +2287 added lines, -2287 removed lines patch added patch discarded remove patch
@@ -20,492 +20,492 @@  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
-     * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED
79
-     * @package GeoDirectory
80
-     * @global object $wpdb WordPress Database object.
81
-     * @global object $post The current post object.
82
-     * @global object $current_user Current user object.
83
-     * @global object $gd_session GeoDirectory Session object.
84
-     * @param array $request_info {
85
-     *    Array of request info arguments.
86
-     *
87
-     *    @type string $action                                  Ajax action name.
88
-     *    @type string $geodir_ajax                             Ajax type.
89
-     *    @type string $ajax_action                             Ajax action.
90
-     *    @type string $listing_type                            Listing type.
91
-     *    @type string $pid                                     Default Post ID.
92
-     *    @type string $preview                                 Todo Desc needed.
93
-     *    @type string $add_listing_page_id                     Add listing page ID.
94
-     *    @type string $post_title                              Listing title.
95
-     *    @type string $post_desc                               Listing Description.
96
-     *    @type string $post_tags                               Listing tags.
97
-     *    @type array  $cat_limit                               Category limit.
98
-     *    @type array  $post_category                           Category IDs.
99
-     *    @type array  $post_category_str                       Category string.
100
-     *    @type string $post_default_category                   Default category ID.
101
-     *    @type string $post_address                            Listing address.
102
-     *    @type string $geodir_location_add_listing_country_val Add listing country value.
103
-     *    @type string $post_country                            Listing country.
104
-     *    @type string $geodir_location_add_listing_region_val  Add listing region value.
105
-     *    @type string $post_region                             Listing region.
106
-     *    @type string $geodir_location_add_listing_city_val    Add listing city value.
107
-     *    @type string $post_city                               Listing city.
108
-     *    @type string $post_zip                                Listing zip.
109
-     *    @type string $post_latitude                           Listing latitude.
110
-     *    @type string $post_longitude                          Listing longitude.
111
-     *    @type string $post_mapview                            Listing mapview. Default "ROADMAP".
112
-     *    @type string $post_mapzoom                            Listing mapzoom Default "9".
113
-     *    @type string $geodir_timing                           Business timing info.
114
-     *    @type string $geodir_contact                          Contact number.
115
-     *    @type string $geodir_email                            Business contact email.
116
-     *    @type string $geodir_website                          Business website.
117
-     *    @type string $geodir_twitter                          Twitter link.
118
-     *    @type string $geodir_facebook                         Facebook link.
119
-     *    @type string $geodir_video                            Video link.
120
-     *    @type string $geodir_special_offers                   Special offers.
121
-     *    @type string $post_images                             Post image urls.
122
-     *    @type string $post_imagesimage_limit                  Post images limit.
123
-     *    @type string $post_imagestotImg                       Todo Desc needed.
124
-     *    @type string $geodir_accept_term_condition            Has accepted terms and conditions?.
125
-     *    @type string $geodir_spamblocker                      Todo Desc needed.
126
-     *    @type string $geodir_filled_by_spam_bot               Todo Desc needed.
127
-     *
128
-     * }
129
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
130
-     * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false.
131
-     * @return int|string|WP_Error Created post id or WP_Error on failure.
132
-     */
133
-    function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false)
134
-    {
135
-        global $wpdb, $current_user, $gd_session;
136
-
137
-        $last_post_id = '';
138
-
139
-        if ($gd_session->get('listing') && !$dummy) {
140
-            $request_info = array();
141
-            $request_session = $gd_session->get('listing');
142
-            $request_info = array_merge($_REQUEST, $request_session);
143
-        } else if (!$gd_session->get('listing') && !$dummy) {
144
-            global $post;
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
+	 * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED
79
+	 * @package GeoDirectory
80
+	 * @global object $wpdb WordPress Database object.
81
+	 * @global object $post The current post object.
82
+	 * @global object $current_user Current user object.
83
+	 * @global object $gd_session GeoDirectory Session object.
84
+	 * @param array $request_info {
85
+	 *    Array of request info arguments.
86
+	 *
87
+	 *    @type string $action                                  Ajax action name.
88
+	 *    @type string $geodir_ajax                             Ajax type.
89
+	 *    @type string $ajax_action                             Ajax action.
90
+	 *    @type string $listing_type                            Listing type.
91
+	 *    @type string $pid                                     Default Post ID.
92
+	 *    @type string $preview                                 Todo Desc needed.
93
+	 *    @type string $add_listing_page_id                     Add listing page ID.
94
+	 *    @type string $post_title                              Listing title.
95
+	 *    @type string $post_desc                               Listing Description.
96
+	 *    @type string $post_tags                               Listing tags.
97
+	 *    @type array  $cat_limit                               Category limit.
98
+	 *    @type array  $post_category                           Category IDs.
99
+	 *    @type array  $post_category_str                       Category string.
100
+	 *    @type string $post_default_category                   Default category ID.
101
+	 *    @type string $post_address                            Listing address.
102
+	 *    @type string $geodir_location_add_listing_country_val Add listing country value.
103
+	 *    @type string $post_country                            Listing country.
104
+	 *    @type string $geodir_location_add_listing_region_val  Add listing region value.
105
+	 *    @type string $post_region                             Listing region.
106
+	 *    @type string $geodir_location_add_listing_city_val    Add listing city value.
107
+	 *    @type string $post_city                               Listing city.
108
+	 *    @type string $post_zip                                Listing zip.
109
+	 *    @type string $post_latitude                           Listing latitude.
110
+	 *    @type string $post_longitude                          Listing longitude.
111
+	 *    @type string $post_mapview                            Listing mapview. Default "ROADMAP".
112
+	 *    @type string $post_mapzoom                            Listing mapzoom Default "9".
113
+	 *    @type string $geodir_timing                           Business timing info.
114
+	 *    @type string $geodir_contact                          Contact number.
115
+	 *    @type string $geodir_email                            Business contact email.
116
+	 *    @type string $geodir_website                          Business website.
117
+	 *    @type string $geodir_twitter                          Twitter link.
118
+	 *    @type string $geodir_facebook                         Facebook link.
119
+	 *    @type string $geodir_video                            Video link.
120
+	 *    @type string $geodir_special_offers                   Special offers.
121
+	 *    @type string $post_images                             Post image urls.
122
+	 *    @type string $post_imagesimage_limit                  Post images limit.
123
+	 *    @type string $post_imagestotImg                       Todo Desc needed.
124
+	 *    @type string $geodir_accept_term_condition            Has accepted terms and conditions?.
125
+	 *    @type string $geodir_spamblocker                      Todo Desc needed.
126
+	 *    @type string $geodir_filled_by_spam_bot               Todo Desc needed.
127
+	 *
128
+	 * }
129
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
130
+	 * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false.
131
+	 * @return int|string|WP_Error Created post id or WP_Error on failure.
132
+	 */
133
+	function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false)
134
+	{
135
+		global $wpdb, $current_user, $gd_session;
136
+
137
+		$last_post_id = '';
138
+
139
+		if ($gd_session->get('listing') && !$dummy) {
140
+			$request_info = array();
141
+			$request_session = $gd_session->get('listing');
142
+			$request_info = array_merge($_REQUEST, $request_session);
143
+		} else if (!$gd_session->get('listing') && !$dummy) {
144
+			global $post;
145 145
             
146
-            $gd_post = $post;
147
-            if (!empty($gd_post) && is_array($gd_post)) {
148
-                $gd_post = (object)$post;
146
+			$gd_post = $post;
147
+			if (!empty($gd_post) && is_array($gd_post)) {
148
+				$gd_post = (object)$post;
149 149
                 
150
-                // Fix WPML duplicate.
151
-                if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
152
-                    return false;
153
-                }
154
-            }
150
+				// Fix WPML duplicate.
151
+				if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
152
+					return false;
153
+				}
154
+			}
155 155
             
156
-            $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL);
157
-            $request_info['post_title'] = $request_info['post_title'];
158
-            $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid']));
159
-            $request_info['post_desc'] = $request_info['content'];
160
-        } else if (!$dummy) {
161
-            return false;
162
-        }
163
-
164
-        /**
165
-         * Filter the request_info array.
166
-         *
167
-         * You can use this filter to modify request_info array.
168
-         *
169
-         * @since 1.0.0
170
-         * @package GeoDirectory
171
-         * @param array $request_info See {@see geodir_save_listing()} for accepted args.
172
-         */
173
-        $request_info = apply_filters('geodir_action_get_request_info', $request_info);
174
-
175
-        // Check if we need to save post location as new location
176
-        $location_result = geodir_get_default_location();
177
-
178
-        if ($location_result->location_id > 0) {
179
-            if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
180
-                $request_info['post_location'] = array(
181
-                    'city' => $request_info['post_city'],
182
-                    'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '',
183
-                    'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '',
184
-                    'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '',
185
-                    'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : ''
186
-                );
187
-
188
-                $post_location_info = $request_info['post_location'];
189
-
190
-                if ($location_id = geodir_add_new_location($post_location_info)) {
191
-                    $post_location_id = $location_id;
192
-                }
193
-            } else {
194
-                $post_location_id = $location_result->location_id;
195
-            }
196
-        } else {
197
-            $post_location_id = $location_result->location_id;
198
-        }
199
-
200
-        if ($dummy) {
201
-            $post_status = 'publish';
202
-        } else {
203
-            $post_status = geodir_new_post_default_status();
204
-        }
205
-
206
-        if (isset($request_info['pid']) && $request_info['pid'] != '') {
207
-            $post_status = get_post_status($request_info['pid']);
208
-        }
209
-
210
-        /* fix change of slug on every title edit */
211
-        if (!isset($request_info['post_name'])) {
212
-            $request_info['post_name'] = $request_info['post_title'];
213
-
214
-            if (!empty($request_info['pid'])) {
215
-                $post_info = get_post($request_info['pid']);
216
-
217
-                if (!empty($post_info) && isset($post_info->post_name)) {
218
-                    $request_info['post_name'] = $post_info->post_name;
219
-                }
220
-            }
221
-        }
222
-
223
-        $post = array(
224
-            'post_content' => $request_info['post_desc'],
225
-            'post_status' => $post_status,
226
-            'post_title' => $request_info['post_title'],
227
-            'post_name' => $request_info['post_name'],
228
-            'post_type' => $request_info['listing_type']
229
-        );
230
-
231
-        /**
232
-         * Called before a listing is saved to the database.
233
-         *
234
-         * @since 1.0.0
235
-         * @param object $post The post object.
236
-         */
237
-        do_action_ref_array('geodir_before_save_listing', $post);
156
+			$request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL);
157
+			$request_info['post_title'] = $request_info['post_title'];
158
+			$request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid']));
159
+			$request_info['post_desc'] = $request_info['content'];
160
+		} else if (!$dummy) {
161
+			return false;
162
+		}
163
+
164
+		/**
165
+		 * Filter the request_info array.
166
+		 *
167
+		 * You can use this filter to modify request_info array.
168
+		 *
169
+		 * @since 1.0.0
170
+		 * @package GeoDirectory
171
+		 * @param array $request_info See {@see geodir_save_listing()} for accepted args.
172
+		 */
173
+		$request_info = apply_filters('geodir_action_get_request_info', $request_info);
174
+
175
+		// Check if we need to save post location as new location
176
+		$location_result = geodir_get_default_location();
177
+
178
+		if ($location_result->location_id > 0) {
179
+			if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
180
+				$request_info['post_location'] = array(
181
+					'city' => $request_info['post_city'],
182
+					'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '',
183
+					'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '',
184
+					'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '',
185
+					'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : ''
186
+				);
187
+
188
+				$post_location_info = $request_info['post_location'];
189
+
190
+				if ($location_id = geodir_add_new_location($post_location_info)) {
191
+					$post_location_id = $location_id;
192
+				}
193
+			} else {
194
+				$post_location_id = $location_result->location_id;
195
+			}
196
+		} else {
197
+			$post_location_id = $location_result->location_id;
198
+		}
238 199
 
239
-        $send_post_submit_mail = false;
200
+		if ($dummy) {
201
+			$post_status = 'publish';
202
+		} else {
203
+			$post_status = geodir_new_post_default_status();
204
+		}
240 205
 
241
-        // unhook this function so it doesn't loop infinitely
242
-        remove_action('save_post', 'geodir_post_information_save',10,2);
206
+		if (isset($request_info['pid']) && $request_info['pid'] != '') {
207
+			$post_status = get_post_status($request_info['pid']);
208
+		}
243 209
 
244
-        if (isset($request_info['pid']) && $request_info['pid'] != '') {
245
-            $post['ID'] = $request_info['pid'];
210
+		/* fix change of slug on every title edit */
211
+		if (!isset($request_info['post_name'])) {
212
+			$request_info['post_name'] = $request_info['post_title'];
246 213
 
247
-            $last_post_id = wp_update_post($post, $wp_error);
248
-        } else {
249
-            $last_post_id = wp_insert_post($post, $wp_error);
214
+			if (!empty($request_info['pid'])) {
215
+				$post_info = get_post($request_info['pid']);
250 216
 
251
-            if (!$dummy && $last_post_id) {
252
-                $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)
253
-                //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
254
-            }
255
-        }
217
+				if (!empty($post_info) && isset($post_info->post_name)) {
218
+					$request_info['post_name'] = $post_info->post_name;
219
+				}
220
+			}
221
+		}
222
+
223
+		$post = array(
224
+			'post_content' => $request_info['post_desc'],
225
+			'post_status' => $post_status,
226
+			'post_title' => $request_info['post_title'],
227
+			'post_name' => $request_info['post_name'],
228
+			'post_type' => $request_info['listing_type']
229
+		);
230
+
231
+		/**
232
+		 * Called before a listing is saved to the database.
233
+		 *
234
+		 * @since 1.0.0
235
+		 * @param object $post The post object.
236
+		 */
237
+		do_action_ref_array('geodir_before_save_listing', $post);
238
+
239
+		$send_post_submit_mail = false;
240
+
241
+		// unhook this function so it doesn't loop infinitely
242
+		remove_action('save_post', 'geodir_post_information_save',10,2);
243
+
244
+		if (isset($request_info['pid']) && $request_info['pid'] != '') {
245
+			$post['ID'] = $request_info['pid'];
246
+
247
+			$last_post_id = wp_update_post($post, $wp_error);
248
+		} else {
249
+			$last_post_id = wp_insert_post($post, $wp_error);
250
+
251
+			if (!$dummy && $last_post_id) {
252
+				$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)
253
+				//geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
254
+			}
255
+		}
256 256
 
257
-        if ($wp_error && is_wp_error($last_post_id)) {
258
-            return $last_post_id; // Return WP_Error on save failure.
259
-        }
257
+		if ($wp_error && is_wp_error($last_post_id)) {
258
+			return $last_post_id; // Return WP_Error on save failure.
259
+		}
260 260
 
261
-        if (!$last_post_id) {
262
-            return false; // Save failure.
263
-        }
261
+		if (!$last_post_id) {
262
+			return false; // Save failure.
263
+		}
264 264
 
265
-        // re-hook this function
266
-        add_action('save_post', 'geodir_post_information_save',10,2);
265
+		// re-hook this function
266
+		add_action('save_post', 'geodir_post_information_save',10,2);
267 267
 
268
-        $post_tags = '';
269
-        if (!isset($request_info['post_tags'])) {
268
+		$post_tags = '';
269
+		if (!isset($request_info['post_tags'])) {
270 270
 
271
-            $post_type = $request_info['listing_type'];
272
-            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
271
+			$post_type = $request_info['listing_type'];
272
+			$post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
273 273
 
274
-        }
274
+		}
275 275
 
276
-        $gd_post_info = array(
277
-            "post_title" => $request_info['post_title'],
278
-            "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags,
279
-            "post_status" => $post_status,
280
-            "post_location_id" => $post_location_id,
281
-            "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '',
282
-            "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '',
283
-            "submit_time" => time(),
284
-            "submit_ip" => $_SERVER['REMOTE_ADDR'],
285
-        );
276
+		$gd_post_info = array(
277
+			"post_title" => $request_info['post_title'],
278
+			"post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags,
279
+			"post_status" => $post_status,
280
+			"post_location_id" => $post_location_id,
281
+			"claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '',
282
+			"businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '',
283
+			"submit_time" => time(),
284
+			"submit_ip" => $_SERVER['REMOTE_ADDR'],
285
+		);
286 286
 
287
-        $payment_info = array();
288
-        $package_info = array();
287
+		$payment_info = array();
288
+		$package_info = array();
289 289
 
290
-        $package_info = (array)geodir_post_package_info($package_info, $post);
290
+		$package_info = (array)geodir_post_package_info($package_info, $post);
291 291
 
292
-        $post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
292
+		$post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
293 293
 
294
-        if (!empty($package_info) && !$post_package_id) {
295
-            if (isset($package_info['days']) && $package_info['days'] != 0) {
296
-                $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
297
-            } else {
298
-                $payment_info['expire_date'] = 'Never';
299
-            }
294
+		if (!empty($package_info) && !$post_package_id) {
295
+			if (isset($package_info['days']) && $package_info['days'] != 0) {
296
+				$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
297
+			} else {
298
+				$payment_info['expire_date'] = 'Never';
299
+			}
300 300
 
301
-            $payment_info['package_id'] = $package_info['pid'];
302
-            $payment_info['alive_days'] = $package_info['days'];
303
-            $payment_info['is_featured'] = $package_info['is_featured'];
301
+			$payment_info['package_id'] = $package_info['pid'];
302
+			$payment_info['alive_days'] = $package_info['days'];
303
+			$payment_info['is_featured'] = $package_info['is_featured'];
304 304
 
305
-            $gd_post_info = array_merge($gd_post_info, $payment_info);
306
-        }
305
+			$gd_post_info = array_merge($gd_post_info, $payment_info);
306
+		}
307 307
 
308
-        $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
308
+		$custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
309 309
 
310
-        foreach ($custom_metaboxes as $key => $val):
310
+		foreach ($custom_metaboxes as $key => $val):
311 311
 
312
-            $name = $val['name'];
313
-            $type = $val['type'];
314
-            $extrafields = $val['extra_fields'];
312
+			$name = $val['name'];
313
+			$type = $val['type'];
314
+			$extrafields = $val['extra_fields'];
315 315
 
316
-            if (trim($type) == 'address') {
317
-                $prefix = $name . '_';
318
-                $address = $prefix . 'address';
316
+			if (trim($type) == 'address') {
317
+				$prefix = $name . '_';
318
+				$address = $prefix . 'address';
319 319
 
320
-                if (isset($request_info[$address]) && $request_info[$address] != '') {
321
-                    $gd_post_info[$address] = wp_slash($request_info[$address]);
322
-                }
320
+				if (isset($request_info[$address]) && $request_info[$address] != '') {
321
+					$gd_post_info[$address] = wp_slash($request_info[$address]);
322
+				}
323 323
 
324
-                if ($extrafields != '') {
325
-                    $extrafields = unserialize($extrafields);
324
+				if ($extrafields != '') {
325
+					$extrafields = unserialize($extrafields);
326 326
 
327 327
 
328
-                    if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
328
+					if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
329 329
 
330
-                        $location_result = geodir_get_default_location();
330
+						$location_result = geodir_get_default_location();
331 331
 
332
-                        $gd_post_info[$prefix . 'city'] = $location_result->city;
333
-                        $gd_post_info[$prefix . 'region'] = $location_result->region;
334
-                        $gd_post_info[$prefix . 'country'] = $location_result->country;
332
+						$gd_post_info[$prefix . 'city'] = $location_result->city;
333
+						$gd_post_info[$prefix . 'region'] = $location_result->region;
334
+						$gd_post_info[$prefix . 'country'] = $location_result->country;
335 335
 
336
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
336
+						$gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
337 337
 
338
-                    } else {
338
+					} else {
339 339
 
340
-                        $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
341
-                        $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
342
-                        $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
340
+						$gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
341
+						$gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
342
+						$gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
343 343
 
344
-                        //----------set post locations when import dummy data-------
345
-                        $location_result = geodir_get_default_location();
344
+						//----------set post locations when import dummy data-------
345
+						$location_result = geodir_get_default_location();
346 346
 
347
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
348
-                        //-----------------------------------------------------------------
347
+						$gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
348
+						//-----------------------------------------------------------------
349 349
 
350
-                    }
350
+					}
351 351
 
352 352
 
353
-                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
354
-                        $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
355
-                    }
353
+					if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
354
+						$gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
355
+					}
356 356
 
357 357
 
358
-                    if (isset($extrafields['show_map']) && $extrafields['show_map']) {
358
+					if (isset($extrafields['show_map']) && $extrafields['show_map']) {
359 359
 
360
-                        if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
361
-                            $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
362
-                        }
360
+						if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
361
+							$gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
362
+						}
363 363
 
364
-                        if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
365
-                            $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
366
-                        }
364
+						if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
365
+							$gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
366
+						}
367 367
 
368
-                        if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
369
-                            $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
370
-                        }
368
+						if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
369
+							$gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
370
+						}
371 371
 
372
-                        if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
373
-                            $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
374
-                        }
372
+						if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
373
+							$gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
374
+						}
375 375
 
376
-                    }
376
+					}
377 377
 
378
-                    // show lat lng
379
-                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
380
-                        $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
381
-                    }
382
-                }
378
+					// show lat lng
379
+					if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
380
+						$gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
381
+					}
382
+				}
383 383
 
384
-            } elseif (trim($type) == 'file') {
385
-                if (isset($request_info[$name])) {
386
-                    $request_files = array();
387
-                    if ($request_info[$name] != '')
388
-                        $request_files = explode(",", $request_info[$name]);
384
+			} elseif (trim($type) == 'file') {
385
+				if (isset($request_info[$name])) {
386
+					$request_files = array();
387
+					if ($request_info[$name] != '')
388
+						$request_files = explode(",", $request_info[$name]);
389 389
 
390
-                    $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
391
-                    geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
392
-                }
393
-            } elseif (trim($type) == 'datepicker') {
394
-                if (isset($request_info[$name])) {
395
-                    $datetime = '';
390
+					$extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
391
+					geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
392
+				}
393
+			} elseif (trim($type) == 'datepicker') {
394
+				if (isset($request_info[$name])) {
395
+					$datetime = '';
396 396
                     
397
-                    if (!empty($request_info[$name])) {
398
-                        $date_format = geodir_default_date_format();
399
-                        if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
400
-                            $extra_fields = unserialize($val['extra_fields']);
401
-                            $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format;
402
-                        }
403
-
404
-                        // check if we need to change the format or not
405
-                        $date_format_len = strlen(str_replace(' ', '', $date_format));
406
-                        if($date_format_len>5){// if greater then 5 then it's the old style format.
397
+					if (!empty($request_info[$name])) {
398
+						$date_format = geodir_default_date_format();
399
+						if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
400
+							$extra_fields = unserialize($val['extra_fields']);
401
+							$date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format;
402
+						}
403
+
404
+						// check if we need to change the format or not
405
+						$date_format_len = strlen(str_replace(' ', '', $date_format));
406
+						if($date_format_len>5){// if greater then 5 then it's the old style format.
407 407
 
408
-                            $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
409
-                            $replace = array('d','j','l','m','n','F','Y');//PHP date format
408
+							$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
409
+							$replace = array('d','j','l','m','n','F','Y');//PHP date format
410 410
 
411
-                            $date_format = str_replace($search, $replace, $date_format);
411
+							$date_format = str_replace($search, $replace, $date_format);
412 412
 
413
-                            $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
413
+							$post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
414 414
 
415
-                        }else{
416
-                            $post_htmlvar_value = $request_info[$name];
417
-                        }
415
+						}else{
416
+							$post_htmlvar_value = $request_info[$name];
417
+						}
418 418
 
419
-                        $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d
420
-                        $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated
421
-                    }
419
+						$post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d
420
+						$datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated
421
+					}
422 422
 
423
-                    $gd_post_info[$name] = $datetime;
424
-                }
425
-            } else if ($type == 'multiselect') {
426
-                if (isset($request_info[$name])) {
427
-                    $gd_post_info[$name] = $request_info[$name];
428
-                } else {
429
-                    if (isset($request_info['gd_field_' . $name])) {
430
-                        $gd_post_info[$name] = ''; /* fix de-select for multiselect */
431
-                    }
432
-                }
433
-            } else if (isset($request_info[$name])) {
434
-                $gd_post_info[$name] = $request_info[$name];
435
-            }
423
+					$gd_post_info[$name] = $datetime;
424
+				}
425
+			} else if ($type == 'multiselect') {
426
+				if (isset($request_info[$name])) {
427
+					$gd_post_info[$name] = $request_info[$name];
428
+				} else {
429
+					if (isset($request_info['gd_field_' . $name])) {
430
+						$gd_post_info[$name] = ''; /* fix de-select for multiselect */
431
+					}
432
+				}
433
+			} else if (isset($request_info[$name])) {
434
+				$gd_post_info[$name] = $request_info[$name];
435
+			}
436 436
 
437
-        endforeach;
437
+		endforeach;
438 438
 
439
-        if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
440
-            $gd_post_info['post_dummy'] = $request_info['post_dummy'];
441
-        }
439
+		if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
440
+			$gd_post_info['post_dummy'] = $request_info['post_dummy'];
441
+		}
442 442
 
443
-        // Save post detail info in detail table
444
-        if (!empty($gd_post_info)) {
445
-            geodir_save_post_info($last_post_id, $gd_post_info);
446
-        }
443
+		// Save post detail info in detail table
444
+		if (!empty($gd_post_info)) {
445
+			geodir_save_post_info($last_post_id, $gd_post_info);
446
+		}
447 447
 
448 448
 
449
-        // Set categories to the listing
450
-        if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
451
-            $post_category = array();
449
+		// Set categories to the listing
450
+		if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
451
+			$post_category = array();
452 452
 
453
-            foreach ($request_info['post_category'] as $taxonomy => $cat) {
453
+			foreach ($request_info['post_category'] as $taxonomy => $cat) {
454 454
 
455
-                if ($dummy)
456
-                    $post_category = $cat;
457
-                else {
455
+				if ($dummy)
456
+					$post_category = $cat;
457
+				else {
458 458
 
459
-                    if (!is_array($cat) && strstr($cat, ','))
460
-                        $cat = explode(',', $cat);
459
+					if (!is_array($cat) && strstr($cat, ','))
460
+						$cat = explode(',', $cat);
461 461
 
462
-                    if (!empty($cat) && is_array($cat))
463
-                        $post_category = array_map('intval', $cat);
464
-                }
462
+					if (!empty($cat) && is_array($cat))
463
+						$post_category = array_map('intval', $cat);
464
+				}
465 465
 
466
-                wp_set_object_terms($last_post_id, $post_category, $taxonomy);
467
-            }
466
+				wp_set_object_terms($last_post_id, $post_category, $taxonomy);
467
+			}
468 468
 
469
-            $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : '';
469
+			$post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : '';
470 470
 
471
-            $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : '';
472
-            geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str);
471
+			$post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : '';
472
+			geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str);
473 473
 
474
-        }
474
+		}
475 475
 
476
-        $post_tags = '';
477
-        // Set tags to the listing
478
-        if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
479
-            $post_tags = explode(",", $request_info['post_tags']);
480
-        } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
481
-            if ($dummy)
482
-                $post_tags = $request_info['post_tags'];
483
-        } else {
484
-            if ($dummy)
485
-                $post_tags = array($request_info['post_title']);
486
-        }
476
+		$post_tags = '';
477
+		// Set tags to the listing
478
+		if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
479
+			$post_tags = explode(",", $request_info['post_tags']);
480
+		} elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
481
+			if ($dummy)
482
+				$post_tags = $request_info['post_tags'];
483
+		} else {
484
+			if ($dummy)
485
+				$post_tags = array($request_info['post_title']);
486
+		}
487 487
 
488
-        if (is_array($post_tags)) {
489
-            $taxonomy = $request_info['listing_type'] . '_tags';
490
-            wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
491
-        }
488
+		if (is_array($post_tags)) {
489
+			$taxonomy = $request_info['listing_type'] . '_tags';
490
+			wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
491
+		}
492 492
 
493 493
 
494
-        // Insert attachment
494
+		// Insert attachment
495 495
 
496
-        if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
497
-            if (!$dummy) {
498
-                $tmpimgArr = trim($request_info['post_images'], ",");
499
-                $tmpimgArr = explode(",", $tmpimgArr);
500
-                geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
501
-            } else{
502
-                geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
503
-            }
496
+		if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
497
+			if (!$dummy) {
498
+				$tmpimgArr = trim($request_info['post_images'], ",");
499
+				$tmpimgArr = explode(",", $tmpimgArr);
500
+				geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
501
+			} else{
502
+				geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
503
+			}
504 504
 
505 505
 
506
-        } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
506
+		} elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
507 507
 
508
-            /* Delete Attachments
508
+			/* Delete Attachments
509 509
 			$postcurr_images = geodir_get_images($last_post_id);
510 510
 
511 511
 			$wpdb->query(
@@ -521,34 +521,34 @@  discard block
 block discarded – undo
521 521
 			geodir_save_post_info($last_post_id, $gd_post_featured_img);
522 522
 			*/
523 523
 
524
-        }
524
+		}
525 525
 
526
-        geodir_remove_temp_images();
527
-        geodir_set_wp_featured_image($last_post_id);
526
+		geodir_remove_temp_images();
527
+		geodir_set_wp_featured_image($last_post_id);
528 528
 
529
-        /**
530
-         * Called after a listing is saved to the database and before any email have been sent.
531
-         *
532
-         * @since 1.0.0
533
-         * @param int $last_post_id The saved post ID.
534
-         * @param array $request_info The post details in an array.
535
-         * @see 'geodir_after_save_listinginfo'
536
-         */
537
-        do_action('geodir_after_save_listing', $last_post_id, $request_info);
529
+		/**
530
+		 * Called after a listing is saved to the database and before any email have been sent.
531
+		 *
532
+		 * @since 1.0.0
533
+		 * @param int $last_post_id The saved post ID.
534
+		 * @param array $request_info The post details in an array.
535
+		 * @see 'geodir_after_save_listinginfo'
536
+		 */
537
+		do_action('geodir_after_save_listing', $last_post_id, $request_info);
538 538
 
539
-        //die;
539
+		//die;
540 540
 
541
-        if ($send_post_submit_mail) { // if new post send out email
542
-            $to_name = geodir_get_client_name($current_user->ID);
543
-            geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
544
-        }
545
-        /*
541
+		if ($send_post_submit_mail) { // if new post send out email
542
+			$to_name = geodir_get_client_name($current_user->ID);
543
+			geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
544
+		}
545
+		/*
546 546
          * Unset the session so we don't loop.
547 547
          */
548
-        $gd_session->un_set('listing');
549
-        return $last_post_id;
548
+		$gd_session->un_set('listing');
549
+		return $last_post_id;
550 550
 
551
-    }
551
+	}
552 552
 
553 553
 }
554 554
 
@@ -567,611 +567,611 @@  discard block
 block discarded – undo
567 567
 function geodir_get_post_info($post_id = '')
568 568
 {
569 569
 
570
-    global $wpdb, $plugin_prefix, $post, $post_info;
570
+	global $wpdb, $plugin_prefix, $post, $post_info;
571 571
 
572
-    if ($post_id == '' && !empty($post))
573
-        $post_id = $post->ID;
572
+	if ($post_id == '' && !empty($post))
573
+		$post_id = $post->ID;
574 574
 
575
-    $post_type = get_post_type($post_id);
575
+	$post_type = get_post_type($post_id);
576 576
 
577
-    $all_postypes = geodir_get_posttypes();
577
+	$all_postypes = geodir_get_posttypes();
578 578
 
579
-    if (!in_array($post_type, $all_postypes))
580
-        return false;
579
+	if (!in_array($post_type, $all_postypes))
580
+		return false;
581 581
 
582
-    $table = $plugin_prefix . $post_type . '_detail';
582
+	$table = $plugin_prefix . $post_type . '_detail';
583 583
 
584
-    /**
585
-     * Apply Filter to change Post info
586
-     *
587
-     * You can use this filter to change Post info.
588
-     *
589
-     * @since 1.0.0
590
-     * @package GeoDirectory
591
-     */
592
-    $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
584
+	/**
585
+	 * Apply Filter to change Post info
586
+	 *
587
+	 * You can use this filter to change Post info.
588
+	 *
589
+	 * @since 1.0.0
590
+	 * @package GeoDirectory
591
+	 */
592
+	$query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
593 593
 			  WHERE p.ID = pd.post_id
594 594
 			  AND pd.post_id = %d", $post_id));
595 595
 
596
-    $post_detail = $wpdb->get_row($query);
596
+	$post_detail = $wpdb->get_row($query);
597 597
 
598
-    return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;
598
+	return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;
599 599
 
600 600
 }
601 601
 
602 602
 
603 603
 if (!function_exists('geodir_save_post_info')) {
604
-    /**
605
-     * Saves post detail info in detail table.
606
-     *
607
-     * @since 1.0.0
608
-     * @package GeoDirectory
609
-     * @global object $wpdb WordPress Database object.
610
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
611
-     * @param int $post_id The post ID.
612
-     * @param array $postinfo_array {
613
-     *    Post info that needs to be saved in detail table.
614
-     *
615
-     *    @type string $post_title              Listing title.
616
-     *    @type string $post_tags               Listing tags.
617
-     *    @type string $post_status             Listing post status.
618
-     *    @type string $post_location_id        Listing location ID.
619
-     *    @type string $claimed                 Todo Desc needed.
620
-     *    @type string $businesses              Todo Desc needed.
621
-     *    @type int    $submit_time             Submitted time in unix timestamp.
622
-     *    @type string $submit_ip               Submitted IP.
623
-     *    @type string $expire_date             Listing expiration date.
624
-     *    @type int    $package_id              Listing package ID.
625
-     *    @type int    $alive_days              Todo Desc needed.
626
-     *    @type int    $is_featured             Is this a featured listing?.
627
-     *    @type string $post_address            Listing address.
628
-     *    @type string $post_city               Listing city.
629
-     *    @type string $post_region             Listing region.
630
-     *    @type string $post_country            Listing country.
631
-     *    @type string $post_locations          Listing locations.
632
-     *    @type string $post_zip                Listing zip.
633
-     *    @type string $post_latitude           Listing latitude.
634
-     *    @type string $post_longitude          Listing longitude.
635
-     *    @type string $post_mapview            Listing mapview. Default "ROADMAP".
636
-     *    @type string $post_mapzoom            Listing mapzoom Default "9".
637
-     *    @type string $geodir_timing           Business timing info.
638
-     *    @type string $geodir_contact          Contact number.
639
-     *    @type string $geodir_email            Business contact email.
640
-     *    @type string $geodir_website          Business website.
641
-     *    @type string $geodir_twitter          Twitter link.
642
-     *    @type string $geodir_facebook         Facebook link.
643
-     *    @type string $geodir_video            Video link.
644
-     *    @type string $geodir_special_offers   Special offers.
645
-     *
646
-     * }
647
-     * @return bool
648
-     */
649
-    function geodir_save_post_info($post_id, $postinfo_array = array())
650
-    {
651
-        global $wpdb, $plugin_prefix;
652
-
653
-        $post_type = get_post_type($post_id);
654
-
655
-        $table = $plugin_prefix . $post_type . '_detail';
656
-
657
-        /**
658
-         * Filter to change Post info
659
-         *
660
-         * You can use this filter to change Post info.
661
-         *
662
-         * @since 1.0.0
663
-         * @package GeoDirectory
664
-         * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
665
-         * @param int $post_id The post ID.
666
-         */
667
-        $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
604
+	/**
605
+	 * Saves post detail info in detail table.
606
+	 *
607
+	 * @since 1.0.0
608
+	 * @package GeoDirectory
609
+	 * @global object $wpdb WordPress Database object.
610
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
611
+	 * @param int $post_id The post ID.
612
+	 * @param array $postinfo_array {
613
+	 *    Post info that needs to be saved in detail table.
614
+	 *
615
+	 *    @type string $post_title              Listing title.
616
+	 *    @type string $post_tags               Listing tags.
617
+	 *    @type string $post_status             Listing post status.
618
+	 *    @type string $post_location_id        Listing location ID.
619
+	 *    @type string $claimed                 Todo Desc needed.
620
+	 *    @type string $businesses              Todo Desc needed.
621
+	 *    @type int    $submit_time             Submitted time in unix timestamp.
622
+	 *    @type string $submit_ip               Submitted IP.
623
+	 *    @type string $expire_date             Listing expiration date.
624
+	 *    @type int    $package_id              Listing package ID.
625
+	 *    @type int    $alive_days              Todo Desc needed.
626
+	 *    @type int    $is_featured             Is this a featured listing?.
627
+	 *    @type string $post_address            Listing address.
628
+	 *    @type string $post_city               Listing city.
629
+	 *    @type string $post_region             Listing region.
630
+	 *    @type string $post_country            Listing country.
631
+	 *    @type string $post_locations          Listing locations.
632
+	 *    @type string $post_zip                Listing zip.
633
+	 *    @type string $post_latitude           Listing latitude.
634
+	 *    @type string $post_longitude          Listing longitude.
635
+	 *    @type string $post_mapview            Listing mapview. Default "ROADMAP".
636
+	 *    @type string $post_mapzoom            Listing mapzoom Default "9".
637
+	 *    @type string $geodir_timing           Business timing info.
638
+	 *    @type string $geodir_contact          Contact number.
639
+	 *    @type string $geodir_email            Business contact email.
640
+	 *    @type string $geodir_website          Business website.
641
+	 *    @type string $geodir_twitter          Twitter link.
642
+	 *    @type string $geodir_facebook         Facebook link.
643
+	 *    @type string $geodir_video            Video link.
644
+	 *    @type string $geodir_special_offers   Special offers.
645
+	 *
646
+	 * }
647
+	 * @return bool
648
+	 */
649
+	function geodir_save_post_info($post_id, $postinfo_array = array())
650
+	{
651
+		global $wpdb, $plugin_prefix;
652
+
653
+		$post_type = get_post_type($post_id);
654
+
655
+		$table = $plugin_prefix . $post_type . '_detail';
656
+
657
+		/**
658
+		 * Filter to change Post info
659
+		 *
660
+		 * You can use this filter to change Post info.
661
+		 *
662
+		 * @since 1.0.0
663
+		 * @package GeoDirectory
664
+		 * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
665
+		 * @param int $post_id The post ID.
666
+		 */
667
+		$postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
668
+
669
+		$query_string_escaped = '';
670
+		$query_string_array = array();
671
+
672
+		if (!empty($postmeta) && $post_id) {
673
+
674
+			$columns = $wpdb->get_col("show columns from $table");
675
+			foreach ($postmeta as $mkey => $mval) {
676
+				if(in_array($mkey,$columns)) {
677
+					if (is_array($mval)) {
678
+						$mval = implode(",", $mval);
679
+					}
680
+					$query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above
681
+					$query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare
668 682
 
669
-        $query_string_escaped = '';
670
-        $query_string_array = array();
683
+				}
684
+			}
671 685
 
672
-        if (!empty($postmeta) && $post_id) {
686
+			$query_string_escaped = trim($query_string_escaped, ", ");
673 687
 
674
-            $columns = $wpdb->get_col("show columns from $table");
675
-            foreach ($postmeta as $mkey => $mval) {
676
-                if(in_array($mkey,$columns)) {
677
-                    if (is_array($mval)) {
678
-                        $mval = implode(",", $mval);
679
-                    }
680
-                    $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above
681
-                    $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare
688
+			if (empty($query_string_array) || trim($query_string_escaped) == '') {
689
+				return false;
690
+			}
682 691
 
683
-                }
684
-            }
692
+			$query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
685 693
 
686
-            $query_string_escaped = trim($query_string_escaped, ", ");
687 694
 
688
-            if (empty($query_string_array) || trim($query_string_escaped) == '') {
689
-                return false;
690
-            }
695
+			/**
696
+			 * Called before saving the listing info.
697
+			 *
698
+			 * @since 1.0.0
699
+			 * @package GeoDirectory
700
+			 * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
701
+			 * @param int $post_id The post ID.
702
+			 */
703
+			do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
691 704
 
692
-            $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
705
+			if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
693 706
 
707
+				$query_string_array[] = $post_id;
708
+				$wpdb->query(
709
+					$wpdb->prepare(
710
+						"UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d",
711
+						$query_string_array
712
+					)
713
+				);
694 714
 
695
-            /**
696
-             * Called before saving the listing info.
697
-             *
698
-             * @since 1.0.0
699
-             * @package GeoDirectory
700
-             * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
701
-             * @param int $post_id The post ID.
702
-             */
703
-            do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
704 715
 
705
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
716
+			} else {
706 717
 
707
-                $query_string_array[] = $post_id;
708
-                $wpdb->query(
709
-                    $wpdb->prepare(
710
-                        "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d",
711
-                        $query_string_array
712
-                    )
713
-                );
718
+				array_unshift($query_string_array, $post_id);
719
+				$wpdb->query(
720
+					$wpdb->prepare(
721
+						"INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped,
722
+						$query_string_array
723
+					)
724
+				);
725
+                
726
+			}
714 727
 
728
+			/**
729
+			 * Called after saving the listing info.
730
+			 *
731
+			 * @since 1.0.0
732
+			 * @package GeoDirectory
733
+			 * @param array $postinfo_array Post info that needs to be saved in detail table.
734
+			 * @param int $post_id The post ID.
735
+			 * @see 'geodir_after_save_listing'
736
+			 */
737
+			do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
738
+
739
+			return true;
740
+		} else
741
+			return false;
715 742
 
716
-            } else {
743
+	}
744
+}
717 745
 
718
-                array_unshift($query_string_array, $post_id);
719
-                $wpdb->query(
720
-                    $wpdb->prepare(
721
-                        "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped,
722
-                        $query_string_array
723
-                    )
724
-                );
725
-                
726
-            }
727 746
 
728
-            /**
729
-             * Called after saving the listing info.
730
-             *
731
-             * @since 1.0.0
732
-             * @package GeoDirectory
733
-             * @param array $postinfo_array Post info that needs to be saved in detail table.
734
-             * @param int $post_id The post ID.
735
-             * @see 'geodir_after_save_listing'
736
-             */
737
-            do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
747
+if (!function_exists('geodir_save_post_meta')) {
748
+	/**
749
+	 * Save or update post custom fields.
750
+	 *
751
+	 * @since 1.0.0
752
+	 * @package GeoDirectory
753
+	 * @global object $wpdb WordPress Database object.
754
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
755
+	 * @param int $post_id The post ID.
756
+	 * @param string $postmeta Detail table column name.
757
+	 * @param string $meta_value Detail table column value.
758
+	 * @return void|bool
759
+	 */
760
+	function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
761
+	{
762
+
763
+		global $wpdb, $plugin_prefix;
764
+
765
+		$post_type = get_post_type($post_id);
766
+
767
+		$table = $plugin_prefix . $post_type . '_detail';
768
+
769
+		if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
770
+
771
+			if (is_array($meta_value)) {
772
+				$meta_value = implode(",", $meta_value);
773
+			}
738 774
 
739
-            return true;
740
-        } else
741
-            return false;
775
+			if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
742 776
 
743
-    }
744
-}
777
+				$wpdb->query(
778
+					$wpdb->prepare(
779
+						"UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
780
+						array($post_id)
781
+					)
782
+				);
745 783
 
784
+			} else {
746 785
 
747
-if (!function_exists('geodir_save_post_meta')) {
748
-    /**
749
-     * Save or update post custom fields.
750
-     *
751
-     * @since 1.0.0
752
-     * @package GeoDirectory
753
-     * @global object $wpdb WordPress Database object.
754
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
755
-     * @param int $post_id The post ID.
756
-     * @param string $postmeta Detail table column name.
757
-     * @param string $meta_value Detail table column value.
758
-     * @return void|bool
759
-     */
760
-    function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
761
-    {
762
-
763
-        global $wpdb, $plugin_prefix;
764
-
765
-        $post_type = get_post_type($post_id);
766
-
767
-        $table = $plugin_prefix . $post_type . '_detail';
768
-
769
-        if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
770
-
771
-            if (is_array($meta_value)) {
772
-                $meta_value = implode(",", $meta_value);
773
-            }
774
-
775
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
776
-
777
-                $wpdb->query(
778
-                    $wpdb->prepare(
779
-                        "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
780
-                        array($post_id)
781
-                    )
782
-                );
783
-
784
-            } else {
785
-
786
-                $wpdb->query(
787
-                    $wpdb->prepare(
788
-                        "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
789
-                        array($post_id)
790
-                    )
791
-                );
792
-            }
793
-
794
-
795
-        } else
796
-            return false;
797
-    }
786
+				$wpdb->query(
787
+					$wpdb->prepare(
788
+						"INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
789
+						array($post_id)
790
+					)
791
+				);
792
+			}
793
+
794
+
795
+		} else
796
+			return false;
797
+	}
798 798
 }
799 799
 
800 800
 if (!function_exists('geodir_delete_post_meta')) {
801
-    /**
802
-     * Delete post custom fields.
803
-     *
804
-     * @since 1.0.0
805
-     * @package GeoDirectory
806
-     * @global object $wpdb WordPress Database object.
807
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
808
-     * @param int $post_id The post ID.
809
-     * @param string $postmeta Detail table column name.
810
-     * @todo check if this is depreciated
811
-     * @todo Fix unknown variable mval
812
-     * @return bool
813
-     */
814
-    function geodir_delete_post_meta($post_id, $postmeta)
815
-    {
816
-
817
-        global $wpdb, $plugin_prefix;
818
-
819
-        $post_type = get_post_type($post_id);
820
-
821
-        $table = $plugin_prefix . $post_type . '_detail';
822
-
823
-        if (is_array($postmeta) && !empty($postmeta) && $post_id) {
824
-            $post_meta_set_query = '';
825
-
826
-            foreach ($postmeta as $mkey) {
827
-                if ($mval != '')
828
-                    $post_meta_set_query .= $mkey . " = '', ";
829
-            }
830
-
831
-            $post_meta_set_query = trim($post_meta_set_query, ", ");
801
+	/**
802
+	 * Delete post custom fields.
803
+	 *
804
+	 * @since 1.0.0
805
+	 * @package GeoDirectory
806
+	 * @global object $wpdb WordPress Database object.
807
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
808
+	 * @param int $post_id The post ID.
809
+	 * @param string $postmeta Detail table column name.
810
+	 * @todo check if this is depreciated
811
+	 * @todo Fix unknown variable mval
812
+	 * @return bool
813
+	 */
814
+	function geodir_delete_post_meta($post_id, $postmeta)
815
+	{
816
+
817
+		global $wpdb, $plugin_prefix;
818
+
819
+		$post_type = get_post_type($post_id);
820
+
821
+		$table = $plugin_prefix . $post_type . '_detail';
822
+
823
+		if (is_array($postmeta) && !empty($postmeta) && $post_id) {
824
+			$post_meta_set_query = '';
825
+
826
+			foreach ($postmeta as $mkey) {
827
+				if ($mval != '')
828
+					$post_meta_set_query .= $mkey . " = '', ";
829
+			}
830
+
831
+			$post_meta_set_query = trim($post_meta_set_query, ", ");
832 832
             
833
-            if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
834
-                return false;
835
-            }
836
-
837
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
838
-
839
-                $wpdb->query(
840
-                    $wpdb->prepare(
841
-                        "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
842
-                        array($post_id)
843
-                    )
844
-                );
845
-
846
-                return true;
847
-            }
848
-
849
-        } elseif ($postmeta != '' && $post_id) {
850
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
851
-
852
-                $wpdb->query(
853
-                    $wpdb->prepare(
854
-                        "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
855
-                        array($post_id)
856
-                    )
857
-                );
858
-
859
-                return true;
860
-            }
861
-
862
-        } else
863
-            return false;
864
-    }
833
+			if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
834
+				return false;
835
+			}
836
+
837
+			if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
838
+
839
+				$wpdb->query(
840
+					$wpdb->prepare(
841
+						"UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
842
+						array($post_id)
843
+					)
844
+				);
845
+
846
+				return true;
847
+			}
848
+
849
+		} elseif ($postmeta != '' && $post_id) {
850
+			if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
851
+
852
+				$wpdb->query(
853
+					$wpdb->prepare(
854
+						"UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
855
+						array($post_id)
856
+					)
857
+				);
858
+
859
+				return true;
860
+			}
861
+
862
+		} else
863
+			return false;
864
+	}
865 865
 }
866 866
 
867 867
 
868 868
 if (!function_exists('geodir_get_post_meta')) {
869
-    /**
870
-     * Get post custom meta.
871
-     *
872
-     * @since 1.0.0
873
-     * @since 1.6.20 Hook added to filter value.
874
-     * @package GeoDirectory
875
-     * @global object $wpdb WordPress Database object.
876
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
877
-     * @param int $post_id The post ID.
878
-     * @param string $meta_key The meta key to retrieve.
879
-     * @param bool $single Optional. Whether to return a single value. Default false.
880
-     * @todo single variable not yet implemented.
881
-     * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
882
-     */
883
-    function geodir_get_post_meta($post_id, $meta_key, $single = false) {
884
-        if (!$post_id) {
885
-            return false;
886
-        }
887
-        global $wpdb, $plugin_prefix;
888
-
889
-        $all_postypes = geodir_get_posttypes();
890
-
891
-        $post_type = get_post_type($post_id);
892
-
893
-        if (!in_array($post_type, $all_postypes))
894
-            return false;
895
-
896
-        $table = $plugin_prefix . $post_type . '_detail';
897
-
898
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
899
-            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
869
+	/**
870
+	 * Get post custom meta.
871
+	 *
872
+	 * @since 1.0.0
873
+	 * @since 1.6.20 Hook added to filter value.
874
+	 * @package GeoDirectory
875
+	 * @global object $wpdb WordPress Database object.
876
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
877
+	 * @param int $post_id The post ID.
878
+	 * @param string $meta_key The meta key to retrieve.
879
+	 * @param bool $single Optional. Whether to return a single value. Default false.
880
+	 * @todo single variable not yet implemented.
881
+	 * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
882
+	 */
883
+	function geodir_get_post_meta($post_id, $meta_key, $single = false) {
884
+		if (!$post_id) {
885
+			return false;
886
+		}
887
+		global $wpdb, $plugin_prefix;
888
+
889
+		$all_postypes = geodir_get_posttypes();
890
+
891
+		$post_type = get_post_type($post_id);
892
+
893
+		if (!in_array($post_type, $all_postypes))
894
+			return false;
895
+
896
+		$table = $plugin_prefix . $post_type . '_detail';
897
+
898
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
899
+			$meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
900 900
             
901
-            if ($meta_value && $meta_value !== '') {
902
-                $meta_value = maybe_serialize($meta_value);
903
-            }
904
-        } else {
905
-            $meta_value = false;
906
-        }
901
+			if ($meta_value && $meta_value !== '') {
902
+				$meta_value = maybe_serialize($meta_value);
903
+			}
904
+		} else {
905
+			$meta_value = false;
906
+		}
907 907
         
908
-        /**
909
-         * Filter the listing custom meta.
910
-         *
911
-         * @since 1.6.20
912
-         * 
913
-         * @param bool|mixed|null|string $meta_value Will be an array if $single is false. Will be value of meta data field if $single is true.
914
-         * @param int $post_id The post ID.
915
-         * @param string $meta_key The meta key to retrieve.
916
-         * @param bool $single Optional. Whether to return a single value. Default false.
917
-         */
918
-        return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single );
919
-    }
908
+		/**
909
+		 * Filter the listing custom meta.
910
+		 *
911
+		 * @since 1.6.20
912
+		 * 
913
+		 * @param bool|mixed|null|string $meta_value Will be an array if $single is false. Will be value of meta data field if $single is true.
914
+		 * @param int $post_id The post ID.
915
+		 * @param string $meta_key The meta key to retrieve.
916
+		 * @param bool $single Optional. Whether to return a single value. Default false.
917
+		 */
918
+		return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single );
919
+	}
920 920
 }
921 921
 
922 922
 
923 923
 if (!function_exists('geodir_save_post_images')) {
924
-    /**
925
-     * Save post attachments.
926
-     *
927
-     * @since 1.0.0
928
-     * @package GeoDirectory
929
-     * @global object $wpdb WordPress Database object.
930
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
931
-     * @global object $current_user Current user object.
932
-     * @param int $post_id The post ID.
933
-     * @param array $post_image Post image urls as an array.
934
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
935
-     */
936
-    function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
937
-    {
924
+	/**
925
+	 * Save post attachments.
926
+	 *
927
+	 * @since 1.0.0
928
+	 * @package GeoDirectory
929
+	 * @global object $wpdb WordPress Database object.
930
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
931
+	 * @global object $current_user Current user object.
932
+	 * @param int $post_id The post ID.
933
+	 * @param array $post_image Post image urls as an array.
934
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
935
+	 */
936
+	function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
937
+	{
938 938
 
939 939
 
940
-        global $wpdb, $plugin_prefix, $current_user;
940
+		global $wpdb, $plugin_prefix, $current_user;
941 941
 
942
-        $post_type = get_post_type($post_id);
942
+		$post_type = get_post_type($post_id);
943 943
 
944
-        $table = $plugin_prefix . $post_type . '_detail';
944
+		$table = $plugin_prefix . $post_type . '_detail';
945 945
 
946
-        $post_images = geodir_get_images($post_id);
946
+		$post_images = geodir_get_images($post_id);
947 947
 
948
-        $wpdb->query(
949
-            $wpdb->prepare(
950
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
951
-                array($post_id)
952
-            )
953
-        );
948
+		$wpdb->query(
949
+			$wpdb->prepare(
950
+				"UPDATE " . $table . " SET featured_image = '' where post_id =%d",
951
+				array($post_id)
952
+			)
953
+		);
954 954
 
955
-        $invalid_files = $post_images;
956
-        $valid_file_ids = array();
957
-        $valid_files_condition = '';
958
-        $geodir_uploaddir = '';
955
+		$invalid_files = $post_images;
956
+		$valid_file_ids = array();
957
+		$valid_files_condition = '';
958
+		$geodir_uploaddir = '';
959 959
 
960
-        $remove_files = array();
960
+		$remove_files = array();
961 961
 
962
-        if (!empty($post_image)) {
962
+		if (!empty($post_image)) {
963 963
 
964
-            $uploads = wp_upload_dir();
965
-            $uploads_dir = $uploads['path'];
964
+			$uploads = wp_upload_dir();
965
+			$uploads_dir = $uploads['path'];
966 966
 
967
-            $geodir_uploadpath = $uploads['path'];
968
-            $geodir_uploadurl = $uploads['url'];
969
-            $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
967
+			$geodir_uploadpath = $uploads['path'];
968
+			$geodir_uploadurl = $uploads['url'];
969
+			$sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
970 970
 
971
-            $invalid_files = array();
972
-            $postcurr_images = array();
971
+			$invalid_files = array();
972
+			$postcurr_images = array();
973 973
 
974
-            for ($m = 0; $m < count($post_image); $m++) {
975
-                $menu_order = $m + 1;
974
+			for ($m = 0; $m < count($post_image); $m++) {
975
+				$menu_order = $m + 1;
976 976
 
977
-                $file_path = '';
978
-                /* --------- start ------- */
977
+				$file_path = '';
978
+				/* --------- start ------- */
979 979
 
980
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
980
+				$split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
981 981
 
982
-                $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
982
+				$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
983 983
 
984 984
 
985
-                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)))) {
985
+				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)))) {
986 986
 
987
-                    /* --------- end ------- */
988
-                    $curr_img_url = $post_image[$m];
987
+					/* --------- end ------- */
988
+					$curr_img_url = $post_image[$m];
989 989
 
990
-                    $image_name_arr = explode('/', $curr_img_url);
990
+					$image_name_arr = explode('/', $curr_img_url);
991 991
 
992
-                    $count_image_name_arr = count($image_name_arr) - 2;
992
+					$count_image_name_arr = count($image_name_arr) - 2;
993 993
 
994
-                    $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
994
+					$count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
995 995
 
996
-                    $curr_img_dir = $image_name_arr[$count_image_name_arr];
996
+					$curr_img_dir = $image_name_arr[$count_image_name_arr];
997 997
 
998
-                    $filename = end($image_name_arr);
999
-                    if (strpos($filename, '?') !== false) {
1000
-                        list($filename) = explode('?', $filename);
1001
-                    }
998
+					$filename = end($image_name_arr);
999
+					if (strpos($filename, '?') !== false) {
1000
+						list($filename) = explode('?', $filename);
1001
+					}
1002 1002
 
1003
-                    $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
1004
-                    $curr_img_dir = str_replace($filename, "", $curr_img_dir);
1003
+					$curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
1004
+					$curr_img_dir = str_replace($filename, "", $curr_img_dir);
1005 1005
 
1006
-                    $img_name_arr = explode('.', $filename);
1006
+					$img_name_arr = explode('.', $filename);
1007 1007
 
1008
-                    $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
1009
-                    if (!empty($img_name_arr) && count($img_name_arr) > 2) {
1010
-                        $new_img_name_arr = $img_name_arr;
1011
-                        if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
1012
-                            unset($new_img_name_arr[count($img_name_arr) - 1]);
1013
-                            $file_title = implode('.', $new_img_name_arr);
1014
-                        }
1015
-                    }
1016
-                    $file_title = sanitize_file_name($file_title);
1017
-                    $file_name = sanitize_file_name($filename);
1008
+					$file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
1009
+					if (!empty($img_name_arr) && count($img_name_arr) > 2) {
1010
+						$new_img_name_arr = $img_name_arr;
1011
+						if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
1012
+							unset($new_img_name_arr[count($img_name_arr) - 1]);
1013
+							$file_title = implode('.', $new_img_name_arr);
1014
+						}
1015
+					}
1016
+					$file_title = sanitize_file_name($file_title);
1017
+					$file_name = sanitize_file_name($filename);
1018 1018
 
1019
-                    $arr_file_type = wp_check_filetype($filename);
1019
+					$arr_file_type = wp_check_filetype($filename);
1020 1020
 
1021
-                    $uploaded_file_type = $arr_file_type['type'];
1021
+					$uploaded_file_type = $arr_file_type['type'];
1022 1022
 
1023
-                    // Set an array containing a list of acceptable formats
1024
-                    $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1023
+					// Set an array containing a list of acceptable formats
1024
+					$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1025 1025
 
1026
-                    // If the uploaded file is the right format
1027
-                    if (in_array($uploaded_file_type, $allowed_file_types)) {
1028
-                        if (!function_exists('wp_handle_upload')) {
1029
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1030
-                        }
1026
+					// If the uploaded file is the right format
1027
+					if (in_array($uploaded_file_type, $allowed_file_types)) {
1028
+						if (!function_exists('wp_handle_upload')) {
1029
+							require_once(ABSPATH . 'wp-admin/includes/file.php');
1030
+						}
1031 1031
 
1032
-                        if (!is_dir($geodir_uploadpath)) {
1033
-                            mkdir($geodir_uploadpath);
1034
-                        }
1032
+						if (!is_dir($geodir_uploadpath)) {
1033
+							mkdir($geodir_uploadpath);
1034
+						}
1035 1035
 
1036
-                        $external_img = false;
1037
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1038
-                        } else {
1039
-                            $external_img = true;
1040
-                        }
1036
+						$external_img = false;
1037
+						if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1038
+						} else {
1039
+							$external_img = true;
1040
+						}
1041 1041
 
1042
-                        if ($dummy || $external_img) {
1043
-                            $uploaded_file = array();
1044
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1042
+						if ($dummy || $external_img) {
1043
+							$uploaded_file = array();
1044
+							$uploaded = (array)fetch_remote_file($curr_img_url);
1045 1045
 
1046
-                            if (isset($uploaded['error']) && empty($uploaded['error'])) {
1047
-                                $new_name = basename($uploaded['file']);
1048
-                                $uploaded_file = $uploaded;
1049
-                            }else{
1050
-                                print_r($uploaded);exit;
1051
-                            }
1052
-                            $external_img = false;
1053
-                        } else {
1054
-                            $new_name = $post_id . '_' . $file_name;
1046
+							if (isset($uploaded['error']) && empty($uploaded['error'])) {
1047
+								$new_name = basename($uploaded['file']);
1048
+								$uploaded_file = $uploaded;
1049
+							}else{
1050
+								print_r($uploaded);exit;
1051
+							}
1052
+							$external_img = false;
1053
+						} else {
1054
+							$new_name = $post_id . '_' . $file_name;
1055 1055
 
1056
-                            if ($curr_img_dir == $sub_dir) {
1057
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1058
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1059
-                            } else {
1060
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1061
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1062
-                            }
1056
+							if ($curr_img_dir == $sub_dir) {
1057
+								$img_path = $geodir_uploadpath . '/' . $filename;
1058
+								$img_url = $geodir_uploadurl . '/' . $filename;
1059
+							} else {
1060
+								$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1061
+								$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1062
+							}
1063 1063
 
1064
-                            $uploaded_file = '';
1064
+							$uploaded_file = '';
1065 1065
 
1066
-                            if (file_exists($img_path)) {
1067
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1068
-                                $file_path = '';
1069
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1070
-                                $uploaded_file = true;
1071
-                                $file_path = $curr_img_dir . '/' . $filename;
1072
-                            }
1066
+							if (file_exists($img_path)) {
1067
+								$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1068
+								$file_path = '';
1069
+							} else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1070
+								$uploaded_file = true;
1071
+								$file_path = $curr_img_dir . '/' . $filename;
1072
+							}
1073 1073
 
1074
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1075
-                                unlink($img_path);
1076
-                        }
1074
+							if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1075
+								unlink($img_path);
1076
+						}
1077 1077
 
1078
-                        if (!empty($uploaded_file)) {
1079
-                            if (!isset($file_path) || !$file_path) {
1080
-                                $file_path = $sub_dir . '/' . $new_name;
1081
-                            }
1078
+						if (!empty($uploaded_file)) {
1079
+							if (!isset($file_path) || !$file_path) {
1080
+								$file_path = $sub_dir . '/' . $new_name;
1081
+							}
1082 1082
 
1083
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1083
+							$postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1084 1084
 
1085
-                            if ($menu_order == 1) {
1085
+							if ($menu_order == 1) {
1086 1086
 
1087
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1087
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1088 1088
 
1089
-                            }
1089
+							}
1090 1090
 
1091
-                            // Set up options array to add this file as an attachment
1092
-                            $attachment = array();
1093
-                            $attachment['post_id'] = $post_id;
1094
-                            $attachment['title'] = $file_title;
1095
-                            $attachment['content'] = '';
1096
-                            $attachment['file'] = $file_path;
1097
-                            $attachment['mime_type'] = $uploaded_file_type;
1098
-                            $attachment['menu_order'] = $menu_order;
1099
-                            $attachment['is_featured'] = 0;
1091
+							// Set up options array to add this file as an attachment
1092
+							$attachment = array();
1093
+							$attachment['post_id'] = $post_id;
1094
+							$attachment['title'] = $file_title;
1095
+							$attachment['content'] = '';
1096
+							$attachment['file'] = $file_path;
1097
+							$attachment['mime_type'] = $uploaded_file_type;
1098
+							$attachment['menu_order'] = $menu_order;
1099
+							$attachment['is_featured'] = 0;
1100 1100
 
1101
-                            $attachment_set = '';
1101
+							$attachment_set = '';
1102 1102
 
1103
-                            foreach ($attachment as $key => $val) {
1104
-                                if ($val != '')
1105
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1106
-                            }
1103
+							foreach ($attachment as $key => $val) {
1104
+								if ($val != '')
1105
+									$attachment_set .= $key . " = '" . $val . "', ";
1106
+							}
1107 1107
 
1108
-                            $attachment_set = trim($attachment_set, ", ");
1108
+							$attachment_set = trim($attachment_set, ", ");
1109
+
1110
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1109 1111
 
1110
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1112
+							$valid_file_ids[] = $wpdb->insert_id;
1113
+						}
1111 1114
 
1112
-                            $valid_file_ids[] = $wpdb->insert_id;
1113
-                        }
1115
+					}
1114 1116
 
1115
-                    }
1116 1117
 
1118
+				} else {
1119
+					$valid_file_ids[] = $find_image;
1117 1120
 
1118
-                } else {
1119
-                    $valid_file_ids[] = $find_image;
1120
-
1121
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1121
+					$postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1122 1122
 
1123
-                    $wpdb->query(
1124
-                        $wpdb->prepare(
1125
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1126
-                            array($menu_order, $split_img_path[1], $post_id)
1127
-                        )
1128
-                    );
1123
+					$wpdb->query(
1124
+						$wpdb->prepare(
1125
+							"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1126
+							array($menu_order, $split_img_path[1], $post_id)
1127
+						)
1128
+					);
1129 1129
 
1130
-                    if ($menu_order == 1)
1131
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1130
+					if ($menu_order == 1)
1131
+						$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1132 1132
 
1133
-                }
1133
+				}
1134 1134
 
1135 1135
 
1136
-            }
1136
+			}
1137 1137
 
1138
-            if (!empty($valid_file_ids)) {
1138
+			if (!empty($valid_file_ids)) {
1139 1139
 
1140
-                $remove_files = $valid_file_ids;
1140
+				$remove_files = $valid_file_ids;
1141 1141
 
1142
-                $remove_files_length = count($remove_files);
1143
-                $remove_files_format = array_fill(0, $remove_files_length, '%d');
1144
-                $format = implode(',', $remove_files_format);
1145
-                $valid_files_condition = " ID NOT IN ($format) AND ";
1142
+				$remove_files_length = count($remove_files);
1143
+				$remove_files_format = array_fill(0, $remove_files_length, '%d');
1144
+				$format = implode(',', $remove_files_format);
1145
+				$valid_files_condition = " ID NOT IN ($format) AND ";
1146 1146
 
1147
-            }
1147
+			}
1148 1148
 
1149
-            //Get and remove all old images of post from database to set by new order
1149
+			//Get and remove all old images of post from database to set by new order
1150 1150
 
1151
-            if (!empty($post_images)) {
1151
+			if (!empty($post_images)) {
1152 1152
 
1153
-                foreach ($post_images as $img) {
1153
+				foreach ($post_images as $img) {
1154 1154
 
1155
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1155
+					if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1156 1156
 
1157
-                        $invalid_files[] = (object)array('src' => $img->src);
1157
+						$invalid_files[] = (object)array('src' => $img->src);
1158 1158
 
1159
-                    }
1159
+					}
1160 1160
 
1161
-                }
1161
+				}
1162 1162
 
1163
-            }
1163
+			}
1164 1164
 
1165
-            $invalid_files = (object)$invalid_files;
1166
-        }
1165
+			$invalid_files = (object)$invalid_files;
1166
+		}
1167 1167
 
1168
-        $remove_files[] = $post_id;
1168
+		$remove_files[] = $post_id;
1169 1169
 
1170
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1170
+		$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1171 1171
 
1172
-        if (!empty($invalid_files))
1173
-            geodir_remove_attachments($invalid_files);
1174
-    }
1172
+		if (!empty($invalid_files))
1173
+			geodir_remove_attachments($invalid_files);
1174
+	}
1175 1175
 
1176 1176
 }
1177 1177
 
@@ -1185,12 +1185,12 @@  discard block
 block discarded – undo
1185 1185
 function geodir_remove_temp_images()
1186 1186
 {
1187 1187
 
1188
-    global $current_user;
1188
+	global $current_user;
1189 1189
 
1190
-    $uploads = wp_upload_dir();
1191
-    $uploads_dir = $uploads['path'];
1190
+	$uploads = wp_upload_dir();
1191
+	$uploads_dir = $uploads['path'];
1192 1192
 
1193
-    /*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1193
+	/*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1194 1194
 
1195 1195
 			$dirPath = $uploads_dir.'/temp_'.$current_user->data->ID;
1196 1196
 			if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
@@ -1207,8 +1207,8 @@  discard block
 block discarded – undo
1207 1207
 			rmdir($dirPath);
1208 1208
 	}	*/
1209 1209
 
1210
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1211
-    geodir_delete_directory($dirname);
1210
+	$dirname = $uploads_dir . '/temp_' . $current_user->ID;
1211
+	geodir_delete_directory($dirname);
1212 1212
 }
1213 1213
 
1214 1214
 
@@ -1222,131 +1222,131 @@  discard block
 block discarded – undo
1222 1222
  */
1223 1223
 function geodir_delete_directory($dirname)
1224 1224
 {
1225
-    $dir_handle = '';
1226
-    if (is_dir($dirname))
1227
-        $dir_handle = opendir($dirname);
1228
-    if (!$dir_handle)
1229
-        return false;
1230
-    while ($file = readdir($dir_handle)) {
1231
-        if ($file != "." && $file != "..") {
1232
-            if (!is_dir($dirname . "/" . $file))
1233
-                unlink($dirname . "/" . $file);
1234
-            else
1235
-                geodir_delete_directory($dirname . '/' . $file);
1236
-        }
1237
-    }
1238
-    closedir($dir_handle);
1239
-    rmdir($dirname);
1240
-    return true;
1225
+	$dir_handle = '';
1226
+	if (is_dir($dirname))
1227
+		$dir_handle = opendir($dirname);
1228
+	if (!$dir_handle)
1229
+		return false;
1230
+	while ($file = readdir($dir_handle)) {
1231
+		if ($file != "." && $file != "..") {
1232
+			if (!is_dir($dirname . "/" . $file))
1233
+				unlink($dirname . "/" . $file);
1234
+			else
1235
+				geodir_delete_directory($dirname . '/' . $file);
1236
+		}
1237
+	}
1238
+	closedir($dir_handle);
1239
+	rmdir($dirname);
1240
+	return true;
1241 1241
 
1242 1242
 }
1243 1243
 
1244 1244
 
1245 1245
 if (!function_exists('geodir_remove_attachments')) {
1246
-    /**
1247
-     * Remove post attachments.
1248
-     *
1249
-     * @since 1.0.0
1250
-     * @package GeoDirectory
1251
-     * @param array $postcurr_images Array of image objects.
1252
-     */
1253
-    function geodir_remove_attachments($postcurr_images = array())
1254
-    {
1255
-        // Unlink all past images of post
1256
-        if (!empty($postcurr_images)) {
1257
-
1258
-            $uploads = wp_upload_dir();
1259
-            $uploads_dir = $uploads['path'];
1260
-
1261
-            foreach ($postcurr_images as $postimg) {
1262
-                $image_name_arr = explode('/', $postimg->src);
1263
-                $filename = end($image_name_arr);
1264
-                if (file_exists($uploads_dir . '/' . $filename))
1265
-                    unlink($uploads_dir . '/' . $filename);
1266
-            }
1267
-
1268
-        } // endif
1269
-        // Unlink all past images of post end
1270
-    }
1246
+	/**
1247
+	 * Remove post attachments.
1248
+	 *
1249
+	 * @since 1.0.0
1250
+	 * @package GeoDirectory
1251
+	 * @param array $postcurr_images Array of image objects.
1252
+	 */
1253
+	function geodir_remove_attachments($postcurr_images = array())
1254
+	{
1255
+		// Unlink all past images of post
1256
+		if (!empty($postcurr_images)) {
1257
+
1258
+			$uploads = wp_upload_dir();
1259
+			$uploads_dir = $uploads['path'];
1260
+
1261
+			foreach ($postcurr_images as $postimg) {
1262
+				$image_name_arr = explode('/', $postimg->src);
1263
+				$filename = end($image_name_arr);
1264
+				if (file_exists($uploads_dir . '/' . $filename))
1265
+					unlink($uploads_dir . '/' . $filename);
1266
+			}
1267
+
1268
+		} // endif
1269
+		// Unlink all past images of post end
1270
+	}
1271 1271
 }
1272 1272
 
1273 1273
 if (!function_exists('geodir_get_featured_image')) {
1274
-    /**
1275
-     * Gets the post featured image.
1276
-     *
1277
-     * @since 1.0.0
1278
-     * @package GeoDirectory
1279
-     * @global object $wpdb WordPress Database object.
1280
-     * @global object $post The current post object.
1281
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1282
-     * @param int|string $post_id The post ID.
1283
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1284
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1285
-     * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1286
-     * @return bool|object Image details as an object.
1287
-     */
1288
-    function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1289
-    {
1290
-
1291
-        /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1274
+	/**
1275
+	 * Gets the post featured image.
1276
+	 *
1277
+	 * @since 1.0.0
1278
+	 * @package GeoDirectory
1279
+	 * @global object $wpdb WordPress Database object.
1280
+	 * @global object $post The current post object.
1281
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1282
+	 * @param int|string $post_id The post ID.
1283
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1284
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1285
+	 * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1286
+	 * @return bool|object Image details as an object.
1287
+	 */
1288
+	function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1289
+	{
1290
+
1291
+		/*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1292 1292
         $img_arr['path'] = '';
1293 1293
         $img_arr['width'] = '';
1294 1294
         $img_arr['height'] = '';
1295 1295
         $img_arr['title'] = '';
1296 1296
         return (object)$img_arr;*/
1297
-        global $wpdb, $plugin_prefix, $post;
1297
+		global $wpdb, $plugin_prefix, $post;
1298
+
1299
+		if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1300
+			$post_type = $post->post_type;
1301
+		} else {
1302
+			$post_type = get_post_type($post_id);
1303
+		}
1304
+
1305
+		if (!in_array($post_type, geodir_get_posttypes())) {
1306
+			return false;// if not a GD CPT return;
1307
+		}
1308
+
1309
+
1310
+		/**
1311
+		 * Filter to force the list images to be smaller.
1312
+		 * @since 1.6.18
1313
+		 */
1314
+		if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){
1315
+			$fimg = get_the_post_thumbnail_url($post_id,'medium');
1316
+			if($fimg){
1317
+				$uploads = wp_upload_dir(); 
1318
+				$uploads_baseurl = $uploads['baseurl'];
1319
+				$file = str_replace($uploads_baseurl,'',$fimg);
1320
+			}
1321
+		}
1322
+
1323
+		$table = $plugin_prefix . $post_type . '_detail';
1298 1324
 
1299
-        if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1300
-            $post_type = $post->post_type;
1301
-        } else {
1302
-            $post_type = get_post_type($post_id);
1303
-        }
1325
+		if (!$file) {
1326
+			if (isset($post->featured_image)) {
1327
+				$file = $post->featured_image;
1328
+			} else {
1329
+				$file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1330
+			}
1331
+		}
1332
+
1333
+		if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1334
+			$img_arr = array();
1304 1335
 
1305
-        if (!in_array($post_type, geodir_get_posttypes())) {
1306
-            return false;// if not a GD CPT return;
1307
-        }
1336
+			$file_info = pathinfo($file);
1337
+			$sub_dir = '';
1338
+			if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1339
+				$sub_dir = stripslashes_deep($file_info['dirname']);
1340
+			}
1308 1341
 
1342
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1343
+			$uploads_baseurl = $uploads['baseurl'];
1344
+			$uploads_path = $uploads['path'];
1309 1345
 
1310
-        /**
1311
-         * Filter to force the list images to be smaller.
1312
-         * @since 1.6.18
1313
-         */
1314
-        if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){
1315
-            $fimg = get_the_post_thumbnail_url($post_id,'medium');
1316
-            if($fimg){
1317
-                $uploads = wp_upload_dir(); 
1318
-                $uploads_baseurl = $uploads['baseurl'];
1319
-                $file = str_replace($uploads_baseurl,'',$fimg);
1320
-            }
1321
-        }
1322
-
1323
-        $table = $plugin_prefix . $post_type . '_detail';
1324
-
1325
-        if (!$file) {
1326
-            if (isset($post->featured_image)) {
1327
-                $file = $post->featured_image;
1328
-            } else {
1329
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1330
-            }
1331
-        }
1332
-
1333
-        if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1334
-            $img_arr = array();
1335
-
1336
-            $file_info = pathinfo($file);
1337
-            $sub_dir = '';
1338
-            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1339
-                $sub_dir = stripslashes_deep($file_info['dirname']);
1340
-            }
1341
-
1342
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1343
-            $uploads_baseurl = $uploads['baseurl'];
1344
-            $uploads_path = $uploads['path'];
1345
-
1346
-            $file_name = $file_info['basename'];
1347
-
1348
-            $uploads_url = $uploads_baseurl . $sub_dir;
1349
-            /*
1346
+			$file_name = $file_info['basename'];
1347
+
1348
+			$uploads_url = $uploads_baseurl . $sub_dir;
1349
+			/*
1350 1350
              * Allows the filter of image src for such things as CDN change.
1351 1351
              *
1352 1352
              * @since 1.5.7
@@ -1355,158 +1355,158 @@  discard block
 block discarded – undo
1355 1355
              * @param string $uploads_url The server upload directory url.
1356 1356
              * @param string $uploads_baseurl The uploads dir base url.
1357 1357
              */
1358
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1359
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1360
-            $width = 0;
1361
-            $height = 0;
1362
-            if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1363
-                $imagesize = getimagesize($img_arr['path']);
1364
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1365
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1366
-            }
1367
-            $img_arr['width'] = $width;
1368
-            $img_arr['height'] = $height;
1369
-            $img_arr['title'] = '';
1370
-        } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1371
-            foreach ($post_images as $image) {
1372
-                return $image;
1373
-            }
1374
-        } else if ($no_image) {
1375
-            $img_arr = array();
1376
-
1377
-            $default_img = '';
1378
-            if (isset($post->default_category) && $post->default_category) {
1379
-                $default_cat = $post->default_category;
1380
-            } else {
1381
-                $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1382
-            }
1383
-
1384
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1385
-                $default_img = $default_catimg['src'];
1386
-            elseif ($no_image) {
1387
-                $default_img = get_option('geodir_listing_no_img');
1388
-            }
1389
-
1390
-            if (!empty($default_img)) {
1391
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1392
-                $uploads_baseurl = $uploads['baseurl'];
1393
-                $uploads_path = $uploads['path'];
1394
-
1395
-                $img_arr = array();
1396
-
1397
-                $file_info = pathinfo($default_img);
1398
-
1399
-                $file_name = $file_info['basename'];
1400
-
1401
-                $img_arr['src'] = $default_img;
1402
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1403
-
1404
-                $width = 0;
1405
-                $height = 0;
1406
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1407
-                    $imagesize = getimagesize($img_arr['path']);
1408
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1409
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1410
-                }
1411
-                $img_arr['width'] = $width;
1412
-                $img_arr['height'] = $height;
1413
-
1414
-                $img_arr['title'] = ''; // add the title to the array
1415
-            }
1416
-        }
1417
-
1418
-        if (!empty($img_arr))
1419
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1420
-        else
1421
-            return false;
1422
-    }
1358
+			$img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1359
+			$img_arr['path'] = $uploads_path . '/' . $file_name;
1360
+			$width = 0;
1361
+			$height = 0;
1362
+			if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1363
+				$imagesize = getimagesize($img_arr['path']);
1364
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1365
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1366
+			}
1367
+			$img_arr['width'] = $width;
1368
+			$img_arr['height'] = $height;
1369
+			$img_arr['title'] = '';
1370
+		} elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1371
+			foreach ($post_images as $image) {
1372
+				return $image;
1373
+			}
1374
+		} else if ($no_image) {
1375
+			$img_arr = array();
1376
+
1377
+			$default_img = '';
1378
+			if (isset($post->default_category) && $post->default_category) {
1379
+				$default_cat = $post->default_category;
1380
+			} else {
1381
+				$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1382
+			}
1383
+
1384
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1385
+				$default_img = $default_catimg['src'];
1386
+			elseif ($no_image) {
1387
+				$default_img = get_option('geodir_listing_no_img');
1388
+			}
1389
+
1390
+			if (!empty($default_img)) {
1391
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1392
+				$uploads_baseurl = $uploads['baseurl'];
1393
+				$uploads_path = $uploads['path'];
1394
+
1395
+				$img_arr = array();
1396
+
1397
+				$file_info = pathinfo($default_img);
1398
+
1399
+				$file_name = $file_info['basename'];
1400
+
1401
+				$img_arr['src'] = $default_img;
1402
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1403
+
1404
+				$width = 0;
1405
+				$height = 0;
1406
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1407
+					$imagesize = getimagesize($img_arr['path']);
1408
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1409
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1410
+				}
1411
+				$img_arr['width'] = $width;
1412
+				$img_arr['height'] = $height;
1413
+
1414
+				$img_arr['title'] = ''; // add the title to the array
1415
+			}
1416
+		}
1417
+
1418
+		if (!empty($img_arr))
1419
+			return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1420
+		else
1421
+			return false;
1422
+	}
1423 1423
 }
1424 1424
 
1425 1425
 if (!function_exists('geodir_show_featured_image')) {
1426
-    /**
1427
-     * Gets the post featured image.
1428
-     *
1429
-     * @since 1.0.0
1430
-     * @package GeoDirectory
1431
-     * @param int|string $post_id The post ID.
1432
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1433
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1434
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1435
-     * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1436
-     * @return bool|string Returns image html.
1437
-     */
1438
-    function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1439
-    {
1440
-        $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1441
-
1442
-        $html = geodir_show_image($image, $size, $no_image, false);
1443
-
1444
-        if (!empty($html) && $echo) {
1445
-            echo $html;
1446
-        } elseif (!empty($html)) {
1447
-            return $html;
1448
-        } else
1449
-            return false;
1450
-    }
1426
+	/**
1427
+	 * Gets the post featured image.
1428
+	 *
1429
+	 * @since 1.0.0
1430
+	 * @package GeoDirectory
1431
+	 * @param int|string $post_id The post ID.
1432
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1433
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1434
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1435
+	 * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1436
+	 * @return bool|string Returns image html.
1437
+	 */
1438
+	function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1439
+	{
1440
+		$image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1441
+
1442
+		$html = geodir_show_image($image, $size, $no_image, false);
1443
+
1444
+		if (!empty($html) && $echo) {
1445
+			echo $html;
1446
+		} elseif (!empty($html)) {
1447
+			return $html;
1448
+		} else
1449
+			return false;
1450
+	}
1451 1451
 }
1452 1452
 
1453 1453
 if (!function_exists('geodir_get_images')) {
1454
-    /**
1455
-     * Gets the post images.
1456
-     *
1457
-     * @since 1.0.0
1458
-     * @package GeoDirectory
1459
-     * @global object $wpdb WordPress Database object.
1460
-     * @param int $post_id The post ID.
1461
-     * @param string $img_size Optional. Thumbnail size.
1462
-     * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1463
-     * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1464
-     * @param int|string $limit Optional. Number of images.
1465
-     * @return array|bool Returns images as an array. Each item is an object.
1466
-     */
1467
-    function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1468
-    {
1469
-        global $wpdb;
1470
-        if ($limit) {
1471
-            $limit_q = " LIMIT $limit ";
1472
-        } else {
1473
-            $limit_q = '';
1474
-        }
1475
-        $not_featured = '';
1476
-        $sub_dir = '';
1477
-        if (!$add_featured)
1478
-            $not_featured = " AND is_featured = 0 ";
1479
-
1480
-        $arrImages = $wpdb->get_results(
1481
-            $wpdb->prepare(
1482
-                "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 ",
1483
-                array('%image%', $post_id)
1484
-            )
1485
-        );
1486
-
1487
-        $counter = 0;
1488
-        $return_arr = array();
1489
-
1490
-        if (!empty($arrImages)) {
1491
-            foreach ($arrImages as $attechment) {
1492
-
1493
-                $img_arr = array();
1494
-                $img_arr['id'] = $attechment->ID;
1495
-                $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1496
-
1497
-                $file_info = pathinfo($attechment->file);
1498
-
1499
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1500
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1501
-
1502
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1503
-                $uploads_baseurl = $uploads['baseurl'];
1504
-                $uploads_path = $uploads['path'];
1505
-
1506
-                $file_name = $file_info['basename'];
1507
-
1508
-                $uploads_url = $uploads_baseurl . $sub_dir;
1509
-                /*
1454
+	/**
1455
+	 * Gets the post images.
1456
+	 *
1457
+	 * @since 1.0.0
1458
+	 * @package GeoDirectory
1459
+	 * @global object $wpdb WordPress Database object.
1460
+	 * @param int $post_id The post ID.
1461
+	 * @param string $img_size Optional. Thumbnail size.
1462
+	 * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1463
+	 * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1464
+	 * @param int|string $limit Optional. Number of images.
1465
+	 * @return array|bool Returns images as an array. Each item is an object.
1466
+	 */
1467
+	function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1468
+	{
1469
+		global $wpdb;
1470
+		if ($limit) {
1471
+			$limit_q = " LIMIT $limit ";
1472
+		} else {
1473
+			$limit_q = '';
1474
+		}
1475
+		$not_featured = '';
1476
+		$sub_dir = '';
1477
+		if (!$add_featured)
1478
+			$not_featured = " AND is_featured = 0 ";
1479
+
1480
+		$arrImages = $wpdb->get_results(
1481
+			$wpdb->prepare(
1482
+				"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 ",
1483
+				array('%image%', $post_id)
1484
+			)
1485
+		);
1486
+
1487
+		$counter = 0;
1488
+		$return_arr = array();
1489
+
1490
+		if (!empty($arrImages)) {
1491
+			foreach ($arrImages as $attechment) {
1492
+
1493
+				$img_arr = array();
1494
+				$img_arr['id'] = $attechment->ID;
1495
+				$img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1496
+
1497
+				$file_info = pathinfo($attechment->file);
1498
+
1499
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1500
+					$sub_dir = stripslashes_deep($file_info['dirname']);
1501
+
1502
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1503
+				$uploads_baseurl = $uploads['baseurl'];
1504
+				$uploads_path = $uploads['path'];
1505
+
1506
+				$file_name = $file_info['basename'];
1507
+
1508
+				$uploads_url = $uploads_baseurl . $sub_dir;
1509
+				/*
1510 1510
                 * Allows the filter of image src for such things as CDN change.
1511 1511
                 *
1512 1512
                 * @since 1.5.7
@@ -1515,533 +1515,533 @@  discard block
 block discarded – undo
1515 1515
                 * @param string $uploads_url The server upload directory url.
1516 1516
                 * @param string $uploads_baseurl The uploads dir base url.
1517 1517
                 */
1518
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1519
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1520
-                $width = 0;
1521
-                $height = 0;
1522
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1523
-                    $imagesize = getimagesize($img_arr['path']);
1524
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1525
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1526
-                }
1527
-                $img_arr['width'] = $width;
1528
-                $img_arr['height'] = $height;
1529
-
1530
-                $img_arr['file'] = $file_name; // add the title to the array
1531
-                $img_arr['title'] = $attechment->title; // add the title to the array
1532
-                $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1533
-                $img_arr['content'] = $attechment->content; // add the description to the array
1534
-                $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1535
-
1536
-                $return_arr[] = (object)$img_arr;
1537
-
1538
-                $counter++;
1539
-            }
1540
-            //return (object)$return_arr;
1541
-            /**
1542
-             * Filter the images array so things can be changed.
1543
-             *
1544
-             * @since 1.6.20
1545
-             * @param array $return_arr The array of image objects.
1546
-             */
1547
-            return apply_filters('geodir_get_images_arr',$return_arr);
1548
-        } else if ($no_images) {
1549
-            $default_img = '';
1550
-            $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1551
-            $post_type = get_post_type($post_id);
1552
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1553
-                $default_img = $default_catimg['src'];
1554
-            elseif ($no_images) {
1555
-                $default_img = get_option('geodir_listing_no_img');
1556
-            }
1557
-
1558
-            if (!empty($default_img)) {
1559
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1518
+				$img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1519
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1520
+				$width = 0;
1521
+				$height = 0;
1522
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1523
+					$imagesize = getimagesize($img_arr['path']);
1524
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1525
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1526
+				}
1527
+				$img_arr['width'] = $width;
1528
+				$img_arr['height'] = $height;
1529
+
1530
+				$img_arr['file'] = $file_name; // add the title to the array
1531
+				$img_arr['title'] = $attechment->title; // add the title to the array
1532
+				$img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1533
+				$img_arr['content'] = $attechment->content; // add the description to the array
1534
+				$img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1535
+
1536
+				$return_arr[] = (object)$img_arr;
1537
+
1538
+				$counter++;
1539
+			}
1540
+			//return (object)$return_arr;
1541
+			/**
1542
+			 * Filter the images array so things can be changed.
1543
+			 *
1544
+			 * @since 1.6.20
1545
+			 * @param array $return_arr The array of image objects.
1546
+			 */
1547
+			return apply_filters('geodir_get_images_arr',$return_arr);
1548
+		} else if ($no_images) {
1549
+			$default_img = '';
1550
+			$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1551
+			$post_type = get_post_type($post_id);
1552
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1553
+				$default_img = $default_catimg['src'];
1554
+			elseif ($no_images) {
1555
+				$default_img = get_option('geodir_listing_no_img');
1556
+			}
1557
+
1558
+			if (!empty($default_img)) {
1559
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1560 1560
                 
1561
-                $image_path = $default_img;
1562
-                if (!path_is_absolute($image_path)) {
1563
-                    $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1564
-                }
1565
-
1566
-                $file_info = pathinfo($default_img);
1567
-                $file_name = $file_info['basename'];
1568
-
1569
-                $width = '';
1570
-                $height = '';
1571
-                if (is_file($image_path) && file_exists($image_path)) {
1572
-                    $imagesize = getimagesize($image_path);
1573
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1574
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1575
-                }
1561
+				$image_path = $default_img;
1562
+				if (!path_is_absolute($image_path)) {
1563
+					$image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1564
+				}
1565
+
1566
+				$file_info = pathinfo($default_img);
1567
+				$file_name = $file_info['basename'];
1568
+
1569
+				$width = '';
1570
+				$height = '';
1571
+				if (is_file($image_path) && file_exists($image_path)) {
1572
+					$imagesize = getimagesize($image_path);
1573
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1574
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1575
+				}
1576 1576
                 
1577
-                $img_arr = array();
1578
-                $img_arr['src'] = $default_img;
1579
-                $img_arr['path'] = $image_path;
1580
-                $img_arr['width'] = $width;
1581
-                $img_arr['height'] = $height;
1582
-                $img_arr['file'] = $file_name; // add the title to the array
1583
-                $img_arr['title'] = $file_info['filename']; // add the title to the array
1584
-                $img_arr['content'] = $file_info['filename']; // add the description to the array
1585
-
1586
-                $return_arr[] = (object)$img_arr;
1587
-
1588
-                /**
1589
-                 * Filter the images array so things can be changed.
1590
-                 * 
1591
-                 * @since 1.6.20
1592
-                 * @param array $return_arr The array of image objects.
1593
-                 */
1594
-                return apply_filters('geodir_get_images_arr',$return_arr);
1595
-            } else
1596
-                return false;
1597
-        }
1598
-    }
1577
+				$img_arr = array();
1578
+				$img_arr['src'] = $default_img;
1579
+				$img_arr['path'] = $image_path;
1580
+				$img_arr['width'] = $width;
1581
+				$img_arr['height'] = $height;
1582
+				$img_arr['file'] = $file_name; // add the title to the array
1583
+				$img_arr['title'] = $file_info['filename']; // add the title to the array
1584
+				$img_arr['content'] = $file_info['filename']; // add the description to the array
1585
+
1586
+				$return_arr[] = (object)$img_arr;
1587
+
1588
+				/**
1589
+				 * Filter the images array so things can be changed.
1590
+				 * 
1591
+				 * @since 1.6.20
1592
+				 * @param array $return_arr The array of image objects.
1593
+				 */
1594
+				return apply_filters('geodir_get_images_arr',$return_arr);
1595
+			} else
1596
+				return false;
1597
+		}
1598
+	}
1599 1599
 }
1600 1600
 
1601 1601
 if (!function_exists('geodir_show_image')) {
1602
-    /**
1603
-     * Show image using image details.
1604
-     *
1605
-     * @since 1.0.0
1606
-     * @package GeoDirectory
1607
-     * @param array|object $request Image info either as an array or object.
1608
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1609
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1610
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1611
-     * @return bool|string Returns image html.
1612
-     */
1613
-    function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1614
-    {
1615
-        $image = new stdClass();
1616
-
1617
-        $html = '';
1618
-        if (!empty($request)) {
1619
-            if (!is_object($request)){
1620
-                $request = (object)$request;
1621
-            }
1622
-
1623
-            if (isset($request->src) && !isset($request->path)) {
1624
-                $request->path = $request->src;
1625
-            }
1626
-
1627
-            /*
1602
+	/**
1603
+	 * Show image using image details.
1604
+	 *
1605
+	 * @since 1.0.0
1606
+	 * @package GeoDirectory
1607
+	 * @param array|object $request Image info either as an array or object.
1608
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1609
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1610
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1611
+	 * @return bool|string Returns image html.
1612
+	 */
1613
+	function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1614
+	{
1615
+		$image = new stdClass();
1616
+
1617
+		$html = '';
1618
+		if (!empty($request)) {
1619
+			if (!is_object($request)){
1620
+				$request = (object)$request;
1621
+			}
1622
+
1623
+			if (isset($request->src) && !isset($request->path)) {
1624
+				$request->path = $request->src;
1625
+			}
1626
+
1627
+			/*
1628 1628
              * getimagesize() works faster from path than url so we try and get path if we can.
1629 1629
              */
1630
-            $upload_dir = wp_upload_dir();
1631
-            $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1632
-            $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1633
-            if (strpos($img_no_http, $upload_no_http) !== false) {
1634
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1635
-            }
1630
+			$upload_dir = wp_upload_dir();
1631
+			$img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1632
+			$upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1633
+			if (strpos($img_no_http, $upload_no_http) !== false) {
1634
+				$request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1635
+			}
1636 1636
             
1637
-            $width = 0;
1638
-            $height = 0;
1639
-            if (is_file($request->path) && file_exists($request->path)) {
1640
-                $imagesize = getimagesize($request->path);
1641
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1642
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1643
-            }
1644
-
1645
-            $image->src = $request->src;
1646
-            $image->width = $width;
1647
-            $image->height = $height;
1648
-
1649
-            $max_size = (object)geodir_get_imagesize($size);
1650
-
1651
-            if (!is_wp_error($max_size)) {
1652
-                if ($image->width) {
1653
-                    if ($image->height >= $image->width) {
1654
-                        $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1655
-                    } else if ($image->width < ($max_size->h)) {
1656
-                        $width_per = round((($image->width / $max_size->w) * 100), 2);
1657
-                    } else
1658
-                        $width_per = 100;
1659
-                }
1660
-
1661
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1662
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1663
-                } else {
1664
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1665
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1666
-                    }else{
1667
-                        //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1668
-                        //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1669
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1670
-
1671
-                    }
1672
-
1673
-                }
1674
-            }
1675
-        }
1676
-
1677
-        if (!empty($html) && $echo) {
1678
-            echo $html;
1679
-        } elseif (!empty($html)) {
1680
-            return $html;
1681
-        } else
1682
-            return false;
1683
-    }
1684
-}
1637
+			$width = 0;
1638
+			$height = 0;
1639
+			if (is_file($request->path) && file_exists($request->path)) {
1640
+				$imagesize = getimagesize($request->path);
1641
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1642
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1643
+			}
1685 1644
 
1686
-if (!function_exists('geodir_set_post_terms')) {
1687
-    /**
1688
-     * Set post Categories.
1689
-     *
1690
-     * @since 1.0.0
1691
-     * @package GeoDirectory
1692
-     * @global object $wpdb WordPress Database object.
1693
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1694
-     * @param int $post_id The post ID.
1695
-     * @param array $terms An array of term objects.
1696
-     * @param array $tt_ids An array of term taxonomy IDs.
1697
-     * @param string $taxonomy Taxonomy slug.
1698
-     */
1699
-    function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1700
-    {
1701
-        global $wpdb, $plugin_prefix;
1645
+			$image->src = $request->src;
1646
+			$image->width = $width;
1647
+			$image->height = $height;
1702 1648
 
1703
-        $post_type = get_post_type($post_id);
1649
+			$max_size = (object)geodir_get_imagesize($size);
1704 1650
 
1705
-        $table = $plugin_prefix . $post_type . '_detail';
1651
+			if (!is_wp_error($max_size)) {
1652
+				if ($image->width) {
1653
+					if ($image->height >= $image->width) {
1654
+						$width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1655
+					} else if ($image->width < ($max_size->h)) {
1656
+						$width_per = round((($image->width / $max_size->w) * 100), 2);
1657
+					} else
1658
+						$width_per = 100;
1659
+				}
1706 1660
 
1707
-        if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1661
+				if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1662
+					$html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1663
+				} else {
1664
+					if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1665
+						$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1666
+					}else{
1667
+						//$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1668
+						//$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1669
+						$html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1708 1670
 
1709
-            if ($taxonomy == $post_type . '_tags') {
1710
-                if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1711
-                    geodir_save_post_meta($post_id, 'post_tags', $terms);
1712
-                }
1713
-            } elseif ($taxonomy == $post_type . 'category') {
1714
-                $srcharr = array('"', '\\');
1715
-                $replarr = array("&quot;", '');
1671
+					}
1716 1672
 
1717
-                $post_obj = get_post($post_id);
1673
+				}
1674
+			}
1675
+		}
1676
+
1677
+		if (!empty($html) && $echo) {
1678
+			echo $html;
1679
+		} elseif (!empty($html)) {
1680
+			return $html;
1681
+		} else
1682
+			return false;
1683
+	}
1684
+}
1718 1685
 
1719
-                $cat_ids = array('0');
1720
-                if (is_array($tt_ids))
1721
-                    $cat_ids = $tt_ids;
1686
+if (!function_exists('geodir_set_post_terms')) {
1687
+	/**
1688
+	 * Set post Categories.
1689
+	 *
1690
+	 * @since 1.0.0
1691
+	 * @package GeoDirectory
1692
+	 * @global object $wpdb WordPress Database object.
1693
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1694
+	 * @param int $post_id The post ID.
1695
+	 * @param array $terms An array of term objects.
1696
+	 * @param array $tt_ids An array of term taxonomy IDs.
1697
+	 * @param string $taxonomy Taxonomy slug.
1698
+	 */
1699
+	function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1700
+	{
1701
+		global $wpdb, $plugin_prefix;
1702
+
1703
+		$post_type = get_post_type($post_id);
1704
+
1705
+		$table = $plugin_prefix . $post_type . '_detail';
1706
+
1707
+		if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1708
+
1709
+			if ($taxonomy == $post_type . '_tags') {
1710
+				if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1711
+					geodir_save_post_meta($post_id, 'post_tags', $terms);
1712
+				}
1713
+			} elseif ($taxonomy == $post_type . 'category') {
1714
+				$srcharr = array('"', '\\');
1715
+				$replarr = array("&quot;", '');
1722 1716
 
1717
+				$post_obj = get_post($post_id);
1723 1718
 
1724
-                if (!empty($cat_ids)) {
1725
-                    $cat_ids_array = $cat_ids;
1726
-                    $cat_ids_length = count($cat_ids_array);
1727
-                    $cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1728
-                    $format = implode(',', $cat_ids_format);
1719
+				$cat_ids = array('0');
1720
+				if (is_array($tt_ids))
1721
+					$cat_ids = $tt_ids;
1729 1722
 
1730
-                    $cat_ids_array_del = $cat_ids_array;
1731
-                    $cat_ids_array_del[] = $post_id;
1732 1723
 
1733
-                    $wpdb->get_var(
1734
-                        $wpdb->prepare(
1735
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1736
-                            $cat_ids_array_del
1737
-                        )
1738
-                    );
1724
+				if (!empty($cat_ids)) {
1725
+					$cat_ids_array = $cat_ids;
1726
+					$cat_ids_length = count($cat_ids_array);
1727
+					$cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1728
+					$format = implode(',', $cat_ids_format);
1739 1729
 
1730
+					$cat_ids_array_del = $cat_ids_array;
1731
+					$cat_ids_array_del[] = $post_id;
1740 1732
 
1741
-                    $post_term = $wpdb->get_col(
1742
-                        $wpdb->prepare(
1743
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1744
-                            $cat_ids_array
1745
-                        )
1746
-                    );
1733
+					$wpdb->get_var(
1734
+						$wpdb->prepare(
1735
+							"DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1736
+							$cat_ids_array_del
1737
+						)
1738
+					);
1747 1739
 
1748
-                }
1749 1740
 
1750
-                $post_marker_json = '';
1741
+					$post_term = $wpdb->get_col(
1742
+						$wpdb->prepare(
1743
+							"SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1744
+							$cat_ids_array
1745
+						)
1746
+					);
1747
+
1748
+				}
1751 1749
 
1752
-                if (!empty($post_term)):
1750
+				$post_marker_json = '';
1753 1751
 
1754
-                    foreach ($post_term as $cat_id):
1752
+				if (!empty($post_term)):
1755 1753
 
1756
-                        $term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1757
-                        $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1754
+					foreach ($post_term as $cat_id):
1758 1755
 
1759
-                        $post_title = $post_obj->title;
1760
-                        $title = str_replace($srcharr, $replarr, $post_title);
1756
+						$term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1757
+						$term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1761 1758
 
1762
-                        $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1763
-                        $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1759
+						$post_title = $post_obj->title;
1760
+						$title = str_replace($srcharr, $replarr, $post_title);
1764 1761
 
1765
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1766
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1762
+						$lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1763
+						$lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1767 1764
 
1768
-                        $json = '{';
1769
-                        $json .= '"id":"' . $post_id . '",';
1770
-                        $json .= '"lat_pos": "' . $lat . '",';
1771
-                        $json .= '"long_pos": "' . $lng . '",';
1772
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1773
-                        $json .= '"icon":"' . $term_icon . '",';
1774
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1775
-                        $json .= '}';
1765
+						$timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1766
+						$timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1776 1767
 
1768
+						$json = '{';
1769
+						$json .= '"id":"' . $post_id . '",';
1770
+						$json .= '"lat_pos": "' . $lat . '",';
1771
+						$json .= '"long_pos": "' . $lng . '",';
1772
+						$json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1773
+						$json .= '"icon":"' . $term_icon . '",';
1774
+						$json .= '"group":"catgroup' . $cat_id . '"';
1775
+						$json .= '}';
1777 1776
 
1778
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1779
-                            $post_marker_json = $json;
1780 1777
 
1778
+						if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1779
+							$post_marker_json = $json;
1781 1780
 
1782
-                        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)))) {
1783 1781
 
1784
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1782
+						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)))) {
1783
+
1784
+							$json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1785 1785
 										post_title = %s,
1786 1786
 										json = %s
1787 1787
 										WHERE post_id = %d AND cat_id = %d ",
1788
-                                array($post_title, $json, $post_id, $cat_id));
1788
+								array($post_title, $json, $post_id, $cat_id));
1789 1789
 
1790
-                        } else {
1790
+						} else {
1791 1791
 
1792
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1792
+							$json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1793 1793
 										post_id = %d,
1794 1794
 										post_title = %s,
1795 1795
 										cat_id = %d,
1796 1796
 										json = %s",
1797
-                                array($post_id, $post_title, $cat_id, $json));
1797
+								array($post_id, $post_title, $cat_id, $json));
1798 1798
 
1799
-                        }
1799
+						}
1800 1800
 
1801
-                        $wpdb->query($json_query);
1801
+						$wpdb->query($json_query);
1802 1802
 
1803
-                    endforeach;
1803
+					endforeach;
1804 1804
 
1805
-                endif;
1805
+				endif;
1806 1806
 
1807
-                if (!empty($post_term) && is_array($post_term)) {
1808
-                    $categories = implode(',', $post_term);
1807
+				if (!empty($post_term) && is_array($post_term)) {
1808
+					$categories = implode(',', $post_term);
1809 1809
 
1810
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1810
+					if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1811 1811
 
1812
-                    if (empty($post_marker_json))
1813
-                        $post_marker_json = isset($json) ? $json : '';
1812
+					if (empty($post_marker_json))
1813
+						$post_marker_json = isset($json) ? $json : '';
1814 1814
 
1815
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1815
+					if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1816 1816
 
1817
-                        $wpdb->query(
1818
-                            $wpdb->prepare(
1819
-                                "UPDATE " . $table . " SET
1817
+						$wpdb->query(
1818
+							$wpdb->prepare(
1819
+								"UPDATE " . $table . " SET
1820 1820
 								" . $taxonomy . " = %s,
1821 1821
 								marker_json = %s
1822 1822
 								where post_id = %d",
1823
-                                array($categories, $post_marker_json, $post_id)
1824
-                            )
1825
-                        );
1823
+								array($categories, $post_marker_json, $post_id)
1824
+							)
1825
+						);
1826 1826
 
1827
-                        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1827
+						if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1828 1828
 
1829
-                            $categories = trim($categories, ',');
1829
+							$categories = trim($categories, ',');
1830 1830
 
1831
-                            if ($categories) {
1831
+							if ($categories) {
1832 1832
 
1833
-                                $categories = explode(',', $categories);
1833
+								$categories = explode(',', $categories);
1834 1834
 
1835
-                                $default_category = geodir_get_post_meta($post_id, 'default_category', true);
1835
+								$default_category = geodir_get_post_meta($post_id, 'default_category', true);
1836 1836
 
1837
-                                if (!in_array($default_category, $categories)) {
1837
+								if (!in_array($default_category, $categories)) {
1838 1838
 
1839
-                                    $wpdb->query(
1840
-                                        $wpdb->prepare(
1841
-                                            "UPDATE " . $table . " SET
1839
+									$wpdb->query(
1840
+										$wpdb->prepare(
1841
+											"UPDATE " . $table . " SET
1842 1842
 											default_category = %s
1843 1843
 											where post_id = %d",
1844
-                                            array($categories[0], $post_id)
1845
-                                        )
1846
-                                    );
1844
+											array($categories[0], $post_id)
1845
+										)
1846
+									);
1847 1847
 
1848
-                                    $default_category = $categories[0];
1848
+									$default_category = $categories[0];
1849 1849
 
1850
-                                }
1850
+								}
1851 1851
 
1852
-                                if ($default_category == '')
1853
-                                    $default_category = $categories[0];
1852
+								if ($default_category == '')
1853
+									$default_category = $categories[0];
1854 1854
 
1855
-                                geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1855
+								geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1856 1856
 
1857
-                            }
1857
+							}
1858 1858
 
1859
-                        }
1859
+						}
1860 1860
 
1861 1861
 
1862
-                    } else {
1862
+					} else {
1863 1863
 
1864
-                        $wpdb->query(
1865
-                            $wpdb->prepare(
1866
-                                "INSERT INTO " . $table . " SET
1864
+						$wpdb->query(
1865
+							$wpdb->prepare(
1866
+								"INSERT INTO " . $table . " SET
1867 1867
 								post_id = %d,
1868 1868
 								" . $taxonomy . " = %s,
1869 1869
 								marker_json = %s ",
1870 1870
 
1871
-                                array($post_id, $categories, $post_marker_json)
1872
-                            )
1873
-                        );
1874
-                    }
1875
-                }
1876
-            }
1877
-        }
1878
-    }
1871
+								array($post_id, $categories, $post_marker_json)
1872
+							)
1873
+						);
1874
+					}
1875
+				}
1876
+			}
1877
+		}
1878
+	}
1879 1879
 }
1880 1880
 
1881 1881
 if (!function_exists('geodir_get_infowindow_html')) {
1882
-    /**
1883
-     * Set post Map Marker info html.
1884
-     *
1885
-     * @since 1.0.0
1886
-     * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1887
-     * @since 1.6.16 Changes for disable review stars for certain post type.
1888
-     * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info.
1889
-     * @package GeoDirectory
1890
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
1891
-     * @global object $gd_session GeoDirectory Session object.
1892
-     * @param object $postinfo_obj The post details object.
1893
-     * @param string $post_preview Is this a post preview?.
1894
-     * @global object $post WordPress Post object.
1895
-     * @return mixed|string|void
1896
-     */
1897
-    function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
1898
-        global $preview, $post, $gd_session;
1899
-        $srcharr = array("'", "/", "-", '"', '\\');
1900
-        $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1901
-
1902
-        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1903
-            $ID = '';
1904
-            $plink = '';
1905
-
1906
-            if (isset($postinfo_obj->pid)) {
1907
-                $ID = $postinfo_obj->pid;
1908
-                $plink = get_permalink($ID);
1909
-            }
1910
-
1911
-            $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1912
-            $lat = $postinfo_obj->post_latitude;
1913
-            $lng = $postinfo_obj->post_longitude;
1914
-        } else {
1915
-            $ID = $postinfo_obj->post_id;
1916
-            $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1917
-            $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1918
-            $plink = get_permalink($ID);
1919
-            $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1920
-            $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1921
-        }
1882
+	/**
1883
+	 * Set post Map Marker info html.
1884
+	 *
1885
+	 * @since 1.0.0
1886
+	 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1887
+	 * @since 1.6.16 Changes for disable review stars for certain post type.
1888
+	 * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info.
1889
+	 * @package GeoDirectory
1890
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
1891
+	 * @global object $gd_session GeoDirectory Session object.
1892
+	 * @param object $postinfo_obj The post details object.
1893
+	 * @param string $post_preview Is this a post preview?.
1894
+	 * @global object $post WordPress Post object.
1895
+	 * @return mixed|string|void
1896
+	 */
1897
+	function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
1898
+		global $preview, $post, $gd_session;
1899
+		$srcharr = array("'", "/", "-", '"', '\\');
1900
+		$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1901
+
1902
+		if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1903
+			$ID = '';
1904
+			$plink = '';
1905
+
1906
+			if (isset($postinfo_obj->pid)) {
1907
+				$ID = $postinfo_obj->pid;
1908
+				$plink = get_permalink($ID);
1909
+			}
1910
+
1911
+			$title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1912
+			$lat = $postinfo_obj->post_latitude;
1913
+			$lng = $postinfo_obj->post_longitude;
1914
+		} else {
1915
+			$ID = $postinfo_obj->post_id;
1916
+			$title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1917
+			$title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1918
+			$plink = get_permalink($ID);
1919
+			$lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1920
+			$lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1921
+		}
1922 1922
         
1923
-        // Some theme overwrites global gd listing $post
1924
-        if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
1925
-            $post = geodir_get_post_info($ID);
1926
-        }
1923
+		// Some theme overwrites global gd listing $post
1924
+		if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
1925
+			$post = geodir_get_post_info($ID);
1926
+		}
1927 1927
         
1928
-        $post_type = $ID ? get_post_type($ID) : '';
1929
-
1930
-        // filter field as per price package
1931
-        global $geodir_addon_list;
1932
-        if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1933
-            $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1934
-            $field_name = 'geodir_contact';
1935
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1936
-                $contact = '';
1937
-            }
1938
-
1939
-            $field_name = 'geodir_timing';
1940
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1941
-                $timing = '';
1942
-            }
1943
-        }
1944
-
1945
-        if ($lat && $lng) {
1946
-            ob_start(); ?>
1928
+		$post_type = $ID ? get_post_type($ID) : '';
1929
+
1930
+		// filter field as per price package
1931
+		global $geodir_addon_list;
1932
+		if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1933
+			$package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1934
+			$field_name = 'geodir_contact';
1935
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1936
+				$contact = '';
1937
+			}
1938
+
1939
+			$field_name = 'geodir_timing';
1940
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1941
+				$timing = '';
1942
+			}
1943
+		}
1944
+
1945
+		if ($lat && $lng) {
1946
+			ob_start(); ?>
1947 1947
             <div class="gd-bubble" style="">
1948 1948
                 <div class="gd-bubble-inside">
1949 1949
                     <?php
1950
-                    $comment_count = '';
1951
-                    $rating_star = '';
1952
-                    if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1953
-                        $rating_star = '';
1954
-                        $comment_count = geodir_get_review_count_total($ID);
1955
-
1956
-                        if (!$preview) {
1957
-                            $post_avgratings = geodir_get_post_rating($ID);
1958
-
1959
-                            $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1960
-
1961
-                            /**
1962
-                             * Filter to change rating stars
1963
-                             *
1964
-                             * You can use this filter to change Rating stars.
1965
-                             *
1966
-                             * @since 1.0.0
1967
-                             * @package GeoDirectory
1968
-                             * @param string $rating_star Rating stars.
1969
-                             * @param float $post_avgratings Average ratings of the post.
1970
-                             * @param int $ID The post ID.
1971
-                             */
1972
-                            $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1973
-                        }
1974
-                    }
1975
-                    ?>
1950
+					$comment_count = '';
1951
+					$rating_star = '';
1952
+					if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1953
+						$rating_star = '';
1954
+						$comment_count = geodir_get_review_count_total($ID);
1955
+
1956
+						if (!$preview) {
1957
+							$post_avgratings = geodir_get_post_rating($ID);
1958
+
1959
+							$rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1960
+
1961
+							/**
1962
+							 * Filter to change rating stars
1963
+							 *
1964
+							 * You can use this filter to change Rating stars.
1965
+							 *
1966
+							 * @since 1.0.0
1967
+							 * @package GeoDirectory
1968
+							 * @param string $rating_star Rating stars.
1969
+							 * @param float $post_avgratings Average ratings of the post.
1970
+							 * @param int $ID The post ID.
1971
+							 */
1972
+							$rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1973
+						}
1974
+					}
1975
+					?>
1976 1976
                     <div class="geodir-bubble_desc">
1977 1977
                         <h4>
1978 1978
                             <a href="<?php if ($plink != '') {
1979
-                                echo $plink;
1980
-                            } else {
1981
-                                echo 'javascript:void(0);';
1982
-                            } ?>"><?php echo $title; ?></a>
1979
+								echo $plink;
1980
+							} else {
1981
+								echo 'javascript:void(0);';
1982
+							} ?>"><?php echo $title; ?></a>
1983 1983
                         </h4>
1984 1984
                         <?php
1985
-                        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1986
-                            $post_images = array();
1987
-                            if (!empty($postinfo_obj->post_images)) {
1988
-                                $post_images = explode(",", $postinfo_obj->post_images);
1989
-                            }
1990
-
1991
-                            if (!empty($post_images)) {
1992
-                                ?>
1985
+						if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1986
+							$post_images = array();
1987
+							if (!empty($postinfo_obj->post_images)) {
1988
+								$post_images = explode(",", $postinfo_obj->post_images);
1989
+							}
1990
+
1991
+							if (!empty($post_images)) {
1992
+								?>
1993 1993
                                 <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
1994
-                                        echo $plink;
1995
-                                    } else {
1996
-                                        echo 'javascript:void(0);';
1997
-                                    } ?>"><img alt="bubble image" style="max-height:50px;"
1994
+										echo $plink;
1995
+									} else {
1996
+										echo 'javascript:void(0);';
1997
+									} ?>"><img alt="bubble image" style="max-height:50px;"
1998 1998
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1999 1999
                             <?php
2000
-                            }else{
2001
-                                echo '<div class="geodir-bubble_image"></div>';
2002
-                            }
2003
-                        } else {
2004
-                            if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
2005
-                                ?>
2000
+							}else{
2001
+								echo '<div class="geodir-bubble_image"></div>';
2002
+							}
2003
+						} else {
2004
+							if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
2005
+								?>
2006 2006
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
2007 2007
                             <?php
2008
-                            }else{
2009
-                                echo '<div class="geodir-bubble_image"></div>';
2010
-                            }
2011
-                        }
2012
-                        ?>
2008
+							}else{
2009
+								echo '<div class="geodir-bubble_image"></div>';
2010
+							}
2011
+						}
2012
+						?>
2013 2013
                         <div class="geodir-bubble-meta-side">
2014 2014
                             <?php
2015
-                            /**
2016
-                             * Fires before the meta info in the map info window.
2017
-                             *
2018
-                             * This can be used to add more info to the map info window before the normal meta info.
2019
-                             *
2020
-                             * @since 1.5.4
2021
-                             * @param int $ID The post id.
2022
-                             * @param object $postinfo_obj The posts info as an object.
2023
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2024
-                             */
2025
-                            do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
2026
-
2027
-                            echo geodir_show_listing_info('mapbubble');
2028
-
2029
-                            /**
2030
-                             * Fires after the meta info in the map info window.
2031
-                             *
2032
-                             * This can be used to add more info to the map info window after the normal meta info.
2033
-                             *
2034
-                             * @since 1.4.2
2035
-                             * @param object $postinfo_obj The posts info as an object.
2036
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2037
-                             */
2038
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2039
-                            ?>
2015
+							/**
2016
+							 * Fires before the meta info in the map info window.
2017
+							 *
2018
+							 * This can be used to add more info to the map info window before the normal meta info.
2019
+							 *
2020
+							 * @since 1.5.4
2021
+							 * @param int $ID The post id.
2022
+							 * @param object $postinfo_obj The posts info as an object.
2023
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2024
+							 */
2025
+							do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
2026
+
2027
+							echo geodir_show_listing_info('mapbubble');
2028
+
2029
+							/**
2030
+							 * Fires after the meta info in the map info window.
2031
+							 *
2032
+							 * This can be used to add more info to the map info window after the normal meta info.
2033
+							 *
2034
+							 * @since 1.4.2
2035
+							 * @param object $postinfo_obj The posts info as an object.
2036
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2037
+							 */
2038
+							do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2039
+							?>
2040 2040
                         </div>
2041 2041
                         <?php
2042
-                        if ($ID) {
2043
-                            $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2044
-                            ?>
2042
+						if ($ID) {
2043
+							$post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2044
+							?>
2045 2045
                             <div class="geodir-bubble-meta-fade"></div>
2046 2046
                             <div class="geodir-bubble-meta-bottom">
2047 2047
                                 <?php if ($rating_star != '') { ?>
@@ -2057,69 +2057,69 @@  discard block
 block discarded – undo
2057 2057
                 </div>
2058 2058
             </div>
2059 2059
             <?php
2060
-            $html = ob_get_clean();
2061
-            /**
2062
-             * Filter to change infowindow html
2063
-             *
2064
-             * You can use this filter to change infowindow html.
2065
-             *
2066
-             * @since 1.0.0
2067
-             * @package GeoDirectory
2068
-             * @param string $html Infowindow html.
2069
-             * @param object $postinfo_obj The Post object.
2070
-             * @param bool|string $post_preview Is this a post preview?
2071
-             */
2072
-            $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2073
-            return $html;
2074
-        }
2075
-    }
2060
+			$html = ob_get_clean();
2061
+			/**
2062
+			 * Filter to change infowindow html
2063
+			 *
2064
+			 * You can use this filter to change infowindow html.
2065
+			 *
2066
+			 * @since 1.0.0
2067
+			 * @package GeoDirectory
2068
+			 * @param string $html Infowindow html.
2069
+			 * @param object $postinfo_obj The Post object.
2070
+			 * @param bool|string $post_preview Is this a post preview?
2071
+			 */
2072
+			$html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2073
+			return $html;
2074
+		}
2075
+	}
2076 2076
 }
2077 2077
 
2078 2078
 
2079 2079
 if (!function_exists('geodir_new_post_default_status')) {
2080
-    /**
2081
-     * Default post status for new posts.
2082
-     *
2083
-     * @since 1.0.0
2084
-     * @package GeoDirectory
2085
-     * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2086
-     */
2087
-    function geodir_new_post_default_status()
2088
-    {
2089
-        if (get_option('geodir_new_post_default_status'))
2090
-            return get_option('geodir_new_post_default_status');
2091
-        else
2092
-            return 'publish';
2093
-
2094
-    }
2080
+	/**
2081
+	 * Default post status for new posts.
2082
+	 *
2083
+	 * @since 1.0.0
2084
+	 * @package GeoDirectory
2085
+	 * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2086
+	 */
2087
+	function geodir_new_post_default_status()
2088
+	{
2089
+		if (get_option('geodir_new_post_default_status'))
2090
+			return get_option('geodir_new_post_default_status');
2091
+		else
2092
+			return 'publish';
2093
+
2094
+	}
2095 2095
 }
2096 2096
 
2097 2097
 if (!function_exists('geodir_change_post_status')) {
2098
-    /**
2099
-     * Change post status of a post.
2100
-     *
2101
-     * @global object $wpdb WordPress Database object.
2102
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2103
-     * @param int|string $post_id The post ID.
2104
-     * @param string $status New post status. Ex: draft, publish etc.
2105
-     */
2106
-    function geodir_change_post_status($post_id = '', $status = '')
2107
-    {
2108
-        global $wpdb, $plugin_prefix;
2109
-
2110
-        $post_type = get_post_type($post_id);
2111
-
2112
-        $table = $plugin_prefix . $post_type . '_detail';
2113
-
2114
-        $wpdb->query(
2115
-            $wpdb->prepare(
2116
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2117
-                array($status, $post_id)
2118
-            )
2119
-        );
2120
-
2121
-
2122
-    }
2098
+	/**
2099
+	 * Change post status of a post.
2100
+	 *
2101
+	 * @global object $wpdb WordPress Database object.
2102
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2103
+	 * @param int|string $post_id The post ID.
2104
+	 * @param string $status New post status. Ex: draft, publish etc.
2105
+	 */
2106
+	function geodir_change_post_status($post_id = '', $status = '')
2107
+	{
2108
+		global $wpdb, $plugin_prefix;
2109
+
2110
+		$post_type = get_post_type($post_id);
2111
+
2112
+		$table = $plugin_prefix . $post_type . '_detail';
2113
+
2114
+		$wpdb->query(
2115
+			$wpdb->prepare(
2116
+				"UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2117
+				array($status, $post_id)
2118
+			)
2119
+		);
2120
+
2121
+
2122
+	}
2123 2123
 }
2124 2124
 
2125 2125
 /**
@@ -2133,13 +2133,13 @@  discard block
 block discarded – undo
2133 2133
  */
2134 2134
 function geodir_set_post_status($pid, $status)
2135 2135
 {
2136
-    if ($pid) {
2137
-        global $wpdb;
2138
-        $my_post = array();
2139
-        $my_post['post_status'] = $status;
2140
-        $my_post['ID'] = $pid;
2141
-        $last_postid = wp_update_post($my_post);
2142
-    }
2136
+	if ($pid) {
2137
+		global $wpdb;
2138
+		$my_post = array();
2139
+		$my_post['post_status'] = $status;
2140
+		$my_post['ID'] = $pid;
2141
+		$last_postid = wp_update_post($my_post);
2142
+	}
2143 2143
 }
2144 2144
 
2145 2145
 
@@ -2155,384 +2155,384 @@  discard block
 block discarded – undo
2155 2155
  */
2156 2156
 function geodir_update_poststatus($new_status, $old_status, $post)
2157 2157
 {
2158
-    global $wpdb;
2158
+	global $wpdb;
2159 2159
 
2160
-    $geodir_posttypes = geodir_get_posttypes();
2160
+	$geodir_posttypes = geodir_get_posttypes();
2161 2161
 
2162
-    if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2162
+	if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2163 2163
 
2164
-        geodir_change_post_status($post->ID, $new_status);
2165
-    }
2164
+		geodir_change_post_status($post->ID, $new_status);
2165
+	}
2166 2166
 }
2167 2167
 
2168 2168
 
2169 2169
 if (!function_exists('geodir_update_listing_info')) {
2170
-    /**
2171
-     * Update post info.
2172
-     *
2173
-     * @since 1.0.0
2174
-     * @package GeoDirectory
2175
-     * @global object $wpdb WordPress Database object.
2176
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2177
-     * @param int $updatingpost The updating post ID.
2178
-     * @param int $temppost The temporary post ID.
2179
-     * @todo fix post_id variable
2180
-     */
2181
-    function geodir_update_listing_info($updatingpost, $temppost)
2182
-    {
2183
-
2184
-        global $wpdb, $plugin_prefix;
2185
-
2186
-        $post_type = get_post_type($post_id);
2187
-
2188
-        $table = $plugin_prefix . $post_type . '_detail';
2189
-
2190
-        $wpdb->query(
2191
-            $wpdb->prepare(
2192
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2193
-                array($updatingpost, $temppost)
2194
-            )
2195
-        );
2196
-
2197
-        $wpdb->query(
2198
-            $wpdb->prepare(
2199
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2200
-                array($updatingpost, $temppost)
2201
-            )
2202
-        );
2203
-
2204
-        /* Update Attachments*/
2205
-
2206
-        $wpdb->query(
2207
-            $wpdb->prepare(
2208
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2209
-                array($updatingpost, $temppost)
2210
-            )
2211
-        );
2212
-
2213
-    }
2170
+	/**
2171
+	 * Update post info.
2172
+	 *
2173
+	 * @since 1.0.0
2174
+	 * @package GeoDirectory
2175
+	 * @global object $wpdb WordPress Database object.
2176
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2177
+	 * @param int $updatingpost The updating post ID.
2178
+	 * @param int $temppost The temporary post ID.
2179
+	 * @todo fix post_id variable
2180
+	 */
2181
+	function geodir_update_listing_info($updatingpost, $temppost)
2182
+	{
2183
+
2184
+		global $wpdb, $plugin_prefix;
2185
+
2186
+		$post_type = get_post_type($post_id);
2187
+
2188
+		$table = $plugin_prefix . $post_type . '_detail';
2189
+
2190
+		$wpdb->query(
2191
+			$wpdb->prepare(
2192
+				"UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2193
+				array($updatingpost, $temppost)
2194
+			)
2195
+		);
2196
+
2197
+		$wpdb->query(
2198
+			$wpdb->prepare(
2199
+				"UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2200
+				array($updatingpost, $temppost)
2201
+			)
2202
+		);
2203
+
2204
+		/* Update Attachments*/
2205
+
2206
+		$wpdb->query(
2207
+			$wpdb->prepare(
2208
+				"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2209
+				array($updatingpost, $temppost)
2210
+			)
2211
+		);
2212
+
2213
+	}
2214 2214
 }
2215 2215
 
2216 2216
 
2217 2217
 if (!function_exists('geodir_delete_listing_info')) {
2218
-    /**
2219
-     * Delete Listing info from details table for the given post id.
2220
-     *
2221
-     * @since 1.0.0
2222
-     * @package GeoDirectory
2223
-     * @global object $wpdb WordPress Database object.
2224
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2225
-     * @param int $deleted_postid The post ID.
2226
-     * @param bool $force Optional. Do you want to force delete it? Default: false.
2227
-     * @return bool|void
2228
-     */
2229
-    function geodir_delete_listing_info($deleted_postid, $force = false)
2230
-    {
2231
-        global $wpdb, $plugin_prefix;
2232
-
2233
-        // check for multisite deletions
2234
-        if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2235
-        } else {
2236
-            return;
2237
-        }
2238
-
2239
-        $post_type = get_post_type($deleted_postid);
2240
-
2241
-        $all_postypes = geodir_get_posttypes();
2242
-
2243
-        if (!in_array($post_type, $all_postypes))
2244
-            return false;
2245
-
2246
-        $table = $plugin_prefix . $post_type . '_detail';
2247
-
2248
-        /* Delete custom post meta*/
2249
-        $wpdb->query(
2250
-            $wpdb->prepare(
2251
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2252
-                array($deleted_postid)
2253
-            )
2254
-        );
2255
-
2256
-        /* Delete post map icons*/
2257
-
2258
-        $wpdb->query(
2259
-            $wpdb->prepare(
2260
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2261
-                array($deleted_postid)
2262
-            )
2263
-        );
2264
-
2265
-        /* Delete Attachments*/
2266
-        $postcurr_images = geodir_get_images($deleted_postid);
2267
-
2268
-        $wpdb->query(
2269
-            $wpdb->prepare(
2270
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2271
-                array($deleted_postid)
2272
-            )
2273
-        );
2274
-        geodir_remove_attachments($postcurr_images);
2275
-
2276
-    }
2218
+	/**
2219
+	 * Delete Listing info from details table for the given post id.
2220
+	 *
2221
+	 * @since 1.0.0
2222
+	 * @package GeoDirectory
2223
+	 * @global object $wpdb WordPress Database object.
2224
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2225
+	 * @param int $deleted_postid The post ID.
2226
+	 * @param bool $force Optional. Do you want to force delete it? Default: false.
2227
+	 * @return bool|void
2228
+	 */
2229
+	function geodir_delete_listing_info($deleted_postid, $force = false)
2230
+	{
2231
+		global $wpdb, $plugin_prefix;
2232
+
2233
+		// check for multisite deletions
2234
+		if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2235
+		} else {
2236
+			return;
2237
+		}
2238
+
2239
+		$post_type = get_post_type($deleted_postid);
2240
+
2241
+		$all_postypes = geodir_get_posttypes();
2242
+
2243
+		if (!in_array($post_type, $all_postypes))
2244
+			return false;
2245
+
2246
+		$table = $plugin_prefix . $post_type . '_detail';
2247
+
2248
+		/* Delete custom post meta*/
2249
+		$wpdb->query(
2250
+			$wpdb->prepare(
2251
+				"DELETE FROM " . $table . " WHERE `post_id` = %d",
2252
+				array($deleted_postid)
2253
+			)
2254
+		);
2255
+
2256
+		/* Delete post map icons*/
2257
+
2258
+		$wpdb->query(
2259
+			$wpdb->prepare(
2260
+				"DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2261
+				array($deleted_postid)
2262
+			)
2263
+		);
2264
+
2265
+		/* Delete Attachments*/
2266
+		$postcurr_images = geodir_get_images($deleted_postid);
2267
+
2268
+		$wpdb->query(
2269
+			$wpdb->prepare(
2270
+				"DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2271
+				array($deleted_postid)
2272
+			)
2273
+		);
2274
+		geodir_remove_attachments($postcurr_images);
2275
+
2276
+	}
2277 2277
 }
2278 2278
 
2279 2279
 
2280 2280
 if (!function_exists('geodir_add_to_favorite')) {
2281
-    /**
2282
-     * This function would add listing to favorite listing.
2283
-     *
2284
-     * @since 1.0.0
2285
-     * @package GeoDirectory
2286
-     * @global object $current_user Current user object.
2287
-     * @param int $post_id The post ID.
2288
-     */
2289
-    function geodir_add_to_favorite($post_id)
2290
-    {
2291
-
2292
-        global $current_user;
2293
-
2294
-        /**
2295
-         * Filter to modify "Unfavorite" text
2296
-         *
2297
-         * You can use this filter to rename "Unfavorite" text to something else.
2298
-         *
2299
-         * @since 1.0.0
2300
-         * @package GeoDirectory
2301
-         */
2302
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2303
-
2304
-        /**
2305
-         * Filter to modify "Remove from Favorites" text
2306
-         *
2307
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2308
-         *
2309
-         * @since 1.0.0
2310
-         * @package GeoDirectory
2311
-         */
2312
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2313
-
2314
-        /**
2315
-         * Filter to modify "fa fa-heart" icon
2316
-         *
2317
-         * You can use this filter to change "fa fa-heart" icon to something else.
2318
-         *
2319
-         * @since 1.0.0
2320
-         * @package GeoDirectory
2321
-         */
2322
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2323
-
2324
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2325
-        $user_meta_data = !empty($user_meta_data) && is_array($user_meta_data) ? $user_meta_data : array();
2326
-
2327
-        if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2328
-            $user_meta_data[] = $post_id;
2329
-        }
2330
-
2331
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2281
+	/**
2282
+	 * This function would add listing to favorite listing.
2283
+	 *
2284
+	 * @since 1.0.0
2285
+	 * @package GeoDirectory
2286
+	 * @global object $current_user Current user object.
2287
+	 * @param int $post_id The post ID.
2288
+	 */
2289
+	function geodir_add_to_favorite($post_id)
2290
+	{
2291
+
2292
+		global $current_user;
2293
+
2294
+		/**
2295
+		 * Filter to modify "Unfavorite" text
2296
+		 *
2297
+		 * You can use this filter to rename "Unfavorite" text to something else.
2298
+		 *
2299
+		 * @since 1.0.0
2300
+		 * @package GeoDirectory
2301
+		 */
2302
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2303
+
2304
+		/**
2305
+		 * Filter to modify "Remove from Favorites" text
2306
+		 *
2307
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2308
+		 *
2309
+		 * @since 1.0.0
2310
+		 * @package GeoDirectory
2311
+		 */
2312
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2313
+
2314
+		/**
2315
+		 * Filter to modify "fa fa-heart" icon
2316
+		 *
2317
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2318
+		 *
2319
+		 * @since 1.0.0
2320
+		 * @package GeoDirectory
2321
+		 */
2322
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2323
+
2324
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2325
+		$user_meta_data = !empty($user_meta_data) && is_array($user_meta_data) ? $user_meta_data : array();
2326
+
2327
+		if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2328
+			$user_meta_data[] = $post_id;
2329
+		}
2330
+
2331
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2332
+
2333
+		/**
2334
+		 * Called before adding the post from favourites.
2335
+		 *
2336
+		 * @since 1.0.0
2337
+		 * @package GeoDirectory
2338
+		 * @param int $post_id The post ID.
2339
+		 */
2340
+		do_action('geodir_before_add_from_favorite', $post_id);
2341
+
2342
+		echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2343
+
2344
+		/**
2345
+		 * Called after adding the post from favourites.
2346
+		 *
2347
+		 * @since 1.0.0
2348
+		 * @package GeoDirectory
2349
+		 * @param int $post_id The post ID.
2350
+		 */
2351
+		do_action('geodir_after_add_from_favorite', $post_id);
2332 2352
 
2333
-        /**
2334
-         * Called before adding the post from favourites.
2335
-         *
2336
-         * @since 1.0.0
2337
-         * @package GeoDirectory
2338
-         * @param int $post_id The post ID.
2339
-         */
2340
-        do_action('geodir_before_add_from_favorite', $post_id);
2341
-
2342
-        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2343
-
2344
-        /**
2345
-         * Called after adding the post from favourites.
2346
-         *
2347
-         * @since 1.0.0
2348
-         * @package GeoDirectory
2349
-         * @param int $post_id The post ID.
2350
-         */
2351
-        do_action('geodir_after_add_from_favorite', $post_id);
2352
-
2353
-    }
2353
+	}
2354 2354
 }
2355 2355
 
2356 2356
 if (!function_exists('geodir_remove_from_favorite')) {
2357
-    /**
2358
-     * This function would remove the favourited property earlier.
2359
-     *
2360
-     * @since 1.0.0
2361
-     * @package GeoDirectory
2362
-     * @global object $current_user Current user object.
2363
-     * @param int $post_id The post ID.
2364
-     */
2365
-    function geodir_remove_from_favorite($post_id)
2366
-    {
2367
-        global $current_user;
2368
-
2369
-        /**
2370
-         * Filter to modify "Add to Favorites" text
2371
-         *
2372
-         * You can use this filter to rename "Add to Favorites" text to something else.
2373
-         *
2374
-         * @since 1.0.0
2375
-         * @package GeoDirectory
2376
-         */
2377
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2378
-
2379
-        /**
2380
-         * Filter to modify "Favourite" text
2381
-         *
2382
-         * You can use this filter to rename "Favourite" text to something else.
2383
-         *
2384
-         * @since 1.0.0
2385
-         * @package GeoDirectory
2386
-         */
2387
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2388
-
2389
-        /**
2390
-         * Filter to modify "fa fa-heart" icon
2391
-         *
2392
-         * You can use this filter to change "fa fa-heart" icon to something else.
2393
-         *
2394
-         * @since 1.0.0
2395
-         * @package GeoDirectory
2396
-         */
2397
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2398
-
2399
-        $user_meta_data = array();
2400
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2401
-
2402
-        if (!empty($user_meta_data)) {
2403
-
2404
-            if (($key = array_search($post_id, $user_meta_data)) !== false) {
2405
-                unset($user_meta_data[$key]);
2406
-            }
2357
+	/**
2358
+	 * This function would remove the favourited property earlier.
2359
+	 *
2360
+	 * @since 1.0.0
2361
+	 * @package GeoDirectory
2362
+	 * @global object $current_user Current user object.
2363
+	 * @param int $post_id The post ID.
2364
+	 */
2365
+	function geodir_remove_from_favorite($post_id)
2366
+	{
2367
+		global $current_user;
2368
+
2369
+		/**
2370
+		 * Filter to modify "Add to Favorites" text
2371
+		 *
2372
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2373
+		 *
2374
+		 * @since 1.0.0
2375
+		 * @package GeoDirectory
2376
+		 */
2377
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2378
+
2379
+		/**
2380
+		 * Filter to modify "Favourite" text
2381
+		 *
2382
+		 * You can use this filter to rename "Favourite" text to something else.
2383
+		 *
2384
+		 * @since 1.0.0
2385
+		 * @package GeoDirectory
2386
+		 */
2387
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2388
+
2389
+		/**
2390
+		 * Filter to modify "fa fa-heart" icon
2391
+		 *
2392
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2393
+		 *
2394
+		 * @since 1.0.0
2395
+		 * @package GeoDirectory
2396
+		 */
2397
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2398
+
2399
+		$user_meta_data = array();
2400
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2401
+
2402
+		if (!empty($user_meta_data)) {
2403
+
2404
+			if (($key = array_search($post_id, $user_meta_data)) !== false) {
2405
+				unset($user_meta_data[$key]);
2406
+			}
2407 2407
 
2408
-        }
2408
+		}
2409 2409
 
2410
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2410
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2411 2411
 
2412
-        /**
2413
-         * Called before removing the post from favourites.
2414
-         *
2415
-         * @since 1.0.0
2416
-         * @package GeoDirectory
2417
-         * @param int $post_id The post ID.
2418
-         */
2419
-        do_action('geodir_before_remove_from_favorite', $post_id);
2412
+		/**
2413
+		 * Called before removing the post from favourites.
2414
+		 *
2415
+		 * @since 1.0.0
2416
+		 * @package GeoDirectory
2417
+		 * @param int $post_id The post ID.
2418
+		 */
2419
+		do_action('geodir_before_remove_from_favorite', $post_id);
2420 2420
 
2421
-        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2421
+		echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2422 2422
 
2423
-        /**
2424
-         * Called after removing the post from favourites.
2425
-         *
2426
-         * @since 1.0.0
2427
-         * @package GeoDirectory
2428
-         * @param int $post_id The post ID.
2429
-         */
2430
-        do_action('geodir_after_remove_from_favorite', $post_id);
2423
+		/**
2424
+		 * Called after removing the post from favourites.
2425
+		 *
2426
+		 * @since 1.0.0
2427
+		 * @package GeoDirectory
2428
+		 * @param int $post_id The post ID.
2429
+		 */
2430
+		do_action('geodir_after_remove_from_favorite', $post_id);
2431 2431
 
2432
-    }
2432
+	}
2433 2433
 }
2434 2434
 
2435 2435
 if (!function_exists('geodir_favourite_html')) {
2436
-    /**
2437
-     * This function would display the html content for add to favorite or remove from favorite.
2438
-     *
2439
-     * @since 1.0.0
2440
-     * @package GeoDirectory
2441
-     * @global object $current_user Current user object.
2442
-     * @global object $post The current post object.
2443
-     * @param int $user_id The user ID.
2444
-     * @param int $post_id The post ID.
2445
-     */
2446
-    function geodir_favourite_html($user_id, $post_id)
2447
-    {
2448
-
2449
-        global $current_user, $post;
2450
-
2451
-        /**
2452
-         * Filter to modify "Add to Favorites" text
2453
-         *
2454
-         * You can use this filter to rename "Add to Favorites" text to something else.
2455
-         *
2456
-         * @since 1.0.0
2457
-         * @package GeoDirectory
2458
-         */
2459
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2460
-
2461
-        /**
2462
-         * Filter to modify "Favourite" text
2463
-         *
2464
-         * You can use this filter to rename "Favourite" text to something else.
2465
-         *
2466
-         * @since 1.0.0
2467
-         * @package GeoDirectory
2468
-         */
2469
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2470
-
2471
-        /**
2472
-         * Filter to modify "Unfavorite" text
2473
-         *
2474
-         * You can use this filter to rename "Unfavorite" text to something else.
2475
-         *
2476
-         * @since 1.0.0
2477
-         * @package GeoDirectory
2478
-         */
2479
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2480
-
2481
-        /**
2482
-         * Filter to modify "Remove from Favorites" text
2483
-         *
2484
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2485
-         *
2486
-         * @since 1.0.0
2487
-         * @package GeoDirectory
2488
-         */
2489
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2490
-
2491
-        /**
2492
-         * Filter to modify "fa fa-heart" icon
2493
-         *
2494
-         * You can use this filter to change "fa fa-heart" icon to something else.
2495
-         *
2496
-         * @since 1.0.0
2497
-         * @package GeoDirectory
2498
-         */
2499
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2500
-
2501
-        /**
2502
-         * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2503
-         *
2504
-         * You can use this filter to change "fa fa-heart" icon to something else.
2505
-         *
2506
-         * @since 1.0.0
2507
-         * @package GeoDirectory
2508
-         */
2509
-        $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2510
-
2511
-        $user_meta_data = '';
2512
-        if (isset($current_user->data->ID))
2513
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2514
-
2515
-        if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2516
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2436
+	/**
2437
+	 * This function would display the html content for add to favorite or remove from favorite.
2438
+	 *
2439
+	 * @since 1.0.0
2440
+	 * @package GeoDirectory
2441
+	 * @global object $current_user Current user object.
2442
+	 * @global object $post The current post object.
2443
+	 * @param int $user_id The user ID.
2444
+	 * @param int $post_id The post ID.
2445
+	 */
2446
+	function geodir_favourite_html($user_id, $post_id)
2447
+	{
2448
+
2449
+		global $current_user, $post;
2450
+
2451
+		/**
2452
+		 * Filter to modify "Add to Favorites" text
2453
+		 *
2454
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2455
+		 *
2456
+		 * @since 1.0.0
2457
+		 * @package GeoDirectory
2458
+		 */
2459
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2460
+
2461
+		/**
2462
+		 * Filter to modify "Favourite" text
2463
+		 *
2464
+		 * You can use this filter to rename "Favourite" text to something else.
2465
+		 *
2466
+		 * @since 1.0.0
2467
+		 * @package GeoDirectory
2468
+		 */
2469
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2470
+
2471
+		/**
2472
+		 * Filter to modify "Unfavorite" text
2473
+		 *
2474
+		 * You can use this filter to rename "Unfavorite" text to something else.
2475
+		 *
2476
+		 * @since 1.0.0
2477
+		 * @package GeoDirectory
2478
+		 */
2479
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2480
+
2481
+		/**
2482
+		 * Filter to modify "Remove from Favorites" text
2483
+		 *
2484
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2485
+		 *
2486
+		 * @since 1.0.0
2487
+		 * @package GeoDirectory
2488
+		 */
2489
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2490
+
2491
+		/**
2492
+		 * Filter to modify "fa fa-heart" icon
2493
+		 *
2494
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2495
+		 *
2496
+		 * @since 1.0.0
2497
+		 * @package GeoDirectory
2498
+		 */
2499
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2500
+
2501
+		/**
2502
+		 * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2503
+		 *
2504
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2505
+		 *
2506
+		 * @since 1.0.0
2507
+		 * @package GeoDirectory
2508
+		 */
2509
+		$unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2510
+
2511
+		$user_meta_data = '';
2512
+		if (isset($current_user->data->ID))
2513
+			$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2514
+
2515
+		if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2516
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2517 2517
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2518 2518
                 onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2519 2519
                 title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2520 2520
             </a>   </span><?php
2521 2521
 
2522
-        } else {
2522
+		} else {
2523 2523
 
2524
-            if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2525
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2526
-            } else
2527
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2524
+			if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2525
+				$script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2526
+			} else
2527
+				$script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2528 2528
 
2529
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2529
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2530 2530
                                                                                         href="javascript:void(0);"
2531 2531
                                                                                         onclick="<?php echo $script_text;?>"
2532 2532
                                                                                         title="<?php echo $add_favourite_text;?>"><i
2533 2533
                     class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2534 2534
         <?php }
2535
-    }
2535
+	}
2536 2536
 }
2537 2537
 
2538 2538
 
@@ -2549,54 +2549,54 @@  discard block
 block discarded – undo
2549 2549
 function geodir_get_cat_postcount($term = array())
2550 2550
 {
2551 2551
 
2552
-    if (!empty($term)) {
2552
+	if (!empty($term)) {
2553 2553
 
2554
-        global $wpdb, $plugin_prefix;
2554
+		global $wpdb, $plugin_prefix;
2555 2555
 
2556
-        $where = '';
2557
-        $join = '';
2558
-        if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2559
-            $taxonomy_obj = get_taxonomy($term->taxonomy);
2556
+		$where = '';
2557
+		$join = '';
2558
+		if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2559
+			$taxonomy_obj = get_taxonomy($term->taxonomy);
2560 2560
 
2561
-            $post_type = $taxonomy_obj->object_type[0];
2561
+			$post_type = $taxonomy_obj->object_type[0];
2562 2562
 
2563
-            $table = $plugin_prefix . $post_type . '_detail';
2563
+			$table = $plugin_prefix . $post_type . '_detail';
2564 2564
 
2565
-            /**
2566
-             * Filter to modify the 'join' query
2567
-             *
2568
-             * @since 1.0.0
2569
-             * @package GeoDirectory
2570
-             * @param object|array $term category / term object that need to be processed.
2571
-             * @param string $join The join query.
2572
-             */
2573
-            $join = apply_filters('geodir_cat_post_count_join', $join, $term);
2565
+			/**
2566
+			 * Filter to modify the 'join' query
2567
+			 *
2568
+			 * @since 1.0.0
2569
+			 * @package GeoDirectory
2570
+			 * @param object|array $term category / term object that need to be processed.
2571
+			 * @param string $join The join query.
2572
+			 */
2573
+			$join = apply_filters('geodir_cat_post_count_join', $join, $term);
2574 2574
 
2575
-            /**
2576
-             * Filter to modify the 'where' query
2577
-             *
2578
-             * @since 1.0.0
2579
-             * @package GeoDirectory
2580
-             * @param object|array $term category / term object that need to be processed.
2581
-             * @param string $where The where query.
2582
-             */
2583
-            $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2575
+			/**
2576
+			 * Filter to modify the 'where' query
2577
+			 *
2578
+			 * @since 1.0.0
2579
+			 * @package GeoDirectory
2580
+			 * @param object|array $term category / term object that need to be processed.
2581
+			 * @param string $where The where query.
2582
+			 */
2583
+			$where = apply_filters('geodir_cat_post_count_where', $where, $term);
2584 2584
 
2585
-            $count_query = "SELECT count(post_id) FROM
2585
+			$count_query = "SELECT count(post_id) FROM
2586 2586
 							" . $table . " as pd " . $join . "
2587 2587
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2588 2588
 
2589
-            $cat_post_count = $wpdb->get_var($count_query);
2590
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2591
-                $cat_post_count = 0;
2589
+			$cat_post_count = $wpdb->get_var($count_query);
2590
+			if (empty($cat_post_count) || is_wp_error($cat_post_count))
2591
+				$cat_post_count = 0;
2592 2592
 
2593
-            return $cat_post_count;
2593
+			return $cat_post_count;
2594 2594
 
2595
-        } else
2595
+		} else
2596 2596
 
2597
-            return $term->count;
2598
-    }
2599
-    return false;
2597
+			return $term->count;
2598
+	}
2599
+	return false;
2600 2600
 
2601 2601
 }
2602 2602
 
@@ -2609,17 +2609,17 @@  discard block
 block discarded – undo
2609 2609
  */
2610 2610
 function geodir_allow_post_type_frontend()
2611 2611
 {
2612
-    $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2612
+	$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2613 2613
 
2614
-    if (!is_admin() && isset($_REQUEST['listing_type'])
2615
-        && !empty($geodir_allow_posttype_frontend)
2616
-        && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2617
-    ) {
2614
+	if (!is_admin() && isset($_REQUEST['listing_type'])
2615
+		&& !empty($geodir_allow_posttype_frontend)
2616
+		&& !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2617
+	) {
2618 2618
 
2619
-        wp_redirect(home_url());
2620
-        exit;
2619
+		wp_redirect(home_url());
2620
+		exit;
2621 2621
 
2622
-    }
2622
+	}
2623 2623
 
2624 2624
 }
2625 2625
 
@@ -2636,20 +2636,20 @@  discard block
 block discarded – undo
2636 2636
  */
2637 2637
 function geodir_excerpt_length($length)
2638 2638
 {
2639
-    global $wp_query, $geodir_is_widget_listing;
2639
+	global $wp_query, $geodir_is_widget_listing;
2640 2640
 	if ($geodir_is_widget_listing) {
2641 2641
 		return $length;
2642 2642
 	}
2643 2643
 	
2644
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2645
-        $length = get_option('geodir_desc_word_limit');
2646
-    elseif (get_query_var('excerpt_length'))
2647
-        $length = get_query_var('excerpt_length');
2644
+	if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2645
+		$length = get_option('geodir_desc_word_limit');
2646
+	elseif (get_query_var('excerpt_length'))
2647
+		$length = get_query_var('excerpt_length');
2648 2648
 
2649
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2650
-        $length = get_option('geodir_author_desc_word_limit');
2649
+	if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2650
+		$length = get_option('geodir_author_desc_word_limit');
2651 2651
 
2652
-    return $length;
2652
+	return $length;
2653 2653
 }
2654 2654
 
2655 2655
 /**
@@ -2664,13 +2664,13 @@  discard block
 block discarded – undo
2664 2664
  */
2665 2665
 function geodir_excerpt_more($more)
2666 2666
 {
2667
-    global $post;
2668
-    $all_postypes = geodir_get_posttypes();
2669
-    if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2670
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2671
-    }
2667
+	global $post;
2668
+	$all_postypes = geodir_get_posttypes();
2669
+	if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2670
+		return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2671
+	}
2672 2672
 
2673
-    return $more;
2673
+	return $more;
2674 2674
 }
2675 2675
 
2676 2676
 
@@ -2687,63 +2687,63 @@  discard block
 block discarded – undo
2687 2687
  */
2688 2688
 function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
2689 2689
 {
2690
-    global $plugin_prefix, $wpdb;
2690
+	global $plugin_prefix, $wpdb;
2691 2691
 
2692
-    $gd_taxonomies = geodir_get_taxonomies();
2692
+	$gd_taxonomies = geodir_get_taxonomies();
2693 2693
 
2694
-    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2694
+	if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2695 2695
 
2696
-        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2697
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2696
+		$geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2697
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
2698 2698
 
2699
-        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2700
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2699
+		$path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2700
+		$term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2701 2701
 
2702
-        $posts = $wpdb->get_results(
2703
-            $wpdb->prepare(
2704
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2705
-                array($term_id, $taxonomy)
2706
-            )
2707
-        );
2702
+		$posts = $wpdb->get_results(
2703
+			$wpdb->prepare(
2704
+				"SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2705
+				array($term_id, $taxonomy)
2706
+			)
2707
+		);
2708 2708
 
2709
-        if (!empty($posts)):
2710
-            foreach ($posts as $post_obj) {
2709
+		if (!empty($posts)):
2710
+			foreach ($posts as $post_obj) {
2711 2711
 
2712
-                $lat = $post_obj->post_latitude;
2713
-                $lng = $post_obj->post_longitude;
2712
+				$lat = $post_obj->post_latitude;
2713
+				$lng = $post_obj->post_longitude;
2714 2714
 
2715
-                $json = '{';
2716
-                $json .= '"id":"' . $post_obj->post_id . '",';
2717
-                $json .= '"lat_pos": "' . $lat . '",';
2718
-                $json .= '"long_pos": "' . $lng . '",';
2719
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2720
-                $json .= '"icon":"' . $term_icon . '",';
2721
-                $json .= '"group":"catgroup' . $term_id . '"';
2722
-                $json .= '}';
2715
+				$json = '{';
2716
+				$json .= '"id":"' . $post_obj->post_id . '",';
2717
+				$json .= '"lat_pos": "' . $lat . '",';
2718
+				$json .= '"long_pos": "' . $lng . '",';
2719
+				$json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2720
+				$json .= '"icon":"' . $term_icon . '",';
2721
+				$json .= '"group":"catgroup' . $term_id . '"';
2722
+				$json .= '}';
2723 2723
 
2724
-                if ($post_obj->default_category == $term_id) {
2724
+				if ($post_obj->default_category == $term_id) {
2725 2725
 
2726
-                    $wpdb->query(
2727
-                        $wpdb->prepare(
2728
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2729
-                            array($json, $post_obj->post_id)
2730
-                        )
2731
-                    );
2732
-                }
2726
+					$wpdb->query(
2727
+						$wpdb->prepare(
2728
+							"UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2729
+							array($json, $post_obj->post_id)
2730
+						)
2731
+					);
2732
+				}
2733 2733
 
2734
-                $wpdb->query(
2735
-                    $wpdb->prepare(
2736
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2737
-                        array($json, $post_obj->post_id, $term_id)
2738
-                    )
2739
-                );
2734
+				$wpdb->query(
2735
+					$wpdb->prepare(
2736
+						"UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2737
+						array($json, $post_obj->post_id, $term_id)
2738
+					)
2739
+				);
2740 2740
 
2741
-            }
2741
+			}
2742 2742
 
2743 2743
 
2744
-        endif;
2744
+		endif;
2745 2745
 
2746
-    }
2746
+	}
2747 2747
 
2748 2748
 }
2749 2749
 
@@ -2757,14 +2757,14 @@  discard block
 block discarded – undo
2757 2757
  */
2758 2758
 function geodir_get_listing_author($listing_id = '')
2759 2759
 {
2760
-    if ($listing_id == '') {
2761
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2762
-            $listing_id = $_REQUEST['pid'];
2763
-        }
2764
-    }
2765
-    $listing = get_post(strip_tags($listing_id));
2766
-    $listing_author_id = $listing->post_author;
2767
-    return $listing_author_id;
2760
+	if ($listing_id == '') {
2761
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2762
+			$listing_id = $_REQUEST['pid'];
2763
+		}
2764
+	}
2765
+	$listing = get_post(strip_tags($listing_id));
2766
+	$listing_author_id = $listing->post_author;
2767
+	return $listing_author_id;
2768 2768
 }
2769 2769
 
2770 2770
 
@@ -2779,11 +2779,11 @@  discard block
 block discarded – undo
2779 2779
  */
2780 2780
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2781 2781
 {
2782
-    $listing_author_id = geodir_get_listing_author($listing_id);
2783
-    if ($listing_author_id == $user_id)
2784
-        return true;
2785
-    else
2786
-        return false;
2782
+	$listing_author_id = geodir_get_listing_author($listing_id);
2783
+	if ($listing_author_id == $user_id)
2784
+		return true;
2785
+	else
2786
+		return false;
2787 2787
 
2788 2788
 }
2789 2789
 
@@ -2799,17 +2799,17 @@  discard block
 block discarded – undo
2799 2799
  */
2800 2800
 function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true)
2801 2801
 {
2802
-    global $current_user;
2803
-    if ($exclude_admin) {
2804
-        foreach ($current_user->caps as $key => $caps) {
2805
-            if (geodir_strtolower($key) == 'administrator') {
2806
-                return true;
2807
-                break;
2808
-            }
2809
-        }
2810
-    }
2811
-
2812
-    return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2802
+	global $current_user;
2803
+	if ($exclude_admin) {
2804
+		foreach ($current_user->caps as $key => $caps) {
2805
+			if (geodir_strtolower($key) == 'administrator') {
2806
+				return true;
2807
+				break;
2808
+			}
2809
+		}
2810
+	}
2811
+
2812
+	return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2813 2813
 }
2814 2814
 
2815 2815
 
@@ -2825,17 +2825,17 @@  discard block
 block discarded – undo
2825 2825
 function geodir_only_supportable_attachments_remove($file)
2826 2826
 {
2827 2827
 
2828
-    global $wpdb;
2828
+	global $wpdb;
2829 2829
 
2830
-    $matches = array();
2830
+	$matches = array();
2831 2831
 
2832
-    $pattern = '/-\d+x\d+\./';
2833
-    preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2832
+	$pattern = '/-\d+x\d+\./';
2833
+	preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2834 2834
 
2835
-    if (empty($matches))
2836
-        return '';
2837
-    else
2838
-        return $file;
2835
+	if (empty($matches))
2836
+		return '';
2837
+	else
2838
+		return $file;
2839 2839
 
2840 2840
 }
2841 2841
 
@@ -2852,78 +2852,78 @@  discard block
 block discarded – undo
2852 2852
 function geodir_set_wp_featured_image($post_id)
2853 2853
 {
2854 2854
 
2855
-    global $wpdb, $plugin_prefix;
2856
-    $uploads = wp_upload_dir();
2855
+	global $wpdb, $plugin_prefix;
2856
+	$uploads = wp_upload_dir();
2857 2857
 //	print_r($uploads ) ;
2858
-    $post_first_image = $wpdb->get_results(
2859
-        $wpdb->prepare(
2860
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2861
-        )
2862
-    );
2858
+	$post_first_image = $wpdb->get_results(
2859
+		$wpdb->prepare(
2860
+			"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2861
+		)
2862
+	);
2863 2863
 
2864
-    $old_attachment_name = '';
2865
-    $post_thumbnail_id = '';
2866
-    if (has_post_thumbnail($post_id)) {
2864
+	$old_attachment_name = '';
2865
+	$post_thumbnail_id = '';
2866
+	if (has_post_thumbnail($post_id)) {
2867 2867
 
2868
-        if (has_post_thumbnail($post_id)) {
2868
+		if (has_post_thumbnail($post_id)) {
2869 2869
 
2870
-            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2870
+			$post_thumbnail_id = get_post_thumbnail_id($post_id);
2871 2871
 
2872
-            $old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2872
+			$old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2873 2873
 
2874
-        }
2875
-    }
2876
-
2877
-    if (!empty($post_first_image)) {
2874
+		}
2875
+	}
2878 2876
 
2879
-        $post_type = get_post_type($post_id);
2877
+	if (!empty($post_first_image)) {
2880 2878
 
2881
-        $table_name = $plugin_prefix . $post_type . '_detail';
2879
+		$post_type = get_post_type($post_id);
2882 2880
 
2883
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2881
+		$table_name = $plugin_prefix . $post_type . '_detail';
2884 2882
 
2885
-        $new_attachment_name = basename($post_first_image[0]->file);
2883
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2886 2884
 
2887
-        if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2885
+		$new_attachment_name = basename($post_first_image[0]->file);
2888 2886
 
2889
-            if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2887
+		if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2890 2888
 
2891
-                add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2889
+			if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2892 2890
 
2893
-                wp_delete_attachment($post_thumbnail_id);
2891
+				add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2894 2892
 
2895
-            }
2896
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2893
+				wp_delete_attachment($post_thumbnail_id);
2897 2894
 
2898
-            $attachment = array(
2899
-                'post_mime_type' => $post_first_image[0]->mime_type,
2900
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2901
-                'post_parent' => $post_id,
2902
-                'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2903
-                'post_content' => ''
2904
-            );
2895
+			}
2896
+			$filename = $uploads['basedir'] . $post_first_image[0]->file;
2897
+
2898
+			$attachment = array(
2899
+				'post_mime_type' => $post_first_image[0]->mime_type,
2900
+				'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2901
+				'post_parent' => $post_id,
2902
+				'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2903
+				'post_content' => ''
2904
+			);
2905 2905
 
2906 2906
 
2907
-            $id = wp_insert_attachment($attachment, $filename, $post_id);
2907
+			$id = wp_insert_attachment($attachment, $filename, $post_id);
2908 2908
 
2909
-            if (!is_wp_error($id)) {
2909
+			if (!is_wp_error($id)) {
2910 2910
 
2911
-                set_post_thumbnail($post_id, $id);
2911
+				set_post_thumbnail($post_id, $id);
2912 2912
 
2913
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2914
-                wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2913
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
2914
+				wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2915 2915
 
2916
-            }
2916
+			}
2917 2917
 
2918
-        }
2918
+		}
2919 2919
 
2920
-    } else {
2921
-        //set_post_thumbnail($post_id,-1);
2920
+	} else {
2921
+		//set_post_thumbnail($post_id,-1);
2922 2922
 
2923
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2924
-            wp_delete_attachment($post_thumbnail_id);
2923
+		if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2924
+			wp_delete_attachment($post_thumbnail_id);
2925 2925
 
2926
-    }
2926
+	}
2927 2927
 }
2928 2928
 
2929 2929
 
@@ -2938,53 +2938,53 @@  discard block
 block discarded – undo
2938 2938
  */
2939 2939
 function gd_copy_original_translation()
2940 2940
 {
2941
-    if (function_exists('icl_object_id')) {
2942
-        global $wpdb, $table_prefix, $plugin_prefix;
2943
-        $post_id = absint($_POST['post_id']);
2944
-        $upload_dir = wp_upload_dir();
2945
-        $post_type = get_post_type($_POST['post_id']);
2946
-        $table = $plugin_prefix . $post_type . '_detail';
2947
-
2948
-        $post_arr = $wpdb->get_results($wpdb->prepare(
2949
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2950
-            array($post_id)
2951
-        )
2952
-            , ARRAY_A);
2953
-
2954
-        $arrImages = $wpdb->get_results(
2955
-            $wpdb->prepare(
2956
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2957
-                array('%image%', $post_id)
2958
-            )
2959
-        );
2960
-        if ($arrImages) {
2961
-            $image_arr = array();
2962
-            foreach ($arrImages as $img) {
2963
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2964
-            }
2965
-            $comma_separated = implode(",", $image_arr);
2966
-            $post_arr[0]['post_images'] = $comma_separated;
2967
-        }
2968
-
2969
-
2970
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2971
-        $cat_arr = array_filter(explode(",", $cats));
2972
-        $trans_cat = array();
2973
-        foreach ($cat_arr as $cat) {
2974
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2975
-        }
2976
-
2977
-
2978
-        $post_arr[0]['categories'] = array_filter($trans_cat);
2941
+	if (function_exists('icl_object_id')) {
2942
+		global $wpdb, $table_prefix, $plugin_prefix;
2943
+		$post_id = absint($_POST['post_id']);
2944
+		$upload_dir = wp_upload_dir();
2945
+		$post_type = get_post_type($_POST['post_id']);
2946
+		$table = $plugin_prefix . $post_type . '_detail';
2947
+
2948
+		$post_arr = $wpdb->get_results($wpdb->prepare(
2949
+			"SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2950
+			array($post_id)
2951
+		)
2952
+			, ARRAY_A);
2953
+
2954
+		$arrImages = $wpdb->get_results(
2955
+			$wpdb->prepare(
2956
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2957
+				array('%image%', $post_id)
2958
+			)
2959
+		);
2960
+		if ($arrImages) {
2961
+			$image_arr = array();
2962
+			foreach ($arrImages as $img) {
2963
+				$image_arr[] = $upload_dir['baseurl'] . $img->file;
2964
+			}
2965
+			$comma_separated = implode(",", $image_arr);
2966
+			$post_arr[0]['post_images'] = $comma_separated;
2967
+		}
2968
+
2969
+
2970
+		$cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2971
+		$cat_arr = array_filter(explode(",", $cats));
2972
+		$trans_cat = array();
2973
+		foreach ($cat_arr as $cat) {
2974
+			$trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2975
+		}
2976
+
2977
+
2978
+		$post_arr[0]['categories'] = array_filter($trans_cat);
2979 2979
 //print_r($image_arr);
2980
-        //print_r($arrImages);
2981
-        //echo $_REQUEST['lang'];
2980
+		//print_r($arrImages);
2981
+		//echo $_REQUEST['lang'];
2982 2982
 //print_r($post_arr);
2983 2983
 //print_r($trans_cat);
2984
-        echo json_encode($post_arr[0]);
2984
+		echo json_encode($post_arr[0]);
2985 2985
 
2986
-    }
2987
-    die();
2986
+	}
2987
+	die();
2988 2988
 }
2989 2989
 
2990 2990
 
@@ -3004,54 +3004,54 @@  discard block
 block discarded – undo
3004 3004
 function geodir_get_custom_fields_type($listing_type = '')
3005 3005
 {
3006 3006
 
3007
-    global $wpdb;
3007
+	global $wpdb;
3008 3008
 
3009
-    if ($listing_type == '')
3010
-        $listing_type = 'gd_place';
3009
+	if ($listing_type == '')
3010
+		$listing_type = 'gd_place';
3011 3011
 
3012
-    $fields_info = array();
3012
+	$fields_info = array();
3013 3013
 
3014
-    $get_data = $wpdb->get_results(
3015
-        $wpdb->prepare(
3016
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
3017
-            array($listing_type)
3018
-        )
3019
-    );
3014
+	$get_data = $wpdb->get_results(
3015
+		$wpdb->prepare(
3016
+			"SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
3017
+			array($listing_type)
3018
+		)
3019
+	);
3020 3020
 
3021
-    if (!empty($get_data)) {
3021
+	if (!empty($get_data)) {
3022 3022
 
3023
-        foreach ($get_data as $data) {
3023
+		foreach ($get_data as $data) {
3024 3024
 
3025
-            if ($data->field_type == 'address') {
3025
+			if ($data->field_type == 'address') {
3026 3026
 
3027
-                $extra_fields = unserialize($data->extra_fields);
3027
+				$extra_fields = unserialize($data->extra_fields);
3028 3028
 
3029
-                $prefix = $data->htmlvar_name . '_';
3029
+				$prefix = $data->htmlvar_name . '_';
3030 3030
 
3031
-                $fields_info[$prefix . 'address'] = $data->field_type;
3031
+				$fields_info[$prefix . 'address'] = $data->field_type;
3032 3032
 
3033
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3034
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3033
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3034
+					$fields_info[$prefix . 'zip'] = $data->field_type;
3035 3035
 
3036
-            } else {
3036
+			} else {
3037 3037
 
3038
-                $fields_info[$data->htmlvar_name] = $data->field_type;
3038
+				$fields_info[$data->htmlvar_name] = $data->field_type;
3039 3039
 
3040
-            }
3040
+			}
3041 3041
 
3042
-        }
3042
+		}
3043 3043
 
3044
-    }
3044
+	}
3045 3045
 
3046
-    /**
3047
-     * Filter to modify custom fields info using listing post type.
3048
-     *
3049
-     * @since 1.0.0
3050
-     * @package GeoDirectory
3051
-     * @return array $fields_info Custom fields info.
3052
-     * @param string $listing_type The listing post type.
3053
-     */
3054
-    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3046
+	/**
3047
+	 * Filter to modify custom fields info using listing post type.
3048
+	 *
3049
+	 * @since 1.0.0
3050
+	 * @package GeoDirectory
3051
+	 * @return array $fields_info Custom fields info.
3052
+	 * @param string $listing_type The listing post type.
3053
+	 */
3054
+	return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3055 3055
 }
3056 3056
 
3057 3057
 
@@ -3066,58 +3066,58 @@  discard block
 block discarded – undo
3066 3066
  */
3067 3067
 function geodir_function_post_updated($post_ID, $post_after, $post_before)
3068 3068
 {
3069
-    $post_type = get_post_type($post_ID);
3069
+	$post_type = get_post_type($post_ID);
3070 3070
 
3071
-    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3072
-        // send notification to client when post moves from draft to publish
3073
-        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')) {
3074
-            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3075
-            $post_author_data = get_userdata($post_author_id);
3071
+	if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3072
+		// send notification to client when post moves from draft to publish
3073
+		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')) {
3074
+			$post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3075
+			$post_author_data = get_userdata($post_author_id);
3076 3076
 
3077
-            $to_name = geodir_get_client_name($post_author_id);
3077
+			$to_name = geodir_get_client_name($post_author_id);
3078 3078
 
3079
-            $from_email = geodir_get_site_email_id();
3080
-            $from_name = get_site_emailName();
3081
-            $to_email = $post_author_data->user_email;
3079
+			$from_email = geodir_get_site_email_id();
3080
+			$from_name = get_site_emailName();
3081
+			$to_email = $post_author_data->user_email;
3082 3082
 
3083
-            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3084
-                $to_email = $post_author_data->user_email;
3085
-            }
3083
+			if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3084
+				$to_email = $post_author_data->user_email;
3085
+			}
3086 3086
 
3087
-            $message_type = 'listing_published';
3087
+			$message_type = 'listing_published';
3088 3088
 
3089
-            if (get_option('geodir_post_published_email_subject') == '') {
3090
-                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3091
-            }
3089
+			if (get_option('geodir_post_published_email_subject') == '') {
3090
+				update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3091
+			}
3092 3092
 
3093
-            if (get_option('geodir_post_published_email_content') == '') {
3094
-                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'));
3095
-            }
3093
+			if (get_option('geodir_post_published_email_content') == '') {
3094
+				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'));
3095
+			}
3096 3096
 
3097
-            /**
3098
-             * Called before sending the email when listing gets published.
3099
-             *
3100
-             * @since 1.0.0
3101
-             * @package GeoDirectory
3102
-             * @param object $post_after The post object after update.
3103
-             * @param object $post_before The post object before update.
3104
-             */
3105
-            do_action('geodir_before_listing_published_email', $post_after, $post_before);
3106
-            if (is_email($to_email)) {
3107
-                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3108
-            }
3097
+			/**
3098
+			 * Called before sending the email when listing gets published.
3099
+			 *
3100
+			 * @since 1.0.0
3101
+			 * @package GeoDirectory
3102
+			 * @param object $post_after The post object after update.
3103
+			 * @param object $post_before The post object before update.
3104
+			 */
3105
+			do_action('geodir_before_listing_published_email', $post_after, $post_before);
3106
+			if (is_email($to_email)) {
3107
+				geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3108
+			}
3109 3109
 
3110
-            /**
3111
-             * Called after sending the email when listing gets published.
3112
-             *
3113
-             * @since 1.0.0
3114
-             * @package GeoDirectory
3115
-             * @param object $post_after The post object after update.
3116
-             * @param object $post_before The post object before update.
3117
-             */
3118
-            do_action('geodir_after_listing_published_email', $post_after, $post_before);
3119
-        }
3120
-    }
3110
+			/**
3111
+			 * Called after sending the email when listing gets published.
3112
+			 *
3113
+			 * @since 1.0.0
3114
+			 * @package GeoDirectory
3115
+			 * @param object $post_after The post object after update.
3116
+			 * @param object $post_before The post object before update.
3117
+			 */
3118
+			do_action('geodir_after_listing_published_email', $post_after, $post_before);
3119
+		}
3120
+	}
3121 3121
 }
3122 3122
 
3123 3123
 add_action('wp_head', 'geodir_fb_like_thumbnail');
@@ -3131,14 +3131,14 @@  discard block
 block discarded – undo
3131 3131
  */
3132 3132
 function geodir_fb_like_thumbnail(){
3133 3133
 
3134
-    // return if not a single post
3135
-    if(!is_single()){return;}
3134
+	// return if not a single post
3135
+	if(!is_single()){return;}
3136 3136
 
3137
-    global $post;
3138
-    if(isset($post->featured_image) && $post->featured_image){
3139
-        $upload_dir = wp_upload_dir();
3140
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3141
-        echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3137
+	global $post;
3138
+	if(isset($post->featured_image) && $post->featured_image){
3139
+		$upload_dir = wp_upload_dir();
3140
+		$thumb = $upload_dir['baseurl'].$post->featured_image;
3141
+		echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3142 3142
 
3143
-    }
3143
+	}
3144 3144
 }
3145 3145
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 
27 27
     if (!isset($default_cat) || empty($default_cat)) {
28 28
         $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
-        if(!is_int($default_cat)){
29
+    } else {
30
+        if (!is_int($default_cat)) {
31 31
             $category = get_term_by('name', $default_cat, $taxonomy);
32
-            if(isset($category->term_id)){
33
-                $default_cat =  $category->term_id;
32
+            if (isset($category->term_id)) {
33
+                $default_cat = $category->term_id;
34 34
             }
35 35
         }
36 36
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 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
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
             
146 146
             $gd_post = $post;
147 147
             if (!empty($gd_post) && is_array($gd_post)) {
148
-                $gd_post = (object)$post;
148
+                $gd_post = (object) $post;
149 149
                 
150 150
                 // Fix WPML duplicate.
151 151
                 if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
         $send_post_submit_mail = false;
240 240
 
241 241
         // unhook this function so it doesn't loop infinitely
242
-        remove_action('save_post', 'geodir_post_information_save',10,2);
242
+        remove_action('save_post', 'geodir_post_information_save', 10, 2);
243 243
 
244 244
         if (isset($request_info['pid']) && $request_info['pid'] != '') {
245 245
             $post['ID'] = $request_info['pid'];
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
         }
264 264
 
265 265
         // re-hook this function
266
-        add_action('save_post', 'geodir_post_information_save',10,2);
266
+        add_action('save_post', 'geodir_post_information_save', 10, 2);
267 267
 
268 268
         $post_tags = '';
269 269
         if (!isset($request_info['post_tags'])) {
270 270
 
271 271
             $post_type = $request_info['listing_type'];
272
-            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
272
+            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type.'_tags', array('fields' => 'names')));
273 273
 
274 274
         }
275 275
 
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
         $payment_info = array();
288 288
         $package_info = array();
289 289
 
290
-        $package_info = (array)geodir_post_package_info($package_info, $post);
290
+        $package_info = (array) geodir_post_package_info($package_info, $post);
291 291
 
292 292
         $post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
293 293
 
294 294
         if (!empty($package_info) && !$post_package_id) {
295 295
             if (isset($package_info['days']) && $package_info['days'] != 0) {
296
-                $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
296
+                $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['days']." days"));
297 297
             } else {
298 298
                 $payment_info['expire_date'] = 'Never';
299 299
             }
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
             $extrafields = $val['extra_fields'];
315 315
 
316 316
             if (trim($type) == 'address') {
317
-                $prefix = $name . '_';
318
-                $address = $prefix . 'address';
317
+                $prefix = $name.'_';
318
+                $address = $prefix.'address';
319 319
 
320 320
                 if (isset($request_info[$address]) && $request_info[$address] != '') {
321 321
                     $gd_post_info[$address] = wp_slash($request_info[$address]);
@@ -325,59 +325,59 @@  discard block
 block discarded – undo
325 325
                     $extrafields = unserialize($extrafields);
326 326
 
327 327
 
328
-                    if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
328
+                    if (!isset($request_info[$prefix.'city']) || $request_info[$prefix.'city'] == '') {
329 329
 
330 330
                         $location_result = geodir_get_default_location();
331 331
 
332
-                        $gd_post_info[$prefix . 'city'] = $location_result->city;
333
-                        $gd_post_info[$prefix . 'region'] = $location_result->region;
334
-                        $gd_post_info[$prefix . 'country'] = $location_result->country;
332
+                        $gd_post_info[$prefix.'city'] = $location_result->city;
333
+                        $gd_post_info[$prefix.'region'] = $location_result->region;
334
+                        $gd_post_info[$prefix.'country'] = $location_result->country;
335 335
 
336
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
336
+                        $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location
337 337
 
338 338
                     } else {
339 339
 
340
-                        $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
341
-                        $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
342
-                        $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
340
+                        $gd_post_info[$prefix.'city'] = $request_info[$prefix.'city'];
341
+                        $gd_post_info[$prefix.'region'] = $request_info[$prefix.'region'];
342
+                        $gd_post_info[$prefix.'country'] = $request_info[$prefix.'country'];
343 343
 
344 344
                         //----------set post locations when import dummy data-------
345 345
                         $location_result = geodir_get_default_location();
346 346
 
347
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
347
+                        $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location
348 348
                         //-----------------------------------------------------------------
349 349
 
350 350
                     }
351 351
 
352 352
 
353
-                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
354
-                        $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
353
+                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix.'zip'])) {
354
+                        $gd_post_info[$prefix.'zip'] = $request_info[$prefix.'zip'];
355 355
                     }
356 356
 
357 357
 
358 358
                     if (isset($extrafields['show_map']) && $extrafields['show_map']) {
359 359
 
360
-                        if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
361
-                            $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
360
+                        if (isset($request_info[$prefix.'latitude']) && $request_info[$prefix.'latitude'] != '') {
361
+                            $gd_post_info[$prefix.'latitude'] = $request_info[$prefix.'latitude'];
362 362
                         }
363 363
 
364
-                        if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
365
-                            $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
364
+                        if (isset($request_info[$prefix.'longitude']) && $request_info[$prefix.'longitude'] != '') {
365
+                            $gd_post_info[$prefix.'longitude'] = $request_info[$prefix.'longitude'];
366 366
                         }
367 367
 
368
-                        if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
369
-                            $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
368
+                        if (isset($request_info[$prefix.'mapview']) && $request_info[$prefix.'mapview'] != '') {
369
+                            $gd_post_info[$prefix.'mapview'] = $request_info[$prefix.'mapview'];
370 370
                         }
371 371
 
372
-                        if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
373
-                            $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
372
+                        if (isset($request_info[$prefix.'mapzoom']) && $request_info[$prefix.'mapzoom'] != '') {
373
+                            $gd_post_info[$prefix.'mapzoom'] = $request_info[$prefix.'mapzoom'];
374 374
                         }
375 375
 
376 376
                     }
377 377
 
378 378
                     // show lat lng
379
-                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
380
-                        $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
379
+                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix.'latlng'])) {
380
+                        $gd_post_info[$prefix.'latlng'] = $request_info[$prefix.'latlng'];
381 381
                     }
382 382
                 }
383 383
 
@@ -403,16 +403,16 @@  discard block
 block discarded – undo
403 403
 
404 404
                         // check if we need to change the format or not
405 405
                         $date_format_len = strlen(str_replace(' ', '', $date_format));
406
-                        if($date_format_len>5){// if greater then 5 then it's the old style format.
406
+                        if ($date_format_len > 5) {// if greater then 5 then it's the old style format.
407 407
 
408
-                            $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
409
-                            $replace = array('d','j','l','m','n','F','Y');//PHP date format
408
+                            $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
409
+                            $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
410 410
 
411 411
                             $date_format = str_replace($search, $replace, $date_format);
412 412
 
413 413
                             $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
414 414
 
415
-                        }else{
415
+                        } else {
416 416
                             $post_htmlvar_value = $request_info[$name];
417 417
                         }
418 418
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
                 if (isset($request_info[$name])) {
427 427
                     $gd_post_info[$name] = $request_info[$name];
428 428
                 } else {
429
-                    if (isset($request_info['gd_field_' . $name])) {
429
+                    if (isset($request_info['gd_field_'.$name])) {
430 430
                         $gd_post_info[$name] = ''; /* fix de-select for multiselect */
431 431
                     }
432 432
                 }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
         }
487 487
 
488 488
         if (is_array($post_tags)) {
489
-            $taxonomy = $request_info['listing_type'] . '_tags';
489
+            $taxonomy = $request_info['listing_type'].'_tags';
490 490
             wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
491 491
         }
492 492
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
                 $tmpimgArr = trim($request_info['post_images'], ",");
499 499
                 $tmpimgArr = explode(",", $tmpimgArr);
500 500
                 geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
501
-            } else{
501
+            } else {
502 502
                 geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
503 503
             }
504 504
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
     if (!in_array($post_type, $all_postypes))
580 580
         return false;
581 581
 
582
-    $table = $plugin_prefix . $post_type . '_detail';
582
+    $table = $plugin_prefix.$post_type.'_detail';
583 583
 
584 584
     /**
585 585
      * Apply Filter to change Post info
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
      * @since 1.0.0
590 590
      * @package GeoDirectory
591 591
      */
592
-    $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
592
+    $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM ".$wpdb->posts." p,".$table." pd
593 593
 			  WHERE p.ID = pd.post_id
594 594
 			  AND pd.post_id = %d", $post_id));
595 595
 
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 
653 653
         $post_type = get_post_type($post_id);
654 654
 
655
-        $table = $plugin_prefix . $post_type . '_detail';
655
+        $table = $plugin_prefix.$post_type.'_detail';
656 656
 
657 657
         /**
658 658
          * Filter to change Post info
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 
674 674
             $columns = $wpdb->get_col("show columns from $table");
675 675
             foreach ($postmeta as $mkey => $mval) {
676
-                if(in_array($mkey,$columns)) {
676
+                if (in_array($mkey, $columns)) {
677 677
                     if (is_array($mval)) {
678 678
                         $mval = implode(",", $mval);
679 679
                     }
@@ -702,12 +702,12 @@  discard block
 block discarded – undo
702 702
              */
703 703
             do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
704 704
 
705
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
705
+            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
706 706
 
707 707
                 $query_string_array[] = $post_id;
708 708
                 $wpdb->query(
709 709
                     $wpdb->prepare(
710
-                        "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d",
710
+                        "UPDATE ".$table." SET ".$query_string_escaped." where post_id =%d",
711 711
                         $query_string_array
712 712
                     )
713 713
                 );
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
                 array_unshift($query_string_array, $post_id);
719 719
                 $wpdb->query(
720 720
                     $wpdb->prepare(
721
-                        "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped,
721
+                        "INSERT INTO ".$table." SET post_id = %d,".$query_string_escaped,
722 722
                         $query_string_array
723 723
                     )
724 724
                 );
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
         $post_type = get_post_type($post_id);
766 766
 
767
-        $table = $plugin_prefix . $post_type . '_detail';
767
+        $table = $plugin_prefix.$post_type.'_detail';
768 768
 
769 769
         if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
770 770
 
@@ -772,11 +772,11 @@  discard block
 block discarded – undo
772 772
                 $meta_value = implode(",", $meta_value);
773 773
             }
774 774
 
775
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
775
+            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
776 776
 
777 777
                 $wpdb->query(
778 778
                     $wpdb->prepare(
779
-                        "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
779
+                        "UPDATE ".$table." SET ".$postmeta." = '".$meta_value."' where post_id =%d",
780 780
                         array($post_id)
781 781
                     )
782 782
                 );
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 
786 786
                 $wpdb->query(
787 787
                     $wpdb->prepare(
788
-                        "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
788
+                        "INSERT INTO ".$table." SET post_id = %d, ".$postmeta." = '".$meta_value."'",
789 789
                         array($post_id)
790 790
                     )
791 791
                 );
@@ -818,14 +818,14 @@  discard block
 block discarded – undo
818 818
 
819 819
         $post_type = get_post_type($post_id);
820 820
 
821
-        $table = $plugin_prefix . $post_type . '_detail';
821
+        $table = $plugin_prefix.$post_type.'_detail';
822 822
 
823 823
         if (is_array($postmeta) && !empty($postmeta) && $post_id) {
824 824
             $post_meta_set_query = '';
825 825
 
826 826
             foreach ($postmeta as $mkey) {
827 827
                 if ($mval != '')
828
-                    $post_meta_set_query .= $mkey . " = '', ";
828
+                    $post_meta_set_query .= $mkey." = '', ";
829 829
             }
830 830
 
831 831
             $post_meta_set_query = trim($post_meta_set_query, ", ");
@@ -834,11 +834,11 @@  discard block
 block discarded – undo
834 834
                 return false;
835 835
             }
836 836
 
837
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
837
+            if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
838 838
 
839 839
                 $wpdb->query(
840 840
                     $wpdb->prepare(
841
-                        "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
841
+                        "UPDATE ".$table." SET ".$post_meta_set_query." where post_id = %d",
842 842
                         array($post_id)
843 843
                     )
844 844
                 );
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
             }
848 848
 
849 849
         } elseif ($postmeta != '' && $post_id) {
850
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
850
+            if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
851 851
 
852 852
                 $wpdb->query(
853 853
                     $wpdb->prepare(
854
-                        "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
854
+                        "UPDATE ".$table." SET ".$postmeta."= '' where post_id = %d",
855 855
                         array($post_id)
856 856
                     )
857 857
                 );
@@ -893,10 +893,10 @@  discard block
 block discarded – undo
893 893
         if (!in_array($post_type, $all_postypes))
894 894
             return false;
895 895
 
896
-        $table = $plugin_prefix . $post_type . '_detail';
896
+        $table = $plugin_prefix.$post_type.'_detail';
897 897
 
898
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
899
-            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
898
+        if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$meta_key."'") != '') {
899
+            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT ".$meta_key." from ".$table." where post_id = %d", array($post_id)));
900 900
             
901 901
             if ($meta_value && $meta_value !== '') {
902 902
                 $meta_value = maybe_serialize($meta_value);
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
          * @param string $meta_key The meta key to retrieve.
916 916
          * @param bool $single Optional. Whether to return a single value. Default false.
917 917
          */
918
-        return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single );
918
+        return apply_filters('geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single);
919 919
     }
920 920
 }
921 921
 
@@ -941,13 +941,13 @@  discard block
 block discarded – undo
941 941
 
942 942
         $post_type = get_post_type($post_id);
943 943
 
944
-        $table = $plugin_prefix . $post_type . '_detail';
944
+        $table = $plugin_prefix.$post_type.'_detail';
945 945
 
946 946
         $post_images = geodir_get_images($post_id);
947 947
 
948 948
         $wpdb->query(
949 949
             $wpdb->prepare(
950
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
950
+                "UPDATE ".$table." SET featured_image = '' where post_id =%d",
951 951
                 array($post_id)
952 952
             )
953 953
         );
@@ -977,12 +977,12 @@  discard block
 block discarded – undo
977 977
                 $file_path = '';
978 978
                 /* --------- start ------- */
979 979
 
980
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
980
+                $split_img_path = explode(str_replace(array('http://', 'https://'), '', $uploads['baseurl']), str_replace(array('http://', 'https://'), '', $post_image[$m]));
981 981
 
982 982
                 $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
983 983
 
984 984
 
985
-                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)))) {
985
+                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)))) {
986 986
 
987 987
                     /* --------- end ------- */
988 988
                     $curr_img_url = $post_image[$m];
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
                     // If the uploaded file is the right format
1027 1027
                     if (in_array($uploaded_file_type, $allowed_file_types)) {
1028 1028
                         if (!function_exists('wp_handle_upload')) {
1029
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1029
+                            require_once(ABSPATH.'wp-admin/includes/file.php');
1030 1030
                         }
1031 1031
 
1032 1032
                         if (!is_dir($geodir_uploadpath)) {
@@ -1034,41 +1034,41 @@  discard block
 block discarded – undo
1034 1034
                         }
1035 1035
 
1036 1036
                         $external_img = false;
1037
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1037
+                        if (strpos(str_replace(array('http://', 'https://'), '', $curr_img_url), str_replace(array('http://', 'https://'), '', $uploads['baseurl'])) !== false) {
1038 1038
                         } else {
1039 1039
                             $external_img = true;
1040 1040
                         }
1041 1041
 
1042 1042
                         if ($dummy || $external_img) {
1043 1043
                             $uploaded_file = array();
1044
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1044
+                            $uploaded = (array) fetch_remote_file($curr_img_url);
1045 1045
 
1046 1046
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1047 1047
                                 $new_name = basename($uploaded['file']);
1048 1048
                                 $uploaded_file = $uploaded;
1049
-                            }else{
1050
-                                print_r($uploaded);exit;
1049
+                            } else {
1050
+                                print_r($uploaded); exit;
1051 1051
                             }
1052 1052
                             $external_img = false;
1053 1053
                         } else {
1054
-                            $new_name = $post_id . '_' . $file_name;
1054
+                            $new_name = $post_id.'_'.$file_name;
1055 1055
 
1056 1056
                             if ($curr_img_dir == $sub_dir) {
1057
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1058
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1057
+                                $img_path = $geodir_uploadpath.'/'.$filename;
1058
+                                $img_url = $geodir_uploadurl.'/'.$filename;
1059 1059
                             } else {
1060
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1061
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1060
+                                $img_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1061
+                                $img_url = $uploads['url'].'/temp_'.$current_user->data->ID.'/'.$filename;
1062 1062
                             }
1063 1063
 
1064 1064
                             $uploaded_file = '';
1065 1065
 
1066 1066
                             if (file_exists($img_path)) {
1067
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1067
+                                $uploaded_file = copy($img_path, $geodir_uploadpath.'/'.$new_name);
1068 1068
                                 $file_path = '';
1069
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1069
+                            } else if (file_exists($uploads['basedir'].$curr_img_dir.$filename)) {
1070 1070
                                 $uploaded_file = true;
1071
-                                $file_path = $curr_img_dir . '/' . $filename;
1071
+                                $file_path = $curr_img_dir.'/'.$filename;
1072 1072
                             }
1073 1073
 
1074 1074
                             if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
@@ -1077,14 +1077,14 @@  discard block
 block discarded – undo
1077 1077
 
1078 1078
                         if (!empty($uploaded_file)) {
1079 1079
                             if (!isset($file_path) || !$file_path) {
1080
-                                $file_path = $sub_dir . '/' . $new_name;
1080
+                                $file_path = $sub_dir.'/'.$new_name;
1081 1081
                             }
1082 1082
 
1083
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1083
+                            $postcurr_images[] = str_replace(array('http://', 'https://'), '', $uploads['baseurl'].$file_path);
1084 1084
 
1085 1085
                             if ($menu_order == 1) {
1086 1086
 
1087
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1087
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1088 1088
 
1089 1089
                             }
1090 1090
 
@@ -1102,12 +1102,12 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
                             foreach ($attachment as $key => $val) {
1104 1104
                                 if ($val != '')
1105
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1105
+                                    $attachment_set .= $key." = '".$val."', ";
1106 1106
                             }
1107 1107
 
1108 1108
                             $attachment_set = trim($attachment_set, ", ");
1109 1109
 
1110
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1110
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
1111 1111
 
1112 1112
                             $valid_file_ids[] = $wpdb->insert_id;
1113 1113
                         }
@@ -1118,17 +1118,17 @@  discard block
 block discarded – undo
1118 1118
                 } else {
1119 1119
                     $valid_file_ids[] = $find_image;
1120 1120
 
1121
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1121
+                    $postcurr_images[] = str_replace(array('http://', 'https://'), '', $post_image[$m]);
1122 1122
 
1123 1123
                     $wpdb->query(
1124 1124
                         $wpdb->prepare(
1125
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1125
+                            "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d where file =%s AND post_id =%d",
1126 1126
                             array($menu_order, $split_img_path[1], $post_id)
1127 1127
                         )
1128 1128
                     );
1129 1129
 
1130 1130
                     if ($menu_order == 1)
1131
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1131
+                        $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1132 1132
 
1133 1133
                 }
1134 1134
 
@@ -1152,9 +1152,9 @@  discard block
 block discarded – undo
1152 1152
 
1153 1153
                 foreach ($post_images as $img) {
1154 1154
 
1155
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1155
+                    if (!in_array(str_replace(array('http://', 'https://'), '', $img->src), $postcurr_images)) {
1156 1156
 
1157
-                        $invalid_files[] = (object)array('src' => $img->src);
1157
+                        $invalid_files[] = (object) array('src' => $img->src);
1158 1158
 
1159 1159
                     }
1160 1160
 
@@ -1162,12 +1162,12 @@  discard block
 block discarded – undo
1162 1162
 
1163 1163
             }
1164 1164
 
1165
-            $invalid_files = (object)$invalid_files;
1165
+            $invalid_files = (object) $invalid_files;
1166 1166
         }
1167 1167
 
1168 1168
         $remove_files[] = $post_id;
1169 1169
 
1170
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1170
+        $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ".$valid_files_condition." post_id = %d", $remove_files));
1171 1171
 
1172 1172
         if (!empty($invalid_files))
1173 1173
             geodir_remove_attachments($invalid_files);
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 			rmdir($dirPath);
1208 1208
 	}	*/
1209 1209
 
1210
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1210
+    $dirname = $uploads_dir.'/temp_'.$current_user->ID;
1211 1211
     geodir_delete_directory($dirname);
1212 1212
 }
1213 1213
 
@@ -1229,10 +1229,10 @@  discard block
 block discarded – undo
1229 1229
         return false;
1230 1230
     while ($file = readdir($dir_handle)) {
1231 1231
         if ($file != "." && $file != "..") {
1232
-            if (!is_dir($dirname . "/" . $file))
1233
-                unlink($dirname . "/" . $file);
1232
+            if (!is_dir($dirname."/".$file))
1233
+                unlink($dirname."/".$file);
1234 1234
             else
1235
-                geodir_delete_directory($dirname . '/' . $file);
1235
+                geodir_delete_directory($dirname.'/'.$file);
1236 1236
         }
1237 1237
     }
1238 1238
     closedir($dir_handle);
@@ -1261,8 +1261,8 @@  discard block
 block discarded – undo
1261 1261
             foreach ($postcurr_images as $postimg) {
1262 1262
                 $image_name_arr = explode('/', $postimg->src);
1263 1263
                 $filename = end($image_name_arr);
1264
-                if (file_exists($uploads_dir . '/' . $filename))
1265
-                    unlink($uploads_dir . '/' . $filename);
1264
+                if (file_exists($uploads_dir.'/'.$filename))
1265
+                    unlink($uploads_dir.'/'.$filename);
1266 1266
             }
1267 1267
 
1268 1268
         } // endif
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
         }
1304 1304
 
1305 1305
         if (!in_array($post_type, geodir_get_posttypes())) {
1306
-            return false;// if not a GD CPT return;
1306
+            return false; // if not a GD CPT return;
1307 1307
         }
1308 1308
 
1309 1309
 
@@ -1311,22 +1311,22 @@  discard block
 block discarded – undo
1311 1311
          * Filter to force the list images to be smaller.
1312 1312
          * @since 1.6.18
1313 1313
          */
1314
-        if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){
1315
-            $fimg = get_the_post_thumbnail_url($post_id,'medium');
1316
-            if($fimg){
1314
+        if ($size == 'list-thumb' && apply_filters('geodir_use_small_list_img', false)) {
1315
+            $fimg = get_the_post_thumbnail_url($post_id, 'medium');
1316
+            if ($fimg) {
1317 1317
                 $uploads = wp_upload_dir(); 
1318 1318
                 $uploads_baseurl = $uploads['baseurl'];
1319
-                $file = str_replace($uploads_baseurl,'',$fimg);
1319
+                $file = str_replace($uploads_baseurl, '', $fimg);
1320 1320
             }
1321 1321
         }
1322 1322
 
1323
-        $table = $plugin_prefix . $post_type . '_detail';
1323
+        $table = $plugin_prefix.$post_type.'_detail';
1324 1324
 
1325 1325
         if (!$file) {
1326 1326
             if (isset($post->featured_image)) {
1327 1327
                 $file = $post->featured_image;
1328 1328
             } else {
1329
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1329
+                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM ".$table." WHERE post_id = %d", array($post_id)));
1330 1330
             }
1331 1331
         }
1332 1332
 
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
 
1346 1346
             $file_name = $file_info['basename'];
1347 1347
 
1348
-            $uploads_url = $uploads_baseurl . $sub_dir;
1348
+            $uploads_url = $uploads_baseurl.$sub_dir;
1349 1349
             /*
1350 1350
              * Allows the filter of image src for such things as CDN change.
1351 1351
              *
@@ -1355,8 +1355,8 @@  discard block
 block discarded – undo
1355 1355
              * @param string $uploads_url The server upload directory url.
1356 1356
              * @param string $uploads_baseurl The uploads dir base url.
1357 1357
              */
1358
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1359
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1358
+            $img_arr['src'] = apply_filters('geodir_get_featured_image_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
1359
+            $img_arr['path'] = $uploads_path.'/'.$file_name;
1360 1360
             $width = 0;
1361 1361
             $height = 0;
1362 1362
             if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
                 $file_name = $file_info['basename'];
1400 1400
 
1401 1401
                 $img_arr['src'] = $default_img;
1402
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1402
+                $img_arr['path'] = $uploads_path.'/'.$file_name;
1403 1403
 
1404 1404
                 $width = 0;
1405 1405
                 $height = 0;
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
         }
1417 1417
 
1418 1418
         if (!empty($img_arr))
1419
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1419
+            return (object) $img_arr; //return (object)array( 'src' => $file_url, 'path' => $file_path );
1420 1420
         else
1421 1421
             return false;
1422 1422
     }
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
 
1480 1480
         $arrImages = $wpdb->get_results(
1481 1481
             $wpdb->prepare(
1482
-                "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 ",
1482
+                "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 ",
1483 1483
                 array('%image%', $post_id)
1484 1484
             )
1485 1485
         );
@@ -1505,7 +1505,7 @@  discard block
 block discarded – undo
1505 1505
 
1506 1506
                 $file_name = $file_info['basename'];
1507 1507
 
1508
-                $uploads_url = $uploads_baseurl . $sub_dir;
1508
+                $uploads_url = $uploads_baseurl.$sub_dir;
1509 1509
                 /*
1510 1510
                 * Allows the filter of image src for such things as CDN change.
1511 1511
                 *
@@ -1515,8 +1515,8 @@  discard block
 block discarded – undo
1515 1515
                 * @param string $uploads_url The server upload directory url.
1516 1516
                 * @param string $uploads_baseurl The uploads dir base url.
1517 1517
                 */
1518
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1519
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1518
+                $img_arr['src'] = apply_filters('geodir_get_images_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
1519
+                $img_arr['path'] = $uploads_path.'/'.$file_name;
1520 1520
                 $width = 0;
1521 1521
                 $height = 0;
1522 1522
                 if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
                 $img_arr['content'] = $attechment->content; // add the description to the array
1534 1534
                 $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1535 1535
 
1536
-                $return_arr[] = (object)$img_arr;
1536
+                $return_arr[] = (object) $img_arr;
1537 1537
 
1538 1538
                 $counter++;
1539 1539
             }
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
              * @since 1.6.20
1545 1545
              * @param array $return_arr The array of image objects.
1546 1546
              */
1547
-            return apply_filters('geodir_get_images_arr',$return_arr);
1547
+            return apply_filters('geodir_get_images_arr', $return_arr);
1548 1548
         } else if ($no_images) {
1549 1549
             $default_img = '';
1550 1550
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
                 $img_arr['title'] = $file_info['filename']; // add the title to the array
1584 1584
                 $img_arr['content'] = $file_info['filename']; // add the description to the array
1585 1585
 
1586
-                $return_arr[] = (object)$img_arr;
1586
+                $return_arr[] = (object) $img_arr;
1587 1587
 
1588 1588
                 /**
1589 1589
                  * Filter the images array so things can be changed.
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
                  * @since 1.6.20
1592 1592
                  * @param array $return_arr The array of image objects.
1593 1593
                  */
1594
-                return apply_filters('geodir_get_images_arr',$return_arr);
1594
+                return apply_filters('geodir_get_images_arr', $return_arr);
1595 1595
             } else
1596 1596
                 return false;
1597 1597
         }
@@ -1616,8 +1616,8 @@  discard block
 block discarded – undo
1616 1616
 
1617 1617
         $html = '';
1618 1618
         if (!empty($request)) {
1619
-            if (!is_object($request)){
1620
-                $request = (object)$request;
1619
+            if (!is_object($request)) {
1620
+                $request = (object) $request;
1621 1621
             }
1622 1622
 
1623 1623
             if (isset($request->src) && !isset($request->path)) {
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
             $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1632 1632
             $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1633 1633
             if (strpos($img_no_http, $upload_no_http) !== false) {
1634
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1634
+                $request->path = str_replace($img_no_http, $upload_dir['basedir'], $request->path);
1635 1635
             }
1636 1636
             
1637 1637
             $width = 0;
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
             $image->width = $width;
1647 1647
             $image->height = $height;
1648 1648
 
1649
-            $max_size = (object)geodir_get_imagesize($size);
1649
+            $max_size = (object) geodir_get_imagesize($size);
1650 1650
 
1651 1651
             if (!is_wp_error($max_size)) {
1652 1652
                 if ($image->width) {
@@ -1658,15 +1658,15 @@  discard block
 block discarded – undo
1658 1658
                         $width_per = 100;
1659 1659
                 }
1660 1660
 
1661
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1662
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1661
+                if (is_admin() && !isset($_REQUEST['geodir_ajax'])) {
1662
+                    $html = '<div class="geodir_thumbnail"><img style="max-height:'.$max_size->h.'px;" alt="place image" src="'.$image->src.'"  /></div>';
1663 1663
                 } else {
1664
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1665
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1666
-                    }else{
1664
+                    if ($size == 'widget-thumb' || !get_option('geodir_lazy_load', 1)) {
1665
+                        $html = '<div class="geodir_thumbnail" style="background-image:url(\''.$image->src.'\');"></div>';
1666
+                    } else {
1667 1667
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1668 1668
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1669
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1669
+                        $html = '<div data-src="'.str_replace(' ', '%20', $image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1670 1670
 
1671 1671
                     }
1672 1672
 
@@ -1702,15 +1702,15 @@  discard block
 block discarded – undo
1702 1702
 
1703 1703
         $post_type = get_post_type($post_id);
1704 1704
 
1705
-        $table = $plugin_prefix . $post_type . '_detail';
1705
+        $table = $plugin_prefix.$post_type.'_detail';
1706 1706
 
1707 1707
         if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1708 1708
 
1709
-            if ($taxonomy == $post_type . '_tags') {
1709
+            if ($taxonomy == $post_type.'_tags') {
1710 1710
                 if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1711 1711
                     geodir_save_post_meta($post_id, 'post_tags', $terms);
1712 1712
                 }
1713
-            } elseif ($taxonomy == $post_type . 'category') {
1713
+            } elseif ($taxonomy == $post_type.'category') {
1714 1714
                 $srcharr = array('"', '\\');
1715 1715
                 $replarr = array("&quot;", '');
1716 1716
 
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 
1733 1733
                     $wpdb->get_var(
1734 1734
                         $wpdb->prepare(
1735
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1735
+                            "DELETE from ".GEODIR_ICON_TABLE." WHERE cat_id NOT IN ($format) AND post_id = %d ",
1736 1736
                             $cat_ids_array_del
1737 1737
                         )
1738 1738
                     );
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
 
1741 1741
                     $post_term = $wpdb->get_col(
1742 1742
                         $wpdb->prepare(
1743
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1743
+                            "SELECT term_id FROM ".$wpdb->term_taxonomy." WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1744 1744
                             $cat_ids_array
1745 1745
                         )
1746 1746
                     );
@@ -1762,16 +1762,16 @@  discard block
 block discarded – undo
1762 1762
                         $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1763 1763
                         $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1764 1764
 
1765
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1766
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1765
+                        $timing = ' - '.date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1766
+                        $timing .= ' - '.geodir_get_post_meta($post_id, 'st_time', true);
1767 1767
 
1768 1768
                         $json = '{';
1769
-                        $json .= '"id":"' . $post_id . '",';
1770
-                        $json .= '"lat_pos": "' . $lat . '",';
1771
-                        $json .= '"long_pos": "' . $lng . '",';
1772
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1773
-                        $json .= '"icon":"' . $term_icon . '",';
1774
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1769
+                        $json .= '"id":"'.$post_id.'",';
1770
+                        $json .= '"lat_pos": "'.$lat.'",';
1771
+                        $json .= '"long_pos": "'.$lng.'",';
1772
+                        $json .= '"marker_id":"'.$post_id.'_'.$cat_id.'",';
1773
+                        $json .= '"icon":"'.$term_icon.'",';
1774
+                        $json .= '"group":"catgroup'.$cat_id.'"';
1775 1775
                         $json .= '}';
1776 1776
 
1777 1777
 
@@ -1779,9 +1779,9 @@  discard block
 block discarded – undo
1779 1779
                             $post_marker_json = $json;
1780 1780
 
1781 1781
 
1782
-                        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)))) {
1782
+                        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)))) {
1783 1783
 
1784
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1784
+                            $json_query = $wpdb->prepare("UPDATE ".GEODIR_ICON_TABLE." SET
1785 1785
 										post_title = %s,
1786 1786
 										json = %s
1787 1787
 										WHERE post_id = %d AND cat_id = %d ",
@@ -1789,7 +1789,7 @@  discard block
 block discarded – undo
1789 1789
 
1790 1790
                         } else {
1791 1791
 
1792
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1792
+                            $json_query = $wpdb->prepare("INSERT INTO ".GEODIR_ICON_TABLE." SET
1793 1793
 										post_id = %d,
1794 1794
 										post_title = %s,
1795 1795
 										cat_id = %d,
@@ -1807,17 +1807,17 @@  discard block
 block discarded – undo
1807 1807
                 if (!empty($post_term) && is_array($post_term)) {
1808 1808
                     $categories = implode(',', $post_term);
1809 1809
 
1810
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1810
+                    if ($categories != '' && $categories != 0) $categories = ','.$categories.',';
1811 1811
 
1812 1812
                     if (empty($post_marker_json))
1813 1813
                         $post_marker_json = isset($json) ? $json : '';
1814 1814
 
1815
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1815
+                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
1816 1816
 
1817 1817
                         $wpdb->query(
1818 1818
                             $wpdb->prepare(
1819
-                                "UPDATE " . $table . " SET
1820
-								" . $taxonomy . " = %s,
1819
+                                "UPDATE ".$table." SET
1820
+								" . $taxonomy." = %s,
1821 1821
 								marker_json = %s
1822 1822
 								where post_id = %d",
1823 1823
                                 array($categories, $post_marker_json, $post_id)
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 
1839 1839
                                     $wpdb->query(
1840 1840
                                         $wpdb->prepare(
1841
-                                            "UPDATE " . $table . " SET
1841
+                                            "UPDATE ".$table." SET
1842 1842
 											default_category = %s
1843 1843
 											where post_id = %d",
1844 1844
                                             array($categories[0], $post_id)
@@ -1863,9 +1863,9 @@  discard block
 block discarded – undo
1863 1863
 
1864 1864
                         $wpdb->query(
1865 1865
                             $wpdb->prepare(
1866
-                                "INSERT INTO " . $table . " SET
1866
+                                "INSERT INTO ".$table." SET
1867 1867
 								post_id = %d,
1868
-								" . $taxonomy . " = %s,
1868
+								" . $taxonomy." = %s,
1869 1869
 								marker_json = %s ",
1870 1870
 
1871 1871
                                 array($post_id, $categories, $post_marker_json)
@@ -1997,7 +1997,7 @@  discard block
 block discarded – undo
1997 1997
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1998 1998
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1999 1999
                             <?php
2000
-                            }else{
2000
+                            } else {
2001 2001
                                 echo '<div class="geodir-bubble_image"></div>';
2002 2002
                             }
2003 2003
                         } else {
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
                                 ?>
2006 2006
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
2007 2007
                             <?php
2008
-                            }else{
2008
+                            } else {
2009 2009
                                 echo '<div class="geodir-bubble_image"></div>';
2010 2010
                             }
2011 2011
                         }
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
                              * @param object $postinfo_obj The posts info as an object.
2036 2036
                              * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2037 2037
                              */
2038
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2038
+                            do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview);
2039 2039
                             ?>
2040 2040
                         </div>
2041 2041
                         <?php
@@ -2045,9 +2045,9 @@  discard block
 block discarded – undo
2045 2045
                             <div class="geodir-bubble-meta-fade"></div>
2046 2046
                             <div class="geodir-bubble-meta-bottom">
2047 2047
                                 <?php if ($rating_star != '') { ?>
2048
-                                <span class="geodir-bubble-rating"><?php echo $rating_star;?></span>
2048
+                                <span class="geodir-bubble-rating"><?php echo $rating_star; ?></span>
2049 2049
                                 <?php } ?>
2050
-                                <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID);?></span>
2050
+                                <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?></span>
2051 2051
                                 <span class="geodir-bubble-reviews">
2052 2052
                                     <a href="<?php echo get_comments_link($ID); ?>" class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?></a>
2053 2053
                                 </span>
@@ -2109,11 +2109,11 @@  discard block
 block discarded – undo
2109 2109
 
2110 2110
         $post_type = get_post_type($post_id);
2111 2111
 
2112
-        $table = $plugin_prefix . $post_type . '_detail';
2112
+        $table = $plugin_prefix.$post_type.'_detail';
2113 2113
 
2114 2114
         $wpdb->query(
2115 2115
             $wpdb->prepare(
2116
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2116
+                "UPDATE ".$table." SET post_status=%s WHERE post_id=%d",
2117 2117
                 array($status, $post_id)
2118 2118
             )
2119 2119
         );
@@ -2185,18 +2185,18 @@  discard block
 block discarded – undo
2185 2185
 
2186 2186
         $post_type = get_post_type($post_id);
2187 2187
 
2188
-        $table = $plugin_prefix . $post_type . '_detail';
2188
+        $table = $plugin_prefix.$post_type.'_detail';
2189 2189
 
2190 2190
         $wpdb->query(
2191 2191
             $wpdb->prepare(
2192
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2192
+                "UPDATE ".$table." SET `post_id` = %d WHERE `post_id` = %d",
2193 2193
                 array($updatingpost, $temppost)
2194 2194
             )
2195 2195
         );
2196 2196
 
2197 2197
         $wpdb->query(
2198 2198
             $wpdb->prepare(
2199
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2199
+                "UPDATE ".GEODIR_ICON_TABLE." SET `post_id` = %d WHERE `post_id` = %d",
2200 2200
                 array($updatingpost, $temppost)
2201 2201
             )
2202 2202
         );
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
 
2206 2206
         $wpdb->query(
2207 2207
             $wpdb->prepare(
2208
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2208
+                "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET `post_id` = %d WHERE `post_id` = %d",
2209 2209
                 array($updatingpost, $temppost)
2210 2210
             )
2211 2211
         );
@@ -2243,12 +2243,12 @@  discard block
 block discarded – undo
2243 2243
         if (!in_array($post_type, $all_postypes))
2244 2244
             return false;
2245 2245
 
2246
-        $table = $plugin_prefix . $post_type . '_detail';
2246
+        $table = $plugin_prefix.$post_type.'_detail';
2247 2247
 
2248 2248
         /* Delete custom post meta*/
2249 2249
         $wpdb->query(
2250 2250
             $wpdb->prepare(
2251
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2251
+                "DELETE FROM ".$table." WHERE `post_id` = %d",
2252 2252
                 array($deleted_postid)
2253 2253
             )
2254 2254
         );
@@ -2257,7 +2257,7 @@  discard block
 block discarded – undo
2257 2257
 
2258 2258
         $wpdb->query(
2259 2259
             $wpdb->prepare(
2260
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2260
+                "DELETE FROM ".GEODIR_ICON_TABLE." WHERE `post_id` = %d",
2261 2261
                 array($deleted_postid)
2262 2262
             )
2263 2263
         );
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 
2268 2268
         $wpdb->query(
2269 2269
             $wpdb->prepare(
2270
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2270
+                "DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE `post_id` = %d",
2271 2271
                 array($deleted_postid)
2272 2272
             )
2273 2273
         );
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
          */
2340 2340
         do_action('geodir_before_add_from_favorite', $post_id);
2341 2341
 
2342
-        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2342
+        echo '<a href="javascript:void(0);" title="'.$remove_favourite_text.'" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'remove\');"><i class="'.$favourite_icon.'"></i> '.$unfavourite_text.'</a>';
2343 2343
 
2344 2344
         /**
2345 2345
          * Called after adding the post from favourites.
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
          */
2419 2419
         do_action('geodir_before_remove_from_favorite', $post_id);
2420 2420
 
2421
-        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2421
+        echo '<a href="javascript:void(0);"  title="'.$add_favourite_text.'" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'add\');"><i class="'.$favourite_icon.'"></i> '.$favourite_text.'</a>';
2422 2422
 
2423 2423
         /**
2424 2424
          * Called after removing the post from favourites.
@@ -2513,24 +2513,24 @@  discard block
 block discarded – undo
2513 2513
             $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2514 2514
 
2515 2515
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2516
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2516
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"  ><a
2517 2517
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2518
-                onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2519
-                title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2518
+                onclick="javascript:addToFavourite(<?php echo $post_id; ?>,'remove');"
2519
+                title="<?php echo $remove_favourite_text; ?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text; ?>
2520 2520
             </a>   </span><?php
2521 2521
 
2522 2522
         } else {
2523 2523
 
2524 2524
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2525
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2525
+                $script_text = 'javascript:window.location.href=\''.geodir_login_url().'\'';
2526 2526
             } else
2527
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2527
+                $script_text = 'javascript:addToFavourite('.$post_id.',\'add\')';
2528 2528
 
2529
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2529
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"><a class="geodir-addtofav-icon"
2530 2530
                                                                                         href="javascript:void(0);"
2531
-                                                                                        onclick="<?php echo $script_text;?>"
2532
-                                                                                        title="<?php echo $add_favourite_text;?>"><i
2533
-                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2531
+                                                                                        onclick="<?php echo $script_text; ?>"
2532
+                                                                                        title="<?php echo $add_favourite_text; ?>"><i
2533
+                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text; ?></a></span>
2534 2534
         <?php }
2535 2535
     }
2536 2536
 }
@@ -2560,7 +2560,7 @@  discard block
 block discarded – undo
2560 2560
 
2561 2561
             $post_type = $taxonomy_obj->object_type[0];
2562 2562
 
2563
-            $table = $plugin_prefix . $post_type . '_detail';
2563
+            $table = $plugin_prefix.$post_type.'_detail';
2564 2564
 
2565 2565
             /**
2566 2566
              * Filter to modify the 'join' query
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
             $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2584 2584
 
2585 2585
             $count_query = "SELECT count(post_id) FROM
2586
-							" . $table . " as pd " . $join . "
2587
-							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2586
+							" . $table." as pd ".$join."
2587
+							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id."',".$term->taxonomy.") ".$where;
2588 2588
 
2589 2589
             $cat_post_count = $wpdb->get_var($count_query);
2590 2590
             if (empty($cat_post_count) || is_wp_error($cat_post_count))
@@ -2667,7 +2667,7 @@  discard block
 block discarded – undo
2667 2667
     global $post;
2668 2668
     $all_postypes = geodir_get_posttypes();
2669 2669
     if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2670
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2670
+        return ' <a href="'.get_permalink($post->ID).'">'.READ_MORE_TXT.'</a>';
2671 2671
     }
2672 2672
 
2673 2673
     return $more;
@@ -2694,14 +2694,14 @@  discard block
 block discarded – undo
2694 2694
     if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2695 2695
 
2696 2696
         $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2697
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2697
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
2698 2698
 
2699 2699
         $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2700
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2700
+        $term_icon = $path_parts['dirname'].'/cat_icon_'.$term_id.'.png';
2701 2701
 
2702 2702
         $posts = $wpdb->get_results(
2703 2703
             $wpdb->prepare(
2704
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2704
+                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM ".$table." WHERE FIND_IN_SET(%s,%1\$s ) ",
2705 2705
                 array($term_id, $taxonomy)
2706 2706
             )
2707 2707
         );
@@ -2713,19 +2713,19 @@  discard block
 block discarded – undo
2713 2713
                 $lng = $post_obj->post_longitude;
2714 2714
 
2715 2715
                 $json = '{';
2716
-                $json .= '"id":"' . $post_obj->post_id . '",';
2717
-                $json .= '"lat_pos": "' . $lat . '",';
2718
-                $json .= '"long_pos": "' . $lng . '",';
2719
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2720
-                $json .= '"icon":"' . $term_icon . '",';
2721
-                $json .= '"group":"catgroup' . $term_id . '"';
2716
+                $json .= '"id":"'.$post_obj->post_id.'",';
2717
+                $json .= '"lat_pos": "'.$lat.'",';
2718
+                $json .= '"long_pos": "'.$lng.'",';
2719
+                $json .= '"marker_id":"'.$post_obj->post_id.'_'.$term_id.'",';
2720
+                $json .= '"icon":"'.$term_icon.'",';
2721
+                $json .= '"group":"catgroup'.$term_id.'"';
2722 2722
                 $json .= '}';
2723 2723
 
2724 2724
                 if ($post_obj->default_category == $term_id) {
2725 2725
 
2726 2726
                     $wpdb->query(
2727 2727
                         $wpdb->prepare(
2728
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2728
+                            "UPDATE ".$table." SET marker_json = %s where post_id = %d",
2729 2729
                             array($json, $post_obj->post_id)
2730 2730
                         )
2731 2731
                     );
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
 
2734 2734
                 $wpdb->query(
2735 2735
                     $wpdb->prepare(
2736
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2736
+                        "UPDATE ".GEODIR_ICON_TABLE." SET json = %s WHERE post_id = %d AND cat_id = %d",
2737 2737
                         array($json, $post_obj->post_id, $term_id)
2738 2738
                     )
2739 2739
                 );
@@ -2857,7 +2857,7 @@  discard block
 block discarded – undo
2857 2857
 //	print_r($uploads ) ;
2858 2858
     $post_first_image = $wpdb->get_results(
2859 2859
         $wpdb->prepare(
2860
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2860
+            "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d and menu_order = 1  ", array($post_id)
2861 2861
         )
2862 2862
     );
2863 2863
 
@@ -2878,9 +2878,9 @@  discard block
 block discarded – undo
2878 2878
 
2879 2879
         $post_type = get_post_type($post_id);
2880 2880
 
2881
-        $table_name = $plugin_prefix . $post_type . '_detail';
2881
+        $table_name = $plugin_prefix.$post_type.'_detail';
2882 2882
 
2883
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2883
+        $wpdb->query("UPDATE ".$table_name." SET featured_image='".$post_first_image[0]->file."' WHERE post_id =".$post_id);
2884 2884
 
2885 2885
         $new_attachment_name = basename($post_first_image[0]->file);
2886 2886
 
@@ -2893,11 +2893,11 @@  discard block
 block discarded – undo
2893 2893
                 wp_delete_attachment($post_thumbnail_id);
2894 2894
 
2895 2895
             }
2896
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2896
+            $filename = $uploads['basedir'].$post_first_image[0]->file;
2897 2897
 
2898 2898
             $attachment = array(
2899 2899
                 'post_mime_type' => $post_first_image[0]->mime_type,
2900
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2900
+                'guid' => $uploads['baseurl'].$post_first_image[0]->file,
2901 2901
                 'post_parent' => $post_id,
2902 2902
                 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2903 2903
                 'post_content' => ''
@@ -2910,7 +2910,7 @@  discard block
 block discarded – undo
2910 2910
 
2911 2911
                 set_post_thumbnail($post_id, $id);
2912 2912
 
2913
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2913
+                require_once(ABSPATH.'wp-admin/includes/image.php');
2914 2914
                 wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2915 2915
 
2916 2916
             }
@@ -2943,35 +2943,35 @@  discard block
 block discarded – undo
2943 2943
         $post_id = absint($_POST['post_id']);
2944 2944
         $upload_dir = wp_upload_dir();
2945 2945
         $post_type = get_post_type($_POST['post_id']);
2946
-        $table = $plugin_prefix . $post_type . '_detail';
2946
+        $table = $plugin_prefix.$post_type.'_detail';
2947 2947
 
2948 2948
         $post_arr = $wpdb->get_results($wpdb->prepare(
2949
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2949
+            "SELECT * FROM $wpdb->posts p JOIN ".$table." gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2950 2950
             array($post_id)
2951 2951
         )
2952 2952
             , ARRAY_A);
2953 2953
 
2954 2954
         $arrImages = $wpdb->get_results(
2955 2955
             $wpdb->prepare(
2956
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2956
+                "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2957 2957
                 array('%image%', $post_id)
2958 2958
             )
2959 2959
         );
2960 2960
         if ($arrImages) {
2961 2961
             $image_arr = array();
2962 2962
             foreach ($arrImages as $img) {
2963
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2963
+                $image_arr[] = $upload_dir['baseurl'].$img->file;
2964 2964
             }
2965 2965
             $comma_separated = implode(",", $image_arr);
2966 2966
             $post_arr[0]['post_images'] = $comma_separated;
2967 2967
         }
2968 2968
 
2969 2969
 
2970
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2970
+        $cats = $post_arr[0][$post_arr[0]['post_type'].'category'];
2971 2971
         $cat_arr = array_filter(explode(",", $cats));
2972 2972
         $trans_cat = array();
2973 2973
         foreach ($cat_arr as $cat) {
2974
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2974
+            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'].'category', false);
2975 2975
         }
2976 2976
 
2977 2977
 
@@ -3013,7 +3013,7 @@  discard block
 block discarded – undo
3013 3013
 
3014 3014
     $get_data = $wpdb->get_results(
3015 3015
         $wpdb->prepare(
3016
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
3016
+            "SELECT htmlvar_name, field_type, extra_fields FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1'",
3017 3017
             array($listing_type)
3018 3018
         )
3019 3019
     );
@@ -3026,12 +3026,12 @@  discard block
 block discarded – undo
3026 3026
 
3027 3027
                 $extra_fields = unserialize($data->extra_fields);
3028 3028
 
3029
-                $prefix = $data->htmlvar_name . '_';
3029
+                $prefix = $data->htmlvar_name.'_';
3030 3030
 
3031
-                $fields_info[$prefix . 'address'] = $data->field_type;
3031
+                $fields_info[$prefix.'address'] = $data->field_type;
3032 3032
 
3033 3033
                 if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3034
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3034
+                    $fields_info[$prefix.'zip'] = $data->field_type;
3035 3035
 
3036 3036
             } else {
3037 3037
 
@@ -3129,13 +3129,13 @@  discard block
 block discarded – undo
3129 3129
  * @since 1.4.9
3130 3130
  * @package GeoDirectory
3131 3131
  */
3132
-function geodir_fb_like_thumbnail(){
3132
+function geodir_fb_like_thumbnail() {
3133 3133
 
3134 3134
     // return if not a single post
3135
-    if(!is_single()){return;}
3135
+    if (!is_single()) {return; }
3136 3136
 
3137 3137
     global $post;
3138
-    if(isset($post->featured_image) && $post->featured_image){
3138
+    if (isset($post->featured_image) && $post->featured_image) {
3139 3139
         $upload_dir = wp_upload_dir();
3140 3140
         $thumb = $upload_dir['baseurl'].$post->featured_image;
3141 3141
         echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
Please login to merge, or discard this patch.
Braces   +168 added lines, -119 removed lines patch added patch discarded remove patch
@@ -21,12 +21,13 @@  discard block
 block discarded – undo
21 21
 {
22 22
 
23 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, ","));
24
+    if (!empty($post_cat_ids)) {
25
+            $post_cat_array = explode(",", trim($post_cat_ids, ","));
26
+    }
26 27
 
27 28
     if (!isset($default_cat) || empty($default_cat)) {
28 29
         $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
+    } else{
30 31
         if(!is_int($default_cat)){
31 32
             $category = get_term_by('name', $default_cat, $taxonomy);
32 33
             if(isset($category->term_id)){
@@ -384,8 +385,9 @@  discard block
 block discarded – undo
384 385
             } elseif (trim($type) == 'file') {
385 386
                 if (isset($request_info[$name])) {
386 387
                     $request_files = array();
387
-                    if ($request_info[$name] != '')
388
-                        $request_files = explode(",", $request_info[$name]);
388
+                    if ($request_info[$name] != '') {
389
+                                            $request_files = explode(",", $request_info[$name]);
390
+                    }
389 391
 
390 392
                     $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
391 393
                     geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
@@ -412,7 +414,7 @@  discard block
 block discarded – undo
412 414
 
413 415
                             $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
414 416
 
415
-                        }else{
417
+                        } else{
416 418
                             $post_htmlvar_value = $request_info[$name];
417 419
                         }
418 420
 
@@ -452,15 +454,17 @@  discard block
 block discarded – undo
452 454
 
453 455
             foreach ($request_info['post_category'] as $taxonomy => $cat) {
454 456
 
455
-                if ($dummy)
456
-                    $post_category = $cat;
457
-                else {
457
+                if ($dummy) {
458
+                                    $post_category = $cat;
459
+                } else {
458 460
 
459
-                    if (!is_array($cat) && strstr($cat, ','))
460
-                        $cat = explode(',', $cat);
461
+                    if (!is_array($cat) && strstr($cat, ',')) {
462
+                                            $cat = explode(',', $cat);
463
+                    }
461 464
 
462
-                    if (!empty($cat) && is_array($cat))
463
-                        $post_category = array_map('intval', $cat);
465
+                    if (!empty($cat) && is_array($cat)) {
466
+                                            $post_category = array_map('intval', $cat);
467
+                    }
464 468
                 }
465 469
 
466 470
                 wp_set_object_terms($last_post_id, $post_category, $taxonomy);
@@ -478,11 +482,13 @@  discard block
 block discarded – undo
478 482
         if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
479 483
             $post_tags = explode(",", $request_info['post_tags']);
480 484
         } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
481
-            if ($dummy)
482
-                $post_tags = $request_info['post_tags'];
485
+            if ($dummy) {
486
+                            $post_tags = $request_info['post_tags'];
487
+            }
483 488
         } else {
484
-            if ($dummy)
485
-                $post_tags = array($request_info['post_title']);
489
+            if ($dummy) {
490
+                            $post_tags = array($request_info['post_title']);
491
+            }
486 492
         }
487 493
 
488 494
         if (is_array($post_tags)) {
@@ -569,15 +575,17 @@  discard block
 block discarded – undo
569 575
 
570 576
     global $wpdb, $plugin_prefix, $post, $post_info;
571 577
 
572
-    if ($post_id == '' && !empty($post))
573
-        $post_id = $post->ID;
578
+    if ($post_id == '' && !empty($post)) {
579
+            $post_id = $post->ID;
580
+    }
574 581
 
575 582
     $post_type = get_post_type($post_id);
576 583
 
577 584
     $all_postypes = geodir_get_posttypes();
578 585
 
579
-    if (!in_array($post_type, $all_postypes))
580
-        return false;
586
+    if (!in_array($post_type, $all_postypes)) {
587
+            return false;
588
+    }
581 589
 
582 590
     $table = $plugin_prefix . $post_type . '_detail';
583 591
 
@@ -737,8 +745,9 @@  discard block
 block discarded – undo
737 745
             do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
738 746
 
739 747
             return true;
740
-        } else
741
-            return false;
748
+        } else {
749
+                    return false;
750
+        }
742 751
 
743 752
     }
744 753
 }
@@ -792,8 +801,9 @@  discard block
 block discarded – undo
792 801
             }
793 802
 
794 803
 
795
-        } else
796
-            return false;
804
+        } else {
805
+                    return false;
806
+        }
797 807
     }
798 808
 }
799 809
 
@@ -824,8 +834,9 @@  discard block
 block discarded – undo
824 834
             $post_meta_set_query = '';
825 835
 
826 836
             foreach ($postmeta as $mkey) {
827
-                if ($mval != '')
828
-                    $post_meta_set_query .= $mkey . " = '', ";
837
+                if ($mval != '') {
838
+                                    $post_meta_set_query .= $mkey . " = '', ";
839
+                }
829 840
             }
830 841
 
831 842
             $post_meta_set_query = trim($post_meta_set_query, ", ");
@@ -859,8 +870,9 @@  discard block
 block discarded – undo
859 870
                 return true;
860 871
             }
861 872
 
862
-        } else
863
-            return false;
873
+        } else {
874
+                    return false;
875
+        }
864 876
     }
865 877
 }
866 878
 
@@ -890,8 +902,9 @@  discard block
 block discarded – undo
890 902
 
891 903
         $post_type = get_post_type($post_id);
892 904
 
893
-        if (!in_array($post_type, $all_postypes))
894
-            return false;
905
+        if (!in_array($post_type, $all_postypes)) {
906
+                    return false;
907
+        }
895 908
 
896 909
         $table = $plugin_prefix . $post_type . '_detail';
897 910
 
@@ -1046,7 +1059,7 @@  discard block
 block discarded – undo
1046 1059
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1047 1060
                                 $new_name = basename($uploaded['file']);
1048 1061
                                 $uploaded_file = $uploaded;
1049
-                            }else{
1062
+                            } else{
1050 1063
                                 print_r($uploaded);exit;
1051 1064
                             }
1052 1065
                             $external_img = false;
@@ -1071,8 +1084,9 @@  discard block
 block discarded – undo
1071 1084
                                 $file_path = $curr_img_dir . '/' . $filename;
1072 1085
                             }
1073 1086
 
1074
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1075
-                                unlink($img_path);
1087
+                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) {
1088
+                                                            unlink($img_path);
1089
+                            }
1076 1090
                         }
1077 1091
 
1078 1092
                         if (!empty($uploaded_file)) {
@@ -1101,8 +1115,9 @@  discard block
 block discarded – undo
1101 1115
                             $attachment_set = '';
1102 1116
 
1103 1117
                             foreach ($attachment as $key => $val) {
1104
-                                if ($val != '')
1105
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1118
+                                if ($val != '') {
1119
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1120
+                                }
1106 1121
                             }
1107 1122
 
1108 1123
                             $attachment_set = trim($attachment_set, ", ");
@@ -1127,8 +1142,9 @@  discard block
 block discarded – undo
1127 1142
                         )
1128 1143
                     );
1129 1144
 
1130
-                    if ($menu_order == 1)
1131
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1145
+                    if ($menu_order == 1) {
1146
+                                            $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1147
+                    }
1132 1148
 
1133 1149
                 }
1134 1150
 
@@ -1169,8 +1185,9 @@  discard block
 block discarded – undo
1169 1185
 
1170 1186
         $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1171 1187
 
1172
-        if (!empty($invalid_files))
1173
-            geodir_remove_attachments($invalid_files);
1188
+        if (!empty($invalid_files)) {
1189
+                    geodir_remove_attachments($invalid_files);
1190
+        }
1174 1191
     }
1175 1192
 
1176 1193
 }
@@ -1223,16 +1240,19 @@  discard block
 block discarded – undo
1223 1240
 function geodir_delete_directory($dirname)
1224 1241
 {
1225 1242
     $dir_handle = '';
1226
-    if (is_dir($dirname))
1227
-        $dir_handle = opendir($dirname);
1228
-    if (!$dir_handle)
1229
-        return false;
1243
+    if (is_dir($dirname)) {
1244
+            $dir_handle = opendir($dirname);
1245
+    }
1246
+    if (!$dir_handle) {
1247
+            return false;
1248
+    }
1230 1249
     while ($file = readdir($dir_handle)) {
1231 1250
         if ($file != "." && $file != "..") {
1232
-            if (!is_dir($dirname . "/" . $file))
1233
-                unlink($dirname . "/" . $file);
1234
-            else
1235
-                geodir_delete_directory($dirname . '/' . $file);
1251
+            if (!is_dir($dirname . "/" . $file)) {
1252
+                            unlink($dirname . "/" . $file);
1253
+            } else {
1254
+                            geodir_delete_directory($dirname . '/' . $file);
1255
+            }
1236 1256
         }
1237 1257
     }
1238 1258
     closedir($dir_handle);
@@ -1261,8 +1281,9 @@  discard block
 block discarded – undo
1261 1281
             foreach ($postcurr_images as $postimg) {
1262 1282
                 $image_name_arr = explode('/', $postimg->src);
1263 1283
                 $filename = end($image_name_arr);
1264
-                if (file_exists($uploads_dir . '/' . $filename))
1265
-                    unlink($uploads_dir . '/' . $filename);
1284
+                if (file_exists($uploads_dir . '/' . $filename)) {
1285
+                                    unlink($uploads_dir . '/' . $filename);
1286
+                }
1266 1287
             }
1267 1288
 
1268 1289
         } // endif
@@ -1381,9 +1402,9 @@  discard block
 block discarded – undo
1381 1402
                 $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1382 1403
             }
1383 1404
 
1384
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1385
-                $default_img = $default_catimg['src'];
1386
-            elseif ($no_image) {
1405
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1406
+                            $default_img = $default_catimg['src'];
1407
+            } elseif ($no_image) {
1387 1408
                 $default_img = get_option('geodir_listing_no_img');
1388 1409
             }
1389 1410
 
@@ -1415,10 +1436,13 @@  discard block
 block discarded – undo
1415 1436
             }
1416 1437
         }
1417 1438
 
1418
-        if (!empty($img_arr))
1419
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1420
-        else
1421
-            return false;
1439
+        if (!empty($img_arr)) {
1440
+                    return (object)$img_arr;
1441
+        }
1442
+        //return (object)array( 'src' => $file_url, 'path' => $file_path );
1443
+        else {
1444
+                    return false;
1445
+        }
1422 1446
     }
1423 1447
 }
1424 1448
 
@@ -1445,8 +1469,9 @@  discard block
 block discarded – undo
1445 1469
             echo $html;
1446 1470
         } elseif (!empty($html)) {
1447 1471
             return $html;
1448
-        } else
1449
-            return false;
1472
+        } else {
1473
+                    return false;
1474
+        }
1450 1475
     }
1451 1476
 }
1452 1477
 
@@ -1474,8 +1499,9 @@  discard block
 block discarded – undo
1474 1499
         }
1475 1500
         $not_featured = '';
1476 1501
         $sub_dir = '';
1477
-        if (!$add_featured)
1478
-            $not_featured = " AND is_featured = 0 ";
1502
+        if (!$add_featured) {
1503
+                    $not_featured = " AND is_featured = 0 ";
1504
+        }
1479 1505
 
1480 1506
         $arrImages = $wpdb->get_results(
1481 1507
             $wpdb->prepare(
@@ -1496,8 +1522,9 @@  discard block
 block discarded – undo
1496 1522
 
1497 1523
                 $file_info = pathinfo($attechment->file);
1498 1524
 
1499
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1500
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1525
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1526
+                                    $sub_dir = stripslashes_deep($file_info['dirname']);
1527
+                }
1501 1528
 
1502 1529
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1503 1530
                 $uploads_baseurl = $uploads['baseurl'];
@@ -1549,9 +1576,9 @@  discard block
 block discarded – undo
1549 1576
             $default_img = '';
1550 1577
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1551 1578
             $post_type = get_post_type($post_id);
1552
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1553
-                $default_img = $default_catimg['src'];
1554
-            elseif ($no_images) {
1579
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1580
+                            $default_img = $default_catimg['src'];
1581
+            } elseif ($no_images) {
1555 1582
                 $default_img = get_option('geodir_listing_no_img');
1556 1583
             }
1557 1584
 
@@ -1592,8 +1619,9 @@  discard block
 block discarded – undo
1592 1619
                  * @param array $return_arr The array of image objects.
1593 1620
                  */
1594 1621
                 return apply_filters('geodir_get_images_arr',$return_arr);
1595
-            } else
1596
-                return false;
1622
+            } else {
1623
+                            return false;
1624
+            }
1597 1625
         }
1598 1626
     }
1599 1627
 }
@@ -1654,8 +1682,9 @@  discard block
 block discarded – undo
1654 1682
                         $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1655 1683
                     } else if ($image->width < ($max_size->h)) {
1656 1684
                         $width_per = round((($image->width / $max_size->w) * 100), 2);
1657
-                    } else
1658
-                        $width_per = 100;
1685
+                    } else {
1686
+                                            $width_per = 100;
1687
+                    }
1659 1688
                 }
1660 1689
 
1661 1690
                 if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
@@ -1663,7 +1692,7 @@  discard block
 block discarded – undo
1663 1692
                 } else {
1664 1693
                     if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1665 1694
                         $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1666
-                    }else{
1695
+                    } else{
1667 1696
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1668 1697
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1669 1698
                         $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
@@ -1678,8 +1707,9 @@  discard block
 block discarded – undo
1678 1707
             echo $html;
1679 1708
         } elseif (!empty($html)) {
1680 1709
             return $html;
1681
-        } else
1682
-            return false;
1710
+        } else {
1711
+                    return false;
1712
+        }
1683 1713
     }
1684 1714
 }
1685 1715
 
@@ -1717,8 +1747,9 @@  discard block
 block discarded – undo
1717 1747
                 $post_obj = get_post($post_id);
1718 1748
 
1719 1749
                 $cat_ids = array('0');
1720
-                if (is_array($tt_ids))
1721
-                    $cat_ids = $tt_ids;
1750
+                if (is_array($tt_ids)) {
1751
+                                    $cat_ids = $tt_ids;
1752
+                }
1722 1753
 
1723 1754
 
1724 1755
                 if (!empty($cat_ids)) {
@@ -1775,8 +1806,9 @@  discard block
 block discarded – undo
1775 1806
                         $json .= '}';
1776 1807
 
1777 1808
 
1778
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1779
-                            $post_marker_json = $json;
1809
+                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) {
1810
+                                                    $post_marker_json = $json;
1811
+                        }
1780 1812
 
1781 1813
 
1782 1814
                         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)))) {
@@ -1807,10 +1839,13 @@  discard block
 block discarded – undo
1807 1839
                 if (!empty($post_term) && is_array($post_term)) {
1808 1840
                     $categories = implode(',', $post_term);
1809 1841
 
1810
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1842
+                    if ($categories != '' && $categories != 0) {
1843
+                    	$categories = ',' . $categories . ',';
1844
+                    }
1811 1845
 
1812
-                    if (empty($post_marker_json))
1813
-                        $post_marker_json = isset($json) ? $json : '';
1846
+                    if (empty($post_marker_json)) {
1847
+                                            $post_marker_json = isset($json) ? $json : '';
1848
+                    }
1814 1849
 
1815 1850
                     if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1816 1851
 
@@ -1849,8 +1884,9 @@  discard block
 block discarded – undo
1849 1884
 
1850 1885
                                 }
1851 1886
 
1852
-                                if ($default_category == '')
1853
-                                    $default_category = $categories[0];
1887
+                                if ($default_category == '') {
1888
+                                                                    $default_category = $categories[0];
1889
+                                }
1854 1890
 
1855 1891
                                 geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1856 1892
 
@@ -1997,7 +2033,7 @@  discard block
 block discarded – undo
1997 2033
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1998 2034
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1999 2035
                             <?php
2000
-                            }else{
2036
+                            } else{
2001 2037
                                 echo '<div class="geodir-bubble_image"></div>';
2002 2038
                             }
2003 2039
                         } else {
@@ -2005,7 +2041,7 @@  discard block
 block discarded – undo
2005 2041
                                 ?>
2006 2042
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
2007 2043
                             <?php
2008
-                            }else{
2044
+                            } else{
2009 2045
                                 echo '<div class="geodir-bubble_image"></div>';
2010 2046
                             }
2011 2047
                         }
@@ -2086,10 +2122,11 @@  discard block
 block discarded – undo
2086 2122
      */
2087 2123
     function geodir_new_post_default_status()
2088 2124
     {
2089
-        if (get_option('geodir_new_post_default_status'))
2090
-            return get_option('geodir_new_post_default_status');
2091
-        else
2092
-            return 'publish';
2125
+        if (get_option('geodir_new_post_default_status')) {
2126
+                    return get_option('geodir_new_post_default_status');
2127
+        } else {
2128
+                    return 'publish';
2129
+        }
2093 2130
 
2094 2131
     }
2095 2132
 }
@@ -2240,8 +2277,9 @@  discard block
 block discarded – undo
2240 2277
 
2241 2278
         $all_postypes = geodir_get_posttypes();
2242 2279
 
2243
-        if (!in_array($post_type, $all_postypes))
2244
-            return false;
2280
+        if (!in_array($post_type, $all_postypes)) {
2281
+                    return false;
2282
+        }
2245 2283
 
2246 2284
         $table = $plugin_prefix . $post_type . '_detail';
2247 2285
 
@@ -2509,8 +2547,9 @@  discard block
 block discarded – undo
2509 2547
         $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2510 2548
 
2511 2549
         $user_meta_data = '';
2512
-        if (isset($current_user->data->ID))
2513
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2550
+        if (isset($current_user->data->ID)) {
2551
+                    $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2552
+        }
2514 2553
 
2515 2554
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2516 2555
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
@@ -2523,8 +2562,9 @@  discard block
 block discarded – undo
2523 2562
 
2524 2563
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2525 2564
                 $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2526
-            } else
2527
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2565
+            } else {
2566
+                            $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2567
+            }
2528 2568
 
2529 2569
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2530 2570
                                                                                         href="javascript:void(0);"
@@ -2587,14 +2627,16 @@  discard block
 block discarded – undo
2587 2627
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2588 2628
 
2589 2629
             $cat_post_count = $wpdb->get_var($count_query);
2590
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2591
-                $cat_post_count = 0;
2630
+            if (empty($cat_post_count) || is_wp_error($cat_post_count)) {
2631
+                            $cat_post_count = 0;
2632
+            }
2592 2633
 
2593 2634
             return $cat_post_count;
2594 2635
 
2595
-        } else
2596
-
2597
-            return $term->count;
2636
+        } else {
2637
+        
2638
+            return $term->count;
2639
+        }
2598 2640
     }
2599 2641
     return false;
2600 2642
 
@@ -2641,13 +2683,15 @@  discard block
 block discarded – undo
2641 2683
 		return $length;
2642 2684
 	}
2643 2685
 	
2644
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2645
-        $length = get_option('geodir_desc_word_limit');
2646
-    elseif (get_query_var('excerpt_length'))
2647
-        $length = get_query_var('excerpt_length');
2686
+    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) {
2687
+            $length = get_option('geodir_desc_word_limit');
2688
+    } elseif (get_query_var('excerpt_length')) {
2689
+            $length = get_query_var('excerpt_length');
2690
+    }
2648 2691
 
2649
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2650
-        $length = get_option('geodir_author_desc_word_limit');
2692
+    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) {
2693
+            $length = get_option('geodir_author_desc_word_limit');
2694
+    }
2651 2695
 
2652 2696
     return $length;
2653 2697
 }
@@ -2780,10 +2824,11 @@  discard block
 block discarded – undo
2780 2824
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2781 2825
 {
2782 2826
     $listing_author_id = geodir_get_listing_author($listing_id);
2783
-    if ($listing_author_id == $user_id)
2784
-        return true;
2785
-    else
2786
-        return false;
2827
+    if ($listing_author_id == $user_id) {
2828
+            return true;
2829
+    } else {
2830
+            return false;
2831
+    }
2787 2832
 
2788 2833
 }
2789 2834
 
@@ -2832,10 +2877,11 @@  discard block
 block discarded – undo
2832 2877
     $pattern = '/-\d+x\d+\./';
2833 2878
     preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2834 2879
 
2835
-    if (empty($matches))
2836
-        return '';
2837
-    else
2838
-        return $file;
2880
+    if (empty($matches)) {
2881
+            return '';
2882
+    } else {
2883
+            return $file;
2884
+    }
2839 2885
 
2840 2886
 }
2841 2887
 
@@ -2920,8 +2966,9 @@  discard block
 block discarded – undo
2920 2966
     } else {
2921 2967
         //set_post_thumbnail($post_id,-1);
2922 2968
 
2923
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2924
-            wp_delete_attachment($post_thumbnail_id);
2969
+        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2970
+                    wp_delete_attachment($post_thumbnail_id);
2971
+        }
2925 2972
 
2926 2973
     }
2927 2974
 }
@@ -3006,8 +3053,9 @@  discard block
 block discarded – undo
3006 3053
 
3007 3054
     global $wpdb;
3008 3055
 
3009
-    if ($listing_type == '')
3010
-        $listing_type = 'gd_place';
3056
+    if ($listing_type == '') {
3057
+            $listing_type = 'gd_place';
3058
+    }
3011 3059
 
3012 3060
     $fields_info = array();
3013 3061
 
@@ -3030,8 +3078,9 @@  discard block
 block discarded – undo
3030 3078
 
3031 3079
                 $fields_info[$prefix . 'address'] = $data->field_type;
3032 3080
 
3033
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3034
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3081
+                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
3082
+                                    $fields_info[$prefix . 'zip'] = $data->field_type;
3083
+                }
3035 3084
 
3036 3085
             } else {
3037 3086
 
Please login to merge, or discard this patch.
geodirectory-functions/custom_fields_functions.php 3 patches
Indentation   +2267 added lines, -2267 removed lines patch added patch discarded remove patch
@@ -10,52 +10,52 @@  discard block
 block discarded – undo
10 10
 global $wpdb, $table_prefix;
11 11
 
12 12
 if (!function_exists('geodir_column_exist')) {
13
-    /**
14
-     * Check table column exist or not.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global object $wpdb WordPress Database object.
19
-     * @param string $db The table name.
20
-     * @param string $column The column name.
21
-     * @return bool If column exists returns true. Otherwise false.
22
-     */
23
-    function geodir_column_exist($db, $column)
24
-    {
25
-        global $wpdb;
26
-        $exists = false;
27
-        $columns = $wpdb->get_col("show columns from $db");
28
-        foreach ($columns as $c) {
29
-            if ($c == $column) {
30
-                $exists = true;
31
-                break;
32
-            }
33
-        }
34
-        return $exists;
35
-    }
13
+	/**
14
+	 * Check table column exist or not.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global object $wpdb WordPress Database object.
19
+	 * @param string $db The table name.
20
+	 * @param string $column The column name.
21
+	 * @return bool If column exists returns true. Otherwise false.
22
+	 */
23
+	function geodir_column_exist($db, $column)
24
+	{
25
+		global $wpdb;
26
+		$exists = false;
27
+		$columns = $wpdb->get_col("show columns from $db");
28
+		foreach ($columns as $c) {
29
+			if ($c == $column) {
30
+				$exists = true;
31
+				break;
32
+			}
33
+		}
34
+		return $exists;
35
+	}
36 36
 }
37 37
 
38 38
 if (!function_exists('geodir_add_column_if_not_exist')) {
39
-    /**
40
-     * Add column if table column not exist.
41
-     *
42
-     * @since 1.0.0
43
-     * @package GeoDirectory
44
-     * @global object $wpdb WordPress Database object.
45
-     * @param string $db The table name.
46
-     * @param string $column The column name.
47
-     * @param string $column_attr The column attributes.
48
-     */
49
-    function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50
-    {
51
-        global $wpdb;
52
-        $result = 0;// no rows affected
53
-        if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
-        }
57
-        return $result;
58
-    }
39
+	/**
40
+	 * Add column if table column not exist.
41
+	 *
42
+	 * @since 1.0.0
43
+	 * @package GeoDirectory
44
+	 * @global object $wpdb WordPress Database object.
45
+	 * @param string $db The table name.
46
+	 * @param string $column The column name.
47
+	 * @param string $column_attr The column attributes.
48
+	 */
49
+	function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50
+	{
51
+		global $wpdb;
52
+		$result = 0;// no rows affected
53
+		if (!geodir_column_exist($db, $column)) {
54
+			if (!empty($db) && !empty($column))
55
+				$result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+		}
57
+		return $result;
58
+	}
59 59
 }
60 60
 
61 61
 /**
@@ -72,706 +72,706 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function geodir_post_custom_fields($package_id = '', $default = 'all', $post_type = 'gd_place', $fields_location = 'none')
74 74
 {
75
-    global $wpdb, $geodir_post_custom_fields_cache;
76
-
77
-    $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
78
-
79
-    if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80
-        return $geodir_post_custom_fields_cache[$cache_stored];
81
-    }
82
-
83
-    $default_query = '';
84
-
85
-    if ($default == 'default')
86
-        $default_query .= " and is_admin IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query .= " and is_admin = '0' ";
89
-
90
-    if ($fields_location == 'none') {
91
-    } else{
92
-        $fields_location = esc_sql( $fields_location );
93
-        $default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94
-    }
95
-
96
-    $post_meta_info = $wpdb->get_results(
97
-        $wpdb->prepare(
98
-            "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99
-            array($post_type)
100
-        )
101
-    );
102
-
103
-
104
-    $return_arr = array();
105
-    if ($post_meta_info) {
106
-
107
-        foreach ($post_meta_info as $post_meta_info_obj) {
108
-
109
-            $custom_fields = array(
110
-                "name" => $post_meta_info_obj->htmlvar_name,
111
-                "label" => $post_meta_info_obj->clabels,
112
-                "default" => $post_meta_info_obj->default_value,
113
-                "type" => $post_meta_info_obj->field_type,
114
-                "desc" => $post_meta_info_obj->admin_desc);
115
-
116
-            if ($post_meta_info_obj->field_type) {
117
-                $options = explode(',', $post_meta_info_obj->option_values);
118
-                $custom_fields["options"] = $options;
119
-            }
120
-
121
-            foreach ($post_meta_info_obj as $key => $val) {
122
-                $custom_fields[$key] = $val;
123
-            }
124
-
125
-            $pricearr = array();
126
-            $pricearr = explode(',', $post_meta_info_obj->packages);
127
-
128
-            if ($package_id != '' && in_array($package_id, $pricearr)) {
129
-                $return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
130
-            } elseif ($package_id == '') {
131
-                $return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
132
-            }
133
-        }
134
-    }
135
-    $geodir_post_custom_fields_cache[$cache_stored] = $return_arr;
136
-
137
-    if (has_filter('geodir_filter_geodir_post_custom_fields')) {
138
-        /**
139
-         * Filter the post custom fields array.
140
-         *
141
-         * @since 1.0.0
142
-         *
143
-         * @param array $return_arr Post custom fields array.
144
-         * @param int|string $package_id The package ID.
145
-         * @param string $post_type Optional. The wordpress post type.
146
-         * @param string $fields_location Optional. Where exactly are you going to place this custom fields?.
147
-         */
148
-        $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
149
-    }
150
-
151
-    return $return_arr;
75
+	global $wpdb, $geodir_post_custom_fields_cache;
76
+
77
+	$cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
78
+
79
+	if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80
+		return $geodir_post_custom_fields_cache[$cache_stored];
81
+	}
82
+
83
+	$default_query = '';
84
+
85
+	if ($default == 'default')
86
+		$default_query .= " and is_admin IN ('1') ";
87
+	elseif ($default == 'custom')
88
+		$default_query .= " and is_admin = '0' ";
89
+
90
+	if ($fields_location == 'none') {
91
+	} else{
92
+		$fields_location = esc_sql( $fields_location );
93
+		$default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94
+	}
95
+
96
+	$post_meta_info = $wpdb->get_results(
97
+		$wpdb->prepare(
98
+			"select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99
+			array($post_type)
100
+		)
101
+	);
102
+
103
+
104
+	$return_arr = array();
105
+	if ($post_meta_info) {
106
+
107
+		foreach ($post_meta_info as $post_meta_info_obj) {
108
+
109
+			$custom_fields = array(
110
+				"name" => $post_meta_info_obj->htmlvar_name,
111
+				"label" => $post_meta_info_obj->clabels,
112
+				"default" => $post_meta_info_obj->default_value,
113
+				"type" => $post_meta_info_obj->field_type,
114
+				"desc" => $post_meta_info_obj->admin_desc);
115
+
116
+			if ($post_meta_info_obj->field_type) {
117
+				$options = explode(',', $post_meta_info_obj->option_values);
118
+				$custom_fields["options"] = $options;
119
+			}
120
+
121
+			foreach ($post_meta_info_obj as $key => $val) {
122
+				$custom_fields[$key] = $val;
123
+			}
124
+
125
+			$pricearr = array();
126
+			$pricearr = explode(',', $post_meta_info_obj->packages);
127
+
128
+			if ($package_id != '' && in_array($package_id, $pricearr)) {
129
+				$return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
130
+			} elseif ($package_id == '') {
131
+				$return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
132
+			}
133
+		}
134
+	}
135
+	$geodir_post_custom_fields_cache[$cache_stored] = $return_arr;
136
+
137
+	if (has_filter('geodir_filter_geodir_post_custom_fields')) {
138
+		/**
139
+		 * Filter the post custom fields array.
140
+		 *
141
+		 * @since 1.0.0
142
+		 *
143
+		 * @param array $return_arr Post custom fields array.
144
+		 * @param int|string $package_id The package ID.
145
+		 * @param string $post_type Optional. The wordpress post type.
146
+		 * @param string $fields_location Optional. Where exactly are you going to place this custom fields?.
147
+		 */
148
+		$return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
149
+	}
150
+
151
+	return $return_arr;
152 152
 }
153 153
 
154
-    /**
155
-     * Adds admin html for custom fields.
156
-     *
157
-     * @since 1.0.0
158
-     * @package GeoDirectory
159
-     * @global object $wpdb WordPress Database object.
160
-     * @param string $field_type The form field type.
161
-     * @param object|int $result_str The custom field results object or row id.
162
-     * @param string $field_ins_upd When set to "submit" displays form.
163
-     * @param string $field_type_key The key of the custom field.
164
-     */
165
-    function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
166
-    {
167
-        global $wpdb;
168
-        $cf = $result_str;
169
-        if (!is_object($cf)) {
170
-
171
-            $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
172
-
173
-        } else {
174
-            $field_info = $cf;
175
-            $result_str = $cf->id;
176
-        }
177
-        /**
178
-         * Contains custom field html.
179
-         *
180
-         * @since 1.0.0
181
-         */
182
-        include('custom_field_html.php');
183
-
184
-    }
154
+	/**
155
+	 * Adds admin html for custom fields.
156
+	 *
157
+	 * @since 1.0.0
158
+	 * @package GeoDirectory
159
+	 * @global object $wpdb WordPress Database object.
160
+	 * @param string $field_type The form field type.
161
+	 * @param object|int $result_str The custom field results object or row id.
162
+	 * @param string $field_ins_upd When set to "submit" displays form.
163
+	 * @param string $field_type_key The key of the custom field.
164
+	 */
165
+	function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
166
+	{
167
+		global $wpdb;
168
+		$cf = $result_str;
169
+		if (!is_object($cf)) {
170
+
171
+			$field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
172
+
173
+		} else {
174
+			$field_info = $cf;
175
+			$result_str = $cf->id;
176
+		}
177
+		/**
178
+		 * Contains custom field html.
179
+		 *
180
+		 * @since 1.0.0
181
+		 */
182
+		include('custom_field_html.php');
183
+
184
+	}
185 185
 
186 186
 
187 187
 if (!function_exists('geodir_custom_field_delete')) {
188
-    /**
189
-     * Delete custom field using field id.
190
-     *
191
-     * @since 1.0.0
192
-     * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
193
-     * @package GeoDirectory
194
-     * @global object $wpdb WordPress Database object.
195
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
196
-     * @param string $field_id The custom field ID.
197
-     * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
198
-     */
199
-    function geodir_custom_field_delete($field_id = '') {
200
-        global $wpdb, $plugin_prefix;
201
-
202
-        if ($field_id != '') {
203
-            $cf = trim($field_id, '_');
204
-
205
-            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
-                $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
207
-
208
-                $post_type = $field->post_type;
209
-                $htmlvar_name = $field->htmlvar_name;
210
-
211
-                if ($post_type != '' && $htmlvar_name != '') {
212
-                    $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213
-                }
214
-
215
-                /**
216
-                 * Called after a custom field is deleted.
217
-                 *
218
-                 * @since 1.0.0
219
-                 * @param string $cf The fields ID.
220
-                 * @param string $field->htmlvar_name The html variable name for the field.
221
-                 * @param string $post_type The post type the field belongs to.
222
-                 */
223
-                do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224
-
225
-                if ($field->field_type == 'address') {
226
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
235
-                } else {
236
-                    if ($field->field_type != 'fieldset') {
237
-                        $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
238
-                    }
239
-                }
240
-
241
-                return $field_id;
242
-            } else
243
-                return 0;
244
-        } else
245
-            return 0;
246
-    }
188
+	/**
189
+	 * Delete custom field using field id.
190
+	 *
191
+	 * @since 1.0.0
192
+	 * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
193
+	 * @package GeoDirectory
194
+	 * @global object $wpdb WordPress Database object.
195
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
196
+	 * @param string $field_id The custom field ID.
197
+	 * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
198
+	 */
199
+	function geodir_custom_field_delete($field_id = '') {
200
+		global $wpdb, $plugin_prefix;
201
+
202
+		if ($field_id != '') {
203
+			$cf = trim($field_id, '_');
204
+
205
+			if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
+				$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
207
+
208
+				$post_type = $field->post_type;
209
+				$htmlvar_name = $field->htmlvar_name;
210
+
211
+				if ($post_type != '' && $htmlvar_name != '') {
212
+					$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213
+				}
214
+
215
+				/**
216
+				 * Called after a custom field is deleted.
217
+				 *
218
+				 * @since 1.0.0
219
+				 * @param string $cf The fields ID.
220
+				 * @param string $field->htmlvar_name The html variable name for the field.
221
+				 * @param string $post_type The post type the field belongs to.
222
+				 */
223
+				do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224
+
225
+				if ($field->field_type == 'address') {
226
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
235
+				} else {
236
+					if ($field->field_type != 'fieldset') {
237
+						$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
238
+					}
239
+				}
240
+
241
+				return $field_id;
242
+			} else
243
+				return 0;
244
+		} else
245
+			return 0;
246
+	}
247 247
 }
248 248
 
249 249
 if (!function_exists('geodir_custom_field_save')) {
250
-    /**
251
-     * Save or Update custom fields into the database.
252
-     *
253
-     * @since 1.0.0
254
-     * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
-     * @package GeoDirectory
256
-     * @global object $wpdb WordPress Database object.
257
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
258
-     * @param array $request_field {
259
-     *    Attributes of the request field array.
260
-     *
261
-     *    @type string $action Ajax Action name. Default "geodir_ajax_action".
262
-     *    @type string $manage_field_type Field type Default "custom_fields".
263
-     *    @type string $create_field Create field Default "true".
264
-     *    @type string $field_ins_upd Field ins upd Default "submit".
265
-     *    @type string $_wpnonce WP nonce value.
266
-     *    @type string $listing_type Listing type Example "gd_place".
267
-     *    @type string $field_type Field type Example "radio".
268
-     *    @type string $field_id Field id Example "12".
269
-     *    @type string $data_type Data type Example "VARCHAR".
270
-     *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
271
-     *    @type array $show_on_pkg Package list to display this field.
272
-     *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
273
-     *    @type string $site_title Section title which you wish to display in frontend.
274
-     *    @type string $admin_desc Section description which will appear in frontend.
275
-     *    @type string $htmlvar_name Html variable name. This should be a unique name.
276
-     *    @type string $clabels Section Title which will appear in backend.
277
-     *    @type string $default_value The default value (for "link" this will be used as the link text).
278
-     *    @type string $sort_order The display order of this field in backend. e.g. 5.
279
-     *    @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field.
280
-     *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
281
-     *    @type string $is_required Use "1" to set field as required.
282
-     *    @type string $required_msg Enter text for error message if field required and have not full fill requirement.
283
-     *    @type string $show_on_listing Want to show this on listing page?.
284
-     *    @type string $show_in What locations to show the custom field in.
285
-     *    @type string $show_on_detail Want to show this in More Info tab on detail page?.
286
-     *    @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes.
287
-     *    @type string $option_values Option Values should be separated by comma.
288
-     *    @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class.
289
-     *    @type string $css_class Enter custom css class for field custom style.
290
-     *    @type array $extra_fields An array of extra fields to store.
291
-     *
292
-     * }
293
-     * @param bool $default Not yet implemented.
294
-     * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
295
-     */
296
-    function geodir_custom_field_save($request_field = array(), $default = false)
297
-    {
298
-
299
-        global $wpdb, $plugin_prefix;
300
-
301
-        $old_html_variable = '';
302
-
303
-        $data_type = trim($request_field['data_type']);
304
-
305
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
306
-
307
-        // some servers fail if a POST value is VARCHAR so we change it.
308
-        if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
309
-            $request_field['data_type'] = 'VARCHAR';
310
-        }
311
-
312
-        $cf = trim($result_str, '_');
313
-
314
-
315
-        /*-------- check duplicate validation --------*/
316
-
317
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
318
-        $post_type = $request_field['listing_type'];
319
-
320
-        if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
321
-            $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
322
-        }
323
-
324
-        $check_html_variable = $wpdb->get_var(
325
-            $wpdb->prepare(
326
-                "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
327
-                array($cf, $cehhtmlvar_name, $post_type)
328
-            )
329
-        );
330
-
331
-
332
-        if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
333
-
334
-            if ($cf != '') {
335
-
336
-                $post_meta_info = $wpdb->get_row(
337
-                    $wpdb->prepare(
338
-                        "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
339
-                        array($cf)
340
-                    )
341
-                );
342
-
343
-            }
344
-
345
-            if (!empty($post_meta_info)) {
346
-                $post_val = $post_meta_info;
347
-                $old_html_variable = $post_val->htmlvar_name;
348
-
349
-            }
350
-
351
-
352
-
353
-            if ($post_type == '') $post_type = 'gd_place';
354
-
355
-
356
-            $detail_table = $plugin_prefix . $post_type . '_detail';
357
-
358
-            $admin_title = $request_field['admin_title'];
359
-            $site_title = $request_field['site_title'];
360
-            $data_type = $request_field['data_type'];
361
-            $field_type = $request_field['field_type'];
362
-            $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type;
363
-            $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
364
-            $admin_desc = $request_field['admin_desc'];
365
-            $clabels = isset($request_field['clabels']) ? $request_field['clabels'] : '';
366
-            $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
367
-            $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
368
-            $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
369
-            $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
370
-            $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
371
-            $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
372
-            $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
373
-            $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
374
-            $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : '';
375
-            $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
376
-            $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
377
-            $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
378
-            $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
379
-            $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
380
-            $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
381
-            $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
250
+	/**
251
+	 * Save or Update custom fields into the database.
252
+	 *
253
+	 * @since 1.0.0
254
+	 * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
+	 * @package GeoDirectory
256
+	 * @global object $wpdb WordPress Database object.
257
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
258
+	 * @param array $request_field {
259
+	 *    Attributes of the request field array.
260
+	 *
261
+	 *    @type string $action Ajax Action name. Default "geodir_ajax_action".
262
+	 *    @type string $manage_field_type Field type Default "custom_fields".
263
+	 *    @type string $create_field Create field Default "true".
264
+	 *    @type string $field_ins_upd Field ins upd Default "submit".
265
+	 *    @type string $_wpnonce WP nonce value.
266
+	 *    @type string $listing_type Listing type Example "gd_place".
267
+	 *    @type string $field_type Field type Example "radio".
268
+	 *    @type string $field_id Field id Example "12".
269
+	 *    @type string $data_type Data type Example "VARCHAR".
270
+	 *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
271
+	 *    @type array $show_on_pkg Package list to display this field.
272
+	 *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
273
+	 *    @type string $site_title Section title which you wish to display in frontend.
274
+	 *    @type string $admin_desc Section description which will appear in frontend.
275
+	 *    @type string $htmlvar_name Html variable name. This should be a unique name.
276
+	 *    @type string $clabels Section Title which will appear in backend.
277
+	 *    @type string $default_value The default value (for "link" this will be used as the link text).
278
+	 *    @type string $sort_order The display order of this field in backend. e.g. 5.
279
+	 *    @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field.
280
+	 *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
281
+	 *    @type string $is_required Use "1" to set field as required.
282
+	 *    @type string $required_msg Enter text for error message if field required and have not full fill requirement.
283
+	 *    @type string $show_on_listing Want to show this on listing page?.
284
+	 *    @type string $show_in What locations to show the custom field in.
285
+	 *    @type string $show_on_detail Want to show this in More Info tab on detail page?.
286
+	 *    @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes.
287
+	 *    @type string $option_values Option Values should be separated by comma.
288
+	 *    @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class.
289
+	 *    @type string $css_class Enter custom css class for field custom style.
290
+	 *    @type array $extra_fields An array of extra fields to store.
291
+	 *
292
+	 * }
293
+	 * @param bool $default Not yet implemented.
294
+	 * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
295
+	 */
296
+	function geodir_custom_field_save($request_field = array(), $default = false)
297
+	{
298
+
299
+		global $wpdb, $plugin_prefix;
300
+
301
+		$old_html_variable = '';
302
+
303
+		$data_type = trim($request_field['data_type']);
304
+
305
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
306
+
307
+		// some servers fail if a POST value is VARCHAR so we change it.
308
+		if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
309
+			$request_field['data_type'] = 'VARCHAR';
310
+		}
311
+
312
+		$cf = trim($result_str, '_');
313
+
314
+
315
+		/*-------- check duplicate validation --------*/
316
+
317
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
318
+		$post_type = $request_field['listing_type'];
319
+
320
+		if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
321
+			$cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
322
+		}
323
+
324
+		$check_html_variable = $wpdb->get_var(
325
+			$wpdb->prepare(
326
+				"select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
327
+				array($cf, $cehhtmlvar_name, $post_type)
328
+			)
329
+		);
330
+
331
+
332
+		if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
333
+
334
+			if ($cf != '') {
335
+
336
+				$post_meta_info = $wpdb->get_row(
337
+					$wpdb->prepare(
338
+						"select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
339
+						array($cf)
340
+					)
341
+				);
342
+
343
+			}
344
+
345
+			if (!empty($post_meta_info)) {
346
+				$post_val = $post_meta_info;
347
+				$old_html_variable = $post_val->htmlvar_name;
348
+
349
+			}
350
+
351
+
352
+
353
+			if ($post_type == '') $post_type = 'gd_place';
354
+
355
+
356
+			$detail_table = $plugin_prefix . $post_type . '_detail';
357
+
358
+			$admin_title = $request_field['admin_title'];
359
+			$site_title = $request_field['site_title'];
360
+			$data_type = $request_field['data_type'];
361
+			$field_type = $request_field['field_type'];
362
+			$field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type;
363
+			$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
364
+			$admin_desc = $request_field['admin_desc'];
365
+			$clabels = isset($request_field['clabels']) ? $request_field['clabels'] : '';
366
+			$default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
367
+			$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
368
+			$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
369
+			$is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
370
+			$required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
371
+			$css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
372
+			$field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
373
+			$show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
374
+			$show_in = isset($request_field['show_in']) ? $request_field['show_in'] : '';
375
+			$show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
376
+			$show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
377
+			$decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
378
+			$decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
379
+			$validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
380
+			$validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
381
+			$for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
382 382
 
383 383
             
384
-            if(is_array($show_in)){
385
-                $show_in = implode(",", $request_field['show_in']);
386
-            }
384
+			if(is_array($show_in)){
385
+				$show_in = implode(",", $request_field['show_in']);
386
+			}
387 387
             
388
-            if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
389
-                $htmlvar_name = 'geodir_' . $htmlvar_name;
390
-            }
388
+			if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
389
+				$htmlvar_name = 'geodir_' . $htmlvar_name;
390
+			}
391 391
 
392
-            $option_values = '';
393
-            if (isset($request_field['option_values']))
394
-                $option_values = $request_field['option_values'];
392
+			$option_values = '';
393
+			if (isset($request_field['option_values']))
394
+				$option_values = $request_field['option_values'];
395 395
 
396
-            $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
396
+			$cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
397 397
 
398
-            $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
398
+			$cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
399 399
 
400
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
402
-            else {
403
-                $package_info = array();
400
+			if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
+				$price_pkg = implode(",", $request_field['show_on_pkg']);
402
+			else {
403
+				$package_info = array();
404 404
 
405
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
406
-                $price_pkg = !empty($package_info->pid) ? $package_info->pid : '';
407
-            }
405
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
406
+				$price_pkg = !empty($package_info->pid) ? $package_info->pid : '';
407
+			}
408 408
 
409 409
 
410
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
411
-                $extra_fields = $request_field['extra'];
410
+			if (isset($request_field['extra']) && !empty($request_field['extra']))
411
+				$extra_fields = $request_field['extra'];
412 412
 
413
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
-                $is_default = $request_field['is_default'];
415
-            else
416
-                $is_default = '0';
413
+			if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
+				$is_default = $request_field['is_default'];
415
+			else
416
+				$is_default = '0';
417 417
 
418
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
-                $is_admin = $request_field['is_admin'];
420
-            else
421
-                $is_admin = '0';
418
+			if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
+				$is_admin = $request_field['is_admin'];
420
+			else
421
+				$is_admin = '0';
422 422
 
423 423
 
424
-            if ($is_active == '') $is_active = 1;
425
-            if ($is_required == '') $is_required = 0;
424
+			if ($is_active == '') $is_active = 1;
425
+			if ($is_required == '') $is_required = 0;
426 426
 
427 427
 
428
-            if ($sort_order == '') {
428
+			if ($sort_order == '') {
429 429
 
430
-                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
430
+				$last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
431 431
 
432
-                $sort_order = (int)$last_order + 1;
433
-            }
432
+				$sort_order = (int)$last_order + 1;
433
+			}
434 434
 
435
-            $default_value_add = '';
435
+			$default_value_add = '';
436 436
 
437 437
 
438
-            if (!empty($post_meta_info)) {
439
-                switch ($field_type):
438
+			if (!empty($post_meta_info)) {
439
+				switch ($field_type):
440 440
 
441
-                    case 'address':
441
+					case 'address':
442 442
 
443
-                        if ($htmlvar_name != '') {
444
-                            $prefix = $htmlvar_name . '_';
445
-                        }
446
-                        $old_prefix = $old_html_variable . '_';
443
+						if ($htmlvar_name != '') {
444
+							$prefix = $htmlvar_name . '_';
445
+						}
446
+						$old_prefix = $old_html_variable . '_';
447 447
 
448 448
 
449
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
449
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
450 450
 
451
-                        if ($default_value != '') {
452
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
453
-                        }
451
+						if ($default_value != '') {
452
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
453
+						}
454 454
 
455
-                        $wpdb->query($meta_field_add);
455
+						$wpdb->query($meta_field_add);
456 456
 
457
-                        if ($extra_fields != '') {
457
+						if ($extra_fields != '') {
458 458
 
459
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
459
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
460 460
 
461
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
462
-                                if ($is_column) {
463
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
461
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
462
+								if ($is_column) {
463
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
464 464
 
465
-                                    if ($default_value != '') {
466
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
467
-                                    }
465
+									if ($default_value != '') {
466
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
467
+									}
468 468
 
469
-                                    $wpdb->query($meta_field_add);
470
-                                } else {
469
+									$wpdb->query($meta_field_add);
470
+								} else {
471 471
 
472
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
473
-                                    if ($default_value != '') {
474
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
475
-                                    }
476
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
472
+									$meta_field_add = "VARCHAR( 50 ) NULL";
473
+									if ($default_value != '') {
474
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
475
+									}
476
+									geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
477 477
 
478
-                                }
478
+								}
479 479
 
480 480
 
481
-                            }
481
+							}
482 482
 
483 483
 
484
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
484
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
485 485
 
486
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
486
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
487 487
 
488
-                                if ($is_column) {
489
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
488
+								if ($is_column) {
489
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
490 490
 
491
-                                    if ($default_value != '') {
492
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
493
-                                    }
491
+									if ($default_value != '') {
492
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
493
+									}
494 494
 
495
-                                    $wpdb->query($meta_field_add);
496
-                                } else {
497
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
498
-                                    if ($default_value != '') {
499
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
500
-                                    }
495
+									$wpdb->query($meta_field_add);
496
+								} else {
497
+									$meta_field_add = "VARCHAR( 50 ) NULL";
498
+									if ($default_value != '') {
499
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
500
+									}
501 501
 
502
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
503
-                                }
502
+									geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
503
+								}
504 504
 
505
-                            }
506
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
505
+							}
506
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
507 507
 
508
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
508
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
509 509
 
510
-                                if ($is_column) {
510
+								if ($is_column) {
511 511
 
512
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
512
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
513 513
 
514
-                                    if ($default_value != '') {
515
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
516
-                                    }
514
+									if ($default_value != '') {
515
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
516
+									}
517 517
 
518
-                                    $wpdb->query($meta_field_add);
519
-                                } else {
518
+									$wpdb->query($meta_field_add);
519
+								} else {
520 520
 
521
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
522
-                                    if ($default_value != '') {
523
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
524
-                                    }
521
+									$meta_field_add = "VARCHAR( 50 ) NULL";
522
+									if ($default_value != '') {
523
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
524
+									}
525 525
 
526
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
526
+									geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
527 527
 
528
-                                }
528
+								}
529 529
 
530
-                            }
531
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
530
+							}
531
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
532 532
 
533
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
533
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
534 534
 
535
-                                if ($is_column) {
535
+								if ($is_column) {
536 536
 
537
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
537
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
538 538
 
539
-                                    if ($default_value != '') {
540
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
541
-                                    }
539
+									if ($default_value != '') {
540
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
541
+									}
542 542
 
543
-                                    $wpdb->query($meta_field_add);
544
-                                } else {
543
+									$wpdb->query($meta_field_add);
544
+								} else {
545 545
 
546
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
547
-                                    if ($default_value != '') {
548
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
549
-                                    }
546
+									$meta_field_add = "VARCHAR( 50 ) NULL";
547
+									if ($default_value != '') {
548
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
549
+									}
550 550
 
551
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
551
+									geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
552 552
 
553
-                                }
553
+								}
554 554
 
555
-                            }
556
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
555
+							}
556
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
557 557
 
558
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
559
-                                if ($is_column) {
558
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
559
+								if ($is_column) {
560 560
 
561
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
561
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
562 562
 
563
-                                    if ($default_value != '') {
564
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
565
-                                    }
563
+									if ($default_value != '') {
564
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
565
+									}
566 566
 
567
-                                    $wpdb->query($meta_field_add);
568
-                                } else {
567
+									$wpdb->query($meta_field_add);
568
+								} else {
569 569
 
570
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
571
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
572
-                                    if ($default_value != '') {
573
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
574
-                                    }
570
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
571
+									$meta_field_add = "VARCHAR( 20 ) NULL";
572
+									if ($default_value != '') {
573
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
574
+									}
575 575
 
576
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
576
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
577 577
 
578
-                                }
578
+								}
579 579
 
580 580
 
581
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
581
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
582 582
 
583
-                                if ($is_column) {
584
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
583
+								if ($is_column) {
584
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
585 585
 
586
-                                    if ($default_value != '') {
587
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
588
-                                    }
586
+									if ($default_value != '') {
587
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
588
+									}
589 589
 
590
-                                    $wpdb->query($meta_field_add);
591
-                                } else {
590
+									$wpdb->query($meta_field_add);
591
+								} else {
592 592
 
593
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
594
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
595
-                                    if ($default_value != '') {
596
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
597
-                                    }
593
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
594
+									$meta_field_add = "VARCHAR( 20 ) NULL";
595
+									if ($default_value != '') {
596
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
597
+									}
598 598
 
599
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
600
-                                }
599
+									geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
600
+								}
601 601
 
602
-                            }
603
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
602
+							}
603
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
604 604
 
605
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
605
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
606 606
 
607
-                                if ($is_column) {
608
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
607
+								if ($is_column) {
608
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
609 609
 
610
-                                    if ($default_value != '') {
611
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
612
-                                    }
610
+									if ($default_value != '') {
611
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
612
+									}
613 613
 
614
-                                    $wpdb->query($meta_field_add);
615
-                                } else {
614
+									$wpdb->query($meta_field_add);
615
+								} else {
616 616
 
617
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
617
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
618 618
 
619
-                                    $meta_field_add = "VARCHAR( 15 ) NULL";
620
-                                    if ($default_value != '') {
621
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
622
-                                    }
619
+									$meta_field_add = "VARCHAR( 15 ) NULL";
620
+									if ($default_value != '') {
621
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
622
+									}
623 623
 
624
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
625
-                                }
624
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
625
+								}
626 626
 
627 627
 
628
-                            }
629
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
628
+							}
629
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
630 630
 
631
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
632
-                                if ($is_column) {
633
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
631
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
632
+								if ($is_column) {
633
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
634 634
 
635
-                                    if ($default_value != '') {
636
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
637
-                                    }
635
+									if ($default_value != '') {
636
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
637
+									}
638 638
 
639
-                                    $wpdb->query($meta_field_add);
639
+									$wpdb->query($meta_field_add);
640 640
 
641
-                                } else {
641
+								} else {
642 642
 
643
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
643
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
644 644
 
645
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
646
-                                    if ($default_value != '') {
647
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
648
-                                    }
645
+									$meta_field_add = "VARCHAR( 3 ) NULL";
646
+									if ($default_value != '') {
647
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
648
+									}
649 649
 
650
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
651
-                                }
650
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
651
+								}
652 652
 
653
-                            }
654
-                            // show lat lng
655
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
656
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
653
+							}
654
+							// show lat lng
655
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
656
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
657 657
 
658
-                                if ($is_column) {
659
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
660
-                                    $meta_field_add .= " DEFAULT '1'";
658
+								if ($is_column) {
659
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
660
+									$meta_field_add .= " DEFAULT '1'";
661 661
 
662
-                                    $wpdb->query($meta_field_add);
663
-                                } else {
664
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
662
+									$wpdb->query($meta_field_add);
663
+								} else {
664
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
665 665
 
666
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
667
-                                    $meta_field_add .= " DEFAULT '1'";
666
+									$meta_field_add = "VARCHAR( 3 ) NULL";
667
+									$meta_field_add .= " DEFAULT '1'";
668 668
 
669
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
670
-                                }
669
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
670
+								}
671 671
 
672
-                            }
673
-                        }// end extra
672
+							}
673
+						}// end extra
674 674
 
675
-                        break;
675
+						break;
676 676
 
677
-                    case 'checkbox':
678
-                    case 'multiselect':
679
-                    case 'select':
680
-                    case 'taxonomy':
677
+					case 'checkbox':
678
+					case 'multiselect':
679
+					case 'select':
680
+					case 'taxonomy':
681 681
 
682
-                        $op_size = '500';
682
+						$op_size = '500';
683 683
 
684
-                        // only make the field as big as it needs to be.
685
-                        if(isset($option_values) && $option_values && $field_type=='select'){
686
-                            $option_values_arr = explode(',',$option_values);
687
-                            if(is_array($option_values_arr)){
688
-                                $op_max = 0;
689
-                                foreach($option_values_arr as $op_val){
690
-                                    if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
691
-                                }
692
-                                if($op_max){$op_size =$op_max; }
693
-                            }
694
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695
-                            if(strlen($option_values)){
696
-                                $op_size =  strlen($option_values);
697
-                            }
698
-                        }
684
+						// only make the field as big as it needs to be.
685
+						if(isset($option_values) && $option_values && $field_type=='select'){
686
+							$option_values_arr = explode(',',$option_values);
687
+							if(is_array($option_values_arr)){
688
+								$op_max = 0;
689
+								foreach($option_values_arr as $op_val){
690
+									if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
691
+								}
692
+								if($op_max){$op_size =$op_max; }
693
+							}
694
+						}elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695
+							if(strlen($option_values)){
696
+								$op_size =  strlen($option_values);
697
+							}
698
+						}
699 699
 
700
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
700
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
701 701
 
702
-                        if ($default_value != '') {
703
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
704
-                        }
702
+						if ($default_value != '') {
703
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
704
+						}
705 705
 
706
-                        $alter_result = $wpdb->query($meta_field_add);
707
-                        if($alter_result===false){
708
-                            return __('Column change failed, you may have too many columns.','geodirectory');
709
-                        }
706
+						$alter_result = $wpdb->query($meta_field_add);
707
+						if($alter_result===false){
708
+							return __('Column change failed, you may have too many columns.','geodirectory');
709
+						}
710 710
 
711
-                        if (isset($request_field['cat_display_type']))
712
-                            $extra_fields = $request_field['cat_display_type'];
711
+						if (isset($request_field['cat_display_type']))
712
+							$extra_fields = $request_field['cat_display_type'];
713 713
 
714
-                        if (isset($request_field['multi_display_type']))
715
-                            $extra_fields = $request_field['multi_display_type'];
714
+						if (isset($request_field['multi_display_type']))
715
+							$extra_fields = $request_field['multi_display_type'];
716 716
 
717 717
 
718
-                        break;
718
+						break;
719 719
 
720
-                    case 'textarea':
721
-                    case 'html':
722
-                    case 'url':
723
-                    case 'file':
720
+					case 'textarea':
721
+					case 'html':
722
+					case 'url':
723
+					case 'file':
724 724
 
725
-                        $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
726
-                        if($alter_result===false){
727
-                            return __('Column change failed, you may have too many columns.','geodirectory');
728
-                        }
729
-                        if (isset($request_field['advanced_editor']))
730
-                            $extra_fields = $request_field['advanced_editor'];
731
-
732
-                        break;
725
+						$alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
726
+						if($alter_result===false){
727
+							return __('Column change failed, you may have too many columns.','geodirectory');
728
+						}
729
+						if (isset($request_field['advanced_editor']))
730
+							$extra_fields = $request_field['advanced_editor'];
731
+
732
+						break;
733 733
 
734
-                    case 'fieldset':
735
-                        // Nothing happened for fieldset
736
-                        break;
734
+					case 'fieldset':
735
+						// Nothing happened for fieldset
736
+						break;
737 737
 
738
-                    default:
739
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
740
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
741
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
742
-                            } else {
743
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
744
-                            }
745
-
746
-                            if (is_numeric($default_value) && $default_value != '') {
747
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
748
-                            }
749
-                        } else {
750
-                            $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
751
-                            if ($default_value != '') {
752
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
753
-                            }
754
-                        }
755
-
756
-                        $alter_result = $wpdb->query($default_value_add);
757
-                        if($alter_result===false){
758
-                            return __('Column change failed, you may have too many columns.','geodirectory');
759
-                        }
760
-                        break;
761
-                endswitch;
762
-
763
-                $extra_field_query = '';
764
-                if (!empty($extra_fields)) {
765
-                    $extra_field_query = serialize($extra_fields);
766
-                }
767
-
768
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
769
-
770
-                $wpdb->query(
771
-
772
-                    $wpdb->prepare(
773
-
774
-                        "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
738
+					default:
739
+						if ($data_type != 'VARCHAR' && $data_type != '') {
740
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
741
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
742
+							} else {
743
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
744
+							}
745
+
746
+							if (is_numeric($default_value) && $default_value != '') {
747
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
748
+							}
749
+						} else {
750
+							$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
751
+							if ($default_value != '') {
752
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
753
+							}
754
+						}
755
+
756
+						$alter_result = $wpdb->query($default_value_add);
757
+						if($alter_result===false){
758
+							return __('Column change failed, you may have too many columns.','geodirectory');
759
+						}
760
+						break;
761
+				endswitch;
762
+
763
+				$extra_field_query = '';
764
+				if (!empty($extra_fields)) {
765
+					$extra_field_query = serialize($extra_fields);
766
+				}
767
+
768
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
769
+
770
+				$wpdb->query(
771
+
772
+					$wpdb->prepare(
773
+
774
+						"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
775 775
 					post_type = %s,
776 776
 					admin_title = %s,
777 777
 					site_title = %s,
@@ -805,308 +805,308 @@  discard block
 block discarded – undo
805 805
 					for_admin_use = %s
806 806
 					where id = %d",
807 807
 
808
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
809
-                    )
808
+						array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
809
+					)
810 810
 
811
-                );
811
+				);
812 812
 
813
-                $lastid = trim($cf);
813
+				$lastid = trim($cf);
814 814
 
815 815
 
816
-                $wpdb->query(
817
-                    $wpdb->prepare(
818
-                        "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
816
+				$wpdb->query(
817
+					$wpdb->prepare(
818
+						"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
819 819
 					 	site_title=%s
820 820
 					where post_type = %s and htmlvar_name = %s",
821
-                        array($site_title, $post_type, $htmlvar_name)
822
-                    )
823
-                );
824
-
825
-
826
-                if ($cat_sort == '')
827
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
828
-
829
-
830
-                /**
831
-                 * Called after all custom fields are saved for a post.
832
-                 *
833
-                 * @since 1.0.0
834
-                 * @param int $lastid The post ID.
835
-                 */
836
-                do_action('geodir_after_custom_fields_updated', $lastid);
837
-
838
-            } else {
839
-
840
-                switch ($field_type):
841
-
842
-                    case 'address':
843
-
844
-                        $data_type = '';
845
-
846
-                        if ($htmlvar_name != '') {
847
-                            $prefix = $htmlvar_name . '_';
848
-                        }
849
-                        $old_prefix = $old_html_variable;
850
-
851
-                        //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
852
-
853
-                        $meta_field_add = "VARCHAR( 254 ) NULL";
854
-                        if ($default_value != '') {
855
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
856
-                        }
857
-
858
-                        geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
859
-                        //$wpdb->query($meta_field_add);
860
-
861
-
862
-                        if (!empty($extra_fields)) {
821
+						array($site_title, $post_type, $htmlvar_name)
822
+					)
823
+				);
824
+
825
+
826
+				if ($cat_sort == '')
827
+					$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
828
+
829
+
830
+				/**
831
+				 * Called after all custom fields are saved for a post.
832
+				 *
833
+				 * @since 1.0.0
834
+				 * @param int $lastid The post ID.
835
+				 */
836
+				do_action('geodir_after_custom_fields_updated', $lastid);
837
+
838
+			} else {
839
+
840
+				switch ($field_type):
841
+
842
+					case 'address':
843
+
844
+						$data_type = '';
845
+
846
+						if ($htmlvar_name != '') {
847
+							$prefix = $htmlvar_name . '_';
848
+						}
849
+						$old_prefix = $old_html_variable;
850
+
851
+						//$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
852
+
853
+						$meta_field_add = "VARCHAR( 254 ) NULL";
854
+						if ($default_value != '') {
855
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
856
+						}
857
+
858
+						geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
859
+						//$wpdb->query($meta_field_add);
860
+
861
+
862
+						if (!empty($extra_fields)) {
863 863
 
864
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
865
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
866
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
867
-                                if ($default_value != '') {
868
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
869
-                                }
870
-
871
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
872
-                                //$wpdb->query($meta_field_add);
873
-                            }
874
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
875
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
876
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
877
-                                if ($default_value != '') {
878
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
879
-                                }
880
-
881
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
882
-                                //$wpdb->query($meta_field_add);
883
-                            }
884
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
885
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
886
-
887
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
888
-                                if ($default_value != '') {
889
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
890
-                                }
891
-
892
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
893
-                                //$wpdb->query($meta_field_add);
894
-                            }
895
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
896
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
897
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
898
-                                if ($default_value != '') {
899
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
900
-                                }
901
-
902
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
903
-                                //$wpdb->query($meta_field_add);
904
-                            }
905
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
906
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
907
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
908
-                                if ($default_value != '') {
909
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
910
-                                }
911
-
912
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
913
-                                //$wpdb->query($meta_field_add);
914
-
915
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
916
-
917
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
918
-                                if ($default_value != '') {
919
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
920
-                                }
921
-
922
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
923
-
924
-                                //$wpdb->query($meta_field_add);
925
-                            }
926
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
927
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
928
-
929
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
930
-                                if ($default_value != '') {
931
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
932
-                                }
933
-
934
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
935
-
936
-                                //$wpdb->query($meta_field_add);
937
-                            }
938
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
939
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
940
-
941
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
942
-                                if ($default_value != '') {
943
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
944
-                                }
945
-
946
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
947
-
948
-                                //$wpdb->query($meta_field_add);
949
-                            }
950
-                            // show lat lng
951
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
952
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
953
-
954
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
955
-                                $meta_field_add .= " DEFAULT '1'";
956
-
957
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
958
-                                //$wpdb->query($meta_field_add);
959
-                            }
960
-                        }
961
-
962
-                        break;
963
-
964
-                    case 'checkbox':
965
-                        $data_type = 'TINYINT';
966
-
967
-                        $meta_field_add = $data_type . "( 1 ) NOT NULL ";
968
-                        if ((int)$default_value === 1) {
969
-                            $meta_field_add .= " DEFAULT '1'";
970
-                        }
971
-
972
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
973
-                        if ($add_result === false) {
974
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
975
-                        }
976
-                        break;
977
-                    case 'multiselect':
978
-                    case 'select':
979
-                        $data_type = 'VARCHAR';
980
-                        $op_size = '500';
981
-
982
-                        // only make the field as big as it needs to be.
983
-                        if (isset($option_values) && $option_values && $field_type == 'select') {
984
-                            $option_values_arr = explode(',', $option_values);
985
-
986
-                            if (is_array($option_values_arr)) {
987
-                                $op_max = 0;
988
-
989
-                                foreach ($option_values_arr as $op_val) {
990
-                                    if (strlen($op_val) && strlen($op_val) > $op_max) {
991
-                                        $op_max = strlen($op_val);
992
-                                    }
993
-                                }
994
-
995
-                                if ($op_max) {
996
-                                    $op_size = $op_max;
997
-                                }
998
-                            }
999
-                        } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
1000
-                            if (strlen($option_values)) {
1001
-                                $op_size =  strlen($option_values);
1002
-                            }
1003
-
1004
-                            if (isset($request_field['multi_display_type'])) {
1005
-                                $extra_fields = $request_field['multi_display_type'];
1006
-                            }
1007
-                        }
1008
-
1009
-                        $meta_field_add = $data_type . "( $op_size ) NULL ";
1010
-                        if ($default_value != '') {
1011
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
1012
-                        }
1013
-
1014
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1015
-                        if ($add_result === false) {
1016
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1017
-                        }
1018
-                        break;
1019
-                    case 'textarea':
1020
-                    case 'html':
1021
-                    case 'url':
1022
-                    case 'file':
1023
-
1024
-                        $data_type = 'TEXT';
1025
-
1026
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1027
-
1028
-                        $meta_field_add = $data_type . " NULL ";
1029
-                        /*if($default_value != '')
864
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
865
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
866
+								$meta_field_add = "VARCHAR( 30 ) NULL";
867
+								if ($default_value != '') {
868
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
869
+								}
870
+
871
+								geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
872
+								//$wpdb->query($meta_field_add);
873
+							}
874
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
875
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
876
+								$meta_field_add = "VARCHAR( 30 ) NULL";
877
+								if ($default_value != '') {
878
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
879
+								}
880
+
881
+								geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
882
+								//$wpdb->query($meta_field_add);
883
+							}
884
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
885
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
886
+
887
+								$meta_field_add = "VARCHAR( 30 ) NULL";
888
+								if ($default_value != '') {
889
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
890
+								}
891
+
892
+								geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
893
+								//$wpdb->query($meta_field_add);
894
+							}
895
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
896
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
897
+								$meta_field_add = "VARCHAR( 15 ) NULL";
898
+								if ($default_value != '') {
899
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
900
+								}
901
+
902
+								geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
903
+								//$wpdb->query($meta_field_add);
904
+							}
905
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
906
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
907
+								$meta_field_add = "VARCHAR( 20 ) NULL";
908
+								if ($default_value != '') {
909
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
910
+								}
911
+
912
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
913
+								//$wpdb->query($meta_field_add);
914
+
915
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
916
+
917
+								$meta_field_add = "VARCHAR( 20 ) NULL";
918
+								if ($default_value != '') {
919
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
920
+								}
921
+
922
+								geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
923
+
924
+								//$wpdb->query($meta_field_add);
925
+							}
926
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
927
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
928
+
929
+								$meta_field_add = "VARCHAR( 15 ) NULL";
930
+								if ($default_value != '') {
931
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
932
+								}
933
+
934
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
935
+
936
+								//$wpdb->query($meta_field_add);
937
+							}
938
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
939
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
940
+
941
+								$meta_field_add = "VARCHAR( 3 ) NULL";
942
+								if ($default_value != '') {
943
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
944
+								}
945
+
946
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
947
+
948
+								//$wpdb->query($meta_field_add);
949
+							}
950
+							// show lat lng
951
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
952
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
953
+
954
+								$meta_field_add = "VARCHAR( 3 ) NULL";
955
+								$meta_field_add .= " DEFAULT '1'";
956
+
957
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
958
+								//$wpdb->query($meta_field_add);
959
+							}
960
+						}
961
+
962
+						break;
963
+
964
+					case 'checkbox':
965
+						$data_type = 'TINYINT';
966
+
967
+						$meta_field_add = $data_type . "( 1 ) NOT NULL ";
968
+						if ((int)$default_value === 1) {
969
+							$meta_field_add .= " DEFAULT '1'";
970
+						}
971
+
972
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
973
+						if ($add_result === false) {
974
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
975
+						}
976
+						break;
977
+					case 'multiselect':
978
+					case 'select':
979
+						$data_type = 'VARCHAR';
980
+						$op_size = '500';
981
+
982
+						// only make the field as big as it needs to be.
983
+						if (isset($option_values) && $option_values && $field_type == 'select') {
984
+							$option_values_arr = explode(',', $option_values);
985
+
986
+							if (is_array($option_values_arr)) {
987
+								$op_max = 0;
988
+
989
+								foreach ($option_values_arr as $op_val) {
990
+									if (strlen($op_val) && strlen($op_val) > $op_max) {
991
+										$op_max = strlen($op_val);
992
+									}
993
+								}
994
+
995
+								if ($op_max) {
996
+									$op_size = $op_max;
997
+								}
998
+							}
999
+						} elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
1000
+							if (strlen($option_values)) {
1001
+								$op_size =  strlen($option_values);
1002
+							}
1003
+
1004
+							if (isset($request_field['multi_display_type'])) {
1005
+								$extra_fields = $request_field['multi_display_type'];
1006
+							}
1007
+						}
1008
+
1009
+						$meta_field_add = $data_type . "( $op_size ) NULL ";
1010
+						if ($default_value != '') {
1011
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
1012
+						}
1013
+
1014
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1015
+						if ($add_result === false) {
1016
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1017
+						}
1018
+						break;
1019
+					case 'textarea':
1020
+					case 'html':
1021
+					case 'url':
1022
+					case 'file':
1023
+
1024
+						$data_type = 'TEXT';
1025
+
1026
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1027
+
1028
+						$meta_field_add = $data_type . " NULL ";
1029
+						/*if($default_value != '')
1030 1030
 					{ $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
1031 1031
 
1032
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1033
-                        if ($add_result === false) {
1034
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1035
-                        }
1032
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1033
+						if ($add_result === false) {
1034
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1035
+						}
1036 1036
 
1037
-                        break;
1037
+						break;
1038 1038
 
1039
-                    case 'datepicker':
1039
+					case 'datepicker':
1040 1040
 
1041
-                        $data_type = 'DATE';
1041
+						$data_type = 'DATE';
1042 1042
 
1043
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1043
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1044 1044
 
1045
-                        $meta_field_add = $data_type . " NULL ";
1045
+						$meta_field_add = $data_type . " NULL ";
1046 1046
 
1047
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1048
-                        if ($add_result === false) {
1049
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1050
-                        }
1047
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1048
+						if ($add_result === false) {
1049
+							return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1050
+						}
1051 1051
 
1052
-                        break;
1052
+						break;
1053 1053
 
1054
-                    case 'time':
1054
+					case 'time':
1055 1055
 
1056
-                        $data_type = 'TIME';
1056
+						$data_type = 'TIME';
1057 1057
 
1058
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1058
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1059 1059
 
1060
-                        $meta_field_add = $data_type . " NULL ";
1060
+						$meta_field_add = $data_type . " NULL ";
1061 1061
 
1062
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1063
-                        if ($add_result === false) {
1064
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1065
-                        }
1062
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1063
+						if ($add_result === false) {
1064
+							return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1065
+						}
1066 1066
 
1067
-                        break;
1067
+						break;
1068 1068
 
1069
-                    default:
1069
+					default:
1070 1070
 
1071
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
1072
-                            $meta_field_add = $data_type . " NULL ";
1071
+						if ($data_type != 'VARCHAR' && $data_type != '') {
1072
+							$meta_field_add = $data_type . " NULL ";
1073 1073
 
1074
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
1075
-                                $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1076
-                            }
1074
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
1075
+								$meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1076
+							}
1077 1077
 
1078
-                            if (is_numeric($default_value) && $default_value != '') {
1079
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1080
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1081
-                            }
1082
-                        } else {
1083
-                            $meta_field_add = " VARCHAR( 254 ) NULL ";
1078
+							if (is_numeric($default_value) && $default_value != '') {
1079
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1080
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1081
+							}
1082
+						} else {
1083
+							$meta_field_add = " VARCHAR( 254 ) NULL ";
1084 1084
 
1085
-                            if ($default_value != '') {
1086
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1087
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1088
-                            }
1089
-                        }
1085
+							if ($default_value != '') {
1086
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1087
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1088
+							}
1089
+						}
1090 1090
 
1091
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1092
-                        if ($add_result === false) {
1093
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1094
-                        }
1095
-                        break;
1096
-                endswitch;
1091
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1092
+						if ($add_result === false) {
1093
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1094
+						}
1095
+						break;
1096
+				endswitch;
1097 1097
 
1098
-                $extra_field_query = '';
1099
-                if (!empty($extra_fields)) {
1100
-                    $extra_field_query = serialize($extra_fields);
1101
-                }
1098
+				$extra_field_query = '';
1099
+				if (!empty($extra_fields)) {
1100
+					$extra_field_query = serialize($extra_fields);
1101
+				}
1102 1102
 
1103
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1103
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1104 1104
 
1105
-                $wpdb->query(
1105
+				$wpdb->query(
1106 1106
 
1107
-                    $wpdb->prepare(
1107
+					$wpdb->prepare(
1108 1108
 
1109
-                        "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1109
+						"insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1110 1110
 					post_type = %s,
1111 1111
 					admin_title = %s,
1112 1112
 					site_title = %s,
@@ -1139,26 +1139,26 @@  discard block
 block discarded – undo
1139 1139
 					validation_msg = %s,
1140 1140
 					for_admin_use = %s ",
1141 1141
 
1142
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1142
+						array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1143 1143
 
1144
-                    )
1144
+					)
1145 1145
 
1146
-                );
1146
+				);
1147 1147
 
1148
-                $lastid = $wpdb->insert_id;
1148
+				$lastid = $wpdb->insert_id;
1149 1149
 
1150
-                $lastid = trim($lastid);
1150
+				$lastid = trim($lastid);
1151 1151
 
1152
-            }
1152
+			}
1153 1153
 
1154
-            return (int)$lastid;
1154
+			return (int)$lastid;
1155 1155
 
1156 1156
 
1157
-        } else {
1158
-            return 'HTML Variable Name should be a unique name';
1159
-        }
1157
+		} else {
1158
+			return 'HTML Variable Name should be a unique name';
1159
+		}
1160 1160
 
1161
-    }
1161
+	}
1162 1162
 }
1163 1163
 
1164 1164
 /**
@@ -1173,63 +1173,63 @@  discard block
 block discarded – undo
1173 1173
 function godir_set_field_order($field_ids = array())
1174 1174
 {
1175 1175
 
1176
-    global $wpdb;
1176
+	global $wpdb;
1177 1177
 
1178
-    $count = 0;
1179
-    if (!empty($field_ids)):
1180
-        $post_meta_info = false;
1181
-        foreach ($field_ids as $id) {
1178
+	$count = 0;
1179
+	if (!empty($field_ids)):
1180
+		$post_meta_info = false;
1181
+		foreach ($field_ids as $id) {
1182 1182
 
1183
-            $cf = trim($id, '_');
1183
+			$cf = trim($id, '_');
1184 1184
 
1185
-            $post_meta_info = $wpdb->query(
1186
-                $wpdb->prepare(
1187
-                    "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1185
+			$post_meta_info = $wpdb->query(
1186
+				$wpdb->prepare(
1187
+					"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1188 1188
 															sort_order=%d 
1189 1189
 															where id= %d",
1190
-                    array($count, $cf)
1191
-                )
1192
-            );
1193
-            $count++;
1194
-        }
1195
-
1196
-        return $post_meta_info;
1197
-    else:
1198
-        return false;
1199
-    endif;
1190
+					array($count, $cf)
1191
+				)
1192
+			);
1193
+			$count++;
1194
+		}
1195
+
1196
+		return $post_meta_info;
1197
+	else:
1198
+		return false;
1199
+	endif;
1200 1200
 }
1201 1201
 
1202 1202
 function geodir_get_cf_value($cf) {
1203
-    global $gd_session;
1204
-    $value = '';
1205
-    if (is_admin()) {
1206
-        global $post;
1207
-
1208
-        if (isset($_REQUEST['post'])) {
1209
-            $_REQUEST['pid'] = (int)$_REQUEST['post'];
1210
-        }
1211
-    }
1212
-
1213
-    if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1214
-        $post = $gd_ses_listing;
1215
-        $value = isset($post[$cf['name']]) ? $post[$cf['name']] : '';
1216
-    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1217
-        $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true);
1218
-    } else {
1219
-        if ($value == '') {
1220
-            $value = $cf['default'];
1221
-        }
1222
-    }
1203
+	global $gd_session;
1204
+	$value = '';
1205
+	if (is_admin()) {
1206
+		global $post;
1207
+
1208
+		if (isset($_REQUEST['post'])) {
1209
+			$_REQUEST['pid'] = (int)$_REQUEST['post'];
1210
+		}
1211
+	}
1212
+
1213
+	if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1214
+		$post = $gd_ses_listing;
1215
+		$value = isset($post[$cf['name']]) ? $post[$cf['name']] : '';
1216
+	} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1217
+		$value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true);
1218
+	} else {
1219
+		if ($value == '') {
1220
+			$value = $cf['default'];
1221
+		}
1222
+	}
1223 1223
     
1224
-    /**
1225
-     * Filter the custom field value.
1226
-     *
1227
-     * @since 1.6.20
1228
-     * 
1229
-     * @param mixed $value Custom field value.
1230
-     * @param array $cf Custom field info.
1231
-     */
1232
-    return apply_filters( 'geodir_get_cf_value', $value, $cf );
1224
+	/**
1225
+	 * Filter the custom field value.
1226
+	 *
1227
+	 * @since 1.6.20
1228
+	 * 
1229
+	 * @param mixed $value Custom field value.
1230
+	 * @param array $cf Custom field info.
1231
+	 */
1232
+	return apply_filters( 'geodir_get_cf_value', $value, $cf );
1233 1233
 }
1234 1234
 
1235 1235
 /**
@@ -1248,422 +1248,422 @@  discard block
 block discarded – undo
1248 1248
  * @param string $post_type Optional. The wordpress post type.
1249 1249
  */
1250 1250
 function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') {
1251
-    global $is_default, $mapzoom, $gd_session;
1251
+	global $is_default, $mapzoom, $gd_session;
1252 1252
 
1253
-    $listing_type = $post_type;
1253
+	$listing_type = $post_type;
1254 1254
 
1255
-    $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1255
+	$custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1256 1256
 
1257
-    foreach ($custom_fields as $key => $val) {
1258
-        if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
1259
-        $val = stripslashes_deep($val); // strip slashes from labels
1260
-        if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
1257
+	foreach ($custom_fields as $key => $val) {
1258
+		if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
1259
+		$val = stripslashes_deep($val); // strip slashes from labels
1260
+		if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
1261 1261
 
1262
-        $name = $val['name'];
1263
-        $type = $val['type'];
1264
-        $is_default = $val['is_default'];
1262
+		$name = $val['name'];
1263
+		$type = $val['type'];
1264
+		$is_default = $val['is_default'];
1265 1265
 
1266
-        /* field available to site admin only for edit */
1267
-        $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1268
-        if ($for_admin_use && !is_super_admin()) {
1269
-            continue;
1270
-        }
1266
+		/* field available to site admin only for edit */
1267
+		$for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1268
+		if ($for_admin_use && !is_super_admin()) {
1269
+			continue;
1270
+		}
1271 1271
 
1272
-        if (is_admin()) {
1273
-            global $post;
1272
+		if (is_admin()) {
1273
+			global $post;
1274 1274
 
1275
-            if (isset($_REQUEST['post']))
1276
-                $_REQUEST['pid'] = $_REQUEST['post'];
1277
-        }
1275
+			if (isset($_REQUEST['post']))
1276
+				$_REQUEST['pid'] = $_REQUEST['post'];
1277
+		}
1278 1278
 
1279 1279
         
1280 1280
 
1281
-        /**
1282
-         * Called before the custom fields info is output for submitting a post.
1283
-         *
1284
-         * Used dynamic hook type geodir_before_custom_form_field_$name.
1285
-         *
1286
-         * @since 1.0.0
1287
-         * @param string $listing_type The post post type.
1288
-         * @param int $package_id The price package ID for the post.
1289
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1290
-         * @see 'geodir_after_custom_form_field_$name'
1291
-         */
1292
-        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1293
-
1294
-
1295
-        $custom_field = $val;
1296
-        $html ='';
1297
-        /**
1298
-         * Filter the output for custom fields.
1299
-         *
1300
-         * Here we can remove or add new functions depending on the field type.
1301
-         *
1302
-         * @param string $html The html to be filtered (blank).
1303
-         * @param array $custom_field The custom field array values.
1304
-         */
1305
-        echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1306
-
1307
-
1308
-
1309
-        /**
1310
-         * Called after the custom fields info is output for submitting a post.
1311
-         *
1312
-         * Used dynamic hook type geodir_after_custom_form_field_$name.
1313
-         *
1314
-         * @since 1.0.0
1315
-         * @param string $listing_type The post post type.
1316
-         * @param int $package_id The price package ID for the post.
1317
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1318
-         * @see 'geodir_before_custom_form_field_$name'
1319
-         */
1320
-        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1321
-
1322
-    }
1281
+		/**
1282
+		 * Called before the custom fields info is output for submitting a post.
1283
+		 *
1284
+		 * Used dynamic hook type geodir_before_custom_form_field_$name.
1285
+		 *
1286
+		 * @since 1.0.0
1287
+		 * @param string $listing_type The post post type.
1288
+		 * @param int $package_id The price package ID for the post.
1289
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1290
+		 * @see 'geodir_after_custom_form_field_$name'
1291
+		 */
1292
+		do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1293
+
1294
+
1295
+		$custom_field = $val;
1296
+		$html ='';
1297
+		/**
1298
+		 * Filter the output for custom fields.
1299
+		 *
1300
+		 * Here we can remove or add new functions depending on the field type.
1301
+		 *
1302
+		 * @param string $html The html to be filtered (blank).
1303
+		 * @param array $custom_field The custom field array values.
1304
+		 */
1305
+		echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1306
+
1307
+
1308
+
1309
+		/**
1310
+		 * Called after the custom fields info is output for submitting a post.
1311
+		 *
1312
+		 * Used dynamic hook type geodir_after_custom_form_field_$name.
1313
+		 *
1314
+		 * @since 1.0.0
1315
+		 * @param string $listing_type The post post type.
1316
+		 * @param int $package_id The price package ID for the post.
1317
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1318
+		 * @see 'geodir_before_custom_form_field_$name'
1319
+		 */
1320
+		do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1321
+
1322
+	}
1323 1323
 
1324 1324
 }
1325 1325
 
1326 1326
 
1327 1327
 if (!function_exists('geodir_get_field_infoby')) {
1328
-    /**
1329
-     * Get custom field using key and value.
1330
-     *
1331
-     * @since 1.0.0
1332
-     * @package GeoDirectory
1333
-     * @global object $wpdb WordPress Database object.
1334
-     * @param string $key The key you want to look for.
1335
-     * @param string $value The value of the key you want to look for.
1336
-     * @param string $geodir_post_type The post type.
1337
-     * @return bool|mixed Returns field info when available. otherwise returns false.
1338
-     */
1339
-    function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
1340
-    {
1341
-
1342
-        global $wpdb;
1343
-
1344
-        $filter = $wpdb->get_row(
1345
-            $wpdb->prepare(
1346
-                "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1347
-                array($geodir_post_type)
1348
-            )
1349
-        );
1350
-
1351
-        if ($filter) {
1352
-            return $filter;
1353
-        } else {
1354
-            return false;
1355
-        }
1356
-
1357
-    }
1328
+	/**
1329
+	 * Get custom field using key and value.
1330
+	 *
1331
+	 * @since 1.0.0
1332
+	 * @package GeoDirectory
1333
+	 * @global object $wpdb WordPress Database object.
1334
+	 * @param string $key The key you want to look for.
1335
+	 * @param string $value The value of the key you want to look for.
1336
+	 * @param string $geodir_post_type The post type.
1337
+	 * @return bool|mixed Returns field info when available. otherwise returns false.
1338
+	 */
1339
+	function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
1340
+	{
1341
+
1342
+		global $wpdb;
1343
+
1344
+		$filter = $wpdb->get_row(
1345
+			$wpdb->prepare(
1346
+				"SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1347
+				array($geodir_post_type)
1348
+			)
1349
+		);
1350
+
1351
+		if ($filter) {
1352
+			return $filter;
1353
+		} else {
1354
+			return false;
1355
+		}
1356
+
1357
+	}
1358 1358
 }
1359 1359
 
1360 1360
 
1361 1361
 function geodir_field_icon_proccess($cf){
1362 1362
 
1363 1363
 
1364
-    if (strpos($cf['field_icon'], 'http') !== false) {
1365
-        $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1366
-    } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1367
-        $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1368
-    }else{
1369
-        $field_icon = $cf['field_icon'];
1370
-    }
1364
+	if (strpos($cf['field_icon'], 'http') !== false) {
1365
+		$field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1366
+	} elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1367
+		$field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1368
+	}else{
1369
+		$field_icon = $cf['field_icon'];
1370
+	}
1371 1371
 
1372
-    return $field_icon;
1372
+	return $field_icon;
1373 1373
 }
1374 1374
 
1375 1375
 if (!function_exists('geodir_show_listing_info')) {
1376
-    /**
1377
-     * Show listing info depending on field location.
1378
-     *
1379
-     * @since 1.0.0
1380
-     * @since 1.5.7 Custom fields option values added to db translation.
1381
-     *              Changes to display url fields title.
1382
-     * @package GeoDirectory
1383
-     * @global object $wpdb WordPress Database object.
1384
-     * @global object $post The current post object.
1385
-     * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
1386
-     *
1387
-     * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
1388
-     * @return string Returns listing info html.
1389
-     */
1390
-    function geodir_show_listing_info($fields_location = '') {
1391
-        global $post, $preview, $wpdb, $send_to_friend;
1392
-
1393
-        $package_info = array();
1394
-
1395
-        $package_info = geodir_post_package_info($package_info, $post);
1396
-        $post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
1397
-        $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype();
1398
-        $send_to_friend = false;
1399
-
1400
-        ob_start();
1401
-        $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location);
1402
-
1403
-        if (!empty($fields_info)) {
1404
-            $post = stripslashes_deep($post); // strip slashes
1376
+	/**
1377
+	 * Show listing info depending on field location.
1378
+	 *
1379
+	 * @since 1.0.0
1380
+	 * @since 1.5.7 Custom fields option values added to db translation.
1381
+	 *              Changes to display url fields title.
1382
+	 * @package GeoDirectory
1383
+	 * @global object $wpdb WordPress Database object.
1384
+	 * @global object $post The current post object.
1385
+	 * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
1386
+	 *
1387
+	 * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
1388
+	 * @return string Returns listing info html.
1389
+	 */
1390
+	function geodir_show_listing_info($fields_location = '') {
1391
+		global $post, $preview, $wpdb, $send_to_friend;
1392
+
1393
+		$package_info = array();
1394
+
1395
+		$package_info = geodir_post_package_info($package_info, $post);
1396
+		$post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
1397
+		$p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype();
1398
+		$send_to_friend = false;
1399
+
1400
+		ob_start();
1401
+		$fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location);
1402
+
1403
+		if (!empty($fields_info)) {
1404
+			$post = stripslashes_deep($post); // strip slashes
1405 1405
             
1406
-            //echo '<div class="geodir-company_info field-group">';
1407
-            global $field_set_start;
1408
-            $field_set_start = 0;
1409
-
1410
-
1411
-
1412
-            foreach ($fields_info as $type) {
1413
-                if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
1414
-                $type = stripslashes_deep($type); // strip slashes
1415
-                if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
1416
-                $html = '';
1417
-                $field_icon = geodir_field_icon_proccess($type);
1418
-                $filed_type = $type['type'];
1419
-                $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
1420
-                if($html_var=='post'){$html_var='post_address';}
1421
-
1422
-                /**
1423
-                 * Filter the output for custom fields.
1424
-                 *
1425
-                 * Here we can remove or add new functions depending on the field type.
1426
-                 *
1427
-                 * @param string $html The html to be filtered (blank).
1428
-                 * @param string $fields_location The location the field is to be show.
1429
-                 * @param array $type The array of field values.
1430
-                 */
1431
-                $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1432
-
1433
-                $variables_array = array();
1434
-
1435
-
1436
-                if ($type['type'] != 'fieldset'):
1437
-                    $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1438
-                    $variables_array['label'] = __($type['site_title'], 'geodirectory');
1439
-                    $variables_array['value'] = '';
1440
-                    if (isset($post->{$type['htmlvar_name']}))
1441
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
1442
-                endif;
1443
-
1444
-
1445
-                if ($html):
1446
-
1447
-                    /**
1448
-                     * Called before a custom fields is output on the frontend.
1449
-                     *
1450
-                     * @since 1.0.0
1451
-                     * @param string $html_var The HTML variable name for the field.
1452
-                     */
1453
-                    do_action("geodir_before_show_{$html_var}");
1454
-                    /**
1455
-                     * Filter custom field output.
1456
-                     *
1457
-                     * @since 1.0.0
1458
-                     *
1459
-                     * @param string $html_var The HTML variable name for the field.
1460
-                     * @param string $html Custom field unfiltered HTML.
1461
-                     * @param array $variables_array Custom field variables array.
1462
-                     */
1463
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1464
-
1465
-                    /**
1466
-                     * Called after a custom fields is output on the frontend.
1467
-                     *
1468
-                     * @since 1.0.0
1469
-                     * @param string $html_var The HTML variable name for the field.
1470
-                     */
1471
-                    do_action("geodir_after_show_{$html_var}");
1472
-
1473
-                endif;
1474
-
1475
-            }
1476
-
1477
-            //echo '</div>';
1478
-
1479
-        }
1480
-
1481
-
1482
-        $html = ob_get_clean();
1483
-
1484
-        /**
1485
-         * Filter the custom fields over all output.
1486
-         *
1487
-         * @param string $html The html of the custom fields.
1488
-         * @param string $fields_location The location the fields are being output.
1489
-         * @since 1.6.9
1490
-         */
1491
-        return apply_filters('geodir_show_listing_info',$html,$fields_location);
1492
-
1493
-    }
1406
+			//echo '<div class="geodir-company_info field-group">';
1407
+			global $field_set_start;
1408
+			$field_set_start = 0;
1409
+
1410
+
1411
+
1412
+			foreach ($fields_info as $type) {
1413
+				if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
1414
+				$type = stripslashes_deep($type); // strip slashes
1415
+				if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
1416
+				$html = '';
1417
+				$field_icon = geodir_field_icon_proccess($type);
1418
+				$filed_type = $type['type'];
1419
+				$html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
1420
+				if($html_var=='post'){$html_var='post_address';}
1421
+
1422
+				/**
1423
+				 * Filter the output for custom fields.
1424
+				 *
1425
+				 * Here we can remove or add new functions depending on the field type.
1426
+				 *
1427
+				 * @param string $html The html to be filtered (blank).
1428
+				 * @param string $fields_location The location the field is to be show.
1429
+				 * @param array $type The array of field values.
1430
+				 */
1431
+				$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1432
+
1433
+				$variables_array = array();
1434
+
1435
+
1436
+				if ($type['type'] != 'fieldset'):
1437
+					$variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1438
+					$variables_array['label'] = __($type['site_title'], 'geodirectory');
1439
+					$variables_array['value'] = '';
1440
+					if (isset($post->{$type['htmlvar_name']}))
1441
+						$variables_array['value'] = $post->{$type['htmlvar_name']};
1442
+				endif;
1443
+
1444
+
1445
+				if ($html):
1446
+
1447
+					/**
1448
+					 * Called before a custom fields is output on the frontend.
1449
+					 *
1450
+					 * @since 1.0.0
1451
+					 * @param string $html_var The HTML variable name for the field.
1452
+					 */
1453
+					do_action("geodir_before_show_{$html_var}");
1454
+					/**
1455
+					 * Filter custom field output.
1456
+					 *
1457
+					 * @since 1.0.0
1458
+					 *
1459
+					 * @param string $html_var The HTML variable name for the field.
1460
+					 * @param string $html Custom field unfiltered HTML.
1461
+					 * @param array $variables_array Custom field variables array.
1462
+					 */
1463
+					if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1464
+
1465
+					/**
1466
+					 * Called after a custom fields is output on the frontend.
1467
+					 *
1468
+					 * @since 1.0.0
1469
+					 * @param string $html_var The HTML variable name for the field.
1470
+					 */
1471
+					do_action("geodir_after_show_{$html_var}");
1472
+
1473
+				endif;
1474
+
1475
+			}
1476
+
1477
+			//echo '</div>';
1478
+
1479
+		}
1480
+
1481
+
1482
+		$html = ob_get_clean();
1483
+
1484
+		/**
1485
+		 * Filter the custom fields over all output.
1486
+		 *
1487
+		 * @param string $html The html of the custom fields.
1488
+		 * @param string $fields_location The location the fields are being output.
1489
+		 * @since 1.6.9
1490
+		 */
1491
+		return apply_filters('geodir_show_listing_info',$html,$fields_location);
1492
+
1493
+	}
1494 1494
 }
1495 1495
 
1496 1496
 if (!function_exists('geodir_default_date_format')) {
1497
-    /**
1498
-     * Returns default date format.
1499
-     *
1500
-     * @since 1.0.0
1501
-     * @package GeoDirectory
1502
-     * @return mixed|string|void Returns default date format.
1503
-     */
1504
-    function geodir_default_date_format()
1505
-    {
1506
-        if ($format = get_option('date_format'))
1507
-            return $format;
1508
-        else
1509
-            return 'dd-mm-yy';
1510
-    }
1497
+	/**
1498
+	 * Returns default date format.
1499
+	 *
1500
+	 * @since 1.0.0
1501
+	 * @package GeoDirectory
1502
+	 * @return mixed|string|void Returns default date format.
1503
+	 */
1504
+	function geodir_default_date_format()
1505
+	{
1506
+		if ($format = get_option('date_format'))
1507
+			return $format;
1508
+		else
1509
+			return 'dd-mm-yy';
1510
+	}
1511 1511
 }
1512 1512
 
1513 1513
 if (!function_exists('geodir_get_formated_date')) {
1514
-    /**
1515
-     * Returns formatted date.
1516
-     *
1517
-     * @since 1.0.0
1518
-     * @package GeoDirectory
1519
-     * @param string $date Date string to convert.
1520
-     * @return bool|int|string Returns formatted date.
1521
-     */
1522
-    function geodir_get_formated_date($date)
1523
-    {
1524
-        return mysql2date(get_option('date_format'), $date);
1525
-    }
1514
+	/**
1515
+	 * Returns formatted date.
1516
+	 *
1517
+	 * @since 1.0.0
1518
+	 * @package GeoDirectory
1519
+	 * @param string $date Date string to convert.
1520
+	 * @return bool|int|string Returns formatted date.
1521
+	 */
1522
+	function geodir_get_formated_date($date)
1523
+	{
1524
+		return mysql2date(get_option('date_format'), $date);
1525
+	}
1526 1526
 }
1527 1527
 
1528 1528
 if (!function_exists('geodir_get_formated_time')) {
1529
-    /**
1530
-     * Returns formatted time.
1531
-     *
1532
-     * @since 1.0.0
1533
-     * @package GeoDirectory
1534
-     * @param string $time Time string to convert.
1535
-     * @return bool|int|string Returns formatted time.
1536
-     */
1537
-    function geodir_get_formated_time($time)
1538
-    {
1539
-        return mysql2date(get_option('time_format'), $time, $translate = true);
1540
-    }
1529
+	/**
1530
+	 * Returns formatted time.
1531
+	 *
1532
+	 * @since 1.0.0
1533
+	 * @package GeoDirectory
1534
+	 * @param string $time Time string to convert.
1535
+	 * @return bool|int|string Returns formatted time.
1536
+	 */
1537
+	function geodir_get_formated_time($time)
1538
+	{
1539
+		return mysql2date(get_option('time_format'), $time, $translate = true);
1540
+	}
1541 1541
 }
1542 1542
 
1543 1543
 
1544 1544
 if (!function_exists('geodir_save_post_file_fields')) {
1545
-    /**
1546
-     * Save post file fields
1547
-     *
1548
-     * @since 1.0.0
1549
-     * @since 1.4.7 Added `$extra_fields` parameter.
1550
-     * @package GeoDirectory
1551
-     * @global object $wpdb WordPress Database object.
1552
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1553
-     * @global object $current_user Current user object.
1554
-     * @param int $post_id
1555
-     * @param string $field_id
1556
-     * @param array $post_image
1557
-     * @param array $extra_fields Array of extra fields.
1558
-     */
1559
-    function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
1560
-    {
1545
+	/**
1546
+	 * Save post file fields
1547
+	 *
1548
+	 * @since 1.0.0
1549
+	 * @since 1.4.7 Added `$extra_fields` parameter.
1550
+	 * @package GeoDirectory
1551
+	 * @global object $wpdb WordPress Database object.
1552
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1553
+	 * @global object $current_user Current user object.
1554
+	 * @param int $post_id
1555
+	 * @param string $field_id
1556
+	 * @param array $post_image
1557
+	 * @param array $extra_fields Array of extra fields.
1558
+	 */
1559
+	function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
1560
+	{
1561 1561
 
1562
-        global $wpdb, $plugin_prefix, $current_user;
1562
+		global $wpdb, $plugin_prefix, $current_user;
1563 1563
 
1564
-        $post_type = get_post_type($post_id);
1565
-        //echo $field_id; exit;
1566
-        $table = $plugin_prefix . $post_type . '_detail';
1564
+		$post_type = get_post_type($post_id);
1565
+		//echo $field_id; exit;
1566
+		$table = $plugin_prefix . $post_type . '_detail';
1567 1567
 
1568
-        $postcurr_images = array();
1569
-        $postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
1570
-        $file_urls = '';
1568
+		$postcurr_images = array();
1569
+		$postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
1570
+		$file_urls = '';
1571 1571
 
1572
-        if (!empty($post_image)) {
1572
+		if (!empty($post_image)) {
1573 1573
 
1574
-            $invalid_files = array();
1574
+			$invalid_files = array();
1575 1575
 
1576
-            //Get and remove all old images of post from database to set by new order
1577
-            $geodir_uploaddir = '';
1578
-            $uploads = wp_upload_dir();
1579
-            $uploads_dir = $uploads['path'];
1576
+			//Get and remove all old images of post from database to set by new order
1577
+			$geodir_uploaddir = '';
1578
+			$uploads = wp_upload_dir();
1579
+			$uploads_dir = $uploads['path'];
1580 1580
 
1581
-            $geodir_uploadpath = $uploads['path'];
1582
-            $geodir_uploadurl = $uploads['url'];
1583
-            $sub_dir = $uploads['subdir'];
1581
+			$geodir_uploadpath = $uploads['path'];
1582
+			$geodir_uploadurl = $uploads['url'];
1583
+			$sub_dir = $uploads['subdir'];
1584 1584
 
1585
-            $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1585
+			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1586 1586
 
1587
-            for ($m = 0; $m < count($post_image); $m++) {
1587
+			for ($m = 0; $m < count($post_image); $m++) {
1588 1588
 
1589
-                /* --------- start ------- */
1589
+				/* --------- start ------- */
1590 1590
 
1591
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1591
+				if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1592 1592
 
1593 1593
 
1594
-                    $curr_img_url = $post_image[$m];
1595
-                    $image_name_arr = explode('/', $curr_img_url);
1596
-                    $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1597
-                    $filename = end($image_name_arr);
1598
-                    $img_name_arr = explode('.', $filename);
1594
+					$curr_img_url = $post_image[$m];
1595
+					$image_name_arr = explode('/', $curr_img_url);
1596
+					$curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1597
+					$filename = end($image_name_arr);
1598
+					$img_name_arr = explode('.', $filename);
1599 1599
 
1600
-                    $arr_file_type = wp_check_filetype($filename);
1600
+					$arr_file_type = wp_check_filetype($filename);
1601 1601
 
1602
-                    if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1603
-                        continue;
1604
-                    }
1602
+					if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1603
+						continue;
1604
+					}
1605 1605
 
1606
-                    $uploaded_file_type = $arr_file_type['type'];
1607
-                    $uploaded_file_ext = $arr_file_type['ext'];
1606
+					$uploaded_file_type = $arr_file_type['type'];
1607
+					$uploaded_file_ext = $arr_file_type['ext'];
1608 1608
 
1609
-                    if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1610
-                        continue; // Invalid file type.
1611
-                    }
1609
+					if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1610
+						continue; // Invalid file type.
1611
+					}
1612 1612
 
1613
-                    // Set an array containing a list of acceptable formats
1614
-                    //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1613
+					// Set an array containing a list of acceptable formats
1614
+					//$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1615 1615
 
1616
-                    if (!function_exists('wp_handle_upload'))
1617
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1616
+					if (!function_exists('wp_handle_upload'))
1617
+						require_once(ABSPATH . 'wp-admin/includes/file.php');
1618 1618
 
1619
-                    if (!is_dir($geodir_uploadpath))
1620
-                        mkdir($geodir_uploadpath);
1619
+					if (!is_dir($geodir_uploadpath))
1620
+						mkdir($geodir_uploadpath);
1621 1621
 
1622
-                    $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1623
-                    $explode_sub_dir = explode("/", $sub_dir);
1624
-                    if ($curr_img_dir == end($explode_sub_dir)) {
1625
-                        $img_path = $geodir_uploadpath . '/' . $filename;
1626
-                        $img_url = $geodir_uploadurl . '/' . $filename;
1627
-                    } else {
1628
-                        $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1629
-                        $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1630
-                    }
1622
+					$new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1623
+					$explode_sub_dir = explode("/", $sub_dir);
1624
+					if ($curr_img_dir == end($explode_sub_dir)) {
1625
+						$img_path = $geodir_uploadpath . '/' . $filename;
1626
+						$img_url = $geodir_uploadurl . '/' . $filename;
1627
+					} else {
1628
+						$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1629
+						$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1630
+					}
1631 1631
 
1632
-                    $uploaded_file = '';
1633
-                    if (file_exists($img_path))
1634
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1632
+					$uploaded_file = '';
1633
+					if (file_exists($img_path))
1634
+						$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1635 1635
 
1636
-                    if ($curr_img_dir != $geodir_uploaddir) {
1637
-                        if (file_exists($img_path))
1638
-                            unlink($img_path);
1639
-                    }
1636
+					if ($curr_img_dir != $geodir_uploaddir) {
1637
+						if (file_exists($img_path))
1638
+							unlink($img_path);
1639
+					}
1640 1640
 
1641
-                    if (!empty($uploaded_file))
1642
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1641
+					if (!empty($uploaded_file))
1642
+						$file_urls = $geodir_uploadurl . '/' . $new_name;
1643 1643
 
1644
-                } else {
1645
-                    $file_urls = $post_image[$m];
1646
-                }
1647
-            }
1644
+				} else {
1645
+					$file_urls = $post_image[$m];
1646
+				}
1647
+			}
1648 1648
 
1649 1649
 
1650
-        }
1650
+		}
1651 1651
 
1652
-        //Remove all old attachments and temp images
1653
-        if (!empty($postcurr_images)) {
1652
+		//Remove all old attachments and temp images
1653
+		if (!empty($postcurr_images)) {
1654 1654
 
1655
-            if ($file_urls != $postcurr_images) {
1656
-                $invalid_files[] = (object)array('src' => $postcurr_images);
1657
-                $invalid_files = (object)$invalid_files;
1658
-            }
1659
-        }
1655
+			if ($file_urls != $postcurr_images) {
1656
+				$invalid_files[] = (object)array('src' => $postcurr_images);
1657
+				$invalid_files = (object)$invalid_files;
1658
+			}
1659
+		}
1660 1660
 
1661
-        geodir_save_post_meta($post_id, $field_id, $file_urls);
1661
+		geodir_save_post_meta($post_id, $field_id, $file_urls);
1662 1662
 
1663
-        if (!empty($invalid_files))
1664
-            geodir_remove_attachments($invalid_files);
1663
+		if (!empty($invalid_files))
1664
+			geodir_remove_attachments($invalid_files);
1665 1665
 
1666
-    }
1666
+	}
1667 1667
 }
1668 1668
 
1669 1669
 
@@ -1678,76 +1678,76 @@  discard block
 block discarded – undo
1678 1678
  */
1679 1679
 function geodir_custom_upload_mimes($existing_mimes = array())
1680 1680
 {
1681
-    $existing_mimes['wif'] = 'text/plain';
1682
-    $existing_mimes['jpg|jpeg'] = 'image/jpeg';
1683
-    $existing_mimes['gif'] = 'image/gif';
1684
-    $existing_mimes['png'] = 'image/png';
1685
-    $existing_mimes['pdf'] = 'application/pdf';
1686
-    $existing_mimes['txt'] = 'text/text';
1687
-    $existing_mimes['csv'] = 'application/octet-stream';
1688
-    $existing_mimes['doc'] = 'application/msword';
1689
-    $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
1690
-    $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1691
-    $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
1692
-    return $existing_mimes;
1681
+	$existing_mimes['wif'] = 'text/plain';
1682
+	$existing_mimes['jpg|jpeg'] = 'image/jpeg';
1683
+	$existing_mimes['gif'] = 'image/gif';
1684
+	$existing_mimes['png'] = 'image/png';
1685
+	$existing_mimes['pdf'] = 'application/pdf';
1686
+	$existing_mimes['txt'] = 'text/text';
1687
+	$existing_mimes['csv'] = 'application/octet-stream';
1688
+	$existing_mimes['doc'] = 'application/msword';
1689
+	$existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
1690
+	$existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1691
+	$existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
1692
+	return $existing_mimes;
1693 1693
 }
1694 1694
 
1695 1695
 if (!function_exists('geodir_plupload_action')) {
1696 1696
 
1697
-    /**
1698
-     * Get upload directory path details
1699
-     *
1700
-     * @since 1.0.0
1701
-     * @package GeoDirectory
1702
-     * @global object $current_user Current user object.
1703
-     * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
1704
-     * @return mixed Returns upload directory details as an array.
1705
-     */
1706
-    function geodir_upload_dir($upload)
1707
-    {
1708
-        global $current_user;
1709
-        $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1710
-        $upload['path'] = $upload['basedir'] . $upload['subdir'];
1711
-        $upload['url'] = $upload['baseurl'] . $upload['subdir'];
1712
-        return $upload;
1713
-    }
1714
-
1715
-    /**
1716
-     * Handles place file and image upload.
1717
-     *
1718
-     * @since 1.0.0
1719
-     * @package GeoDirectory
1720
-     */
1721
-    function geodir_plupload_action()
1722
-    {
1723
-        // check ajax nonce
1724
-        $imgid = $_POST["imgid"];
1725
-
1726
-        check_ajax_referer($imgid . 'pluploadan');
1727
-
1728
-        // handle custom file uploaddir
1729
-        add_filter('upload_dir', 'geodir_upload_dir');
1730
-
1731
-        // change file orientation if needed
1732
-        $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1733
-
1734
-        // handle file upload
1735
-        $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1736
-        // remove handle custom file uploaddir
1737
-        remove_filter('upload_dir', 'geodir_upload_dir');
1738
-
1739
-        if(!isset($status['url']) && isset($status['error'])){
1740
-            print_r($status);
1741
-        }
1742
-
1743
-        // send the uploaded file url in response
1744
-        if (isset($status['url'])) {
1745
-            echo $status['url'];
1746
-        } else {
1747
-            echo 'x';
1748
-        }
1749
-        exit;
1750
-    }
1697
+	/**
1698
+	 * Get upload directory path details
1699
+	 *
1700
+	 * @since 1.0.0
1701
+	 * @package GeoDirectory
1702
+	 * @global object $current_user Current user object.
1703
+	 * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
1704
+	 * @return mixed Returns upload directory details as an array.
1705
+	 */
1706
+	function geodir_upload_dir($upload)
1707
+	{
1708
+		global $current_user;
1709
+		$upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1710
+		$upload['path'] = $upload['basedir'] . $upload['subdir'];
1711
+		$upload['url'] = $upload['baseurl'] . $upload['subdir'];
1712
+		return $upload;
1713
+	}
1714
+
1715
+	/**
1716
+	 * Handles place file and image upload.
1717
+	 *
1718
+	 * @since 1.0.0
1719
+	 * @package GeoDirectory
1720
+	 */
1721
+	function geodir_plupload_action()
1722
+	{
1723
+		// check ajax nonce
1724
+		$imgid = $_POST["imgid"];
1725
+
1726
+		check_ajax_referer($imgid . 'pluploadan');
1727
+
1728
+		// handle custom file uploaddir
1729
+		add_filter('upload_dir', 'geodir_upload_dir');
1730
+
1731
+		// change file orientation if needed
1732
+		$fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1733
+
1734
+		// handle file upload
1735
+		$status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1736
+		// remove handle custom file uploaddir
1737
+		remove_filter('upload_dir', 'geodir_upload_dir');
1738
+
1739
+		if(!isset($status['url']) && isset($status['error'])){
1740
+			print_r($status);
1741
+		}
1742
+
1743
+		// send the uploaded file url in response
1744
+		if (isset($status['url'])) {
1745
+			echo $status['url'];
1746
+		} else {
1747
+			echo 'x';
1748
+		}
1749
+		exit;
1750
+	}
1751 1751
 }
1752 1752
 
1753 1753
 /**
@@ -1762,17 +1762,17 @@  discard block
 block discarded – undo
1762 1762
  */
1763 1763
 function geodir_get_video($post_id)
1764 1764
 {
1765
-    global $wpdb, $plugin_prefix;
1765
+	global $wpdb, $plugin_prefix;
1766 1766
 
1767
-    $post_type = get_post_type($post_id);
1767
+	$post_type = get_post_type($post_id);
1768 1768
 
1769
-    $table = $plugin_prefix . $post_type . '_detail';
1769
+	$table = $plugin_prefix . $post_type . '_detail';
1770 1770
 
1771
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1771
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1772 1772
 
1773
-    if ($results) {
1774
-        return $results[0]->geodir_video;
1775
-    }
1773
+	if ($results) {
1774
+		return $results[0]->geodir_video;
1775
+	}
1776 1776
 
1777 1777
 }
1778 1778
 
@@ -1788,40 +1788,40 @@  discard block
 block discarded – undo
1788 1788
  */
1789 1789
 function geodir_get_special_offers($post_id)
1790 1790
 {
1791
-    global $wpdb, $plugin_prefix;
1791
+	global $wpdb, $plugin_prefix;
1792 1792
 
1793
-    $post_type = get_post_type($post_id);
1793
+	$post_type = get_post_type($post_id);
1794 1794
 
1795
-    $table = $plugin_prefix . $post_type . '_detail';
1795
+	$table = $plugin_prefix . $post_type . '_detail';
1796 1796
 
1797
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1797
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1798 1798
 
1799
-    if ($results) {
1800
-        return $results[0]->geodir_special_offers;
1801
-    }
1799
+	if ($results) {
1800
+		return $results[0]->geodir_special_offers;
1801
+	}
1802 1802
 
1803 1803
 }
1804 1804
 
1805 1805
 if (!function_exists('geodir_max_upload_size')) {
1806
-    /**
1807
-     * Get max upload file size
1808
-     *
1809
-     * @since 1.0.0
1810
-     * @package GeoDirectory
1811
-     * @return mixed|void Returns max upload file size.
1812
-     */
1813
-    function geodir_max_upload_size()
1814
-    {
1815
-        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1816
-
1817
-        if ($max_filesize > 0 && $max_filesize < 1) {
1818
-            $max_filesize = (int)($max_filesize * 1024) . 'kb';
1819
-        } else {
1820
-            $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1821
-        }
1822
-        /** Filter documented in geodirectory-functions/general_functions.php **/
1823
-        return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1824
-    }
1806
+	/**
1807
+	 * Get max upload file size
1808
+	 *
1809
+	 * @since 1.0.0
1810
+	 * @package GeoDirectory
1811
+	 * @return mixed|void Returns max upload file size.
1812
+	 */
1813
+	function geodir_max_upload_size()
1814
+	{
1815
+		$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1816
+
1817
+		if ($max_filesize > 0 && $max_filesize < 1) {
1818
+			$max_filesize = (int)($max_filesize * 1024) . 'kb';
1819
+		} else {
1820
+			$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1821
+		}
1822
+		/** Filter documented in geodirectory-functions/general_functions.php **/
1823
+		return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1824
+	}
1825 1825
 }
1826 1826
 
1827 1827
 
@@ -1839,33 +1839,33 @@  discard block
 block discarded – undo
1839 1839
  */
1840 1840
 function geodir_add_custom_sort_options($fields, $post_type)
1841 1841
 {
1842
-    global $wpdb;
1842
+	global $wpdb;
1843 1843
 
1844
-    if ($post_type != '') {
1844
+	if ($post_type != '') {
1845 1845
 
1846
-        $all_postypes = geodir_get_posttypes();
1846
+		$all_postypes = geodir_get_posttypes();
1847 1847
 
1848
-        if (in_array($post_type, $all_postypes)) {
1848
+		if (in_array($post_type, $all_postypes)) {
1849 1849
 
1850
-            $custom_fields = $wpdb->get_results(
1851
-                $wpdb->prepare(
1852
-                    "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1853
-                    array($post_type)
1854
-                ), 'ARRAY_A'
1855
-            );
1850
+			$custom_fields = $wpdb->get_results(
1851
+				$wpdb->prepare(
1852
+					"select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1853
+					array($post_type)
1854
+				), 'ARRAY_A'
1855
+			);
1856 1856
 
1857
-            if (!empty($custom_fields)) {
1857
+			if (!empty($custom_fields)) {
1858 1858
 
1859
-                foreach ($custom_fields as $val) {
1860
-                    $fields[] = $val;
1861
-                }
1862
-            }
1859
+				foreach ($custom_fields as $val) {
1860
+					$fields[] = $val;
1861
+				}
1862
+			}
1863 1863
 
1864
-        }
1864
+		}
1865 1865
 
1866
-    }
1866
+	}
1867 1867
 
1868
-    return $fields;
1868
+	return $fields;
1869 1869
 }
1870 1870
 
1871 1871
 
@@ -1881,76 +1881,76 @@  discard block
 block discarded – undo
1881 1881
 function geodir_get_custom_sort_options($post_type = '')
1882 1882
 {
1883 1883
 
1884
-    global $wpdb;
1885
-
1886
-    if ($post_type != '') {
1887
-
1888
-        $all_postypes = geodir_get_posttypes();
1889
-
1890
-        if (!in_array($post_type, $all_postypes))
1891
-            return false;
1892
-
1893
-        $fields = array();
1894
-
1895
-        $fields[] = array(
1896
-            'post_type' => $post_type,
1897
-            'data_type' => '',
1898
-            'field_type' => 'random',
1899
-            'site_title' => 'Random',
1900
-            'htmlvar_name' => 'post_title',
1901
-            'field_icon' =>  'fa fa-random',
1902
-            'description' =>  __('Random sort (not recommended for large sites)', 'geodirectory')
1903
-        );
1904
-
1905
-        $fields[] = array(
1906
-            'post_type' => $post_type,
1907
-            'data_type' => '',
1908
-            'field_type' => 'datetime',
1909
-            'site_title' => __('Add date', 'geodirectory'),
1910
-            'htmlvar_name' => 'post_date',
1911
-            'field_icon' =>  'fa fa-calendar',
1912
-            'description' =>  __('Sort by date added', 'geodirectory')
1913
-        );
1914
-        $fields[] = array(
1915
-            'post_type' => $post_type,
1916
-            'data_type' => '',
1917
-            'field_type' => 'bigint',
1918
-            'site_title' => __('Review', 'geodirectory'),
1919
-            'htmlvar_name' => 'comment_count',
1920
-            'field_icon' =>  'fa fa-commenting-o',
1921
-            'description' =>  __('Sort by the number of reviews', 'geodirectory')
1922
-        );
1923
-        $fields[] = array(
1924
-            'post_type' => $post_type,
1925
-            'data_type' => '',
1926
-            'field_type' => 'float',
1927
-            'site_title' => __('Rating', 'geodirectory'),
1928
-            'htmlvar_name' => 'overall_rating',
1929
-            'field_icon' =>  'fa fa-star-o',
1930
-            'description' =>  __('Sort by the overall rating value', 'geodirectory')
1931
-        );
1932
-        $fields[] = array(
1933
-            'post_type' => $post_type,
1934
-            'data_type' => '',
1935
-            'field_type' => 'text',
1936
-            'site_title' => __('Title', 'geodirectory'),
1937
-            'htmlvar_name' => 'post_title',
1938
-            'field_icon' =>  'fa fa-sort-alpha-desc',
1939
-            'description' =>  __('Sort alphabetically by title', 'geodirectory')
1940
-        );
1941
-
1942
-        /**
1943
-         * Hook to add custom sort options.
1944
-         *
1945
-         * @since 1.0.0
1946
-         * @param array $fields Unmodified sort options array.
1947
-         * @param string $post_type Post type.
1948
-         */
1949
-        return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
1950
-
1951
-    }
1952
-
1953
-    return false;
1884
+	global $wpdb;
1885
+
1886
+	if ($post_type != '') {
1887
+
1888
+		$all_postypes = geodir_get_posttypes();
1889
+
1890
+		if (!in_array($post_type, $all_postypes))
1891
+			return false;
1892
+
1893
+		$fields = array();
1894
+
1895
+		$fields[] = array(
1896
+			'post_type' => $post_type,
1897
+			'data_type' => '',
1898
+			'field_type' => 'random',
1899
+			'site_title' => 'Random',
1900
+			'htmlvar_name' => 'post_title',
1901
+			'field_icon' =>  'fa fa-random',
1902
+			'description' =>  __('Random sort (not recommended for large sites)', 'geodirectory')
1903
+		);
1904
+
1905
+		$fields[] = array(
1906
+			'post_type' => $post_type,
1907
+			'data_type' => '',
1908
+			'field_type' => 'datetime',
1909
+			'site_title' => __('Add date', 'geodirectory'),
1910
+			'htmlvar_name' => 'post_date',
1911
+			'field_icon' =>  'fa fa-calendar',
1912
+			'description' =>  __('Sort by date added', 'geodirectory')
1913
+		);
1914
+		$fields[] = array(
1915
+			'post_type' => $post_type,
1916
+			'data_type' => '',
1917
+			'field_type' => 'bigint',
1918
+			'site_title' => __('Review', 'geodirectory'),
1919
+			'htmlvar_name' => 'comment_count',
1920
+			'field_icon' =>  'fa fa-commenting-o',
1921
+			'description' =>  __('Sort by the number of reviews', 'geodirectory')
1922
+		);
1923
+		$fields[] = array(
1924
+			'post_type' => $post_type,
1925
+			'data_type' => '',
1926
+			'field_type' => 'float',
1927
+			'site_title' => __('Rating', 'geodirectory'),
1928
+			'htmlvar_name' => 'overall_rating',
1929
+			'field_icon' =>  'fa fa-star-o',
1930
+			'description' =>  __('Sort by the overall rating value', 'geodirectory')
1931
+		);
1932
+		$fields[] = array(
1933
+			'post_type' => $post_type,
1934
+			'data_type' => '',
1935
+			'field_type' => 'text',
1936
+			'site_title' => __('Title', 'geodirectory'),
1937
+			'htmlvar_name' => 'post_title',
1938
+			'field_icon' =>  'fa fa-sort-alpha-desc',
1939
+			'description' =>  __('Sort alphabetically by title', 'geodirectory')
1940
+		);
1941
+
1942
+		/**
1943
+		 * Hook to add custom sort options.
1944
+		 *
1945
+		 * @since 1.0.0
1946
+		 * @param array $fields Unmodified sort options array.
1947
+		 * @param string $post_type Post type.
1948
+		 */
1949
+		return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
1950
+
1951
+	}
1952
+
1953
+	return false;
1954 1954
 }
1955 1955
 
1956 1956
 
@@ -1966,117 +1966,117 @@  discard block
 block discarded – undo
1966 1966
 function godir_set_sort_field_order($field_ids = array())
1967 1967
 {
1968 1968
 
1969
-    global $wpdb;
1969
+	global $wpdb;
1970 1970
 
1971
-    $count = 0;
1972
-    if (!empty($field_ids)):
1973
-        foreach ($field_ids as $id) {
1971
+	$count = 0;
1972
+	if (!empty($field_ids)):
1973
+		foreach ($field_ids as $id) {
1974 1974
 
1975
-            $cf = trim($id, '_');
1975
+			$cf = trim($id, '_');
1976 1976
 
1977
-            $post_meta_info = $wpdb->query(
1978
-                $wpdb->prepare(
1979
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1977
+			$post_meta_info = $wpdb->query(
1978
+				$wpdb->prepare(
1979
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1980 1980
 															sort_order=%d 
1981 1981
 															where id= %d",
1982
-                    array($count, $cf)
1983
-                )
1984
-            );
1985
-            $count++;
1986
-        }
1987
-
1988
-        return $field_ids;
1989
-    else:
1990
-        return false;
1991
-    endif;
1982
+					array($count, $cf)
1983
+				)
1984
+			);
1985
+			$count++;
1986
+		}
1987
+
1988
+		return $field_ids;
1989
+	else:
1990
+		return false;
1991
+	endif;
1992 1992
 }
1993 1993
 
1994 1994
 
1995 1995
 if (!function_exists('geodir_custom_sort_field_save')) {
1996
-    /**
1997
-     * Save or Update custom sort fields into the database.
1998
-     *
1999
-     * @since 1.0.0
2000
-     * @package GeoDirectory
2001
-     * @global object $wpdb WordPress Database object.
2002
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2003
-     * @param array $request_field {
2004
-     *    Attributes of the Request field.
2005
-     *
2006
-     *    @type string $action Ajax action name.
2007
-     *    @type string $manage_field_type Manage field type Default "sorting_options".
2008
-     *    @type string $create_field Do you want to create this field?.
2009
-     *    @type string $field_ins_upd Field created or updated?.
2010
-     *    @type string $_wpnonce Nonce value.
2011
-     *    @type string $listing_type The Post type.
2012
-     *    @type string $field_type Field Type.
2013
-     *    @type string $field_id Field ID.
2014
-     *    @type string $data_type Data Type.
2015
-     *    @type string $htmlvar_name HTML variable name.
2016
-     *    @type string $site_title Section title which you wish to display in frontend.
2017
-     *    @type string $is_default Is this default sorting?.
2018
-     *    @type string $is_active If not active then the field will not be displayed anywhere.
2019
-     *    @type string $sort_order Sort Order.
2020
-     *
2021
-     * }
2022
-     * @param bool $default Not yet implemented.
2023
-     * @return int Returns the last affected db table row id.
2024
-     */
2025
-    function geodir_custom_sort_field_save($request_field = array(), $default = false)
2026
-    {
2027
-
2028
-        global $wpdb, $plugin_prefix;
2029
-
2030
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
2031
-
2032
-        $cf = trim($result_str, '_');
2033
-
2034
-        /*-------- check duplicate validation --------*/
2035
-
2036
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2037
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2038
-
2039
-        $post_type = $request_field['listing_type'];
2040
-        $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
2041
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2042
-        $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
2043
-        $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2044
-        $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
2045
-        $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
2046
-        $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
2047
-        $asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
2048
-        $desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
2049
-        $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
2050
-        $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
2051
-
2052
-        $default_order = '';
2053
-        if ($is_default != '') {
2054
-            $default_order = $is_default;
2055
-            $is_default = '1';
2056
-        }
2057
-
2058
-
2059
-        $check_html_variable = $wpdb->get_var(
2060
-            $wpdb->prepare(
2061
-                "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2062
-                array($cehhtmlvar_name, $post_type, $field_type)
2063
-            )
2064
-        );
2065
-
2066
-        if ($is_default == 1) {
2067
-
2068
-            $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2069
-
2070
-        }
2071
-
2072
-
2073
-        if (!$check_html_variable) {
2074
-
2075
-            $wpdb->query(
2076
-
2077
-                $wpdb->prepare(
2078
-
2079
-                    "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1996
+	/**
1997
+	 * Save or Update custom sort fields into the database.
1998
+	 *
1999
+	 * @since 1.0.0
2000
+	 * @package GeoDirectory
2001
+	 * @global object $wpdb WordPress Database object.
2002
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2003
+	 * @param array $request_field {
2004
+	 *    Attributes of the Request field.
2005
+	 *
2006
+	 *    @type string $action Ajax action name.
2007
+	 *    @type string $manage_field_type Manage field type Default "sorting_options".
2008
+	 *    @type string $create_field Do you want to create this field?.
2009
+	 *    @type string $field_ins_upd Field created or updated?.
2010
+	 *    @type string $_wpnonce Nonce value.
2011
+	 *    @type string $listing_type The Post type.
2012
+	 *    @type string $field_type Field Type.
2013
+	 *    @type string $field_id Field ID.
2014
+	 *    @type string $data_type Data Type.
2015
+	 *    @type string $htmlvar_name HTML variable name.
2016
+	 *    @type string $site_title Section title which you wish to display in frontend.
2017
+	 *    @type string $is_default Is this default sorting?.
2018
+	 *    @type string $is_active If not active then the field will not be displayed anywhere.
2019
+	 *    @type string $sort_order Sort Order.
2020
+	 *
2021
+	 * }
2022
+	 * @param bool $default Not yet implemented.
2023
+	 * @return int Returns the last affected db table row id.
2024
+	 */
2025
+	function geodir_custom_sort_field_save($request_field = array(), $default = false)
2026
+	{
2027
+
2028
+		global $wpdb, $plugin_prefix;
2029
+
2030
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
2031
+
2032
+		$cf = trim($result_str, '_');
2033
+
2034
+		/*-------- check duplicate validation --------*/
2035
+
2036
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2037
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2038
+
2039
+		$post_type = $request_field['listing_type'];
2040
+		$data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
2041
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2042
+		$site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
2043
+		$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2044
+		$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
2045
+		$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
2046
+		$is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
2047
+		$asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
2048
+		$desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
2049
+		$asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
2050
+		$desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
2051
+
2052
+		$default_order = '';
2053
+		if ($is_default != '') {
2054
+			$default_order = $is_default;
2055
+			$is_default = '1';
2056
+		}
2057
+
2058
+
2059
+		$check_html_variable = $wpdb->get_var(
2060
+			$wpdb->prepare(
2061
+				"select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2062
+				array($cehhtmlvar_name, $post_type, $field_type)
2063
+			)
2064
+		);
2065
+
2066
+		if ($is_default == 1) {
2067
+
2068
+			$wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2069
+
2070
+		}
2071
+
2072
+
2073
+		if (!$check_html_variable) {
2074
+
2075
+			$wpdb->query(
2076
+
2077
+				$wpdb->prepare(
2078
+
2079
+					"insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2080 2080
 				post_type = %s,
2081 2081
 				data_type = %s,
2082 2082
 				field_type = %s,
@@ -2091,23 +2091,23 @@  discard block
 block discarded – undo
2091 2091
 				asc_title = %s,
2092 2092
 				desc_title = %s",
2093 2093
 
2094
-                    array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title)
2095
-                )
2094
+					array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title)
2095
+				)
2096 2096
 
2097
-            );
2097
+			);
2098 2098
 
2099 2099
 
2100
-            $lastid = $wpdb->insert_id;
2100
+			$lastid = $wpdb->insert_id;
2101 2101
 
2102
-            $lastid = trim($lastid);
2102
+			$lastid = trim($lastid);
2103 2103
 
2104
-        } else {
2104
+		} else {
2105 2105
 
2106
-            $wpdb->query(
2106
+			$wpdb->query(
2107 2107
 
2108
-                $wpdb->prepare(
2108
+				$wpdb->prepare(
2109 2109
 
2110
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2110
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2111 2111
 				post_type = %s,
2112 2112
 				data_type = %s,
2113 2113
 				field_type = %s,
@@ -2123,123 +2123,123 @@  discard block
 block discarded – undo
2123 2123
 				desc_title = %s
2124 2124
 				where id = %d",
2125 2125
 
2126
-                    array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf)
2127
-                )
2126
+					array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf)
2127
+				)
2128 2128
 
2129
-            );
2129
+			);
2130 2130
 
2131
-            $lastid = trim($cf);
2131
+			$lastid = trim($cf);
2132 2132
 
2133
-        }
2133
+		}
2134 2134
 
2135 2135
 
2136
-        return (int)$lastid;
2136
+		return (int)$lastid;
2137 2137
 
2138
-    }
2138
+	}
2139 2139
 }
2140 2140
 
2141 2141
 
2142 2142
 if (!function_exists('geodir_custom_sort_field_delete')) {
2143
-    /**
2144
-     * Delete a custom sort field using field id.
2145
-     * @since 1.0.0
2146
-     * @package GeoDirectory
2147
-     * @global object $wpdb WordPress Database object.
2148
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2149
-     * @param string $field_id The field ID.
2150
-     * @return int|string Returns field id when successful deletion, else returns 0.
2151
-     */
2152
-    function geodir_custom_sort_field_delete($field_id = '')
2153
-    {
2154
-
2155
-        global $wpdb, $plugin_prefix;
2156
-        if ($field_id != '') {
2157
-            $cf = trim($field_id, '_');
2158
-
2159
-            $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2160
-
2161
-            return $field_id;
2162
-
2163
-        } else
2164
-            return 0;
2165
-
2166
-    }
2143
+	/**
2144
+	 * Delete a custom sort field using field id.
2145
+	 * @since 1.0.0
2146
+	 * @package GeoDirectory
2147
+	 * @global object $wpdb WordPress Database object.
2148
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2149
+	 * @param string $field_id The field ID.
2150
+	 * @return int|string Returns field id when successful deletion, else returns 0.
2151
+	 */
2152
+	function geodir_custom_sort_field_delete($field_id = '')
2153
+	{
2154
+
2155
+		global $wpdb, $plugin_prefix;
2156
+		if ($field_id != '') {
2157
+			$cf = trim($field_id, '_');
2158
+
2159
+			$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2160
+
2161
+			return $field_id;
2162
+
2163
+		} else
2164
+			return 0;
2165
+
2166
+	}
2167 2167
 }
2168 2168
 
2169 2169
 
2170 2170
 if (!function_exists('geodir_custom_sort_field_adminhtml')) {
2171
-    /**
2172
-     * Custom sort field admin html.
2173
-     *
2174
-     * @since 1.0.0
2175
-     * @package GeoDirectory
2176
-     * @global object $wpdb WordPress Database object.
2177
-     * @param string $field_type The form field type.
2178
-     * @param object|int $result_str The custom field results object or row id.
2179
-     * @param string $field_ins_upd When set to "submit" displays form.
2180
-     * @param bool $default when set to true field will be for admin use only.
2181
-     */
2182
-    function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='')
2183
-    {
2184
-        global $wpdb;
2185
-        $cf = $result_str;
2186
-        if (!is_object($cf)) {
2187
-            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2188
-        } else {
2189
-            $field_info = $cf;
2190
-            $result_str = $cf->id;
2191
-        }
2192
-
2193
-        $field_info = stripslashes_deep($field_info); // strip slashes
2194
-
2195
-        if (!isset($field_info->post_type)) {
2196
-            $post_type = sanitize_text_field($_REQUEST['listing_type']);
2197
-        } else {
2198
-            $post_type = $field_info->post_type;
2199
-        }
2200
-
2201
-
2202
-        $htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2203
-
2204
-        $site_title = '';
2205
-        if ($site_title == '')
2206
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2207
-
2208
-        if ($site_title == '') {
2209
-            $fields = geodir_get_custom_sort_options($post_type);
2210
-
2211
-            foreach ($fields as $val) {
2212
-                $val = stripslashes_deep($val); // strip slashes
2213
-
2214
-                if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
2215
-                    $site_title = isset($val['site_title']) ? $val['site_title'] : '';
2216
-                }
2217
-            }
2218
-        }
2219
-
2220
-        if ($htmlvar_name == '')
2221
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2222
-
2223
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
2224
-
2225
-        $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
2226
-        $cso_arr = geodir_get_custom_sort_options($post_type);
2227
-
2228
-        $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']);
2229
-        foreach($cso_arr as $cso){
2230
-            if($cur_field_type==$cso['field_type']){
2231
-
2232
-                if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2233
-                    $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2234
-                }elseif(isset($cso['field_icon']) && $cso['field_icon']){
2235
-                    $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2236
-                }
2237
-
2238
-            }
2239
-        }
2240
-
2241
-        $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500);
2242
-        ?>
2171
+	/**
2172
+	 * Custom sort field admin html.
2173
+	 *
2174
+	 * @since 1.0.0
2175
+	 * @package GeoDirectory
2176
+	 * @global object $wpdb WordPress Database object.
2177
+	 * @param string $field_type The form field type.
2178
+	 * @param object|int $result_str The custom field results object or row id.
2179
+	 * @param string $field_ins_upd When set to "submit" displays form.
2180
+	 * @param bool $default when set to true field will be for admin use only.
2181
+	 */
2182
+	function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='')
2183
+	{
2184
+		global $wpdb;
2185
+		$cf = $result_str;
2186
+		if (!is_object($cf)) {
2187
+			$field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2188
+		} else {
2189
+			$field_info = $cf;
2190
+			$result_str = $cf->id;
2191
+		}
2192
+
2193
+		$field_info = stripslashes_deep($field_info); // strip slashes
2194
+
2195
+		if (!isset($field_info->post_type)) {
2196
+			$post_type = sanitize_text_field($_REQUEST['listing_type']);
2197
+		} else {
2198
+			$post_type = $field_info->post_type;
2199
+		}
2200
+
2201
+
2202
+		$htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2203
+
2204
+		$site_title = '';
2205
+		if ($site_title == '')
2206
+			$site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2207
+
2208
+		if ($site_title == '') {
2209
+			$fields = geodir_get_custom_sort_options($post_type);
2210
+
2211
+			foreach ($fields as $val) {
2212
+				$val = stripslashes_deep($val); // strip slashes
2213
+
2214
+				if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
2215
+					$site_title = isset($val['site_title']) ? $val['site_title'] : '';
2216
+				}
2217
+			}
2218
+		}
2219
+
2220
+		if ($htmlvar_name == '')
2221
+			$htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2222
+
2223
+		$nonce = wp_create_nonce('custom_fields_' . $result_str);
2224
+
2225
+		$field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
2226
+		$cso_arr = geodir_get_custom_sort_options($post_type);
2227
+
2228
+		$cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']);
2229
+		foreach($cso_arr as $cso){
2230
+			if($cur_field_type==$cso['field_type']){
2231
+
2232
+				if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2233
+					$field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2234
+				}elseif(isset($cso['field_icon']) && $cso['field_icon']){
2235
+					$field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2236
+				}
2237
+
2238
+			}
2239
+		}
2240
+
2241
+		$radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500);
2242
+		?>
2243 2243
 
2244 2244
         <li class="text" id="licontainer_<?php echo $result_str;?>">
2245 2245
             <form><!-- we need to wrap in a form so we can use radio buttons with same name -->
@@ -2248,7 +2248,7 @@  discard block
 block discarded – undo
2248 2248
                  ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
2249 2249
                 <?php
2250 2250
 
2251
-                ?>
2251
+				?>
2252 2252
 
2253 2253
                 <div title="<?php _e('Click to remove field', 'geodirectory');?>"
2254 2254
                      onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
@@ -2263,17 +2263,17 @@  discard block
 block discarded – undo
2263 2263
 
2264 2264
             <div id="field_frm<?php echo $result_str;?>" class="field_frm"
2265 2265
                  style="display:<?php if ($field_ins_upd == 'submit') {
2266
-                     echo 'block;';
2267
-                 } else {
2268
-                     echo 'none;';
2269
-                 } ?>">
2266
+					 echo 'block;';
2267
+				 } else {
2268
+					 echo 'none;';
2269
+				 } ?>">
2270 2270
                 <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
2271 2271
                 <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/>
2272 2272
                 <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/>
2273 2273
                 <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/>
2274 2274
                 <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
2275
-                    echo $field_info->data_type;
2276
-                }?>"/>
2275
+					echo $field_info->data_type;
2276
+				}?>"/>
2277 2277
                 <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/>
2278 2278
 
2279 2279
 
@@ -2296,14 +2296,14 @@  discard block
 block discarded – undo
2296 2296
 
2297 2297
                                 <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled"  value="1"
2298 2298
                                     <?php if ($value == '1') {
2299
-                                        echo 'checked';
2300
-                                    } ?>/>
2299
+										echo 'checked';
2300
+									} ?>/>
2301 2301
                                 <label onclick="show_hide_radio(this,'show','cfs-asc-title');" for="asc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2302 2302
 
2303 2303
                                 <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0"
2304 2304
                                     <?php if ($value == '0' || !$value) {
2305
-                                        echo 'checked';
2306
-                                    } ?>/>
2305
+										echo 'checked';
2306
+									} ?>/>
2307 2307
                                 <label onclick="show_hide_radio(this,'hide','cfs-asc-title');" for="asc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2308 2308
 
2309 2309
                             </div>
@@ -2340,8 +2340,8 @@  discard block
 block discarded – undo
2340 2340
 
2341 2341
                                 <input type="radio" name="is_default"
2342 2342
                                        value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
2343
-                                    echo 'checked="checked"';
2344
-                                } ?>/>
2343
+									echo 'checked="checked"';
2344
+								} ?>/>
2345 2345
                             </div>
2346 2346
 
2347 2347
                         </li>
@@ -2361,14 +2361,14 @@  discard block
 block discarded – undo
2361 2361
 
2362 2362
                                 <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled"  value="1"
2363 2363
                                     <?php if ($value == '1') {
2364
-                                        echo 'checked';
2365
-                                    } ?>/>
2364
+										echo 'checked';
2365
+									} ?>/>
2366 2366
                                 <label onclick="show_hide_radio(this,'show','cfs-desc-title');" for="desc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2367 2367
 
2368 2368
                                 <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0"
2369 2369
                                     <?php if ($value == '0' || !$value) {
2370
-                                        echo 'checked';
2371
-                                    } ?>/>
2370
+										echo 'checked';
2371
+									} ?>/>
2372 2372
                                 <label onclick="show_hide_radio(this,'hide','cfs-desc-title');" for="desc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2373 2373
 
2374 2374
                             </div>
@@ -2404,8 +2404,8 @@  discard block
 block discarded – undo
2404 2404
 
2405 2405
                                 <input type="radio" name="is_default"
2406 2406
                                        value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
2407
-                                    echo 'checked="checked"';
2408
-                                } ?>/>
2407
+									echo 'checked="checked"';
2408
+								} ?>/>
2409 2409
                             </div>
2410 2410
 
2411 2411
                         </li>
@@ -2447,8 +2447,8 @@  discard block
 block discarded – undo
2447 2447
 
2448 2448
                                 <input type="checkbox" name="is_default"
2449 2449
                                        value="<?php echo $field_type; ?>"  <?php if (isset($value) && $value == '1') {
2450
-                                    echo 'checked="checked"';
2451
-                                } ?>/>
2450
+									echo 'checked="checked"';
2451
+								} ?>/>
2452 2452
                             </div>
2453 2453
 
2454 2454
 
@@ -2471,14 +2471,14 @@  discard block
 block discarded – undo
2471 2471
 
2472 2472
                             <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled"  value="1"
2473 2473
                                 <?php if ($value == '1') {
2474
-                                    echo 'checked';
2475
-                                } ?>/>
2474
+									echo 'checked';
2475
+								} ?>/>
2476 2476
                             <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2477 2477
 
2478 2478
                             <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0"
2479 2479
                                 <?php if ($value == '0' || !$value) {
2480
-                                    echo 'checked';
2481
-                                } ?>/>
2480
+									echo 'checked';
2481
+								} ?>/>
2482 2482
                             <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2483 2483
 
2484 2484
                         </div>
@@ -2488,8 +2488,8 @@  discard block
 block discarded – undo
2488 2488
 
2489 2489
                     <input type="hidden" readonly="readonly" name="sort_order" id="sort_order"
2490 2490
                                                 value="<?php if (isset($field_info->sort_order)) {
2491
-                                                    echo esc_attr($field_info->sort_order);
2492
-                                                }?>" size="50"/>
2491
+													echo esc_attr($field_info->sort_order);
2492
+												}?>" size="50"/>
2493 2493
 
2494 2494
 
2495 2495
 
@@ -2513,38 +2513,38 @@  discard block
 block discarded – undo
2513 2513
             </form>
2514 2514
         </li> <?php
2515 2515
 
2516
-    }
2516
+	}
2517 2517
 }
2518 2518
 
2519 2519
 if (!function_exists('check_field_visibility')) {
2520
-    /**
2521
-     * Check field visibility as per price package.
2522
-     *
2523
-     * @since 1.0.0
2524
-     * @package GeoDirectory
2525
-     * @global object $wpdb WordPress Database object.
2526
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
2527
-     * @param int|string $package_id The package ID.
2528
-     * @param string $field_name The field name.
2529
-     * @param string $post_type Optional. The wordpress post type.
2530
-     * @return bool Returns true when field visible, otherwise false.
2531
-     */
2532
-    function check_field_visibility($package_id, $field_name, $post_type)
2533
-    {
2534
-        global $wpdb, $geodir_addon_list;
2535
-        if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
2536
-            return true;
2537
-        }
2538
-        if (!$package_id || !$field_name || !$post_type) {
2539
-            return true;
2540
-        }
2541
-        $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2542
-
2543
-        if ($wpdb->get_var($sql)) {
2544
-            return true;
2545
-        }
2546
-        return false;
2547
-    }
2520
+	/**
2521
+	 * Check field visibility as per price package.
2522
+	 *
2523
+	 * @since 1.0.0
2524
+	 * @package GeoDirectory
2525
+	 * @global object $wpdb WordPress Database object.
2526
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
2527
+	 * @param int|string $package_id The package ID.
2528
+	 * @param string $field_name The field name.
2529
+	 * @param string $post_type Optional. The wordpress post type.
2530
+	 * @return bool Returns true when field visible, otherwise false.
2531
+	 */
2532
+	function check_field_visibility($package_id, $field_name, $post_type)
2533
+	{
2534
+		global $wpdb, $geodir_addon_list;
2535
+		if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
2536
+			return true;
2537
+		}
2538
+		if (!$package_id || !$field_name || !$post_type) {
2539
+			return true;
2540
+		}
2541
+		$sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2542
+
2543
+		if ($wpdb->get_var($sql)) {
2544
+			return true;
2545
+		}
2546
+		return false;
2547
+	}
2548 2548
 }
2549 2549
 
2550 2550
 /**
@@ -2560,43 +2560,43 @@  discard block
 block discarded – undo
2560 2560
  */
2561 2561
 function geodir_string_to_options($input = '', $translated = false)
2562 2562
 {
2563
-    $return = array();
2564
-    if ($input != '') {
2565
-        $input = trim($input);
2566
-        $input = rtrim($input, ",");
2567
-        $input = ltrim($input, ",");
2568
-        $input = trim($input);
2569
-    }
2570
-
2571
-    $input_arr = explode(',', $input);
2572
-
2573
-    if (!empty($input_arr)) {
2574
-        foreach ($input_arr as $input_str) {
2575
-            $input_str = trim($input_str);
2576
-
2577
-            if (strpos($input_str, "/") !== false) {
2578
-                $input_str = explode("/", $input_str, 2);
2579
-                $label = trim($input_str[0]);
2580
-                if ($translated && $label != '') {
2581
-                    $label = __($label, 'geodirectory');
2582
-                }
2583
-                $label = geodir_utf8_ucfirst($label);
2584
-                $value = trim($input_str[1]);
2585
-            } else {
2586
-                $value = $input_str;
2587
-                if ($translated && $input_str != '') {
2588
-                    $input_str = __($input_str, 'geodirectory');
2589
-                }
2590
-                $label = geodir_utf8_ucfirst($input_str);
2591
-            }
2592
-
2593
-            if ($label != '') {
2594
-                $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
2595
-            }
2596
-        }
2597
-    }
2598
-
2599
-    return $return;
2563
+	$return = array();
2564
+	if ($input != '') {
2565
+		$input = trim($input);
2566
+		$input = rtrim($input, ",");
2567
+		$input = ltrim($input, ",");
2568
+		$input = trim($input);
2569
+	}
2570
+
2571
+	$input_arr = explode(',', $input);
2572
+
2573
+	if (!empty($input_arr)) {
2574
+		foreach ($input_arr as $input_str) {
2575
+			$input_str = trim($input_str);
2576
+
2577
+			if (strpos($input_str, "/") !== false) {
2578
+				$input_str = explode("/", $input_str, 2);
2579
+				$label = trim($input_str[0]);
2580
+				if ($translated && $label != '') {
2581
+					$label = __($label, 'geodirectory');
2582
+				}
2583
+				$label = geodir_utf8_ucfirst($label);
2584
+				$value = trim($input_str[1]);
2585
+			} else {
2586
+				$value = $input_str;
2587
+				if ($translated && $input_str != '') {
2588
+					$input_str = __($input_str, 'geodirectory');
2589
+				}
2590
+				$label = geodir_utf8_ucfirst($input_str);
2591
+			}
2592
+
2593
+			if ($label != '') {
2594
+				$return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
2595
+			}
2596
+		}
2597
+	}
2598
+
2599
+	return $return;
2600 2600
 }
2601 2601
 
2602 2602
 /**
@@ -2611,66 +2611,66 @@  discard block
 block discarded – undo
2611 2611
  */
2612 2612
 function geodir_string_values_to_options($option_values = '', $translated = false)
2613 2613
 {
2614
-    $options = array();
2615
-    if ($option_values == '') {
2616
-        return NULL;
2617
-    }
2618
-
2619
-    if (strpos($option_values, "{/optgroup}") !== false) {
2620
-        $option_values_arr = explode("{/optgroup}", $option_values);
2621
-
2622
-        foreach ($option_values_arr as $optgroup) {
2623
-            if (strpos($optgroup, "{optgroup}") !== false) {
2624
-                $optgroup_arr = explode("{optgroup}", $optgroup);
2625
-
2626
-                $count = 0;
2627
-                foreach ($optgroup_arr as $optgroup_str) {
2628
-                    $count++;
2629
-                    $optgroup_str = trim($optgroup_str);
2630
-
2631
-                    $optgroup_label = '';
2632
-                    if (strpos($optgroup_str, "|") !== false) {
2633
-                        $optgroup_str_arr = explode("|", $optgroup_str, 2);
2634
-                        $optgroup_label = trim($optgroup_str_arr[0]);
2635
-                        if ($translated && $optgroup_label != '') {
2636
-                            $optgroup_label = __($optgroup_label, 'geodirectory');
2637
-                        }
2638
-                        $optgroup_label = geodir_utf8_ucfirst($optgroup_label);
2639
-                        $optgroup_str = $optgroup_str_arr[1];
2640
-                    }
2641
-
2642
-                    $optgroup3 = geodir_string_to_options($optgroup_str, $translated);
2643
-
2644
-                    if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
2645
-                        $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
2646
-                        $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
2647
-                        $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
2648
-                    }
2649
-                    $options = array_merge($options, $optgroup3);
2650
-                }
2651
-            } else {
2652
-                $optgroup1 = geodir_string_to_options($optgroup, $translated);
2653
-                $options = array_merge($options, $optgroup1);
2654
-            }
2655
-        }
2656
-    } else {
2657
-        $options = geodir_string_to_options($option_values, $translated);
2658
-    }
2659
-
2660
-    return $options;
2614
+	$options = array();
2615
+	if ($option_values == '') {
2616
+		return NULL;
2617
+	}
2618
+
2619
+	if (strpos($option_values, "{/optgroup}") !== false) {
2620
+		$option_values_arr = explode("{/optgroup}", $option_values);
2621
+
2622
+		foreach ($option_values_arr as $optgroup) {
2623
+			if (strpos($optgroup, "{optgroup}") !== false) {
2624
+				$optgroup_arr = explode("{optgroup}", $optgroup);
2625
+
2626
+				$count = 0;
2627
+				foreach ($optgroup_arr as $optgroup_str) {
2628
+					$count++;
2629
+					$optgroup_str = trim($optgroup_str);
2630
+
2631
+					$optgroup_label = '';
2632
+					if (strpos($optgroup_str, "|") !== false) {
2633
+						$optgroup_str_arr = explode("|", $optgroup_str, 2);
2634
+						$optgroup_label = trim($optgroup_str_arr[0]);
2635
+						if ($translated && $optgroup_label != '') {
2636
+							$optgroup_label = __($optgroup_label, 'geodirectory');
2637
+						}
2638
+						$optgroup_label = geodir_utf8_ucfirst($optgroup_label);
2639
+						$optgroup_str = $optgroup_str_arr[1];
2640
+					}
2641
+
2642
+					$optgroup3 = geodir_string_to_options($optgroup_str, $translated);
2643
+
2644
+					if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
2645
+						$optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
2646
+						$optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
2647
+						$optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
2648
+					}
2649
+					$options = array_merge($options, $optgroup3);
2650
+				}
2651
+			} else {
2652
+				$optgroup1 = geodir_string_to_options($optgroup, $translated);
2653
+				$options = array_merge($options, $optgroup1);
2654
+			}
2655
+		}
2656
+	} else {
2657
+		$options = geodir_string_to_options($option_values, $translated);
2658
+	}
2659
+
2660
+	return $options;
2661 2661
 }
2662 2662
 
2663 2663
 
2664 2664
 function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){
2665
-    ob_start();
2666
-
2667
-    $dt_value = '';
2668
-    if (isset($field_info->data_type)) {
2669
-        $dt_value  = esc_attr($field_info->data_type);
2670
-    }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2671
-        $dt_value  = $cf['defaults']['data_type'];
2672
-    }
2673
-    ?>
2665
+	ob_start();
2666
+
2667
+	$dt_value = '';
2668
+	if (isset($field_info->data_type)) {
2669
+		$dt_value  = esc_attr($field_info->data_type);
2670
+	}elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2671
+		$dt_value  = $cf['defaults']['data_type'];
2672
+	}
2673
+	?>
2674 2674
     <li>
2675 2675
         <label for="data_type"><?php _e('Field Data Type ? :', 'geodirectory'); ?></label>
2676 2676
         <div class="gd-cf-input-wrap">
@@ -2679,16 +2679,16 @@  discard block
 block discarded – undo
2679 2679
                     onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');">
2680 2680
                 <option
2681 2681
                     value="XVARCHAR" <?php if ($dt_value  == 'VARCHAR') {
2682
-                    echo 'selected="selected"';
2683
-                } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2682
+					echo 'selected="selected"';
2683
+				} ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2684 2684
                 <option
2685 2685
                     value="INT" <?php if ($dt_value   == 'INT') {
2686
-                    echo 'selected="selected"';
2687
-                } ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2686
+					echo 'selected="selected"';
2687
+				} ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2688 2688
                 <option
2689 2689
                     value="FLOAT" <?php if ($dt_value   == 'FLOAT') {
2690
-                    echo 'selected="selected"';
2691
-                } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2690
+					echo 'selected="selected"';
2691
+				} ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2692 2692
             </select>
2693 2693
             <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span>
2694 2694
 
@@ -2696,13 +2696,13 @@  discard block
 block discarded – undo
2696 2696
     </li>
2697 2697
 
2698 2698
     <?php
2699
-    $value = '';
2700
-    if (isset($field_info->decimal_point)) {
2701
-        $value = esc_attr($field_info->decimal_point);
2702
-    }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2703
-        $value = $cf['defaults']['decimal_point'];
2704
-    }
2705
-    ?>
2699
+	$value = '';
2700
+	if (isset($field_info->decimal_point)) {
2701
+		$value = esc_attr($field_info->decimal_point);
2702
+	}elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2703
+		$value = $cf['defaults']['decimal_point'];
2704
+	}
2705
+	?>
2706 2706
 
2707 2707
     <li class="decimal-point-wrapper"
2708 2708
         style="<?php echo ($dt_value  == 'FLOAT') ? '' : 'display:none' ?>">
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
             <select name="decimal_point" id="decimal_point">
2712 2712
                 <option value=""><?php echo _e('Select', 'geodirectory'); ?></option>
2713 2713
                 <?php for ($i = 1; $i <= 10; $i++) {
2714
-                    $selected = $i == $value ? 'selected="selected"' : ''; ?>
2714
+					$selected = $i == $value ? 'selected="selected"' : ''; ?>
2715 2715
                     <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
2716 2716
                 <?php } ?>
2717 2717
             </select>
@@ -2720,8 +2720,8 @@  discard block
 block discarded – undo
2720 2720
     </li>
2721 2721
 <?php
2722 2722
 
2723
-    $output = ob_get_clean();
2724
-    return $output;
2723
+	$output = ob_get_clean();
2724
+	return $output;
2725 2725
 }
2726 2726
 add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4);
2727 2727
 
@@ -2757,9 +2757,9 @@  discard block
 block discarded – undo
2757 2757
 
2758 2758
 
2759 2759
 function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){
2760
-    if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2761
-    ob_start();
2762
-    ?>
2760
+	if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2761
+	ob_start();
2762
+	?>
2763 2763
     <li>
2764 2764
         <label for="advanced_editor" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show advanced editor :', 'geodirectory'); ?>
2765 2765
             <div class="gdcf-tooltip">
@@ -2770,13 +2770,13 @@  discard block
 block discarded – undo
2770 2770
         <div class="gd-cf-input-wrap">
2771 2771
 
2772 2772
             <?php
2773
-            $selected = '';
2774
-            if (isset($field_info->extra_fields))
2775
-                $advanced_editor = unserialize($field_info->extra_fields);
2773
+			$selected = '';
2774
+			if (isset($field_info->extra_fields))
2775
+				$advanced_editor = unserialize($field_info->extra_fields);
2776 2776
 
2777
-            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2778
-                $selected = 'checked="checked"';
2779
-            ?>
2777
+			if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2778
+				$selected = 'checked="checked"';
2779
+			?>
2780 2780
 
2781 2781
             <input type="checkbox" name="advanced_editor[]" id="advanced_editor"
2782 2782
                    value="1" <?php echo $selected; ?>/>
@@ -2785,22 +2785,22 @@  discard block
 block discarded – undo
2785 2785
     </li>
2786 2786
     <?php
2787 2787
 
2788
-    $output = ob_get_clean();
2789
-    return $output;
2788
+	$output = ob_get_clean();
2789
+	return $output;
2790 2790
 }
2791 2791
 add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4);
2792 2792
 
2793 2793
 
2794 2794
 function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){
2795
-    ob_start();
2796
-
2797
-    $value = '';
2798
-    if (isset($field_info->validation_pattern)) {
2799
-        $value = esc_attr($field_info->validation_pattern);
2800
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2801
-        $value = esc_attr($cf['defaults']['validation_pattern']);
2802
-    }
2803
-    ?>
2795
+	ob_start();
2796
+
2797
+	$value = '';
2798
+	if (isset($field_info->validation_pattern)) {
2799
+		$value = esc_attr($field_info->validation_pattern);
2800
+	}elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2801
+		$value = esc_attr($cf['defaults']['validation_pattern']);
2802
+	}
2803
+	?>
2804 2804
     <li>
2805 2805
         <label for="validation_pattern" class="gd-cf-tooltip-wrap">
2806 2806
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?>
@@ -2814,13 +2814,13 @@  discard block
 block discarded – undo
2814 2814
         </div>
2815 2815
     </li>
2816 2816
     <?php
2817
-    $value = '';
2818
-    if (isset($field_info->validation_msg)) {
2819
-        $value = esc_attr($field_info->validation_msg);
2820
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2821
-        $value = esc_attr($cf['defaults']['validation_msg']);
2822
-    }
2823
-    ?>
2817
+	$value = '';
2818
+	if (isset($field_info->validation_msg)) {
2819
+		$value = esc_attr($field_info->validation_msg);
2820
+	}elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2821
+		$value = esc_attr($cf['defaults']['validation_msg']);
2822
+	}
2823
+	?>
2824 2824
     <li>
2825 2825
         <label for="validation_msg" class="gd-cf-tooltip-wrap">
2826 2826
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?>
@@ -2835,21 +2835,21 @@  discard block
 block discarded – undo
2835 2835
     </li>
2836 2836
     <?php
2837 2837
 
2838
-    $output = ob_get_clean();
2839
-    return $output;
2838
+	$output = ob_get_clean();
2839
+	return $output;
2840 2840
 }
2841 2841
 add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4);
2842 2842
 
2843 2843
 
2844 2844
 function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){
2845
-    ob_start();
2846
-    global $post_type;
2847
-
2848
-    if (!isset($field_info->post_type)) {
2849
-        $post_type = sanitize_text_field($_REQUEST['listing_type']);
2850
-    } else
2851
-        $post_type = $field_info->post_type;
2852
-    ?>
2845
+	ob_start();
2846
+	global $post_type;
2847
+
2848
+	if (!isset($field_info->post_type)) {
2849
+		$post_type = sanitize_text_field($_REQUEST['listing_type']);
2850
+	} else
2851
+		$post_type = $field_info->post_type;
2852
+	?>
2853 2853
     <li style="display: none;">
2854 2854
         <label for="htmlvar_name" class="gd-cf-tooltip-wrap">
2855 2855
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?>
@@ -2860,15 +2860,15 @@  discard block
 block discarded – undo
2860 2860
         <div class="gd-cf-input-wrap">
2861 2861
             <select name="htmlvar_name" id="htmlvar_name">
2862 2862
                 <?php
2863
-                $gd_taxonomy = geodir_get_taxonomies($post_type);
2863
+				$gd_taxonomy = geodir_get_taxonomies($post_type);
2864 2864
 
2865
-                foreach ($gd_taxonomy as $gd_tax) {
2866
-                    ?>
2865
+				foreach ($gd_taxonomy as $gd_tax) {
2866
+					?>
2867 2867
                     <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) {
2868
-                        echo 'selected="selected"';
2869
-                    }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2870
-                }
2871
-                ?>
2868
+						echo 'selected="selected"';
2869
+					}?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2870
+				}
2871
+				?>
2872 2872
             </select>
2873 2873
         </div>
2874 2874
     </li>
@@ -2884,49 +2884,49 @@  discard block
 block discarded – undo
2884 2884
 
2885 2885
             <select name="cat_display_type" id="cat_display_type">
2886 2886
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') {
2887
-                    echo 'selected="selected"';
2888
-                }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2887
+					echo 'selected="selected"';
2888
+				}?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2889 2889
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
2890
-                    echo 'selected="selected"';
2891
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
2890
+					echo 'selected="selected"';
2891
+				}?> value="select"><?php _e('Select', 'geodirectory');?></option>
2892 2892
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') {
2893
-                    echo 'selected="selected"';
2894
-                }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2893
+					echo 'selected="selected"';
2894
+				}?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2895 2895
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
2896
-                    echo 'selected="selected"';
2897
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2896
+					echo 'selected="selected"';
2897
+				}?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2898 2898
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
2899
-                    echo 'selected="selected"';
2900
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2899
+					echo 'selected="selected"';
2900
+				}?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2901 2901
             </select>
2902 2902
         </div>
2903 2903
     </li>
2904 2904
     <?php
2905 2905
 
2906
-    $output = ob_get_clean();
2907
-    return $output;
2906
+	$output = ob_get_clean();
2907
+	return $output;
2908 2908
 }
2909 2909
 add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4);
2910 2910
 
2911 2911
 
2912 2912
 function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){
2913 2913
 
2914
-    ob_start();
2915
-    if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2916
-        $address = stripslashes_deep(unserialize($field_info->extra_fields));
2917
-    }
2914
+	ob_start();
2915
+	if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2916
+		$address = stripslashes_deep(unserialize($field_info->extra_fields));
2917
+	}
2918 2918
 
2919
-    $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
2920
-    ?>
2919
+	$radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
2920
+	?>
2921 2921
     <?php
2922
-    /**
2923
-     * Called on the add custom fields settings page before the address field is output.
2924
-     *
2925
-     * @since 1.0.0
2926
-     * @param array $address The address settings array.
2927
-     * @param object $field_info Extra fields info.
2928
-     */
2929
-    do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
2922
+	/**
2923
+	 * Called on the add custom fields settings page before the address field is output.
2924
+	 *
2925
+	 * @since 1.0.0
2926
+	 * @param array $address The address settings array.
2927
+	 * @param object $field_info Extra fields info.
2928
+	 */
2929
+	do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
2930 2930
 
2931 2931
     <li>
2932 2932
         <label for="show_zip" class="gd-cf-tooltip-wrap">
@@ -2939,14 +2939,14 @@  discard block
 block discarded – undo
2939 2939
 
2940 2940
             <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled"  value="1"
2941 2941
                 <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') {
2942
-                    echo 'checked';
2943
-                } ?>/>
2942
+					echo 'checked';
2943
+				} ?>/>
2944 2944
             <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2945 2945
 
2946 2946
             <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0"
2947 2947
                 <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {
2948
-                    echo 'checked';
2949
-                } ?>/>
2948
+					echo 'checked';
2949
+				} ?>/>
2950 2950
             <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2951 2951
 
2952 2952
 
@@ -2963,8 +2963,8 @@  discard block
 block discarded – undo
2963 2963
         <div class="gd-cf-input-wrap">
2964 2964
             <input type="text" name="extra[zip_lable]" id="zip_lable"
2965 2965
                    value="<?php if (isset($address['zip_lable'])) {
2966
-                       echo esc_attr($address['zip_lable']);
2967
-                   }?>"/>
2966
+					   echo esc_attr($address['zip_lable']);
2967
+				   }?>"/>
2968 2968
         </div>
2969 2969
     </li>
2970 2970
 
@@ -2981,8 +2981,8 @@  discard block
 block discarded – undo
2981 2981
         <div class="gd-cf-input-wrap">
2982 2982
             <input type="text" name="extra[map_lable]" id="map_lable"
2983 2983
                    value="<?php if (isset($address['map_lable'])) {
2984
-                       echo esc_attr($address['map_lable']);
2985
-                   }?>"/>
2984
+					   echo esc_attr($address['map_lable']);
2985
+				   }?>"/>
2986 2986
         </div>
2987 2987
     </li>
2988 2988
 
@@ -2997,14 +2997,14 @@  discard block
 block discarded – undo
2997 2997
 
2998 2998
             <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled"  value="1"
2999 2999
                 <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') {
3000
-                    echo 'checked';
3001
-                } ?>/>
3000
+					echo 'checked';
3001
+				} ?>/>
3002 3002
             <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3003 3003
 
3004 3004
             <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0"
3005 3005
                 <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) {
3006
-                    echo 'checked';
3007
-                } ?>/>
3006
+					echo 'checked';
3007
+				} ?>/>
3008 3008
             <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3009 3009
 
3010 3010
         </div>
@@ -3021,14 +3021,14 @@  discard block
 block discarded – undo
3021 3021
 
3022 3022
             <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled"  value="1"
3023 3023
                 <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') {
3024
-                    echo 'checked';
3025
-                } ?>/>
3024
+					echo 'checked';
3025
+				} ?>/>
3026 3026
             <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3027 3027
 
3028 3028
             <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0"
3029 3029
                 <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) {
3030
-                    echo 'checked';
3031
-                } ?>/>
3030
+					echo 'checked';
3031
+				} ?>/>
3032 3032
             <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3033 3033
 
3034 3034
         </div>
@@ -3045,8 +3045,8 @@  discard block
 block discarded – undo
3045 3045
         <div class="gd-cf-input-wrap">
3046 3046
             <input type="text" name="extra[mapview_lable]" id="mapview_lable"
3047 3047
                    value="<?php if (isset($address['mapview_lable'])) {
3048
-                       echo esc_attr($address['mapview_lable']);
3049
-                   }?>"/>
3048
+					   echo esc_attr($address['mapview_lable']);
3049
+				   }?>"/>
3050 3050
         </div>
3051 3051
     </li>
3052 3052
     <li>
@@ -3060,29 +3060,29 @@  discard block
 block discarded – undo
3060 3060
 
3061 3061
             <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled"  value="1"
3062 3062
                 <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') {
3063
-                    echo 'checked';
3064
-                } ?>/>
3063
+					echo 'checked';
3064
+				} ?>/>
3065 3065
             <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3066 3066
 
3067 3067
             <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0"
3068 3068
                 <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) {
3069
-                    echo 'checked';
3070
-                } ?>/>
3069
+					echo 'checked';
3070
+				} ?>/>
3071 3071
             <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3072 3072
 
3073 3073
         </div>
3074 3074
     </li>
3075 3075
     <?php
3076 3076
 
3077
-    $html = ob_get_clean();
3078
-    return $output.$html;
3077
+	$html = ob_get_clean();
3078
+	return $output.$html;
3079 3079
 }
3080 3080
 add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4);
3081 3081
 
3082 3082
 
3083 3083
 function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){
3084
-    ob_start();
3085
-    ?>
3084
+	ob_start();
3085
+	?>
3086 3086
     <li>
3087 3087
         <label for="multi_display_type" class="gd-cf-tooltip-wrap">
3088 3088
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?>
@@ -3094,14 +3094,14 @@  discard block
 block discarded – undo
3094 3094
 
3095 3095
             <select name="multi_display_type" id="multi_display_type">
3096 3096
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
3097
-                    echo 'selected="selected"';
3098
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
3097
+					echo 'selected="selected"';
3098
+				}?> value="select"><?php _e('Select', 'geodirectory');?></option>
3099 3099
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
3100
-                    echo 'selected="selected"';
3101
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
3100
+					echo 'selected="selected"';
3101
+				}?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
3102 3102
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
3103
-                    echo 'selected="selected"';
3104
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
3103
+					echo 'selected="selected"';
3104
+				}?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
3105 3105
             </select>
3106 3106
 
3107 3107
             <br/>
@@ -3109,25 +3109,25 @@  discard block
 block discarded – undo
3109 3109
     </li>
3110 3110
     <?php
3111 3111
 
3112
-    $html = ob_get_clean();
3113
-    return $output.$html;
3112
+	$html = ob_get_clean();
3113
+	return $output.$html;
3114 3114
 }
3115 3115
 add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4);
3116 3116
 
3117 3117
 
3118 3118
 function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){
3119 3119
 
3120
-    ob_start();
3120
+	ob_start();
3121 3121
 
3122
-    $value = '';
3123
-    if (isset($field_info->option_values)) {
3124
-        $value = esc_attr($field_info->option_values);
3125
-    }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3126
-        $value = esc_attr($cf['defaults']['option_values']);
3127
-    }
3122
+	$value = '';
3123
+	if (isset($field_info->option_values)) {
3124
+		$value = esc_attr($field_info->option_values);
3125
+	}elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3126
+		$value = esc_attr($cf['defaults']['option_values']);
3127
+	}
3128 3128
 
3129
-    $field_type = isset($field_info->field_type) ? $field_info->field_type : '';
3130
-    ?>
3129
+	$field_type = isset($field_info->field_type) ? $field_info->field_type : '';
3130
+	?>
3131 3131
     <li>
3132 3132
         <label for="option_values" class="gd-cf-tooltip-wrap">
3133 3133
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?>
@@ -3154,8 +3154,8 @@  discard block
 block discarded – undo
3154 3154
     </li>
3155 3155
     <?php
3156 3156
 
3157
-    $html = ob_get_clean();
3158
-    return $output.$html;
3157
+	$html = ob_get_clean();
3158
+	return $output.$html;
3159 3159
 }
3160 3160
 add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4);
3161 3161
 add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4);
@@ -3163,12 +3163,12 @@  discard block
 block discarded – undo
3163 3163
 
3164 3164
 
3165 3165
 function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){
3166
-    ob_start();
3167
-    $extra = array();
3168
-    if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
3169
-        $extra = unserialize($field_info->extra_fields);
3170
-    }
3171
-    ?>
3166
+	ob_start();
3167
+	$extra = array();
3168
+	if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
3169
+		$extra = unserialize($field_info->extra_fields);
3170
+	}
3171
+	?>
3172 3172
     <li>
3173 3173
         <label for="date_format" class="gd-cf-tooltip-wrap">
3174 3174
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?>
@@ -3178,52 +3178,52 @@  discard block
 block discarded – undo
3178 3178
         </label>
3179 3179
         <div class="gd-cf-input-wrap" style="overflow:inherit;">
3180 3180
             <?php
3181
-            $date_formats = array(
3182
-                'm/d/Y',
3183
-                'd/m/Y',
3184
-                'Y/m/d',
3185
-                'm-d-Y',
3186
-                'd-m-Y',
3187
-                'Y-m-d',
3188
-                'F j, Y',
3189
-            );
3190
-            /**
3191
-             * Filter the custom field date format options.
3192
-             *
3193
-             * @since 1.6.5
3194
-             * @param array $date_formats The PHP date format array.
3195
-             */
3196
-            $date_formats = apply_filters('geodir_date_formats',$date_formats);
3197
-            ?>
3181
+			$date_formats = array(
3182
+				'm/d/Y',
3183
+				'd/m/Y',
3184
+				'Y/m/d',
3185
+				'm-d-Y',
3186
+				'd-m-Y',
3187
+				'Y-m-d',
3188
+				'F j, Y',
3189
+			);
3190
+			/**
3191
+			 * Filter the custom field date format options.
3192
+			 *
3193
+			 * @since 1.6.5
3194
+			 * @param array $date_formats The PHP date format array.
3195
+			 */
3196
+			$date_formats = apply_filters('geodir_date_formats',$date_formats);
3197
+			?>
3198 3198
             <select name="extra[date_format]" id="date_format">
3199 3199
                 <?php
3200
-                foreach($date_formats as $format){
3201
-                    $selected = '';
3202
-                    if(!empty($extra) && esc_attr($extra['date_format'])==$format){
3203
-                        $selected = "selected='selected'";
3204
-                    }
3205
-                    echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3206
-                }
3207
-                ?>
3200
+				foreach($date_formats as $format){
3201
+					$selected = '';
3202
+					if(!empty($extra) && esc_attr($extra['date_format'])==$format){
3203
+						$selected = "selected='selected'";
3204
+					}
3205
+					echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3206
+				}
3207
+				?>
3208 3208
             </select>
3209 3209
 
3210 3210
         </div>
3211 3211
     </li>
3212 3212
     <?php
3213 3213
 
3214
-    $html = ob_get_clean();
3215
-    return $output.$html;
3214
+	$html = ob_get_clean();
3215
+	return $output.$html;
3216 3216
 }
3217 3217
 add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4);
3218 3218
 
3219 3219
 
3220 3220
 function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){
3221
-    ob_start();
3222
-    $allowed_file_types = geodir_allowed_mime_types();
3221
+	ob_start();
3222
+	$allowed_file_types = geodir_allowed_mime_types();
3223 3223
 
3224
-    $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3225
-    $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
3226
-    ?>
3224
+	$extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3225
+	$gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
3226
+	?>
3227 3227
     <li>
3228 3228
         <label for="gd_file_types" class="gd-cf-tooltip-wrap">
3229 3229
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?>
@@ -3246,33 +3246,33 @@  discard block
 block discarded – undo
3246 3246
     </li>
3247 3247
     <?php
3248 3248
 
3249
-    $html = ob_get_clean();
3250
-    return $output.$html;
3249
+	$html = ob_get_clean();
3250
+	return $output.$html;
3251 3251
 }
3252 3252
 add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4);
3253 3253
 
3254 3254
 function geodir_cfa_extra_fields_text($output,$result_str,$cf,$field_info){
3255
-    ob_start();
3255
+	ob_start();
3256 3256
 
3257
-    $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3257
+	$extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3258 3258
    // print_r($cf);echo '###';
3259 3259
 
3260 3260
 
3261 3261
 
3262
-    $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
3262
+	$radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
3263 3263
 
3264 3264
 
3265
-    $value = '';
3266
-    if ($extra_fields && isset($extra_fields['is_price'])) {
3267
-    $value = esc_attr($extra_fields['is_price']);
3268
-    }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3269
-    $value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3270
-    }
3265
+	$value = '';
3266
+	if ($extra_fields && isset($extra_fields['is_price'])) {
3267
+	$value = esc_attr($extra_fields['is_price']);
3268
+	}elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3269
+	$value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3270
+	}
3271 3271
 
3272
-    $show_price_extra = ($value==1) ? 1 : 0;
3272
+	$show_price_extra = ($value==1) ? 1 : 0;
3273 3273
 
3274
-    $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0;
3275
-    ?>
3274
+	$show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0;
3275
+	?>
3276 3276
     <li class="gdcf-price-extra-set" <?php if(!$show_price){ echo "style='display:none;'";}?>>
3277 3277
         <label for="is_price" class="gd-cf-tooltip-wrap">
3278 3278
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display as price? :', 'geodirectory'); ?>
@@ -3284,14 +3284,14 @@  discard block
 block discarded – undo
3284 3284
 
3285 3285
             <input type="radio" id="is_price_yes<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-enabled"  value="1"
3286 3286
                 <?php if ($value == '1') {
3287
-                    echo 'checked';
3288
-                } ?>/>
3287
+					echo 'checked';
3288
+				} ?>/>
3289 3289
             <label onclick="show_hide_radio(this,'show','gdcf-price-extra');" for="is_price_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3290 3290
 
3291 3291
             <input type="radio" id="is_price_no<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-disabled" value="0"
3292 3292
                 <?php if ($value == '0' || !$value) {
3293
-                    echo 'checked';
3294
-                } ?>/>
3293
+					echo 'checked';
3294
+				} ?>/>
3295 3295
             <label onclick="show_hide_radio(this,'hide','gdcf-price-extra');" for="is_price_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3296 3296
 
3297 3297
         </div>
@@ -3299,13 +3299,13 @@  discard block
 block discarded – undo
3299 3299
 
3300 3300
     <?php
3301 3301
 
3302
-    $value = '';
3303
-    if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3304
-        $value = esc_attr($extra_fields['thousand_separator']);
3305
-    }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3306
-        $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3307
-    }
3308
-    ?>
3302
+	$value = '';
3303
+	if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3304
+		$value = esc_attr($extra_fields['thousand_separator']);
3305
+	}elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3306
+		$value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3307
+	}
3308
+	?>
3309 3309
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3310 3310
         <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory');?>
3311 3311
             <div class="gdcf-tooltip">
@@ -3326,13 +3326,13 @@  discard block
 block discarded – undo
3326 3326
 
3327 3327
     <?php
3328 3328
 
3329
-    $value = '';
3330
-    if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3331
-        $value = esc_attr($extra_fields['decimal_separator']);
3332
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3333
-        $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3334
-    }
3335
-    ?>
3329
+	$value = '';
3330
+	if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3331
+		$value = esc_attr($extra_fields['decimal_separator']);
3332
+	}elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3333
+		$value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3334
+	}
3335
+	?>
3336 3336
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3337 3337
         <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory');?>
3338 3338
             <div class="gdcf-tooltip">
@@ -3349,13 +3349,13 @@  discard block
 block discarded – undo
3349 3349
 
3350 3350
     <?php
3351 3351
 
3352
-    $value = '';
3353
-    if ($extra_fields && isset($extra_fields['decimal_display'])) {
3354
-        $value = esc_attr($extra_fields['decimal_display']);
3355
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3356
-        $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3357
-    }
3358
-    ?>
3352
+	$value = '';
3353
+	if ($extra_fields && isset($extra_fields['decimal_display'])) {
3354
+		$value = esc_attr($extra_fields['decimal_display']);
3355
+	}elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3356
+		$value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3357
+	}
3358
+	?>
3359 3359
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3360 3360
         <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory');?>
3361 3361
             <div class="gdcf-tooltip">
@@ -3372,13 +3372,13 @@  discard block
 block discarded – undo
3372 3372
 
3373 3373
     <?php
3374 3374
 
3375
-    $value = '';
3376
-    if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3377
-        $value = esc_attr($extra_fields['currency_symbol']);
3378
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3379
-        $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3380
-    }
3381
-    ?>
3375
+	$value = '';
3376
+	if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3377
+		$value = esc_attr($extra_fields['currency_symbol']);
3378
+	}elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3379
+		$value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3380
+	}
3381
+	?>
3382 3382
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3383 3383
         <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory');?>
3384 3384
             <div class="gdcf-tooltip">
@@ -3393,13 +3393,13 @@  discard block
 block discarded – undo
3393 3393
 
3394 3394
     <?php
3395 3395
 
3396
-    $value = '';
3397
-    if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3398
-        $value = esc_attr($extra_fields['currency_symbol_placement']);
3399
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3400
-        $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3401
-    }
3402
-    ?>
3396
+	$value = '';
3397
+	if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3398
+		$value = esc_attr($extra_fields['currency_symbol_placement']);
3399
+	}elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3400
+		$value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3401
+	}
3402
+	?>
3403 3403
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3404 3404
         <label for="currency_symbol_placement" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol placement :', 'geodirectory');?>
3405 3405
             <div class="gdcf-tooltip">
@@ -3417,225 +3417,225 @@  discard block
 block discarded – undo
3417 3417
 
3418 3418
     <?php
3419 3419
 
3420
-    $html = ob_get_clean();
3421
-    return $output.$html;
3420
+	$html = ob_get_clean();
3421
+	return $output.$html;
3422 3422
 }
3423 3423
 add_filter('geodir_cfa_extra_fields_text','geodir_cfa_extra_fields_text',10,4);
3424 3424
 
3425 3425
 function geodir_default_custom_fields($post_type='gd_place',$package_id=''){
3426
-    $fields = array();
3427
-    $package = ($package_id=='') ? '' : array($package_id);
3428
-
3429
-    $fields[] = array('listing_type' => $post_type,
3430
-                      'data_type' => 'VARCHAR',
3431
-                      'field_type' => 'taxonomy',
3432
-                      'admin_title' => __('Category', 'geodirectory'),
3433
-                      'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'),
3434
-                      'site_title' => __('Category', 'geodirectory'),
3435
-                      'htmlvar_name' => $post_type.'category',
3436
-                      'default_value' => '',
3437
-                      'is_default' => '1',
3438
-                      'is_admin' => '1',
3439
-                      'is_required' => '1',
3440
-                      'show_in'   =>  '[detail]',
3441
-                      'show_on_pkg' => $package,
3442
-                      'clabels' => __('Category', 'geodirectory'));
3443
-
3444
-    $fields[] = array('listing_type' => $post_type,
3445
-                      'data_type' => 'VARCHAR',
3446
-                      'field_type' => 'address',
3447
-                      'admin_title' => __('Address', 'geodirectory'),
3448
-                      'admin_desc' => ADDRESS_MSG,
3449
-                      'site_title' => __('Address', 'geodirectory'),
3450
-                      'htmlvar_name' => 'post',
3451
-                      'default_value' => '',
3452
-                      'option_values' => '',
3453
-                      'is_default' => '1',
3454
-                      'is_admin' => '1',
3455
-                      'is_required' => '1',
3456
-                      'show_in'   =>  '[detail],[mapbubble]',
3457
-                      'show_on_pkg' => $package,
3458
-                      'required_msg' => __('Address fields are required', 'geodirectory'),
3459
-                      'clabels' => __('Address', 'geodirectory'),
3460
-                      'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'),
3461
-                                       'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'),
3462
-                                       'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'),
3463
-                                       'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'),
3464
-                                       'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'),
3465
-                                       'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'),
3466
-                                       'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden',
3467
-                                       'show_latlng' => 1));
3468
-
3469
-    $fields[] = array('listing_type' => $post_type,
3470
-                      'data_type' => 'VARCHAR',
3471
-                      'field_type' => 'text',
3472
-                      'admin_title' => __('Time', 'geodirectory'),
3473
-                      'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'),
3474
-                      'site_title' => __('Time', 'geodirectory'),
3475
-                      'htmlvar_name' => 'timing',
3476
-                      'default_value' => '',
3477
-                      'option_values' => '',
3478
-                      'is_default' => '1',
3479
-                      'is_admin' => '1',
3480
-                      'show_in' =>  '[detail],[mapbubble]',
3481
-                      'show_on_pkg' => $package,
3482
-                      'clabels' => __('Time', 'geodirectory'));
3483
-
3484
-    $fields[] = array('listing_type' => $post_type,
3485
-                      'data_type' => 'VARCHAR',
3486
-                      'field_type' => 'phone',
3487
-                      'admin_title' => __('Phone', 'geodirectory'),
3488
-                      'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'),
3489
-                      'site_title' => __('Phone', 'geodirectory'),
3490
-                      'htmlvar_name' => 'contact',
3491
-                      'default_value' => '',
3492
-                      'option_values' => '',
3493
-                      'is_default' => '1',
3494
-                      'is_admin' => '1',
3495
-                      'show_in' =>  '[detail],[mapbubble]',
3496
-                      'show_on_pkg' => $package,
3497
-                      'clabels' => __('Phone', 'geodirectory'));
3498
-
3499
-    $fields[] = array('listing_type' => $post_type,
3500
-                      'data_type' => 'VARCHAR',
3501
-                      'field_type' => 'email',
3502
-                      'admin_title' => __('Email', 'geodirectory'),
3503
-                      'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'),
3504
-                      'site_title' => __('Email', 'geodirectory'),
3505
-                      'htmlvar_name' => 'email',
3506
-                      'default_value' => '',
3507
-                      'option_values' => '',
3508
-                      'is_default' => '1',
3509
-                      'is_admin' => '1',
3510
-                      'show_in' => '[detail]',
3511
-                      'show_on_pkg' => $package,
3512
-                      'clabels' => __('Email', 'geodirectory'));
3513
-
3514
-    $fields[] = array('listing_type' => $post_type,
3515
-                      'data_type' => 'VARCHAR',
3516
-                      'field_type' => 'url',
3517
-                      'admin_title' => __('Website', 'geodirectory'),
3518
-                      'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'),
3519
-                      'site_title' => __('Website', 'geodirectory'),
3520
-                      'htmlvar_name' => 'website',
3521
-                      'default_value' => '',
3522
-                      'option_values' => '',
3523
-                      'is_default' => '1',
3524
-                      'is_admin' => '1',
3525
-                      'show_in' => '[detail]',
3526
-                      'show_on_pkg' => $package,
3527
-                      'clabels' => __('Website', 'geodirectory'));
3528
-
3529
-    $fields[] = array('listing_type' => $post_type,
3530
-                      'data_type' => 'VARCHAR',
3531
-                      'field_type' => 'url',
3532
-                      'admin_title' => __('Twitter', 'geodirectory'),
3533
-                      'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'),
3534
-                      'site_title' => __('Twitter', 'geodirectory'),
3535
-                      'htmlvar_name' => 'twitter',
3536
-                      'default_value' => '',
3537
-                      'option_values' => '',
3538
-                      'is_default' => '1',
3539
-                      'is_admin' => '1',
3540
-                      'show_in' => '[detail]',
3541
-                      'show_on_pkg' => $package,
3542
-                      'clabels' => __('Twitter', 'geodirectory'));
3543
-
3544
-    $fields[] = array('listing_type' => $post_type,
3545
-                      'data_type' => 'VARCHAR',
3546
-                      'field_type' => 'url',
3547
-                      'admin_title' => __('Facebook', 'geodirectory'),
3548
-                      'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'),
3549
-                      'site_title' => __('Facebook', 'geodirectory'),
3550
-                      'htmlvar_name' => 'facebook',
3551
-                      'default_value' => '',
3552
-                      'option_values' => '',
3553
-                      'is_default' => '1',
3554
-                      'is_admin' => '1',
3555
-                      'show_in' => '[detail]',
3556
-                      'show_on_pkg' => $package,
3557
-                      'clabels' => __('Facebook', 'geodirectory'));
3558
-
3559
-    $fields[] = array('listing_type' => $post_type,
3560
-                      'data_type' => 'TEXT',
3561
-                      'field_type' => 'textarea',
3562
-                      'admin_title' => __('Video', 'geodirectory'),
3563
-                      'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'),
3564
-                      'site_title' => __('Video', 'geodirectory'),
3565
-                      'htmlvar_name' => 'video',
3566
-                      'default_value' => '',
3567
-                      'option_values' => '',
3568
-                      'is_default' => '0',
3569
-                      'is_admin' => '1',
3570
-                      'show_in' => '[owntab]',
3571
-                      'show_on_pkg' => $package,
3572
-                      'clabels' => __('Video', 'geodirectory'));
3573
-
3574
-    $fields[] = array('listing_type' => $post_type,
3575
-                      'data_type' => 'TEXT',
3576
-                      'field_type' => 'textarea',
3577
-                      'admin_title' => __('Special Offers', 'geodirectory'),
3578
-                      'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'),
3579
-                      'site_title' => __('Special Offers', 'geodirectory'),
3580
-                      'htmlvar_name' => 'special_offers',
3581
-                      'default_value' => '',
3582
-                      'option_values' => '',
3583
-                      'is_default' => '0',
3584
-                      'is_admin' => '1',
3585
-                      'show_in' => '[owntab]',
3586
-                      'show_on_pkg' => $package,
3587
-                      'clabels' => __('Special Offers', 'geodirectory'));
3588
-
3589
-    /**
3590
-     * Filter the array of default custom fields DB table data.
3591
-     *
3592
-     * @since 1.6.6
3593
-     * @param string $fields The default custom fields as an array.
3594
-     */
3595
-    $fields = apply_filters('geodir_default_custom_fields', $fields);
3596
-
3597
-    return  $fields;
3426
+	$fields = array();
3427
+	$package = ($package_id=='') ? '' : array($package_id);
3428
+
3429
+	$fields[] = array('listing_type' => $post_type,
3430
+					  'data_type' => 'VARCHAR',
3431
+					  'field_type' => 'taxonomy',
3432
+					  'admin_title' => __('Category', 'geodirectory'),
3433
+					  'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'),
3434
+					  'site_title' => __('Category', 'geodirectory'),
3435
+					  'htmlvar_name' => $post_type.'category',
3436
+					  'default_value' => '',
3437
+					  'is_default' => '1',
3438
+					  'is_admin' => '1',
3439
+					  'is_required' => '1',
3440
+					  'show_in'   =>  '[detail]',
3441
+					  'show_on_pkg' => $package,
3442
+					  'clabels' => __('Category', 'geodirectory'));
3443
+
3444
+	$fields[] = array('listing_type' => $post_type,
3445
+					  'data_type' => 'VARCHAR',
3446
+					  'field_type' => 'address',
3447
+					  'admin_title' => __('Address', 'geodirectory'),
3448
+					  'admin_desc' => ADDRESS_MSG,
3449
+					  'site_title' => __('Address', 'geodirectory'),
3450
+					  'htmlvar_name' => 'post',
3451
+					  'default_value' => '',
3452
+					  'option_values' => '',
3453
+					  'is_default' => '1',
3454
+					  'is_admin' => '1',
3455
+					  'is_required' => '1',
3456
+					  'show_in'   =>  '[detail],[mapbubble]',
3457
+					  'show_on_pkg' => $package,
3458
+					  'required_msg' => __('Address fields are required', 'geodirectory'),
3459
+					  'clabels' => __('Address', 'geodirectory'),
3460
+					  'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'),
3461
+									   'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'),
3462
+									   'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'),
3463
+									   'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'),
3464
+									   'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'),
3465
+									   'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'),
3466
+									   'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden',
3467
+									   'show_latlng' => 1));
3468
+
3469
+	$fields[] = array('listing_type' => $post_type,
3470
+					  'data_type' => 'VARCHAR',
3471
+					  'field_type' => 'text',
3472
+					  'admin_title' => __('Time', 'geodirectory'),
3473
+					  'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'),
3474
+					  'site_title' => __('Time', 'geodirectory'),
3475
+					  'htmlvar_name' => 'timing',
3476
+					  'default_value' => '',
3477
+					  'option_values' => '',
3478
+					  'is_default' => '1',
3479
+					  'is_admin' => '1',
3480
+					  'show_in' =>  '[detail],[mapbubble]',
3481
+					  'show_on_pkg' => $package,
3482
+					  'clabels' => __('Time', 'geodirectory'));
3483
+
3484
+	$fields[] = array('listing_type' => $post_type,
3485
+					  'data_type' => 'VARCHAR',
3486
+					  'field_type' => 'phone',
3487
+					  'admin_title' => __('Phone', 'geodirectory'),
3488
+					  'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'),
3489
+					  'site_title' => __('Phone', 'geodirectory'),
3490
+					  'htmlvar_name' => 'contact',
3491
+					  'default_value' => '',
3492
+					  'option_values' => '',
3493
+					  'is_default' => '1',
3494
+					  'is_admin' => '1',
3495
+					  'show_in' =>  '[detail],[mapbubble]',
3496
+					  'show_on_pkg' => $package,
3497
+					  'clabels' => __('Phone', 'geodirectory'));
3498
+
3499
+	$fields[] = array('listing_type' => $post_type,
3500
+					  'data_type' => 'VARCHAR',
3501
+					  'field_type' => 'email',
3502
+					  'admin_title' => __('Email', 'geodirectory'),
3503
+					  'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'),
3504
+					  'site_title' => __('Email', 'geodirectory'),
3505
+					  'htmlvar_name' => 'email',
3506
+					  'default_value' => '',
3507
+					  'option_values' => '',
3508
+					  'is_default' => '1',
3509
+					  'is_admin' => '1',
3510
+					  'show_in' => '[detail]',
3511
+					  'show_on_pkg' => $package,
3512
+					  'clabels' => __('Email', 'geodirectory'));
3513
+
3514
+	$fields[] = array('listing_type' => $post_type,
3515
+					  'data_type' => 'VARCHAR',
3516
+					  'field_type' => 'url',
3517
+					  'admin_title' => __('Website', 'geodirectory'),
3518
+					  'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'),
3519
+					  'site_title' => __('Website', 'geodirectory'),
3520
+					  'htmlvar_name' => 'website',
3521
+					  'default_value' => '',
3522
+					  'option_values' => '',
3523
+					  'is_default' => '1',
3524
+					  'is_admin' => '1',
3525
+					  'show_in' => '[detail]',
3526
+					  'show_on_pkg' => $package,
3527
+					  'clabels' => __('Website', 'geodirectory'));
3528
+
3529
+	$fields[] = array('listing_type' => $post_type,
3530
+					  'data_type' => 'VARCHAR',
3531
+					  'field_type' => 'url',
3532
+					  'admin_title' => __('Twitter', 'geodirectory'),
3533
+					  'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'),
3534
+					  'site_title' => __('Twitter', 'geodirectory'),
3535
+					  'htmlvar_name' => 'twitter',
3536
+					  'default_value' => '',
3537
+					  'option_values' => '',
3538
+					  'is_default' => '1',
3539
+					  'is_admin' => '1',
3540
+					  'show_in' => '[detail]',
3541
+					  'show_on_pkg' => $package,
3542
+					  'clabels' => __('Twitter', 'geodirectory'));
3543
+
3544
+	$fields[] = array('listing_type' => $post_type,
3545
+					  'data_type' => 'VARCHAR',
3546
+					  'field_type' => 'url',
3547
+					  'admin_title' => __('Facebook', 'geodirectory'),
3548
+					  'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'),
3549
+					  'site_title' => __('Facebook', 'geodirectory'),
3550
+					  'htmlvar_name' => 'facebook',
3551
+					  'default_value' => '',
3552
+					  'option_values' => '',
3553
+					  'is_default' => '1',
3554
+					  'is_admin' => '1',
3555
+					  'show_in' => '[detail]',
3556
+					  'show_on_pkg' => $package,
3557
+					  'clabels' => __('Facebook', 'geodirectory'));
3558
+
3559
+	$fields[] = array('listing_type' => $post_type,
3560
+					  'data_type' => 'TEXT',
3561
+					  'field_type' => 'textarea',
3562
+					  'admin_title' => __('Video', 'geodirectory'),
3563
+					  'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'),
3564
+					  'site_title' => __('Video', 'geodirectory'),
3565
+					  'htmlvar_name' => 'video',
3566
+					  'default_value' => '',
3567
+					  'option_values' => '',
3568
+					  'is_default' => '0',
3569
+					  'is_admin' => '1',
3570
+					  'show_in' => '[owntab]',
3571
+					  'show_on_pkg' => $package,
3572
+					  'clabels' => __('Video', 'geodirectory'));
3573
+
3574
+	$fields[] = array('listing_type' => $post_type,
3575
+					  'data_type' => 'TEXT',
3576
+					  'field_type' => 'textarea',
3577
+					  'admin_title' => __('Special Offers', 'geodirectory'),
3578
+					  'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'),
3579
+					  'site_title' => __('Special Offers', 'geodirectory'),
3580
+					  'htmlvar_name' => 'special_offers',
3581
+					  'default_value' => '',
3582
+					  'option_values' => '',
3583
+					  'is_default' => '0',
3584
+					  'is_admin' => '1',
3585
+					  'show_in' => '[owntab]',
3586
+					  'show_on_pkg' => $package,
3587
+					  'clabels' => __('Special Offers', 'geodirectory'));
3588
+
3589
+	/**
3590
+	 * Filter the array of default custom fields DB table data.
3591
+	 *
3592
+	 * @since 1.6.6
3593
+	 * @param string $fields The default custom fields as an array.
3594
+	 */
3595
+	$fields = apply_filters('geodir_default_custom_fields', $fields);
3596
+
3597
+	return  $fields;
3598 3598
 }
3599 3599
 
3600 3600
 function geodir_currency_format_number($number='',$cf=''){
3601 3601
 
3602
-    $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : '';
3602
+	$cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : '';
3603 3603
 
3604
-    $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$';
3605
-    $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2;
3606
-    $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if');
3607
-    $decimalpoint = '.';
3604
+	$symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$';
3605
+	$decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2;
3606
+	$decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if');
3607
+	$decimalpoint = '.';
3608 3608
 
3609
-    if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
3610
-        $decimalpoint = ',';
3611
-    }
3609
+	if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
3610
+		$decimalpoint = ',';
3611
+	}
3612 3612
 
3613
-    $separator = ',';
3613
+	$separator = ',';
3614 3614
 
3615
-    if(isset($cs['thousand_separator'])){
3616
-        if($cs['thousand_separator']=='comma'){$separator = ',';}
3617
-        if($cs['thousand_separator']=='slash'){$separator = '\\';}
3618
-        if($cs['thousand_separator']=='period'){$separator = '.';}
3619
-        if($cs['thousand_separator']=='space'){$separator = ' ';}
3620
-        if($cs['thousand_separator']=='none'){$separator = '';}
3621
-    }
3615
+	if(isset($cs['thousand_separator'])){
3616
+		if($cs['thousand_separator']=='comma'){$separator = ',';}
3617
+		if($cs['thousand_separator']=='slash'){$separator = '\\';}
3618
+		if($cs['thousand_separator']=='period'){$separator = '.';}
3619
+		if($cs['thousand_separator']=='space'){$separator = ' ';}
3620
+		if($cs['thousand_separator']=='none'){$separator = '';}
3621
+	}
3622 3622
 
3623
-    $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3623
+	$currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3624 3624
 
3625
-    if($decimals>0 && $decimal_display=='if'){
3626
-        if(is_int($number) || floor( $number ) == $number)
3627
-            $decimals = 0;
3628
-    }
3625
+	if($decimals>0 && $decimal_display=='if'){
3626
+		if(is_int($number) || floor( $number ) == $number)
3627
+			$decimals = 0;
3628
+	}
3629 3629
 
3630
-    $number = number_format($number,$decimals,$decimalpoint,$separator);
3630
+	$number = number_format($number,$decimals,$decimalpoint,$separator);
3631 3631
 
3632 3632
 
3633 3633
 
3634
-    if($currency_symbol_placement=='left'){
3635
-        $number = $symbol . $number;
3636
-    }else{
3637
-        $number = $number . $symbol;
3638
-    }
3634
+	if($currency_symbol_placement=='left'){
3635
+		$number = $symbol . $number;
3636
+	}else{
3637
+		$number = $number . $symbol;
3638
+	}
3639 3639
 
3640 3640
 
3641 3641
    return $number;
Please login to merge, or discard this patch.
Spacing   +412 added lines, -412 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50 50
     {
51 51
         global $wpdb;
52
-        $result = 0;// no rows affected
52
+        $result = 0; // no rows affected
53 53
         if (!geodir_column_exist($db, $column)) {
54 54
             if (!empty($db) && !empty($column))
55 55
                 $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 {
75 75
     global $wpdb, $geodir_post_custom_fields_cache;
76 76
 
77
-    $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
77
+    $cache_stored = $post_type.'_'.$package_id.'_'.$default.'_'.$fields_location;
78 78
 
79 79
     if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80 80
         return $geodir_post_custom_fields_cache[$cache_stored];
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
         $default_query .= " and is_admin = '0' ";
89 89
 
90 90
     if ($fields_location == 'none') {
91
-    } else{
92
-        $fields_location = esc_sql( $fields_location );
91
+    } else {
92
+        $fields_location = esc_sql($fields_location);
93 93
         $default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94 94
     }
95 95
 
96 96
     $post_meta_info = $wpdb->get_results(
97 97
         $wpdb->prepare(
98
-            "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
98
+            "select * from ".GEODIR_CUSTOM_FIELDS_TABLE." where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99 99
             array($post_type)
100 100
         )
101 101
     );
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
      * @param string $field_ins_upd When set to "submit" displays form.
163 163
      * @param string $field_type_key The key of the custom field.
164 164
      */
165
-    function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
165
+    function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key = '')
166 166
     {
167 167
         global $wpdb;
168 168
         $cf = $result_str;
169 169
         if (!is_object($cf)) {
170 170
 
171
-            $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
171
+            $field_info = $wpdb->get_row($wpdb->prepare("select * from ".GEODIR_CUSTOM_FIELDS_TABLE." where id= %d", array($cf)));
172 172
 
173 173
         } else {
174 174
             $field_info = $cf;
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
         if ($field_id != '') {
203 203
             $cf = trim($field_id, '_');
204 204
 
205
-            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
-                $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
205
+            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from ".GEODIR_CUSTOM_FIELDS_TABLE." where id= %d", array($cf)))) {
206
+                $wpdb->query($wpdb->prepare("delete from ".GEODIR_CUSTOM_FIELDS_TABLE." where id= %d ", array($cf)));
207 207
 
208 208
                 $post_type = $field->post_type;
209 209
                 $htmlvar_name = $field->htmlvar_name;
210 210
 
211 211
                 if ($post_type != '' && $htmlvar_name != '') {
212
-                    $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
212
+                    $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213 213
                 }
214 214
 
215 215
                 /**
@@ -223,18 +223,18 @@  discard block
 block discarded – undo
223 223
                 do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224 224
 
225 225
                 if ($field->field_type == 'address') {
226
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
226
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_address`");
227
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_city`");
228
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_region`");
229
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_country`");
230
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_zip`");
231
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_latitude`");
232
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_longitude`");
233
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_mapview`");
234
+                    $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."_mapzoom`");
235 235
                 } else {
236 236
                     if ($field->field_type != 'fieldset') {
237
-                        $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
237
+                        $wpdb->query("ALTER TABLE ".$plugin_prefix.$post_type."_detail DROP `".$field->htmlvar_name."`");
238 238
                     }
239 239
                 }
240 240
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
         $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
306 306
 
307 307
         // some servers fail if a POST value is VARCHAR so we change it.
308
-        if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
308
+        if (isset($request_field['data_type']) && $request_field['data_type'] == 'XVARCHAR') {
309 309
             $request_field['data_type'] = 'VARCHAR';
310 310
         }
311 311
 
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
         $post_type = $request_field['listing_type'];
319 319
 
320 320
         if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
321
-            $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
321
+            $cehhtmlvar_name = 'geodir_'.$cehhtmlvar_name;
322 322
         }
323 323
 
324 324
         $check_html_variable = $wpdb->get_var(
325 325
             $wpdb->prepare(
326
-                "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
326
+                "select htmlvar_name from ".GEODIR_CUSTOM_FIELDS_TABLE." where id <> %d and htmlvar_name = %s and post_type = %s ",
327 327
                 array($cf, $cehhtmlvar_name, $post_type)
328 328
             )
329 329
         );
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
                 $post_meta_info = $wpdb->get_row(
337 337
                     $wpdb->prepare(
338
-                        "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
338
+                        "select * from ".GEODIR_CUSTOM_FIELDS_TABLE." where id = %d",
339 339
                         array($cf)
340 340
                     )
341 341
                 );
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
             if ($post_type == '') $post_type = 'gd_place';
354 354
 
355 355
 
356
-            $detail_table = $plugin_prefix . $post_type . '_detail';
356
+            $detail_table = $plugin_prefix.$post_type.'_detail';
357 357
 
358 358
             $admin_title = $request_field['admin_title'];
359 359
             $site_title = $request_field['site_title'];
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
             $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
382 382
 
383 383
             
384
-            if(is_array($show_in)){
384
+            if (is_array($show_in)) {
385 385
                 $show_in = implode(",", $request_field['show_in']);
386 386
             }
387 387
             
388 388
             if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
389
-                $htmlvar_name = 'geodir_' . $htmlvar_name;
389
+                $htmlvar_name = 'geodir_'.$htmlvar_name;
390 390
             }
391 391
 
392 392
             $option_values = '';
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 
428 428
             if ($sort_order == '') {
429 429
 
430
-                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
430
+                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM ".GEODIR_CUSTOM_FIELDS_TABLE);
431 431
 
432
-                $sort_order = (int)$last_order + 1;
432
+                $sort_order = (int) $last_order + 1;
433 433
             }
434 434
 
435 435
             $default_value_add = '';
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
                     case 'address':
442 442
 
443 443
                         if ($htmlvar_name != '') {
444
-                            $prefix = $htmlvar_name . '_';
444
+                            $prefix = $htmlvar_name.'_';
445 445
                         }
446
-                        $old_prefix = $old_html_variable . '_';
446
+                        $old_prefix = $old_html_variable.'_';
447 447
 
448 448
 
449
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
449
+                        $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."address` `".$prefix."address` VARCHAR( 254 ) NULL";
450 450
 
451 451
                         if ($default_value != '') {
452
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
452
+                            $meta_field_add .= " DEFAULT '".$default_value."'";
453 453
                         }
454 454
 
455 455
                         $wpdb->query($meta_field_add);
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 
459 459
                             if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
460 460
 
461
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
461
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."city'");
462 462
                                 if ($is_column) {
463
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
463
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."city` `".$prefix."city` VARCHAR( 50 ) NULL";
464 464
 
465 465
                                     if ($default_value != '') {
466
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
466
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
467 467
                                     }
468 468
 
469 469
                                     $wpdb->query($meta_field_add);
@@ -471,9 +471,9 @@  discard block
 block discarded – undo
471 471
 
472 472
                                     $meta_field_add = "VARCHAR( 50 ) NULL";
473 473
                                     if ($default_value != '') {
474
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
474
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
475 475
                                     }
476
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
476
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."city", $meta_field_add);
477 477
 
478 478
                                 }
479 479
 
@@ -483,36 +483,36 @@  discard block
 block discarded – undo
483 483
 
484 484
                             if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
485 485
 
486
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
486
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."region'");
487 487
 
488 488
                                 if ($is_column) {
489
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
489
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."region` `".$prefix."region` VARCHAR( 50 ) NULL";
490 490
 
491 491
                                     if ($default_value != '') {
492
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
492
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
493 493
                                     }
494 494
 
495 495
                                     $wpdb->query($meta_field_add);
496 496
                                 } else {
497 497
                                     $meta_field_add = "VARCHAR( 50 ) NULL";
498 498
                                     if ($default_value != '') {
499
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
499
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
500 500
                                     }
501 501
 
502
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
502
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."region", $meta_field_add);
503 503
                                 }
504 504
 
505 505
                             }
506 506
                             if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
507 507
 
508
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
508
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."country'");
509 509
 
510 510
                                 if ($is_column) {
511 511
 
512
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
512
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."country` `".$prefix."country` VARCHAR( 50 ) NULL";
513 513
 
514 514
                                     if ($default_value != '') {
515
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
515
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
516 516
                                     }
517 517
 
518 518
                                     $wpdb->query($meta_field_add);
@@ -520,24 +520,24 @@  discard block
 block discarded – undo
520 520
 
521 521
                                     $meta_field_add = "VARCHAR( 50 ) NULL";
522 522
                                     if ($default_value != '') {
523
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
523
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
524 524
                                     }
525 525
 
526
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
526
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."country", $meta_field_add);
527 527
 
528 528
                                 }
529 529
 
530 530
                             }
531 531
                             if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
532 532
 
533
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
533
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."zip'");
534 534
 
535 535
                                 if ($is_column) {
536 536
 
537
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
537
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."zip` `".$prefix."zip` VARCHAR( 50 ) NULL";
538 538
 
539 539
                                     if ($default_value != '') {
540
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
540
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
541 541
                                     }
542 542
 
543 543
                                     $wpdb->query($meta_field_add);
@@ -545,128 +545,128 @@  discard block
 block discarded – undo
545 545
 
546 546
                                     $meta_field_add = "VARCHAR( 50 ) NULL";
547 547
                                     if ($default_value != '') {
548
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
548
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
549 549
                                     }
550 550
 
551
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
551
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."zip", $meta_field_add);
552 552
 
553 553
                                 }
554 554
 
555 555
                             }
556 556
                             if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
557 557
 
558
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
558
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."latitude'");
559 559
                                 if ($is_column) {
560 560
 
561
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
561
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."latitude` `".$prefix."latitude` VARCHAR( 20 ) NULL";
562 562
 
563 563
                                     if ($default_value != '') {
564
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
564
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
565 565
                                     }
566 566
 
567 567
                                     $wpdb->query($meta_field_add);
568 568
                                 } else {
569 569
 
570
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
570
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."latitude` VARCHAR( 20 ) NULL";
571 571
                                     $meta_field_add = "VARCHAR( 20 ) NULL";
572 572
                                     if ($default_value != '') {
573
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
573
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
574 574
                                     }
575 575
 
576
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
576
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."latitude", $meta_field_add);
577 577
 
578 578
                                 }
579 579
 
580 580
 
581
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
581
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."longitude'");
582 582
 
583 583
                                 if ($is_column) {
584
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
584
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."longitude` `".$prefix."longitude` VARCHAR( 20 ) NULL";
585 585
 
586 586
                                     if ($default_value != '') {
587
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
587
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
588 588
                                     }
589 589
 
590 590
                                     $wpdb->query($meta_field_add);
591 591
                                 } else {
592 592
 
593
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
593
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."longitude` VARCHAR( 20 ) NULL";
594 594
                                     $meta_field_add = "VARCHAR( 20 ) NULL";
595 595
                                     if ($default_value != '') {
596
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
596
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
597 597
                                     }
598 598
 
599
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
599
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."longitude", $meta_field_add);
600 600
                                 }
601 601
 
602 602
                             }
603 603
                             if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
604 604
 
605
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
605
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."mapview'");
606 606
 
607 607
                                 if ($is_column) {
608
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
608
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."mapview` `".$prefix."mapview` VARCHAR( 15 ) NULL";
609 609
 
610 610
                                     if ($default_value != '') {
611
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
611
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
612 612
                                     }
613 613
 
614 614
                                     $wpdb->query($meta_field_add);
615 615
                                 } else {
616 616
 
617
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
617
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."mapview` VARCHAR( 15 ) NULL";
618 618
 
619 619
                                     $meta_field_add = "VARCHAR( 15 ) NULL";
620 620
                                     if ($default_value != '') {
621
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
621
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
622 622
                                     }
623 623
 
624
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
624
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."mapview", $meta_field_add);
625 625
                                 }
626 626
 
627 627
 
628 628
                             }
629 629
                             if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
630 630
 
631
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
631
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."mapzoom'");
632 632
                                 if ($is_column) {
633
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
633
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."mapzoom` `".$prefix."mapzoom` VARCHAR( 3 ) NULL";
634 634
 
635 635
                                     if ($default_value != '') {
636
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
636
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
637 637
                                     }
638 638
 
639 639
                                     $wpdb->query($meta_field_add);
640 640
 
641 641
                                 } else {
642 642
 
643
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
643
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."mapzoom` VARCHAR( 3 ) NULL";
644 644
 
645 645
                                     $meta_field_add = "VARCHAR( 3 ) NULL";
646 646
                                     if ($default_value != '') {
647
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
647
+                                        $meta_field_add .= " DEFAULT '".$default_value."'";
648 648
                                     }
649 649
 
650
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
650
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."mapzoom", $meta_field_add);
651 651
                                 }
652 652
 
653 653
                             }
654 654
                             // show lat lng
655 655
                             if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
656
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
656
+                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM ".$detail_table." where field='".$old_prefix."latlng'");
657 657
 
658 658
                                 if ($is_column) {
659
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
659
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_prefix."latlng` `".$prefix."latlng` VARCHAR( 3 ) NULL";
660 660
                                     $meta_field_add .= " DEFAULT '1'";
661 661
 
662 662
                                     $wpdb->query($meta_field_add);
663 663
                                 } else {
664
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
664
+                                    $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."latlng` VARCHAR( 3 ) NULL";
665 665
 
666 666
                                     $meta_field_add = "VARCHAR( 3 ) NULL";
667 667
                                     $meta_field_add .= " DEFAULT '1'";
668 668
 
669
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
669
+                                    geodir_add_column_if_not_exist($detail_table, $prefix."latlng", $meta_field_add);
670 670
                                 }
671 671
 
672 672
                             }
@@ -682,30 +682,30 @@  discard block
 block discarded – undo
682 682
                         $op_size = '500';
683 683
 
684 684
                         // only make the field as big as it needs to be.
685
-                        if(isset($option_values) && $option_values && $field_type=='select'){
686
-                            $option_values_arr = explode(',',$option_values);
687
-                            if(is_array($option_values_arr)){
685
+                        if (isset($option_values) && $option_values && $field_type == 'select') {
686
+                            $option_values_arr = explode(',', $option_values);
687
+                            if (is_array($option_values_arr)) {
688 688
                                 $op_max = 0;
689
-                                foreach($option_values_arr as $op_val){
690
-                                    if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
689
+                                foreach ($option_values_arr as $op_val) {
690
+                                    if (strlen($op_val) && strlen($op_val) > $op_max) {$op_max = strlen($op_val); }
691 691
                                 }
692
-                                if($op_max){$op_size =$op_max; }
692
+                                if ($op_max) {$op_size = $op_max; }
693 693
                             }
694
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695
-                            if(strlen($option_values)){
696
-                                $op_size =  strlen($option_values);
694
+                        }elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
695
+                            if (strlen($option_values)) {
696
+                                $op_size = strlen($option_values);
697 697
                             }
698 698
                         }
699 699
 
700
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
700
+                        $meta_field_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_html_variable."` `".$htmlvar_name."`VARCHAR( $op_size ) NULL";
701 701
 
702 702
                         if ($default_value != '') {
703
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
703
+                            $meta_field_add .= " DEFAULT '".$default_value."'";
704 704
                         }
705 705
 
706 706
                         $alter_result = $wpdb->query($meta_field_add);
707
-                        if($alter_result===false){
708
-                            return __('Column change failed, you may have too many columns.','geodirectory');
707
+                        if ($alter_result === false) {
708
+                            return __('Column change failed, you may have too many columns.', 'geodirectory');
709 709
                         }
710 710
 
711 711
                         if (isset($request_field['cat_display_type']))
@@ -722,9 +722,9 @@  discard block
 block discarded – undo
722 722
                     case 'url':
723 723
                     case 'file':
724 724
 
725
-                        $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
726
-                        if($alter_result===false){
727
-                            return __('Column change failed, you may have too many columns.','geodirectory');
725
+                        $alter_result = $wpdb->query("ALTER TABLE ".$detail_table." CHANGE `".$old_html_variable."` `".$htmlvar_name."` TEXT NULL");
726
+                        if ($alter_result === false) {
727
+                            return __('Column change failed, you may have too many columns.', 'geodirectory');
728 728
                         }
729 729
                         if (isset($request_field['advanced_editor']))
730 730
                             $extra_fields = $request_field['advanced_editor'];
@@ -738,24 +738,24 @@  discard block
 block discarded – undo
738 738
                     default:
739 739
                         if ($data_type != 'VARCHAR' && $data_type != '') {
740 740
                             if ($data_type == 'FLOAT' && $decimal_point > 0) {
741
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
741
+                                $default_value_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_html_variable."` `".$htmlvar_name."` DECIMAL(11, ".(int) $decimal_point.") NULL";
742 742
                             } else {
743
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
743
+                                $default_value_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_html_variable."` `".$htmlvar_name."` ".$data_type." NULL";
744 744
                             }
745 745
 
746 746
                             if (is_numeric($default_value) && $default_value != '') {
747
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
747
+                                $default_value_add .= " DEFAULT '".$default_value."'";
748 748
                             }
749 749
                         } else {
750
-                            $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
750
+                            $default_value_add = "ALTER TABLE ".$detail_table." CHANGE `".$old_html_variable."` `".$htmlvar_name."` VARCHAR( 254 ) NULL";
751 751
                             if ($default_value != '') {
752
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
752
+                                $default_value_add .= " DEFAULT '".$default_value."'";
753 753
                             }
754 754
                         }
755 755
 
756 756
                         $alter_result = $wpdb->query($default_value_add);
757
-                        if($alter_result===false){
758
-                            return __('Column change failed, you may have too many columns.','geodirectory');
757
+                        if ($alter_result === false) {
758
+                            return __('Column change failed, you may have too many columns.', 'geodirectory');
759 759
                         }
760 760
                         break;
761 761
                 endswitch;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 
772 772
                     $wpdb->prepare(
773 773
 
774
-                        "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
774
+                        "update ".GEODIR_CUSTOM_FIELDS_TABLE." set 
775 775
 					post_type = %s,
776 776
 					admin_title = %s,
777 777
 					site_title = %s,
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 					for_admin_use = %s
806 806
 					where id = %d",
807 807
 
808
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
808
+                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point, $validation_pattern, $validation_msg, $for_admin_use, $cf)
809 809
                     )
810 810
 
811 811
                 );
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 
816 816
                 $wpdb->query(
817 817
                     $wpdb->prepare(
818
-                        "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
818
+                        "update ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." set 
819 819
 					 	site_title=%s
820 820
 					where post_type = %s and htmlvar_name = %s",
821 821
                         array($site_title, $post_type, $htmlvar_name)
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 
825 825
 
826 826
                 if ($cat_sort == '')
827
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
827
+                    $wpdb->query($wpdb->prepare("delete from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
828 828
 
829 829
 
830 830
                 /**
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
                         $data_type = '';
845 845
 
846 846
                         if ($htmlvar_name != '') {
847
-                            $prefix = $htmlvar_name . '_';
847
+                            $prefix = $htmlvar_name.'_';
848 848
                         }
849 849
                         $old_prefix = $old_html_variable;
850 850
 
@@ -852,109 +852,109 @@  discard block
 block discarded – undo
852 852
 
853 853
                         $meta_field_add = "VARCHAR( 254 ) NULL";
854 854
                         if ($default_value != '') {
855
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
855
+                            $meta_field_add .= " DEFAULT '".$default_value."'";
856 856
                         }
857 857
 
858
-                        geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
858
+                        geodir_add_column_if_not_exist($detail_table, $prefix."address", $meta_field_add);
859 859
                         //$wpdb->query($meta_field_add);
860 860
 
861 861
 
862 862
                         if (!empty($extra_fields)) {
863 863
 
864 864
                             if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
865
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
865
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."city` VARCHAR( 30 ) NULL";
866 866
                                 $meta_field_add = "VARCHAR( 30 ) NULL";
867 867
                                 if ($default_value != '') {
868
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
868
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
869 869
                                 }
870 870
 
871
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
871
+                                geodir_add_column_if_not_exist($detail_table, $prefix."city", $meta_field_add);
872 872
                                 //$wpdb->query($meta_field_add);
873 873
                             }
874 874
                             if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
875
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
875
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."region` VARCHAR( 30 ) NULL";
876 876
                                 $meta_field_add = "VARCHAR( 30 ) NULL";
877 877
                                 if ($default_value != '') {
878
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
878
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
879 879
                                 }
880 880
 
881
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
881
+                                geodir_add_column_if_not_exist($detail_table, $prefix."region", $meta_field_add);
882 882
                                 //$wpdb->query($meta_field_add);
883 883
                             }
884 884
                             if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
885
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
885
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."country` VARCHAR( 30 ) NULL";
886 886
 
887 887
                                 $meta_field_add = "VARCHAR( 30 ) NULL";
888 888
                                 if ($default_value != '') {
889
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
889
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
890 890
                                 }
891 891
 
892
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
892
+                                geodir_add_column_if_not_exist($detail_table, $prefix."country", $meta_field_add);
893 893
                                 //$wpdb->query($meta_field_add);
894 894
                             }
895 895
                             if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
896
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
896
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."zip` VARCHAR( 15 ) NULL";
897 897
                                 $meta_field_add = "VARCHAR( 15 ) NULL";
898 898
                                 if ($default_value != '') {
899
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
899
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
900 900
                                 }
901 901
 
902
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
902
+                                geodir_add_column_if_not_exist($detail_table, $prefix."zip", $meta_field_add);
903 903
                                 //$wpdb->query($meta_field_add);
904 904
                             }
905 905
                             if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
906
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
906
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."latitude` VARCHAR( 20 ) NULL";
907 907
                                 $meta_field_add = "VARCHAR( 20 ) NULL";
908 908
                                 if ($default_value != '') {
909
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
909
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
910 910
                                 }
911 911
 
912
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
912
+                                geodir_add_column_if_not_exist($detail_table, $prefix."latitude", $meta_field_add);
913 913
                                 //$wpdb->query($meta_field_add);
914 914
 
915
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
915
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."longitude` VARCHAR( 20 ) NULL";
916 916
 
917 917
                                 $meta_field_add = "VARCHAR( 20 ) NULL";
918 918
                                 if ($default_value != '') {
919
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
919
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
920 920
                                 }
921 921
 
922
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
922
+                                geodir_add_column_if_not_exist($detail_table, $prefix."longitude", $meta_field_add);
923 923
 
924 924
                                 //$wpdb->query($meta_field_add);
925 925
                             }
926 926
                             if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
927
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
927
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."mapview` VARCHAR( 15 ) NULL";
928 928
 
929 929
                                 $meta_field_add = "VARCHAR( 15 ) NULL";
930 930
                                 if ($default_value != '') {
931
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
931
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
932 932
                                 }
933 933
 
934
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
934
+                                geodir_add_column_if_not_exist($detail_table, $prefix."mapview", $meta_field_add);
935 935
 
936 936
                                 //$wpdb->query($meta_field_add);
937 937
                             }
938 938
                             if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
939
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
939
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."mapzoom` VARCHAR( 3 ) NULL";
940 940
 
941 941
                                 $meta_field_add = "VARCHAR( 3 ) NULL";
942 942
                                 if ($default_value != '') {
943
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
943
+                                    $meta_field_add .= " DEFAULT '".$default_value."'";
944 944
                                 }
945 945
 
946
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
946
+                                geodir_add_column_if_not_exist($detail_table, $prefix."mapzoom", $meta_field_add);
947 947
 
948 948
                                 //$wpdb->query($meta_field_add);
949 949
                             }
950 950
                             // show lat lng
951 951
                             if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
952
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
952
+                                $meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."latlng` VARCHAR( 3 ) NULL";
953 953
 
954 954
                                 $meta_field_add = "VARCHAR( 3 ) NULL";
955 955
                                 $meta_field_add .= " DEFAULT '1'";
956 956
 
957
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
957
+                                geodir_add_column_if_not_exist($detail_table, $prefix."latlng", $meta_field_add);
958 958
                                 //$wpdb->query($meta_field_add);
959 959
                             }
960 960
                         }
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
                     case 'checkbox':
965 965
                         $data_type = 'TINYINT';
966 966
 
967
-                        $meta_field_add = $data_type . "( 1 ) NOT NULL ";
968
-                        if ((int)$default_value === 1) {
967
+                        $meta_field_add = $data_type."( 1 ) NOT NULL ";
968
+                        if ((int) $default_value === 1) {
969 969
                             $meta_field_add .= " DEFAULT '1'";
970 970
                         }
971 971
 
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
                             }
999 999
                         } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
1000 1000
                             if (strlen($option_values)) {
1001
-                                $op_size =  strlen($option_values);
1001
+                                $op_size = strlen($option_values);
1002 1002
                             }
1003 1003
 
1004 1004
                             if (isset($request_field['multi_display_type'])) {
@@ -1006,9 +1006,9 @@  discard block
 block discarded – undo
1006 1006
                             }
1007 1007
                         }
1008 1008
 
1009
-                        $meta_field_add = $data_type . "( $op_size ) NULL ";
1009
+                        $meta_field_add = $data_type."( $op_size ) NULL ";
1010 1010
                         if ($default_value != '') {
1011
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
1011
+                            $meta_field_add .= " DEFAULT '".$default_value."'";
1012 1012
                         }
1013 1013
 
1014 1014
                         $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
@@ -1023,9 +1023,9 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
                         $data_type = 'TEXT';
1025 1025
 
1026
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1026
+                        $default_value_add = " `".$htmlvar_name."` ".$data_type." NULL ";
1027 1027
 
1028
-                        $meta_field_add = $data_type . " NULL ";
1028
+                        $meta_field_add = $data_type." NULL ";
1029 1029
                         /*if($default_value != '')
1030 1030
 					{ $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
1031 1031
 
@@ -1040,9 +1040,9 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
                         $data_type = 'DATE';
1042 1042
 
1043
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1043
+                        $default_value_add = " `".$htmlvar_name."` ".$data_type." NULL ";
1044 1044
 
1045
-                        $meta_field_add = $data_type . " NULL ";
1045
+                        $meta_field_add = $data_type." NULL ";
1046 1046
 
1047 1047
                         $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1048 1048
                         if ($add_result === false) {
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
 
1056 1056
                         $data_type = 'TIME';
1057 1057
 
1058
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1058
+                        $default_value_add = " `".$htmlvar_name."` ".$data_type." NULL ";
1059 1059
 
1060
-                        $meta_field_add = $data_type . " NULL ";
1060
+                        $meta_field_add = $data_type." NULL ";
1061 1061
 
1062 1062
                         $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1063 1063
                         if ($add_result === false) {
@@ -1069,22 +1069,22 @@  discard block
 block discarded – undo
1069 1069
                     default:
1070 1070
 
1071 1071
                         if ($data_type != 'VARCHAR' && $data_type != '') {
1072
-                            $meta_field_add = $data_type . " NULL ";
1072
+                            $meta_field_add = $data_type." NULL ";
1073 1073
 
1074 1074
                             if ($data_type == 'FLOAT' && $decimal_point > 0) {
1075
-                                $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1075
+                                $meta_field_add = "DECIMAL(11, ".(int) $decimal_point.") NULL ";
1076 1076
                             }
1077 1077
 
1078 1078
                             if (is_numeric($default_value) && $default_value != '') {
1079
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1080
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1079
+                                $default_value_add .= " DEFAULT '".$default_value."'";
1080
+                                $meta_field_add .= " DEFAULT '".$default_value."'";
1081 1081
                             }
1082 1082
                         } else {
1083 1083
                             $meta_field_add = " VARCHAR( 254 ) NULL ";
1084 1084
 
1085 1085
                             if ($default_value != '') {
1086
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1087
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1086
+                                $default_value_add .= " DEFAULT '".$default_value."'";
1087
+                                $meta_field_add .= " DEFAULT '".$default_value."'";
1088 1088
                             }
1089 1089
                         }
1090 1090
 
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 
1107 1107
                     $wpdb->prepare(
1108 1108
 
1109
-                        "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1109
+                        "insert into ".GEODIR_CUSTOM_FIELDS_TABLE." set 
1110 1110
 					post_type = %s,
1111 1111
 					admin_title = %s,
1112 1112
 					site_title = %s,
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 					validation_msg = %s,
1140 1140
 					for_admin_use = %s ",
1141 1141
 
1142
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1142
+                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point, $validation_pattern, $validation_msg, $for_admin_use)
1143 1143
 
1144 1144
                     )
1145 1145
 
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 
1152 1152
             }
1153 1153
 
1154
-            return (int)$lastid;
1154
+            return (int) $lastid;
1155 1155
 
1156 1156
 
1157 1157
         } else {
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 
1185 1185
             $post_meta_info = $wpdb->query(
1186 1186
                 $wpdb->prepare(
1187
-                    "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1187
+                    "update ".GEODIR_CUSTOM_FIELDS_TABLE." set 
1188 1188
 															sort_order=%d 
1189 1189
 															where id= %d",
1190 1190
                     array($count, $cf)
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
         global $post;
1207 1207
 
1208 1208
         if (isset($_REQUEST['post'])) {
1209
-            $_REQUEST['pid'] = (int)$_REQUEST['post'];
1209
+            $_REQUEST['pid'] = (int) $_REQUEST['post'];
1210 1210
         }
1211 1211
     }
1212 1212
 
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
      * @param mixed $value Custom field value.
1230 1230
      * @param array $cf Custom field info.
1231 1231
      */
1232
-    return apply_filters( 'geodir_get_cf_value', $value, $cf );
1232
+    return apply_filters('geodir_get_cf_value', $value, $cf);
1233 1233
 }
1234 1234
 
1235 1235
 /**
@@ -1255,16 +1255,16 @@  discard block
 block discarded – undo
1255 1255
     $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1256 1256
 
1257 1257
     foreach ($custom_fields as $key => $val) {
1258
-        if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
1258
+        if (isset($val['extra_fields'])) {$extra_fields = $val['extra_fields']; }
1259 1259
         $val = stripslashes_deep($val); // strip slashes from labels
1260
-        if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
1260
+        if (isset($val['extra_fields'])) {$val['extra_fields'] = $extra_fields; }
1261 1261
 
1262 1262
         $name = $val['name'];
1263 1263
         $type = $val['type'];
1264 1264
         $is_default = $val['is_default'];
1265 1265
 
1266 1266
         /* field available to site admin only for edit */
1267
-        $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1267
+        $for_admin_use = isset($val['for_admin_use']) && (int) $val['for_admin_use'] == 1 ? true : false;
1268 1268
         if ($for_admin_use && !is_super_admin()) {
1269 1269
             continue;
1270 1270
         }
@@ -1289,11 +1289,11 @@  discard block
 block discarded – undo
1289 1289
          * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1290 1290
          * @see 'geodir_after_custom_form_field_$name'
1291 1291
          */
1292
-        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1292
+        do_action('geodir_before_custom_form_field_'.$name, $listing_type, $package_id, $val);
1293 1293
 
1294 1294
 
1295 1295
         $custom_field = $val;
1296
-        $html ='';
1296
+        $html = '';
1297 1297
         /**
1298 1298
          * Filter the output for custom fields.
1299 1299
          *
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
          * @param string $html The html to be filtered (blank).
1303 1303
          * @param array $custom_field The custom field array values.
1304 1304
          */
1305
-        echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1305
+        echo apply_filters("geodir_custom_field_input_{$type}", $html, $custom_field);
1306 1306
 
1307 1307
 
1308 1308
 
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
          * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1318 1318
          * @see 'geodir_before_custom_form_field_$name'
1319 1319
          */
1320
-        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1320
+        do_action('geodir_after_custom_form_field_'.$name, $listing_type, $package_id, $val);
1321 1321
 
1322 1322
     }
1323 1323
 
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 
1344 1344
         $filter = $wpdb->get_row(
1345 1345
             $wpdb->prepare(
1346
-                "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1346
+                "SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND ".$key."='".$value."'",
1347 1347
                 array($geodir_post_type)
1348 1348
             )
1349 1349
         );
@@ -1358,14 +1358,14 @@  discard block
 block discarded – undo
1358 1358
 }
1359 1359
 
1360 1360
 
1361
-function geodir_field_icon_proccess($cf){
1361
+function geodir_field_icon_proccess($cf) {
1362 1362
 
1363 1363
 
1364 1364
     if (strpos($cf['field_icon'], 'http') !== false) {
1365
-        $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1365
+        $field_icon = ' background: url('.$cf['field_icon'].') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1366 1366
     } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1367
-        $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1368
-    }else{
1367
+        $field_icon = '<i class="'.$cf['field_icon'].'"></i>';
1368
+    } else {
1369 1369
         $field_icon = $cf['field_icon'];
1370 1370
     }
1371 1371
 
@@ -1410,14 +1410,14 @@  discard block
 block discarded – undo
1410 1410
 
1411 1411
 
1412 1412
             foreach ($fields_info as $type) {
1413
-                if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
1413
+                if (isset($type['extra_fields'])) {$extra_fields = $type['extra_fields']; }
1414 1414
                 $type = stripslashes_deep($type); // strip slashes
1415
-                if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
1415
+                if (isset($type['extra_fields'])) {$type['extra_fields'] = $extra_fields; }
1416 1416
                 $html = '';
1417 1417
                 $field_icon = geodir_field_icon_proccess($type);
1418 1418
                 $filed_type = $type['type'];
1419 1419
                 $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
1420
-                if($html_var=='post'){$html_var='post_address';}
1420
+                if ($html_var == 'post') {$html_var = 'post_address'; }
1421 1421
 
1422 1422
                 /**
1423 1423
                  * Filter the output for custom fields.
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
                  * @param string $fields_location The location the field is to be show.
1429 1429
                  * @param array $type The array of field values.
1430 1430
                  */
1431
-                $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1431
+                $html = apply_filters("geodir_custom_field_output_{$filed_type}", $html, $fields_location, $type);
1432 1432
 
1433 1433
                 $variables_array = array();
1434 1434
 
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
          * @param string $fields_location The location the fields are being output.
1489 1489
          * @since 1.6.9
1490 1490
          */
1491
-        return apply_filters('geodir_show_listing_info',$html,$fields_location);
1491
+        return apply_filters('geodir_show_listing_info', $html, $fields_location);
1492 1492
 
1493 1493
     }
1494 1494
 }
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 
1564 1564
         $post_type = get_post_type($post_id);
1565 1565
         //echo $field_id; exit;
1566
-        $table = $plugin_prefix . $post_type . '_detail';
1566
+        $table = $plugin_prefix.$post_type.'_detail';
1567 1567
 
1568 1568
         $postcurr_images = array();
1569 1569
         $postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
@@ -1582,13 +1582,13 @@  discard block
 block discarded – undo
1582 1582
             $geodir_uploadurl = $uploads['url'];
1583 1583
             $sub_dir = $uploads['subdir'];
1584 1584
 
1585
-            $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1585
+            $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
1586 1586
 
1587 1587
             for ($m = 0; $m < count($post_image); $m++) {
1588 1588
 
1589 1589
                 /* --------- start ------- */
1590 1590
 
1591
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1591
+                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM ".$table." WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1592 1592
 
1593 1593
 
1594 1594
                     $curr_img_url = $post_image[$m];
@@ -1614,24 +1614,24 @@  discard block
 block discarded – undo
1614 1614
                     //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1615 1615
 
1616 1616
                     if (!function_exists('wp_handle_upload'))
1617
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1617
+                        require_once(ABSPATH.'wp-admin/includes/file.php');
1618 1618
 
1619 1619
                     if (!is_dir($geodir_uploadpath))
1620 1620
                         mkdir($geodir_uploadpath);
1621 1621
 
1622
-                    $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1622
+                    $new_name = $post_id.'_'.$field_id.'_'.$img_name_arr[0].'.'.$img_name_arr[1];
1623 1623
                     $explode_sub_dir = explode("/", $sub_dir);
1624 1624
                     if ($curr_img_dir == end($explode_sub_dir)) {
1625
-                        $img_path = $geodir_uploadpath . '/' . $filename;
1626
-                        $img_url = $geodir_uploadurl . '/' . $filename;
1625
+                        $img_path = $geodir_uploadpath.'/'.$filename;
1626
+                        $img_url = $geodir_uploadurl.'/'.$filename;
1627 1627
                     } else {
1628
-                        $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1629
-                        $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1628
+                        $img_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1629
+                        $img_url = $uploads['url'].'/temp_'.$current_user->data->ID.'/'.$filename;
1630 1630
                     }
1631 1631
 
1632 1632
                     $uploaded_file = '';
1633 1633
                     if (file_exists($img_path))
1634
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1634
+                        $uploaded_file = copy($img_path, $geodir_uploadpath.'/'.$new_name);
1635 1635
 
1636 1636
                     if ($curr_img_dir != $geodir_uploaddir) {
1637 1637
                         if (file_exists($img_path))
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
                     }
1640 1640
 
1641 1641
                     if (!empty($uploaded_file))
1642
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1642
+                        $file_urls = $geodir_uploadurl.'/'.$new_name;
1643 1643
 
1644 1644
                 } else {
1645 1645
                     $file_urls = $post_image[$m];
@@ -1653,8 +1653,8 @@  discard block
 block discarded – undo
1653 1653
         if (!empty($postcurr_images)) {
1654 1654
 
1655 1655
             if ($file_urls != $postcurr_images) {
1656
-                $invalid_files[] = (object)array('src' => $postcurr_images);
1657
-                $invalid_files = (object)$invalid_files;
1656
+                $invalid_files[] = (object) array('src' => $postcurr_images);
1657
+                $invalid_files = (object) $invalid_files;
1658 1658
             }
1659 1659
         }
1660 1660
 
@@ -1706,9 +1706,9 @@  discard block
 block discarded – undo
1706 1706
     function geodir_upload_dir($upload)
1707 1707
     {
1708 1708
         global $current_user;
1709
-        $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1710
-        $upload['path'] = $upload['basedir'] . $upload['subdir'];
1711
-        $upload['url'] = $upload['baseurl'] . $upload['subdir'];
1709
+        $upload['subdir'] = $upload['subdir'].'/temp_'.$current_user->data->ID;
1710
+        $upload['path'] = $upload['basedir'].$upload['subdir'];
1711
+        $upload['url'] = $upload['baseurl'].$upload['subdir'];
1712 1712
         return $upload;
1713 1713
     }
1714 1714
 
@@ -1723,20 +1723,20 @@  discard block
 block discarded – undo
1723 1723
         // check ajax nonce
1724 1724
         $imgid = $_POST["imgid"];
1725 1725
 
1726
-        check_ajax_referer($imgid . 'pluploadan');
1726
+        check_ajax_referer($imgid.'pluploadan');
1727 1727
 
1728 1728
         // handle custom file uploaddir
1729 1729
         add_filter('upload_dir', 'geodir_upload_dir');
1730 1730
 
1731 1731
         // change file orientation if needed
1732
-        $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1732
+        $fixed_file = geodir_exif($_FILES[$imgid.'async-upload']);
1733 1733
 
1734 1734
         // handle file upload
1735 1735
         $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1736 1736
         // remove handle custom file uploaddir
1737 1737
         remove_filter('upload_dir', 'geodir_upload_dir');
1738 1738
 
1739
-        if(!isset($status['url']) && isset($status['error'])){
1739
+        if (!isset($status['url']) && isset($status['error'])) {
1740 1740
             print_r($status);
1741 1741
         }
1742 1742
 
@@ -1766,9 +1766,9 @@  discard block
 block discarded – undo
1766 1766
 
1767 1767
     $post_type = get_post_type($post_id);
1768 1768
 
1769
-    $table = $plugin_prefix . $post_type . '_detail';
1769
+    $table = $plugin_prefix.$post_type.'_detail';
1770 1770
 
1771
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1771
+    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM ".$table." WHERE post_id=%d", array($post_id)));
1772 1772
 
1773 1773
     if ($results) {
1774 1774
         return $results[0]->geodir_video;
@@ -1792,9 +1792,9 @@  discard block
 block discarded – undo
1792 1792
 
1793 1793
     $post_type = get_post_type($post_id);
1794 1794
 
1795
-    $table = $plugin_prefix . $post_type . '_detail';
1795
+    $table = $plugin_prefix.$post_type.'_detail';
1796 1796
 
1797
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1797
+    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM ".$table." WHERE post_id=%d", array($post_id)));
1798 1798
 
1799 1799
     if ($results) {
1800 1800
         return $results[0]->geodir_special_offers;
@@ -1812,12 +1812,12 @@  discard block
 block discarded – undo
1812 1812
      */
1813 1813
     function geodir_max_upload_size()
1814 1814
     {
1815
-        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1815
+        $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1816 1816
 
1817 1817
         if ($max_filesize > 0 && $max_filesize < 1) {
1818
-            $max_filesize = (int)($max_filesize * 1024) . 'kb';
1818
+            $max_filesize = (int) ($max_filesize * 1024).'kb';
1819 1819
         } else {
1820
-            $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1820
+            $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb';
1821 1821
         }
1822 1822
         /** Filter documented in geodirectory-functions/general_functions.php **/
1823 1823
         return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
 
1850 1850
             $custom_fields = $wpdb->get_results(
1851 1851
                 $wpdb->prepare(
1852
-                    "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1852
+                    "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from ".GEODIR_CUSTOM_FIELDS_TABLE." where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1853 1853
                     array($post_type)
1854 1854
                 ), 'ARRAY_A'
1855 1855
             );
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
 
1977 1977
             $post_meta_info = $wpdb->query(
1978 1978
                 $wpdb->prepare(
1979
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1979
+                    "update ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." set 
1980 1980
 															sort_order=%d 
1981 1981
 															where id= %d",
1982 1982
                     array($count, $cf)
@@ -2058,14 +2058,14 @@  discard block
 block discarded – undo
2058 2058
 
2059 2059
         $check_html_variable = $wpdb->get_var(
2060 2060
             $wpdb->prepare(
2061
-                "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2061
+                "select htmlvar_name from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s and field_type=%s ",
2062 2062
                 array($cehhtmlvar_name, $post_type, $field_type)
2063 2063
             )
2064 2064
         );
2065 2065
 
2066 2066
         if ($is_default == 1) {
2067 2067
 
2068
-            $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2068
+            $wpdb->query($wpdb->prepare("update ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." set is_default='0', default_order='' where post_type = %s", array($post_type)));
2069 2069
 
2070 2070
         }
2071 2071
 
@@ -2076,7 +2076,7 @@  discard block
 block discarded – undo
2076 2076
 
2077 2077
                 $wpdb->prepare(
2078 2078
 
2079
-                    "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2079
+                    "insert into ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." set 
2080 2080
 				post_type = %s,
2081 2081
 				data_type = %s,
2082 2082
 				field_type = %s,
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
 
2108 2108
                 $wpdb->prepare(
2109 2109
 
2110
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2110
+                    "update ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." set 
2111 2111
 				post_type = %s,
2112 2112
 				data_type = %s,
2113 2113
 				field_type = %s,
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
         }
2134 2134
 
2135 2135
 
2136
-        return (int)$lastid;
2136
+        return (int) $lastid;
2137 2137
 
2138 2138
     }
2139 2139
 }
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
         if ($field_id != '') {
2157 2157
             $cf = trim($field_id, '_');
2158 2158
 
2159
-            $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2159
+            $wpdb->query($wpdb->prepare("delete from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where id= %d ", array($cf)));
2160 2160
 
2161 2161
             return $field_id;
2162 2162
 
@@ -2179,12 +2179,12 @@  discard block
 block discarded – undo
2179 2179
      * @param string $field_ins_upd When set to "submit" displays form.
2180 2180
      * @param bool $default when set to true field will be for admin use only.
2181 2181
      */
2182
-    function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='')
2182
+    function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key = '')
2183 2183
     {
2184 2184
         global $wpdb;
2185 2185
         $cf = $result_str;
2186 2186
         if (!is_object($cf)) {
2187
-            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2187
+            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE id = %d", array($cf)));
2188 2188
         } else {
2189 2189
             $field_info = $cf;
2190 2190
             $result_str = $cf->id;
@@ -2220,18 +2220,18 @@  discard block
 block discarded – undo
2220 2220
         if ($htmlvar_name == '')
2221 2221
             $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2222 2222
 
2223
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
2223
+        $nonce = wp_create_nonce('custom_fields_'.$result_str);
2224 2224
 
2225 2225
         $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
2226 2226
         $cso_arr = geodir_get_custom_sort_options($post_type);
2227 2227
 
2228 2228
         $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']);
2229
-        foreach($cso_arr as $cso){
2230
-            if($cur_field_type==$cso['field_type']){
2229
+        foreach ($cso_arr as $cso) {
2230
+            if ($cur_field_type == $cso['field_type']) {
2231 2231
 
2232 2232
                 if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2233 2233
                     $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2234
-                }elseif(isset($cso['field_icon']) && $cso['field_icon']){
2234
+                }elseif (isset($cso['field_icon']) && $cso['field_icon']) {
2235 2235
                     $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2236 2236
                 }
2237 2237
 
@@ -2241,40 +2241,40 @@  discard block
 block discarded – undo
2241 2241
         $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500);
2242 2242
         ?>
2243 2243
 
2244
-        <li class="text" id="licontainer_<?php echo $result_str;?>">
2244
+        <li class="text" id="licontainer_<?php echo $result_str; ?>">
2245 2245
             <form><!-- we need to wrap in a form so we can use radio buttons with same name -->
2246
-            <div class="title title<?php echo $result_str;?> gt-fieldset"
2247
-                 title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory');?>"
2248
-                 ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
2246
+            <div class="title title<?php echo $result_str; ?> gt-fieldset"
2247
+                 title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory'); ?>"
2248
+                 ondblclick="show_hide('field_frm<?php echo $result_str; ?>')">
2249 2249
                 <?php
2250 2250
 
2251 2251
                 ?>
2252 2252
 
2253
-                <div title="<?php _e('Click to remove field', 'geodirectory');?>"
2254
-                     onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
2253
+                <div title="<?php _e('Click to remove field', 'geodirectory'); ?>"
2254
+                     onclick="delete_sort_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>', this)"
2255 2255
                      class="handlediv close"><i class="fa fa-times" aria-hidden="true"></i></div>
2256 2256
 
2257 2257
 
2258
-                <?php echo $field_icon;?>
2258
+                <?php echo $field_icon; ?>
2259 2259
                 <b style="cursor:pointer;"
2260
-                   onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(__('Field:', 'geodirectory') . ' (' . $site_title . ')');?></b>
2260
+                   onclick="show_hide('field_frm<?php echo $result_str; ?>')"><?php echo geodir_ucwords(__('Field:', 'geodirectory').' ('.$site_title.')'); ?></b>
2261 2261
 
2262 2262
             </div>
2263 2263
 
2264
-            <div id="field_frm<?php echo $result_str;?>" class="field_frm"
2264
+            <div id="field_frm<?php echo $result_str; ?>" class="field_frm"
2265 2265
                  style="display:<?php if ($field_ins_upd == 'submit') {
2266 2266
                      echo 'block;';
2267 2267
                  } else {
2268 2268
                      echo 'none;';
2269 2269
                  } ?>">
2270 2270
                 <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
2271
-                <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/>
2272
-                <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/>
2273
-                <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/>
2271
+                <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type; ?>"/>
2272
+                <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/>
2273
+                <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str; ?>"/>
2274 2274
                 <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
2275 2275
                     echo $field_info->data_type;
2276 2276
                 }?>"/>
2277
-                <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/>
2277
+                <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name; ?>"/>
2278 2278
 
2279 2279
 
2280 2280
                 <ul class="widefat post fixed" border="0" style="width:100%;">
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
                         <input type="hidden" name="site_title" id="site_title" value="<?php echo esc_attr($site_title); ?>"/>
2285 2285
 
2286 2286
                         <li>
2287
-                            <?php $value = (isset($field_info->sort_asc) && $field_info->sort_asc) ? $field_info->sort_asc : 0;?>
2287
+                            <?php $value = (isset($field_info->sort_asc) && $field_info->sort_asc) ? $field_info->sort_asc : 0; ?>
2288 2288
 
2289 2289
                             <label for="asc" class="gd-cf-tooltip-wrap">
2290 2290
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show Ascending Sort (low to high)', 'geodirectory'); ?>
@@ -2294,24 +2294,24 @@  discard block
 block discarded – undo
2294 2294
                             </label>
2295 2295
                             <div class="gd-cf-input-wrap gd-switch">
2296 2296
 
2297
-                                <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled"  value="1"
2297
+                                <input type="radio" id="asc_yes<?php echo $radio_id; ?>" name="asc" class="gdri-enabled"  value="1"
2298 2298
                                     <?php if ($value == '1') {
2299 2299
                                         echo 'checked';
2300 2300
                                     } ?>/>
2301
-                                <label onclick="show_hide_radio(this,'show','cfs-asc-title');" for="asc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2301
+                                <label onclick="show_hide_radio(this,'show','cfs-asc-title');" for="asc_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2302 2302
 
2303
-                                <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0"
2303
+                                <input type="radio" id="asc_no<?php echo $radio_id; ?>" name="asc" class="gdri-disabled" value="0"
2304 2304
                                     <?php if ($value == '0' || !$value) {
2305 2305
                                         echo 'checked';
2306 2306
                                     } ?>/>
2307
-                                <label onclick="show_hide_radio(this,'hide','cfs-asc-title');" for="asc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2307
+                                <label onclick="show_hide_radio(this,'hide','cfs-asc-title');" for="asc_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2308 2308
 
2309 2309
                             </div>
2310 2310
 
2311 2311
                         </li>
2312 2312
 
2313
-                        <li class="cfs-asc-title" <?php if ((isset($field_info->sort_asc) && $field_info->sort_asc == '0') || !isset($field_info->sort_asc)) {echo "style='display:none;'";}?>>
2314
-                            <?php $value = (isset($field_info->asc_title) && $field_info->asc_title) ? esc_attr($field_info->asc_title) : '';?>
2313
+                        <li class="cfs-asc-title" <?php if ((isset($field_info->sort_asc) && $field_info->sort_asc == '0') || !isset($field_info->sort_asc)) {echo "style='display:none;'"; }?>>
2314
+                            <?php $value = (isset($field_info->asc_title) && $field_info->asc_title) ? esc_attr($field_info->asc_title) : ''; ?>
2315 2315
 
2316 2316
                             <label for="asc_title" class="gd-cf-tooltip-wrap">
2317 2317
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Ascending title', 'geodirectory'); ?>
@@ -2321,14 +2321,14 @@  discard block
 block discarded – undo
2321 2321
                             </label>
2322 2322
                             <div class="gd-cf-input-wrap">
2323 2323
 
2324
-                                <input type="text" name="asc_title" id="asc_title" value="<?php echo $value;?>" />
2324
+                                <input type="text" name="asc_title" id="asc_title" value="<?php echo $value; ?>" />
2325 2325
                             </div>
2326 2326
 
2327 2327
 
2328 2328
                         </li>
2329 2329
 
2330 2330
 
2331
-                        <li class="cfs-asc-title" <?php if ((isset($field_info->sort_asc) && $field_info->sort_asc == '0') || !isset($field_info->sort_asc)) {echo "style='display:none;'";}?>>
2331
+                        <li class="cfs-asc-title" <?php if ((isset($field_info->sort_asc) && $field_info->sort_asc == '0') || !isset($field_info->sort_asc)) {echo "style='display:none;'"; }?>>
2332 2332
 
2333 2333
                             <label for="is_default" class="gd-cf-tooltip-wrap">
2334 2334
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Default sort?', 'geodirectory'); ?>
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
                             <div class="gd-cf-input-wrap">
2340 2340
 
2341 2341
                                 <input type="radio" name="is_default"
2342
-                                       value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
2342
+                                       value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name.'_asc') {
2343 2343
                                     echo 'checked="checked"';
2344 2344
                                 } ?>/>
2345 2345
                             </div>
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
 
2350 2350
 
2351 2351
                         <li>
2352
-                            <?php $value = (isset($field_info->sort_desc) && $field_info->sort_desc) ? $field_info->sort_desc : 0;?>
2352
+                            <?php $value = (isset($field_info->sort_desc) && $field_info->sort_desc) ? $field_info->sort_desc : 0; ?>
2353 2353
 
2354 2354
                             <label for="desc" class="gd-cf-tooltip-wrap">
2355 2355
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show Descending Sort (high to low)', 'geodirectory'); ?>
@@ -2359,24 +2359,24 @@  discard block
 block discarded – undo
2359 2359
                             </label>
2360 2360
                             <div class="gd-cf-input-wrap gd-switch">
2361 2361
 
2362
-                                <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled"  value="1"
2362
+                                <input type="radio" id="desc_yes<?php echo $radio_id; ?>" name="desc" class="gdri-enabled"  value="1"
2363 2363
                                     <?php if ($value == '1') {
2364 2364
                                         echo 'checked';
2365 2365
                                     } ?>/>
2366
-                                <label onclick="show_hide_radio(this,'show','cfs-desc-title');" for="desc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2366
+                                <label onclick="show_hide_radio(this,'show','cfs-desc-title');" for="desc_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2367 2367
 
2368
-                                <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0"
2368
+                                <input type="radio" id="desc_no<?php echo $radio_id; ?>" name="desc" class="gdri-disabled" value="0"
2369 2369
                                     <?php if ($value == '0' || !$value) {
2370 2370
                                         echo 'checked';
2371 2371
                                     } ?>/>
2372
-                                <label onclick="show_hide_radio(this,'hide','cfs-desc-title');" for="desc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2372
+                                <label onclick="show_hide_radio(this,'hide','cfs-desc-title');" for="desc_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2373 2373
 
2374 2374
                             </div>
2375 2375
 
2376 2376
                         </li>
2377 2377
 
2378
-                        <li class="cfs-desc-title" <?php if ((isset($field_info->sort_desc) && $field_info->sort_desc == '0') || !isset($field_info->sort_desc)) {echo "style='display:none;'";}?>>
2379
-                            <?php $value = (isset($field_info->desc_title) && $field_info->desc_title) ? esc_attr($field_info->desc_title) : '';?>
2378
+                        <li class="cfs-desc-title" <?php if ((isset($field_info->sort_desc) && $field_info->sort_desc == '0') || !isset($field_info->sort_desc)) {echo "style='display:none;'"; }?>>
2379
+                            <?php $value = (isset($field_info->desc_title) && $field_info->desc_title) ? esc_attr($field_info->desc_title) : ''; ?>
2380 2380
 
2381 2381
                             <label for="desc_title" class="gd-cf-tooltip-wrap">
2382 2382
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Descending title', 'geodirectory'); ?>
@@ -2386,13 +2386,13 @@  discard block
 block discarded – undo
2386 2386
                             </label>
2387 2387
                             <div class="gd-cf-input-wrap">
2388 2388
 
2389
-                                <input type="text" name="desc_title" id="desc_title" value="<?php echo $value;?>" />
2389
+                                <input type="text" name="desc_title" id="desc_title" value="<?php echo $value; ?>" />
2390 2390
                             </div>
2391 2391
 
2392 2392
 
2393 2393
                         </li>
2394 2394
 
2395
-                        <li class="cfs-desc-title" <?php if ((isset($field_info->sort_desc) && $field_info->sort_desc == '0') || !isset($field_info->sort_desc)) {echo "style='display:none;'";}?>>
2395
+                        <li class="cfs-desc-title" <?php if ((isset($field_info->sort_desc) && $field_info->sort_desc == '0') || !isset($field_info->sort_desc)) {echo "style='display:none;'"; }?>>
2396 2396
 
2397 2397
                             <label for="is_default" class="gd-cf-tooltip-wrap">
2398 2398
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Default sort?', 'geodirectory'); ?>
@@ -2403,7 +2403,7 @@  discard block
 block discarded – undo
2403 2403
                             <div class="gd-cf-input-wrap">
2404 2404
 
2405 2405
                                 <input type="radio" name="is_default"
2406
-                                       value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
2406
+                                       value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name.'_desc') {
2407 2407
                                     echo 'checked="checked"';
2408 2408
                                 } ?>/>
2409 2409
                             </div>
@@ -2428,14 +2428,14 @@  discard block
 block discarded – undo
2428 2428
                             </label>
2429 2429
                             <div class="gd-cf-input-wrap">
2430 2430
 
2431
-                                <input type="text" name="site_title" id="site_title" value="<?php echo $value;?>" />
2431
+                                <input type="text" name="site_title" id="site_title" value="<?php echo $value; ?>" />
2432 2432
                             </div>
2433 2433
 
2434 2434
 
2435 2435
                         </li>
2436 2436
 
2437 2437
                         <li>
2438
-                            <?php $value = (isset($field_info->is_default) && $field_info->is_default) ? esc_attr($field_info->is_default) : '';?>
2438
+                            <?php $value = (isset($field_info->is_default) && $field_info->is_default) ? esc_attr($field_info->is_default) : ''; ?>
2439 2439
 
2440 2440
                             <label for="is_default" class="gd-cf-tooltip-wrap">
2441 2441
                                 <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Default sort?', 'geodirectory'); ?>
@@ -2459,7 +2459,7 @@  discard block
 block discarded – undo
2459 2459
 
2460 2460
 
2461 2461
                     <li>
2462
-                        <?php $value = (isset($field_info->is_active) && $field_info->is_active) ? $field_info->is_active: 0;?>
2462
+                        <?php $value = (isset($field_info->is_active) && $field_info->is_active) ? $field_info->is_active : 0; ?>
2463 2463
 
2464 2464
                         <label for="is_active" class="gd-cf-tooltip-wrap">
2465 2465
                             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Is active', 'geodirectory'); ?>
@@ -2469,17 +2469,17 @@  discard block
 block discarded – undo
2469 2469
                         </label>
2470 2470
                         <div class="gd-cf-input-wrap gd-switch">
2471 2471
 
2472
-                            <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled"  value="1"
2472
+                            <input type="radio" id="is_active_yes<?php echo $radio_id; ?>" name="is_active" class="gdri-enabled"  value="1"
2473 2473
                                 <?php if ($value == '1') {
2474 2474
                                     echo 'checked';
2475 2475
                                 } ?>/>
2476
-                            <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2476
+                            <label for="is_active_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2477 2477
 
2478
-                            <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0"
2478
+                            <input type="radio" id="is_active_no<?php echo $radio_id; ?>" name="is_active" class="gdri-disabled" value="0"
2479 2479
                                 <?php if ($value == '0' || !$value) {
2480 2480
                                     echo 'checked';
2481 2481
                                 } ?>/>
2482
-                            <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2482
+                            <label for="is_active_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2483 2483
 
2484 2484
                         </div>
2485 2485
 
@@ -2500,10 +2500,10 @@  discard block
 block discarded – undo
2500 2500
                             <h3></h3>
2501 2501
                         </label>
2502 2502
                         <div class="gd-cf-input-wrap">
2503
-                            <input type="button" class="button button-primary" name="save" id="save" value="<?php echo esc_attr(__('Save','geodirectory'));?>"
2503
+                            <input type="button" class="button button-primary" name="save" id="save" value="<?php echo esc_attr(__('Save', 'geodirectory')); ?>"
2504 2504
                                    onclick="save_sort_field('<?php echo esc_attr($result_str); ?>')"/>
2505
-                                <a href="javascript:void(0)"><input type="button" name="delete" value="<?php echo esc_attr(__('Delete','geodirectory'));?>"
2506
-                                                                    onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
2505
+                                <a href="javascript:void(0)"><input type="button" name="delete" value="<?php echo esc_attr(__('Delete', 'geodirectory')); ?>"
2506
+                                                                    onclick="delete_sort_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>', this)"
2507 2507
                                                                     class="button"/></a>
2508 2508
                         </div>
2509 2509
                     </li>
@@ -2538,7 +2538,7 @@  discard block
 block discarded – undo
2538 2538
         if (!$package_id || !$field_name || !$post_type) {
2539 2539
             return true;
2540 2540
         }
2541
-        $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2541
+        $sql = $wpdb->prepare("SELECT id FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int) $package_id));
2542 2542
 
2543 2543
         if ($wpdb->get_var($sql)) {
2544 2544
             return true;
@@ -2661,13 +2661,13 @@  discard block
 block discarded – undo
2661 2661
 }
2662 2662
 
2663 2663
 
2664
-function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){
2664
+function geodir_cfa_data_type_text($output, $result_str, $cf, $field_info) {
2665 2665
     ob_start();
2666 2666
 
2667 2667
     $dt_value = '';
2668 2668
     if (isset($field_info->data_type)) {
2669 2669
         $dt_value  = esc_attr($field_info->data_type);
2670
-    }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2670
+    }elseif (isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']) {
2671 2671
         $dt_value  = $cf['defaults']['data_type'];
2672 2672
     }
2673 2673
     ?>
@@ -2678,15 +2678,15 @@  discard block
 block discarded – undo
2678 2678
             <select name="data_type" id="data_type"
2679 2679
                     onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');">
2680 2680
                 <option
2681
-                    value="XVARCHAR" <?php if ($dt_value  == 'VARCHAR') {
2681
+                    value="XVARCHAR" <?php if ($dt_value == 'VARCHAR') {
2682 2682
                     echo 'selected="selected"';
2683 2683
                 } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2684 2684
                 <option
2685
-                    value="INT" <?php if ($dt_value   == 'INT') {
2685
+                    value="INT" <?php if ($dt_value == 'INT') {
2686 2686
                     echo 'selected="selected"';
2687 2687
                 } ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2688 2688
                 <option
2689
-                    value="FLOAT" <?php if ($dt_value   == 'FLOAT') {
2689
+                    value="FLOAT" <?php if ($dt_value == 'FLOAT') {
2690 2690
                     echo 'selected="selected"';
2691 2691
                 } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2692 2692
             </select>
@@ -2699,13 +2699,13 @@  discard block
 block discarded – undo
2699 2699
     $value = '';
2700 2700
     if (isset($field_info->decimal_point)) {
2701 2701
         $value = esc_attr($field_info->decimal_point);
2702
-    }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2702
+    }elseif (isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']) {
2703 2703
         $value = $cf['defaults']['decimal_point'];
2704 2704
     }
2705 2705
     ?>
2706 2706
 
2707 2707
     <li class="decimal-point-wrapper"
2708
-        style="<?php echo ($dt_value  == 'FLOAT') ? '' : 'display:none' ?>">
2708
+        style="<?php echo ($dt_value == 'FLOAT') ? '' : 'display:none' ?>">
2709 2709
         <label for="decimal_point"><?php _e('Select decimal point :', 'geodirectory'); ?></label>
2710 2710
         <div class="gd-cf-input-wrap">
2711 2711
             <select name="decimal_point" id="decimal_point">
@@ -2723,41 +2723,41 @@  discard block
 block discarded – undo
2723 2723
     $output = ob_get_clean();
2724 2724
     return $output;
2725 2725
 }
2726
-add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4);
2726
+add_filter('geodir_cfa_data_type_text', 'geodir_cfa_data_type_text', 10, 4);
2727 2727
 
2728 2728
 // htmlvar not needed for fieldset and taxonomy
2729
-add_filter('geodir_cfa_htmlvar_name_fieldset','__return_empty_string',10,4);
2730
-add_filter('geodir_cfa_htmlvar_name_taxonomy','__return_empty_string',10,4);
2729
+add_filter('geodir_cfa_htmlvar_name_fieldset', '__return_empty_string', 10, 4);
2730
+add_filter('geodir_cfa_htmlvar_name_taxonomy', '__return_empty_string', 10, 4);
2731 2731
 
2732 2732
 
2733 2733
 // default_value not needed for textarea, html, file, fieldset, taxonomy, address
2734
-add_filter('geodir_cfa_default_value_file','__return_empty_string',10,4);
2735
-add_filter('geodir_cfa_default_value_taxonomy','__return_empty_string',10,4);
2736
-add_filter('geodir_cfa_default_value_address','__return_empty_string',10,4);
2737
-add_filter('geodir_cfa_default_value_fieldset','__return_empty_string',10,4);
2734
+add_filter('geodir_cfa_default_value_file', '__return_empty_string', 10, 4);
2735
+add_filter('geodir_cfa_default_value_taxonomy', '__return_empty_string', 10, 4);
2736
+add_filter('geodir_cfa_default_value_address', '__return_empty_string', 10, 4);
2737
+add_filter('geodir_cfa_default_value_fieldset', '__return_empty_string', 10, 4);
2738 2738
 
2739 2739
 // is_required not needed for fieldset
2740
-add_filter('geodir_cfa_is_required_fieldset','__return_empty_string',10,4);
2741
-add_filter('geodir_cfa_required_msg_fieldset','__return_empty_string',10,4);
2740
+add_filter('geodir_cfa_is_required_fieldset', '__return_empty_string', 10, 4);
2741
+add_filter('geodir_cfa_required_msg_fieldset', '__return_empty_string', 10, 4);
2742 2742
 
2743 2743
 // field_icon not needed for fieldset
2744
-add_filter('geodir_cfa_field_icon_fieldset','__return_empty_string',10,4);
2745
-add_filter('geodir_cfa_css_class_fieldset','__return_empty_string',10,4);
2744
+add_filter('geodir_cfa_field_icon_fieldset', '__return_empty_string', 10, 4);
2745
+add_filter('geodir_cfa_css_class_fieldset', '__return_empty_string', 10, 4);
2746 2746
 
2747 2747
 // cat_sort not needed for some fields
2748
-add_filter('geodir_cfa_cat_sort_html','__return_empty_string',10,4);
2749
-add_filter('geodir_cfa_cat_sort_file','__return_empty_string',10,4);
2750
-add_filter('geodir_cfa_cat_sort_url','__return_empty_string',10,4);
2751
-add_filter('geodir_cfa_cat_sort_fieldset','__return_empty_string',10,4);
2752
-add_filter('geodir_cfa_cat_sort_multiselect','__return_empty_string',10,4);
2753
-add_filter('geodir_cfa_cat_sort_textarea','__return_empty_string',10,4);
2754
-add_filter('geodir_cfa_cat_sort_taxonomy','__return_empty_string',10,4);
2755
-add_filter('geodir_cfa_cat_sort_address','__return_empty_string',10,4);
2748
+add_filter('geodir_cfa_cat_sort_html', '__return_empty_string', 10, 4);
2749
+add_filter('geodir_cfa_cat_sort_file', '__return_empty_string', 10, 4);
2750
+add_filter('geodir_cfa_cat_sort_url', '__return_empty_string', 10, 4);
2751
+add_filter('geodir_cfa_cat_sort_fieldset', '__return_empty_string', 10, 4);
2752
+add_filter('geodir_cfa_cat_sort_multiselect', '__return_empty_string', 10, 4);
2753
+add_filter('geodir_cfa_cat_sort_textarea', '__return_empty_string', 10, 4);
2754
+add_filter('geodir_cfa_cat_sort_taxonomy', '__return_empty_string', 10, 4);
2755
+add_filter('geodir_cfa_cat_sort_address', '__return_empty_string', 10, 4);
2756 2756
 
2757 2757
 
2758 2758
 
2759
-function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){
2760
-    if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2759
+function geodir_cfa_advanced_editor_geodir_special_offers($output, $result_str, $cf, $field_info) {
2760
+    if ($field_info->htmlvar_name != 'geodir_special_offers') {return ''; }
2761 2761
     ob_start();
2762 2762
     ?>
2763 2763
     <li>
@@ -2788,16 +2788,16 @@  discard block
 block discarded – undo
2788 2788
     $output = ob_get_clean();
2789 2789
     return $output;
2790 2790
 }
2791
-add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4);
2791
+add_filter('geodir_cfa_advanced_editor_textarea', 'geodir_cfa_advanced_editor_geodir_special_offers', 10, 4);
2792 2792
 
2793 2793
 
2794
-function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){
2794
+function geodir_cfa_validation_pattern_text($output, $result_str, $cf, $field_info) {
2795 2795
     ob_start();
2796 2796
 
2797 2797
     $value = '';
2798 2798
     if (isset($field_info->validation_pattern)) {
2799 2799
         $value = esc_attr($field_info->validation_pattern);
2800
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2800
+    }elseif (isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']) {
2801 2801
         $value = esc_attr($cf['defaults']['validation_pattern']);
2802 2802
     }
2803 2803
     ?>
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
     $value = '';
2818 2818
     if (isset($field_info->validation_msg)) {
2819 2819
         $value = esc_attr($field_info->validation_msg);
2820
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2820
+    }elseif (isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']) {
2821 2821
         $value = esc_attr($cf['defaults']['validation_msg']);
2822 2822
     }
2823 2823
     ?>
@@ -2838,10 +2838,10 @@  discard block
 block discarded – undo
2838 2838
     $output = ob_get_clean();
2839 2839
     return $output;
2840 2840
 }
2841
-add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4);
2841
+add_filter('geodir_cfa_validation_pattern_text', 'geodir_cfa_validation_pattern_text', 10, 4);
2842 2842
 
2843 2843
 
2844
-function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){
2844
+function geodir_cfa_htmlvar_name_taxonomy($output, $result_str, $cf, $field_info) {
2845 2845
     ob_start();
2846 2846
     global $post_type;
2847 2847
 
@@ -2866,7 +2866,7 @@  discard block
 block discarded – undo
2866 2866
                     ?>
2867 2867
                     <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) {
2868 2868
                         echo 'selected="selected"';
2869
-                    }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2869
+                    }?> id="<?php echo $gd_tax; ?>"><?php echo $gd_tax; ?></option><?php
2870 2870
                 }
2871 2871
                 ?>
2872 2872
             </select>
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
         <label for="cat_display_type" class="gd-cf-tooltip-wrap">
2878 2878
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Category display type :', 'geodirectory'); ?>
2879 2879
             <div class="gdcf-tooltip">
2880
-                <?php _e('Show categories list as select, multiselect, checkbox or radio', 'geodirectory');?>
2880
+                <?php _e('Show categories list as select, multiselect, checkbox or radio', 'geodirectory'); ?>
2881 2881
             </div>
2882 2882
         </label>
2883 2883
         <div class="gd-cf-input-wrap">
@@ -2885,19 +2885,19 @@  discard block
 block discarded – undo
2885 2885
             <select name="cat_display_type" id="cat_display_type">
2886 2886
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') {
2887 2887
                     echo 'selected="selected"';
2888
-                }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2888
+                }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory'); ?></option>
2889 2889
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
2890 2890
                     echo 'selected="selected"';
2891
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
2891
+                }?> value="select"><?php _e('Select', 'geodirectory'); ?></option>
2892 2892
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') {
2893 2893
                     echo 'selected="selected"';
2894
-                }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2894
+                }?> value="multiselect"><?php _e('Multiselect', 'geodirectory'); ?></option>
2895 2895
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
2896 2896
                     echo 'selected="selected"';
2897
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2897
+                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory'); ?></option>
2898 2898
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
2899 2899
                     echo 'selected="selected"';
2900
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2900
+                }?> value="radio"><?php _e('Radio', 'geodirectory'); ?></option>
2901 2901
             </select>
2902 2902
         </div>
2903 2903
     </li>
@@ -2906,10 +2906,10 @@  discard block
 block discarded – undo
2906 2906
     $output = ob_get_clean();
2907 2907
     return $output;
2908 2908
 }
2909
-add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4);
2909
+add_filter('geodir_cfa_htmlvar_name_taxonomy', 'geodir_cfa_htmlvar_name_taxonomy', 10, 4);
2910 2910
 
2911 2911
 
2912
-function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){
2912
+function geodir_cfa_extra_fields_address($output, $result_str, $cf, $field_info) {
2913 2913
 
2914 2914
     ob_start();
2915 2915
     if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
@@ -2932,32 +2932,32 @@  discard block
 block discarded – undo
2932 2932
         <label for="show_zip" class="gd-cf-tooltip-wrap">
2933 2933
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display zip/post code :', 'geodirectory'); ?>
2934 2934
             <div class="gdcf-tooltip">
2935
-                <?php _e('Select if you want to show zip/post code field in address section.', 'geodirectory');?>
2935
+                <?php _e('Select if you want to show zip/post code field in address section.', 'geodirectory'); ?>
2936 2936
             </div>
2937 2937
         </label>
2938 2938
         <div class="gd-cf-input-wrap gd-switch">
2939 2939
 
2940
-            <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled"  value="1"
2940
+            <input type="radio" id="show_zip_yes<?php echo $radio_id; ?>" name="extra[show_zip]" class="gdri-enabled"  value="1"
2941 2941
                 <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') {
2942 2942
                     echo 'checked';
2943 2943
                 } ?>/>
2944
-            <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2944
+            <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2945 2945
 
2946
-            <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0"
2946
+            <input type="radio" id="show_zip_no<?php echo $radio_id; ?>" name="extra[show_zip]" class="gdri-disabled" value="0"
2947 2947
                 <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {
2948 2948
                     echo 'checked';
2949 2949
                 } ?>/>
2950
-            <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2950
+            <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2951 2951
 
2952 2952
 
2953 2953
         </div>
2954 2954
     </li>
2955 2955
 
2956
-    <li class="cf-zip-lable"  <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {echo "style='display:none;'";}?> >
2956
+    <li class="cf-zip-lable"  <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {echo "style='display:none;'"; }?> >
2957 2957
         <label for="zip_lable" class="gd-cf-tooltip-wrap">
2958 2958
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Zip/Post code label :', 'geodirectory'); ?>
2959 2959
             <div class="gdcf-tooltip">
2960
-                <?php _e('Enter zip/post code field label in address section.', 'geodirectory');?>
2960
+                <?php _e('Enter zip/post code field label in address section.', 'geodirectory'); ?>
2961 2961
             </div>
2962 2962
         </label>
2963 2963
         <div class="gd-cf-input-wrap">
@@ -2975,7 +2975,7 @@  discard block
 block discarded – undo
2975 2975
         <label for="map_lable" class="gd-cf-tooltip-wrap">
2976 2976
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Map button label :', 'geodirectory'); ?>
2977 2977
             <div class="gdcf-tooltip">
2978
-                <?php _e('Enter text for `set address on map` button in address section.', 'geodirectory');?>
2978
+                <?php _e('Enter text for `set address on map` button in address section.', 'geodirectory'); ?>
2979 2979
             </div>
2980 2980
         </label>
2981 2981
         <div class="gd-cf-input-wrap">
@@ -2990,22 +2990,22 @@  discard block
 block discarded – undo
2990 2990
         <label for="show_mapzoom" class="gd-cf-tooltip-wrap">
2991 2991
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Use user zoom level:', 'geodirectory'); ?>
2992 2992
             <div class="gdcf-tooltip">
2993
-                <?php _e('Do you want to use the user defined map zoom level from the add listing page?', 'geodirectory');?>
2993
+                <?php _e('Do you want to use the user defined map zoom level from the add listing page?', 'geodirectory'); ?>
2994 2994
             </div>
2995 2995
         </label>
2996 2996
         <div class="gd-cf-input-wrap gd-switch">
2997 2997
 
2998
-            <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled"  value="1"
2998
+            <input type="radio" id="show_mapzoom_yes<?php echo $radio_id; ?>" name="extra[show_mapzoom]" class="gdri-enabled"  value="1"
2999 2999
                 <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') {
3000 3000
                     echo 'checked';
3001 3001
                 } ?>/>
3002
-            <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3002
+            <label for="show_mapzoom_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3003 3003
 
3004
-            <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0"
3004
+            <input type="radio" id="show_mapzoom_no<?php echo $radio_id; ?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0"
3005 3005
                 <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) {
3006 3006
                     echo 'checked';
3007 3007
                 } ?>/>
3008
-            <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3008
+            <label for="show_mapzoom_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3009 3009
 
3010 3010
         </div>
3011 3011
     </li>
@@ -3014,22 +3014,22 @@  discard block
 block discarded – undo
3014 3014
         <label for="show_mapview" class="gd-cf-tooltip-wrap">
3015 3015
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display map view:', 'geodirectory'); ?>
3016 3016
             <div class="gdcf-tooltip">
3017
-                <?php _e('Select if you want to `set default map` options in address section. ( Satellite Map, Hybrid Map, Terrain Map)', 'geodirectory');?>
3017
+                <?php _e('Select if you want to `set default map` options in address section. ( Satellite Map, Hybrid Map, Terrain Map)', 'geodirectory'); ?>
3018 3018
             </div>
3019 3019
         </label>
3020 3020
         <div class="gd-cf-input-wrap gd-switch">
3021 3021
 
3022
-            <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled"  value="1"
3022
+            <input type="radio" id="show_mapview_yes<?php echo $radio_id; ?>" name="extra[show_mapview]" class="gdri-enabled"  value="1"
3023 3023
                 <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') {
3024 3024
                     echo 'checked';
3025 3025
                 } ?>/>
3026
-            <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3026
+            <label for="show_mapview_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3027 3027
 
3028
-            <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0"
3028
+            <input type="radio" id="show_mapview_no<?php echo $radio_id; ?>" name="extra[show_mapview]" class="gdri-disabled" value="0"
3029 3029
                 <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) {
3030 3030
                     echo 'checked';
3031 3031
                 } ?>/>
3032
-            <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3032
+            <label for="show_mapview_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3033 3033
 
3034 3034
         </div>
3035 3035
     </li>
@@ -3039,7 +3039,7 @@  discard block
 block discarded – undo
3039 3039
         <label for="mapview_lable" class="gd-cf-tooltip-wrap">
3040 3040
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Map view label:', 'geodirectory'); ?>
3041 3041
             <div class="gdcf-tooltip">
3042
-                <?php _e('Enter mapview field label in address section.', 'geodirectory');?>
3042
+                <?php _e('Enter mapview field label in address section.', 'geodirectory'); ?>
3043 3043
             </div>
3044 3044
         </label>
3045 3045
         <div class="gd-cf-input-wrap">
@@ -3053,22 +3053,22 @@  discard block
 block discarded – undo
3053 3053
         <label for="show_latlng" class="gd-cf-tooltip-wrap">
3054 3054
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show latitude and longitude', 'geodirectory'); ?>
3055 3055
             <div class="gdcf-tooltip">
3056
-                <?php _e('This will show/hide the longitude fields in the address section add listing form.', 'geodirectory');?>
3056
+                <?php _e('This will show/hide the longitude fields in the address section add listing form.', 'geodirectory'); ?>
3057 3057
             </div>
3058 3058
         </label>
3059 3059
         <div class="gd-cf-input-wrap gd-switch">
3060 3060
 
3061
-            <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled"  value="1"
3061
+            <input type="radio" id="show_latlng_yes<?php echo $radio_id; ?>" name="extra[show_latlng]" class="gdri-enabled"  value="1"
3062 3062
                 <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') {
3063 3063
                     echo 'checked';
3064 3064
                 } ?>/>
3065
-            <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3065
+            <label for="show_latlng_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3066 3066
 
3067
-            <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0"
3067
+            <input type="radio" id="show_latlng_no<?php echo $radio_id; ?>" name="extra[show_latlng]" class="gdri-disabled" value="0"
3068 3068
                 <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) {
3069 3069
                     echo 'checked';
3070 3070
                 } ?>/>
3071
-            <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3071
+            <label for="show_latlng_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3072 3072
 
3073 3073
         </div>
3074 3074
     </li>
@@ -3077,17 +3077,17 @@  discard block
 block discarded – undo
3077 3077
     $html = ob_get_clean();
3078 3078
     return $output.$html;
3079 3079
 }
3080
-add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4);
3080
+add_filter('geodir_cfa_extra_fields_address', 'geodir_cfa_extra_fields_address', 10, 4);
3081 3081
 
3082 3082
 
3083
-function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){
3083
+function geodir_cfa_extra_fields_multiselect($output, $result_str, $cf, $field_info) {
3084 3084
     ob_start();
3085 3085
     ?>
3086 3086
     <li>
3087 3087
         <label for="multi_display_type" class="gd-cf-tooltip-wrap">
3088 3088
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?>
3089 3089
             <div class="gdcf-tooltip">
3090
-                <?php _e('Show multiselect list as multiselect,checkbox or radio.', 'geodirectory');?>
3090
+                <?php _e('Show multiselect list as multiselect,checkbox or radio.', 'geodirectory'); ?>
3091 3091
             </div>
3092 3092
         </label>
3093 3093
         <div class="gd-cf-input-wrap">
@@ -3095,13 +3095,13 @@  discard block
 block discarded – undo
3095 3095
             <select name="multi_display_type" id="multi_display_type">
3096 3096
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
3097 3097
                     echo 'selected="selected"';
3098
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
3098
+                }?> value="select"><?php _e('Select', 'geodirectory'); ?></option>
3099 3099
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
3100 3100
                     echo 'selected="selected"';
3101
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
3101
+                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory'); ?></option>
3102 3102
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
3103 3103
                     echo 'selected="selected"';
3104
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
3104
+                }?> value="radio"><?php _e('Radio', 'geodirectory'); ?></option>
3105 3105
             </select>
3106 3106
 
3107 3107
             <br/>
@@ -3112,17 +3112,17 @@  discard block
 block discarded – undo
3112 3112
     $html = ob_get_clean();
3113 3113
     return $output.$html;
3114 3114
 }
3115
-add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4);
3115
+add_filter('geodir_cfa_extra_fields_multiselect', 'geodir_cfa_extra_fields_multiselect', 10, 4);
3116 3116
 
3117 3117
 
3118
-function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){
3118
+function geodir_cfa_extra_fields_smr($output, $result_str, $cf, $field_info) {
3119 3119
 
3120 3120
     ob_start();
3121 3121
 
3122 3122
     $value = '';
3123 3123
     if (isset($field_info->option_values)) {
3124 3124
         $value = esc_attr($field_info->option_values);
3125
-    }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3125
+    }elseif (isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']) {
3126 3126
         $value = esc_attr($cf['defaults']['option_values']);
3127 3127
     }
3128 3128
 
@@ -3132,11 +3132,11 @@  discard block
 block discarded – undo
3132 3132
         <label for="option_values" class="gd-cf-tooltip-wrap">
3133 3133
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?>
3134 3134
             <div class="gdcf-tooltip">
3135
-                <span><?php _e('Option Values should be separated by comma.', 'geodirectory');?></span>
3135
+                <span><?php _e('Option Values should be separated by comma.', 'geodirectory'); ?></span>
3136 3136
                 <br/>
3137
-                <small><span><?php _e('If using for a "tick filter" place a / and then either a 1 for true or 0 for false', 'geodirectory');?></span>
3137
+                <small><span><?php _e('If using for a "tick filter" place a / and then either a 1 for true or 0 for false', 'geodirectory'); ?></span>
3138 3138
                     <br/>
3139
-                    <span><?php _e('eg: "No Dogs Allowed/0,Dogs Allowed/1" (Select only, not multiselect)', 'geodirectory');?></span>
3139
+                    <span><?php _e('eg: "No Dogs Allowed/0,Dogs Allowed/1" (Select only, not multiselect)', 'geodirectory'); ?></span>
3140 3140
                     <?php if ($field_type == 'multiselect' || $field_type == 'select') { ?>
3141 3141
                         <br/>
3142 3142
                         <span><?php _e('- If using OPTGROUP tag to grouping options, use "{optgroup}OPTGROUP-LABEL|OPTION-1,OPTION-2{/optgroup}"', 'geodirectory'); ?></span>
@@ -3147,7 +3147,7 @@  discard block
 block discarded – undo
3147 3147
         </label>
3148 3148
         <div class="gd-cf-input-wrap">
3149 3149
             <input type="text" name="option_values" id="option_values"
3150
-                   value="<?php echo $value;?>"/>
3150
+                   value="<?php echo $value; ?>"/>
3151 3151
             <br/>
3152 3152
 
3153 3153
         </div>
@@ -3157,12 +3157,12 @@  discard block
 block discarded – undo
3157 3157
     $html = ob_get_clean();
3158 3158
     return $output.$html;
3159 3159
 }
3160
-add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4);
3161
-add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4);
3162
-add_filter('geodir_cfa_extra_fields_radio','geodir_cfa_extra_fields_smr',10,4);
3160
+add_filter('geodir_cfa_extra_fields_multiselect', 'geodir_cfa_extra_fields_smr', 10, 4);
3161
+add_filter('geodir_cfa_extra_fields_select', 'geodir_cfa_extra_fields_smr', 10, 4);
3162
+add_filter('geodir_cfa_extra_fields_radio', 'geodir_cfa_extra_fields_smr', 10, 4);
3163 3163
 
3164 3164
 
3165
-function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){
3165
+function geodir_cfa_extra_fields_datepicker($output, $result_str, $cf, $field_info) {
3166 3166
     ob_start();
3167 3167
     $extra = array();
3168 3168
     if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
         <label for="date_format" class="gd-cf-tooltip-wrap">
3174 3174
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?>
3175 3175
             <div class="gdcf-tooltip">
3176
-                <?php _e('Select the date format.', 'geodirectory');?>
3176
+                <?php _e('Select the date format.', 'geodirectory'); ?>
3177 3177
             </div>
3178 3178
         </label>
3179 3179
         <div class="gd-cf-input-wrap" style="overflow:inherit;">
@@ -3193,16 +3193,16 @@  discard block
 block discarded – undo
3193 3193
              * @since 1.6.5
3194 3194
              * @param array $date_formats The PHP date format array.
3195 3195
              */
3196
-            $date_formats = apply_filters('geodir_date_formats',$date_formats);
3196
+            $date_formats = apply_filters('geodir_date_formats', $date_formats);
3197 3197
             ?>
3198 3198
             <select name="extra[date_format]" id="date_format">
3199 3199
                 <?php
3200
-                foreach($date_formats as $format){
3200
+                foreach ($date_formats as $format) {
3201 3201
                     $selected = '';
3202
-                    if(!empty($extra) && esc_attr($extra['date_format'])==$format){
3202
+                    if (!empty($extra) && esc_attr($extra['date_format']) == $format) {
3203 3203
                         $selected = "selected='selected'";
3204 3204
                     }
3205
-                    echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3205
+                    echo "<option $selected value='$format'>$format       (".date_i18n($format, time()).")</option>";
3206 3206
                 }
3207 3207
                 ?>
3208 3208
             </select>
@@ -3214,10 +3214,10 @@  discard block
 block discarded – undo
3214 3214
     $html = ob_get_clean();
3215 3215
     return $output.$html;
3216 3216
 }
3217
-add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4);
3217
+add_filter('geodir_cfa_extra_fields_datepicker', 'geodir_cfa_extra_fields_datepicker', 10, 4);
3218 3218
 
3219 3219
 
3220
-function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){
3220
+function geodir_cfa_extra_fields_file($output, $result_str, $cf, $field_info) {
3221 3221
     ob_start();
3222 3222
     $allowed_file_types = geodir_allowed_mime_types();
3223 3223
 
@@ -3228,16 +3228,16 @@  discard block
 block discarded – undo
3228 3228
         <label for="gd_file_types" class="gd-cf-tooltip-wrap">
3229 3229
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?>
3230 3230
             <div class="gdcf-tooltip">
3231
-                <?php _e('Select file types to allowed for file uploading. (Select multiple file types by holding down "Ctrl" key.)', 'geodirectory');?>
3231
+                <?php _e('Select file types to allowed for file uploading. (Select multiple file types by holding down "Ctrl" key.)', 'geodirectory'); ?>
3232 3232
             </div>
3233 3233
         </label>
3234 3234
         <div class="gd-cf-input-wrap">
3235 3235
             <select name="extra[gd_file_types][]" id="gd_file_types" multiple="multiple" style="height:100px;width:90%;">
3236
-                <option value="*" <?php selected(true, in_array('*', $gd_file_types));?>><?php _e('All types', 'geodirectory') ;?></option>
3237
-                <?php foreach ( $allowed_file_types as $format => $types ) { ?>
3238
-                    <optgroup label="<?php echo esc_attr( wp_sprintf(__('%s formats', 'geodirectory'), __($format, 'geodirectory') ) ) ;?>">
3239
-                        <?php foreach ( $types as $ext => $type ) { ?>
3240
-                            <option value="<?php echo esc_attr($ext) ;?>" <?php selected(true, in_array($ext, $gd_file_types));?>><?php echo '.' . $ext ;?></option>
3236
+                <option value="*" <?php selected(true, in_array('*', $gd_file_types)); ?>><?php _e('All types', 'geodirectory'); ?></option>
3237
+                <?php foreach ($allowed_file_types as $format => $types) { ?>
3238
+                    <optgroup label="<?php echo esc_attr(wp_sprintf(__('%s formats', 'geodirectory'), __($format, 'geodirectory'))); ?>">
3239
+                        <?php foreach ($types as $ext => $type) { ?>
3240
+                            <option value="<?php echo esc_attr($ext); ?>" <?php selected(true, in_array($ext, $gd_file_types)); ?>><?php echo '.'.$ext; ?></option>
3241 3241
                         <?php } ?>
3242 3242
                     </optgroup>
3243 3243
                 <?php } ?>
@@ -3249,9 +3249,9 @@  discard block
 block discarded – undo
3249 3249
     $html = ob_get_clean();
3250 3250
     return $output.$html;
3251 3251
 }
3252
-add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4);
3252
+add_filter('geodir_cfa_extra_fields_file', 'geodir_cfa_extra_fields_file', 10, 4);
3253 3253
 
3254
-function geodir_cfa_extra_fields_text($output,$result_str,$cf,$field_info){
3254
+function geodir_cfa_extra_fields_text($output, $result_str, $cf, $field_info) {
3255 3255
     ob_start();
3256 3256
 
3257 3257
     $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
@@ -3265,15 +3265,15 @@  discard block
 block discarded – undo
3265 3265
     $value = '';
3266 3266
     if ($extra_fields && isset($extra_fields['is_price'])) {
3267 3267
     $value = esc_attr($extra_fields['is_price']);
3268
-    }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3268
+    }elseif (isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']) {
3269 3269
     $value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3270 3270
     }
3271 3271
 
3272
-    $show_price_extra = ($value==1) ? 1 : 0;
3272
+    $show_price_extra = ($value == 1) ? 1 : 0;
3273 3273
 
3274
-    $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0;
3274
+    $show_price = (isset($field_info->data_type) && ($field_info->data_type == 'INT' && $field_info->data_type == 'FLOAT')) ? 1 : 0;
3275 3275
     ?>
3276
-    <li class="gdcf-price-extra-set" <?php if(!$show_price){ echo "style='display:none;'";}?>>
3276
+    <li class="gdcf-price-extra-set" <?php if (!$show_price) { echo "style='display:none;'"; }?>>
3277 3277
         <label for="is_price" class="gd-cf-tooltip-wrap">
3278 3278
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display as price? :', 'geodirectory'); ?>
3279 3279
             <div class="gdcf-tooltip">
@@ -3282,17 +3282,17 @@  discard block
 block discarded – undo
3282 3282
         </label>
3283 3283
         <div class="gd-cf-input-wrap gd-switch">
3284 3284
 
3285
-            <input type="radio" id="is_price_yes<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-enabled"  value="1"
3285
+            <input type="radio" id="is_price_yes<?php echo $radio_id; ?>" name="extra[is_price]" class="gdri-enabled"  value="1"
3286 3286
                 <?php if ($value == '1') {
3287 3287
                     echo 'checked';
3288 3288
                 } ?>/>
3289
-            <label onclick="show_hide_radio(this,'show','gdcf-price-extra');" for="is_price_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3289
+            <label onclick="show_hide_radio(this,'show','gdcf-price-extra');" for="is_price_yes<?php echo $radio_id; ?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3290 3290
 
3291
-            <input type="radio" id="is_price_no<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-disabled" value="0"
3291
+            <input type="radio" id="is_price_no<?php echo $radio_id; ?>" name="extra[is_price]" class="gdri-disabled" value="0"
3292 3292
                 <?php if ($value == '0' || !$value) {
3293 3293
                     echo 'checked';
3294 3294
                 } ?>/>
3295
-            <label onclick="show_hide_radio(this,'hide','gdcf-price-extra');" for="is_price_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3295
+            <label onclick="show_hide_radio(this,'hide','gdcf-price-extra');" for="is_price_no<?php echo $radio_id; ?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3296 3296
 
3297 3297
         </div>
3298 3298
     </li>
@@ -3302,23 +3302,23 @@  discard block
 block discarded – undo
3302 3302
     $value = '';
3303 3303
     if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3304 3304
         $value = esc_attr($extra_fields['thousand_separator']);
3305
-    }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3305
+    }elseif (isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']) {
3306 3306
         $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3307 3307
     }
3308 3308
     ?>
3309
-    <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3310
-        <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory');?>
3309
+    <li class="gdcf-price-extra" <?php if (!$show_price_extra) { echo "style='display:none;'"; }?>>
3310
+        <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory'); ?>
3311 3311
             <div class="gdcf-tooltip">
3312 3312
                 <?php _e('Select the thousand separator.', 'geodirectory'); ?>
3313 3313
             </div>
3314 3314
         </label>
3315 3315
         <div class="gd-cf-input-wrap">
3316 3316
                 <select name="extra[thousand_separator]" id="thousand_separator">
3317
-                    <option value="comma" <?php selected(true, $value == 'comma');?>><?php _e(', (comma)', 'geodirectory'); ?></option>
3318
-                    <option value="slash" <?php selected(true, $value == "slash");?>><?php _e('\ (slash)', 'geodirectory'); ?></option>
3319
-                    <option value="period" <?php selected(true, $value == 'period');?>><?php _e('. (period)', 'geodirectory'); ?></option>
3320
-                    <option value="space" <?php selected(true, $value == 'space');?>><?php _e(' (space)', 'geodirectory'); ?></option>
3321
-                    <option value="none" <?php selected(true, $value == 'none');?>><?php _e('(none)', 'geodirectory'); ?></option>
3317
+                    <option value="comma" <?php selected(true, $value == 'comma'); ?>><?php _e(', (comma)', 'geodirectory'); ?></option>
3318
+                    <option value="slash" <?php selected(true, $value == "slash"); ?>><?php _e('\ (slash)', 'geodirectory'); ?></option>
3319
+                    <option value="period" <?php selected(true, $value == 'period'); ?>><?php _e('. (period)', 'geodirectory'); ?></option>
3320
+                    <option value="space" <?php selected(true, $value == 'space'); ?>><?php _e(' (space)', 'geodirectory'); ?></option>
3321
+                    <option value="none" <?php selected(true, $value == 'none'); ?>><?php _e('(none)', 'geodirectory'); ?></option>
3322 3322
                 </select>
3323 3323
         </div>
3324 3324
     </li>
@@ -3329,20 +3329,20 @@  discard block
 block discarded – undo
3329 3329
     $value = '';
3330 3330
     if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3331 3331
         $value = esc_attr($extra_fields['decimal_separator']);
3332
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3332
+    }elseif (isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']) {
3333 3333
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3334 3334
     }
3335 3335
     ?>
3336
-    <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3337
-        <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory');?>
3336
+    <li class="gdcf-price-extra" <?php if (!$show_price_extra) { echo "style='display:none;'"; }?>>
3337
+        <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory'); ?>
3338 3338
             <div class="gdcf-tooltip">
3339 3339
                 <?php _e('Select the decimal separator.', 'geodirectory'); ?>
3340 3340
             </div>
3341 3341
         </label>
3342 3342
         <div class="gd-cf-input-wrap">
3343 3343
             <select name="extra[decimal_separator]" id="decimal_separator">
3344
-                <option value="period" <?php selected(true, $value == 'period');?>><?php _e('. (period)', 'geodirectory'); ?></option>
3345
-                <option value="comma" <?php selected(true, $value == "comma");?>><?php _e(', (comma)', 'geodirectory'); ?></option>
3344
+                <option value="period" <?php selected(true, $value == 'period'); ?>><?php _e('. (period)', 'geodirectory'); ?></option>
3345
+                <option value="comma" <?php selected(true, $value == "comma"); ?>><?php _e(', (comma)', 'geodirectory'); ?></option>
3346 3346
             </select>
3347 3347
         </div>
3348 3348
     </li>
@@ -3352,20 +3352,20 @@  discard block
 block discarded – undo
3352 3352
     $value = '';
3353 3353
     if ($extra_fields && isset($extra_fields['decimal_display'])) {
3354 3354
         $value = esc_attr($extra_fields['decimal_display']);
3355
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3355
+    }elseif (isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']) {
3356 3356
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3357 3357
     }
3358 3358
     ?>
3359
-    <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3360
-        <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory');?>
3359
+    <li class="gdcf-price-extra" <?php if (!$show_price_extra) { echo "style='display:none;'"; }?>>
3360
+        <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory'); ?>
3361 3361
             <div class="gdcf-tooltip">
3362 3362
                 <?php _e('Select how the decimal is displayed', 'geodirectory'); ?>
3363 3363
             </div>
3364 3364
         </label>
3365 3365
         <div class="gd-cf-input-wrap">
3366 3366
             <select name="extra[decimal_display]" id="decimal_display">
3367
-                <option value="if" <?php selected(true, $value == 'if');?>><?php _e('If used (not .00)', 'geodirectory'); ?></option>
3368
-                <option value="allways" <?php selected(true, $value == "allways");?>><?php _e('Always (.00)', 'geodirectory'); ?></option>
3367
+                <option value="if" <?php selected(true, $value == 'if'); ?>><?php _e('If used (not .00)', 'geodirectory'); ?></option>
3368
+                <option value="allways" <?php selected(true, $value == "allways"); ?>><?php _e('Always (.00)', 'geodirectory'); ?></option>
3369 3369
             </select>
3370 3370
         </div>
3371 3371
     </li>
@@ -3375,12 +3375,12 @@  discard block
 block discarded – undo
3375 3375
     $value = '';
3376 3376
     if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3377 3377
         $value = esc_attr($extra_fields['currency_symbol']);
3378
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3378
+    }elseif (isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']) {
3379 3379
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3380 3380
     }
3381 3381
     ?>
3382
-    <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3383
-        <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory');?>
3382
+    <li class="gdcf-price-extra" <?php if (!$show_price_extra) { echo "style='display:none;'"; }?>>
3383
+        <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory'); ?>
3384 3384
             <div class="gdcf-tooltip">
3385 3385
                 <?php _e('Select the currency symbol.', 'geodirectory'); ?>
3386 3386
             </div>
@@ -3396,20 +3396,20 @@  discard block
 block discarded – undo
3396 3396
     $value = '';
3397 3397
     if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3398 3398
         $value = esc_attr($extra_fields['currency_symbol_placement']);
3399
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3399
+    }elseif (isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']) {
3400 3400
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3401 3401
     }
3402 3402
     ?>
3403
-    <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3404
-        <label for="currency_symbol_placement" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol placement :', 'geodirectory');?>
3403
+    <li class="gdcf-price-extra" <?php if (!$show_price_extra) { echo "style='display:none;'"; }?>>
3404
+        <label for="currency_symbol_placement" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol placement :', 'geodirectory'); ?>
3405 3405
             <div class="gdcf-tooltip">
3406 3406
                 <?php _e('Select the currency symbol placement.', 'geodirectory'); ?>
3407 3407
             </div>
3408 3408
         </label>
3409 3409
         <div class="gd-cf-input-wrap">
3410 3410
             <select name="extra[currency_symbol_placement]" id="currency_symbol_placement">
3411
-                <option value="left" <?php selected(true, $value == 'left');?>><?php _e('Left', 'geodirectory'); ?></option>
3412
-                <option value="right" <?php selected(true, $value == "right");?>><?php _e('Right', 'geodirectory'); ?></option>
3411
+                <option value="left" <?php selected(true, $value == 'left'); ?>><?php _e('Left', 'geodirectory'); ?></option>
3412
+                <option value="right" <?php selected(true, $value == "right"); ?>><?php _e('Right', 'geodirectory'); ?></option>
3413 3413
             </select>
3414 3414
         </div>
3415 3415
     </li>
@@ -3420,11 +3420,11 @@  discard block
 block discarded – undo
3420 3420
     $html = ob_get_clean();
3421 3421
     return $output.$html;
3422 3422
 }
3423
-add_filter('geodir_cfa_extra_fields_text','geodir_cfa_extra_fields_text',10,4);
3423
+add_filter('geodir_cfa_extra_fields_text', 'geodir_cfa_extra_fields_text', 10, 4);
3424 3424
 
3425
-function geodir_default_custom_fields($post_type='gd_place',$package_id=''){
3425
+function geodir_default_custom_fields($post_type = 'gd_place', $package_id = '') {
3426 3426
     $fields = array();
3427
-    $package = ($package_id=='') ? '' : array($package_id);
3427
+    $package = ($package_id == '') ? '' : array($package_id);
3428 3428
 
3429 3429
     $fields[] = array('listing_type' => $post_type,
3430 3430
                       'data_type' => 'VARCHAR',
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
     return  $fields;
3598 3598
 }
3599 3599
 
3600
-function geodir_currency_format_number($number='',$cf=''){
3600
+function geodir_currency_format_number($number = '', $cf = '') {
3601 3601
 
3602 3602
     $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : '';
3603 3603
 
@@ -3606,35 +3606,35 @@  discard block
 block discarded – undo
3606 3606
     $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if');
3607 3607
     $decimalpoint = '.';
3608 3608
 
3609
-    if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
3609
+    if (isset($cs['decimal_separator']) && $cs['decimal_separator'] == 'comma') {
3610 3610
         $decimalpoint = ',';
3611 3611
     }
3612 3612
 
3613 3613
     $separator = ',';
3614 3614
 
3615
-    if(isset($cs['thousand_separator'])){
3616
-        if($cs['thousand_separator']=='comma'){$separator = ',';}
3617
-        if($cs['thousand_separator']=='slash'){$separator = '\\';}
3618
-        if($cs['thousand_separator']=='period'){$separator = '.';}
3619
-        if($cs['thousand_separator']=='space'){$separator = ' ';}
3620
-        if($cs['thousand_separator']=='none'){$separator = '';}
3615
+    if (isset($cs['thousand_separator'])) {
3616
+        if ($cs['thousand_separator'] == 'comma') {$separator = ','; }
3617
+        if ($cs['thousand_separator'] == 'slash') {$separator = '\\'; }
3618
+        if ($cs['thousand_separator'] == 'period') {$separator = '.'; }
3619
+        if ($cs['thousand_separator'] == 'space') {$separator = ' '; }
3620
+        if ($cs['thousand_separator'] == 'none') {$separator = ''; }
3621 3621
     }
3622 3622
 
3623 3623
     $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3624 3624
 
3625
-    if($decimals>0 && $decimal_display=='if'){
3626
-        if(is_int($number) || floor( $number ) == $number)
3625
+    if ($decimals > 0 && $decimal_display == 'if') {
3626
+        if (is_int($number) || floor($number) == $number)
3627 3627
             $decimals = 0;
3628 3628
     }
3629 3629
 
3630
-    $number = number_format($number,$decimals,$decimalpoint,$separator);
3630
+    $number = number_format($number, $decimals, $decimalpoint, $separator);
3631 3631
 
3632 3632
 
3633 3633
 
3634
-    if($currency_symbol_placement=='left'){
3635
-        $number = $symbol . $number;
3636
-    }else{
3637
-        $number = $number . $symbol;
3634
+    if ($currency_symbol_placement == 'left') {
3635
+        $number = $symbol.$number;
3636
+    } else {
3637
+        $number = $number.$symbol;
3638 3638
     }
3639 3639
 
3640 3640
 
Please login to merge, or discard this patch.
Braces   +133 added lines, -92 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
         global $wpdb;
52 52
         $result = 0;// no rows affected
53 53
         if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
54
+            if (!empty($db) && !empty($column)) {
55
+                            $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+            }
56 57
         }
57 58
         return $result;
58 59
     }
@@ -82,10 +83,11 @@  discard block
 block discarded – undo
82 83
 
83 84
     $default_query = '';
84 85
 
85
-    if ($default == 'default')
86
-        $default_query .= " and is_admin IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query .= " and is_admin = '0' ";
86
+    if ($default == 'default') {
87
+            $default_query .= " and is_admin IN ('1') ";
88
+    } elseif ($default == 'custom') {
89
+            $default_query .= " and is_admin = '0' ";
90
+    }
89 91
 
90 92
     if ($fields_location == 'none') {
91 93
     } else{
@@ -239,10 +241,12 @@  discard block
 block discarded – undo
239 241
                 }
240 242
 
241 243
                 return $field_id;
242
-            } else
243
-                return 0;
244
-        } else
245
-            return 0;
244
+            } else {
245
+                            return 0;
246
+            }
247
+        } else {
248
+                    return 0;
249
+        }
246 250
     }
247 251
 }
248 252
 
@@ -350,7 +354,9 @@  discard block
 block discarded – undo
350 354
 
351 355
 
352 356
 
353
-            if ($post_type == '') $post_type = 'gd_place';
357
+            if ($post_type == '') {
358
+            	$post_type = 'gd_place';
359
+            }
354 360
 
355 361
 
356 362
             $detail_table = $plugin_prefix . $post_type . '_detail';
@@ -390,16 +396,17 @@  discard block
 block discarded – undo
390 396
             }
391 397
 
392 398
             $option_values = '';
393
-            if (isset($request_field['option_values']))
394
-                $option_values = $request_field['option_values'];
399
+            if (isset($request_field['option_values'])) {
400
+                            $option_values = $request_field['option_values'];
401
+            }
395 402
 
396 403
             $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
397 404
 
398 405
             $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
399 406
 
400
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
402
-            else {
407
+            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) {
408
+                            $price_pkg = implode(",", $request_field['show_on_pkg']);
409
+            } else {
403 410
                 $package_info = array();
404 411
 
405 412
                 $package_info = geodir_post_package_info($package_info, '', $post_type);
@@ -407,22 +414,29 @@  discard block
 block discarded – undo
407 414
             }
408 415
 
409 416
 
410
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
411
-                $extra_fields = $request_field['extra'];
417
+            if (isset($request_field['extra']) && !empty($request_field['extra'])) {
418
+                            $extra_fields = $request_field['extra'];
419
+            }
412 420
 
413
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
-                $is_default = $request_field['is_default'];
415
-            else
416
-                $is_default = '0';
421
+            if (isset($request_field['is_default']) && $request_field['is_default'] != '') {
422
+                            $is_default = $request_field['is_default'];
423
+            } else {
424
+                            $is_default = '0';
425
+            }
417 426
 
418
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
-                $is_admin = $request_field['is_admin'];
420
-            else
421
-                $is_admin = '0';
427
+            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') {
428
+                            $is_admin = $request_field['is_admin'];
429
+            } else {
430
+                            $is_admin = '0';
431
+            }
422 432
 
423 433
 
424
-            if ($is_active == '') $is_active = 1;
425
-            if ($is_required == '') $is_required = 0;
434
+            if ($is_active == '') {
435
+            	$is_active = 1;
436
+            }
437
+            if ($is_required == '') {
438
+            	$is_required = 0;
439
+            }
426 440
 
427 441
 
428 442
             if ($sort_order == '') {
@@ -691,7 +705,7 @@  discard block
 block discarded – undo
691 705
                                 }
692 706
                                 if($op_max){$op_size =$op_max; }
693 707
                             }
694
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
708
+                        } elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695 709
                             if(strlen($option_values)){
696 710
                                 $op_size =  strlen($option_values);
697 711
                             }
@@ -708,11 +722,13 @@  discard block
 block discarded – undo
708 722
                             return __('Column change failed, you may have too many columns.','geodirectory');
709 723
                         }
710 724
 
711
-                        if (isset($request_field['cat_display_type']))
712
-                            $extra_fields = $request_field['cat_display_type'];
725
+                        if (isset($request_field['cat_display_type'])) {
726
+                                                    $extra_fields = $request_field['cat_display_type'];
727
+                        }
713 728
 
714
-                        if (isset($request_field['multi_display_type']))
715
-                            $extra_fields = $request_field['multi_display_type'];
729
+                        if (isset($request_field['multi_display_type'])) {
730
+                                                    $extra_fields = $request_field['multi_display_type'];
731
+                        }
716 732
 
717 733
 
718 734
                         break;
@@ -726,8 +742,9 @@  discard block
 block discarded – undo
726 742
                         if($alter_result===false){
727 743
                             return __('Column change failed, you may have too many columns.','geodirectory');
728 744
                         }
729
-                        if (isset($request_field['advanced_editor']))
730
-                            $extra_fields = $request_field['advanced_editor'];
745
+                        if (isset($request_field['advanced_editor'])) {
746
+                                                    $extra_fields = $request_field['advanced_editor'];
747
+                        }
731 748
 
732 749
                         break;
733 750
 
@@ -823,8 +840,9 @@  discard block
 block discarded – undo
823 840
                 );
824 841
 
825 842
 
826
-                if ($cat_sort == '')
827
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
843
+                if ($cat_sort == '') {
844
+                                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
845
+                }
828 846
 
829 847
 
830 848
                 /**
@@ -1194,8 +1212,10 @@  discard block
 block discarded – undo
1194 1212
         }
1195 1213
 
1196 1214
         return $post_meta_info;
1197
-    else:
1198
-        return false;
1215
+    else {
1216
+    	:
1217
+        return false;
1218
+    }
1199 1219
     endif;
1200 1220
 }
1201 1221
 
@@ -1272,8 +1292,9 @@  discard block
 block discarded – undo
1272 1292
         if (is_admin()) {
1273 1293
             global $post;
1274 1294
 
1275
-            if (isset($_REQUEST['post']))
1276
-                $_REQUEST['pid'] = $_REQUEST['post'];
1295
+            if (isset($_REQUEST['post'])) {
1296
+                            $_REQUEST['pid'] = $_REQUEST['post'];
1297
+            }
1277 1298
         }
1278 1299
 
1279 1300
         
@@ -1365,7 +1386,7 @@  discard block
 block discarded – undo
1365 1386
         $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1366 1387
     } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1367 1388
         $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1368
-    }else{
1389
+    } else{
1369 1390
         $field_icon = $cf['field_icon'];
1370 1391
     }
1371 1392
 
@@ -1437,8 +1458,9 @@  discard block
 block discarded – undo
1437 1458
                     $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1438 1459
                     $variables_array['label'] = __($type['site_title'], 'geodirectory');
1439 1460
                     $variables_array['value'] = '';
1440
-                    if (isset($post->{$type['htmlvar_name']}))
1441
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
1461
+                    if (isset($post->{$type['htmlvar_name']})) {
1462
+                                            $variables_array['value'] = $post->{$type['htmlvar_name']};
1463
+                    }
1442 1464
                 endif;
1443 1465
 
1444 1466
 
@@ -1460,7 +1482,9 @@  discard block
 block discarded – undo
1460 1482
                      * @param string $html Custom field unfiltered HTML.
1461 1483
                      * @param array $variables_array Custom field variables array.
1462 1484
                      */
1463
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1485
+                    if ($html) {
1486
+                    	echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1487
+                    }
1464 1488
 
1465 1489
                     /**
1466 1490
                      * Called after a custom fields is output on the frontend.
@@ -1503,10 +1527,11 @@  discard block
 block discarded – undo
1503 1527
      */
1504 1528
     function geodir_default_date_format()
1505 1529
     {
1506
-        if ($format = get_option('date_format'))
1507
-            return $format;
1508
-        else
1509
-            return 'dd-mm-yy';
1530
+        if ($format = get_option('date_format')) {
1531
+                    return $format;
1532
+        } else {
1533
+                    return 'dd-mm-yy';
1534
+        }
1510 1535
     }
1511 1536
 }
1512 1537
 
@@ -1613,11 +1638,13 @@  discard block
 block discarded – undo
1613 1638
                     // Set an array containing a list of acceptable formats
1614 1639
                     //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1615 1640
 
1616
-                    if (!function_exists('wp_handle_upload'))
1617
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1641
+                    if (!function_exists('wp_handle_upload')) {
1642
+                                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1643
+                    }
1618 1644
 
1619
-                    if (!is_dir($geodir_uploadpath))
1620
-                        mkdir($geodir_uploadpath);
1645
+                    if (!is_dir($geodir_uploadpath)) {
1646
+                                            mkdir($geodir_uploadpath);
1647
+                    }
1621 1648
 
1622 1649
                     $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1623 1650
                     $explode_sub_dir = explode("/", $sub_dir);
@@ -1630,16 +1657,19 @@  discard block
 block discarded – undo
1630 1657
                     }
1631 1658
 
1632 1659
                     $uploaded_file = '';
1633
-                    if (file_exists($img_path))
1634
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1660
+                    if (file_exists($img_path)) {
1661
+                                            $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1662
+                    }
1635 1663
 
1636 1664
                     if ($curr_img_dir != $geodir_uploaddir) {
1637
-                        if (file_exists($img_path))
1638
-                            unlink($img_path);
1665
+                        if (file_exists($img_path)) {
1666
+                                                    unlink($img_path);
1667
+                        }
1639 1668
                     }
1640 1669
 
1641
-                    if (!empty($uploaded_file))
1642
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1670
+                    if (!empty($uploaded_file)) {
1671
+                                            $file_urls = $geodir_uploadurl . '/' . $new_name;
1672
+                    }
1643 1673
 
1644 1674
                 } else {
1645 1675
                     $file_urls = $post_image[$m];
@@ -1660,8 +1690,9 @@  discard block
 block discarded – undo
1660 1690
 
1661 1691
         geodir_save_post_meta($post_id, $field_id, $file_urls);
1662 1692
 
1663
-        if (!empty($invalid_files))
1664
-            geodir_remove_attachments($invalid_files);
1693
+        if (!empty($invalid_files)) {
1694
+                    geodir_remove_attachments($invalid_files);
1695
+        }
1665 1696
 
1666 1697
     }
1667 1698
 }
@@ -1887,8 +1918,9 @@  discard block
 block discarded – undo
1887 1918
 
1888 1919
         $all_postypes = geodir_get_posttypes();
1889 1920
 
1890
-        if (!in_array($post_type, $all_postypes))
1891
-            return false;
1921
+        if (!in_array($post_type, $all_postypes)) {
1922
+                    return false;
1923
+        }
1892 1924
 
1893 1925
         $fields = array();
1894 1926
 
@@ -1986,8 +2018,10 @@  discard block
 block discarded – undo
1986 2018
         }
1987 2019
 
1988 2020
         return $field_ids;
1989
-    else:
1990
-        return false;
2021
+    else {
2022
+    	:
2023
+        return false;
2024
+    }
1991 2025
     endif;
1992 2026
 }
1993 2027
 
@@ -2160,8 +2194,9 @@  discard block
 block discarded – undo
2160 2194
 
2161 2195
             return $field_id;
2162 2196
 
2163
-        } else
2164
-            return 0;
2197
+        } else {
2198
+                    return 0;
2199
+        }
2165 2200
 
2166 2201
     }
2167 2202
 }
@@ -2202,8 +2237,9 @@  discard block
 block discarded – undo
2202 2237
         $htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2203 2238
 
2204 2239
         $site_title = '';
2205
-        if ($site_title == '')
2206
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2240
+        if ($site_title == '') {
2241
+                    $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2242
+        }
2207 2243
 
2208 2244
         if ($site_title == '') {
2209 2245
             $fields = geodir_get_custom_sort_options($post_type);
@@ -2217,8 +2253,9 @@  discard block
 block discarded – undo
2217 2253
             }
2218 2254
         }
2219 2255
 
2220
-        if ($htmlvar_name == '')
2221
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2256
+        if ($htmlvar_name == '') {
2257
+                    $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2258
+        }
2222 2259
 
2223 2260
         $nonce = wp_create_nonce('custom_fields_' . $result_str);
2224 2261
 
@@ -2231,7 +2268,7 @@  discard block
 block discarded – undo
2231 2268
 
2232 2269
                 if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2233 2270
                     $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2234
-                }elseif(isset($cso['field_icon']) && $cso['field_icon']){
2271
+                } elseif(isset($cso['field_icon']) && $cso['field_icon']){
2235 2272
                     $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2236 2273
                 }
2237 2274
 
@@ -2667,7 +2704,7 @@  discard block
 block discarded – undo
2667 2704
     $dt_value = '';
2668 2705
     if (isset($field_info->data_type)) {
2669 2706
         $dt_value  = esc_attr($field_info->data_type);
2670
-    }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2707
+    } elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2671 2708
         $dt_value  = $cf['defaults']['data_type'];
2672 2709
     }
2673 2710
     ?>
@@ -2699,7 +2736,7 @@  discard block
 block discarded – undo
2699 2736
     $value = '';
2700 2737
     if (isset($field_info->decimal_point)) {
2701 2738
         $value = esc_attr($field_info->decimal_point);
2702
-    }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2739
+    } elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2703 2740
         $value = $cf['defaults']['decimal_point'];
2704 2741
     }
2705 2742
     ?>
@@ -2771,11 +2808,13 @@  discard block
 block discarded – undo
2771 2808
 
2772 2809
             <?php
2773 2810
             $selected = '';
2774
-            if (isset($field_info->extra_fields))
2775
-                $advanced_editor = unserialize($field_info->extra_fields);
2811
+            if (isset($field_info->extra_fields)) {
2812
+                            $advanced_editor = unserialize($field_info->extra_fields);
2813
+            }
2776 2814
 
2777
-            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2778
-                $selected = 'checked="checked"';
2815
+            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) {
2816
+                            $selected = 'checked="checked"';
2817
+            }
2779 2818
             ?>
2780 2819
 
2781 2820
             <input type="checkbox" name="advanced_editor[]" id="advanced_editor"
@@ -2797,7 +2836,7 @@  discard block
 block discarded – undo
2797 2836
     $value = '';
2798 2837
     if (isset($field_info->validation_pattern)) {
2799 2838
         $value = esc_attr($field_info->validation_pattern);
2800
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2839
+    } elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2801 2840
         $value = esc_attr($cf['defaults']['validation_pattern']);
2802 2841
     }
2803 2842
     ?>
@@ -2817,7 +2856,7 @@  discard block
 block discarded – undo
2817 2856
     $value = '';
2818 2857
     if (isset($field_info->validation_msg)) {
2819 2858
         $value = esc_attr($field_info->validation_msg);
2820
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2859
+    } elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2821 2860
         $value = esc_attr($cf['defaults']['validation_msg']);
2822 2861
     }
2823 2862
     ?>
@@ -2847,8 +2886,9 @@  discard block
 block discarded – undo
2847 2886
 
2848 2887
     if (!isset($field_info->post_type)) {
2849 2888
         $post_type = sanitize_text_field($_REQUEST['listing_type']);
2850
-    } else
2851
-        $post_type = $field_info->post_type;
2889
+    } else {
2890
+            $post_type = $field_info->post_type;
2891
+    }
2852 2892
     ?>
2853 2893
     <li style="display: none;">
2854 2894
         <label for="htmlvar_name" class="gd-cf-tooltip-wrap">
@@ -3122,7 +3162,7 @@  discard block
 block discarded – undo
3122 3162
     $value = '';
3123 3163
     if (isset($field_info->option_values)) {
3124 3164
         $value = esc_attr($field_info->option_values);
3125
-    }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3165
+    } elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3126 3166
         $value = esc_attr($cf['defaults']['option_values']);
3127 3167
     }
3128 3168
 
@@ -3265,7 +3305,7 @@  discard block
 block discarded – undo
3265 3305
     $value = '';
3266 3306
     if ($extra_fields && isset($extra_fields['is_price'])) {
3267 3307
     $value = esc_attr($extra_fields['is_price']);
3268
-    }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3308
+    } elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3269 3309
     $value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3270 3310
     }
3271 3311
 
@@ -3302,7 +3342,7 @@  discard block
 block discarded – undo
3302 3342
     $value = '';
3303 3343
     if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3304 3344
         $value = esc_attr($extra_fields['thousand_separator']);
3305
-    }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3345
+    } elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3306 3346
         $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3307 3347
     }
3308 3348
     ?>
@@ -3329,7 +3369,7 @@  discard block
 block discarded – undo
3329 3369
     $value = '';
3330 3370
     if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3331 3371
         $value = esc_attr($extra_fields['decimal_separator']);
3332
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3372
+    } elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3333 3373
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3334 3374
     }
3335 3375
     ?>
@@ -3352,7 +3392,7 @@  discard block
 block discarded – undo
3352 3392
     $value = '';
3353 3393
     if ($extra_fields && isset($extra_fields['decimal_display'])) {
3354 3394
         $value = esc_attr($extra_fields['decimal_display']);
3355
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3395
+    } elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3356 3396
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3357 3397
     }
3358 3398
     ?>
@@ -3375,7 +3415,7 @@  discard block
 block discarded – undo
3375 3415
     $value = '';
3376 3416
     if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3377 3417
         $value = esc_attr($extra_fields['currency_symbol']);
3378
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3418
+    } elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3379 3419
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3380 3420
     }
3381 3421
     ?>
@@ -3396,7 +3436,7 @@  discard block
 block discarded – undo
3396 3436
     $value = '';
3397 3437
     if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3398 3438
         $value = esc_attr($extra_fields['currency_symbol_placement']);
3399
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3439
+    } elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3400 3440
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3401 3441
     }
3402 3442
     ?>
@@ -3623,8 +3663,9 @@  discard block
 block discarded – undo
3623 3663
     $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3624 3664
 
3625 3665
     if($decimals>0 && $decimal_display=='if'){
3626
-        if(is_int($number) || floor( $number ) == $number)
3627
-            $decimals = 0;
3666
+        if(is_int($number) || floor( $number ) == $number) {
3667
+                    $decimals = 0;
3668
+        }
3628 3669
     }
3629 3670
 
3630 3671
     $number = number_format($number,$decimals,$decimalpoint,$separator);
@@ -3633,7 +3674,7 @@  discard block
 block discarded – undo
3633 3674
 
3634 3675
     if($currency_symbol_placement=='left'){
3635 3676
         $number = $symbol . $number;
3636
-    }else{
3677
+    } else{
3637 3678
         $number = $number . $symbol;
3638 3679
     }
3639 3680
 
Please login to merge, or discard this patch.
geodirectory_hooks_actions.php 2 patches
Indentation   +1169 added lines, -1169 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function geodir_get_ajax_url()
21 21
 {
22
-    return admin_url('admin-ajax.php?action=geodir_ajax_action');
22
+	return admin_url('admin-ajax.php?action=geodir_ajax_action');
23 23
 }
24 24
 
25 25
 /////////////////////
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 add_filter('query_vars', 'geodir_add_geodir_page_var');
88 88
 add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
89 89
 if (get_option('permalink_structure') != '')
90
-    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
90
+	add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
91 91
 
92 92
 add_filter('parse_query', 'geodir_modified_query');
93 93
 
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 /* POST AND LOOP ACTIONS */
155 155
 ////////////////////////
156 156
 if (!is_admin()) {
157
-    add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere
158
-    add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
-    /** Exclude Virtual Pages From Pages List **/
160
-    add_action('pre_get_posts', 'set_listing_request', 0);
161
-    add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
-    add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
-    add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
-    add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
157
+	add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere
158
+	add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
159
+	/** Exclude Virtual Pages From Pages List **/
160
+	add_action('pre_get_posts', 'set_listing_request', 0);
161
+	add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
162
+	add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
163
+	add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
164
+	add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
165 165
 }
166 166
 
167 167
 
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
  */
224 224
 function geodir_unset_prev_theme_nav_location($newname)
225 225
 {
226
-    $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
227
-    if ($geodir_theme_location) {
228
-        update_option('geodir_theme_location_nav', $geodir_theme_location);
229
-    } else {
230
-        update_option('geodir_theme_location_nav', '');
231
-    }
226
+	$geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
227
+	if ($geodir_theme_location) {
228
+		update_option('geodir_theme_location_nav', $geodir_theme_location);
229
+	} else {
230
+		update_option('geodir_theme_location_nav', '');
231
+	}
232 232
 }
233 233
 
234 234
 /// add action for theme switch to blank previous theme navigation location setting
@@ -249,32 +249,32 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function geodir_add_post_filters()
251 251
 {
252
-    /**
253
-     * Contains all function for filtering listing.
254
-     *
255
-     * @since 1.0.0
256
-     * @package GeoDirectory
257
-     */
258
-    include_once('geodirectory-functions/listing_filters.php');
252
+	/**
253
+	 * Contains all function for filtering listing.
254
+	 *
255
+	 * @since 1.0.0
256
+	 * @package GeoDirectory
257
+	 */
258
+	include_once('geodirectory-functions/listing_filters.php');
259 259
 }
260 260
 
261 261
 
262 262
 if (!function_exists('geodir_init_defaults')) {
263
-    /**
264
-     * Calls the function to register the GeoDirectory default CPT and taxonomies.
265
-     *
266
-     * @since 1.0.0
267
-     * @package GeoDirectory
268
-     */
269
-    function geodir_init_defaults()
270
-    {
271
-        if (function_exists('geodir_register_defaults')) {
263
+	/**
264
+	 * Calls the function to register the GeoDirectory default CPT and taxonomies.
265
+	 *
266
+	 * @since 1.0.0
267
+	 * @package GeoDirectory
268
+	 */
269
+	function geodir_init_defaults()
270
+	{
271
+		if (function_exists('geodir_register_defaults')) {
272 272
 
273
-            geodir_register_defaults();
273
+			geodir_register_defaults();
274 274
 
275
-        }
275
+		}
276 276
 
277
-    }
277
+	}
278 278
 }
279 279
 
280 280
 
@@ -296,26 +296,26 @@  discard block
 block discarded – undo
296 296
 // CALLED ON 'sidebars_widgets' FILTER
297 297
 
298 298
 if (!function_exists('geodir_restrict_widget')) {
299
-    /**
300
-     * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
301
-     *
302
-     * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
303
-     * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
304
-     * @since 1.0.0
305
-     * @package GeoDirectory
306
-     */
307
-    function geodir_restrict_widget()
308
-    {
309
-        global $is_listing, $is_single_place;
299
+	/**
300
+	 * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page.
301
+	 *
302
+	 * @global bool $is_listing Sets the global value to true if on a GD category page. False if not.
303
+	 * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not.
304
+	 * @since 1.0.0
305
+	 * @package GeoDirectory
306
+	 */
307
+	function geodir_restrict_widget()
308
+	{
309
+		global $is_listing, $is_single_place;
310 310
 
311
-        // set is listing	
312
-        (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
311
+		// set is listing	
312
+		(geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
313 313
 
314
-        // set is single place
315
-        (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
314
+		// set is single place
315
+		(geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
316 316
 
317 317
 
318
-    }
318
+	}
319 319
 }
320 320
 
321 321
 
@@ -336,31 +336,31 @@  discard block
 block discarded – undo
336 336
  */
337 337
 function geodir_detail_page_sidebar_content_sorting()
338 338
 {
339
-    $arr_detail_page_sidebar_content =
340
-        /**
341
-         * An array of functions to be called to be displayed on the details (post) page sidebar.
342
-         *
343
-         * This filter can be used to remove sections of the details page sidebar,
344
-         * add new sections or rearrange the order of the sections.
345
-         *
346
-         * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
347
-         * @since 1.0.0
348
-         */
349
-        apply_filters('geodir_detail_page_sidebar_content',
350
-            array('geodir_social_sharing_buttons',
351
-                'geodir_detail_page_google_analytics',
352
-                'geodir_edit_post_link',
353
-                'geodir_detail_page_review_rating',
354
-                'geodir_detail_page_more_info'
355
-            ) // end of array 
356
-        ); // end of apply filter
357
-    if (!empty($arr_detail_page_sidebar_content)) {
358
-        foreach ($arr_detail_page_sidebar_content as $content_function) {
359
-            if (function_exists($content_function)) {
360
-                add_action('geodir_detail_page_sidebar', $content_function);
361
-            }
362
-        }
363
-    }
339
+	$arr_detail_page_sidebar_content =
340
+		/**
341
+		 * An array of functions to be called to be displayed on the details (post) page sidebar.
342
+		 *
343
+		 * This filter can be used to remove sections of the details page sidebar,
344
+		 * add new sections or rearrange the order of the sections.
345
+		 *
346
+		 * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
347
+		 * @since 1.0.0
348
+		 */
349
+		apply_filters('geodir_detail_page_sidebar_content',
350
+			array('geodir_social_sharing_buttons',
351
+				'geodir_detail_page_google_analytics',
352
+				'geodir_edit_post_link',
353
+				'geodir_detail_page_review_rating',
354
+				'geodir_detail_page_more_info'
355
+			) // end of array 
356
+		); // end of apply filter
357
+	if (!empty($arr_detail_page_sidebar_content)) {
358
+		foreach ($arr_detail_page_sidebar_content as $content_function) {
359
+			if (function_exists($content_function)) {
360
+				add_action('geodir_detail_page_sidebar', $content_function);
361
+			}
362
+		}
363
+	}
364 364
 }
365 365
 
366 366
 add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1);
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function geodir_add_to_favourite_link()
377 377
 {
378
-    global $post, $preview;
379
-    if (!$preview && geodir_is_page('detail')) {
380
-        ?>
378
+	global $post, $preview;
379
+	if (!$preview && geodir_is_page('detail')) {
380
+		?>
381 381
         <p class="edit_link">
382 382
             <?php geodir_favourite_html($post->post_author, $post->ID); ?>
383 383
         </p>
384 384
     <?php
385
-    }
385
+	}
386 386
 }
387 387
 
388 388
 /**
@@ -396,41 +396,41 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function geodir_social_sharing_buttons()
398 398
 {
399
-    global $preview;
400
-    ob_start(); // Start  buffering;
401
-    /**
402
-     * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
403
-     *
404
-     * @since 1.0.0
405
-     */
406
-    do_action('geodir_before_social_sharing_buttons');
407
-    if (!$preview) {
408
-        ?>
399
+	global $preview;
400
+	ob_start(); // Start  buffering;
401
+	/**
402
+	 * This action is called before the social buttons twitter,facebook and google plus are output in a containing div.
403
+	 *
404
+	 * @since 1.0.0
405
+	 */
406
+	do_action('geodir_before_social_sharing_buttons');
407
+	if (!$preview) {
408
+		?>
409 409
         <div class="likethis">
410 410
             <?php geodir_twitter_tweet_button(); ?>
411 411
             <?php geodir_fb_like_button(); ?>
412 412
             <?php geodir_google_plus_button(); ?>
413 413
         </div>
414 414
     <?php
415
-    }// end of if, if its a preview or not
416
-
417
-    /**
418
-     * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
419
-     *
420
-     * @since 1.0.0
421
-     */
422
-    do_action('geodir_after_social_sharing_buttons');
423
-    $content_html = ob_get_clean();
424
-    if (trim($content_html) != '')
425
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
426
-    if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
427
-        /**
428
-         * Filter the geodir_social_sharing_buttons() function content.
429
-         *
430
-         * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
431
-         */
432
-        echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
433
-    }
415
+	}// end of if, if its a preview or not
416
+
417
+	/**
418
+	 * This action is called after the social buttons twitter,facebook and google plus are output in a containing div.
419
+	 *
420
+	 * @since 1.0.0
421
+	 */
422
+	do_action('geodir_after_social_sharing_buttons');
423
+	$content_html = ob_get_clean();
424
+	if (trim($content_html) != '')
425
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
426
+	if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
427
+		/**
428
+		 * Filter the geodir_social_sharing_buttons() function content.
429
+		 *
430
+		 * @param string $content_html The output html of the geodir_social_sharing_buttons() function.
431
+		 */
432
+		echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
433
+	}
434 434
 
435 435
 
436 436
 }
@@ -448,46 +448,46 @@  discard block
 block discarded – undo
448 448
  */
449 449
 function geodir_edit_post_link()
450 450
 {
451
-    global $post, $preview;
452
-    ob_start(); // Start buffering;
453
-    /**
454
-     * This is called before the edit post link html in the function geodir_edit_post_link()
455
-     *
456
-     * @since 1.0.0
457
-     */
458
-    do_action('geodir_before_edit_post_link');
459
-    if (!$preview) {
460
-        $is_current_user_owner = geodir_listing_belong_to_current_user();
451
+	global $post, $preview;
452
+	ob_start(); // Start buffering;
453
+	/**
454
+	 * This is called before the edit post link html in the function geodir_edit_post_link()
455
+	 *
456
+	 * @since 1.0.0
457
+	 */
458
+	do_action('geodir_before_edit_post_link');
459
+	if (!$preview) {
460
+		$is_current_user_owner = geodir_listing_belong_to_current_user();
461 461
         
462
-        if ($is_current_user_owner) {
463
-            $post_id = $post->ID;
462
+		if ($is_current_user_owner) {
463
+			$post_id = $post->ID;
464 464
             
465
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
466
-                $post_id = (int)$_REQUEST['pid'];
467
-            }
465
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
466
+				$post_id = (int)$_REQUEST['pid'];
467
+			}
468 468
 
469
-            $postlink = get_permalink(geodir_add_listing_page_id());
470
-            $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
471
-            echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
472
-        }
473
-    }// end of if, if its a preview or not
474
-    /**
475
-     * This is called after the edit post link html in the function geodir_edit_post_link()
476
-     *
477
-     * @since 1.0.0
478
-     */
479
-    do_action('geodir_after_edit_post_link');
480
-    $content_html = ob_get_clean();
481
-    if (trim($content_html) != '')
482
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
483
-    if ((int)get_option('geodir_disable_user_links_section') != 1) {
484
-        /**
485
-         * Filter the geodir_edit_post_link() function content.
486
-         *
487
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
488
-         */
489
-        echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
490
-    }
469
+			$postlink = get_permalink(geodir_add_listing_page_id());
470
+			$editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
471
+			echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
472
+		}
473
+	}// end of if, if its a preview or not
474
+	/**
475
+	 * This is called after the edit post link html in the function geodir_edit_post_link()
476
+	 *
477
+	 * @since 1.0.0
478
+	 */
479
+	do_action('geodir_after_edit_post_link');
480
+	$content_html = ob_get_clean();
481
+	if (trim($content_html) != '')
482
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
483
+	if ((int)get_option('geodir_disable_user_links_section') != 1) {
484
+		/**
485
+		 * Filter the geodir_edit_post_link() function content.
486
+		 *
487
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
488
+		 */
489
+		echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
490
+	}
491 491
 }
492 492
 
493 493
 /**
@@ -501,42 +501,42 @@  discard block
 block discarded – undo
501 501
  */
502 502
 function geodir_detail_page_google_analytics()
503 503
 {
504
-    global $post,$preview;
505
-    if($preview){return '';}
506
-    $package_info = array();
507
-    $package_info = geodir_post_package_info($package_info, $post);
504
+	global $post,$preview;
505
+	if($preview){return '';}
506
+	$package_info = array();
507
+	$package_info = geodir_post_package_info($package_info, $post);
508 508
 
509
-    $id = trim(get_option('geodir_ga_account_id'));
509
+	$id = trim(get_option('geodir_ga_account_id'));
510 510
 
511
-    if (!$id) {
512
-        return; //if no Google Analytics ID then bail.
513
-    }
511
+	if (!$id) {
512
+		return; //if no Google Analytics ID then bail.
513
+	}
514 514
 
515
-    ob_start(); // Start buffering;
516
-    /**
517
-     * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
518
-     *
519
-     * @since 1.0.0
520
-     */
521
-    do_action('geodir_before_google_analytics');
515
+	ob_start(); // Start buffering;
516
+	/**
517
+	 * This is called before the edit post link html in the function geodir_detail_page_google_analytics()
518
+	 *
519
+	 * @since 1.0.0
520
+	 */
521
+	do_action('geodir_before_google_analytics');
522 522
     
523
-    $refresh_time = get_option('geodir_ga_refresh_time', 5);
524
-    /**
525
-     * Filter the time interval to check & refresh new users results.
526
-     *
527
-     * @since 1.5.9
528
-     *
529
-     * @param int $refresh_time Time interval to check & refresh new users results.
530
-     */
531
-    $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
532
-    $refresh_time = absint($refresh_time * 1000);
523
+	$refresh_time = get_option('geodir_ga_refresh_time', 5);
524
+	/**
525
+	 * Filter the time interval to check & refresh new users results.
526
+	 *
527
+	 * @since 1.5.9
528
+	 *
529
+	 * @param int $refresh_time Time interval to check & refresh new users results.
530
+	 */
531
+	$refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
532
+	$refresh_time = absint($refresh_time * 1000);
533 533
     
534
-    $hide_refresh = get_option('geodir_ga_auto_refresh');
534
+	$hide_refresh = get_option('geodir_ga_auto_refresh');
535 535
     
536
-    $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
537
-    if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
538
-        $page_url = urlencode($_SERVER['REQUEST_URI']);
539
-        ?>
536
+	$auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
537
+	if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
538
+		$page_url = urlencode($_SERVER['REQUEST_URI']);
539
+		?>
540 540
         <script type="text/javascript">
541 541
             var gd_gaTimeOut;
542 542
             var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
@@ -788,15 +788,15 @@  discard block
 block discarded – undo
788 788
                     var labels = results[1].rows.map(function(row) { return +row[0]; });
789 789
 
790 790
                     <?php
791
-                    // Here we list the shorthand days of the week so it can be used in translation.
792
-                    __("Mon",'geodirectory');
793
-                    __("Tue",'geodirectory');
794
-                    __("Wed",'geodirectory');
795
-                    __("Thu",'geodirectory');
796
-                    __("Fri",'geodirectory');
797
-                    __("Sat",'geodirectory');
798
-                    __("Sun",'geodirectory');
799
-                    ?>
791
+					// Here we list the shorthand days of the week so it can be used in translation.
792
+					__("Mon",'geodirectory');
793
+					__("Tue",'geodirectory');
794
+					__("Wed",'geodirectory');
795
+					__("Thu",'geodirectory');
796
+					__("Fri",'geodirectory');
797
+					__("Sat",'geodirectory');
798
+					__("Sun",'geodirectory');
799
+					?>
800 800
 
801 801
                     labels = [
802 802
                         "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
@@ -1045,24 +1045,24 @@  discard block
 block discarded – undo
1045 1045
         </span>
1046 1046
 
1047 1047
     <?php
1048
-    }
1049
-    /**
1050
-     * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1051
-     *
1052
-     * @since 1.0.0
1053
-     */
1054
-    do_action('geodir_after_google_analytics');
1055
-    $content_html = ob_get_clean();
1056
-    if (trim($content_html) != '')
1057
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1058
-    if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1059
-        /**
1060
-         * Filter the geodir_edit_post_link() function content.
1061
-         *
1062
-         * @param string $content_html The output html of the geodir_edit_post_link() function.
1063
-         */
1064
-        echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1065
-    }
1048
+	}
1049
+	/**
1050
+	 * This is called after the edit post link html in the function geodir_detail_page_google_analytics()
1051
+	 *
1052
+	 * @since 1.0.0
1053
+	 */
1054
+	do_action('geodir_after_google_analytics');
1055
+	$content_html = ob_get_clean();
1056
+	if (trim($content_html) != '')
1057
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1058
+	if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1059
+		/**
1060
+		 * Filter the geodir_edit_post_link() function content.
1061
+		 *
1062
+		 * @param string $content_html The output html of the geodir_edit_post_link() function.
1063
+		 */
1064
+		echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
1065
+	}
1066 1066
 }
1067 1067
 
1068 1068
 /**
@@ -1079,94 +1079,94 @@  discard block
 block discarded – undo
1079 1079
  */
1080 1080
 function geodir_detail_page_review_rating()
1081 1081
 {
1082
-    global $post, $preview, $post_images;
1082
+	global $post, $preview, $post_images;
1083 1083
     
1084
-    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1085
-        return;
1086
-    }
1087
-    ob_start(); // Start  buffering;
1088
-    /**
1089
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1090
-     *
1091
-     * This is called outside the check for an actual rating and the check for preview page.
1092
-     *
1093
-     * @since 1.0.0
1094
-     */
1095
-    do_action('geodir_before_detail_page_review_rating');
1096
-
1097
-    $comment_count = geodir_get_review_count_total($post->ID);
1098
-    $post_avgratings = geodir_get_post_rating($post->ID);
1099
-
1100
-    if ($post_avgratings != 0 && !$preview) {
1101
-        /**
1102
-         * This is called before the rating html in the function geodir_detail_page_review_rating().
1103
-         *
1104
-         * This is called inside the check for an actual rating and the check for preview page.
1105
-         *
1106
-         * @since 1.0.0
1107
-         * @param float $post_avgratings Average rating for the current post.
1108
-         * @param int $post->ID Current post ID.
1109
-         */
1110
-        do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1111
-
1112
-        $html = '<p style=" float:left;">';
1113
-        $html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1114
-        $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1115
-        $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1084
+	if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1085
+		return;
1086
+	}
1087
+	ob_start(); // Start  buffering;
1088
+	/**
1089
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1090
+	 *
1091
+	 * This is called outside the check for an actual rating and the check for preview page.
1092
+	 *
1093
+	 * @since 1.0.0
1094
+	 */
1095
+	do_action('geodir_before_detail_page_review_rating');
1096
+
1097
+	$comment_count = geodir_get_review_count_total($post->ID);
1098
+	$post_avgratings = geodir_get_post_rating($post->ID);
1099
+
1100
+	if ($post_avgratings != 0 && !$preview) {
1101
+		/**
1102
+		 * This is called before the rating html in the function geodir_detail_page_review_rating().
1103
+		 *
1104
+		 * This is called inside the check for an actual rating and the check for preview page.
1105
+		 *
1106
+		 * @since 1.0.0
1107
+		 * @param float $post_avgratings Average rating for the current post.
1108
+		 * @param int $post->ID Current post ID.
1109
+		 */
1110
+		do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1111
+
1112
+		$html = '<p style=" float:left;">';
1113
+		$html .= geodir_get_rating_stars($post_avgratings, $post->ID);
1114
+		$html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
1115
+		$post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings;
1116 1116
        
1117 1117
 	   $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
1118 1118
 	   
1119 1119
 	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
1120 1120
 
1121
-        $html .= '<span class="item">';
1122
-        $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1121
+		$html .= '<span class="item">';
1122
+		$html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1123 1123
 
1124
-        if ($post_images) {
1125
-            foreach ($post_images as $img) {
1126
-                $post_img = $img->src;
1127
-                break;
1128
-            }
1129
-        }
1130
-
1131
-        if (isset($post_img) && $post_img) {
1132
-            $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1133
-        }
1134
-
1135
-        $html .= '</span>';
1136
-
1137
-        echo $html .= '</div>';
1138
-        /**
1139
-         * This is called after the rating html in the function geodir_detail_page_review_rating().
1140
-         *
1141
-         * This is called inside the check for an actual rating and the check for preview page.
1142
-         *
1143
-         * @since 1.0.0
1144
-         * @param float $post_avgratings Average rating for the current post.
1145
-         * @param int $post->ID Current post ID.
1146
-         */
1147
-        do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1148
-    }
1149
-    /**
1150
-     * This is called before the rating html in the function geodir_detail_page_review_rating().
1151
-     *
1152
-     * This is called outside the check for an actual rating and the check for preview page.
1153
-     *
1154
-     * @since 1.0.0
1155
-     */
1156
-    do_action('geodir_after_detail_page_review_rating');
1157
-    $content_html = ob_get_clean();
1158
-    if (trim($content_html) != '') {
1159
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1160
-    }
1161
-    if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1162
-        /**
1163
-         * Filter the geodir_detail_page_review_rating() function content.
1164
-         *
1165
-         * @since 1.0.0
1166
-         * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1167
-         */
1168
-        echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1169
-    }
1124
+		if ($post_images) {
1125
+			foreach ($post_images as $img) {
1126
+				$post_img = $img->src;
1127
+				break;
1128
+			}
1129
+		}
1130
+
1131
+		if (isset($post_img) && $post_img) {
1132
+			$html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1133
+		}
1134
+
1135
+		$html .= '</span>';
1136
+
1137
+		echo $html .= '</div>';
1138
+		/**
1139
+		 * This is called after the rating html in the function geodir_detail_page_review_rating().
1140
+		 *
1141
+		 * This is called inside the check for an actual rating and the check for preview page.
1142
+		 *
1143
+		 * @since 1.0.0
1144
+		 * @param float $post_avgratings Average rating for the current post.
1145
+		 * @param int $post->ID Current post ID.
1146
+		 */
1147
+		do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
1148
+	}
1149
+	/**
1150
+	 * This is called before the rating html in the function geodir_detail_page_review_rating().
1151
+	 *
1152
+	 * This is called outside the check for an actual rating and the check for preview page.
1153
+	 *
1154
+	 * @since 1.0.0
1155
+	 */
1156
+	do_action('geodir_after_detail_page_review_rating');
1157
+	$content_html = ob_get_clean();
1158
+	if (trim($content_html) != '') {
1159
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1160
+	}
1161
+	if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1162
+		/**
1163
+		 * Filter the geodir_detail_page_review_rating() function content.
1164
+		 *
1165
+		 * @since 1.0.0
1166
+		 * @param string $content_html The output html of the geodir_detail_page_review_rating() function.
1167
+		 */
1168
+		echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
1169
+	}
1170 1170
 }
1171 1171
 
1172 1172
 /**
@@ -1178,35 +1178,35 @@  discard block
 block discarded – undo
1178 1178
  */
1179 1179
 function geodir_detail_page_more_info()
1180 1180
 {
1181
-    ob_start(); // Start  buffering;
1182
-    /**
1183
-     * This is called before the info section html.
1184
-     *
1185
-     * @since 1.0.0
1186
-     */
1187
-    do_action('geodir_before_detail_page_more_info');
1188
-    if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1189
-        echo $geodir_post_detail_fields;
1190
-    }
1191
-    /**
1192
-     * This is called after the info section html.
1193
-     *
1194
-     * @since 1.0.0
1195
-     */
1196
-    do_action('geodir_after_detail_page_more_info');
1197
-
1198
-    $content_html = ob_get_clean();
1199
-    if (trim($content_html) != '')
1200
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1201
-    if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1202
-        /**
1203
-         * Filter the output html for function geodir_detail_page_more_info().
1204
-         *
1205
-         * @since 1.0.0
1206
-         * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1207
-         */
1208
-        echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1209
-    }
1181
+	ob_start(); // Start  buffering;
1182
+	/**
1183
+	 * This is called before the info section html.
1184
+	 *
1185
+	 * @since 1.0.0
1186
+	 */
1187
+	do_action('geodir_before_detail_page_more_info');
1188
+	if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) {
1189
+		echo $geodir_post_detail_fields;
1190
+	}
1191
+	/**
1192
+	 * This is called after the info section html.
1193
+	 *
1194
+	 * @since 1.0.0
1195
+	 */
1196
+	do_action('geodir_after_detail_page_more_info');
1197
+
1198
+	$content_html = ob_get_clean();
1199
+	if (trim($content_html) != '')
1200
+		$content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1201
+	if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1202
+		/**
1203
+		 * Filter the output html for function geodir_detail_page_more_info().
1204
+		 *
1205
+		 * @since 1.0.0
1206
+		 * @param string $content_html The output html of the geodir_detail_page_more_info() function.
1207
+		 */
1208
+		echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
1209
+	}
1210 1210
 }
1211 1211
 
1212 1212
 
@@ -1220,15 +1220,15 @@  discard block
 block discarded – undo
1220 1220
  */
1221 1221
 function geodir_localize_all_js_msg()
1222 1222
 {// check_ajax_referer function is used to make sure no files are uploaded remotely but it will fail if used between https and non https so we do the check below of the urls
1223
-    if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1224
-        $ajax_url = admin_url('admin-ajax.php');
1225
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1226
-        $ajax_url = admin_url('admin-ajax.php');
1227
-    } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1228
-        $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1229
-    } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1230
-        $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1231
-    }
1223
+	if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1224
+		$ajax_url = admin_url('admin-ajax.php');
1225
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1226
+		$ajax_url = admin_url('admin-ajax.php');
1227
+	} elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
1228
+		$ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
1229
+	} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
1230
+		$ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
1231
+	}
1232 1232
 	
1233 1233
 	/**
1234 1234
 	 * Filter the allowed image type extensions for post images.
@@ -1238,60 +1238,60 @@  discard block
 block discarded – undo
1238 1238
 	 */
1239 1239
 	$allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
1240 1240
 	
1241
-    $default_marker_icon = get_option('geodir_default_marker_icon');
1242
-    $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1243
-    $default_marker_width = $default_marker_size['w'];
1244
-    $default_marker_height = $default_marker_size['h'];
1241
+	$default_marker_icon = get_option('geodir_default_marker_icon');
1242
+	$default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
1243
+	$default_marker_width = $default_marker_size['w'];
1244
+	$default_marker_height = $default_marker_size['h'];
1245 1245
     
1246
-    $arr_alert_msg = array(
1247
-        'geodir_plugin_url' => geodir_plugin_url(),
1248
-        'geodir_admin_ajax_url' => $ajax_url,
1249
-        'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1250
-        'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1251
-        'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1252
-        'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1253
-        //start not show alert msg
1254
-        'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1255
-        'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1256
-        'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1257
-        'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1258
-        'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1259
-        // end not show alert msg
1260
-        'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'),
1261
-        'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1262
-        //start not show alert msg
1263
-        'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1264
-        'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1265
-        'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1266
-        'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1267
-        'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1268
-        'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1269
-        'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1270
-        'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1271
-        'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1272
-        'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1273
-        'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1274
-        'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1275
-        'geodir_default_marker_icon' => $default_marker_icon,
1276
-        'geodir_default_marker_w' => $default_marker_width,
1277
-        'geodir_default_marker_h' => $default_marker_height,
1278
-        'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1279
-        'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1280
-        'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1281
-        'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1282
-        'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1283
-        'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1284
-        'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1285
-        'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1286
-        /* on/off dragging for phone devices */
1287
-        'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1288
-        'geodir_is_mobile' => wp_is_mobile() ? true : false,
1289
-        'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1290
-        'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1291
-        'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1292
-        'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1293
-        'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1294
-        'geodir_action_remove' => __('Remove', 'geodirectory'),
1246
+	$arr_alert_msg = array(
1247
+		'geodir_plugin_url' => geodir_plugin_url(),
1248
+		'geodir_admin_ajax_url' => $ajax_url,
1249
+		'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
1250
+		'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
1251
+		'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
1252
+		'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
1253
+		//start not show alert msg
1254
+		'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
1255
+		'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
1256
+		'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
1257
+		'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
1258
+		'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
1259
+		// end not show alert msg
1260
+		'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'),
1261
+		'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'),
1262
+		//start not show alert msg
1263
+		'rating_error_msg' => __('Error : please retry', 'geodirectory'),
1264
+		'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
1265
+		'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
1266
+		'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
1267
+		'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
1268
+		'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
1269
+		'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
1270
+		'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
1271
+		'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
1272
+		'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
1273
+		'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
1274
+		'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
1275
+		'geodir_default_marker_icon' => $default_marker_icon,
1276
+		'geodir_default_marker_w' => $default_marker_width,
1277
+		'geodir_default_marker_h' => $default_marker_height,
1278
+		'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG,
1279
+		'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG,
1280
+		'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
1281
+		'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
1282
+		'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
1283
+		'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
1284
+		'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
1285
+		'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
1286
+		/* on/off dragging for phone devices */
1287
+		'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
1288
+		'geodir_is_mobile' => wp_is_mobile() ? true : false,
1289
+		'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
1290
+		'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
1291
+		'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
1292
+		'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
1293
+		'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
1294
+		'geodir_action_remove' => __('Remove', 'geodirectory'),
1295 1295
 		'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
1296 1296
 		'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
1297 1297
 		'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
@@ -1299,40 +1299,40 @@  discard block
 block discarded – undo
1299 1299
 		'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
1300 1300
 		'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1301 1301
 		'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
1302
-        'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1303
-        'geodir_map_name' => geodir_map_name(),
1304
-        'osmStart' => __('Start', 'geodirectory'),
1305
-        'osmVia' => __('Via {viaNumber}', 'geodirectory'),
1306
-        'osmEnd' => __('Enter Your Location', 'geodirectory'),
1307
-        'ga_delete_check' => __('Are you wish to Deauthorize and break Analytics?', 'geodirectory'),
1308
-        'geoMyLocation' => __('My Location', 'geodirectory'),
1309
-        'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')),
1310
-        'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')),
1311
-        'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')),
1312
-        'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')),
1313
-        'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')),
1314
-    );
1315
-
1316
-    /**
1317
-     * Filters the translated JS strings from function geodir_localize_all_js_msg().
1318
-     *
1319
-     * With this filter you can add, remove or change translated JS strings.
1320
-     * You should add your own translations to this if you are building an addon rather than adding another script block.
1321
-     *
1322
-     * @since 1.0.0
1323
-     */
1324
-    $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1325
-
1326
-    foreach ($arr_alert_msg as $key => $value) {
1327
-        if (!is_scalar($value))
1328
-            continue;
1329
-        $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1330
-    }
1302
+		'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1303
+		'geodir_map_name' => geodir_map_name(),
1304
+		'osmStart' => __('Start', 'geodirectory'),
1305
+		'osmVia' => __('Via {viaNumber}', 'geodirectory'),
1306
+		'osmEnd' => __('Enter Your Location', 'geodirectory'),
1307
+		'ga_delete_check' => __('Are you wish to Deauthorize and break Analytics?', 'geodirectory'),
1308
+		'geoMyLocation' => __('My Location', 'geodirectory'),
1309
+		'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')),
1310
+		'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')),
1311
+		'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')),
1312
+		'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')),
1313
+		'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')),
1314
+	);
1315
+
1316
+	/**
1317
+	 * Filters the translated JS strings from function geodir_localize_all_js_msg().
1318
+	 *
1319
+	 * With this filter you can add, remove or change translated JS strings.
1320
+	 * You should add your own translations to this if you are building an addon rather than adding another script block.
1321
+	 *
1322
+	 * @since 1.0.0
1323
+	 */
1324
+	$arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1331 1325
 
1332
-    $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1333
-    echo '<script>';
1334
-    echo $script;
1335
-    echo '</script>';
1326
+	foreach ($arr_alert_msg as $key => $value) {
1327
+		if (!is_scalar($value))
1328
+			continue;
1329
+		$arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1330
+	}
1331
+
1332
+	$script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1333
+	echo '<script>';
1334
+	echo $script;
1335
+	echo '</script>';
1336 1336
 }
1337 1337
 
1338 1338
 add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31);
@@ -1348,11 +1348,11 @@  discard block
 block discarded – undo
1348 1348
  */
1349 1349
 function geodir_admin_bar_site_menu($wp_admin_bar)
1350 1350
 {
1351
-    if (get_option("geodir_installed")) {
1352
-        if (current_user_can('manage_options')) {
1353
-            $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1354
-        }
1355
-    }
1351
+	if (get_option("geodir_installed")) {
1352
+		if (current_user_can('manage_options')) {
1353
+			$wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
1354
+		}
1355
+	}
1356 1356
 }
1357 1357
 
1358 1358
 add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/
@@ -1378,25 +1378,25 @@  discard block
 block discarded – undo
1378 1378
  */
1379 1379
 function geodir_store_sidebars()
1380 1380
 {
1381
-    global $geodir_sidebars;
1382
-    global $sidebars_widgets;
1383
-
1384
-    if (!is_array($sidebars_widgets))
1385
-        $sidebars_widgets = wp_get_sidebars_widgets();
1386
-    $geodir_old_sidebars = array();
1387
-
1388
-    if (is_array($geodir_sidebars)) {
1389
-        foreach ($geodir_sidebars as $val) {
1390
-            if (is_array($sidebars_widgets)) {
1391
-                if (array_key_exists($val, $sidebars_widgets))
1392
-                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1393
-                else
1394
-                    $geodir_old_sidebars[$val] = array();
1395
-            }
1396
-        }
1397
-    }
1398
-    update_option('geodir_sidebars', $geodir_old_sidebars);
1399
-    geodir_option_version_backup('geodir_sidebars');
1381
+	global $geodir_sidebars;
1382
+	global $sidebars_widgets;
1383
+
1384
+	if (!is_array($sidebars_widgets))
1385
+		$sidebars_widgets = wp_get_sidebars_widgets();
1386
+	$geodir_old_sidebars = array();
1387
+
1388
+	if (is_array($geodir_sidebars)) {
1389
+		foreach ($geodir_sidebars as $val) {
1390
+			if (is_array($sidebars_widgets)) {
1391
+				if (array_key_exists($val, $sidebars_widgets))
1392
+					$geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1393
+				else
1394
+					$geodir_old_sidebars[$val] = array();
1395
+			}
1396
+		}
1397
+	}
1398
+	update_option('geodir_sidebars', $geodir_old_sidebars);
1399
+	geodir_option_version_backup('geodir_sidebars');
1400 1400
 
1401 1401
 }
1402 1402
 
@@ -1410,28 +1410,28 @@  discard block
 block discarded – undo
1410 1410
  */
1411 1411
 function geodir_restore_sidebars()
1412 1412
 {
1413
-    global $sidebars_widgets;
1414
-
1415
-    if (!is_array($sidebars_widgets))
1416
-        $sidebars_widgets = wp_get_sidebars_widgets();
1417
-
1418
-    if (is_array($sidebars_widgets)) {
1419
-        $geodir_old_sidebars = get_option('geodir_sidebars');
1420
-        if (is_array($geodir_old_sidebars)) {
1421
-            foreach ($geodir_old_sidebars as $key => $val) {
1422
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1423
-                {
1424
-                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1425
-                }
1413
+	global $sidebars_widgets;
1426 1414
 
1415
+	if (!is_array($sidebars_widgets))
1416
+		$sidebars_widgets = wp_get_sidebars_widgets();
1427 1417
 
1428
-            }
1429
-        }
1418
+	if (is_array($sidebars_widgets)) {
1419
+		$geodir_old_sidebars = get_option('geodir_sidebars');
1420
+		if (is_array($geodir_old_sidebars)) {
1421
+			foreach ($geodir_old_sidebars as $key => $val) {
1422
+				if(0 === strpos($key, 'geodir_'))// if gd widget
1423
+				{
1424
+					$sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1425
+				}
1430 1426
 
1431
-    }
1432 1427
 
1433
-    update_option('sidebars_widgets', $sidebars_widgets);
1434
-    update_option('geodir_sidebars', '');
1428
+			}
1429
+		}
1430
+
1431
+	}
1432
+
1433
+	update_option('sidebars_widgets', $sidebars_widgets);
1434
+	update_option('geodir_sidebars', '');
1435 1435
 }
1436 1436
 
1437 1437
 add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview');
@@ -1444,9 +1444,9 @@  discard block
 block discarded – undo
1444 1444
  */
1445 1445
 function geodir_after_listing_post_gridview()
1446 1446
 {
1447
-    global $gridview_columns;
1447
+	global $gridview_columns;
1448 1448
 
1449
-    $gridview_columns = '';
1449
+	$gridview_columns = '';
1450 1450
 
1451 1451
 }
1452 1452
 
@@ -1474,11 +1474,11 @@  discard block
 block discarded – undo
1474 1474
  */
1475 1475
 function so_handle_038($url, $original_url, $_context)
1476 1476
 {
1477
-    if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1478
-        $url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1479
-    }
1477
+	if (strstr($url, "maps.google.com/maps/api/js") !== false) {
1478
+		$url = str_replace("&#038;", "&amp;", $url); // or $url = $original_url
1479
+	}
1480 1480
 
1481
-    return $url;
1481
+	return $url;
1482 1482
 }
1483 1483
 
1484 1484
 
@@ -1494,34 +1494,34 @@  discard block
 block discarded – undo
1494 1494
 function geodir_after_main_form_fields() {
1495 1495
 	global $gd_session;
1496 1496
 	
1497
-    if (get_option('geodir_accept_term_condition')) {
1498
-        global $post;
1499
-        $term_condition = '';
1500
-        if (isset($_REQUEST['backandedit'])) {
1501
-            $post = (object)$gd_session->get('listing');
1502
-            $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1503
-        }
1504
-
1505
-        ?>
1497
+	if (get_option('geodir_accept_term_condition')) {
1498
+		global $post;
1499
+		$term_condition = '';
1500
+		if (isset($_REQUEST['backandedit'])) {
1501
+			$post = (object)$gd_session->get('listing');
1502
+			$term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1503
+		}
1504
+
1505
+		?>
1506 1506
         <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix">
1507 1507
             <label>&nbsp;</label>
1508 1508
 
1509 1509
             <div class="geodir_taxonomy_field" style="float:left; width:70%;">
1510 1510
 				<span style="display:block"> 
1511 1511
 				<input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') {
1512
-                    echo 'checked="checked"';
1513
-                } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1512
+					echo 'checked="checked"';
1513
+				} ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1514 1514
                        class="geodir_textfield" value="1"
1515 1515
                        style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1516 1516
 				</span>
1517 1517
             </div>
1518 1518
             <span class="geodir_message_error"><?php if (isset($required_msg)) {
1519
-                    _e($required_msg, 'geodirectory');
1520
-                } ?></span>
1519
+					_e($required_msg, 'geodirectory');
1520
+				} ?></span>
1521 1521
         </div>
1522 1522
     <?php
1523 1523
 
1524
-    }
1524
+	}
1525 1525
 }
1526 1526
 
1527 1527
 
@@ -1546,42 +1546,42 @@  discard block
 block discarded – undo
1546 1546
  */
1547 1547
 function geodir_detail_page_tab_is_display($is_display, $tab)
1548 1548
 {
1549
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1549
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1550 1550
 
1551
-    if ($tab == 'post_profile') {
1552
-        /** This action is documented in geodirectory_template_actions.php */
1553
-        $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1551
+	if ($tab == 'post_profile') {
1552
+		/** This action is documented in geodirectory_template_actions.php */
1553
+		$desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1554 1554
         
1555
-        if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1556
-            $is_display = false;
1557
-        }
1558
-    }
1555
+		if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1556
+			$is_display = false;
1557
+		}
1558
+	}
1559 1559
     
1560
-    if ($tab == 'post_info')
1561
-        $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1560
+	if ($tab == 'post_info')
1561
+		$is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1562 1562
     
1563
-    if ($tab == 'post_images')
1564
-        $is_display = (!empty($post_images)) ? true : false;
1563
+	if ($tab == 'post_images')
1564
+		$is_display = (!empty($post_images)) ? true : false;
1565 1565
 
1566
-    if ($tab == 'post_video')
1567
-        $is_display = (!empty($video)) ? true : false;
1566
+	if ($tab == 'post_video')
1567
+		$is_display = (!empty($video)) ? true : false;
1568 1568
 
1569
-    if ($tab == 'special_offers')
1570
-        $is_display = (!empty($special_offers)) ? true : false;
1569
+	if ($tab == 'special_offers')
1570
+		$is_display = (!empty($special_offers)) ? true : false;
1571 1571
 
1572
-    if ($tab == 'reviews')
1573
-        $is_display = (geodir_is_page('detail')) ? true : false;
1572
+	if ($tab == 'reviews')
1573
+		$is_display = (geodir_is_page('detail')) ? true : false;
1574 1574
 
1575
-    if ($tab == 'related_listing') {
1576
-       $message = __('No listings found which match your selection.', 'geodirectory');
1575
+	if ($tab == 'related_listing') {
1576
+	   $message = __('No listings found which match your selection.', 'geodirectory');
1577 1577
        
1578
-       /** This action is documented in geodirectory-functions/template_functions.php */
1579
-       $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1578
+	   /** This action is documented in geodirectory-functions/template_functions.php */
1579
+	   $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
1580 1580
        
1581
-       $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1582
-    }
1581
+	   $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
1582
+	}
1583 1583
 
1584
-    return $is_display;
1584
+	return $is_display;
1585 1585
 }
1586 1586
 
1587 1587
 
@@ -1597,69 +1597,69 @@  discard block
 block discarded – undo
1597 1597
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1598 1598
  */
1599 1599
 function geodir_changes_in_custom_fields_table() {
1600
-    global $wpdb, $plugin_prefix;
1600
+	global $wpdb, $plugin_prefix;
1601 1601
 	
1602 1602
 	// Remove unused virtual page
1603 1603
 	$listings_page_id = (int)get_option('geodir_listing_page');
1604 1604
 	if ($listings_page_id) {
1605 1605
 		$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1606
-        delete_option('geodir_listing_page');
1606
+		delete_option('geodir_listing_page');
1607 1607
 	}
1608 1608
 
1609
-    if (!get_option('geodir_changes_in_custom_fields_table')) {
1610
-        $wpdb->query(
1611
-            $wpdb->prepare(
1612
-                "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1613
-                array('1', '1', 'admin')
1614
-            )
1615
-        );
1609
+	if (!get_option('geodir_changes_in_custom_fields_table')) {
1610
+		$wpdb->query(
1611
+			$wpdb->prepare(
1612
+				"UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1613
+				array('1', '1', 'admin')
1614
+			)
1615
+		);
1616 1616
 
1617 1617
 
1618
-        /* --- terms meta value set --- */
1618
+		/* --- terms meta value set --- */
1619 1619
 
1620
-        update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1620
+		update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1621 1621
 
1622
-        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1622
+		$options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1623 1623
 
1624
-        if (!empty($options_data)) {
1624
+		if (!empty($options_data)) {
1625 1625
 
1626
-            foreach ($options_data as $optobj) {
1626
+			foreach ($options_data as $optobj) {
1627 1627
 
1628
-                $option_val = str_replace('tax_meta_', '', $optobj->option_name);
1628
+				$option_val = str_replace('tax_meta_', '', $optobj->option_name);
1629 1629
 
1630
-                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1630
+				$taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1631 1631
 
1632
-                if (!empty($taxonomies_data)) {
1632
+				if (!empty($taxonomies_data)) {
1633 1633
 
1634
-                    foreach ($taxonomies_data as $taxobj) {
1634
+					foreach ($taxonomies_data as $taxobj) {
1635 1635
 
1636
-                        $taxObject = get_taxonomy($taxobj->taxonomy);
1637
-                        $post_type = $taxObject->object_type[0];
1636
+						$taxObject = get_taxonomy($taxobj->taxonomy);
1637
+						$post_type = $taxObject->object_type[0];
1638 1638
 
1639
-                        $opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1639
+						$opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1640 1640
 
1641
-                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1641
+						$duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1642 1642
 
1643
-                        if ($duplicate_data) {
1643
+						if ($duplicate_data) {
1644 1644
 
1645
-                            $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1645
+							$wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1646 1646
 
1647
-                        } else {
1647
+						} else {
1648 1648
 
1649
-                            $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1649
+							$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1650 1650
 
1651
-                        }
1651
+						}
1652 1652
 
1653
-                    }
1653
+					}
1654 1654
 
1655
-                }
1655
+				}
1656 1656
 
1657
-            }
1658
-        }
1657
+			}
1658
+		}
1659 1659
 
1660
-        update_option('geodir_changes_in_custom_fields_table', '1');
1660
+		update_option('geodir_changes_in_custom_fields_table', '1');
1661 1661
 
1662
-    }
1662
+	}
1663 1663
 
1664 1664
 }
1665 1665
 
@@ -1678,24 +1678,24 @@  discard block
 block discarded – undo
1678 1678
 function geodir_location_slug_check($slug)
1679 1679
 {
1680 1680
 
1681
-    global $wpdb, $table_prefix;
1681
+	global $wpdb, $table_prefix;
1682 1682
 
1683
-    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1683
+	$slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1684 1684
 
1685
-    if ($slug_exists) {
1685
+	if ($slug_exists) {
1686 1686
 
1687
-        $suffix = 1;
1688
-        do {
1689
-            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1690
-            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1691
-            $suffix++;
1692
-        } while ($location_slug_check && $suffix < 100);
1687
+		$suffix = 1;
1688
+		do {
1689
+			$alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1690
+			$location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1691
+			$suffix++;
1692
+		} while ($location_slug_check && $suffix < 100);
1693 1693
 
1694
-        $slug = $alt_location_name;
1694
+		$slug = $alt_location_name;
1695 1695
 
1696
-    }
1696
+	}
1697 1697
 
1698
-    return $slug;
1698
+	return $slug;
1699 1699
 
1700 1700
 }
1701 1701
 
@@ -1720,42 +1720,42 @@  discard block
 block discarded – undo
1720 1720
 function geodir_update_term_slug($term_id, $tt_id, $taxonomy)
1721 1721
 {
1722 1722
 
1723
-    global $wpdb, $plugin_prefix, $table_prefix;
1723
+	global $wpdb, $plugin_prefix, $table_prefix;
1724 1724
 
1725
-    $tern_data = get_term_by('id', $term_id, $taxonomy);
1725
+	$tern_data = get_term_by('id', $term_id, $taxonomy);
1726 1726
 
1727
-    $slug = $tern_data->slug;
1727
+	$slug = $tern_data->slug;
1728 1728
 
1729
-    /**
1730
-     * Filter if a term slug exists.
1731
-     *
1732
-     * @since 1.0.0
1733
-     * @package GeoDirectory
1734
-     * @param bool $bool Default: false.
1735
-     * @param string $slug The term slug.
1736
-     * @param int $term_id The term ID.
1737
-     */
1738
-    $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1729
+	/**
1730
+	 * Filter if a term slug exists.
1731
+	 *
1732
+	 * @since 1.0.0
1733
+	 * @package GeoDirectory
1734
+	 * @param bool $bool Default: false.
1735
+	 * @param string $slug The term slug.
1736
+	 * @param int $term_id The term ID.
1737
+	 */
1738
+	$slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
1739 1739
 
1740
-    if ($slug_exists) {
1740
+	if ($slug_exists) {
1741 1741
 
1742
-        $suffix = 1;
1743
-        do {
1744
-            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1742
+		$suffix = 1;
1743
+		do {
1744
+			$new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1745 1745
 
1746
-            /** This action is documented in geodirectory_hooks_actions.php */
1747
-            $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1746
+			/** This action is documented in geodirectory_hooks_actions.php */
1747
+			$term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
1748 1748
 
1749
-            $suffix++;
1750
-        } while ($term_slug_check && $suffix < 100);
1749
+			$suffix++;
1750
+		} while ($term_slug_check && $suffix < 100);
1751 1751
 
1752
-        $slug = $new_slug;
1752
+		$slug = $new_slug;
1753 1753
 
1754
-        //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1754
+		//wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1755 1755
 
1756
-        $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1756
+		$wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1757 1757
 
1758
-    }
1758
+	}
1759 1759
 	
1760 1760
 	// Update tag in detail table.
1761 1761
 	$taxonomy_obj = get_taxonomy($taxonomy);
@@ -1796,21 +1796,21 @@  discard block
 block discarded – undo
1796 1796
 function geodir_term_slug_is_exists($slug_exists, $slug, $term_id)
1797 1797
 {
1798 1798
 
1799
-    global $wpdb, $table_prefix;
1799
+	global $wpdb, $table_prefix;
1800 1800
 
1801
-    $default_location = geodir_get_default_location();
1801
+	$default_location = geodir_get_default_location();
1802 1802
 
1803
-    $country_slug = $default_location->country_slug;
1804
-    $region_slug = $default_location->region_slug;
1805
-    $city_slug = $default_location->city_slug;
1803
+	$country_slug = $default_location->country_slug;
1804
+	$region_slug = $default_location->region_slug;
1805
+	$city_slug = $default_location->city_slug;
1806 1806
 
1807
-    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1808
-        return $slug_exists = true;
1807
+	if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1808
+		return $slug_exists = true;
1809 1809
 
1810
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1811
-        return $slug_exists = true;
1810
+	if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1811
+		return $slug_exists = true;
1812 1812
 
1813
-    return $slug_exists;
1813
+	return $slug_exists;
1814 1814
 }
1815 1815
 
1816 1816
 
@@ -1830,75 +1830,75 @@  discard block
 block discarded – undo
1830 1830
  */
1831 1831
 function geodir_custom_page_title($title = '', $sep = '')
1832 1832
 {
1833
-    global $wp;
1834
-    if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1835
-        return $title;
1836
-    }
1833
+	global $wp;
1834
+	if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
1835
+		return $title;
1836
+	}
1837 1837
 
1838
-    if ($sep == '') {
1839
-        /**
1840
-         * Filter the page title separator.
1841
-         *
1842
-         * @since 1.0.0
1843
-         * @package GeoDirectory
1844
-         * @param string $sep The separator, default: `|`.
1845
-         */
1846
-        $sep = apply_filters('geodir_page_title_separator', '|');
1847
-    }
1838
+	if ($sep == '') {
1839
+		/**
1840
+		 * Filter the page title separator.
1841
+		 *
1842
+		 * @since 1.0.0
1843
+		 * @package GeoDirectory
1844
+		 * @param string $sep The separator, default: `|`.
1845
+		 */
1846
+		$sep = apply_filters('geodir_page_title_separator', '|');
1847
+	}
1848 1848
 
1849 1849
 
1850
-    $gd_page = '';
1851
-    if(geodir_is_page('home')){
1852
-        $gd_page = 'home';
1853
-        $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1854
-    }
1855
-    elseif(geodir_is_page('detail')){
1856
-        $gd_page = 'detail';
1857
-        $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1858
-    }
1859
-    elseif(geodir_is_page('pt')){
1860
-        $gd_page = 'pt';
1861
-        $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1862
-    }
1863
-    elseif(geodir_is_page('listing')){
1864
-        $gd_page = 'listing';
1865
-        $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1866
-    }
1867
-    elseif(geodir_is_page('location')){
1868
-        $gd_page = 'location';
1869
-        $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1870
-    }
1871
-    elseif(geodir_is_page('search')){
1872
-        $gd_page = 'search';
1873
-        $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1874
-    }
1875
-    elseif(geodir_is_page('add-listing')){
1876
-        $gd_page = 'add-listing';
1877
-        $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1878
-    }
1879
-    elseif(geodir_is_page('author')){
1880
-        $gd_page = 'author';
1881
-        $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1882
-    }
1883
-    elseif(geodir_is_page('login')){
1884
-        $gd_page = 'login';
1885
-        $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1886
-    }
1887
-    elseif(geodir_is_page('listing-success')){
1888
-        $gd_page = 'listing-success';
1889
-        $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1890
-    }
1850
+	$gd_page = '';
1851
+	if(geodir_is_page('home')){
1852
+		$gd_page = 'home';
1853
+		$title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1854
+	}
1855
+	elseif(geodir_is_page('detail')){
1856
+		$gd_page = 'detail';
1857
+		$title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1858
+	}
1859
+	elseif(geodir_is_page('pt')){
1860
+		$gd_page = 'pt';
1861
+		$title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1862
+	}
1863
+	elseif(geodir_is_page('listing')){
1864
+		$gd_page = 'listing';
1865
+		$title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1866
+	}
1867
+	elseif(geodir_is_page('location')){
1868
+		$gd_page = 'location';
1869
+		$title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1870
+	}
1871
+	elseif(geodir_is_page('search')){
1872
+		$gd_page = 'search';
1873
+		$title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1874
+	}
1875
+	elseif(geodir_is_page('add-listing')){
1876
+		$gd_page = 'add-listing';
1877
+		$title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1878
+	}
1879
+	elseif(geodir_is_page('author')){
1880
+		$gd_page = 'author';
1881
+		$title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1882
+	}
1883
+	elseif(geodir_is_page('login')){
1884
+		$gd_page = 'login';
1885
+		$title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1886
+	}
1887
+	elseif(geodir_is_page('listing-success')){
1888
+		$gd_page = 'listing-success';
1889
+		$title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1890
+	}
1891 1891
 
1892 1892
 
1893
-    /**
1894
-     * Filter page meta title to replace variables.
1895
-     *
1896
-     * @since 1.5.4
1897
-     * @param string $title The page title including variables.
1898
-     * @param string $gd_page The GeoDirectory page type if any.
1899
-     * @param string $sep The title separator symbol.
1900
-     */
1901
-    return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1893
+	/**
1894
+	 * Filter page meta title to replace variables.
1895
+	 *
1896
+	 * @since 1.5.4
1897
+	 * @param string $title The page title including variables.
1898
+	 * @param string $gd_page The GeoDirectory page type if any.
1899
+	 * @param string $sep The title separator symbol.
1900
+	 */
1901
+	return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
1902 1902
 
1903 1903
 }
1904 1904
 
@@ -1914,36 +1914,36 @@  discard block
 block discarded – undo
1914 1914
 function geodir_set_post_attachment()
1915 1915
 {
1916 1916
 
1917
-    if (!get_option('geodir_set_post_attachments')) {
1917
+	if (!get_option('geodir_set_post_attachments')) {
1918 1918
 
1919
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1920
-        require_once(ABSPATH . 'wp-admin/includes/file.php');
1919
+		require_once(ABSPATH . 'wp-admin/includes/image.php');
1920
+		require_once(ABSPATH . 'wp-admin/includes/file.php');
1921 1921
 
1922
-        $all_postypes = geodir_get_posttypes();
1922
+		$all_postypes = geodir_get_posttypes();
1923 1923
 
1924
-        foreach($all_postypes as $post_type){
1925
-            $args = array(
1926
-                'posts_per_page' => -1,
1927
-                'post_type' => $post_type,
1928
-                'post_status' => 'publish');
1924
+		foreach($all_postypes as $post_type){
1925
+			$args = array(
1926
+				'posts_per_page' => -1,
1927
+				'post_type' => $post_type,
1928
+				'post_status' => 'publish');
1929 1929
 
1930
-            $posts_array = get_posts($args);
1930
+			$posts_array = get_posts($args);
1931 1931
 
1932
-            if (!empty($posts_array)) {
1932
+			if (!empty($posts_array)) {
1933 1933
 
1934
-                foreach ($posts_array as $post) {
1934
+				foreach ($posts_array as $post) {
1935 1935
 
1936
-                    geodir_set_wp_featured_image($post->ID);
1936
+					geodir_set_wp_featured_image($post->ID);
1937 1937
 
1938
-                }
1938
+				}
1939 1939
 
1940
-            }
1941
-        }
1940
+			}
1941
+		}
1942 1942
 
1943 1943
 
1944
-        update_option('geodir_set_post_attachments', '1');
1944
+		update_option('geodir_set_post_attachments', '1');
1945 1945
 
1946
-    }
1946
+	}
1947 1947
 
1948 1948
 }
1949 1949
 
@@ -1960,19 +1960,19 @@  discard block
 block discarded – undo
1960 1960
 function geodir_remove_url_seperator()
1961 1961
 {
1962 1962
 
1963
-    if (!get_option('geodir_remove_url_seperator')) {
1963
+	if (!get_option('geodir_remove_url_seperator')) {
1964 1964
 
1965
-        if (get_option('geodir_listingurl_separator'))
1966
-            delete_option('geodir_listingurl_separator');
1965
+		if (get_option('geodir_listingurl_separator'))
1966
+			delete_option('geodir_listingurl_separator');
1967 1967
 
1968
-        if (get_option('geodir_detailurl_separator'))
1969
-            delete_option('geodir_detailurl_separator');
1968
+		if (get_option('geodir_detailurl_separator'))
1969
+			delete_option('geodir_detailurl_separator');
1970 1970
 
1971
-        flush_rewrite_rules(false);
1971
+		flush_rewrite_rules(false);
1972 1972
 
1973
-        update_option('geodir_remove_url_seperator', '1');
1973
+		update_option('geodir_remove_url_seperator', '1');
1974 1974
 
1975
-    }
1975
+	}
1976 1976
 
1977 1977
 }
1978 1978
 
@@ -1988,19 +1988,19 @@  discard block
 block discarded – undo
1988 1988
  */
1989 1989
 function geodir_remove_url_seperator_form_permalink_settings($permalink_arr)
1990 1990
 {
1991
-    foreach ($permalink_arr as $key => $value) {
1991
+	foreach ($permalink_arr as $key => $value) {
1992 1992
 
1993
-        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
1994
-            unset($permalink_arr[$key]);
1993
+		if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
1994
+			unset($permalink_arr[$key]);
1995 1995
 
1996
-    }
1996
+	}
1997 1997
 
1998
-    return $permalink_arr;
1998
+	return $permalink_arr;
1999 1999
 
2000 2000
 }
2001 2001
 
2002 2002
 if (!is_admin()) {
2003
-    add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2003
+	add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
2004 2004
 }
2005 2005
 /**
2006 2006
  * Set status from draft to publish.
@@ -2013,16 +2013,16 @@  discard block
 block discarded – undo
2013 2013
  */
2014 2014
 function geodir_set_status_draft_to_publish_for_own_post($post)
2015 2015
 {
2016
-    $user_id = get_current_user_id();
2016
+	$user_id = get_current_user_id();
2017 2017
 
2018
-    if(!$user_id){return $post;}
2018
+	if(!$user_id){return $post;}
2019 2019
 
2020
-    $gd_post_types = geodir_get_posttypes();
2020
+	$gd_post_types = geodir_get_posttypes();
2021 2021
 
2022
-    if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2023
-        $post[0]->post_status = 'publish';
2024
-    }
2025
-    return $post;
2022
+	if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) {
2023
+		$post[0]->post_status = 'publish';
2024
+	}
2025
+	return $post;
2026 2026
 }
2027 2027
 
2028 2028
 
@@ -2114,33 +2114,33 @@  discard block
 block discarded – undo
2114 2114
  */
2115 2115
 function geodir_detail_page_tab_headings_change($tabs_arr)
2116 2116
 {
2117
-    global $wpdb;
2117
+	global $wpdb;
2118 2118
 
2119
-    $post_type = geodir_get_current_posttype();
2119
+	$post_type = geodir_get_current_posttype();
2120 2120
 
2121
-    $all_postypes = geodir_get_posttypes();
2121
+	$all_postypes = geodir_get_posttypes();
2122 2122
 
2123
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2123
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
2124 2124
 
2125
-        if (array_key_exists('post_video', $tabs_arr)) {
2125
+		if (array_key_exists('post_video', $tabs_arr)) {
2126 2126
 
2127
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2127
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2128 2128
 
2129
-            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2130
-                $tabs_arr['post_video']['heading_text'] = $field_title;
2131
-        }
2129
+			if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2130
+				$tabs_arr['post_video']['heading_text'] = $field_title;
2131
+		}
2132 2132
 
2133
-        if (array_key_exists('special_offers', $tabs_arr)) {
2133
+		if (array_key_exists('special_offers', $tabs_arr)) {
2134 2134
 
2135
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2135
+			$field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2136 2136
 
2137
-            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2138
-                $tabs_arr['special_offers']['heading_text'] = $field_title;
2139
-        }
2137
+			if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2138
+				$tabs_arr['special_offers']['heading_text'] = $field_title;
2139
+		}
2140 2140
 
2141
-    }
2141
+	}
2142 2142
 
2143
-    return $tabs_arr;
2143
+	return $tabs_arr;
2144 2144
 
2145 2145
 }
2146 2146
 
@@ -2153,10 +2153,10 @@  discard block
 block discarded – undo
2153 2153
  */
2154 2154
 function geodir_remove_template_redirect_actions()
2155 2155
 {
2156
-    if (geodir_is_page('login')){
2157
-        remove_all_actions('template_redirect');
2158
-        remove_action('init', 'avia_modify_front', 10);
2159
-    }
2156
+	if (geodir_is_page('login')){
2157
+		remove_all_actions('template_redirect');
2158
+		remove_action('init', 'avia_modify_front', 10);
2159
+	}
2160 2160
 }
2161 2161
 
2162 2162
 
@@ -2178,51 +2178,51 @@  discard block
 block discarded – undo
2178 2178
 function geodirectory_before_featured_image_delete($attachment_id)
2179 2179
 {
2180 2180
 
2181
-    global $wpdb, $plugin_prefix;
2181
+	global $wpdb, $plugin_prefix;
2182 2182
 
2183
-    $post_id = get_post_field('post_parent', $attachment_id);
2183
+	$post_id = get_post_field('post_parent', $attachment_id);
2184 2184
 
2185
-    $attachment_url = wp_get_attachment_url($attachment_id);
2185
+	$attachment_url = wp_get_attachment_url($attachment_id);
2186 2186
 
2187
-    if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2187
+	if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
2188 2188
 
2189
-        $post_type = get_post_type($post_id);
2189
+		$post_type = get_post_type($post_id);
2190 2190
 
2191
-        $all_postypes = geodir_get_posttypes();
2191
+		$all_postypes = geodir_get_posttypes();
2192 2192
 
2193
-        if (!in_array($post_type, $all_postypes) || !is_admin())
2194
-            return false;
2193
+		if (!in_array($post_type, $all_postypes) || !is_admin())
2194
+			return false;
2195 2195
 
2196
-        $uploads = wp_upload_dir();
2196
+		$uploads = wp_upload_dir();
2197 2197
 
2198
-        $split_img_path = explode($uploads['baseurl'], $attachment_url);
2198
+		$split_img_path = explode($uploads['baseurl'], $attachment_url);
2199 2199
 
2200
-        $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2200
+		$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2201 2201
 
2202
-        $wpdb->query(
2203
-            $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2204
-                array($post_id, $split_img_file_path)
2205
-            )
2206
-        );
2202
+		$wpdb->query(
2203
+			$wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2204
+				array($post_id, $split_img_file_path)
2205
+			)
2206
+		);
2207 2207
 
2208
-        $attachment_data = $wpdb->get_row(
2209
-            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2210
-                array($post_id)
2211
-            )
2212
-        );
2208
+		$attachment_data = $wpdb->get_row(
2209
+			$wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2210
+				array($post_id)
2211
+			)
2212
+		);
2213 2213
 
2214
-        if (!empty($attachment_data)) {
2215
-            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2216
-        }
2214
+		if (!empty($attachment_data)) {
2215
+			$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2216
+		}
2217 2217
 
2218 2218
 
2219
-        $table_name = $plugin_prefix . $post_type . '_detail';
2219
+		$table_name = $plugin_prefix . $post_type . '_detail';
2220 2220
 
2221
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2221
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2222 2222
 
2223
-        geodir_set_wp_featured_image($post_id);
2223
+		geodir_set_wp_featured_image($post_id);
2224 2224
 
2225
-    }
2225
+	}
2226 2226
 
2227 2227
 }
2228 2228
 
@@ -2240,79 +2240,79 @@  discard block
 block discarded – undo
2240 2240
 function geodir_temp_set_post_attachment()
2241 2241
 {
2242 2242
 
2243
-    global $wpdb, $plugin_prefix;
2243
+	global $wpdb, $plugin_prefix;
2244 2244
 
2245
-    $all_postypes = geodir_get_posttypes();
2245
+	$all_postypes = geodir_get_posttypes();
2246 2246
 
2247
-    foreach ($all_postypes as $posttype) {
2247
+	foreach ($all_postypes as $posttype) {
2248 2248
 
2249
-        $tablename = $plugin_prefix . $posttype . '_detail';
2249
+		$tablename = $plugin_prefix . $posttype . '_detail';
2250 2250
 
2251
-        $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2251
+		$get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2252 2252
 
2253
-        if (!empty($get_post_data)) {
2253
+		if (!empty($get_post_data)) {
2254 2254
 
2255
-            foreach ($get_post_data as $data) {
2255
+			foreach ($get_post_data as $data) {
2256 2256
 
2257
-                $post_id = $data->post_id;
2257
+				$post_id = $data->post_id;
2258 2258
 
2259
-                $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2259
+				$attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2260 2260
 
2261
-                if (!empty($attachment_data)) {
2261
+				if (!empty($attachment_data)) {
2262 2262
 
2263
-                    foreach ($attachment_data as $attach) {
2263
+					foreach ($attachment_data as $attach) {
2264 2264
 
2265
-                        $file_info = pathinfo($attach->file);
2265
+						$file_info = pathinfo($attach->file);
2266 2266
 
2267
-                        $sub_dir = '';
2268
-                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2269
-                            $sub_dir = stripslashes_deep($file_info['dirname']);
2267
+						$sub_dir = '';
2268
+						if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2269
+							$sub_dir = stripslashes_deep($file_info['dirname']);
2270 2270
 
2271
-                        $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2272
-                        $uploads_path = $uploads['basedir'];
2271
+						$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2272
+						$uploads_path = $uploads['basedir'];
2273 2273
 
2274
-                        $file_name = $file_info['basename'];
2274
+						$file_name = $file_info['basename'];
2275 2275
 
2276
-                        $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2276
+						$img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2277 2277
 
2278
-                        if (!file_exists($img_arr['path'])) {
2278
+						if (!file_exists($img_arr['path'])) {
2279 2279
 
2280
-                            $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2280
+							$wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2281 2281
 
2282
-                        }
2282
+						}
2283 2283
 
2284
-                    }
2284
+					}
2285 2285
 
2286
-                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2286
+					$attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2287 2287
 
2288
-                    if (!empty($attachment_data)) {
2288
+					if (!empty($attachment_data)) {
2289 2289
 
2290
-                        if ($attachment_data->ID)
2291
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2290
+						if ($attachment_data->ID)
2291
+							$wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2292 2292
 
2293
-                    } else {
2293
+					} else {
2294 2294
 
2295
-                        if (has_post_thumbnail($post_id)) {
2295
+						if (has_post_thumbnail($post_id)) {
2296 2296
 
2297
-                            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2297
+							$post_thumbnail_id = get_post_thumbnail_id($post_id);
2298 2298
 
2299
-                            wp_delete_attachment($post_thumbnail_id);
2299
+							wp_delete_attachment($post_thumbnail_id);
2300 2300
 
2301
-                        }
2301
+						}
2302 2302
 
2303
-                    }
2303
+					}
2304 2304
 
2305
-                    $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2305
+					$wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2306 2306
 
2307
-                    geodir_set_wp_featured_image($post_id);
2307
+					geodir_set_wp_featured_image($post_id);
2308 2308
 
2309
-                }
2309
+				}
2310 2310
 
2311
-            }
2311
+			}
2312 2312
 
2313
-        }
2313
+		}
2314 2314
 
2315
-    }
2315
+	}
2316 2316
 
2317 2317
 }
2318 2318
 
@@ -2330,9 +2330,9 @@  discard block
 block discarded – undo
2330 2330
 function geodir_default_rating_star_icon()
2331 2331
 {
2332 2332
 
2333
-    if (!get_option('geodir_default_rating_star_icon')) {
2334
-        update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2335
-    }
2333
+	if (!get_option('geodir_default_rating_star_icon')) {
2334
+		update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2335
+	}
2336 2336
 
2337 2337
 }
2338 2338
 
@@ -2350,27 +2350,27 @@  discard block
 block discarded – undo
2350 2350
  */
2351 2351
 function geodir_user_post_listing_count($user_id=null)
2352 2352
 {
2353
-    global $wpdb, $plugin_prefix, $current_user;
2354
-    if(!$user_id){
2355
-        $user_id = $current_user->ID;
2356
-    }
2353
+	global $wpdb, $plugin_prefix, $current_user;
2354
+	if(!$user_id){
2355
+		$user_id = $current_user->ID;
2356
+	}
2357 2357
 
2358
-    $user_id = $current_user->ID;
2359
-    $all_postypes = geodir_get_posttypes();
2360
-    $all_posts = get_option('geodir_listing_link_user_dashboard');
2358
+	$user_id = $current_user->ID;
2359
+	$all_postypes = geodir_get_posttypes();
2360
+	$all_posts = get_option('geodir_listing_link_user_dashboard');
2361 2361
 
2362
-    $user_listing = array();
2363
-    if (is_array($all_posts) && !empty($all_posts)) {
2364
-        foreach ($all_posts as $ptype) {
2365
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
2362
+	$user_listing = array();
2363
+	if (is_array($all_posts) && !empty($all_posts)) {
2364
+		foreach ($all_posts as $ptype) {
2365
+			$total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
2366 2366
 
2367
-            if ($total_posts > 0) {
2368
-                $user_listing[$ptype] = $total_posts;
2369
-            }
2370
-        }
2371
-    }
2367
+			if ($total_posts > 0) {
2368
+				$user_listing[$ptype] = $total_posts;
2369
+			}
2370
+		}
2371
+	}
2372 2372
 
2373
-    return $user_listing;
2373
+	return $user_listing;
2374 2374
 }
2375 2375
 
2376 2376
 
@@ -2390,189 +2390,189 @@  discard block
 block discarded – undo
2390 2390
  */
2391 2391
 function geodir_detail_page_custom_field_tab($tabs_arr)
2392 2392
 {
2393
-    global $post;
2394
-
2395
-    $post_type = geodir_get_current_posttype();
2396
-    $all_postypes = geodir_get_posttypes();
2397
-
2398
-    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2399
-        $package_info = array();
2400
-        $package_info = geodir_post_package_info($package_info, $post);
2401
-        $post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
2402
-        $fields_location = 'owntab';
2403
-
2404
-        $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2405
-        //remove video and special offers if it is already set to show
2406
-        if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2407
-            $unset_video = true;
2408
-        }
2409
-
2410
-        if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2411
-            $unset_special_offers = true;
2412
-        }
2413
-        if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2414
-            foreach($custom_fields as $key => $custom_field){
2415
-                if($custom_field['name']=='geodir_video' && isset($unset_video)){
2416
-                    unset($custom_fields[$key]);
2417
-                }
2418
-                if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2419
-                    unset($custom_fields[$key]);
2420
-                }
2421
-            }
2422
-        }
2393
+	global $post;
2423 2394
 
2395
+	$post_type = geodir_get_current_posttype();
2396
+	$all_postypes = geodir_get_posttypes();
2424 2397
 
2425
-        if (!empty($custom_fields)) {
2426
-            $parse_custom_fields = array();
2427
-            foreach ($custom_fields as $field) {
2428
-                $field = stripslashes_deep($field); // strip slashes
2429
-                $type = $field;
2430
-                $field_name = $field['htmlvar_name'];
2431
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2432
-                    $post->{$field_name} = $_REQUEST[$field_name];
2433
-                }
2398
+	if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
2399
+		$package_info = array();
2400
+		$package_info = geodir_post_package_info($package_info, $post);
2401
+		$post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
2402
+		$fields_location = 'owntab';
2434 2403
 
2435
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2436
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2437
-                        continue;
2438
-                    }
2439
-
2440
-                    $parse_custom_fields[] = $field;
2441
-                }
2442
-            }
2443
-            $custom_fields = $parse_custom_fields;
2444
-        }
2445
-        //print_r($custom_fields);
2446
-        if (!empty($custom_fields)) {
2404
+		$custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2405
+		//remove video and special offers if it is already set to show
2406
+		if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2407
+			$unset_video = true;
2408
+		}
2447 2409
 
2448
-            global $field_set_start;
2410
+		if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2411
+			$unset_special_offers = true;
2412
+		}
2413
+		if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2414
+			foreach($custom_fields as $key => $custom_field){
2415
+				if($custom_field['name']=='geodir_video' && isset($unset_video)){
2416
+					unset($custom_fields[$key]);
2417
+				}
2418
+				if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2419
+					unset($custom_fields[$key]);
2420
+				}
2421
+			}
2422
+		}
2449 2423
 
2450
-            $post = stripslashes_deep($post); // strip slashes
2451
-            
2452
-            $field_set_start = 0;
2453
-            $fieldset_count = 0;
2454
-            $fieldset = '';
2455
-            $total_fields = count($custom_fields);
2456
-            $count_field = 0;
2457
-            $fieldset_arr = array();
2458
-            $i = 0;
2459
-            $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2460
-
2461
-            foreach ($custom_fields as $field) {
2462
-                $count_field++;
2463
-                $field_name = $field['htmlvar_name'];
2464
-                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2465
-                    $post->{$field_name} = $_REQUEST[$field_name];
2466
-                }
2467 2424
 
2468
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2469
-                    $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2470
-                    $site_title = trim($field['site_title']);
2471
-                    $type = $field;
2472
-                    $variables_array = array();
2425
+		if (!empty($custom_fields)) {
2426
+			$parse_custom_fields = array();
2427
+			foreach ($custom_fields as $field) {
2428
+				$field = stripslashes_deep($field); // strip slashes
2429
+				$type = $field;
2430
+				$field_name = $field['htmlvar_name'];
2431
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2432
+					$post->{$field_name} = $_REQUEST[$field_name];
2433
+				}
2473 2434
 
2474
-                    if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2475
-                        continue;
2476
-                    }
2435
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2436
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2437
+						continue;
2438
+					}
2477 2439
 
2478
-                    if ($type['type'] != 'fieldset') {
2479
-                        $i++;
2480
-                        $variables_array['post_id'] = $post->ID;
2481
-                        $variables_array['label'] = __($type['site_title'], 'geodirectory');
2482
-                        $variables_array['value'] = '';
2483
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
2484
-                    }else{
2485
-                        $i = 0;
2486
-                        $fieldset_count++;
2487
-                        $field_set_start = 1;
2488
-                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2489
-                        $fieldset_arr[$fieldset_count]['label'] = $label;
2490
-                    }
2440
+					$parse_custom_fields[] = $field;
2441
+				}
2442
+			}
2443
+			$custom_fields = $parse_custom_fields;
2444
+		}
2445
+		//print_r($custom_fields);
2446
+		if (!empty($custom_fields)) {
2491 2447
 
2448
+			global $field_set_start;
2492 2449
 
2493
-                    if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2494
-                    $type = stripslashes_deep($type); // strip slashes
2495
-                    if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2496
-                    $html = '';
2497
-                    $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2498
-                    if($html_var=='post'){$html_var='post_address';}
2499
-                    $field_icon = geodir_field_icon_proccess($type);
2500
-                    $filed_type = $type['type'];
2501
-
2502
-                    /**
2503
-                     * Filter the output for custom fields.
2504
-                     *
2505
-                     * Here we can remove or add new functions depending on the field type.
2506
-                     *
2507
-                     * @param string $html The html to be filtered (blank).
2508
-                     * @param string $fields_location The location the field is to be show.
2509
-                     * @param array $type The array of field values.
2510
-                     */
2511
-                    $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2512
-
2513
-
2514
-                    /**
2515
-                     * Filter custom field output in tab.
2516
-                     *
2517
-                     * @since 1.5.6
2518
-                     *
2519
-                     * @param string $html_var The HTML variable name for the field.
2520
-                     * @param string $html Custom field unfiltered HTML.
2521
-                     * @param array $variables_array Custom field variables array.
2522
-                     */
2523
-                    $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2524
-
2525
-                    $fieldset_html = '';
2526
-                    if ($field_set_start == 1) {
2527
-                        $add_html = false;
2528
-                        if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2529
-                            if ($fieldset != '') {
2530
-                                $add_html = true;
2531
-                                $label = $fieldset_arr[$fieldset_count - 1]['label'];
2532
-                                $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2533
-                            }
2534
-                            $fieldset_html = $fieldset;
2535
-                            $fieldset = '';
2536
-                        } else {
2537
-                            $fieldset .= $html;
2538
-                            if ($total_fields == $count_field && $fieldset != '') {
2539
-                                $add_html = true;
2540
-                                $label = $fieldset_arr[$fieldset_count]['label'];
2541
-                                $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2542
-                                $fieldset_html = $fieldset;
2543
-                            }
2544
-                        }
2545
-
2546
-                        if ($add_html) {
2547
-                            $tabs_arr[$htmlvar_name] = array(
2548
-                                'heading_text' => __($label, 'geodirectory'),
2549
-                                'is_active_tab' => false,
2550
-                                /**
2551
-                                 * Filter if a custom field should be displayed on the details page tab.
2552
-                                 *
2553
-                                 * @since 1.0.0
2554
-                                 * @param string $htmlvar_name The field HTML var name.
2555
-                                 */
2556
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2557
-                                'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2558
-                            );
2559
-                        }
2560
-                    } else {
2561
-                        if ($html != '') {
2562
-                            $tabs_arr[$html_var] = array(
2563
-                                'heading_text' => __($label, 'geodirectory'),
2564
-                                'is_active_tab' => false,
2565
-                                /** This action is documented in geodirectory_hooks_actions.php */
2566
-                                'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2567
-                                'tab_content' => $html
2568
-                            );
2569
-                        }
2570
-                    }
2571
-                }
2572
-            }
2573
-        }
2574
-    }
2575
-    return $tabs_arr;
2450
+			$post = stripslashes_deep($post); // strip slashes
2451
+            
2452
+			$field_set_start = 0;
2453
+			$fieldset_count = 0;
2454
+			$fieldset = '';
2455
+			$total_fields = count($custom_fields);
2456
+			$count_field = 0;
2457
+			$fieldset_arr = array();
2458
+			$i = 0;
2459
+			$geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
2460
+
2461
+			foreach ($custom_fields as $field) {
2462
+				$count_field++;
2463
+				$field_name = $field['htmlvar_name'];
2464
+				if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
2465
+					$post->{$field_name} = $_REQUEST[$field_name];
2466
+				}
2467
+
2468
+				if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2469
+					$label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2470
+					$site_title = trim($field['site_title']);
2471
+					$type = $field;
2472
+					$variables_array = array();
2473
+
2474
+					if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2475
+						continue;
2476
+					}
2477
+
2478
+					if ($type['type'] != 'fieldset') {
2479
+						$i++;
2480
+						$variables_array['post_id'] = $post->ID;
2481
+						$variables_array['label'] = __($type['site_title'], 'geodirectory');
2482
+						$variables_array['value'] = '';
2483
+						$variables_array['value'] = $post->{$type['htmlvar_name']};
2484
+					}else{
2485
+						$i = 0;
2486
+						$fieldset_count++;
2487
+						$field_set_start = 1;
2488
+						$fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2489
+						$fieldset_arr[$fieldset_count]['label'] = $label;
2490
+					}
2491
+
2492
+
2493
+					if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2494
+					$type = stripslashes_deep($type); // strip slashes
2495
+					if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2496
+					$html = '';
2497
+					$html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2498
+					if($html_var=='post'){$html_var='post_address';}
2499
+					$field_icon = geodir_field_icon_proccess($type);
2500
+					$filed_type = $type['type'];
2501
+
2502
+					/**
2503
+					 * Filter the output for custom fields.
2504
+					 *
2505
+					 * Here we can remove or add new functions depending on the field type.
2506
+					 *
2507
+					 * @param string $html The html to be filtered (blank).
2508
+					 * @param string $fields_location The location the field is to be show.
2509
+					 * @param array $type The array of field values.
2510
+					 */
2511
+					$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2512
+
2513
+
2514
+					/**
2515
+					 * Filter custom field output in tab.
2516
+					 *
2517
+					 * @since 1.5.6
2518
+					 *
2519
+					 * @param string $html_var The HTML variable name for the field.
2520
+					 * @param string $html Custom field unfiltered HTML.
2521
+					 * @param array $variables_array Custom field variables array.
2522
+					 */
2523
+					$html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
2524
+
2525
+					$fieldset_html = '';
2526
+					if ($field_set_start == 1) {
2527
+						$add_html = false;
2528
+						if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
2529
+							if ($fieldset != '') {
2530
+								$add_html = true;
2531
+								$label = $fieldset_arr[$fieldset_count - 1]['label'];
2532
+								$htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
2533
+							}
2534
+							$fieldset_html = $fieldset;
2535
+							$fieldset = '';
2536
+						} else {
2537
+							$fieldset .= $html;
2538
+							if ($total_fields == $count_field && $fieldset != '') {
2539
+								$add_html = true;
2540
+								$label = $fieldset_arr[$fieldset_count]['label'];
2541
+								$htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
2542
+								$fieldset_html = $fieldset;
2543
+							}
2544
+						}
2545
+
2546
+						if ($add_html) {
2547
+							$tabs_arr[$htmlvar_name] = array(
2548
+								'heading_text' => __($label, 'geodirectory'),
2549
+								'is_active_tab' => false,
2550
+								/**
2551
+								 * Filter if a custom field should be displayed on the details page tab.
2552
+								 *
2553
+								 * @since 1.0.0
2554
+								 * @param string $htmlvar_name The field HTML var name.
2555
+								 */
2556
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2557
+								'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2558
+							);
2559
+						}
2560
+					} else {
2561
+						if ($html != '') {
2562
+							$tabs_arr[$html_var] = array(
2563
+								'heading_text' => __($label, 'geodirectory'),
2564
+								'is_active_tab' => false,
2565
+								/** This action is documented in geodirectory_hooks_actions.php */
2566
+								'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
2567
+								'tab_content' => $html
2568
+							);
2569
+						}
2570
+					}
2571
+				}
2572
+			}
2573
+		}
2574
+	}
2575
+	return $tabs_arr;
2576 2576
 }
2577 2577
 
2578 2578
 /* display add listing page for wpml */
@@ -2596,39 +2596,39 @@  discard block
 block discarded – undo
2596 2596
  */
2597 2597
 function geodir_add_post_status_author_page()
2598 2598
 {
2599
-    global $wpdb, $post;
2600
-
2601
-    $html = '';
2602
-    if (get_current_user_id()) {
2603
-
2604
-        $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
2605
-        if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2606
-
2607
-            // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2608
-            $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2609
-            $status = "<strong>(";
2610
-            $status_icon = '<i class="fa fa-play"></i>';
2611
-            if ($real_status == 'publish') {
2612
-                $status .= __('Published', 'geodirectory');
2613
-            } else {
2614
-                $status .= __('Not published', 'geodirectory');
2615
-                $status_icon = '<i class="fa fa-pause"></i>';
2616
-            }
2617
-            $status .= ")</strong>";
2599
+	global $wpdb, $post;
2600
+
2601
+	$html = '';
2602
+	if (get_current_user_id()) {
2603
+
2604
+		$is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author'));
2605
+		if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
2606
+
2607
+			// we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
2608
+			$real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
2609
+			$status = "<strong>(";
2610
+			$status_icon = '<i class="fa fa-play"></i>';
2611
+			if ($real_status == 'publish') {
2612
+				$status .= __('Published', 'geodirectory');
2613
+			} else {
2614
+				$status .= __('Not published', 'geodirectory');
2615
+				$status_icon = '<i class="fa fa-pause"></i>';
2616
+			}
2617
+			$status .= ")</strong>";
2618 2618
 
2619
-            $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2620
-        }
2621
-    }
2619
+			$html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2620
+		}
2621
+	}
2622 2622
 
2623
-    if ($html != '') {
2624
-        /**
2625
-         * Filter the post status text on the author page.
2626
-         *
2627
-         * @since 1.0.0
2628
-         * @param string $html The HTML of the status.
2629
-         */
2630
-        echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2631
-    }
2623
+	if ($html != '') {
2624
+		/**
2625
+		 * Filter the post status text on the author page.
2626
+		 *
2627
+		 * @since 1.0.0
2628
+		 * @param string $html The HTML of the status.
2629
+		 */
2630
+		echo apply_filters('geodir_filter_status_text_on_author_page', $html);
2631
+	}
2632 2632
 
2633 2633
 
2634 2634
 }
@@ -2642,9 +2642,9 @@  discard block
 block discarded – undo
2642 2642
  * @package GeoDirectory
2643 2643
  */
2644 2644
 function geodir_init_no_rating() {
2645
-    if (geodir_rating_disabled_post_types()) {
2646
-        add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2647
-    }
2645
+	if (geodir_rating_disabled_post_types()) {
2646
+		add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
2647
+	}
2648 2648
 }
2649 2649
 
2650 2650
 /**
@@ -2658,22 +2658,22 @@  discard block
 block discarded – undo
2658 2658
  * @return array Modified sort options array.
2659 2659
  */
2660 2660
 function geodir_no_rating_get_sort_options($options, $post_type = '') {
2661
-    if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) {
2662
-        $new_options = array();
2661
+	if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) {
2662
+		$new_options = array();
2663 2663
         
2664
-        if (!empty($options)) {
2665
-            foreach ($options as $option) {
2666
-                if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2667
-                    continue;
2668
-                }
2669
-                $new_options[] = $option;
2670
-            }
2664
+		if (!empty($options)) {
2665
+			foreach ($options as $option) {
2666
+				if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
2667
+					continue;
2668
+				}
2669
+				$new_options[] = $option;
2670
+			}
2671 2671
 
2672
-            $options = $new_options;
2673
-        }
2674
-    }
2672
+			$options = $new_options;
2673
+		}
2674
+	}
2675 2675
 
2676
-    return $options;
2676
+	return $options;
2677 2677
 }
2678 2678
 
2679 2679
 /**
@@ -2685,9 +2685,9 @@  discard block
 block discarded – undo
2685 2685
  * @return array Modified class array.
2686 2686
  */
2687 2687
 function geodir_body_class_active_map($classes = array()) {
2688
-    $classes[] = 'gd-map-' . geodir_map_name();
2688
+	$classes[] = 'gd-map-' . geodir_map_name();
2689 2689
 
2690
-    return $classes;
2690
+	return $classes;
2691 2691
 }
2692 2692
 add_filter('body_class', 'geodir_body_class_active_map', 100);
2693 2693
 
@@ -2700,9 +2700,9 @@  discard block
 block discarded – undo
2700 2700
  * @return string Modified class string.
2701 2701
  */
2702 2702
 function geodir_admin_body_class_active_map($class = '') {    
2703
-    $class .= ' gd-map-' . geodir_map_name();
2703
+	$class .= ' gd-map-' . geodir_map_name();
2704 2704
 
2705
-    return $class;
2705
+	return $class;
2706 2706
 }
2707 2707
 add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100);
2708 2708
 
@@ -2720,36 +2720,36 @@  discard block
 block discarded – undo
2720 2720
  * @return array Translation texts.
2721 2721
  */
2722 2722
 function geodir_load_gd_options_text_translation($translation_texts = array()) {
2723
-    $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2724
-
2725
-    $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2726
-
2727
-    /**
2728
-     * Filters the geodirectory option names that requires to add for translation.
2729
-     *
2730
-     * @since 1.5.7
2731
-     * @package GeoDirectory
2732
-     *
2733
-     * @param  array $gd_options Array of option names.
2734
-     */
2735
-    $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2736
-    $gd_options = array_unique($gd_options);
2737
-
2738
-    if (!empty($gd_options)) {
2739
-        foreach ($gd_options as $gd_option) {
2740
-            if ($gd_option != '' && $option_value = get_option($gd_option)) {
2741
-                $option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2723
+	$translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2724
+
2725
+	$gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2726
+
2727
+	/**
2728
+	 * Filters the geodirectory option names that requires to add for translation.
2729
+	 *
2730
+	 * @since 1.5.7
2731
+	 * @package GeoDirectory
2732
+	 *
2733
+	 * @param  array $gd_options Array of option names.
2734
+	 */
2735
+	$gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
2736
+	$gd_options = array_unique($gd_options);
2737
+
2738
+	if (!empty($gd_options)) {
2739
+		foreach ($gd_options as $gd_option) {
2740
+			if ($gd_option != '' && $option_value = get_option($gd_option)) {
2741
+				$option_value = is_string($option_value) ? stripslashes_deep($option_value) : '';
2742 2742
                 
2743
-                if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2744
-                    $translation_texts[] = stripslashes_deep($option_value);
2745
-                }
2746
-            }
2747
-        }
2748
-    }
2743
+				if ($option_value != '' && !in_array($option_value, $translation_texts)) {
2744
+					$translation_texts[] = stripslashes_deep($option_value);
2745
+				}
2746
+			}
2747
+		}
2748
+	}
2749 2749
 
2750
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2750
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
2751 2751
 
2752
-    return $translation_texts;
2752
+	return $translation_texts;
2753 2753
 }
2754 2754
 
2755 2755
 add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation');
@@ -2763,15 +2763,15 @@  discard block
 block discarded – undo
2763 2763
 
2764 2764
 add_filter('get_comments_link', 'gd_get_comments_link', 10, 2);
2765 2765
 function gd_get_comments_link($comments_link, $post_id) {
2766
-    $post_type = get_post_type($post_id);
2766
+	$post_type = get_post_type($post_id);
2767 2767
 
2768
-    $all_postypes = geodir_get_posttypes();
2769
-    if (in_array($post_type, $all_postypes)) {
2770
-        $comments_link = str_replace('#comments', '#reviews', $comments_link);
2771
-        $comments_link = str_replace('#respond', '#reviews', $comments_link);
2772
-    }
2768
+	$all_postypes = geodir_get_posttypes();
2769
+	if (in_array($post_type, $all_postypes)) {
2770
+		$comments_link = str_replace('#comments', '#reviews', $comments_link);
2771
+		$comments_link = str_replace('#respond', '#reviews', $comments_link);
2772
+	}
2773 2773
 
2774
-    return $comments_link;
2774
+	return $comments_link;
2775 2775
 }
2776 2776
 
2777 2777
 
@@ -2789,11 +2789,11 @@  discard block
 block discarded – undo
2789 2789
 function geodir_add_nav_menu_class( $args )
2790 2790
 {
2791 2791
 
2792
-        if(isset($args['menu_class'])){
2793
-            $args['menu_class'] = $args['menu_class']." gd-menu-z";
2794
-        }
2792
+		if(isset($args['menu_class'])){
2793
+			$args['menu_class'] = $args['menu_class']." gd-menu-z";
2794
+		}
2795 2795
     
2796
-    return $args;
2796
+	return $args;
2797 2797
 }
2798 2798
 
2799 2799
 add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' );
@@ -2810,15 +2810,15 @@  discard block
 block discarded – undo
2810 2810
  * @return string Filtered locale ID.
2811 2811
  */
2812 2812
 function geodir_wpml_filter_locale($locale) {
2813
-    global $sitepress;
2813
+	global $sitepress;
2814 2814
     
2815
-    $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : '');
2815
+	$post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : '');
2816 2816
     
2817
-    if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) {
2818
-        $locale = $sitepress->get_locale($current_lang);
2819
-    }
2817
+	if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) {
2818
+		$locale = $sitepress->get_locale($current_lang);
2819
+	}
2820 2820
     
2821
-    return $locale;
2821
+	return $locale;
2822 2822
 }
2823 2823
 
2824 2824
 /**
@@ -2828,19 +2828,19 @@  discard block
 block discarded – undo
2828 2828
  * @package GeoDirectory
2829 2829
  */
2830 2830
 function geodir_wpml_set_filter() {
2831
-    if (function_exists('icl_object_id')) {
2832
-        global $sitepress;
2831
+	if (function_exists('icl_object_id')) {
2832
+		global $sitepress;
2833 2833
         
2834
-        if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2835
-            add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1);
2836
-        }
2834
+		if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2835
+			add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1);
2836
+		}
2837 2837
         
2838
-        add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2839
-        add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2840
-        if (is_admin()) {
2841
-            add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2842
-        }
2843
-    }
2838
+		add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2839
+		add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2840
+		if (is_admin()) {
2841
+			add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2842
+		}
2843
+	}
2844 2844
 }
2845 2845
 add_filter('plugins_loaded', 'geodir_wpml_set_filter');
2846 2846
 
@@ -2853,38 +2853,38 @@  discard block
 block discarded – undo
2853 2853
  * @return array Filtered languages.
2854 2854
  */
2855 2855
 function geodir_wpml_filter_ls_languages($languages) {    
2856
-    if (geodir_is_geodir_page()) {        
2857
-        $keep_vars = array();
2856
+	if (geodir_is_geodir_page()) {        
2857
+		$keep_vars = array();
2858 2858
         
2859
-        if (geodir_is_page('add-listing')) {
2860
-            $keep_vars = array('listing_type', 'package_id');
2861
-        } else if (geodir_is_page('search')) {
2862
-            $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon');
2863
-        } else if (geodir_is_page('author')) {
2864
-            $keep_vars = array('geodir_dashbord', 'stype', 'list');
2865
-        } else if (geodir_is_page('login')) {
2866
-            $keep_vars = array('forgot', 'signup');
2867
-        }        
2859
+		if (geodir_is_page('add-listing')) {
2860
+			$keep_vars = array('listing_type', 'package_id');
2861
+		} else if (geodir_is_page('search')) {
2862
+			$keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon');
2863
+		} else if (geodir_is_page('author')) {
2864
+			$keep_vars = array('geodir_dashbord', 'stype', 'list');
2865
+		} else if (geodir_is_page('login')) {
2866
+			$keep_vars = array('forgot', 'signup');
2867
+		}        
2868 2868
         
2869
-        if (!empty($keep_vars)) {
2870
-            foreach ( $languages as $code => $url) {
2871
-                $filter_url = $url['url'];
2869
+		if (!empty($keep_vars)) {
2870
+			foreach ( $languages as $code => $url) {
2871
+				$filter_url = $url['url'];
2872 2872
                 
2873
-                foreach ($keep_vars as $var) {
2874
-                    if (isset($_GET[$var]) && !is_array($_GET[$var])) {
2875
-                        $filter_url = remove_query_arg(array($var), $filter_url);
2876
-                        $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url);
2877
-                    }
2878
-                }
2873
+				foreach ($keep_vars as $var) {
2874
+					if (isset($_GET[$var]) && !is_array($_GET[$var])) {
2875
+						$filter_url = remove_query_arg(array($var), $filter_url);
2876
+						$filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url);
2877
+					}
2878
+				}
2879 2879
                 
2880
-                if ($filter_url != $url['url']) {
2881
-                    $languages[$code]['url'] = $filter_url;
2882
-                }
2883
-            }
2884
-        }
2885
-    }
2880
+				if ($filter_url != $url['url']) {
2881
+					$languages[$code]['url'] = $filter_url;
2882
+				}
2883
+			}
2884
+		}
2885
+	}
2886 2886
 
2887
-    return $languages;
2887
+	return $languages;
2888 2888
 }
2889 2889
 add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 );
2890 2890
 
@@ -2895,18 +2895,18 @@  discard block
 block discarded – undo
2895 2895
  *
2896 2896
  */
2897 2897
 function geodir_remove_yoast_seo_metas(){
2898
-    if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2899
-        $wpseo = WPSEO_Frontend::get_instance();
2898
+	if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2899
+		$wpseo = WPSEO_Frontend::get_instance();
2900 2900
         
2901
-        remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2902
-        remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2903
-        remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2904
-        remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2905
-        remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2906
-        remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2901
+		remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2902
+		remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2903
+		remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2904
+		remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2905
+		remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2906
+		remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2907 2907
         
2908
-        remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2909
-    }
2908
+		remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2909
+	}
2910 2910
 }
2911 2911
 
2912 2912
 /**
@@ -2920,20 +2920,20 @@  discard block
 block discarded – undo
2920 2920
  *
2921 2921
  */
2922 2922
  function geodir_wpml_ajax_set_guest_lang() {    
2923
-    if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2924
-        if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2925
-            global $sitepress;
2923
+	if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2924
+		if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2925
+			global $sitepress;
2926 2926
             
2927
-            $referer = wp_get_referer();
2927
+			$referer = wp_get_referer();
2928 2928
             
2929
-            $current_lang = $sitepress->get_current_language();
2930
-            $referrer_lang = $sitepress->get_language_from_url( $referer );
2929
+			$current_lang = $sitepress->get_current_language();
2930
+			$referrer_lang = $sitepress->get_language_from_url( $referer );
2931 2931
             
2932
-            if ( $referrer_lang && $current_lang != $referrer_lang ) {
2933
-                $_GET['lang'] = $referrer_lang;
2934
-            }
2935
-        }
2936
-    }
2932
+			if ( $referrer_lang && $current_lang != $referrer_lang ) {
2933
+				$_GET['lang'] = $referrer_lang;
2934
+			}
2935
+		}
2936
+	}
2937 2937
 }
2938 2938
 add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 );
2939 2939
 
@@ -2945,36 +2945,36 @@  discard block
 block discarded – undo
2945 2945
  * @param object $wp The WordPress object.
2946 2946
  */
2947 2947
 function geodir_check_redirect($wp) {
2948
-    if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) {
2949
-        $current_url = geodir_curPageURL();
2950
-        $search = 'czech-republic';
2951
-        $replace = 'czechia';        
2948
+	if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) {
2949
+		$current_url = geodir_curPageURL();
2950
+		$search = 'czech-republic';
2951
+		$replace = 'czechia';        
2952 2952
         
2953
-        $has_slash = substr($current_url, -1);
2954
-        if ($has_slash != "/") {
2955
-            $current_url .= '/';
2956
-        }
2953
+		$has_slash = substr($current_url, -1);
2954
+		if ($has_slash != "/") {
2955
+			$current_url .= '/';
2956
+		}
2957 2957
         
2958
-        $redirect = false;
2959
-        if (strpos($current_url, '/' . $search . '/') !== false) {
2960
-            $redirect = true;
2961
-            $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2962
-        }
2958
+		$redirect = false;
2959
+		if (strpos($current_url, '/' . $search . '/') !== false) {
2960
+			$redirect = true;
2961
+			$current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2962
+		}
2963 2963
         
2964
-        if ($has_slash != "/") {
2965
-            $current_url = trim($current_url, '/');
2966
-        }
2964
+		if ($has_slash != "/") {
2965
+			$current_url = trim($current_url, '/');
2966
+		}
2967 2967
         
2968
-        if (strpos($current_url, 'gd_country=' . $search) !== false) {
2969
-            $redirect = true;
2970
-            $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2971
-        }
2972
-
2973
-        if ($redirect) {
2974
-            wp_redirect($current_url);
2975
-            exit;
2976
-        }
2977
-    }
2968
+		if (strpos($current_url, 'gd_country=' . $search) !== false) {
2969
+			$redirect = true;
2970
+			$current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2971
+		}
2972
+
2973
+		if ($redirect) {
2974
+			wp_redirect($current_url);
2975
+			exit;
2976
+		}
2977
+	}
2978 2978
 }
2979 2979
 add_action('parse_request', 'geodir_check_redirect', 101, 1);
2980 2980
 
@@ -2993,31 +2993,31 @@  discard block
 block discarded – undo
2993 2993
  * @param string $original_slug The original post slug.
2994 2994
  */
2995 2995
 function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
2996
-    global $wpdb;
2996
+	global $wpdb;
2997 2997
     
2998
-    if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
2999
-        $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '" . $post_type . "category' OR taxonomy = '" . $post_type . "_tags' ) LIMIT 1", $slug ) );
2998
+	if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
2999
+		$term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '" . $post_type . "category' OR taxonomy = '" . $post_type . "_tags' ) LIMIT 1", $slug ) );
3000 3000
 
3001
-        if ( $term_slug_check ) {
3002
-            $suffix = 1;
3001
+		if ( $term_slug_check ) {
3002
+			$suffix = 1;
3003 3003
             
3004
-            do {
3005
-                $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3004
+			do {
3005
+				$alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3006 3006
                 
3007
-                $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '" . $post_type . "category' OR taxonomy = '" . $post_type . "_tags' ) LIMIT 1", $alt_slug ) );
3007
+				$term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '" . $post_type . "category' OR taxonomy = '" . $post_type . "_tags' ) LIMIT 1", $alt_slug ) );
3008 3008
                 
3009
-                $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3009
+				$post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3010 3010
                 
3011
-                $term_slug_check = $term_check || $post_check;
3011
+				$term_slug_check = $term_check || $post_check;
3012 3012
                 
3013
-                $suffix++;
3014
-            } while ( $term_slug_check );
3013
+				$suffix++;
3014
+			} while ( $term_slug_check );
3015 3015
             
3016
-            $slug = $alt_slug;
3017
-        }
3018
-    }
3016
+			$slug = $alt_slug;
3017
+		}
3018
+	}
3019 3019
     
3020
-    return $slug;
3020
+	return $slug;
3021 3021
 }
3022 3022
 add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 10, 6 );
3023 3023
 
@@ -3035,24 +3035,24 @@  discard block
 block discarded – undo
3035 3035
  * @return bool true when exists. false when not exists.
3036 3036
  */
3037 3037
 function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) {
3038
-    global $wpdb, $gd_term_post_type;
3038
+	global $wpdb, $gd_term_post_type;
3039 3039
     
3040
-    if ( $slug_exists ) {
3041
-        return $slug_exists;
3042
-    }
3040
+	if ( $slug_exists ) {
3041
+		return $slug_exists;
3042
+	}
3043 3043
     
3044
-    if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3045
-        $post_type = $gd_term_post_type[$term_id];
3046
-    } else {
3047
-        $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3048
-        $taxonomy_obj = get_taxonomy( $taxonomy );
3049
-        $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3050
-    }
3044
+	if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3045
+		$post_type = $gd_term_post_type[$term_id];
3046
+	} else {
3047
+		$taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3048
+		$taxonomy_obj = get_taxonomy( $taxonomy );
3049
+		$post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3050
+	}
3051 3051
     
3052
-    if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s LIMIT 1", $slug, $post_type ) ) ) {
3053
-        $slug_exists = true;
3054
-    }
3052
+	if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s LIMIT 1", $slug, $post_type ) ) ) {
3053
+		$slug_exists = true;
3054
+	}
3055 3055
 
3056
-    return $slug_exists;
3056
+	return $slug_exists;
3057 3057
 }
3058 3058
 add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 );
3059 3059
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 /* ON TEMPLATE INCLUDE */
137 137
 /////////////////////////
138 138
 
139
-add_filter('template_include', 'geodir_template_loader',9);
139
+add_filter('template_include', 'geodir_template_loader', 9);
140 140
 
141 141
 /////////////////////////
142 142
 /* CATEGORY / TAXONOMY / CUSTOM POST ACTIONS */
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 /* WP REVIEW COUNT ACTIONS */
177 177
 ////////////////////////
178 178
 
179
-add_action('geodir_update_postrating', 'geodir_term_review_count_force_update_single_post', 100,1);
179
+add_action('geodir_update_postrating', 'geodir_term_review_count_force_update_single_post', 100, 1);
180 180
 //add_action('geodir_update_postrating', 'geodir_term_review_count_force_update', 100);
181
-add_action('transition_post_status', 'geodir_term_review_count_force_update', 100,3);
181
+add_action('transition_post_status', 'geodir_term_review_count_force_update', 100, 3);
182 182
 //add_action('created_term', 'geodir_term_review_count_force_update', 100);
183 183
 add_action('edited_term', 'geodir_term_review_count_force_update', 100);
184 184
 add_action('delete_term', 'geodir_term_review_count_force_update', 100);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
  */
224 224
 function geodir_unset_prev_theme_nav_location($newname)
225 225
 {
226
-    $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
226
+    $geodir_theme_location = get_option('geodir_theme_location_nav_'.$newname);
227 227
     if ($geodir_theme_location) {
228 228
         update_option('geodir_theme_location_nav', $geodir_theme_location);
229 229
     } else {
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 
322 322
 /////// GEO DIRECOTORY CUSTOM HOOKS ///
323 323
 
324
-add_action('geodir_before_tab_content', 'geodir_before_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content 
325
-add_action('geodir_after_tab_content', 'geodir_after_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content
324
+add_action('geodir_before_tab_content', 'geodir_before_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content 
325
+add_action('geodir_after_tab_content', 'geodir_after_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content
326 326
 
327 327
 // Detail page sidebar content 
328 328
 add_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting', 1);
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
     do_action('geodir_after_social_sharing_buttons');
423 423
     $content_html = ob_get_clean();
424 424
     if (trim($content_html) != '')
425
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
426
-    if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
425
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">'.$content_html.'</div>';
426
+    if ((int) get_option('geodir_disable_tfg_buttons_section') != 1) {
427 427
         /**
428 428
          * Filter the geodir_social_sharing_buttons() function content.
429 429
          *
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
             $post_id = $post->ID;
464 464
             
465 465
             if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
466
-                $post_id = (int)$_REQUEST['pid'];
466
+                $post_id = (int) $_REQUEST['pid'];
467 467
             }
468 468
 
469 469
             $postlink = get_permalink(geodir_add_listing_page_id());
470 470
             $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
471
-            echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
471
+            echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="'.esc_url($editlink).'">'.__('Edit this Post', 'geodirectory').'</a></p>';
472 472
         }
473 473
     }// end of if, if its a preview or not
474 474
     /**
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
     do_action('geodir_after_edit_post_link');
480 480
     $content_html = ob_get_clean();
481 481
     if (trim($content_html) != '')
482
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
483
-    if ((int)get_option('geodir_disable_user_links_section') != 1) {
482
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">'.$content_html.'</div>';
483
+    if ((int) get_option('geodir_disable_user_links_section') != 1) {
484 484
         /**
485 485
          * Filter the geodir_edit_post_link() function content.
486 486
          *
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
  */
502 502
 function geodir_detail_page_google_analytics()
503 503
 {
504
-    global $post,$preview;
505
-    if($preview){return '';}
504
+    global $post, $preview;
505
+    if ($preview) {return ''; }
506 506
     $package_info = array();
507 507
     $package_info = geodir_post_package_info($package_info, $post);
508 508
 
@@ -534,14 +534,14 @@  discard block
 block discarded – undo
534 534
     $hide_refresh = get_option('geodir_ga_auto_refresh');
535 535
     
536 536
     $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0;
537
-    if (get_option('geodir_ga_stats') && is_user_logged_in() &&  (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
537
+    if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id() == $post->post_author || current_user_can('manage_options'))) {
538 538
         $page_url = urlencode($_SERVER['REQUEST_URI']);
539 539
         ?>
540 540
         <script type="text/javascript">
541 541
             var gd_gaTimeOut;
542
-            var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
543
-            var gd_gaHideRefresh = <?php echo (int)$hide_refresh;?>;
544
-            var gd_gaAutoRefresh = <?php echo $auto_refresh;?>;
542
+            var gd_gaTime = parseInt('<?php echo $refresh_time; ?>');
543
+            var gd_gaHideRefresh = <?php echo (int) $hide_refresh; ?>;
544
+            var gd_gaAutoRefresh = <?php echo $auto_refresh; ?>;
545 545
             ga_data1 = false;
546 546
             ga_data2 = false;
547 547
             ga_data3 = false;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
             }
683 683
 
684 684
             function gdga_noResults() {
685
-                jQuery('#gdga-chart-container').html('<?php _e('No results available','geodirectory');?>');
685
+                jQuery('#gdga-chart-container').html('<?php _e('No results available', 'geodirectory'); ?>');
686 686
                 jQuery('#gdga-legend-container').html('');
687 687
             }
688 688
 
@@ -714,18 +714,18 @@  discard block
 block discarded – undo
714 714
                     var data2 = results[1].rows.map(function(row) { return +row[2]; });
715 715
                     //var labelsN = results[0].rows.map(function(row) { return +row[1]; });
716 716
 
717
-                    var labels = ['<?php _e('Jan', 'geodirectory');?>',
718
-                        '<?php _e('Feb', 'geodirectory');?>',
719
-                        '<?php _e('Mar', 'geodirectory');?>',
720
-                        '<?php _e('Apr', 'geodirectory');?>',
721
-                        '<?php _e('May', 'geodirectory');?>',
722
-                        '<?php _e('Jun', 'geodirectory');?>',
723
-                        '<?php _e('Jul', 'geodirectory');?>',
724
-                        '<?php _e('Aug', 'geodirectory');?>',
725
-                        '<?php _e('Sep', 'geodirectory');?>',
726
-                        '<?php _e('Oct', 'geodirectory');?>',
727
-                        '<?php _e('Nov', 'geodirectory');?>',
728
-                        '<?php _e('Dec', 'geodirectory');?>'];
717
+                    var labels = ['<?php _e('Jan', 'geodirectory'); ?>',
718
+                        '<?php _e('Feb', 'geodirectory'); ?>',
719
+                        '<?php _e('Mar', 'geodirectory'); ?>',
720
+                        '<?php _e('Apr', 'geodirectory'); ?>',
721
+                        '<?php _e('May', 'geodirectory'); ?>',
722
+                        '<?php _e('Jun', 'geodirectory'); ?>',
723
+                        '<?php _e('Jul', 'geodirectory'); ?>',
724
+                        '<?php _e('Aug', 'geodirectory'); ?>',
725
+                        '<?php _e('Sep', 'geodirectory'); ?>',
726
+                        '<?php _e('Oct', 'geodirectory'); ?>',
727
+                        '<?php _e('Nov', 'geodirectory'); ?>',
728
+                        '<?php _e('Dec', 'geodirectory'); ?>'];
729 729
 
730 730
                     // Ensure the data arrays are at least as long as the labels array.
731 731
                     // Chart.js bar charts don't (yet) accept sparse datasets.
@@ -738,13 +738,13 @@  discard block
 block discarded – undo
738 738
                         labels : labels,
739 739
                         datasets : [
740 740
                             {
741
-                                label: '<?php _e('Last Year', 'geodirectory');?>',
741
+                                label: '<?php _e('Last Year', 'geodirectory'); ?>',
742 742
                                 fillColor : "rgba(220,220,220,0.5)",
743 743
                                 strokeColor : "rgba(220,220,220,1)",
744 744
                                 data : data2
745 745
                             },
746 746
                             {
747
-                                label: '<?php _e('This Year', 'geodirectory');?>',
747
+                                label: '<?php _e('This Year', 'geodirectory'); ?>',
748 748
                                 fillColor : "rgba(151,187,205,0.5)",
749 749
                                 strokeColor : "rgba(151,187,205,1)",
750 750
                                 data : data1
@@ -789,30 +789,30 @@  discard block
 block discarded – undo
789 789
 
790 790
                     <?php
791 791
                     // Here we list the shorthand days of the week so it can be used in translation.
792
-                    __("Mon",'geodirectory');
793
-                    __("Tue",'geodirectory');
794
-                    __("Wed",'geodirectory');
795
-                    __("Thu",'geodirectory');
796
-                    __("Fri",'geodirectory');
797
-                    __("Sat",'geodirectory');
798
-                    __("Sun",'geodirectory');
792
+                    __("Mon", 'geodirectory');
793
+                    __("Tue", 'geodirectory');
794
+                    __("Wed", 'geodirectory');
795
+                    __("Thu", 'geodirectory');
796
+                    __("Fri", 'geodirectory');
797
+                    __("Sat", 'geodirectory');
798
+                    __("Sun", 'geodirectory');
799 799
                     ?>
800 800
 
801 801
                     labels = [
802
-                        "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
803
-                        "<?php _e(date('D', strtotime("+2 day")),'geodirectory'); ?>",
804
-                        "<?php _e(date('D', strtotime("+3 day")),'geodirectory'); ?>",
805
-                        "<?php _e(date('D', strtotime("+4 day")),'geodirectory'); ?>",
806
-                        "<?php _e(date('D', strtotime("+5 day")),'geodirectory'); ?>",
807
-                        "<?php _e(date('D', strtotime("+6 day")),'geodirectory'); ?>",
808
-                        "<?php _e(date('D', strtotime("+7 day")),'geodirectory'); ?>"
802
+                        "<?php _e(date('D', strtotime("+1 day")), 'geodirectory'); ?>",
803
+                        "<?php _e(date('D', strtotime("+2 day")), 'geodirectory'); ?>",
804
+                        "<?php _e(date('D', strtotime("+3 day")), 'geodirectory'); ?>",
805
+                        "<?php _e(date('D', strtotime("+4 day")), 'geodirectory'); ?>",
806
+                        "<?php _e(date('D', strtotime("+5 day")), 'geodirectory'); ?>",
807
+                        "<?php _e(date('D', strtotime("+6 day")), 'geodirectory'); ?>",
808
+                        "<?php _e(date('D', strtotime("+7 day")), 'geodirectory'); ?>"
809 809
                     ];
810 810
 
811 811
                     var data = {
812 812
                         labels : labels,
813 813
                         datasets : [
814 814
                             {
815
-                                label: '<?php _e('Last Week', 'geodirectory');?>',
815
+                                label: '<?php _e('Last Week', 'geodirectory'); ?>',
816 816
                                 fillColor : "rgba(220,220,220,0.5)",
817 817
                                 strokeColor : "rgba(220,220,220,1)",
818 818
                                 pointColor : "rgba(220,220,220,1)",
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
                                 data : data2
821 821
                             },
822 822
                             {
823
-                                label: '<?php _e('This Week', 'geodirectory');?>',
823
+                                label: '<?php _e('This Week', 'geodirectory'); ?>',
824 824
                                 fillColor : "rgba(151,187,205,0.5)",
825 825
                                 strokeColor : "rgba(151,187,205,1)",
826 826
                                 pointColor : "rgba(151,187,205,1)",
@@ -1027,18 +1027,18 @@  discard block
 block discarded – undo
1027 1027
         </style>
1028 1028
         <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
1029 1029
         <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
1030
-        <button type="button" class="gdga-show-analytics"><?php _e('Show Google Analytics', 'geodirectory');?></button>
1030
+        <button type="button" class="gdga-show-analytics"><?php _e('Show Google Analytics', 'geodirectory'); ?></button>
1031 1031
         <span id="ga_stats" class="gdga-analytics-box" style="display:none">
1032
-            <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory');?></div>
1032
+            <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory'); ?></div>
1033 1033
             <div id="gd-active-users-container">
1034
-                <div class="gd-ActiveUsers"><i id="gdga-loader-icon" class="fa fa-refresh fa-spin" title="<?php esc_attr_e("Refresh", 'geodirectory');?>"></i><?php _e("Active Users:", 'geodirectory');?>
1034
+                <div class="gd-ActiveUsers"><i id="gdga-loader-icon" class="fa fa-refresh fa-spin" title="<?php esc_attr_e("Refresh", 'geodirectory'); ?>"></i><?php _e("Active Users:", 'geodirectory'); ?>
1035 1035
                     <b class="gd-ActiveUsers-value">0</b>
1036 1036
                 </div>
1037 1037
             </div>
1038 1038
             <select id="gdga-select-analytic" onchange="gdga_select_option();" style="display: none;">
1039
-                <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory');?></option>
1040
-                <option value="years"><?php _e("This Year vs Last Year", 'geodirectory');?></option>
1041
-                <option value="country"><?php _e("Top Countries", 'geodirectory');?></option>
1039
+                <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory'); ?></option>
1040
+                <option value="years"><?php _e("This Year vs Last Year", 'geodirectory'); ?></option>
1041
+                <option value="country"><?php _e("Top Countries", 'geodirectory'); ?></option>
1042 1042
             </select>
1043 1043
             <div class="Chartjs-figure" id="gdga-chart-container"></div>
1044 1044
             <ol class="Chartjs-legend" id="gdga-legend-container"></ol>
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
     do_action('geodir_after_google_analytics');
1055 1055
     $content_html = ob_get_clean();
1056 1056
     if (trim($content_html) != '')
1057
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1058
-    if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1057
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">'.$content_html.'</div>';
1058
+    if ((int) get_option('geodir_disable_google_analytics_section') != 1) {
1059 1059
         /**
1060 1060
          * Filter the geodir_edit_post_link() function content.
1061 1061
          *
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 {
1082 1082
     global $post, $preview, $post_images;
1083 1083
     
1084
-    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
1084
+    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int) $post->ID)) {
1085 1085
         return;
1086 1086
     }
1087 1087
     ob_start(); // Start  buffering;
@@ -1116,10 +1116,10 @@  discard block
 block discarded – undo
1116 1116
        
1117 1117
 	   $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
1118 1118
 	   
1119
-	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
1119
+	   $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="'.$post_avgratings.'">'.$post_avgratings.'</span> / <span itemprop="best" content="5">5</span> '.__("based on", 'geodirectory').' </span><span class="count" itemprop="count" content="'.$comment_count.'">'.$comment_count.' '.$reviews_text.'</span><br />';
1120 1120
 
1121 1121
         $html .= '<span class="item">';
1122
-        $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>';
1122
+        $html .= '<span class="fn" itemprop="itemreviewed">'.$post->post_title.'</span>';
1123 1123
 
1124 1124
         if ($post_images) {
1125 1125
             foreach ($post_images as $img) {
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
         }
1130 1130
 
1131 1131
         if (isset($post_img) && $post_img) {
1132
-            $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />';
1132
+            $html .= '<br /><img src="'.$post_img.'" class="photo" alt="'.esc_attr($post->post_title).'" itemprop="photo" content="'.$post_img.'" class="photo" />';
1133 1133
         }
1134 1134
 
1135 1135
         $html .= '</span>';
@@ -1156,9 +1156,9 @@  discard block
 block discarded – undo
1156 1156
     do_action('geodir_after_detail_page_review_rating');
1157 1157
     $content_html = ob_get_clean();
1158 1158
     if (trim($content_html) != '') {
1159
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>';
1159
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">'.$content_html.'</div>';
1160 1160
     }
1161
-    if ((int)get_option('geodir_disable_rating_info_section') != 1) {
1161
+    if ((int) get_option('geodir_disable_rating_info_section') != 1) {
1162 1162
         /**
1163 1163
          * Filter the geodir_detail_page_review_rating() function content.
1164 1164
          *
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
 
1198 1198
     $content_html = ob_get_clean();
1199 1199
     if (trim($content_html) != '')
1200
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1201
-    if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1200
+        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">'.$content_html.'</div>';
1201
+    if ((int) get_option('geodir_disable_listing_info_section') != 1) {
1202 1202
         /**
1203 1203
          * Filter the output html for function geodir_detail_page_more_info().
1204 1204
          *
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 		'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
1298 1298
 		'geodir_txt_form_wait' => __('Wait...', 'geodirectory'),
1299 1299
 		'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
1300
-		'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1300
+		'fa_rating' => (int) get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
1301 1301
 		'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
1302 1302
         'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false,
1303 1303
         'geodir_map_name' => geodir_map_name(),
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
     foreach ($arr_alert_msg as $key => $value) {
1327 1327
         if (!is_scalar($value))
1328 1328
             continue;
1329
-        $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1329
+        $arr_alert_msg[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
1330 1330
     }
1331 1331
 
1332
-    $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';';
1332
+    $script = "var geodir_all_js_msg = ".json_encode($arr_alert_msg).';';
1333 1333
     echo '<script>';
1334 1334
     echo $script;
1335 1335
     echo '</script>';
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
         $geodir_old_sidebars = get_option('geodir_sidebars');
1420 1420
         if (is_array($geodir_old_sidebars)) {
1421 1421
             foreach ($geodir_old_sidebars as $key => $val) {
1422
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1422
+                if (0 === strpos($key, 'geodir_'))// if gd widget
1423 1423
                 {
1424 1424
                     $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1425 1425
                 }
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
         global $post;
1499 1499
         $term_condition = '';
1500 1500
         if (isset($_REQUEST['backandedit'])) {
1501
-            $post = (object)$gd_session->get('listing');
1501
+            $post = (object) $gd_session->get('listing');
1502 1502
             $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : '';
1503 1503
         }
1504 1504
 
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
                     echo 'checked="checked"';
1513 1513
                 } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition"
1514 1514
                        class="geodir_textfield" value="1"
1515
-                       style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1515
+                       style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if ($terms_page) { echo get_permalink($terms_page); }?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
1516 1516
 				</span>
1517 1517
             </div>
1518 1518
             <span class="geodir_message_error"><?php if (isset($required_msg)) {
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
         /** This action is documented in geodirectory_template_actions.php */
1553 1553
         $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
1554 1554
         
1555
-        if (!($desc_limit === '' || (int)$desc_limit > 0)) {
1555
+        if (!($desc_limit === '' || (int) $desc_limit > 0)) {
1556 1556
             $is_display = false;
1557 1557
         }
1558 1558
     }
@@ -1600,16 +1600,16 @@  discard block
 block discarded – undo
1600 1600
     global $wpdb, $plugin_prefix;
1601 1601
 	
1602 1602
 	// Remove unused virtual page
1603
-	$listings_page_id = (int)get_option('geodir_listing_page');
1603
+	$listings_page_id = (int) get_option('geodir_listing_page');
1604 1604
 	if ($listings_page_id) {
1605
-		$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1605
+		$wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->posts." WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
1606 1606
         delete_option('geodir_listing_page');
1607 1607
 	}
1608 1608
 
1609 1609
     if (!get_option('geodir_changes_in_custom_fields_table')) {
1610 1610
         $wpdb->query(
1611 1611
             $wpdb->prepare(
1612
-                "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s",
1612
+                "UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET is_default=%s, is_admin=%s WHERE is_default=%s",
1613 1613
                 array('1', '1', 'admin')
1614 1614
             )
1615 1615
         );
@@ -1617,9 +1617,9 @@  discard block
 block discarded – undo
1617 1617
 
1618 1618
         /* --- terms meta value set --- */
1619 1619
 
1620
-        update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
1620
+        update_option('geodir_default_marker_icon', geodir_plugin_url().'/geodirectory-functions/map-functions/icons/pin.png');
1621 1621
 
1622
-        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
1622
+        $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."options WHERE option_name LIKE %s", array('%tax_meta_%')));
1623 1623
 
1624 1624
         if (!empty($options_data)) {
1625 1625
 
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 
1628 1628
                 $option_val = str_replace('tax_meta_', '', $optobj->option_name);
1629 1629
 
1630
-                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1630
+                $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM ".$wpdb->prefix."term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
1631 1631
 
1632 1632
                 if (!empty($taxonomies_data)) {
1633 1633
 
@@ -1636,17 +1636,17 @@  discard block
 block discarded – undo
1636 1636
                         $taxObject = get_taxonomy($taxobj->taxonomy);
1637 1637
                         $post_type = $taxObject->object_type[0];
1638 1638
 
1639
-                        $opt_value = 'tax_meta_' . $post_type . '_' . $option_val;
1639
+                        $opt_value = 'tax_meta_'.$post_type.'_'.$option_val;
1640 1640
 
1641
-                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
1641
+                        $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM ".$wpdb->prefix."options WHERE option_name=%s", array('tax_meta_'.$option_val)));
1642 1642
 
1643 1643
                         if ($duplicate_data) {
1644 1644
 
1645
-                            $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1645
+                            $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."options SET	option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
1646 1646
 
1647 1647
                         } else {
1648 1648
 
1649
-                            $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1649
+                            $wpdb->query($wpdb->prepare("INSERT INTO ".$wpdb->prefix."options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
1650 1650
 
1651 1651
                         }
1652 1652
 
@@ -1680,14 +1680,14 @@  discard block
 block discarded – undo
1680 1680
 
1681 1681
     global $wpdb, $table_prefix;
1682 1682
 
1683
-    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
1683
+    $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s", array($slug)));
1684 1684
 
1685 1685
     if ($slug_exists) {
1686 1686
 
1687 1687
         $suffix = 1;
1688 1688
         do {
1689
-            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1690
-            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
1689
+            $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
1690
+            $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s", array($alt_location_name)));
1691 1691
             $suffix++;
1692 1692
         } while ($location_slug_check && $suffix < 100);
1693 1693
 
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 
1742 1742
         $suffix = 1;
1743 1743
         do {
1744
-            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix";
1744
+            $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix";
1745 1745
 
1746 1746
             /** This action is documented in geodirectory_hooks_actions.php */
1747 1747
             $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 
1754 1754
         //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
1755 1755
 
1756
-        $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1756
+        $wpdb->query($wpdb->prepare("UPDATE ".$table_prefix."terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
1757 1757
 
1758 1758
     }
1759 1759
 	
@@ -1762,18 +1762,18 @@  discard block
 block discarded – undo
1762 1762
 	$post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL;
1763 1763
 	
1764 1764
 	$post_types = geodir_get_posttypes();
1765
-	if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) {		
1766
-		$posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id)));
1765
+	if ($post_type && in_array($post_type, $post_types) && $post_type.'_tags' == $taxonomy) {		
1766
+		$posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id = %d", array($tt_id)));
1767 1767
 		
1768 1768
 		if (!empty($posts_obj)) {
1769 1769
 			foreach ($posts_obj as $post_obj) {
1770 1770
 				$post_id = $post_obj->object_id;
1771 1771
 				
1772
-				$raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names'));
1772
+				$raw_tags = wp_get_object_terms($post_id, $post_type.'_tags', array('fields' => 'names'));
1773 1773
 				$post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : '';
1774 1774
 				
1775
-				$listing_table = $plugin_prefix . $post_type . '_detail';
1776
-				$wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id)));
1775
+				$listing_table = $plugin_prefix.$post_type.'_detail';
1776
+				$wpdb->query($wpdb->prepare("UPDATE ".$listing_table." SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id)));
1777 1777
 			}
1778 1778
 		}
1779 1779
 	}
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
     if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1808 1808
         return $slug_exists = true;
1809 1809
 
1810
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1810
+    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1811 1811
         return $slug_exists = true;
1812 1812
 
1813 1813
     return $slug_exists;
@@ -1848,43 +1848,43 @@  discard block
 block discarded – undo
1848 1848
 
1849 1849
 
1850 1850
     $gd_page = '';
1851
-    if(geodir_is_page('home')){
1851
+    if (geodir_is_page('home')) {
1852 1852
         $gd_page = 'home';
1853 1853
         $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1854 1854
     }
1855
-    elseif(geodir_is_page('detail')){
1855
+    elseif (geodir_is_page('detail')) {
1856 1856
         $gd_page = 'detail';
1857 1857
         $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1858 1858
     }
1859
-    elseif(geodir_is_page('pt')){
1859
+    elseif (geodir_is_page('pt')) {
1860 1860
         $gd_page = 'pt';
1861 1861
         $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1862 1862
     }
1863
-    elseif(geodir_is_page('listing')){
1863
+    elseif (geodir_is_page('listing')) {
1864 1864
         $gd_page = 'listing';
1865 1865
         $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1866 1866
     }
1867
-    elseif(geodir_is_page('location')){
1867
+    elseif (geodir_is_page('location')) {
1868 1868
         $gd_page = 'location';
1869 1869
         $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1870 1870
     }
1871
-    elseif(geodir_is_page('search')){
1871
+    elseif (geodir_is_page('search')) {
1872 1872
         $gd_page = 'search';
1873 1873
         $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1874 1874
     }
1875
-    elseif(geodir_is_page('add-listing')){
1875
+    elseif (geodir_is_page('add-listing')) {
1876 1876
         $gd_page = 'add-listing';
1877 1877
         $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1878 1878
     }
1879
-    elseif(geodir_is_page('author')){
1879
+    elseif (geodir_is_page('author')) {
1880 1880
         $gd_page = 'author';
1881 1881
         $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1882 1882
     }
1883
-    elseif(geodir_is_page('login')){
1883
+    elseif (geodir_is_page('login')) {
1884 1884
         $gd_page = 'login';
1885 1885
         $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1886 1886
     }
1887
-    elseif(geodir_is_page('listing-success')){
1887
+    elseif (geodir_is_page('listing-success')) {
1888 1888
         $gd_page = 'listing-success';
1889 1889
         $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1890 1890
     }
@@ -1916,12 +1916,12 @@  discard block
 block discarded – undo
1916 1916
 
1917 1917
     if (!get_option('geodir_set_post_attachments')) {
1918 1918
 
1919
-        require_once(ABSPATH . 'wp-admin/includes/image.php');
1920
-        require_once(ABSPATH . 'wp-admin/includes/file.php');
1919
+        require_once(ABSPATH.'wp-admin/includes/image.php');
1920
+        require_once(ABSPATH.'wp-admin/includes/file.php');
1921 1921
 
1922 1922
         $all_postypes = geodir_get_posttypes();
1923 1923
 
1924
-        foreach($all_postypes as $post_type){
1924
+        foreach ($all_postypes as $post_type) {
1925 1925
             $args = array(
1926 1926
                 'posts_per_page' => -1,
1927 1927
                 'post_type' => $post_type,
@@ -2015,7 +2015,7 @@  discard block
 block discarded – undo
2015 2015
 {
2016 2016
     $user_id = get_current_user_id();
2017 2017
 
2018
-    if(!$user_id){return $post;}
2018
+    if (!$user_id) {return $post; }
2019 2019
 
2020 2020
     $gd_post_types = geodir_get_posttypes();
2021 2021
 
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
 
2125 2125
         if (array_key_exists('post_video', $tabs_arr)) {
2126 2126
 
2127
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2127
+            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from ".GEODIR_CUSTOM_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2128 2128
 
2129 2129
             if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2130 2130
                 $tabs_arr['post_video']['heading_text'] = $field_title;
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
 
2133 2133
         if (array_key_exists('special_offers', $tabs_arr)) {
2134 2134
 
2135
-            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2135
+            $field_title = $wpdb->get_var($wpdb->prepare("select site_title from ".GEODIR_CUSTOM_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2136 2136
 
2137 2137
             if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2138 2138
                 $tabs_arr['special_offers']['heading_text'] = $field_title;
@@ -2153,7 +2153,7 @@  discard block
 block discarded – undo
2153 2153
  */
2154 2154
 function geodir_remove_template_redirect_actions()
2155 2155
 {
2156
-    if (geodir_is_page('login')){
2156
+    if (geodir_is_page('login')) {
2157 2157
         remove_all_actions('template_redirect');
2158 2158
         remove_action('init', 'avia_modify_front', 10);
2159 2159
     }
@@ -2200,25 +2200,25 @@  discard block
 block discarded – undo
2200 2200
         $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
2201 2201
 
2202 2202
         $wpdb->query(
2203
-            $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
2203
+            $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d AND file=%s ",
2204 2204
                 array($post_id, $split_img_file_path)
2205 2205
             )
2206 2206
         );
2207 2207
 
2208 2208
         $attachment_data = $wpdb->get_row(
2209
-            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
2209
+            $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id=%d",
2210 2210
                 array($post_id)
2211 2211
             )
2212 2212
         );
2213 2213
 
2214 2214
         if (!empty($attachment_data)) {
2215
-            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2215
+            $wpdb->query("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order=1 WHERE ID=".$attachment_data->ID);
2216 2216
         }
2217 2217
 
2218 2218
 
2219
-        $table_name = $plugin_prefix . $post_type . '_detail';
2219
+        $table_name = $plugin_prefix.$post_type.'_detail';
2220 2220
 
2221
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
2221
+        $wpdb->query("UPDATE ".$table_name." SET featured_image='' WHERE post_id =".$post_id);
2222 2222
 
2223 2223
         geodir_set_wp_featured_image($post_id);
2224 2224
 
@@ -2246,9 +2246,9 @@  discard block
 block discarded – undo
2246 2246
 
2247 2247
     foreach ($all_postypes as $posttype) {
2248 2248
 
2249
-        $tablename = $plugin_prefix . $posttype . '_detail';
2249
+        $tablename = $plugin_prefix.$posttype.'_detail';
2250 2250
 
2251
-        $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
2251
+        $get_post_data = $wpdb->get_results("SELECT post_id FROM ".$tablename);
2252 2252
 
2253 2253
         if (!empty($get_post_data)) {
2254 2254
 
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
 
2257 2257
                 $post_id = $data->post_id;
2258 2258
 
2259
-                $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
2259
+                $attachment_data = $wpdb->get_results("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id =".$post_id." AND file!=''");
2260 2260
 
2261 2261
                 if (!empty($attachment_data)) {
2262 2262
 
@@ -2273,22 +2273,22 @@  discard block
 block discarded – undo
2273 2273
 
2274 2274
                         $file_name = $file_info['basename'];
2275 2275
 
2276
-                        $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name;
2276
+                        $img_arr['path'] = $uploads_path.$sub_dir.'/'.$file_name;
2277 2277
 
2278 2278
                         if (!file_exists($img_arr['path'])) {
2279 2279
 
2280
-                            $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
2280
+                            $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ID=".$attach->ID);
2281 2281
 
2282 2282
                         }
2283 2283
 
2284 2284
                     }
2285 2285
 
2286
-                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
2286
+                    $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id=".$post_id." GROUP BY post_id");
2287 2287
 
2288 2288
                     if (!empty($attachment_data)) {
2289 2289
 
2290 2290
                         if ($attachment_data->ID)
2291
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2291
+                            $wpdb->query("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order=1 WHERE ID=".$attachment_data->ID);
2292 2292
 
2293 2293
                     } else {
2294 2294
 
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 
2303 2303
                     }
2304 2304
 
2305
-                    $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
2305
+                    $wpdb->query("UPDATE ".$tablename." SET featured_image='' WHERE post_id =".$post_id);
2306 2306
 
2307 2307
                     geodir_set_wp_featured_image($post_id);
2308 2308
 
@@ -2331,7 +2331,7 @@  discard block
 block discarded – undo
2331 2331
 {
2332 2332
 
2333 2333
     if (!get_option('geodir_default_rating_star_icon')) {
2334
-        update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
2334
+        update_option('geodir_default_rating_star_icon', geodir_plugin_url().'/geodirectory-assets/images/stars.png');
2335 2335
     }
2336 2336
 
2337 2337
 }
@@ -2348,10 +2348,10 @@  discard block
 block discarded – undo
2348 2348
  * @global string $plugin_prefix Geodirectory plugin table prefix.
2349 2349
  * @return array User listing count for each post type.
2350 2350
  */
2351
-function geodir_user_post_listing_count($user_id=null)
2351
+function geodir_user_post_listing_count($user_id = null)
2352 2352
 {
2353 2353
     global $wpdb, $plugin_prefix, $current_user;
2354
-    if(!$user_id){
2354
+    if (!$user_id) {
2355 2355
         $user_id = $current_user->ID;
2356 2356
     }
2357 2357
 
@@ -2362,7 +2362,7 @@  discard block
 block discarded – undo
2362 2362
     $user_listing = array();
2363 2363
     if (is_array($all_posts) && !empty($all_posts)) {
2364 2364
         foreach ($all_posts as $ptype) {
2365
-            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
2365
+            $total_posts = $wpdb->get_var("SELECT count( ID ) FROM ".$wpdb->prefix."posts WHERE post_author=".$user_id." AND post_type='".$ptype."' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
2366 2366
 
2367 2367
             if ($total_posts > 0) {
2368 2368
                 $user_listing[$ptype] = $total_posts;
@@ -2403,19 +2403,19 @@  discard block
 block discarded – undo
2403 2403
 
2404 2404
         $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location);
2405 2405
         //remove video and special offers if it is already set to show
2406
-        if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){
2406
+        if (isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']) {
2407 2407
             $unset_video = true;
2408 2408
         }
2409 2409
 
2410
-        if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){
2410
+        if (isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']) {
2411 2411
             $unset_special_offers = true;
2412 2412
         }
2413
-        if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){
2414
-            foreach($custom_fields as $key => $custom_field){
2415
-                if($custom_field['name']=='geodir_video' && isset($unset_video)){
2413
+        if (isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)) {
2414
+            foreach ($custom_fields as $key => $custom_field) {
2415
+                if ($custom_field['name'] == 'geodir_video' && isset($unset_video)) {
2416 2416
                     unset($custom_fields[$key]);
2417 2417
                 }
2418
-                if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){
2418
+                if ($custom_field['name'] == 'geodir_special_offers' && isset($unset_special_offers)) {
2419 2419
                     unset($custom_fields[$key]);
2420 2420
                 }
2421 2421
             }
@@ -2432,7 +2432,7 @@  discard block
 block discarded – undo
2432 2432
                     $post->{$field_name} = $_REQUEST[$field_name];
2433 2433
                 }
2434 2434
 
2435
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false  && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2435
+                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) {
2436 2436
                     if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
2437 2437
                         continue;
2438 2438
                     }
@@ -2465,7 +2465,7 @@  discard block
 block discarded – undo
2465 2465
                     $post->{$field_name} = $_REQUEST[$field_name];
2466 2466
                 }
2467 2467
 
2468
-                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) {
2468
+                if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) {
2469 2469
                     $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
2470 2470
                     $site_title = trim($field['site_title']);
2471 2471
                     $type = $field;
@@ -2481,21 +2481,21 @@  discard block
 block discarded – undo
2481 2481
                         $variables_array['label'] = __($type['site_title'], 'geodirectory');
2482 2482
                         $variables_array['value'] = '';
2483 2483
                         $variables_array['value'] = $post->{$type['htmlvar_name']};
2484
-                    }else{
2484
+                    } else {
2485 2485
                         $i = 0;
2486 2486
                         $fieldset_count++;
2487 2487
                         $field_set_start = 1;
2488
-                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
2488
+                        $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_'.$fieldset_count;
2489 2489
                         $fieldset_arr[$fieldset_count]['label'] = $label;
2490 2490
                     }
2491 2491
 
2492 2492
 
2493
-                    if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
2493
+                    if (isset($type['extra_fields'])) {$extra_fields = $type['extra_fields']; }
2494 2494
                     $type = stripslashes_deep($type); // strip slashes
2495
-                    if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
2495
+                    if (isset($type['extra_fields'])) {$type['extra_fields'] = $extra_fields; }
2496 2496
                     $html = '';
2497 2497
                     $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
2498
-                    if($html_var=='post'){$html_var='post_address';}
2498
+                    if ($html_var == 'post') {$html_var = 'post_address'; }
2499 2499
                     $field_icon = geodir_field_icon_proccess($type);
2500 2500
                     $filed_type = $type['type'];
2501 2501
 
@@ -2508,7 +2508,7 @@  discard block
 block discarded – undo
2508 2508
                      * @param string $fields_location The location the field is to be show.
2509 2509
                      * @param array $type The array of field values.
2510 2510
                      */
2511
-                    $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
2511
+                    $html = apply_filters("geodir_custom_field_output_{$filed_type}", $html, $fields_location, $type);
2512 2512
 
2513 2513
 
2514 2514
                     /**
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
                                  * @param string $htmlvar_name The field HTML var name.
2555 2555
                                  */
2556 2556
                                 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
2557
-                                'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>'
2557
+                                'tab_content' => '<div class="geodir-company_info field-group xxx">'.$fieldset_html.'</div>'
2558 2558
                             );
2559 2559
                         }
2560 2560
                     } else {
@@ -2616,7 +2616,7 @@  discard block
 block discarded – undo
2616 2616
             }
2617 2617
             $status .= ")</strong>";
2618 2618
 
2619
-            $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
2619
+            $html = '<span class="geodir-post-status">'.$status_icon.' <font class="geodir-status-label">'.__('Status: ', 'geodirectory').'</font>'.$status.'</span>';
2620 2620
         }
2621 2621
     }
2622 2622
 
@@ -2685,7 +2685,7 @@  discard block
 block discarded – undo
2685 2685
  * @return array Modified class array.
2686 2686
  */
2687 2687
 function geodir_body_class_active_map($classes = array()) {
2688
-    $classes[] = 'gd-map-' . geodir_map_name();
2688
+    $classes[] = 'gd-map-'.geodir_map_name();
2689 2689
 
2690 2690
     return $classes;
2691 2691
 }
@@ -2700,7 +2700,7 @@  discard block
 block discarded – undo
2700 2700
  * @return string Modified class string.
2701 2701
  */
2702 2702
 function geodir_admin_body_class_active_map($class = '') {    
2703
-    $class .= ' gd-map-' . geodir_map_name();
2703
+    $class .= ' gd-map-'.geodir_map_name();
2704 2704
 
2705 2705
     return $class;
2706 2706
 }
@@ -2720,7 +2720,7 @@  discard block
 block discarded – undo
2720 2720
  * @return array Translation texts.
2721 2721
  */
2722 2722
 function geodir_load_gd_options_text_translation($translation_texts = array()) {
2723
-    $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array();
2723
+    $translation_texts = !empty($translation_texts) && is_array($translation_texts) ? $translation_texts : array();
2724 2724
 
2725 2725
     $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
2726 2726
 
@@ -2786,17 +2786,17 @@  discard block
 block discarded – undo
2786 2786
  * @param array $args The array of menu arguments.
2787 2787
  * @return array The modified arguments.
2788 2788
  */
2789
-function geodir_add_nav_menu_class( $args )
2789
+function geodir_add_nav_menu_class($args)
2790 2790
 {
2791 2791
 
2792
-        if(isset($args['menu_class'])){
2792
+        if (isset($args['menu_class'])) {
2793 2793
             $args['menu_class'] = $args['menu_class']." gd-menu-z";
2794 2794
         }
2795 2795
     
2796 2796
     return $args;
2797 2797
 }
2798 2798
 
2799
-add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' );
2799
+add_filter('wp_nav_menu_args', 'geodir_add_nav_menu_class');
2800 2800
 
2801 2801
 /**
2802 2802
  * Filters WordPress locale ID.
@@ -2836,9 +2836,9 @@  discard block
 block discarded – undo
2836 2836
         }
2837 2837
         
2838 2838
         add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2);
2839
-        add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 );
2839
+        add_action('geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1);
2840 2840
         if (is_admin()) {
2841
-            add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 );
2841
+            add_filter('geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1);
2842 2842
         }
2843 2843
     }
2844 2844
 }
@@ -2867,7 +2867,7 @@  discard block
 block discarded – undo
2867 2867
         }        
2868 2868
         
2869 2869
         if (!empty($keep_vars)) {
2870
-            foreach ( $languages as $code => $url) {
2870
+            foreach ($languages as $code => $url) {
2871 2871
                 $filter_url = $url['url'];
2872 2872
                 
2873 2873
                 foreach ($keep_vars as $var) {
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 
2887 2887
     return $languages;
2888 2888
 }
2889
-add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 );
2889
+add_filter('icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1);
2890 2890
 
2891 2891
 /**
2892 2892
  * Remove Yoast SEO hook if disabled on GD pages.
@@ -2894,18 +2894,18 @@  discard block
 block discarded – undo
2894 2894
  * @since 1.6.18
2895 2895
  *
2896 2896
  */
2897
-function geodir_remove_yoast_seo_metas(){
2898
-    if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) {
2897
+function geodir_remove_yoast_seo_metas() {
2898
+    if (class_exists('WPSEO_Frontend') && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas()) {
2899 2899
         $wpseo = WPSEO_Frontend::get_instance();
2900 2900
         
2901
-        remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 );
2902
-        remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 );
2903
-        remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 );
2904
-        remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 );
2905
-        remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 );
2906
-        remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 );
2901
+        remove_action('wp_head', array($wpseo, 'metadesc'), 6);
2902
+        remove_action('wp_head', array($wpseo, 'metakeywords'), 11);
2903
+        remove_filter('pre_get_document_title', array($wpseo, 'title'), 15);
2904
+        remove_filter('wp_title', array($wpseo, 'title'), 15, 3);
2905
+        remove_filter('thematic_doctitle', array($wpseo, 'title'), 15);
2906
+        remove_filter('woo_title', array($wpseo, 'fix_woo_title'), 99);
2907 2907
         
2908
-        remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 );
2908
+        remove_action('template_redirect', 'wpseo_frontend_head_init', 999);
2909 2909
     }
2910 2910
 }
2911 2911
 
@@ -2920,22 +2920,22 @@  discard block
 block discarded – undo
2920 2920
  *
2921 2921
  */
2922 2922
  function geodir_wpml_ajax_set_guest_lang() {    
2923
-    if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) {
2924
-        if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) {
2923
+    if (geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in()) {
2924
+        if (empty($_GET['lang']) && !(!empty($_SERVER['REQUEST_URI']) && preg_match('@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename(preg_replace('@\?.*$@', '', $_SERVER['REQUEST_URI']))))) {
2925 2925
             global $sitepress;
2926 2926
             
2927 2927
             $referer = wp_get_referer();
2928 2928
             
2929 2929
             $current_lang = $sitepress->get_current_language();
2930
-            $referrer_lang = $sitepress->get_language_from_url( $referer );
2930
+            $referrer_lang = $sitepress->get_language_from_url($referer);
2931 2931
             
2932
-            if ( $referrer_lang && $current_lang != $referrer_lang ) {
2932
+            if ($referrer_lang && $current_lang != $referrer_lang) {
2933 2933
                 $_GET['lang'] = $referrer_lang;
2934 2934
             }
2935 2935
         }
2936 2936
     }
2937 2937
 }
2938
-add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 );
2938
+add_action('plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1);
2939 2939
 
2940 2940
 /**
2941 2941
  * Change country slug czech-republic to czechia and redirect.
@@ -2956,18 +2956,18 @@  discard block
 block discarded – undo
2956 2956
         }
2957 2957
         
2958 2958
         $redirect = false;
2959
-        if (strpos($current_url, '/' . $search . '/') !== false) {
2959
+        if (strpos($current_url, '/'.$search.'/') !== false) {
2960 2960
             $redirect = true;
2961
-            $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1);
2961
+            $current_url = preg_replace('/\/'.$search.'\//', '/'.$replace.'/', $current_url, 1);
2962 2962
         }
2963 2963
         
2964 2964
         if ($has_slash != "/") {
2965 2965
             $current_url = trim($current_url, '/');
2966 2966
         }
2967 2967
         
2968
-        if (strpos($current_url, 'gd_country=' . $search) !== false) {
2968
+        if (strpos($current_url, 'gd_country='.$search) !== false) {
2969 2969
             $redirect = true;
2970
-            $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url);
2970
+            $current_url = str_replace('gd_country='.$search, 'gd_country='.$replace, $current_url);
2971 2971
         }
2972 2972
 
2973 2973
         if ($redirect) {
@@ -2992,26 +2992,26 @@  discard block
 block discarded – undo
2992 2992
  * @param int    $post_parent   Post parent ID
2993 2993
  * @param string $original_slug The original post slug.
2994 2994
  */
2995
-function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
2995
+function geodir_check_post_to_term_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) {
2996 2996
     global $wpdb;
2997 2997
     
2998
-    if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) {
2999
-        $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '" . $post_type . "category' OR taxonomy = '" . $post_type . "_tags' ) LIMIT 1", $slug ) );
2998
+    if ($post_type && strpos($post_type, 'gd_') === 0) {
2999
+        $term_slug_check = $wpdb->get_var($wpdb->prepare("SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '".$post_type."category' OR taxonomy = '".$post_type."_tags' ) LIMIT 1", $slug));
3000 3000
 
3001
-        if ( $term_slug_check ) {
3001
+        if ($term_slug_check) {
3002 3002
             $suffix = 1;
3003 3003
             
3004 3004
             do {
3005
-                $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
3005
+                $alt_slug = _truncate_post_slug($original_slug, 200 - (strlen($suffix) + 1))."-$suffix";
3006 3006
                 
3007
-                $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '" . $post_type . "category' OR taxonomy = '" . $post_type . "_tags' ) LIMIT 1", $alt_slug ) );
3007
+                $term_check = $wpdb->get_var($wpdb->prepare("SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id WHERE slug = '%s' AND ( taxonomy = '".$post_type."category' OR taxonomy = '".$post_type."_tags' ) LIMIT 1", $alt_slug));
3008 3008
                 
3009
-                $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1", $alt_slug, $post_type, $post_ID ) );
3009
+                $post_check = !$term_check && $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1", $alt_slug, $post_type, $post_ID));
3010 3010
                 
3011 3011
                 $term_slug_check = $term_check || $post_check;
3012 3012
                 
3013 3013
                 $suffix++;
3014
-            } while ( $term_slug_check );
3014
+            } while ($term_slug_check);
3015 3015
             
3016 3016
             $slug = $alt_slug;
3017 3017
         }
@@ -3019,7 +3019,7 @@  discard block
 block discarded – undo
3019 3019
     
3020 3020
     return $slug;
3021 3021
 }
3022
-add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 10, 6 );
3022
+add_filter('wp_unique_post_slug', 'geodir_check_post_to_term_slug', 10, 6);
3023 3023
 
3024 3024
 /**
3025 3025
  * Check whether a post name with slug exists or not.
@@ -3034,25 +3034,25 @@  discard block
 block discarded – undo
3034 3034
  * @param int $term_id The term ID.
3035 3035
  * @return bool true when exists. false when not exists.
3036 3036
  */
3037
-function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) {
3037
+function geodir_check_term_to_post_slug($slug_exists, $slug, $term_id) {
3038 3038
     global $wpdb, $gd_term_post_type;
3039 3039
     
3040
-    if ( $slug_exists ) {
3040
+    if ($slug_exists) {
3041 3041
         return $slug_exists;
3042 3042
     }
3043 3043
     
3044
-    if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) {
3044
+    if (!empty($gd_term_post_type) && $gd_term_post_type[$term_id]) {
3045 3045
         $post_type = $gd_term_post_type[$term_id];
3046 3046
     } else {
3047
-        $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) );
3048
-        $taxonomy_obj = get_taxonomy( $taxonomy );
3049
-        $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL;
3047
+        $taxonomy = $wpdb->get_var($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id));
3048
+        $taxonomy_obj = get_taxonomy($taxonomy);
3049
+        $post_type = !empty($taxonomy_obj->object_type) ? $taxonomy_obj->object_type[0] : NULL;
3050 3050
     }
3051 3051
     
3052
-    if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s LIMIT 1", $slug, $post_type ) ) ) {
3052
+    if ($post_type && $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s LIMIT 1", $slug, $post_type))) {
3053 3053
         $slug_exists = true;
3054 3054
     }
3055 3055
 
3056 3056
     return $slug_exists;
3057 3057
 }
3058
-add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 );
3059 3058
\ No newline at end of file
3059
+add_filter('geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3);
3060 3060
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 3 patches
Indentation   +1252 added lines, -1252 removed lines patch added patch discarded remove patch
@@ -33,265 +33,265 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_add_nav_menu_items()
35 35
 {
36
-    $items = '';
37
-    // apply filter to add more navigations // -Filter-Location-Manager
38
-
39
-    if (get_option('geodir_show_listing_nav')) {
40
-
41
-        $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
44
-
45
-
46
-        //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
-        $post_types = geodir_get_posttypes('object');
48
-        $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
-        if (!empty($post_types)) {
50
-            foreach ($post_types as $post_type => $args) {
51
-                if (!empty($show_post_type_main_nav)) {
52
-                    if (in_array($post_type, $show_post_type_main_nav)) {
53
-                        if (get_post_type_archive_link($post_type)) {
54
-                            $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
57
-                            /**
58
-                             * Filter the menu li class.
59
-                             *
60
-                             * @since 1.0.0
61
-                             * @param string $menu_class The menu HTML class.
62
-                             */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
-                            /**
65
-                             * Filter the menu a class.
66
-                             *
67
-                             * @since 1.0.0
68
-                             */
69
-                            $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
36
+	$items = '';
37
+	// apply filter to add more navigations // -Filter-Location-Manager
38
+
39
+	if (get_option('geodir_show_listing_nav')) {
40
+
41
+		$menu_class = '';
42
+		if (geodir_is_page('listing'))
43
+			$menu_class = 'current-menu-item';
44
+
45
+
46
+		//SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
+		$post_types = geodir_get_posttypes('object');
48
+		$show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
+		if (!empty($post_types)) {
50
+			foreach ($post_types as $post_type => $args) {
51
+				if (!empty($show_post_type_main_nav)) {
52
+					if (in_array($post_type, $show_post_type_main_nav)) {
53
+						if (get_post_type_archive_link($post_type)) {
54
+							$menu_class = '';
55
+							if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
+								$menu_class = 'current-menu-item';
57
+							/**
58
+							 * Filter the menu li class.
59
+							 *
60
+							 * @since 1.0.0
61
+							 * @param string $menu_class The menu HTML class.
62
+							 */
63
+							$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
+							/**
65
+							 * Filter the menu a class.
66
+							 *
67
+							 * @since 1.0.0
68
+							 */
69
+							$a_class = apply_filters('geodir_menu_a_class', '');
70
+							$items .= '<li class="' . $li_class . '">
71 71
 									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72 72
 										' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
73 73
 									</a>
74 74
 								</li>';
75
-                        }
76
-                    }
77
-                }
78
-            }
79
-        }
80
-        //END LISTING OF POST TYPE IN MAIN NAVIGATION
81
-
82
-        $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
-        $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
-        if ($is_listing_sub_meny_exists) {
85
-            /**
86
-             * Filter the menu li class.
87
-             *
88
-             * @since 1.0.0
89
-             * @param string $menu_class The menu HTML class.
90
-             */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
-            /**
93
-             * Filter the sub menu li class.
94
-             *
95
-             * @since 1.0.0
96
-             * @param string $menu_class The menu HTML class.
97
-             */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
-            /**
100
-             * Filter the sub menu ul class.
101
-             *
102
-             * @since 1.0.0
103
-             */
104
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
-            /**
106
-             * Filter the menu a class.
107
-             *
108
-             * @since 1.0.0
109
-             */
110
-            $a_class = apply_filters('geodir_menu_a_class', '');
111
-            /**
112
-             * Filter the sub menu a class.
113
-             *
114
-             * @since 1.0.0
115
-             */
116
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
75
+						}
76
+					}
77
+				}
78
+			}
79
+		}
80
+		//END LISTING OF POST TYPE IN MAIN NAVIGATION
81
+
82
+		$view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
+		$is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
+		if ($is_listing_sub_meny_exists) {
85
+			/**
86
+			 * Filter the menu li class.
87
+			 *
88
+			 * @since 1.0.0
89
+			 * @param string $menu_class The menu HTML class.
90
+			 */
91
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
+			/**
93
+			 * Filter the sub menu li class.
94
+			 *
95
+			 * @since 1.0.0
96
+			 * @param string $menu_class The menu HTML class.
97
+			 */
98
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
+			/**
100
+			 * Filter the sub menu ul class.
101
+			 *
102
+			 * @since 1.0.0
103
+			 */
104
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
+			/**
106
+			 * Filter the menu a class.
107
+			 *
108
+			 * @since 1.0.0
109
+			 */
110
+			$a_class = apply_filters('geodir_menu_a_class', '');
111
+			/**
112
+			 * Filter the sub menu a class.
113
+			 *
114
+			 * @since 1.0.0
115
+			 */
116
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
+			$items .= '<li class="' . $li_class . '">
118 118
 					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119 119
 					<ul class="' . $sub_ul_class . '">';
120
-            $post_types = geodir_get_posttypes('object');
120
+			$post_types = geodir_get_posttypes('object');
121 121
 
122
-            $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
122
+			$show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
123 123
 
124
-            if (!empty($post_types)) {
125
-                global $geodir_add_location_url;
126
-                $geodir_add_location_url = true;
127
-                foreach ($post_types as $post_type => $args) {
128
-                    if (!empty($show_listing_post_types)) {
129
-                        if (in_array($post_type, $show_listing_post_types)) {
130
-                            if (get_post_type_archive_link($post_type)) {
124
+			if (!empty($post_types)) {
125
+				global $geodir_add_location_url;
126
+				$geodir_add_location_url = true;
127
+				foreach ($post_types as $post_type => $args) {
128
+					if (!empty($show_listing_post_types)) {
129
+						if (in_array($post_type, $show_listing_post_types)) {
130
+							if (get_post_type_archive_link($post_type)) {
131 131
 
132
-                                $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
132
+								$menu_class = '';
133
+								if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
+									$menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
136
+								$items .= '<li class="' . $sub_li_class . '">
137 137
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138 138
 															' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
139 139
 														</a>
140 140
 													</li>';
141
-                            }
142
-                        }
143
-                    }
144
-                }
145
-                $geodir_add_location_url = NULL;
146
-            }
141
+							}
142
+						}
143
+					}
144
+				}
145
+				$geodir_add_location_url = NULL;
146
+			}
147 147
 
148
-            $items .= '	</ul> ';
149
-            /**
150
-             * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
-             *
152
-             * @since 1.5.9
153
-             */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
155
-            $items .= '</li>';
156
-        }
157
-    }
158
-
159
-    if (get_option('geodir_show_addlisting_nav')) {
160
-
161
-        $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
164
-
165
-        //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
-        $post_types = geodir_get_posttypes('object');
167
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
-
170
-        if (!empty($post_types)) {
171
-            foreach ($post_types as $post_type => $args) {
172
-                if (!empty($geodir_allow_posttype_frontend)) {
173
-                    if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
-                        if (!empty($show_add_listing_post_types_main_nav)) {
175
-                            if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
-                                if (geodir_get_addlisting_link($post_type)) {
177
-
178
-                                    $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
181
-                                    /**
182
-                                     * Filter the menu li class.
183
-                                     *
184
-                                     * @since 1.0.0
185
-                                     * @param string $menu_class The menu HTML class.
186
-                                     */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
-                                    /**
189
-                                     * Filter the menu a class.
190
-                                     *
191
-                                     * @since 1.0.0
192
-                                     */
193
-                                    $a_class = apply_filters('geodir_menu_a_class', '');
194
-                                    $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
148
+			$items .= '	</ul> ';
149
+			/**
150
+			 * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
+			 *
152
+			 * @since 1.5.9
153
+			 */
154
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
155
+			$items .= '</li>';
156
+		}
157
+	}
158
+
159
+	if (get_option('geodir_show_addlisting_nav')) {
160
+
161
+		$menu_class = '';
162
+		if (geodir_is_page('add-listing'))
163
+			$menu_class = 'current-menu-item';
164
+
165
+		//SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
+		$post_types = geodir_get_posttypes('object');
167
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
+
170
+		if (!empty($post_types)) {
171
+			foreach ($post_types as $post_type => $args) {
172
+				if (!empty($geodir_allow_posttype_frontend)) {
173
+					if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
+						if (!empty($show_add_listing_post_types_main_nav)) {
175
+							if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
+								if (geodir_get_addlisting_link($post_type)) {
177
+
178
+									$menu_class = '';
179
+									if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
+										$menu_class = 'current-menu-item';
181
+									/**
182
+									 * Filter the menu li class.
183
+									 *
184
+									 * @since 1.0.0
185
+									 * @param string $menu_class The menu HTML class.
186
+									 */
187
+									$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
+									/**
189
+									 * Filter the menu a class.
190
+									 *
191
+									 * @since 1.0.0
192
+									 */
193
+									$a_class = apply_filters('geodir_menu_a_class', '');
194
+									$cpt_name = __($args->labels->singular_name, 'geodirectory');
195
+									$items .= '<li class="' . $li_class . '">
196 196
 											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197 197
 												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
198 198
 											</a>
199 199
 										</li>';
200
-                                }
201
-                            }
202
-                        }
203
-                    }
204
-                }
205
-            }
206
-        }
207
-        //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
-    }
209
-
210
-    $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
-    $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
-    if ($is_add_listing_sub_meny_exists) {
213
-
214
-        if (get_option('geodir_show_addlisting_nav')) {
215
-            /**
216
-             * Filter the menu li class.
217
-             *
218
-             * @since 1.0.0
219
-             * @param string $menu_class The menu HTML class.
220
-             */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
-            /**
223
-             * Filter the sub menu li class.
224
-             *
225
-             * @since 1.0.0
226
-             * @param string $menu_class The menu HTML class.
227
-             */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
-            /**
230
-             * Filter the sub menu ul class.
231
-             *
232
-             * @since 1.0.0
233
-             */
234
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
-            /**
236
-             * Filter the menu a class.
237
-             *
238
-             * @since 1.0.0
239
-             */
240
-            $a_class = apply_filters('geodir_menu_a_class', '');
241
-            /**
242
-             * Filter the sub menu a class.
243
-             *
244
-             * @since 1.0.0
245
-             */
246
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
200
+								}
201
+							}
202
+						}
203
+					}
204
+				}
205
+			}
206
+		}
207
+		//END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
+	}
209
+
210
+	$view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
+	$is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
+	if ($is_add_listing_sub_meny_exists) {
213
+
214
+		if (get_option('geodir_show_addlisting_nav')) {
215
+			/**
216
+			 * Filter the menu li class.
217
+			 *
218
+			 * @since 1.0.0
219
+			 * @param string $menu_class The menu HTML class.
220
+			 */
221
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
+			/**
223
+			 * Filter the sub menu li class.
224
+			 *
225
+			 * @since 1.0.0
226
+			 * @param string $menu_class The menu HTML class.
227
+			 */
228
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
+			/**
230
+			 * Filter the sub menu ul class.
231
+			 *
232
+			 * @since 1.0.0
233
+			 */
234
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
+			/**
236
+			 * Filter the menu a class.
237
+			 *
238
+			 * @since 1.0.0
239
+			 */
240
+			$a_class = apply_filters('geodir_menu_a_class', '');
241
+			/**
242
+			 * Filter the sub menu a class.
243
+			 *
244
+			 * @since 1.0.0
245
+			 */
246
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
+			$items .= '<li  class="' . $li_class . '">
248 248
 					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249 249
 					<ul class="' . $sub_ul_class . '">';
250 250
 
251
-            $post_types = geodir_get_posttypes('object');
252
-
253
-            $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
-
255
-            if (!empty($post_types)) {
256
-                foreach ($post_types as $post_type => $args) {
257
-                    if (!empty($geodir_allow_posttype_frontend)) {
258
-                        if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
-                            if (!empty($show_add_listing_post_types)) {
260
-                                if (in_array($post_type, $show_add_listing_post_types)) {
261
-                                    if (geodir_get_addlisting_link($post_type)) {
262
-
263
-                                        $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
266
-                                        /**
267
-                                         * Filter the menu li class.
268
-                                         *
269
-                                         * @since 1.0.0
270
-                                         * @param string $menu_class The menu HTML class.
271
-                                         */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
-                                        $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $sub_li_class . '">
251
+			$post_types = geodir_get_posttypes('object');
252
+
253
+			$show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
+
255
+			if (!empty($post_types)) {
256
+				foreach ($post_types as $post_type => $args) {
257
+					if (!empty($geodir_allow_posttype_frontend)) {
258
+						if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
+							if (!empty($show_add_listing_post_types)) {
260
+								if (in_array($post_type, $show_add_listing_post_types)) {
261
+									if (geodir_get_addlisting_link($post_type)) {
262
+
263
+										$menu_class = '';
264
+										if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
+											$menu_class = 'current-menu-item';
266
+										/**
267
+										 * Filter the menu li class.
268
+										 *
269
+										 * @since 1.0.0
270
+										 * @param string $menu_class The menu HTML class.
271
+										 */
272
+										$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
+										$cpt_name = __($args->labels->singular_name, 'geodirectory');
274
+										$items .= '<li class="' . $sub_li_class . '">
275 275
 														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276 276
 															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
277 277
 														</a>
278 278
 													</li>';
279
-                                    }
280
-                                }
281
-                            }
282
-                        }
283
-                    }
284
-                }
285
-            }
279
+									}
280
+								}
281
+							}
282
+						}
283
+					}
284
+				}
285
+			}
286 286
 
287
-            $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
289
-            $items .= '</li>';
287
+			$items .= '	</ul> ';
288
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
289
+			$items .= '</li>';
290 290
 
291
-        }
292
-    }
293
-    // apply filter to add more navigations // -Filter-Location-Manager
294
-    return $items;
291
+		}
292
+	}
293
+	// apply filter to add more navigations // -Filter-Location-Manager
294
+	return $items;
295 295
 }
296 296
 
297 297
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function geodir_pagemenu_items($menu, $args)
311 311
 {
312
-    $locations = get_nav_menu_locations();
313
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
314
-    $geodir_theme_location_nav = array();
315
-    if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
-        $geodir_theme_location_nav[] = $args['theme_location'];
318
-        update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
-    }
320
-    //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
312
+	$locations = get_nav_menu_locations();
313
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
314
+	$geodir_theme_location_nav = array();
315
+	if (empty($locations) && empty($geodir_theme_location)) {
316
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
+		$geodir_theme_location_nav[] = $args['theme_location'];
318
+		update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
+	}
320
+	//else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
322
+	else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
324 324
 
325
-    return $menu;
325
+	return $menu;
326 326
 
327 327
 }
328 328
 
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
 function geodir_menu_items($items, $args)
343 343
 {
344 344
 
345
-    $location = $args->theme_location;
345
+	$location = $args->theme_location;
346 346
 
347
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
347
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
348 348
 
349
-    if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
349
+	if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
352
-        return $items;
351
+		$items = $items . geodir_add_nav_menu_items();
352
+		return $items;
353 353
 
354
-    } else {
355
-        return $items;
356
-    }
354
+	} else {
355
+		return $items;
356
+	}
357 357
 }
358 358
 
359 359
 /**
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function geodir_get_category_all_array()
370 370
 {
371
-    global $wpdb;
372
-    $return_array = array();
373
-
374
-    $taxonomies = geodir_get_taxonomies();
375
-    $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
377
-
378
-    $pn_categories = $wpdb->get_results(
379
-        $wpdb->prepare(
380
-            "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
382
-        )
383
-    );
384
-
385
-    foreach ($pn_categories as $pn_categories_obj) {
386
-        $return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
-            "title" => $pn_categories_obj->name,);
388
-    }
389
-    return $return_array;
371
+	global $wpdb;
372
+	$return_array = array();
373
+
374
+	$taxonomies = geodir_get_taxonomies();
375
+	$taxonomies = implode("','", $taxonomies);
376
+	$taxonomies = "'" . $taxonomies . "'";
377
+
378
+	$pn_categories = $wpdb->get_results(
379
+		$wpdb->prepare(
380
+			"SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
+			array($wpdb->terms . term_id)
382
+		)
383
+	);
384
+
385
+	foreach ($pn_categories as $pn_categories_obj) {
386
+		$return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
+			"title" => $pn_categories_obj->name,);
388
+	}
389
+	return $return_array;
390 390
 }
391 391
 
392 392
 
@@ -402,49 +402,49 @@  discard block
 block discarded – undo
402 402
  * @return string The post type.
403 403
  */
404 404
 function geodir_get_current_posttype() {
405
-    global $wp_query, $post, $geodir_post_type;
405
+	global $wp_query, $post, $geodir_post_type;
406 406
 
407
-    $geodir_post_type = get_query_var('post_type');
407
+	$geodir_post_type = get_query_var('post_type');
408 408
 
409
-    if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
-    }
409
+	if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
+			$geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
+		elseif (isset($_REQUEST['listing_type']))
413
+			$geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
+	}
415 415
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
416
+	if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
418 418
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
419
+	if (is_tax())
420
+		$geodir_post_type = geodir_get_taxonomy_posttype();
421 421
 
422
-    // Retrive post type for map marker html ajax request on preview page.
423
-    if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
-        if (!empty($post->post_type)) {
425
-            $geodir_post_type = $post->post_type;
426
-        } else if (!empty($post->listing_type)) {
427
-            $geodir_post_type = $post->listing_type;
428
-        }
429
-    }
422
+	// Retrive post type for map marker html ajax request on preview page.
423
+	if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
+		if (!empty($post->post_type)) {
425
+			$geodir_post_type = $post->post_type;
426
+		} else if (!empty($post->listing_type)) {
427
+			$geodir_post_type = $post->listing_type;
428
+		}
429
+	}
430 430
 
431
-    $all_postypes = geodir_get_posttypes();
432
-    $all_postypes = stripslashes_deep($all_postypes);
431
+	$all_postypes = geodir_get_posttypes();
432
+	$all_postypes = stripslashes_deep($all_postypes);
433 433
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
434
+	if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
+		$geodir_post_type = '';
436 436
 
437
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
-    }
437
+	if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
+	}
440 440
 
441 441
 
442
-    /**
443
-     * Filter the default CPT return.
444
-     *
445
-     * @since 1.6.9
446
-     */
447
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
442
+	/**
443
+	 * Filter the default CPT return.
444
+	 *
445
+	 * @since 1.6.9
446
+	 */
447
+	return apply_filters('geodir_get_current_posttype',$geodir_post_type);
448 448
 }
449 449
 
450 450
 /**
@@ -458,22 +458,22 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_get_default_posttype()
460 460
 {
461
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
-
463
-    $stype = false;
464
-    foreach ( $post_types as $post_type => $info ) {
465
-        global $wpdb;
466
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
-        if ( $has_posts ) {
468
-            $stype = $post_type; break;
469
-        }
470
-    }
471
-
472
-    if(!$stype){
473
-        $stype = 'gd_place';
474
-    }
475
-
476
-    return $stype;
461
+	$post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
+
463
+	$stype = false;
464
+	foreach ( $post_types as $post_type => $info ) {
465
+		global $wpdb;
466
+		$has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
+		if ( $has_posts ) {
468
+			$stype = $post_type; break;
469
+		}
470
+	}
471
+
472
+	if(!$stype){
473
+		$stype = 'gd_place';
474
+	}
475
+
476
+	return $stype;
477 477
 }
478 478
 
479 479
 /**
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
  */
488 488
 function geodir_get_posttypes($output = 'names')
489 489
 {
490
-    $post_types = array();
491
-    $post_types = get_option('geodir_post_types');
492
-    $post_types = stripslashes_deep($post_types);
493
-    if (!empty($post_types)) {
494
-        switch ($output):
495
-            case 'object':
496
-            case 'Object':
497
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
-                break;
499
-            case 'array':
500
-            case 'Array':
501
-                $post_types = (array)$post_types;
502
-                break;
490
+	$post_types = array();
491
+	$post_types = get_option('geodir_post_types');
492
+	$post_types = stripslashes_deep($post_types);
493
+	if (!empty($post_types)) {
494
+		switch ($output):
495
+			case 'object':
496
+			case 'Object':
497
+				$post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
+				break;
499
+			case 'array':
500
+			case 'Array':
501
+				$post_types = (array)$post_types;
502
+				break;
503 503
 			case 'options':
504
-                $post_types = (array)$post_types;
504
+				$post_types = (array)$post_types;
505 505
 				
506 506
 				$options = array();
507 507
 				if (!empty($post_types)) {
@@ -510,17 +510,17 @@  discard block
 block discarded – undo
510 510
 					}
511 511
 				}
512 512
 				$post_types = $options;
513
-                break;
514
-            default:
515
-                $post_types = array_keys($post_types);
516
-                break;
517
-        endswitch;
518
-    }
519
-
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
513
+				break;
514
+			default:
515
+				$post_types = array_keys($post_types);
516
+				break;
517
+		endswitch;
518
+	}
519
+
520
+	if (!empty($post_types))
521
+		return $post_types;
522
+	else
523
+		return array();
524 524
 }
525 525
 
526 526
 /**
@@ -533,108 +533,108 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function geodir_get_posttype_info($post_type = '')
535 535
 {
536
-    $post_types = array();
537
-    $post_types = get_option('geodir_post_types');
538
-    $post_types = stripslashes_deep($post_types);
539
-    if (!empty($post_types) && $post_type != '') {
540
-        return $post_types[$post_type];
541
-    } else
542
-        return false;
536
+	$post_types = array();
537
+	$post_types = get_option('geodir_post_types');
538
+	$post_types = stripslashes_deep($post_types);
539
+	if (!empty($post_types) && $post_type != '') {
540
+		return $post_types[$post_type];
541
+	} else
542
+		return false;
543 543
 }
544 544
 
545 545
 if (!function_exists('geodir_get_taxonomies')) {
546
-    /**
547
-     * Get all custom taxonomies.
548
-     *
549
-     * @since 1.0.0
550
-     * @package GeoDirectory
551
-     * @param string $post_type The post type.
552
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
-     * @return array|bool Taxonomies on success. false on failure.
554
-     */
555
-    function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false)
556
-    {
546
+	/**
547
+	 * Get all custom taxonomies.
548
+	 *
549
+	 * @since 1.0.0
550
+	 * @package GeoDirectory
551
+	 * @param string $post_type The post type.
552
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
+	 * @return array|bool Taxonomies on success. false on failure.
554
+	 */
555
+	function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false)
556
+	{
557 557
 
558
-        $taxonomies = array();
559
-        $gd_taxonomies = array();
558
+		$taxonomies = array();
559
+		$gd_taxonomies = array();
560 560
 
561
-        if ($taxonomies = get_option('geodir_taxonomies')) {
561
+		if ($taxonomies = get_option('geodir_taxonomies')) {
562 562
 
563 563
 
564
-            $gd_taxonomies = array_keys($taxonomies);
564
+			$gd_taxonomies = array_keys($taxonomies);
565 565
 
566 566
 
567
-            if ($post_type != '')
568
-                $gd_taxonomies = array();
567
+			if ($post_type != '')
568
+				$gd_taxonomies = array();
569 569
 
570
-            $i = 0;
571
-            foreach ($taxonomies as $taxonomy => $args) {
570
+			$i = 0;
571
+			foreach ($taxonomies as $taxonomy => $args) {
572 572
 
573
-                if ($post_type != '' && $args['object_type'] == $post_type)
574
-                    $gd_taxonomies[] = $taxonomy;
573
+				if ($post_type != '' && $args['object_type'] == $post_type)
574
+					$gd_taxonomies[] = $taxonomy;
575 575
 
576
-                if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
578
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
579
-                }
576
+				if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
+					if (array_search($taxonomy, $gd_taxonomies) !== false)
578
+						unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
579
+				}
580 580
 
581
-            }
581
+			}
582 582
 
583
-            $gd_taxonomies = array_values($gd_taxonomies);
584
-        }
585
-
586
-        /**
587
-         * Filter the taxonomies.
588
-         *
589
-         * @since 1.0.0
590
-         * @param array $gd_taxonomies The taxonomy array.
591
-         */
592
-        $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
593
-
594
-        if (!empty($taxonomies)) {
595
-            return $taxonomies;
596
-        } else {
597
-            return false;
598
-        }
599
-    }
583
+			$gd_taxonomies = array_values($gd_taxonomies);
584
+		}
585
+
586
+		/**
587
+		 * Filter the taxonomies.
588
+		 *
589
+		 * @since 1.0.0
590
+		 * @param array $gd_taxonomies The taxonomy array.
591
+		 */
592
+		$taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
593
+
594
+		if (!empty($taxonomies)) {
595
+			return $taxonomies;
596
+		} else {
597
+			return false;
598
+		}
599
+	}
600 600
 }
601 601
 
602 602
 if (!function_exists(' geodir_get_categories_dl')) {
603
-    /**
604
-     * Get categories dropdown HTML.
605
-     *
606
-     * @since 1.0.0
607
-     * @package GeoDirectory
608
-     * @param string $post_type The post type.
609
-     * @param string $selected The selected value.
610
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
611
-     * @param bool $echo Prints the HTML when set to true. Default: true.
612
-     * @return void|string Dropdown HTML.
613
-     */
614
-    function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
615
-    {
616
-
617
-        $html = '';
618
-        $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
619
-
620
-        $categories = get_terms($taxonomies);
621
-
622
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
623
-
624
-        foreach ($categories as $category_obj) {
625
-            $select_opt = '';
626
-            if ($selected == $category_obj->term_id) {
627
-                $select_opt = 'selected="selected"';
628
-            }
629
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
630
-                . geodir_utf8_ucfirst($category_obj->name) . '</option>';
631
-        }
632
-
633
-        if ($echo)
634
-            echo $html;
635
-        else
636
-            return $html;
637
-    }
603
+	/**
604
+	 * Get categories dropdown HTML.
605
+	 *
606
+	 * @since 1.0.0
607
+	 * @package GeoDirectory
608
+	 * @param string $post_type The post type.
609
+	 * @param string $selected The selected value.
610
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
611
+	 * @param bool $echo Prints the HTML when set to true. Default: true.
612
+	 * @return void|string Dropdown HTML.
613
+	 */
614
+	function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
615
+	{
616
+
617
+		$html = '';
618
+		$taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
619
+
620
+		$categories = get_terms($taxonomies);
621
+
622
+		$html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
623
+
624
+		foreach ($categories as $category_obj) {
625
+			$select_opt = '';
626
+			if ($selected == $category_obj->term_id) {
627
+				$select_opt = 'selected="selected"';
628
+			}
629
+			$html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
630
+				. geodir_utf8_ucfirst($category_obj->name) . '</option>';
631
+		}
632
+
633
+		if ($echo)
634
+			echo $html;
635
+		else
636
+			return $html;
637
+	}
638 638
 }
639 639
 
640 640
 
@@ -649,28 +649,28 @@  discard block
 block discarded – undo
649 649
 function geodir_get_listing_slug($object_type = '')
650 650
 {
651 651
 
652
-    $listing_slug = '';
652
+	$listing_slug = '';
653 653
 
654
-    $post_types = get_option('geodir_post_types');
655
-    $taxonomies = get_option('geodir_taxonomies');
654
+	$post_types = get_option('geodir_post_types');
655
+	$taxonomies = get_option('geodir_taxonomies');
656 656
 
657 657
 
658
-    if ($object_type != '') {
659
-        if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
658
+	if ($object_type != '') {
659
+		if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
660 660
 
661
-            $object_info = $post_types[$object_type];
662
-            $listing_slug = $object_info['listing_slug'];
663
-        } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
664
-            $object_info = $taxonomies[$object_type];
665
-            $listing_slug = $object_info['listing_slug'];
666
-        }
661
+			$object_info = $post_types[$object_type];
662
+			$listing_slug = $object_info['listing_slug'];
663
+		} elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
664
+			$object_info = $taxonomies[$object_type];
665
+			$listing_slug = $object_info['listing_slug'];
666
+		}
667 667
 
668
-    }
668
+	}
669 669
 
670
-    if (!empty($listing_slug))
671
-        return $listing_slug;
672
-    else
673
-        return false;
670
+	if (!empty($listing_slug))
671
+		return $listing_slug;
672
+	else
673
+		return false;
674 674
 }
675 675
 
676 676
 
@@ -685,212 +685,212 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function geodir_get_taxonomy_posttype($taxonomy = '')
687 687
 {
688
-    global $wp_query;
689
-
690
-    $post_type = array();
691
-    $taxonomies = array();
692
-
693
-    if (!empty($taxonomy)) {
694
-        $taxonomies[] = $taxonomy;
695
-    } elseif (isset($wp_query->tax_query->queries)) {
696
-        $tax_arr = $wp_query->tax_query->queries;
697
-        //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
698
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
699
-        $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
700
-    }
701
-
702
-    if (!empty($taxonomies)) {
703
-        foreach (geodir_get_posttypes() as $pt) {
704
-            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
-            if (array_intersect($taxonomies, $object_taxonomies))
706
-                $post_type[] = $pt;
707
-        }
708
-    }
709
-
710
-    if (!empty($post_type))
711
-        return $post_type[0];
712
-    else
713
-        return false;
688
+	global $wp_query;
689
+
690
+	$post_type = array();
691
+	$taxonomies = array();
692
+
693
+	if (!empty($taxonomy)) {
694
+		$taxonomies[] = $taxonomy;
695
+	} elseif (isset($wp_query->tax_query->queries)) {
696
+		$tax_arr = $wp_query->tax_query->queries;
697
+		//if tax query has 'relation' set then it will break wp_list_pluck so we remove it
698
+		if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
699
+		$taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
700
+	}
701
+
702
+	if (!empty($taxonomies)) {
703
+		foreach (geodir_get_posttypes() as $pt) {
704
+			$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
+			if (array_intersect($taxonomies, $object_taxonomies))
706
+				$post_type[] = $pt;
707
+		}
708
+	}
709
+
710
+	if (!empty($post_type))
711
+		return $post_type[0];
712
+	else
713
+		return false;
714 714
 }
715 715
 
716 716
 if (!function_exists('geodir_custom_taxonomy_walker')) {
717
-    /**
718
-     * Custom taxonomy walker function.
719
-     *
720
-     * @since 1.0.0
721
-     * @package GeoDirectory
722
-     * @param string $cat_taxonomy The taxonomy name.
723
-     * @param int $cat_parent The parent term ID.
724
-     * @param bool $hide_empty Hide empty taxonomies? Default: false.
725
-     * @param int $pading CSS padding in pixels.
726
-     * @return string|void taxonomy HTML.
727
-     */
728
-    function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
729
-    {
730
-        global $cat_display, $post_cat, $exclude_cats;
731
-
732
-        $search_terms = trim($post_cat, ",");
733
-
734
-        $search_terms = explode(",", $search_terms);
735
-
736
-        $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
737
-
738
-        $display = '';
739
-        $onchange = '';
740
-        $term_check = '';
741
-        $main_list_class = '';
742
-        $out = '';
743
-        //If there are terms, start displaying
744
-        if (count($cat_terms) > 0) {
745
-            //Displaying as a list
746
-            $p = $pading * 20;
747
-            $pading++;
748
-
749
-
750
-            if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
751
-                if ($cat_parent == 0) {
752
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
753
-                    $main_list_class = 'class="main_list_selecter"';
754
-                } else {
755
-                    //$display = 'display:none';
756
-                    $list_class = 'sub_list gd-sub-cats-list';
757
-                }
758
-            }
717
+	/**
718
+	 * Custom taxonomy walker function.
719
+	 *
720
+	 * @since 1.0.0
721
+	 * @package GeoDirectory
722
+	 * @param string $cat_taxonomy The taxonomy name.
723
+	 * @param int $cat_parent The parent term ID.
724
+	 * @param bool $hide_empty Hide empty taxonomies? Default: false.
725
+	 * @param int $pading CSS padding in pixels.
726
+	 * @return string|void taxonomy HTML.
727
+	 */
728
+	function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
729
+	{
730
+		global $cat_display, $post_cat, $exclude_cats;
731
+
732
+		$search_terms = trim($post_cat, ",");
733
+
734
+		$search_terms = explode(",", $search_terms);
735
+
736
+		$cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
737
+
738
+		$display = '';
739
+		$onchange = '';
740
+		$term_check = '';
741
+		$main_list_class = '';
742
+		$out = '';
743
+		//If there are terms, start displaying
744
+		if (count($cat_terms) > 0) {
745
+			//Displaying as a list
746
+			$p = $pading * 20;
747
+			$pading++;
748
+
749
+
750
+			if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
751
+				if ($cat_parent == 0) {
752
+					$list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
753
+					$main_list_class = 'class="main_list_selecter"';
754
+				} else {
755
+					//$display = 'display:none';
756
+					$list_class = 'sub_list gd-sub-cats-list';
757
+				}
758
+			}
759 759
 
760
-            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
761
-                $p = 0;
762
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
763
-            }
760
+			if ($cat_display == 'checkbox' || $cat_display == 'radio') {
761
+				$p = 0;
762
+				$out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
763
+			}
764 764
 
765
-            foreach ($cat_terms as $cat_term) {
765
+			foreach ($cat_terms as $cat_term) {
766 766
 
767
-                $checked = '';
767
+				$checked = '';
768 768
 
769
-                if (in_array($cat_term->term_id, $search_terms)) {
770
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
771
-                        $checked = 'selected="selected"';
772
-                    else
773
-                        $checked = 'checked="checked"';
774
-                }
769
+				if (in_array($cat_term->term_id, $search_terms)) {
770
+					if ($cat_display == 'select' || $cat_display == 'multiselect')
771
+						$checked = 'selected="selected"';
772
+					else
773
+						$checked = 'checked="checked"';
774
+				}
775 775
 
776
-                if ($cat_display == 'radio')
777
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
776
+				if ($cat_display == 'radio')
777
+					$out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
+				elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
+					$out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
780 780
 
781
-                else {
782
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783
-                }
781
+				else {
782
+					$out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783
+				}
784 784
 
785
-                // Call recurson to print sub cats
786
-                $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
785
+				// Call recurson to print sub cats
786
+				$out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
787 787
 
788
-            }
788
+			}
789 789
 
790
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
-                $out .= '</div>';
790
+			if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
+				$out .= '</div>';
792 792
 
793
-            return $out;
794
-        }
795
-        return;
796
-    }
793
+			return $out;
794
+		}
795
+		return;
796
+	}
797 797
 }
798 798
 
799 799
 if (!function_exists('geodir_custom_taxonomy_walker2')) {
800
-    /**
801
-     * Custom taxonomy walker function.
802
-     *
803
-     * @since 1.0.0
804
-     * @package GeoDirectory
805
-     * @global object $post WordPress Post object.
806
-     * @global object $gd_session GeoDirectory Session object.
807
-     * @param string $cat_taxonomy The taxonomy name.
808
-     * @param string $cat_limit Number of categories to display.
809
-     */
810
-    function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
811
-    {
812
-        $post_category = '';
813
-        $post_category_str = '';
814
-        global $exclude_cats, $gd_session;
815
-
816
-        $cat_exclude = '';
817
-        if (is_array($exclude_cats) && !empty($exclude_cats))
818
-            $cat_exclude = serialize($exclude_cats);
819
-
820
-        if (isset($_REQUEST['backandedit'])) {
821
-            $post = (object)$gd_session->get('listing');
822
-
823
-            if (!is_array($post->post_category[$cat_taxonomy]))
824
-                $post_category = $post->post_category[$cat_taxonomy];
825
-
826
-            $post_categories = $post->post_category_str;
827
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
-                $post_category_str = $post_categories[$cat_taxonomy];
829
-
830
-        } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831
-            global $post;
832
-
833
-            $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
834
-            if (empty($post_category) && isset($post->{$cat_taxonomy})) {
835
-                $post_category = $post->{$cat_taxonomy};
836
-            }
800
+	/**
801
+	 * Custom taxonomy walker function.
802
+	 *
803
+	 * @since 1.0.0
804
+	 * @package GeoDirectory
805
+	 * @global object $post WordPress Post object.
806
+	 * @global object $gd_session GeoDirectory Session object.
807
+	 * @param string $cat_taxonomy The taxonomy name.
808
+	 * @param string $cat_limit Number of categories to display.
809
+	 */
810
+	function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
811
+	{
812
+		$post_category = '';
813
+		$post_category_str = '';
814
+		global $exclude_cats, $gd_session;
815
+
816
+		$cat_exclude = '';
817
+		if (is_array($exclude_cats) && !empty($exclude_cats))
818
+			$cat_exclude = serialize($exclude_cats);
819
+
820
+		if (isset($_REQUEST['backandedit'])) {
821
+			$post = (object)$gd_session->get('listing');
822
+
823
+			if (!is_array($post->post_category[$cat_taxonomy]))
824
+				$post_category = $post->post_category[$cat_taxonomy];
825
+
826
+			$post_categories = $post->post_category_str;
827
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
+				$post_category_str = $post_categories[$cat_taxonomy];
829
+
830
+		} elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831
+			global $post;
832
+
833
+			$post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
834
+			if (empty($post_category) && isset($post->{$cat_taxonomy})) {
835
+				$post_category = $post->{$cat_taxonomy};
836
+			}
837 837
 
838
-            $post_categories = get_post_meta($post->ID, 'post_categories', true);
838
+			$post_categories = get_post_meta($post->ID, 'post_categories', true);
839 839
 
840
-            if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
841
-                foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
842
-                    if (is_numeric($cat_part)) {
843
-                        $cat_part_arr[] = $cat_part;
844
-                    }
845
-                }
846
-                if (is_array($cat_part_arr)) {
847
-                    $post_category = implode(',', $cat_part_arr);
848
-                }
849
-            }
840
+			if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
841
+				foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
842
+					if (is_numeric($cat_part)) {
843
+						$cat_part_arr[] = $cat_part;
844
+					}
845
+				}
846
+				if (is_array($cat_part_arr)) {
847
+					$post_category = implode(',', $cat_part_arr);
848
+				}
849
+			}
850 850
 
851
-            if (!empty($post_category)) {
852
-                $cat1 = array_filter(explode(',', $post_category));
853
-                $post_category = ',' . implode(',', $cat1) . ',';
851
+			if (!empty($post_category)) {
852
+				$cat1 = array_filter(explode(',', $post_category));
853
+				$post_category = ',' . implode(',', $cat1) . ',';
854 854
 
855
-            }
855
+			}
856 856
 
857
-            if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
857
+			if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
858 858
 
859
-                $post_category_upd = explode(',', $post_category);
860
-                $post_category_change = '';
861
-                foreach ($post_category_upd as $cat) {
859
+				$post_category_upd = explode(',', $post_category);
860
+				$post_category_change = '';
861
+				foreach ($post_category_upd as $cat) {
862 862
 
863
-                    if (!in_array($cat, $exclude_cats) && $cat != '') {
864
-                        $post_category_change .= ',' . $cat;
865
-                    }
866
-                }
867
-                $post_category = $post_category_change;
868
-            }
863
+					if (!in_array($cat, $exclude_cats) && $cat != '') {
864
+						$post_category_change .= ',' . $cat;
865
+					}
866
+				}
867
+				$post_category = $post_category_change;
868
+			}
869 869
 
870 870
 
871
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
872
-                $post_category_str = $post_categories[$cat_taxonomy];
873
-            }
874
-        }
871
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
872
+				$post_category_str = $post_categories[$cat_taxonomy];
873
+			}
874
+		}
875 875
 
876
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
876
+		echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
877 877
 
878
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
878
+		echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
879 879
 
880
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
880
+		echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
881 881
 
882 882
 
883
-        ?>
883
+		?>
884 884
         <div class="cat_sublist">
885 885
             <?php
886 886
 
887
-            $post_id = isset($post->ID) ? $post->ID : '';
887
+			$post_id = isset($post->ID) ? $post->ID : '';
888 888
 
889
-            if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
889
+			if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
890 890
 
891
-                geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
892
-            }
893
-            ?>
891
+				geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
892
+			}
893
+			?>
894 894
         </div>
895 895
         <script type="text/javascript">
896 896
 
@@ -1013,22 +1013,22 @@  discard block
 block discarded – undo
1013 1013
 
1014 1014
         </script>
1015 1015
         <?php
1016
-        if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017
-            $post_cat_str = $post_categories[$cat_taxonomy];
1018
-            $post_cat_array = explode("#", $post_cat_str);
1019
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
-                $style = "display:none;";
1021
-        }
1022
-        ?>
1016
+		if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017
+			$post_cat_str = $post_categories[$cat_taxonomy];
1018
+			$post_cat_array = explode("#", $post_cat_str);
1019
+			if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
+				$style = "display:none;";
1021
+		}
1022
+		?>
1023 1023
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1024
-            echo $style;
1025
-        }?> ">
1024
+			echo $style;
1025
+		}?> ">
1026 1026
             <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1027
-            ?>
1027
+			?>
1028 1028
         </div>
1029 1029
     <?php
1030 1030
 
1031
-    }
1031
+	}
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1045,23 +1045,23 @@  discard block
 block discarded – undo
1045 1045
  */
1046 1046
 function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '')
1047 1047
 {
1048
-    global $exclude_cats;
1048
+	global $exclude_cats;
1049 1049
 
1050
-    if ($exclude != '') {
1051
-        $exclude_cats = maybe_unserialize(base64_decode($exclude));
1050
+	if ($exclude != '') {
1051
+		$exclude_cats = maybe_unserialize(base64_decode($exclude));
1052 1052
 
1053
-        if(is_array( $exclude_cats)){
1054
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1055
-        }else{
1056
-            $exclude_cats = intval($exclude_cats);
1057
-        }
1053
+		if(is_array( $exclude_cats)){
1054
+			$exclude_cats = array_map( 'intval', $exclude_cats );
1055
+		}else{
1056
+			$exclude_cats = intval($exclude_cats);
1057
+		}
1058 1058
 
1059
-    }
1059
+	}
1060 1060
 
1061
-    if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1062
-        (!is_array($exclude_cats) || empty($exclude_cats))
1063
-    ) {
1064
-        ?>
1061
+	if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1062
+		(!is_array($exclude_cats) || empty($exclude_cats))
1063
+	) {
1064
+		?>
1065 1065
 
1066 1066
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1067 1067
 
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
             <br/>
1092 1092
             <?php
1093
-            $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1094
-            if (!empty($cat_terms)) { ?>
1093
+			$cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1094
+			if (!empty($cat_terms)) { ?>
1095 1095
                 <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
1096 1096
                 <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?>
1097 1097
             <?php } ?>
@@ -1113,53 +1113,53 @@  discard block
 block discarded – undo
1113 1113
 function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories)
1114 1114
 {
1115 1115
 
1116
-    if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1117
-        $post_cat_str = $post_categories[$request_taxonomy];
1118
-        $post_cat_array = explode("#", $post_cat_str);
1119
-        if (is_array($post_cat_array)) {
1120
-            $post_cat_array = array_unique( $post_cat_array );
1116
+	if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1117
+		$post_cat_str = $post_categories[$request_taxonomy];
1118
+		$post_cat_array = explode("#", $post_cat_str);
1119
+		if (is_array($post_cat_array)) {
1120
+			$post_cat_array = array_unique( $post_cat_array );
1121 1121
 
1122 1122
 			foreach ($post_cat_array as $post_cat_html) {
1123 1123
 
1124
-                $post_cat_info = explode(":", $post_cat_html);
1125
-                $post_maincat_str = $post_cat_info[0];
1124
+				$post_cat_info = explode(":", $post_cat_html);
1125
+				$post_maincat_str = $post_cat_info[0];
1126 1126
 
1127
-                if (!empty($post_maincat_str)) {
1128
-                    $post_maincat_info = explode(",", $post_maincat_str);
1129
-                    $post_maincat_id = $post_maincat_info[0];
1130
-                    ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1131
-                    (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1132
-                }
1133
-                $post_sub_catid = '';
1134
-                if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1135
-                    $post_sub_catid = (int)$post_cat_info[1];
1136
-                }
1127
+				if (!empty($post_maincat_str)) {
1128
+					$post_maincat_info = explode(",", $post_maincat_str);
1129
+					$post_maincat_id = $post_maincat_info[0];
1130
+					($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1131
+					(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1132
+				}
1133
+				$post_sub_catid = '';
1134
+				if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1135
+					$post_sub_catid = (int)$post_cat_info[1];
1136
+				}
1137 1137
 
1138
-                geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1138
+				geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1139 1139
 
1140
-            }
1141
-        } else {
1140
+			}
1141
+		} else {
1142 1142
 
1143
-            $post_cat_info = explode(":", $post_cat_str);
1144
-            $post_maincat_str = $post_cat_info[0];
1143
+			$post_cat_info = explode(":", $post_cat_str);
1144
+			$post_maincat_str = $post_cat_info[0];
1145 1145
 
1146
-            $post_sub_catid = '';
1146
+			$post_sub_catid = '';
1147 1147
 
1148
-            if (!empty($post_maincat_str)) {
1149
-                $post_maincat_info = explode(",", $post_maincat_str);
1150
-                $post_maincat_id = $post_maincat_info[0];
1151
-                ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1152
-                (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1153
-            }
1148
+			if (!empty($post_maincat_str)) {
1149
+				$post_maincat_info = explode(",", $post_maincat_str);
1150
+				$post_maincat_id = $post_maincat_info[0];
1151
+				($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1152
+				(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1153
+			}
1154 1154
 
1155
-            if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1156
-                $post_sub_catid = (int)$post_cat_info[1];
1157
-            }
1155
+			if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1156
+				$post_sub_catid = (int)$post_cat_info[1];
1157
+			}
1158 1158
 
1159
-            geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1159
+			geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1160 1160
 
1161
-        }
1162
-    }
1161
+		}
1162
+	}
1163 1163
 }
1164 1164
 
1165 1165
 /**
@@ -1173,35 +1173,35 @@  discard block
 block discarded – undo
1173 1173
  */
1174 1174
 function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false)
1175 1175
 {
1176
-    global $exclude_cats;
1176
+	global $exclude_cats;
1177 1177
 
1178
-    $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1178
+	$cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1179 1179
 
1180
-    if (!empty($cat_terms)) {
1181
-        $onchange = '';
1182
-        $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1180
+	if (!empty($cat_terms)) {
1181
+		$onchange = '';
1182
+		$onchange = ' onchange="show_subcatlist(this.value, this)" ';
1183 1183
 
1184
-        $option_selected = '';
1185
-        if (!$selected)
1186
-            $option_slected = ' selected="selected" ';
1184
+		$option_selected = '';
1185
+		if (!$selected)
1186
+			$option_slected = ' selected="selected" ';
1187 1187
 
1188
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1188
+		echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1189 1189
 
1190
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1190
+		echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1191 1191
 
1192
-        foreach ($cat_terms as $cat_term) {
1193
-            $option_selected = '';
1194
-            if ($selected == $cat_term->term_id)
1195
-                $option_selected = ' selected="selected" ';
1192
+		foreach ($cat_terms as $cat_term) {
1193
+			$option_selected = '';
1194
+			if ($selected == $cat_term->term_id)
1195
+				$option_selected = ' selected="selected" ';
1196 1196
 
1197
-            // Count child terms
1198
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1199
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1197
+			// Count child terms
1198
+			$child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1199
+			$has_child = !empty( $child_terms ) ? 't' : 'f';
1200 1200
 
1201
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1202
-        }
1203
-        echo '</select>';
1204
-    }
1201
+			echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1202
+		}
1203
+		echo '</select>';
1204
+	}
1205 1205
 }
1206 1206
 
1207 1207
 /**
@@ -1217,28 +1217,28 @@  discard block
 block discarded – undo
1217 1217
  */
1218 1218
 function geodir_custom_update_messages($messages)
1219 1219
 {
1220
-    global $post, $post_ID;
1221
-
1222
-    $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1223
-
1224
-    foreach ($post_types as $post_type => $post_object) {
1225
-
1226
-        $messages[$post_type] = array(
1227
-            0 => '', // Unused. Messages start at index 1.
1228
-            1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1229
-            2 => __('Custom field updated.', 'geodirectory'),
1230
-            3 => __('Custom field deleted.', 'geodirectory'),
1231
-            4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1232
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1233
-            6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1234
-            7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1235
-            8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1236
-            9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1237
-            10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1238
-        );
1239
-    }
1240
-
1241
-    return $messages;
1220
+	global $post, $post_ID;
1221
+
1222
+	$post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1223
+
1224
+	foreach ($post_types as $post_type => $post_object) {
1225
+
1226
+		$messages[$post_type] = array(
1227
+			0 => '', // Unused. Messages start at index 1.
1228
+			1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1229
+			2 => __('Custom field updated.', 'geodirectory'),
1230
+			3 => __('Custom field deleted.', 'geodirectory'),
1231
+			4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1232
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1233
+			6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1234
+			7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1235
+			8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1236
+			9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1237
+			10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1238
+		);
1239
+	}
1240
+
1241
+	return $messages;
1242 1242
 }
1243 1243
 
1244 1244
 
@@ -1253,182 +1253,182 @@  discard block
 block discarded – undo
1253 1253
 function geodir_register_defaults()
1254 1254
 {
1255 1255
 
1256
-    global $wpdb;
1257
-
1258
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259
-
1260
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
-        $listing_slug = 'places';
1262
-
1263
-    /**
1264
-     * Taxonomies
1265
-     **/
1266
-    //if ( ! taxonomy_exists('gd_place_tags') )
1267
-    {
1268
-
1269
-        $gd_placetags = array();
1270
-        $gd_placetags['object_type'] = 'gd_place';
1271
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1272
-        $gd_placetags['args'] = array(
1273
-            'public' => true,
1274
-            'hierarchical' => false,
1275
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1276
-            'query_var' => true,
1277
-
1278
-            'labels' => array(
1279
-                'name' => __('Place Tags', 'geodirectory'),
1280
-                'singular_name' => __('Place Tag', 'geodirectory'),
1281
-                'search_items' => __('Search Place Tags', 'geodirectory'),
1282
-                'popular_items' => __('Popular Place Tags', 'geodirectory'),
1283
-                'all_items' => __('All Place Tags', 'geodirectory'),
1284
-                'edit_item' => __('Edit Place Tag', 'geodirectory'),
1285
-                'update_item' => __('Update Place Tag', 'geodirectory'),
1286
-                'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1287
-                'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1288
-                'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1289
-                'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1290
-                'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1291
-            ),
1292
-        );
1293
-
1294
-
1295
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1296
-        $geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1297
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1298
-
1299
-
1300
-        // Update post types and delete tmp options
1301
-        flush_rewrite_rules();
1302
-
1303
-    }
1304
-
1305
-    //if ( ! taxonomy_exists('gd_placecategory') )
1306
-    {
1307
-
1308
-        $gd_placecategory = array();
1309
-        $gd_placecategory['object_type'] = 'gd_place';
1310
-        $gd_placecategory['listing_slug'] = $listing_slug;
1311
-        $gd_placecategory['args'] = array(
1312
-            'public' => true,
1313
-            'hierarchical' => true,
1314
-            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1315
-            'query_var' => true,
1316
-            'labels' => array(
1317
-                'name' => __('Place Categories', 'geodirectory'),
1318
-                'singular_name' => __('Place Category', 'geodirectory'),
1319
-                'search_items' => __('Search Place Categories', 'geodirectory'),
1320
-                'popular_items' => __('Popular Place Categories', 'geodirectory'),
1321
-                'all_items' => __('All Place Categories', 'geodirectory'),
1322
-                'edit_item' => __('Edit Place Category', 'geodirectory'),
1323
-                'update_item' => __('Update Place Category', 'geodirectory'),
1324
-                'add_new_item' => __('Add New Place Category', 'geodirectory'),
1325
-                'new_item_name' => __('New Place Category', 'geodirectory'),
1326
-                'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1327
-            ),
1328
-        );
1329
-
1330
-
1331
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1332
-        $geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1333
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1334
-
1335
-
1336
-        flush_rewrite_rules();
1337
-    }
1338
-
1339
-    /**
1340
-     * Post Types
1341
-     **/
1342
-
1343
-    //if ( ! post_type_exists('gd_place') )
1344
-    {
1345
-
1346
-        $labels = array(
1347
-            'name' => __('Places', 'geodirectory'),
1348
-            'singular_name' => __('Place', 'geodirectory'),
1349
-            'add_new' => __('Add New', 'geodirectory'),
1350
-            'add_new_item' => __('Add New Place', 'geodirectory'),
1351
-            'edit_item' => __('Edit Place', 'geodirectory'),
1352
-            'new_item' => __('New Place', 'geodirectory'),
1353
-            'view_item' => __('View Place', 'geodirectory'),
1354
-            'search_items' => __('Search Places', 'geodirectory'),
1355
-            'not_found' => __('No Place Found', 'geodirectory'),
1356
-            'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1357
-
1358
-        $place_default = array(
1359
-            'labels' => $labels,
1360
-            'can_export' => true,
1361
-            'capability_type' => 'post',
1362
-            'description' => 'Place post type.',
1363
-            'has_archive' => $listing_slug,
1364
-            'hierarchical' => false,
1365
-            'map_meta_cap' => true,
1366
-            'menu_icon' => $menu_icon,
1367
-            'public' => true,
1368
-            'query_var' => true,
1369
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1370
-            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1371
-            'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1372
-
1373
-        //Update custom post types
1374
-        $geodir_post_types = get_option('geodir_post_types');
1375
-        $geodir_post_types['gd_place'] = $place_default;
1376
-        update_option('geodir_post_types', $geodir_post_types);
1377
-
1378
-        // Update post types and delete tmp options
1379
-        flush_rewrite_rules();
1380
-    }
1381
-
1382
-
1383
-    geodir_register_taxonomies();
1384
-    geodir_register_post_types();
1385
-
1386
-    //die;
1256
+	global $wpdb;
1257
+
1258
+	$menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259
+
1260
+	if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
+		$listing_slug = 'places';
1262
+
1263
+	/**
1264
+	 * Taxonomies
1265
+	 **/
1266
+	//if ( ! taxonomy_exists('gd_place_tags') )
1267
+	{
1268
+
1269
+		$gd_placetags = array();
1270
+		$gd_placetags['object_type'] = 'gd_place';
1271
+		$gd_placetags['listing_slug'] = $listing_slug . '/tags';
1272
+		$gd_placetags['args'] = array(
1273
+			'public' => true,
1274
+			'hierarchical' => false,
1275
+			'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1276
+			'query_var' => true,
1277
+
1278
+			'labels' => array(
1279
+				'name' => __('Place Tags', 'geodirectory'),
1280
+				'singular_name' => __('Place Tag', 'geodirectory'),
1281
+				'search_items' => __('Search Place Tags', 'geodirectory'),
1282
+				'popular_items' => __('Popular Place Tags', 'geodirectory'),
1283
+				'all_items' => __('All Place Tags', 'geodirectory'),
1284
+				'edit_item' => __('Edit Place Tag', 'geodirectory'),
1285
+				'update_item' => __('Update Place Tag', 'geodirectory'),
1286
+				'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1287
+				'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1288
+				'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1289
+				'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1290
+				'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1291
+			),
1292
+		);
1293
+
1294
+
1295
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1296
+		$geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1297
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1298
+
1299
+
1300
+		// Update post types and delete tmp options
1301
+		flush_rewrite_rules();
1302
+
1303
+	}
1304
+
1305
+	//if ( ! taxonomy_exists('gd_placecategory') )
1306
+	{
1307
+
1308
+		$gd_placecategory = array();
1309
+		$gd_placecategory['object_type'] = 'gd_place';
1310
+		$gd_placecategory['listing_slug'] = $listing_slug;
1311
+		$gd_placecategory['args'] = array(
1312
+			'public' => true,
1313
+			'hierarchical' => true,
1314
+			'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1315
+			'query_var' => true,
1316
+			'labels' => array(
1317
+				'name' => __('Place Categories', 'geodirectory'),
1318
+				'singular_name' => __('Place Category', 'geodirectory'),
1319
+				'search_items' => __('Search Place Categories', 'geodirectory'),
1320
+				'popular_items' => __('Popular Place Categories', 'geodirectory'),
1321
+				'all_items' => __('All Place Categories', 'geodirectory'),
1322
+				'edit_item' => __('Edit Place Category', 'geodirectory'),
1323
+				'update_item' => __('Update Place Category', 'geodirectory'),
1324
+				'add_new_item' => __('Add New Place Category', 'geodirectory'),
1325
+				'new_item_name' => __('New Place Category', 'geodirectory'),
1326
+				'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1327
+			),
1328
+		);
1329
+
1330
+
1331
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1332
+		$geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1333
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1334
+
1335
+
1336
+		flush_rewrite_rules();
1337
+	}
1338
+
1339
+	/**
1340
+	 * Post Types
1341
+	 **/
1342
+
1343
+	//if ( ! post_type_exists('gd_place') )
1344
+	{
1345
+
1346
+		$labels = array(
1347
+			'name' => __('Places', 'geodirectory'),
1348
+			'singular_name' => __('Place', 'geodirectory'),
1349
+			'add_new' => __('Add New', 'geodirectory'),
1350
+			'add_new_item' => __('Add New Place', 'geodirectory'),
1351
+			'edit_item' => __('Edit Place', 'geodirectory'),
1352
+			'new_item' => __('New Place', 'geodirectory'),
1353
+			'view_item' => __('View Place', 'geodirectory'),
1354
+			'search_items' => __('Search Places', 'geodirectory'),
1355
+			'not_found' => __('No Place Found', 'geodirectory'),
1356
+			'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1357
+
1358
+		$place_default = array(
1359
+			'labels' => $labels,
1360
+			'can_export' => true,
1361
+			'capability_type' => 'post',
1362
+			'description' => 'Place post type.',
1363
+			'has_archive' => $listing_slug,
1364
+			'hierarchical' => false,
1365
+			'map_meta_cap' => true,
1366
+			'menu_icon' => $menu_icon,
1367
+			'public' => true,
1368
+			'query_var' => true,
1369
+			'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1370
+			'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1371
+			'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1372
+
1373
+		//Update custom post types
1374
+		$geodir_post_types = get_option('geodir_post_types');
1375
+		$geodir_post_types['gd_place'] = $place_default;
1376
+		update_option('geodir_post_types', $geodir_post_types);
1377
+
1378
+		// Update post types and delete tmp options
1379
+		flush_rewrite_rules();
1380
+	}
1381
+
1382
+
1383
+	geodir_register_taxonomies();
1384
+	geodir_register_post_types();
1385
+
1386
+	//die;
1387 1387
 
1388 1388
 }
1389 1389
 
1390 1390
 $gd_wpml_get_languages = "";
1391 1391
 function gd_wpml_get_lang_from_url($url) {
1392
-    global $sitepress, $gd_wpml_get_languages;
1392
+	global $sitepress, $gd_wpml_get_languages;
1393 1393
     
1394
-    if (geodir_is_wpml()) {
1395
-        return $sitepress->get_language_from_url($url);
1396
-    }
1394
+	if (geodir_is_wpml()) {
1395
+		return $sitepress->get_language_from_url($url);
1396
+	}
1397 1397
     
1398
-    if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1399
-        return $_REQUEST['lang'];
1400
-    }
1398
+	if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1399
+		return $_REQUEST['lang'];
1400
+	}
1401 1401
 
1402
-    $url = str_replace(array("http://","https://"),"",$url);
1402
+	$url = str_replace(array("http://","https://"),"",$url);
1403 1403
 
1404
-    // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1405
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1404
+	// site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1405
+	$site_url = str_replace(array("http://","https://"),"",site_url());
1406 1406
 
1407
-    $url = str_replace($site_url,"",$url);
1407
+	$url = str_replace($site_url,"",$url);
1408 1408
 
1409
-    $segments = explode('/', trim($url, '/'));
1409
+	$segments = explode('/', trim($url, '/'));
1410 1410
 
1411
-    if ($gd_wpml_get_languages) {
1412
-        $langs = $gd_wpml_get_languages;
1413
-    } else {
1414
-        $gd_wpml_get_languages = $sitepress->get_active_languages();
1415
-    }
1411
+	if ($gd_wpml_get_languages) {
1412
+		$langs = $gd_wpml_get_languages;
1413
+	} else {
1414
+		$gd_wpml_get_languages = $sitepress->get_active_languages();
1415
+	}
1416 1416
 
1417
-    if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1418
-        return $segments[0];
1419
-    }
1417
+	if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1418
+		return $segments[0];
1419
+	}
1420 1420
 
1421
-    return false;
1421
+	return false;
1422 1422
 }
1423 1423
 
1424 1424
 function gd_wpml_slug_translation_turned_on($post_type) {
1425 1425
 
1426
-    global $sitepress;
1427
-    $settings = $sitepress->get_settings();
1428
-    return isset($settings['posts_slug_translation']['types'][$post_type])
1429
-    && $settings['posts_slug_translation']['types'][$post_type]
1430
-    && isset($settings['posts_slug_translation']['on'])
1431
-    && $settings['posts_slug_translation']['on'];
1426
+	global $sitepress;
1427
+	$settings = $sitepress->get_settings();
1428
+	return isset($settings['posts_slug_translation']['types'][$post_type])
1429
+	&& $settings['posts_slug_translation']['types'][$post_type]
1430
+	&& isset($settings['posts_slug_translation']['on'])
1431
+	&& $settings['posts_slug_translation']['on'];
1432 1432
 }
1433 1433
 
1434 1434
 
@@ -1455,158 +1455,158 @@  discard block
 block discarded – undo
1455 1455
  */
1456 1456
 function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample)
1457 1457
 {
1458
-    //echo $post_link."<br />".$sample ;
1458
+	//echo $post_link."<br />".$sample ;
1459 1459
 
1460 1460
 
1461
-    global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1462
-    if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1463
-    } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1464
-        return $post_link;
1465
-    } else {
1466
-        $orig_post = $post;
1467
-        $post = $post_obj;
1468
-    }
1461
+	global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1462
+	if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1463
+	} elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1464
+		return $post_link;
1465
+	} else {
1466
+		$orig_post = $post;
1467
+		$post = $post_obj;
1468
+	}
1469 1469
 
1470
-    if (in_array($post->post_type, geodir_get_posttypes())) {
1470
+	if (in_array($post->post_type, geodir_get_posttypes())) {
1471 1471
 
1472
-        // if we dont have a GD post then try to grab it
1473
-        if(!isset($post->default_category)){
1474
-            $gd_post = geodir_get_post_info($post->ID);
1475
-            if(!empty($gd_post)){
1476
-                $post = $gd_post;
1477
-            }
1478
-        }
1472
+		// if we dont have a GD post then try to grab it
1473
+		if(!isset($post->default_category)){
1474
+			$gd_post = geodir_get_post_info($post->ID);
1475
+			if(!empty($gd_post)){
1476
+				$post = $gd_post;
1477
+			}
1478
+		}
1479 1479
 
1480 1480
 
1481
-        $post_types = get_option('geodir_post_types');
1482
-        $slug = $post_types[$post->post_type]['rewrite']['slug'];
1481
+		$post_types = get_option('geodir_post_types');
1482
+		$slug = $post_types[$post->post_type]['rewrite']['slug'];
1483 1483
 
1484
-        // Alter the CPT slug if WPML is set to do so
1485
-        if(function_exists('icl_object_id')){
1486
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1484
+		// Alter the CPT slug if WPML is set to do so
1485
+		if(function_exists('icl_object_id')){
1486
+			if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1487 1487
 
1488
-                $org_slug = $slug;
1489
-                $slug = apply_filters( 'wpml_translate_single_string',
1490
-                    $slug,
1491
-                    'WordPress',
1492
-                    'URL slug: ' . $slug,
1493
-                    $language_code);
1488
+				$org_slug = $slug;
1489
+				$slug = apply_filters( 'wpml_translate_single_string',
1490
+					$slug,
1491
+					'WordPress',
1492
+					'URL slug: ' . $slug,
1493
+					$language_code);
1494 1494
 
1495
-                if(!$slug){$slug = $org_slug;}
1495
+				if(!$slug){$slug = $org_slug;}
1496 1496
 
1497
-            }
1498
-        }
1497
+			}
1498
+		}
1499 1499
 
1500
-        if (function_exists('geodir_location_geo_home_link')) {
1501
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1502
-        }
1500
+		if (function_exists('geodir_location_geo_home_link')) {
1501
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1502
+		}
1503 1503
         
1504
-        // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1505
-        $site_url = trailingslashit(get_bloginfo('url'));
1504
+		// Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1505
+		$site_url = trailingslashit(get_bloginfo('url'));
1506 1506
         
1507
-        if (function_exists('geodir_location_geo_home_link')) {
1508
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1509
-        }
1510
-
1511
-        $fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1512
-        if ($fix_url) {
1513
-            $post_link = str_replace($site_url, '', $post_link);
1514
-        }
1515
-
1516
-        $post_link = trailingslashit(
1517
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1518
-        );
1519
-
1520
-        if ($fix_url) {
1521
-            $post_link = $site_url . $post_link;
1522
-        }
1523
-
1524
-        if (isset($comment_post_cache[$post->ID])) {
1525
-            $post = $comment_post_cache[$post->ID];
1526
-        }
1527
-        if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1528
-            $post_id = $post->ID;
1529
-            if (isset($orig_post)) {
1530
-                $post = $orig_post;
1531
-            }
1532
-            return $gd_permalink_cache[$post_id];
1533
-        }
1507
+		if (function_exists('geodir_location_geo_home_link')) {
1508
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1509
+		}
1534 1510
 
1535
-        if (!isset($post->post_locations)) {
1536
-            $post_type = $post->post_type;
1537
-            $ID = $post->ID;
1538
-            $post2 = $wpdb->get_row(
1539
-                $wpdb->prepare(
1540
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1541
-                    array($post->ID)
1542
-                )
1543
-            );
1511
+		$fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1512
+		if ($fix_url) {
1513
+			$post_link = str_replace($site_url, '', $post_link);
1514
+		}
1544 1515
 
1545
-            $post = (object)array_merge((array)$post, (array)$post2);
1516
+		$post_link = trailingslashit(
1517
+			preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1518
+		);
1546 1519
 
1547
-            $comment_post_cache[$post->ID] = $post;
1548
-        }
1520
+		if ($fix_url) {
1521
+			$post_link = $site_url . $post_link;
1522
+		}
1549 1523
 
1524
+		if (isset($comment_post_cache[$post->ID])) {
1525
+			$post = $comment_post_cache[$post->ID];
1526
+		}
1527
+		if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1528
+			$post_id = $post->ID;
1529
+			if (isset($orig_post)) {
1530
+				$post = $orig_post;
1531
+			}
1532
+			return $gd_permalink_cache[$post_id];
1533
+		}
1550 1534
 
1535
+		if (!isset($post->post_locations)) {
1536
+			$post_type = $post->post_type;
1537
+			$ID = $post->ID;
1538
+			$post2 = $wpdb->get_row(
1539
+				$wpdb->prepare(
1540
+					"SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1541
+					array($post->ID)
1542
+				)
1543
+			);
1551 1544
 
1552
-        if (false !== strpos($post_link, '%gd_taxonomy%')) {
1545
+			$post = (object)array_merge((array)$post, (array)$post2);
1553 1546
 
1554
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1555
-                $location_request = '';
1547
+			$comment_post_cache[$post->ID] = $post;
1548
+		}
1556 1549
 
1557 1550
 
1558
-                if (!empty($post->post_locations)) {
1559
-                    $geodir_arr_locations = explode(',', $post->post_locations);
1560
-                    if (count($geodir_arr_locations) == 3) {
1561
-                        $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1562
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1563
-                        $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1564
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1565
-                        $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1567 1551
 
1568
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1569
-                            'region_slug' => $post->region_slug,
1570
-                            'city_slug' => $post->city_slug
1571
-                        );
1552
+		if (false !== strpos($post_link, '%gd_taxonomy%')) {
1572 1553
 
1573
-                    } else
1574
-                        $post_location = geodir_get_location();
1554
+			if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1555
+				$location_request = '';
1575 1556
 
1576 1557
 
1577
-                } else {
1558
+				if (!empty($post->post_locations)) {
1559
+					$geodir_arr_locations = explode(',', $post->post_locations);
1560
+					if (count($geodir_arr_locations) == 3) {
1561
+						$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1562
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1563
+						$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1564
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1565
+						$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1578 1567
 
1579
-                    $post_location_sql = $wpdb->get_results(
1580
-                        $wpdb->prepare(
1581
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1582
-                            array($post->ID)
1583
-                        )
1584
-                    );
1585
-
1586
-                    if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1587
-
1588
-                        $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1589
-                        if (count($geodir_arr_locations) == 3) {
1590
-                            $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1591
-                            $post->city_slug = str_replace(']', '', $post->city_slug);
1592
-                            $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1593
-                            $post->region_slug = str_replace(']', '', $post->region_slug);
1594
-                            $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595
-                            $post->country_slug = str_replace(']', '', $post->country_slug);
1596
-
1597
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1598
-                                'region_slug' => $post->region_slug,
1599
-                                'city_slug' => $post->city_slug
1600
-                            );
1568
+						$post_location = (object)array('country_slug' => $post->country_slug,
1569
+							'region_slug' => $post->region_slug,
1570
+							'city_slug' => $post->city_slug
1571
+						);
1572
+
1573
+					} else
1574
+						$post_location = geodir_get_location();
1601 1575
 
1602
-                        }
1603
-                    } else
1604
-                        $post_location = geodir_get_location();
1605
-                }
1606 1576
 
1577
+				} else {
1607 1578
 
1608
-                if (!empty($post_location)) {
1609
-                    $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1579
+					$post_location_sql = $wpdb->get_results(
1580
+						$wpdb->prepare(
1581
+							"SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1582
+							array($post->ID)
1583
+						)
1584
+					);
1585
+
1586
+					if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1587
+
1588
+						$geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1589
+						if (count($geodir_arr_locations) == 3) {
1590
+							$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1591
+							$post->city_slug = str_replace(']', '', $post->city_slug);
1592
+							$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1593
+							$post->region_slug = str_replace(']', '', $post->region_slug);
1594
+							$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595
+							$post->country_slug = str_replace(']', '', $post->country_slug);
1596
+
1597
+							$post_location = (object)array('country_slug' => $post->country_slug,
1598
+								'region_slug' => $post->region_slug,
1599
+								'city_slug' => $post->city_slug
1600
+							);
1601
+
1602
+						}
1603
+					} else
1604
+						$post_location = geodir_get_location();
1605
+				}
1606
+
1607
+
1608
+				if (!empty($post_location)) {
1609
+					$country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1610 1610
 					$region_slug = isset($post_location->region_slug) ? $post_location->region_slug : '';
1611 1611
 					$city_slug = isset($post_location->city_slug) ? $post_location->city_slug : '';
1612 1612
 					
@@ -1624,89 +1624,89 @@  discard block
 block discarded – undo
1624 1624
 					$location_slug[] = $city_slug;
1625 1625
 					
1626 1626
 					$location_request .= implode('/', $location_slug) . '/';
1627
-                }
1628
-            }
1627
+				}
1628
+			}
1629 1629
 
1630
-            if (get_option('geodir_add_categories_url')) {
1630
+			if (get_option('geodir_add_categories_url')) {
1631 1631
 
1632
-                $term_request = '';
1633
-                $taxonomies = geodir_get_taxonomies($post->post_type);
1632
+				$term_request = '';
1633
+				$taxonomies = geodir_get_taxonomies($post->post_type);
1634 1634
 
1635
-                $taxonomies = end($taxonomies);
1635
+				$taxonomies = end($taxonomies);
1636 1636
 
1637
-                if (!empty($post->default_category)) {
1638
-                    $post_terms = $post->default_category;
1639
-                } else {
1640
-                    $post_terms = '';
1641
-
1642
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643
-                        $post_terms = absint($_POST['post_default_category']);
1644
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1645
-                        $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646
-                        $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1647
-                    }elseif (isset($post->{$taxonomies})) {
1648
-                        $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649
-                        $post_terms = $post_terms[0];
1650
-                    }
1637
+				if (!empty($post->default_category)) {
1638
+					$post_terms = $post->default_category;
1639
+				} else {
1640
+					$post_terms = '';
1641
+
1642
+					if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643
+						$post_terms = absint($_POST['post_default_category']);
1644
+					}elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1645
+						$post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646
+						$post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1647
+					}elseif (isset($post->{$taxonomies})) {
1648
+						$post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649
+						$post_terms = $post_terms[0];
1650
+					}
1651 1651
 
1652
-                    if (!$post_terms)
1653
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1652
+					if (!$post_terms)
1653
+						$post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1654 1654
 
1655
-                    if (!$post_terms) {
1656
-                        $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1655
+					if (!$post_terms) {
1656
+						$post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1657 1657
 
1658
-                        if ($post_terms) {
1659
-                            $post_terms = explode(",", trim($post_terms, ","));
1660
-                            $post_terms = $post_terms[0];
1661
-                        }
1662
-                    }
1663
-                }
1658
+						if ($post_terms) {
1659
+							$post_terms = explode(",", trim($post_terms, ","));
1660
+							$post_terms = $post_terms[0];
1661
+						}
1662
+					}
1663
+				}
1664 1664
 
1665
-                $term = get_term_by('id', $post_terms, $taxonomies);
1665
+				$term = get_term_by('id', $post_terms, $taxonomies);
1666 1666
 
1667
-                if (!empty($term))
1668
-                    $term_request = $term->slug;
1669
-                //$term_request = $term->slug.'/';
1670
-            }
1667
+				if (!empty($term))
1668
+					$term_request = $term->slug;
1669
+				//$term_request = $term->slug.'/';
1670
+			}
1671 1671
 
1672
-            $request_term = '';
1673
-            $listingurl_separator = '';
1674
-            //$detailurl_separator = get_option('geodir_detailurl_separator');
1675
-            $detailurl_separator = '';
1676
-            if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1677
-                $request_term = $location_request;
1678
-                //$listingurl_separator = get_option('geodir_listingurl_separator');
1679
-                //$request_term .= $listingurl_separator.'/'.$term_request;
1680
-                $request_term .= $term_request;
1672
+			$request_term = '';
1673
+			$listingurl_separator = '';
1674
+			//$detailurl_separator = get_option('geodir_detailurl_separator');
1675
+			$detailurl_separator = '';
1676
+			if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1677
+				$request_term = $location_request;
1678
+				//$listingurl_separator = get_option('geodir_listingurl_separator');
1679
+				//$request_term .= $listingurl_separator.'/'.$term_request;
1680
+				$request_term .= $term_request;
1681 1681
 
1682
-            } else {
1683
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1682
+			} else {
1683
+				if (isset($location_request) && $location_request != '') $request_term = $location_request;
1684 1684
 
1685
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1686
-            }
1687
-            $request_term = trim($request_term, '/');
1685
+				if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1686
+			}
1687
+			$request_term = trim($request_term, '/');
1688 1688
             
1689
-            // Fix with WPML the location terms added twice when CPT slug is translated.
1690
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1691
-                $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692
-            }
1689
+			// Fix with WPML the location terms added twice when CPT slug is translated.
1690
+			if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1691
+				$post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692
+			}
1693 1693
             
1694
-            if (!empty($request_term))
1695
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
-            else
1697
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1698
-            //echo $post_link ;
1699
-        }
1700
-        // temp cache the permalink
1701
-        if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1702
-            $gd_permalink_cache[$post->ID] = $post_link;
1703
-        }
1704
-    }
1705
-    if (isset($orig_post)) {
1706
-        $post = $orig_post;
1707
-    }
1708
-
1709
-    return $post_link;
1694
+			if (!empty($request_term))
1695
+				$post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
+			else
1697
+				$post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1698
+			//echo $post_link ;
1699
+		}
1700
+		// temp cache the permalink
1701
+		if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1702
+			$gd_permalink_cache[$post->ID] = $post_link;
1703
+		}
1704
+	}
1705
+	if (isset($orig_post)) {
1706
+		$post = $orig_post;
1707
+	}
1708
+
1709
+	return $post_link;
1710 1710
 }
1711 1711
 
1712 1712
 /**
@@ -1722,99 +1722,99 @@  discard block
 block discarded – undo
1722 1722
  * @return string The term link.
1723 1723
  */
1724 1724
 function geodir_term_link($termlink, $term, $taxonomy) {
1725
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1725
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1726 1726
 
1727
-    if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1728
-        global $geodir_add_location_url, $gd_session;
1729
-        $include_location = false;
1730
-        $request_term = array();
1731
-        $add_location_url = get_option('geodir_add_location_url');
1732
-        $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1727
+	if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1728
+		global $geodir_add_location_url, $gd_session;
1729
+		$include_location = false;
1730
+		$request_term = array();
1731
+		$add_location_url = get_option('geodir_add_location_url');
1732
+		$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1733 1733
 
1734
-        $listing_slug = geodir_get_listing_slug($taxonomy);
1734
+		$listing_slug = geodir_get_listing_slug($taxonomy);
1735 1735
 
1736
-        if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1737
-            if ($geodir_add_location_url && $add_location_url) {
1738
-                $include_location = true;
1739
-            }
1740
-        } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1741
-            $include_location = true;
1742
-        } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1743
-            $include_location = true;
1744
-        }
1745
-
1746
-        if ($include_location) {
1747
-            global $post;
1736
+		if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1737
+			if ($geodir_add_location_url && $add_location_url) {
1738
+				$include_location = true;
1739
+			}
1740
+		} elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1741
+			$include_location = true;
1742
+		} elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1743
+			$include_location = true;
1744
+		}
1745
+
1746
+		if ($include_location) {
1747
+			global $post;
1748 1748
             
1749
-            $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1749
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1750 1750
             
1751
-            if (geodir_is_page('detail') && isset($post->country_slug)) {
1752
-                $location_terms = array(
1753
-                    'gd_country' => $post->country_slug,
1754
-                    'gd_region' => $post->region_slug,
1755
-                    'gd_city' => $post->city_slug
1756
-                );
1751
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
1752
+				$location_terms = array(
1753
+					'gd_country' => $post->country_slug,
1754
+					'gd_region' => $post->region_slug,
1755
+					'gd_city' => $post->city_slug
1756
+				);
1757 1757
                 
1758
-                if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1759
-                    $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1760
-                }
1761
-            } else {
1762
-                $location_terms = geodir_get_current_location_terms('query_vars');
1763
-            }
1758
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1759
+					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1760
+				}
1761
+			} else {
1762
+				$location_terms = geodir_get_current_location_terms('query_vars');
1763
+			}
1764 1764
 
1765
-            $geodir_show_location_url = get_option('geodir_show_location_url');
1766
-            $location_terms = geodir_remove_location_terms($location_terms);
1765
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1766
+			$location_terms = geodir_remove_location_terms($location_terms);
1767 1767
 
1768
-            if (!empty($location_terms)) {
1769
-                $url_separator = '';
1768
+			if (!empty($location_terms)) {
1769
+				$url_separator = '';
1770 1770
 
1771
-                if (get_option('permalink_structure') != '') {
1772
-                    $old_listing_slug = '/' . $listing_slug . '/';
1773
-                    $request_term = implode("/", $location_terms);
1774
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1771
+				if (get_option('permalink_structure') != '') {
1772
+					$old_listing_slug = '/' . $listing_slug . '/';
1773
+					$request_term = implode("/", $location_terms);
1774
+					$new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1775 1775
 
1776
-                    $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1777
-                } else {
1778
-                    $termlink = geodir_getlink($termlink, $request_term);
1779
-                }
1780
-            }
1781
-        }
1776
+					$termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1777
+				} else {
1778
+					$termlink = geodir_getlink($termlink, $request_term);
1779
+				}
1780
+			}
1781
+		}
1782 1782
 
1783
-        // Alter the CPT slug is WPML is set to do so
1784
-        /* we can replace this with the below function
1783
+		// Alter the CPT slug is WPML is set to do so
1784
+		/* we can replace this with the below function
1785 1785
         if(function_exists('icl_object_id')){
1786 1786
             global $sitepress;
1787 1787
             $post_type = str_replace("category","",$taxonomy);
1788 1788
             $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type);
1789 1789
         }*/
1790 1790
 
1791
-        // Alter the CPT slug if WPML is set to do so
1792
-        if (function_exists('icl_object_id')) {
1793
-            $post_types = get_option('geodir_post_types');
1794
-            $post_type = str_replace("category","",$taxonomy);
1795
-            $post_type = str_replace("_tags","",$post_type);
1796
-            $slug = $post_types[$post_type]['rewrite']['slug'];
1797
-            if (gd_wpml_slug_translation_turned_on($post_type)) {
1798
-                global $sitepress;
1799
-                $default_lang = $sitepress->get_default_language();
1800
-                $language_code = gd_wpml_get_lang_from_url($termlink);
1801
-                if (!$language_code ) {
1802
-                    $language_code  = $default_lang;
1803
-                }
1791
+		// Alter the CPT slug if WPML is set to do so
1792
+		if (function_exists('icl_object_id')) {
1793
+			$post_types = get_option('geodir_post_types');
1794
+			$post_type = str_replace("category","",$taxonomy);
1795
+			$post_type = str_replace("_tags","",$post_type);
1796
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1797
+			if (gd_wpml_slug_translation_turned_on($post_type)) {
1798
+				global $sitepress;
1799
+				$default_lang = $sitepress->get_default_language();
1800
+				$language_code = gd_wpml_get_lang_from_url($termlink);
1801
+				if (!$language_code ) {
1802
+					$language_code  = $default_lang;
1803
+				}
1804 1804
 
1805
-                $org_slug = $slug;
1806
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1805
+				$org_slug = $slug;
1806
+				$slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1807 1807
 
1808
-                if (!$slug) {
1809
-                    $slug = $org_slug;
1810
-                }
1808
+				if (!$slug) {
1809
+					$slug = $org_slug;
1810
+				}
1811 1811
 
1812
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1813
-            }
1814
-        }
1815
-    }
1812
+				$termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1813
+			}
1814
+		}
1815
+	}
1816 1816
     
1817
-    return $termlink;
1817
+	return $termlink;
1818 1818
 }
1819 1819
 
1820 1820
 /**
@@ -1840,14 +1840,14 @@  discard block
 block discarded – undo
1840 1840
 	if (in_array($post_type, geodir_get_posttypes())) {
1841 1841
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1842 1842
 			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1843
-                $location_terms = array(
1844
-                    'gd_country' => $post->country_slug,
1845
-                    'gd_region' => $post->region_slug,
1846
-                    'gd_city' => $post->city_slug
1847
-                );
1848
-            } else {
1849
-                $location_terms = geodir_get_current_location_terms('query_vars');
1850
-            }
1843
+				$location_terms = array(
1844
+					'gd_country' => $post->country_slug,
1845
+					'gd_region' => $post->region_slug,
1846
+					'gd_city' => $post->city_slug
1847
+				);
1848
+			} else {
1849
+				$location_terms = geodir_get_current_location_terms('query_vars');
1850
+			}
1851 1851
 			
1852 1852
 			$location_terms = geodir_remove_location_terms($location_terms);
1853 1853
 			
@@ -1879,17 +1879,17 @@  discard block
 block discarded – undo
1879 1879
  * @return void|string Label.
1880 1880
  */
1881 1881
 function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
1882
-    $obj_post_type = get_post_type_object($post_type);
1883
-    if (!is_object($obj_post_type)) {
1884
-        return;
1885
-    }
1882
+	$obj_post_type = get_post_type_object($post_type);
1883
+	if (!is_object($obj_post_type)) {
1884
+		return;
1885
+	}
1886 1886
     
1887
-    $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1887
+	$label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1888 1888
     
1889
-    if ($echo)
1890
-        echo $label;
1891
-    else
1892
-        return $label;
1889
+	if ($echo)
1890
+		echo $label;
1891
+	else
1892
+		return $label;
1893 1893
 }
1894 1894
 
1895 1895
 /**
@@ -1904,19 +1904,19 @@  discard block
 block discarded – undo
1904 1904
  * @return void|string Label.
1905 1905
  */
1906 1906
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1907
-    $all_postypes = geodir_get_posttypes();
1907
+	$all_postypes = geodir_get_posttypes();
1908 1908
 
1909
-    if (!in_array($post_type, $all_postypes))
1910
-        return false;
1909
+	if (!in_array($post_type, $all_postypes))
1910
+		return false;
1911 1911
 
1912
-    $obj_post_type = get_post_type_object($post_type);
1912
+	$obj_post_type = get_post_type_object($post_type);
1913 1913
     
1914
-    $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1914
+	$label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1915 1915
     
1916
-    if ($echo)
1917
-        echo $label;
1918
-    else
1919
-        return $label;
1916
+	if ($echo)
1917
+		echo $label;
1918
+	else
1919
+		return $label;
1920 1920
 }
1921 1921
 
1922 1922
 /**
@@ -1934,51 +1934,51 @@  discard block
 block discarded – undo
1934 1934
  */
1935 1935
 function geodir_term_exists($term, $taxonomy = '', $parent = 0)
1936 1936
 {
1937
-    global $wpdb;
1938
-
1939
-    $select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1940
-    $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941
-
1942
-    if (is_int($term)) {
1943
-        if (0 == $term)
1944
-            return 0;
1945
-        $where = 't.term_id = %d';
1946
-        if (!empty($taxonomy))
1947
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
-        else
1949
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1950
-    }
1937
+	global $wpdb;
1938
+
1939
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1940
+	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941
+
1942
+	if (is_int($term)) {
1943
+		if (0 == $term)
1944
+			return 0;
1945
+		$where = 't.term_id = %d';
1946
+		if (!empty($taxonomy))
1947
+			return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
+		else
1949
+			return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1950
+	}
1951 1951
 
1952
-    $term = trim(wp_unslash($term));
1952
+	$term = trim(wp_unslash($term));
1953 1953
 
1954
-    if ('' === $slug = sanitize_title($term))
1955
-        return 0;
1954
+	if ('' === $slug = sanitize_title($term))
1955
+		return 0;
1956 1956
 
1957
-    $where = 't.slug = %s';
1957
+	$where = 't.slug = %s';
1958 1958
 
1959
-    $where_fields = array($slug);
1960
-    if (!empty($taxonomy)) {
1961
-        $parent = (int)$parent;
1962
-        if ($parent > 0) {
1963
-            $where_fields[] = $parent;
1964
-            $else_where_fields[] = $parent;
1965
-            $where .= ' AND tt.parent = %d';
1959
+	$where_fields = array($slug);
1960
+	if (!empty($taxonomy)) {
1961
+		$parent = (int)$parent;
1962
+		if ($parent > 0) {
1963
+			$where_fields[] = $parent;
1964
+			$else_where_fields[] = $parent;
1965
+			$where .= ' AND tt.parent = %d';
1966 1966
 
1967
-        }
1967
+		}
1968 1968
 
1969
-        $where_fields[] = $taxonomy;
1969
+		$where_fields[] = $taxonomy;
1970 1970
 
1971 1971
 
1972
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
-            return $result;
1972
+		if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
+			return $result;
1974 1974
 
1975
-        return false;
1976
-    }
1975
+		return false;
1976
+	}
1977 1977
 
1978
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
-        return $result;
1978
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
+		return $result;
1980 1980
 
1981
-    return false;
1981
+	return false;
1982 1982
 }
1983 1983
 
1984 1984
 /**
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
 function geodir_get_term_icon_rebuild()
1991 1991
 {
1992 1992
 
1993
-    update_option('gd_term_icons', '');
1993
+	update_option('gd_term_icons', '');
1994 1994
 
1995 1995
 }
1996 1996
 
@@ -2008,61 +2008,61 @@  discard block
 block discarded – undo
2008 2008
  */
2009 2009
 function geodir_get_term_icon($term_id = false, $rebuild = false)
2010 2010
 {
2011
-    global $wpdb;
2012
-    if (!$rebuild) {
2013
-        $terms_icons = get_option('gd_term_icons');
2014
-    } else {
2015
-        $terms_icons = array();
2016
-    }
2017
-
2018
-    if (empty($terms_icons)) {
2019
-        $terms_icons = array();
2020
-        $default_icon_url = get_option('geodir_default_marker_icon');
2021
-        $taxonomy = geodir_get_taxonomies();
2022
-        $post_types = geodir_get_posttypes();
2023
-        $tax_arr = array();
2024
-        foreach ($post_types as $post_type) {
2025
-            $tax_arr[] = "'" . $post_type . "category'";
2026
-        }
2027
-        $tax_c = implode(',', $tax_arr);
2028
-        $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2029
-        //$terms = get_terms( $taxonomy );
2030
-
2031
-        if($terms) {
2032
-            foreach ($terms as $term) {
2033
-                $post_type = str_replace("category", "", $term->taxonomy);
2034
-                $a_terms[$post_type][] = $term;
2011
+	global $wpdb;
2012
+	if (!$rebuild) {
2013
+		$terms_icons = get_option('gd_term_icons');
2014
+	} else {
2015
+		$terms_icons = array();
2016
+	}
2035 2017
 
2036
-            }
2037
-        }
2018
+	if (empty($terms_icons)) {
2019
+		$terms_icons = array();
2020
+		$default_icon_url = get_option('geodir_default_marker_icon');
2021
+		$taxonomy = geodir_get_taxonomies();
2022
+		$post_types = geodir_get_posttypes();
2023
+		$tax_arr = array();
2024
+		foreach ($post_types as $post_type) {
2025
+			$tax_arr[] = "'" . $post_type . "category'";
2026
+		}
2027
+		$tax_c = implode(',', $tax_arr);
2028
+		$terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2029
+		//$terms = get_terms( $taxonomy );
2038 2030
 
2039
-        if($a_terms) {
2040
-            foreach ($a_terms as $pt => $t2) {
2031
+		if($terms) {
2032
+			foreach ($terms as $term) {
2033
+				$post_type = str_replace("category", "", $term->taxonomy);
2034
+				$a_terms[$post_type][] = $term;
2041 2035
 
2042
-                foreach ($t2 as $term) {
2043
-                    $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2044
-                    if ($term_icon) {
2045
-                        $term_icon_url = $term_icon["src"];
2046
-                    } else {
2047
-                        $term_icon_url = $default_icon_url;
2048
-                    }
2049
-                    $terms_icons[$term->term_id] = $term_icon_url;
2050
-                }
2051
-            }
2052
-        }
2036
+			}
2037
+		}
2053 2038
 
2054
-        update_option('gd_term_icons', $terms_icons);
2055
-    }
2039
+		if($a_terms) {
2040
+			foreach ($a_terms as $pt => $t2) {
2056 2041
 
2057
-    if ($term_id && isset($terms_icons[$term_id])) {
2058
-        return $terms_icons[$term_id];
2059
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2060
-        return get_option('geodir_default_marker_icon');
2061
-    }
2042
+				foreach ($t2 as $term) {
2043
+					$term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2044
+					if ($term_icon) {
2045
+						$term_icon_url = $term_icon["src"];
2046
+					} else {
2047
+						$term_icon_url = $default_icon_url;
2048
+					}
2049
+					$terms_icons[$term->term_id] = $term_icon_url;
2050
+				}
2051
+			}
2052
+		}
2053
+
2054
+		update_option('gd_term_icons', $terms_icons);
2055
+	}
2062 2056
 
2063
-    if (is_ssl()) {
2064
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2065
-    }
2057
+	if ($term_id && isset($terms_icons[$term_id])) {
2058
+		return $terms_icons[$term_id];
2059
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2060
+		return get_option('geodir_default_marker_icon');
2061
+	}
2062
+
2063
+	if (is_ssl()) {
2064
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2065
+	}
2066 2066
 
2067
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2067
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2068 2068
 }
2069 2069
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
                              * @since 1.0.0
61 61
                              * @param string $menu_class The menu HTML class.
62 62
                              */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
63
+                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
64 64
                             /**
65 65
                              * Filter the menu a class.
66 66
                              *
67 67
                              * @since 1.0.0
68 68
                              */
69 69
                             $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
71
-									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72
-										' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
70
+                            $items .= '<li class="'.$li_class.'">
71
+									<a href="' . get_post_type_archive_link($post_type).'" class="'.$a_class.'">
72
+										' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').'
73 73
 									</a>
74 74
 								</li>';
75 75
                         }
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
              * @since 1.0.0
89 89
              * @param string $menu_class The menu HTML class.
90 90
              */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
91
+            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings '.$menu_class);
92 92
             /**
93 93
              * Filter the sub menu li class.
94 94
              *
95 95
              * @since 1.0.0
96 96
              * @param string $menu_class The menu HTML class.
97 97
              */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
98
+            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
99 99
             /**
100 100
              * Filter the sub menu ul class.
101 101
              *
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
              * @since 1.0.0
115 115
              */
116 116
             $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
118
-					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119
-					<ul class="' . $sub_ul_class . '">';
117
+            $items .= '<li class="'.$li_class.'">
118
+					<a href="#" class="' . $a_class.'">'.__('Listing', 'geodirectory').'</a>
119
+					<ul class="' . $sub_ul_class.'">';
120 120
             $post_types = geodir_get_posttypes('object');
121 121
 
122 122
             $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
                                 if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134 134
                                     $menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
137
-														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138
-															' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
136
+                                $items .= '<li class="'.$sub_li_class.'">
137
+														<a href="' . get_post_type_archive_link($post_type).'" class="'.$sub_a_class.'">
138
+															' . __(geodir_utf8_ucfirst($args->labels->name), 'geodirectory').'
139 139
 														</a>
140 140
 													</li>';
141 141
                             }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
              *
152 152
              * @since 1.5.9
153 153
              */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
154
+            $items .= apply_filters('geodir_menu_after_sub_ul', '');
155 155
             $items .= '</li>';
156 156
         }
157 157
     }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                                      * @since 1.0.0
185 185
                                      * @param string $menu_class The menu HTML class.
186 186
                                      */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
187
+                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
188 188
                                     /**
189 189
                                      * Filter the menu a class.
190 190
                                      *
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
                                      */
193 193
                                     $a_class = apply_filters('geodir_menu_a_class', '');
194 194
                                     $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
196
-											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197
-												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
195
+                                    $items .= '<li class="'.$li_class.'">
196
+											<a href="' . geodir_get_addlisting_link($post_type).'" class="'.$a_class.'">
197
+												' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
198 198
 											</a>
199 199
 										</li>';
200 200
                                 }
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
              * @since 1.0.0
219 219
              * @param string $menu_class The menu HTML class.
220 220
              */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
221
+            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing '.$menu_class);
222 222
             /**
223 223
              * Filter the sub menu li class.
224 224
              *
225 225
              * @since 1.0.0
226 226
              * @param string $menu_class The menu HTML class.
227 227
              */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
228
+            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class);
229 229
             /**
230 230
              * Filter the sub menu ul class.
231 231
              *
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
              * @since 1.0.0
245 245
              */
246 246
             $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
248
-					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249
-					<ul class="' . $sub_ul_class . '">';
247
+            $items .= '<li  class="'.$li_class.'">
248
+					<a href="#" class="' . $a_class.'">'.__('Add Listing', 'geodirectory').'</a>
249
+					<ul class="' . $sub_ul_class.'">';
250 250
 
251 251
             $post_types = geodir_get_posttypes('object');
252 252
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
                                          * @since 1.0.0
270 270
                                          * @param string $menu_class The menu HTML class.
271 271
                                          */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
272
+                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class);
273 273
                                         $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $sub_li_class . '">
275
-														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276
-															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
274
+                                        $items .= '<li class="'.$sub_li_class.'">
275
+														<a href="' . geodir_get_addlisting_link($post_type).'" class="'.$sub_a_class.'">
276
+															' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).'
277 277
 														</a>
278 278
 													</li>';
279 279
                                     }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             }
286 286
 
287 287
             $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
288
+            $items .= apply_filters('geodir_menu_after_sub_ul', '');
289 289
             $items .= '</li>';
290 290
 
291 291
         }
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
     $geodir_theme_location = get_option('geodir_theme_location_nav');
314 314
     $geodir_theme_location_nav = array();
315 315
     if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
316
+        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
317 317
         $geodir_theme_location_nav[] = $args['theme_location'];
318 318
         update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319 319
     }
320 320
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322 322
     else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
323
+        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu);
324 324
 
325 325
     return $menu;
326 326
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
     if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
351
+        $items = $items.geodir_add_nav_menu_items();
352 352
         return $items;
353 353
 
354 354
     } else {
@@ -373,12 +373,12 @@  discard block
 block discarded – undo
373 373
 
374 374
     $taxonomies = geodir_get_taxonomies();
375 375
     $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
376
+    $taxonomies = "'".$taxonomies."'";
377 377
 
378 378
     $pn_categories = $wpdb->get_results(
379 379
         $wpdb->prepare(
380 380
             "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
381
+            array($wpdb->terms.term_id)
382 382
         )
383 383
     );
384 384
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410 410
         if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
411
+            $geodir_post_type = get_post_type((int) $_REQUEST['pid']);
412 412
         elseif (isset($_REQUEST['listing_type']))
413 413
             $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414 414
     }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435 435
         $geodir_post_type = '';
436 436
 
437
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
437
+    if (defined('DOING_AJAX') && isset($_REQUEST['stype'])) {
438 438
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439 439
     }
440 440
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
      *
445 445
      * @since 1.6.9
446 446
      */
447
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
447
+    return apply_filters('geodir_get_current_posttype', $geodir_post_type);
448 448
 }
449 449
 
450 450
 /**
@@ -458,18 +458,18 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_get_default_posttype()
460 460
 {
461
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
461
+    $post_types = apply_filters('geodir_get_default_posttype', geodir_get_posttypes('object'));
462 462
 
463 463
     $stype = false;
464
-    foreach ( $post_types as $post_type => $info ) {
464
+    foreach ($post_types as $post_type => $info) {
465 465
         global $wpdb;
466
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
-        if ( $has_posts ) {
466
+        $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
467
+        if ($has_posts) {
468 468
             $stype = $post_type; break;
469 469
         }
470 470
     }
471 471
 
472
-    if(!$stype){
472
+    if (!$stype) {
473 473
         $stype = 'gd_place';
474 474
     }
475 475
 
@@ -494,14 +494,14 @@  discard block
 block discarded – undo
494 494
         switch ($output):
495 495
             case 'object':
496 496
             case 'Object':
497
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
497
+                $post_types = json_decode(json_encode($post_types), FALSE); //(object)$post_types;
498 498
                 break;
499 499
             case 'array':
500 500
             case 'Array':
501
-                $post_types = (array)$post_types;
501
+                $post_types = (array) $post_types;
502 502
                 break;
503 503
 			case 'options':
504
-                $post_types = (array)$post_types;
504
+                $post_types = (array) $post_types;
505 505
 				
506 506
 				$options = array();
507 507
 				if (!empty($post_types)) {
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
 
620 620
         $categories = get_terms($taxonomies);
621 621
 
622
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
622
+        $html .= '<option value="0">'.__('All', 'geodirectory').'</option>';
623 623
 
624 624
         foreach ($categories as $category_obj) {
625 625
             $select_opt = '';
626 626
             if ($selected == $category_obj->term_id) {
627 627
                 $select_opt = 'selected="selected"';
628 628
             }
629
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
630
-                . geodir_utf8_ucfirst($category_obj->name) . '</option>';
629
+            $html .= '<option '.$select_opt.' value="'.$category_obj->term_id.'">'
630
+                . geodir_utf8_ucfirst($category_obj->name).'</option>';
631 631
         }
632 632
 
633 633
         if ($echo)
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
     } elseif (isset($wp_query->tax_query->queries)) {
696 696
         $tax_arr = $wp_query->tax_query->queries;
697 697
         //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
698
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
698
+        if (isset($tax_arr['relation'])) {unset($tax_arr['relation']); }
699 699
         $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
700 700
     }
701 701
 
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 
750 750
             if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
751 751
                 if ($cat_parent == 0) {
752
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
752
+                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-'.$cat_display;
753 753
                     $main_list_class = 'class="main_list_selecter"';
754 754
                 } else {
755 755
                     //$display = 'display:none';
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 
760 760
             if ($cat_display == 'checkbox' || $cat_display == 'radio') {
761 761
                 $p = 0;
762
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
762
+                $out = '<div class="'.$list_class.' gd-cat-row-'.$cat_parent.'" style="margin-left:'.$p.'px;'.$display.';">';
763 763
             }
764 764
 
765 765
             foreach ($cat_terms as $cat_term) {
@@ -774,12 +774,12 @@  discard block
 block discarded – undo
774 774
                 }
775 775
 
776 776
                 if ($cat_display == 'radio')
777
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
777
+                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>';
778 778
                 elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
779
+                    $out .= '<option '.$main_list_class.' style="margin-left:'.$p.'px;" alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</option>';
780 780
 
781 781
                 else {
782
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
782
+                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.geodir_utf8_ucfirst($cat_term->name).'</span>';
783 783
                 }
784 784
 
785 785
                 // Call recurson to print sub cats
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
             $cat_exclude = serialize($exclude_cats);
819 819
 
820 820
         if (isset($_REQUEST['backandedit'])) {
821
-            $post = (object)$gd_session->get('listing');
821
+            $post = (object) $gd_session->get('listing');
822 822
 
823 823
             if (!is_array($post->post_category[$cat_taxonomy]))
824 824
                 $post_category = $post->post_category[$cat_taxonomy];
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 
851 851
             if (!empty($post_category)) {
852 852
                 $cat1 = array_filter(explode(',', $post_category));
853
-                $post_category = ',' . implode(',', $cat1) . ',';
853
+                $post_category = ','.implode(',', $cat1).',';
854 854
 
855 855
             }
856 856
 
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
                 foreach ($post_category_upd as $cat) {
862 862
 
863 863
                     if (!in_array($cat, $exclude_cats) && $cat != '') {
864
-                        $post_category_change .= ',' . $cat;
864
+                        $post_category_change .= ','.$cat;
865 865
                     }
866 866
                 }
867 867
                 $post_category = $post_category_change;
@@ -873,11 +873,11 @@  discard block
 block discarded – undo
873 873
             }
874 874
         }
875 875
 
876
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
876
+        echo '<input type="hidden" id="cat_limit" value="'.$cat_limit.'" name="cat_limit['.$cat_taxonomy.']"  />';
877 877
 
878
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
878
+        echo '<input type="hidden" id="post_category" value="'.$post_category.'" name="post_category['.$cat_taxonomy.']"  />';
879 879
 
880
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
880
+        echo '<input type="hidden" id="post_category_str" value="'.$post_category_str.'" name="post_category_str['.$cat_taxonomy.']"  />';
881 881
 
882 882
 
883 883
         ?>
@@ -896,14 +896,14 @@  discard block
 block discarded – undo
896 896
 
897 897
             function show_subcatlist(main_cat, catObj) {
898 898
                 if (main_cat != '') {
899
-					var url = '<?php echo geodir_get_ajax_url();?>';
900
-                    var cat_taxonomy = '<?php echo $cat_taxonomy;?>';
901
-                    var cat_exclude = '<?php echo base64_encode($cat_exclude);?>';
899
+					var url = '<?php echo geodir_get_ajax_url(); ?>';
900
+                    var cat_taxonomy = '<?php echo $cat_taxonomy; ?>';
901
+                    var cat_exclude = '<?php echo base64_encode($cat_exclude); ?>';
902 902
                     var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val();
903
-					<?php if ((int)$cat_limit > 0) { ?>
903
+					<?php if ((int) $cat_limit > 0) { ?>
904 904
 					var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length);
905 905
 					if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) {
906
-						alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int)$cat_limit));?>");
906
+						alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int) $cat_limit)); ?>");
907 907
 						return false;
908 908
 					}
909 909
 					<?php } ?>
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
             }
943 943
 
944 944
             function update_listing_cat(el) {
945
-                var cat_taxonomy = '<?php echo $cat_taxonomy;?>';
945
+                var cat_taxonomy = '<?php echo $cat_taxonomy; ?>';
946 946
                 var cat_ids = '';
947 947
                 var main_cat = '';
948 948
                 var sub_cat = '';
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1024 1024
             echo $style;
1025 1025
         }?> ">
1026
-            <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1026
+            <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list
1027 1027
             ?>
1028 1028
         </div>
1029 1029
     <?php
@@ -1050,9 +1050,9 @@  discard block
 block discarded – undo
1050 1050
     if ($exclude != '') {
1051 1051
         $exclude_cats = maybe_unserialize(base64_decode($exclude));
1052 1052
 
1053
-        if(is_array( $exclude_cats)){
1054
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1055
-        }else{
1053
+        if (is_array($exclude_cats)) {
1054
+            $exclude_cats = array_map('intval', $exclude_cats);
1055
+        } else {
1056 1056
             $exclude_cats = intval($exclude_cats);
1057 1057
         }
1058 1058
 
@@ -1066,25 +1066,25 @@  discard block
 block discarded – undo
1066 1066
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1067 1067
 
1068 1068
         <div class="post_catlist_item" style="border:1px solid #CCCCCC; margin:5px auto; padding:5px;">
1069
-            <img alt="move icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/move.png';?>"
1069
+            <img alt="move icon" src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png'; ?>"
1070 1070
                  onclick="jQuery(this).closest('div').remove();update_listing_cat(this);" align="right"/>
1071 1071
             <?php /* ?>
1072 1072
 		<img src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png';?>" onclick="jQuery(this).closest('div').remove();show_subcatlist();" align="right" /> 
1073 1073
 		<?php */ ?>
1074 1074
 
1075
-            <input type="checkbox" value="<?php echo $main_cat->term_id;?>" class="listing_main_cat"
1075
+            <input type="checkbox" value="<?php echo $main_cat->term_id; ?>" class="listing_main_cat"
1076 1076
                    onchange="if(jQuery(this).is(':checked')){jQuery(this).closest('div').find('.post_default_category').prop('checked',false).show();}else{jQuery(this).closest('div').find('.post_default_category').prop('checked',false).hide();};update_listing_cat()"
1077 1077
                    checked="checked" disabled="disabled"/>
1078 1078
        <span> 
1079
-        <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1079
+        <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
1080 1080
         </span>
1081 1081
             <br/>
1082 1082
 
1083 1083
             <div class="post_default_category">
1084
-                <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1085
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1084
+                <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id; ?>"
1085
+                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" '; ?>   />
1086 1086
         <span> 
1087
-        <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1087
+        <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?>
1088 1088
         </span>
1089 1089
             </div>
1090 1090
 
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
         $post_cat_str = $post_categories[$request_taxonomy];
1118 1118
         $post_cat_array = explode("#", $post_cat_str);
1119 1119
         if (is_array($post_cat_array)) {
1120
-            $post_cat_array = array_unique( $post_cat_array );
1120
+            $post_cat_array = array_unique($post_cat_array);
1121 1121
 
1122 1122
 			foreach ($post_cat_array as $post_cat_html) {
1123 1123
 
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
                 }
1133 1133
                 $post_sub_catid = '';
1134 1134
                 if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1135
-                    $post_sub_catid = (int)$post_cat_info[1];
1135
+                    $post_sub_catid = (int) $post_cat_info[1];
1136 1136
                 }
1137 1137
 
1138 1138
                 geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
             }
1154 1154
 
1155 1155
             if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1156
-                $post_sub_catid = (int)$post_cat_info[1];
1156
+                $post_sub_catid = (int) $post_cat_info[1];
1157 1157
             }
1158 1158
 
1159 1159
             geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
@@ -1185,9 +1185,9 @@  discard block
 block discarded – undo
1185 1185
         if (!$selected)
1186 1186
             $option_slected = ' selected="selected" ';
1187 1187
 
1188
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1188
+        echo '<select field_type="select" id="'.sanitize_text_field($cat_taxonomy).'" class="chosen_select" '.$onchange.' option-ajaxChosen="false" >';
1189 1189
 
1190
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1190
+        echo '<option value="" '.$option_selected.' >'.__('Select Category', 'geodirectory').'</option>';
1191 1191
 
1192 1192
         foreach ($cat_terms as $cat_term) {
1193 1193
             $option_selected = '';
@@ -1195,10 +1195,10 @@  discard block
 block discarded – undo
1195 1195
                 $option_selected = ' selected="selected" ';
1196 1196
 
1197 1197
             // Count child terms
1198
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1199
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1198
+            $child_terms = get_terms($cat_taxonomy, array('parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1));
1199
+            $has_child = !empty($child_terms) ? 't' : 'f';
1200 1200
 
1201
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1201
+            echo '<option  '.$option_selected.' alt="'.$cat_term->taxonomy.'" title="'.geodir_utf8_ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" _hc="'.$has_child.'" >'.geodir_utf8_ucfirst($cat_term->name).'</option>';
1202 1202
         }
1203 1203
         echo '</select>';
1204 1204
     }
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
             2 => __('Custom field updated.', 'geodirectory'),
1230 1230
             3 => __('Custom field deleted.', 'geodirectory'),
1231 1231
             4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1232
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1232
+            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false,
1233 1233
             6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1234 1234
             7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1235 1235
             8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 
1256 1256
     global $wpdb;
1257 1257
 
1258
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1258
+    $menu_icon = geodir_plugin_url().'/geodirectory-assets/images/favicon.ico';
1259 1259
 
1260 1260
     if (!$listing_slug = get_option('geodir_listing_prefix'))
1261 1261
         $listing_slug = 'places';
@@ -1268,11 +1268,11 @@  discard block
 block discarded – undo
1268 1268
 
1269 1269
         $gd_placetags = array();
1270 1270
         $gd_placetags['object_type'] = 'gd_place';
1271
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1271
+        $gd_placetags['listing_slug'] = $listing_slug.'/tags';
1272 1272
         $gd_placetags['args'] = array(
1273 1273
             'public' => true,
1274 1274
             'hierarchical' => false,
1275
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1275
+            'rewrite' => array('slug' => $listing_slug.'/tags', 'with_front' => false, 'hierarchical' => true),
1276 1276
             'query_var' => true,
1277 1277
 
1278 1278
             'labels' => array(
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
             'menu_icon' => $menu_icon,
1367 1367
             'public' => true,
1368 1368
             'query_var' => true,
1369
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1369
+            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1370 1370
             'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1371 1371
             'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1372 1372
 
@@ -1399,12 +1399,12 @@  discard block
 block discarded – undo
1399 1399
         return $_REQUEST['lang'];
1400 1400
     }
1401 1401
 
1402
-    $url = str_replace(array("http://","https://"),"",$url);
1402
+    $url = str_replace(array("http://", "https://"), "", $url);
1403 1403
 
1404 1404
     // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1405
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1405
+    $site_url = str_replace(array("http://", "https://"), "", site_url());
1406 1406
 
1407
-    $url = str_replace($site_url,"",$url);
1407
+    $url = str_replace($site_url, "", $url);
1408 1408
 
1409 1409
     $segments = explode('/', trim($url, '/'));
1410 1410
 
@@ -1470,9 +1470,9 @@  discard block
 block discarded – undo
1470 1470
     if (in_array($post->post_type, geodir_get_posttypes())) {
1471 1471
 
1472 1472
         // if we dont have a GD post then try to grab it
1473
-        if(!isset($post->default_category)){
1473
+        if (!isset($post->default_category)) {
1474 1474
             $gd_post = geodir_get_post_info($post->ID);
1475
-            if(!empty($gd_post)){
1475
+            if (!empty($gd_post)) {
1476 1476
                 $post = $gd_post;
1477 1477
             }
1478 1478
         }
@@ -1482,17 +1482,17 @@  discard block
 block discarded – undo
1482 1482
         $slug = $post_types[$post->post_type]['rewrite']['slug'];
1483 1483
 
1484 1484
         // Alter the CPT slug if WPML is set to do so
1485
-        if(function_exists('icl_object_id')){
1486
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1485
+        if (function_exists('icl_object_id')) {
1486
+            if (gd_wpml_slug_translation_turned_on($post->post_type) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1487 1487
 
1488 1488
                 $org_slug = $slug;
1489
-                $slug = apply_filters( 'wpml_translate_single_string',
1489
+                $slug = apply_filters('wpml_translate_single_string',
1490 1490
                     $slug,
1491 1491
                     'WordPress',
1492
-                    'URL slug: ' . $slug,
1492
+                    'URL slug: '.$slug,
1493 1493
                     $language_code);
1494 1494
 
1495
-                if(!$slug){$slug = $org_slug;}
1495
+                if (!$slug) {$slug = $org_slug; }
1496 1496
 
1497 1497
             }
1498 1498
         }
@@ -1514,11 +1514,11 @@  discard block
 block discarded – undo
1514 1514
         }
1515 1515
 
1516 1516
         $post_link = trailingslashit(
1517
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1517
+            preg_replace("/".preg_quote($slug, "/")."/", $slug."/%gd_taxonomy%", $post_link, 1)
1518 1518
         );
1519 1519
 
1520 1520
         if ($fix_url) {
1521
-            $post_link = $site_url . $post_link;
1521
+            $post_link = $site_url.$post_link;
1522 1522
         }
1523 1523
 
1524 1524
         if (isset($comment_post_cache[$post->ID])) {
@@ -1537,12 +1537,12 @@  discard block
 block discarded – undo
1537 1537
             $ID = $post->ID;
1538 1538
             $post2 = $wpdb->get_row(
1539 1539
                 $wpdb->prepare(
1540
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1540
+                    "SELECT * from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ",
1541 1541
                     array($post->ID)
1542 1542
                 )
1543 1543
             );
1544 1544
 
1545
-            $post = (object)array_merge((array)$post, (array)$post2);
1545
+            $post = (object) array_merge((array) $post, (array) $post2);
1546 1546
 
1547 1547
             $comment_post_cache[$post->ID] = $post;
1548 1548
         }
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
 
1552 1552
         if (false !== strpos($post_link, '%gd_taxonomy%')) {
1553 1553
 
1554
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1554
+            if (apply_filters("geodir_add_location_url_to_url", get_option('geodir_add_location_url'), $post->post_type, $post)) {
1555 1555
                 $location_request = '';
1556 1556
 
1557 1557
 
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
                         $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566 1566
                         $post->country_slug = str_replace(']', '', $post->country_slug);
1567 1567
 
1568
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1568
+                        $post_location = (object) array('country_slug' => $post->country_slug,
1569 1569
                             'region_slug' => $post->region_slug,
1570 1570
                             'city_slug' => $post->city_slug
1571 1571
                         );
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 
1579 1579
                     $post_location_sql = $wpdb->get_results(
1580 1580
                         $wpdb->prepare(
1581
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1581
+                            "SELECT post_locations from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ",
1582 1582
                             array($post->ID)
1583 1583
                         )
1584 1584
                     );
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                             $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595 1595
                             $post->country_slug = str_replace(']', '', $post->country_slug);
1596 1596
 
1597
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1597
+                            $post_location = (object) array('country_slug' => $post->country_slug,
1598 1598
                                 'region_slug' => $post->region_slug,
1599 1599
                                 'city_slug' => $post->city_slug
1600 1600
                             );
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
 					}
1624 1624
 					$location_slug[] = $city_slug;
1625 1625
 					
1626
-					$location_request .= implode('/', $location_slug) . '/';
1626
+					$location_request .= implode('/', $location_slug).'/';
1627 1627
                 }
1628 1628
             }
1629 1629
 
@@ -1639,9 +1639,9 @@  discard block
 block discarded – undo
1639 1639
                 } else {
1640 1640
                     $post_terms = '';
1641 1641
 
1642
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1642
+                    if (isset($_POST['post_default_category']) && $_POST['post_default_category']) {
1643 1643
                         $post_terms = absint($_POST['post_default_category']);
1644
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1644
+                    }elseif (isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1645 1645
                         $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646 1646
                         $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1647 1647
                     }elseif (isset($post->{$taxonomies})) {
@@ -1687,14 +1687,14 @@  discard block
 block discarded – undo
1687 1687
             $request_term = trim($request_term, '/');
1688 1688
             
1689 1689
             // Fix with WPML the location terms added twice when CPT slug is translated.
1690
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1690
+            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/'.$request_term.$detailurl_separator) !== false) {
1691 1691
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692 1692
             }
1693 1693
             
1694 1694
             if (!empty($request_term))
1695
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1695
+                $post_link = str_replace('%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
1696 1696
             else
1697
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1697
+                $post_link = str_replace('/%gd_taxonomy%', $request_term.$detailurl_separator, $post_link);
1698 1698
             //echo $post_link ;
1699 1699
         }
1700 1700
         // temp cache the permalink
@@ -1769,9 +1769,9 @@  discard block
 block discarded – undo
1769 1769
                 $url_separator = '';
1770 1770
 
1771 1771
                 if (get_option('permalink_structure') != '') {
1772
-                    $old_listing_slug = '/' . $listing_slug . '/';
1772
+                    $old_listing_slug = '/'.$listing_slug.'/';
1773 1773
                     $request_term = implode("/", $location_terms);
1774
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1774
+                    $new_listing_slug = '/'.$listing_slug.'/'.$request_term.'/';
1775 1775
 
1776 1776
                     $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1777 1777
                 } else {
@@ -1791,25 +1791,25 @@  discard block
 block discarded – undo
1791 1791
         // Alter the CPT slug if WPML is set to do so
1792 1792
         if (function_exists('icl_object_id')) {
1793 1793
             $post_types = get_option('geodir_post_types');
1794
-            $post_type = str_replace("category","",$taxonomy);
1795
-            $post_type = str_replace("_tags","",$post_type);
1794
+            $post_type = str_replace("category", "", $taxonomy);
1795
+            $post_type = str_replace("_tags", "", $post_type);
1796 1796
             $slug = $post_types[$post_type]['rewrite']['slug'];
1797 1797
             if (gd_wpml_slug_translation_turned_on($post_type)) {
1798 1798
                 global $sitepress;
1799 1799
                 $default_lang = $sitepress->get_default_language();
1800 1800
                 $language_code = gd_wpml_get_lang_from_url($termlink);
1801
-                if (!$language_code ) {
1802
-                    $language_code  = $default_lang;
1801
+                if (!$language_code) {
1802
+                    $language_code = $default_lang;
1803 1803
                 }
1804 1804
 
1805 1805
                 $org_slug = $slug;
1806
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1806
+                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: '.$slug, $language_code);
1807 1807
 
1808 1808
                 if (!$slug) {
1809 1809
                     $slug = $org_slug;
1810 1810
                 }
1811 1811
 
1812
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1812
+                $termlink = trailingslashit(preg_replace("/".preg_quote($org_slug, "/")."/", $slug, $termlink, 1));
1813 1813
             }
1814 1814
         }
1815 1815
     }
@@ -1839,7 +1839,7 @@  discard block
 block discarded – undo
1839 1839
 	
1840 1840
 	if (in_array($post_type, geodir_get_posttypes())) {
1841 1841
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1842
-			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1842
+			if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1843 1843
                 $location_terms = array(
1844 1844
                     'gd_country' => $post->country_slug,
1845 1845
                     'gd_region' => $post->region_slug,
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
 					$location_terms = implode("/", $location_terms);
1857 1857
 					$location_terms = rtrim($location_terms, '/');
1858 1858
 					
1859
-					$link .= urldecode($location_terms) . '/';
1859
+					$link .= urldecode($location_terms).'/';
1860 1860
 				} else {
1861 1861
 					$link = geodir_getlink($link, $location_terms);
1862 1862
 				}
@@ -1944,9 +1944,9 @@  discard block
 block discarded – undo
1944 1944
             return 0;
1945 1945
         $where = 't.term_id = %d';
1946 1946
         if (!empty($taxonomy))
1947
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1947
+            return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948 1948
         else
1949
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1949
+            return $wpdb->get_var($wpdb->prepare($select.$where, $term));
1950 1950
     }
1951 1951
 
1952 1952
     $term = trim(wp_unslash($term));
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 
1959 1959
     $where_fields = array($slug);
1960 1960
     if (!empty($taxonomy)) {
1961
-        $parent = (int)$parent;
1961
+        $parent = (int) $parent;
1962 1962
         if ($parent > 0) {
1963 1963
             $where_fields[] = $parent;
1964 1964
             $else_where_fields[] = $parent;
@@ -2022,13 +2022,13 @@  discard block
 block discarded – undo
2022 2022
         $post_types = geodir_get_posttypes();
2023 2023
         $tax_arr = array();
2024 2024
         foreach ($post_types as $post_type) {
2025
-            $tax_arr[] = "'" . $post_type . "category'";
2025
+            $tax_arr[] = "'".$post_type."category'";
2026 2026
         }
2027 2027
         $tax_c = implode(',', $tax_arr);
2028 2028
         $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2029 2029
         //$terms = get_terms( $taxonomy );
2030 2030
 
2031
-        if($terms) {
2031
+        if ($terms) {
2032 2032
             foreach ($terms as $term) {
2033 2033
                 $post_type = str_replace("category", "", $term->taxonomy);
2034 2034
                 $a_terms[$post_type][] = $term;
@@ -2036,7 +2036,7 @@  discard block
 block discarded – undo
2036 2036
             }
2037 2037
         }
2038 2038
 
2039
-        if($a_terms) {
2039
+        if ($a_terms) {
2040 2040
             foreach ($a_terms as $pt => $t2) {
2041 2041
 
2042 2042
                 foreach ($t2 as $term) {
@@ -2061,7 +2061,7 @@  discard block
 block discarded – undo
2061 2061
     }
2062 2062
 
2063 2063
     if (is_ssl()) {
2064
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2064
+        $terms_icons = str_replace("http:", "https:", $terms_icons);
2065 2065
     }
2066 2066
 
2067 2067
     return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
Please login to merge, or discard this patch.
Braces   +170 added lines, -122 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
     if (get_option('geodir_show_listing_nav')) {
40 40
 
41 41
         $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
42
+        if (geodir_is_page('listing')) {
43
+                    $menu_class = 'current-menu-item';
44
+        }
44 45
 
45 46
 
46 47
         //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
                     if (in_array($post_type, $show_post_type_main_nav)) {
53 54
                         if (get_post_type_archive_link($post_type)) {
54 55
                             $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
56
+                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
57
+                                                            $menu_class = 'current-menu-item';
58
+                            }
57 59
                             /**
58 60
                              * Filter the menu li class.
59 61
                              *
@@ -130,8 +132,9 @@  discard block
 block discarded – undo
130 132
                             if (get_post_type_archive_link($post_type)) {
131 133
 
132 134
                                 $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
135
+                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
136
+                                                                    $menu_class = 'current-menu-item';
137
+                                }
135 138
 
136 139
                                 $items .= '<li class="' . $sub_li_class . '">
137 140
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
@@ -159,8 +162,9 @@  discard block
 block discarded – undo
159 162
     if (get_option('geodir_show_addlisting_nav')) {
160 163
 
161 164
         $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
165
+        if (geodir_is_page('add-listing')) {
166
+                    $menu_class = 'current-menu-item';
167
+        }
164 168
 
165 169
         //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166 170
         $post_types = geodir_get_posttypes('object');
@@ -176,8 +180,9 @@  discard block
 block discarded – undo
176 180
                                 if (geodir_get_addlisting_link($post_type)) {
177 181
 
178 182
                                     $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
183
+                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
184
+                                                                            $menu_class = 'current-menu-item';
185
+                                    }
181 186
                                     /**
182 187
                                      * Filter the menu li class.
183 188
                                      *
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
                                     if (geodir_get_addlisting_link($post_type)) {
262 267
 
263 268
                                         $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
269
+                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
270
+                                                                                    $menu_class = 'current-menu-item';
271
+                                        }
266 272
                                         /**
267 273
                                          * Filter the menu li class.
268 274
                                          *
@@ -319,8 +325,9 @@  discard block
 block discarded – undo
319 325
     }
320 326
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 327
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
328
+    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) {
329
+            $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
330
+    }
324 331
 
325 332
     return $menu;
326 333
 
@@ -407,17 +414,20 @@  discard block
 block discarded – undo
407 414
     $geodir_post_type = get_query_var('post_type');
408 415
 
409 416
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
417
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
418
+                    $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
419
+        } elseif (isset($_REQUEST['listing_type'])) {
420
+                    $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
421
+        }
414 422
     }
415 423
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
424
+    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) {
425
+            $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
426
+    }
418 427
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
428
+    if (is_tax()) {
429
+            $geodir_post_type = geodir_get_taxonomy_posttype();
430
+    }
421 431
 
422 432
     // Retrive post type for map marker html ajax request on preview page.
423 433
     if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
@@ -431,8 +441,9 @@  discard block
 block discarded – undo
431 441
     $all_postypes = geodir_get_posttypes();
432 442
     $all_postypes = stripslashes_deep($all_postypes);
433 443
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
444
+    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) {
445
+            $geodir_post_type = '';
446
+    }
436 447
 
437 448
     if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438 449
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
@@ -517,11 +528,12 @@  discard block
 block discarded – undo
517 528
         endswitch;
518 529
     }
519 530
 
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
524
-}
531
+    if (!empty($post_types)) {
532
+            return $post_types;
533
+    } else {
534
+            return array();
535
+    }
536
+    }
525 537
 
526 538
 /**
527 539
  * Get Custom Post Type info.
@@ -538,9 +550,10 @@  discard block
 block discarded – undo
538 550
     $post_types = stripslashes_deep($post_types);
539 551
     if (!empty($post_types) && $post_type != '') {
540 552
         return $post_types[$post_type];
541
-    } else
542
-        return false;
543
-}
553
+    } else {
554
+            return false;
555
+    }
556
+    }
544 557
 
545 558
 if (!function_exists('geodir_get_taxonomies')) {
546 559
     /**
@@ -564,18 +577,21 @@  discard block
 block discarded – undo
564 577
             $gd_taxonomies = array_keys($taxonomies);
565 578
 
566 579
 
567
-            if ($post_type != '')
568
-                $gd_taxonomies = array();
580
+            if ($post_type != '') {
581
+                            $gd_taxonomies = array();
582
+            }
569 583
 
570 584
             $i = 0;
571 585
             foreach ($taxonomies as $taxonomy => $args) {
572 586
 
573
-                if ($post_type != '' && $args['object_type'] == $post_type)
574
-                    $gd_taxonomies[] = $taxonomy;
587
+                if ($post_type != '' && $args['object_type'] == $post_type) {
588
+                                    $gd_taxonomies[] = $taxonomy;
589
+                }
575 590
 
576 591
                 if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
578
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
592
+                    if (array_search($taxonomy, $gd_taxonomies) !== false) {
593
+                                            unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
594
+                    }
579 595
                 }
580 596
 
581 597
             }
@@ -630,10 +646,11 @@  discard block
 block discarded – undo
630 646
                 . geodir_utf8_ucfirst($category_obj->name) . '</option>';
631 647
         }
632 648
 
633
-        if ($echo)
634
-            echo $html;
635
-        else
636
-            return $html;
649
+        if ($echo) {
650
+                    echo $html;
651
+        } else {
652
+                    return $html;
653
+        }
637 654
     }
638 655
 }
639 656
 
@@ -667,11 +684,12 @@  discard block
 block discarded – undo
667 684
 
668 685
     }
669 686
 
670
-    if (!empty($listing_slug))
671
-        return $listing_slug;
672
-    else
673
-        return false;
674
-}
687
+    if (!empty($listing_slug)) {
688
+            return $listing_slug;
689
+    } else {
690
+            return false;
691
+    }
692
+    }
675 693
 
676 694
 
677 695
 /**
@@ -702,16 +720,18 @@  discard block
 block discarded – undo
702 720
     if (!empty($taxonomies)) {
703 721
         foreach (geodir_get_posttypes() as $pt) {
704 722
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
-            if (array_intersect($taxonomies, $object_taxonomies))
706
-                $post_type[] = $pt;
723
+            if (array_intersect($taxonomies, $object_taxonomies)) {
724
+                            $post_type[] = $pt;
725
+            }
707 726
         }
708 727
     }
709 728
 
710
-    if (!empty($post_type))
711
-        return $post_type[0];
712
-    else
713
-        return false;
714
-}
729
+    if (!empty($post_type)) {
730
+            return $post_type[0];
731
+    } else {
732
+            return false;
733
+    }
734
+    }
715 735
 
716 736
 if (!function_exists('geodir_custom_taxonomy_walker')) {
717 737
     /**
@@ -767,18 +787,18 @@  discard block
 block discarded – undo
767 787
                 $checked = '';
768 788
 
769 789
                 if (in_array($cat_term->term_id, $search_terms)) {
770
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
771
-                        $checked = 'selected="selected"';
772
-                    else
773
-                        $checked = 'checked="checked"';
790
+                    if ($cat_display == 'select' || $cat_display == 'multiselect') {
791
+                                            $checked = 'selected="selected"';
792
+                    } else {
793
+                                            $checked = 'checked="checked"';
794
+                    }
774 795
                 }
775 796
 
776
-                if ($cat_display == 'radio')
777
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
780
-
781
-                else {
797
+                if ($cat_display == 'radio') {
798
+                                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
799
+                } elseif ($cat_display == 'select' || $cat_display == 'multiselect') {
800
+                                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
801
+                } else {
782 802
                     $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783 803
                 }
784 804
 
@@ -787,8 +807,9 @@  discard block
 block discarded – undo
787 807
 
788 808
             }
789 809
 
790
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
-                $out .= '</div>';
810
+            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
811
+                            $out .= '</div>';
812
+            }
792 813
 
793 814
             return $out;
794 815
         }
@@ -814,18 +835,21 @@  discard block
 block discarded – undo
814 835
         global $exclude_cats, $gd_session;
815 836
 
816 837
         $cat_exclude = '';
817
-        if (is_array($exclude_cats) && !empty($exclude_cats))
818
-            $cat_exclude = serialize($exclude_cats);
838
+        if (is_array($exclude_cats) && !empty($exclude_cats)) {
839
+                    $cat_exclude = serialize($exclude_cats);
840
+        }
819 841
 
820 842
         if (isset($_REQUEST['backandedit'])) {
821 843
             $post = (object)$gd_session->get('listing');
822 844
 
823
-            if (!is_array($post->post_category[$cat_taxonomy]))
824
-                $post_category = $post->post_category[$cat_taxonomy];
845
+            if (!is_array($post->post_category[$cat_taxonomy])) {
846
+                            $post_category = $post->post_category[$cat_taxonomy];
847
+            }
825 848
 
826 849
             $post_categories = $post->post_category_str;
827
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
-                $post_category_str = $post_categories[$cat_taxonomy];
850
+            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
851
+                            $post_category_str = $post_categories[$cat_taxonomy];
852
+            }
829 853
 
830 854
         } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831 855
             global $post;
@@ -1016,8 +1040,9 @@  discard block
 block discarded – undo
1016 1040
         if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017 1041
             $post_cat_str = $post_categories[$cat_taxonomy];
1018 1042
             $post_cat_array = explode("#", $post_cat_str);
1019
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
-                $style = "display:none;";
1043
+            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) {
1044
+                            $style = "display:none;";
1045
+            }
1021 1046
         }
1022 1047
         ?>
1023 1048
         <div class="main_cat_list" style=" <?php if (isset($style)) {
@@ -1052,7 +1077,7 @@  discard block
 block discarded – undo
1052 1077
 
1053 1078
         if(is_array( $exclude_cats)){
1054 1079
             $exclude_cats = array_map( 'intval', $exclude_cats );
1055
-        }else{
1080
+        } else{
1056 1081
             $exclude_cats = intval($exclude_cats);
1057 1082
         }
1058 1083
 
@@ -1082,7 +1107,10 @@  discard block
 block discarded – undo
1082 1107
 
1083 1108
             <div class="post_default_category">
1084 1109
                 <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1085
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1110
+                       onchange="update_listing_cat()" <?php if ($default) {
1111
+	echo ' checked="checked" ';
1112
+}
1113
+?>   />
1086 1114
         <span> 
1087 1115
         <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1088 1116
         </span>
@@ -1182,8 +1210,9 @@  discard block
 block discarded – undo
1182 1210
         $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1183 1211
 
1184 1212
         $option_selected = '';
1185
-        if (!$selected)
1186
-            $option_slected = ' selected="selected" ';
1213
+        if (!$selected) {
1214
+                    $option_slected = ' selected="selected" ';
1215
+        }
1187 1216
 
1188 1217
         echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1189 1218
 
@@ -1191,8 +1220,9 @@  discard block
 block discarded – undo
1191 1220
 
1192 1221
         foreach ($cat_terms as $cat_term) {
1193 1222
             $option_selected = '';
1194
-            if ($selected == $cat_term->term_id)
1195
-                $option_selected = ' selected="selected" ';
1223
+            if ($selected == $cat_term->term_id) {
1224
+                            $option_selected = ' selected="selected" ';
1225
+            }
1196 1226
 
1197 1227
             // Count child terms
1198 1228
             $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
@@ -1257,8 +1287,9 @@  discard block
 block discarded – undo
1257 1287
 
1258 1288
     $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259 1289
 
1260
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
-        $listing_slug = 'places';
1290
+    if (!$listing_slug = get_option('geodir_listing_prefix')) {
1291
+            $listing_slug = 'places';
1292
+    }
1262 1293
 
1263 1294
     /**
1264 1295
      * Taxonomies
@@ -1570,8 +1601,9 @@  discard block
 block discarded – undo
1570 1601
                             'city_slug' => $post->city_slug
1571 1602
                         );
1572 1603
 
1573
-                    } else
1574
-                        $post_location = geodir_get_location();
1604
+                    } else {
1605
+                                            $post_location = geodir_get_location();
1606
+                    }
1575 1607
 
1576 1608
 
1577 1609
                 } else {
@@ -1600,8 +1632,9 @@  discard block
 block discarded – undo
1600 1632
                             );
1601 1633
 
1602 1634
                         }
1603
-                    } else
1604
-                        $post_location = geodir_get_location();
1635
+                    } else {
1636
+                                            $post_location = geodir_get_location();
1637
+                    }
1605 1638
                 }
1606 1639
 
1607 1640
 
@@ -1641,16 +1674,17 @@  discard block
 block discarded – undo
1641 1674
 
1642 1675
                     if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643 1676
                         $post_terms = absint($_POST['post_default_category']);
1644
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1677
+                    } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1645 1678
                         $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646 1679
                         $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1647
-                    }elseif (isset($post->{$taxonomies})) {
1680
+                    } elseif (isset($post->{$taxonomies})) {
1648 1681
                         $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649 1682
                         $post_terms = $post_terms[0];
1650 1683
                     }
1651 1684
 
1652
-                    if (!$post_terms)
1653
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1685
+                    if (!$post_terms) {
1686
+                                            $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1687
+                    }
1654 1688
 
1655 1689
                     if (!$post_terms) {
1656 1690
                         $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
@@ -1664,8 +1698,9 @@  discard block
 block discarded – undo
1664 1698
 
1665 1699
                 $term = get_term_by('id', $post_terms, $taxonomies);
1666 1700
 
1667
-                if (!empty($term))
1668
-                    $term_request = $term->slug;
1701
+                if (!empty($term)) {
1702
+                                    $term_request = $term->slug;
1703
+                }
1669 1704
                 //$term_request = $term->slug.'/';
1670 1705
             }
1671 1706
 
@@ -1680,9 +1715,13 @@  discard block
 block discarded – undo
1680 1715
                 $request_term .= $term_request;
1681 1716
 
1682 1717
             } else {
1683
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1718
+                if (isset($location_request) && $location_request != '') {
1719
+                	$request_term = $location_request;
1720
+                }
1684 1721
 
1685
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1722
+                if (isset($term_request) && $term_request != '') {
1723
+                	$request_term .= $term_request;
1724
+                }
1686 1725
             }
1687 1726
             $request_term = trim($request_term, '/');
1688 1727
             
@@ -1691,10 +1730,11 @@  discard block
 block discarded – undo
1691 1730
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692 1731
             }
1693 1732
             
1694
-            if (!empty($request_term))
1695
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
-            else
1697
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1733
+            if (!empty($request_term)) {
1734
+                            $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1735
+            } else {
1736
+                            $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1737
+            }
1698 1738
             //echo $post_link ;
1699 1739
         }
1700 1740
         // temp cache the permalink
@@ -1886,11 +1926,12 @@  discard block
 block discarded – undo
1886 1926
     
1887 1927
     $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1888 1928
     
1889
-    if ($echo)
1890
-        echo $label;
1891
-    else
1892
-        return $label;
1893
-}
1929
+    if ($echo) {
1930
+            echo $label;
1931
+    } else {
1932
+            return $label;
1933
+    }
1934
+    }
1894 1935
 
1895 1936
 /**
1896 1937
  * Print or Get post type plural label.
@@ -1906,18 +1947,20 @@  discard block
 block discarded – undo
1906 1947
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1907 1948
     $all_postypes = geodir_get_posttypes();
1908 1949
 
1909
-    if (!in_array($post_type, $all_postypes))
1910
-        return false;
1950
+    if (!in_array($post_type, $all_postypes)) {
1951
+            return false;
1952
+    }
1911 1953
 
1912 1954
     $obj_post_type = get_post_type_object($post_type);
1913 1955
     
1914 1956
     $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1915 1957
     
1916
-    if ($echo)
1917
-        echo $label;
1918
-    else
1919
-        return $label;
1920
-}
1958
+    if ($echo) {
1959
+            echo $label;
1960
+    } else {
1961
+            return $label;
1962
+    }
1963
+    }
1921 1964
 
1922 1965
 /**
1923 1966
  * Checks whether a term exists or not.
@@ -1940,19 +1983,22 @@  discard block
 block discarded – undo
1940 1983
     $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941 1984
 
1942 1985
     if (is_int($term)) {
1943
-        if (0 == $term)
1944
-            return 0;
1986
+        if (0 == $term) {
1987
+                    return 0;
1988
+        }
1945 1989
         $where = 't.term_id = %d';
1946
-        if (!empty($taxonomy))
1947
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
-        else
1949
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1990
+        if (!empty($taxonomy)) {
1991
+                    return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1992
+        } else {
1993
+                    return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1994
+        }
1950 1995
     }
1951 1996
 
1952 1997
     $term = trim(wp_unslash($term));
1953 1998
 
1954
-    if ('' === $slug = sanitize_title($term))
1955
-        return 0;
1999
+    if ('' === $slug = sanitize_title($term)) {
2000
+            return 0;
2001
+    }
1956 2002
 
1957 2003
     $where = 't.slug = %s';
1958 2004
 
@@ -1969,14 +2015,16 @@  discard block
 block discarded – undo
1969 2015
         $where_fields[] = $taxonomy;
1970 2016
 
1971 2017
 
1972
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
-            return $result;
2018
+        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) {
2019
+                    return $result;
2020
+        }
1974 2021
 
1975 2022
         return false;
1976 2023
     }
1977 2024
 
1978
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
-        return $result;
2025
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) {
2026
+            return $result;
2027
+    }
1980 2028
 
1981 2029
     return false;
1982 2030
 }
Please login to merge, or discard this patch.