Test Failed
Pull Request — master (#373)
by Viruthagiri
15:27
created
geodirectory-functions/post_functions.php 3 patches
Indentation   +2252 added lines, -2252 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,599 +567,599 @@  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
-     * @package GeoDirectory
874
-     * @global object $wpdb WordPress Database object.
875
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
876
-     * @param int $post_id The post ID.
877
-     * @param string $meta_key The meta key to retrieve.
878
-     * @param bool $single Optional. Whether to return a single value. Default false.
879
-     * @todo single variable not yet implemented.
880
-     * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
881
-     */
882
-    function geodir_get_post_meta($post_id, $meta_key, $single = false)
883
-    {
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
-            if ($meta_value && $meta_value !== '') {
901
-                return maybe_serialize($meta_value);
902
-            } else
903
-                return $meta_value;
904
-        } else {
905
-            return false;
906
-        }
907
-    }
869
+	/**
870
+	 * Get post custom meta.
871
+	 *
872
+	 * @since 1.0.0
873
+	 * @package GeoDirectory
874
+	 * @global object $wpdb WordPress Database object.
875
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
876
+	 * @param int $post_id The post ID.
877
+	 * @param string $meta_key The meta key to retrieve.
878
+	 * @param bool $single Optional. Whether to return a single value. Default false.
879
+	 * @todo single variable not yet implemented.
880
+	 * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
881
+	 */
882
+	function geodir_get_post_meta($post_id, $meta_key, $single = false)
883
+	{
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
+			if ($meta_value && $meta_value !== '') {
901
+				return maybe_serialize($meta_value);
902
+			} else
903
+				return $meta_value;
904
+		} else {
905
+			return false;
906
+		}
907
+	}
908 908
 }
909 909
 
910 910
 
911 911
 if (!function_exists('geodir_save_post_images')) {
912
-    /**
913
-     * Save post attachments.
914
-     *
915
-     * @since 1.0.0
916
-     * @package GeoDirectory
917
-     * @global object $wpdb WordPress Database object.
918
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
919
-     * @global object $current_user Current user object.
920
-     * @param int $post_id The post ID.
921
-     * @param array $post_image Post image urls as an array.
922
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
923
-     */
924
-    function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
925
-    {
912
+	/**
913
+	 * Save post attachments.
914
+	 *
915
+	 * @since 1.0.0
916
+	 * @package GeoDirectory
917
+	 * @global object $wpdb WordPress Database object.
918
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
919
+	 * @global object $current_user Current user object.
920
+	 * @param int $post_id The post ID.
921
+	 * @param array $post_image Post image urls as an array.
922
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
923
+	 */
924
+	function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
925
+	{
926 926
 
927 927
 
928
-        global $wpdb, $plugin_prefix, $current_user;
928
+		global $wpdb, $plugin_prefix, $current_user;
929 929
 
930
-        $post_type = get_post_type($post_id);
930
+		$post_type = get_post_type($post_id);
931 931
 
932
-        $table = $plugin_prefix . $post_type . '_detail';
932
+		$table = $plugin_prefix . $post_type . '_detail';
933 933
 
934
-        $post_images = geodir_get_images($post_id);
934
+		$post_images = geodir_get_images($post_id);
935 935
 
936
-        $wpdb->query(
937
-            $wpdb->prepare(
938
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
939
-                array($post_id)
940
-            )
941
-        );
936
+		$wpdb->query(
937
+			$wpdb->prepare(
938
+				"UPDATE " . $table . " SET featured_image = '' where post_id =%d",
939
+				array($post_id)
940
+			)
941
+		);
942 942
 
943
-        $invalid_files = $post_images;
944
-        $valid_file_ids = array();
945
-        $valid_files_condition = '';
946
-        $geodir_uploaddir = '';
943
+		$invalid_files = $post_images;
944
+		$valid_file_ids = array();
945
+		$valid_files_condition = '';
946
+		$geodir_uploaddir = '';
947 947
 
948
-        $remove_files = array();
948
+		$remove_files = array();
949 949
 
950
-        if (!empty($post_image)) {
950
+		if (!empty($post_image)) {
951 951
 
952
-            $uploads = wp_upload_dir();
953
-            $uploads_dir = $uploads['path'];
952
+			$uploads = wp_upload_dir();
953
+			$uploads_dir = $uploads['path'];
954 954
 
955
-            $geodir_uploadpath = $uploads['path'];
956
-            $geodir_uploadurl = $uploads['url'];
957
-            $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
955
+			$geodir_uploadpath = $uploads['path'];
956
+			$geodir_uploadurl = $uploads['url'];
957
+			$sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
958 958
 
959
-            $invalid_files = array();
960
-            $postcurr_images = array();
959
+			$invalid_files = array();
960
+			$postcurr_images = array();
961 961
 
962
-            for ($m = 0; $m < count($post_image); $m++) {
963
-                $menu_order = $m + 1;
962
+			for ($m = 0; $m < count($post_image); $m++) {
963
+				$menu_order = $m + 1;
964 964
 
965
-                $file_path = '';
966
-                /* --------- start ------- */
965
+				$file_path = '';
966
+				/* --------- start ------- */
967 967
 
968
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
968
+				$split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
969 969
 
970
-                $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
970
+				$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
971 971
 
972 972
 
973
-                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)))) {
973
+				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)))) {
974 974
 
975
-                    /* --------- end ------- */
976
-                    $curr_img_url = $post_image[$m];
975
+					/* --------- end ------- */
976
+					$curr_img_url = $post_image[$m];
977 977
 
978
-                    $image_name_arr = explode('/', $curr_img_url);
978
+					$image_name_arr = explode('/', $curr_img_url);
979 979
 
980
-                    $count_image_name_arr = count($image_name_arr) - 2;
980
+					$count_image_name_arr = count($image_name_arr) - 2;
981 981
 
982
-                    $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
982
+					$count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
983 983
 
984
-                    $curr_img_dir = $image_name_arr[$count_image_name_arr];
984
+					$curr_img_dir = $image_name_arr[$count_image_name_arr];
985 985
 
986
-                    $filename = end($image_name_arr);
987
-                    if (strpos($filename, '?') !== false) {
988
-                        list($filename) = explode('?', $filename);
989
-                    }
986
+					$filename = end($image_name_arr);
987
+					if (strpos($filename, '?') !== false) {
988
+						list($filename) = explode('?', $filename);
989
+					}
990 990
 
991
-                    $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
992
-                    $curr_img_dir = str_replace($filename, "", $curr_img_dir);
991
+					$curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
992
+					$curr_img_dir = str_replace($filename, "", $curr_img_dir);
993 993
 
994
-                    $img_name_arr = explode('.', $filename);
994
+					$img_name_arr = explode('.', $filename);
995 995
 
996
-                    $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
997
-                    if (!empty($img_name_arr) && count($img_name_arr) > 2) {
998
-                        $new_img_name_arr = $img_name_arr;
999
-                        if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
1000
-                            unset($new_img_name_arr[count($img_name_arr) - 1]);
1001
-                            $file_title = implode('.', $new_img_name_arr);
1002
-                        }
1003
-                    }
1004
-                    $file_title = sanitize_file_name($file_title);
1005
-                    $file_name = sanitize_file_name($filename);
996
+					$file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
997
+					if (!empty($img_name_arr) && count($img_name_arr) > 2) {
998
+						$new_img_name_arr = $img_name_arr;
999
+						if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
1000
+							unset($new_img_name_arr[count($img_name_arr) - 1]);
1001
+							$file_title = implode('.', $new_img_name_arr);
1002
+						}
1003
+					}
1004
+					$file_title = sanitize_file_name($file_title);
1005
+					$file_name = sanitize_file_name($filename);
1006 1006
 
1007
-                    $arr_file_type = wp_check_filetype($filename);
1007
+					$arr_file_type = wp_check_filetype($filename);
1008 1008
 
1009
-                    $uploaded_file_type = $arr_file_type['type'];
1009
+					$uploaded_file_type = $arr_file_type['type'];
1010 1010
 
1011
-                    // Set an array containing a list of acceptable formats
1012
-                    $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1011
+					// Set an array containing a list of acceptable formats
1012
+					$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1013 1013
 
1014
-                    // If the uploaded file is the right format
1015
-                    if (in_array($uploaded_file_type, $allowed_file_types)) {
1016
-                        if (!function_exists('wp_handle_upload')) {
1017
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1018
-                        }
1014
+					// If the uploaded file is the right format
1015
+					if (in_array($uploaded_file_type, $allowed_file_types)) {
1016
+						if (!function_exists('wp_handle_upload')) {
1017
+							require_once(ABSPATH . 'wp-admin/includes/file.php');
1018
+						}
1019 1019
 
1020
-                        if (!is_dir($geodir_uploadpath)) {
1021
-                            mkdir($geodir_uploadpath);
1022
-                        }
1020
+						if (!is_dir($geodir_uploadpath)) {
1021
+							mkdir($geodir_uploadpath);
1022
+						}
1023 1023
 
1024
-                        $external_img = false;
1025
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1026
-                        } else {
1027
-                            $external_img = true;
1028
-                        }
1024
+						$external_img = false;
1025
+						if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1026
+						} else {
1027
+							$external_img = true;
1028
+						}
1029 1029
 
1030
-                        if ($dummy || $external_img) {
1031
-                            $uploaded_file = array();
1032
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1030
+						if ($dummy || $external_img) {
1031
+							$uploaded_file = array();
1032
+							$uploaded = (array)fetch_remote_file($curr_img_url);
1033 1033
 
1034
-                            if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035
-                                $new_name = basename($uploaded['file']);
1036
-                                $uploaded_file = $uploaded;
1037
-                            }else{
1038
-                                print_r($uploaded);exit;
1039
-                            }
1040
-                            $external_img = false;
1041
-                        } else {
1042
-                            $new_name = $post_id . '_' . $file_name;
1034
+							if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035
+								$new_name = basename($uploaded['file']);
1036
+								$uploaded_file = $uploaded;
1037
+							}else{
1038
+								print_r($uploaded);exit;
1039
+							}
1040
+							$external_img = false;
1041
+						} else {
1042
+							$new_name = $post_id . '_' . $file_name;
1043 1043
 
1044
-                            if ($curr_img_dir == $sub_dir) {
1045
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1046
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1047
-                            } else {
1048
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1050
-                            }
1044
+							if ($curr_img_dir == $sub_dir) {
1045
+								$img_path = $geodir_uploadpath . '/' . $filename;
1046
+								$img_url = $geodir_uploadurl . '/' . $filename;
1047
+							} else {
1048
+								$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
+								$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1050
+							}
1051 1051
 
1052
-                            $uploaded_file = '';
1052
+							$uploaded_file = '';
1053 1053
 
1054
-                            if (file_exists($img_path)) {
1055
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1056
-                                $file_path = '';
1057
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1058
-                                $uploaded_file = true;
1059
-                                $file_path = $curr_img_dir . '/' . $filename;
1060
-                            }
1054
+							if (file_exists($img_path)) {
1055
+								$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1056
+								$file_path = '';
1057
+							} else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1058
+								$uploaded_file = true;
1059
+								$file_path = $curr_img_dir . '/' . $filename;
1060
+							}
1061 1061
 
1062
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
-                                unlink($img_path);
1064
-                        }
1062
+							if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
+								unlink($img_path);
1064
+						}
1065 1065
 
1066
-                        if (!empty($uploaded_file)) {
1067
-                            if (!isset($file_path) || !$file_path) {
1068
-                                $file_path = $sub_dir . '/' . $new_name;
1069
-                            }
1066
+						if (!empty($uploaded_file)) {
1067
+							if (!isset($file_path) || !$file_path) {
1068
+								$file_path = $sub_dir . '/' . $new_name;
1069
+							}
1070 1070
 
1071
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1071
+							$postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1072 1072
 
1073
-                            if ($menu_order == 1) {
1073
+							if ($menu_order == 1) {
1074 1074
 
1075
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1075
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1076 1076
 
1077
-                            }
1077
+							}
1078 1078
 
1079
-                            // Set up options array to add this file as an attachment
1080
-                            $attachment = array();
1081
-                            $attachment['post_id'] = $post_id;
1082
-                            $attachment['title'] = $file_title;
1083
-                            $attachment['content'] = '';
1084
-                            $attachment['file'] = $file_path;
1085
-                            $attachment['mime_type'] = $uploaded_file_type;
1086
-                            $attachment['menu_order'] = $menu_order;
1087
-                            $attachment['is_featured'] = 0;
1079
+							// Set up options array to add this file as an attachment
1080
+							$attachment = array();
1081
+							$attachment['post_id'] = $post_id;
1082
+							$attachment['title'] = $file_title;
1083
+							$attachment['content'] = '';
1084
+							$attachment['file'] = $file_path;
1085
+							$attachment['mime_type'] = $uploaded_file_type;
1086
+							$attachment['menu_order'] = $menu_order;
1087
+							$attachment['is_featured'] = 0;
1088 1088
 
1089
-                            $attachment_set = '';
1089
+							$attachment_set = '';
1090 1090
 
1091
-                            foreach ($attachment as $key => $val) {
1092
-                                if ($val != '')
1093
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1094
-                            }
1091
+							foreach ($attachment as $key => $val) {
1092
+								if ($val != '')
1093
+									$attachment_set .= $key . " = '" . $val . "', ";
1094
+							}
1095 1095
 
1096
-                            $attachment_set = trim($attachment_set, ", ");
1096
+							$attachment_set = trim($attachment_set, ", ");
1097
+
1098
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1097 1099
 
1098
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1100
+							$valid_file_ids[] = $wpdb->insert_id;
1101
+						}
1099 1102
 
1100
-                            $valid_file_ids[] = $wpdb->insert_id;
1101
-                        }
1103
+					}
1102 1104
 
1103
-                    }
1104 1105
 
1106
+				} else {
1107
+					$valid_file_ids[] = $find_image;
1105 1108
 
1106
-                } else {
1107
-                    $valid_file_ids[] = $find_image;
1108
-
1109
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1109
+					$postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1110 1110
 
1111
-                    $wpdb->query(
1112
-                        $wpdb->prepare(
1113
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1114
-                            array($menu_order, $split_img_path[1], $post_id)
1115
-                        )
1116
-                    );
1111
+					$wpdb->query(
1112
+						$wpdb->prepare(
1113
+							"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1114
+							array($menu_order, $split_img_path[1], $post_id)
1115
+						)
1116
+					);
1117 1117
 
1118
-                    if ($menu_order == 1)
1119
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1118
+					if ($menu_order == 1)
1119
+						$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1120 1120
 
1121
-                }
1121
+				}
1122 1122
 
1123 1123
 
1124
-            }
1124
+			}
1125 1125
 
1126
-            if (!empty($valid_file_ids)) {
1126
+			if (!empty($valid_file_ids)) {
1127 1127
 
1128
-                $remove_files = $valid_file_ids;
1128
+				$remove_files = $valid_file_ids;
1129 1129
 
1130
-                $remove_files_length = count($remove_files);
1131
-                $remove_files_format = array_fill(0, $remove_files_length, '%d');
1132
-                $format = implode(',', $remove_files_format);
1133
-                $valid_files_condition = " ID NOT IN ($format) AND ";
1130
+				$remove_files_length = count($remove_files);
1131
+				$remove_files_format = array_fill(0, $remove_files_length, '%d');
1132
+				$format = implode(',', $remove_files_format);
1133
+				$valid_files_condition = " ID NOT IN ($format) AND ";
1134 1134
 
1135
-            }
1135
+			}
1136 1136
 
1137
-            //Get and remove all old images of post from database to set by new order
1137
+			//Get and remove all old images of post from database to set by new order
1138 1138
 
1139
-            if (!empty($post_images)) {
1139
+			if (!empty($post_images)) {
1140 1140
 
1141
-                foreach ($post_images as $img) {
1141
+				foreach ($post_images as $img) {
1142 1142
 
1143
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1143
+					if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1144 1144
 
1145
-                        $invalid_files[] = (object)array('src' => $img->src);
1145
+						$invalid_files[] = (object)array('src' => $img->src);
1146 1146
 
1147
-                    }
1147
+					}
1148 1148
 
1149
-                }
1149
+				}
1150 1150
 
1151
-            }
1151
+			}
1152 1152
 
1153
-            $invalid_files = (object)$invalid_files;
1154
-        }
1153
+			$invalid_files = (object)$invalid_files;
1154
+		}
1155 1155
 
1156
-        $remove_files[] = $post_id;
1156
+		$remove_files[] = $post_id;
1157 1157
 
1158
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1158
+		$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1159 1159
 
1160
-        if (!empty($invalid_files))
1161
-            geodir_remove_attachments($invalid_files);
1162
-    }
1160
+		if (!empty($invalid_files))
1161
+			geodir_remove_attachments($invalid_files);
1162
+	}
1163 1163
 
1164 1164
 }
1165 1165
 
@@ -1173,12 +1173,12 @@  discard block
 block discarded – undo
1173 1173
 function geodir_remove_temp_images()
1174 1174
 {
1175 1175
 
1176
-    global $current_user;
1176
+	global $current_user;
1177 1177
 
1178
-    $uploads = wp_upload_dir();
1179
-    $uploads_dir = $uploads['path'];
1178
+	$uploads = wp_upload_dir();
1179
+	$uploads_dir = $uploads['path'];
1180 1180
 
1181
-    /*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1181
+	/*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1182 1182
 
1183 1183
 			$dirPath = $uploads_dir.'/temp_'.$current_user->data->ID;
1184 1184
 			if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
 			rmdir($dirPath);
1196 1196
 	}	*/
1197 1197
 
1198
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1199
-    geodir_delete_directory($dirname);
1198
+	$dirname = $uploads_dir . '/temp_' . $current_user->ID;
1199
+	geodir_delete_directory($dirname);
1200 1200
 }
1201 1201
 
1202 1202
 
@@ -1210,120 +1210,120 @@  discard block
 block discarded – undo
1210 1210
  */
1211 1211
 function geodir_delete_directory($dirname)
1212 1212
 {
1213
-    $dir_handle = '';
1214
-    if (is_dir($dirname))
1215
-        $dir_handle = opendir($dirname);
1216
-    if (!$dir_handle)
1217
-        return false;
1218
-    while ($file = readdir($dir_handle)) {
1219
-        if ($file != "." && $file != "..") {
1220
-            if (!is_dir($dirname . "/" . $file))
1221
-                unlink($dirname . "/" . $file);
1222
-            else
1223
-                geodir_delete_directory($dirname . '/' . $file);
1224
-        }
1225
-    }
1226
-    closedir($dir_handle);
1227
-    rmdir($dirname);
1228
-    return true;
1213
+	$dir_handle = '';
1214
+	if (is_dir($dirname))
1215
+		$dir_handle = opendir($dirname);
1216
+	if (!$dir_handle)
1217
+		return false;
1218
+	while ($file = readdir($dir_handle)) {
1219
+		if ($file != "." && $file != "..") {
1220
+			if (!is_dir($dirname . "/" . $file))
1221
+				unlink($dirname . "/" . $file);
1222
+			else
1223
+				geodir_delete_directory($dirname . '/' . $file);
1224
+		}
1225
+	}
1226
+	closedir($dir_handle);
1227
+	rmdir($dirname);
1228
+	return true;
1229 1229
 
1230 1230
 }
1231 1231
 
1232 1232
 
1233 1233
 if (!function_exists('geodir_remove_attachments')) {
1234
-    /**
1235
-     * Remove post attachments.
1236
-     *
1237
-     * @since 1.0.0
1238
-     * @package GeoDirectory
1239
-     * @param array $postcurr_images Array of image objects.
1240
-     */
1241
-    function geodir_remove_attachments($postcurr_images = array())
1242
-    {
1243
-        // Unlink all past images of post
1244
-        if (!empty($postcurr_images)) {
1245
-
1246
-            $uploads = wp_upload_dir();
1247
-            $uploads_dir = $uploads['path'];
1248
-
1249
-            foreach ($postcurr_images as $postimg) {
1250
-                $image_name_arr = explode('/', $postimg->src);
1251
-                $filename = end($image_name_arr);
1252
-                if (file_exists($uploads_dir . '/' . $filename))
1253
-                    unlink($uploads_dir . '/' . $filename);
1254
-            }
1255
-
1256
-        } // endif
1257
-        // Unlink all past images of post end
1258
-    }
1234
+	/**
1235
+	 * Remove post attachments.
1236
+	 *
1237
+	 * @since 1.0.0
1238
+	 * @package GeoDirectory
1239
+	 * @param array $postcurr_images Array of image objects.
1240
+	 */
1241
+	function geodir_remove_attachments($postcurr_images = array())
1242
+	{
1243
+		// Unlink all past images of post
1244
+		if (!empty($postcurr_images)) {
1245
+
1246
+			$uploads = wp_upload_dir();
1247
+			$uploads_dir = $uploads['path'];
1248
+
1249
+			foreach ($postcurr_images as $postimg) {
1250
+				$image_name_arr = explode('/', $postimg->src);
1251
+				$filename = end($image_name_arr);
1252
+				if (file_exists($uploads_dir . '/' . $filename))
1253
+					unlink($uploads_dir . '/' . $filename);
1254
+			}
1255
+
1256
+		} // endif
1257
+		// Unlink all past images of post end
1258
+	}
1259 1259
 }
1260 1260
 
1261 1261
 if (!function_exists('geodir_get_featured_image')) {
1262
-    /**
1263
-     * Gets the post featured image.
1264
-     *
1265
-     * @since 1.0.0
1266
-     * @package GeoDirectory
1267
-     * @global object $wpdb WordPress Database object.
1268
-     * @global object $post The current post object.
1269
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1270
-     * @param int|string $post_id The post ID.
1271
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1272
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1273
-     * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1274
-     * @return bool|object Image details as an object.
1275
-     */
1276
-    function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1277
-    {
1278
-
1279
-        /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1262
+	/**
1263
+	 * Gets the post featured image.
1264
+	 *
1265
+	 * @since 1.0.0
1266
+	 * @package GeoDirectory
1267
+	 * @global object $wpdb WordPress Database object.
1268
+	 * @global object $post The current post object.
1269
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1270
+	 * @param int|string $post_id The post ID.
1271
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1272
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1273
+	 * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1274
+	 * @return bool|object Image details as an object.
1275
+	 */
1276
+	function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1277
+	{
1278
+
1279
+		/*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1280 1280
         $img_arr['path'] = '';
1281 1281
         $img_arr['width'] = '';
1282 1282
         $img_arr['height'] = '';
1283 1283
         $img_arr['title'] = '';
1284 1284
         return (object)$img_arr;*/
1285
-        global $wpdb, $plugin_prefix, $post;
1286
-
1287
-        if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1288
-            $post_type = $post->post_type;
1289
-        } else {
1290
-            $post_type = get_post_type($post_id);
1291
-        }
1292
-
1293
-        if (!in_array($post_type, geodir_get_posttypes())) {
1294
-            return false;// if not a GD CPT return;
1295
-        }
1296
-
1297
-        $table = $plugin_prefix . $post_type . '_detail';
1298
-
1299
-        if (!$file) {
1300
-            if (isset($post->featured_image)) {
1301
-                $file = $post->featured_image;
1302
-            } else {
1303
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1304
-            }
1305
-        }
1306
-
1307
-        if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1308
-            $img_arr = array();
1309
-
1310
-            $file_info = pathinfo($file);
1311
-            $sub_dir = '';
1312
-            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1313
-                $sub_dir = stripslashes_deep($file_info['dirname']);
1314
-                if ((substr( $sub_dir, 0, 7 ) === "http://") || (substr( $sub_dir, 0, 8 ) === "https://")) {
1315
-                    $sub_dir = str_replace($uploads['baseurl'], "", $sub_dir);
1316
-                }
1317
-            }
1318
-
1319
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1320
-            $uploads_baseurl = $uploads['baseurl'];
1321
-            $uploads_path = $uploads['path'];
1322
-
1323
-            $file_name = $file_info['basename'];
1324
-
1325
-            $uploads_url = $uploads_baseurl . $sub_dir;
1326
-            /*
1285
+		global $wpdb, $plugin_prefix, $post;
1286
+
1287
+		if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1288
+			$post_type = $post->post_type;
1289
+		} else {
1290
+			$post_type = get_post_type($post_id);
1291
+		}
1292
+
1293
+		if (!in_array($post_type, geodir_get_posttypes())) {
1294
+			return false;// if not a GD CPT return;
1295
+		}
1296
+
1297
+		$table = $plugin_prefix . $post_type . '_detail';
1298
+
1299
+		if (!$file) {
1300
+			if (isset($post->featured_image)) {
1301
+				$file = $post->featured_image;
1302
+			} else {
1303
+				$file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1304
+			}
1305
+		}
1306
+
1307
+		if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1308
+			$img_arr = array();
1309
+
1310
+			$file_info = pathinfo($file);
1311
+			$sub_dir = '';
1312
+			if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1313
+				$sub_dir = stripslashes_deep($file_info['dirname']);
1314
+				if ((substr( $sub_dir, 0, 7 ) === "http://") || (substr( $sub_dir, 0, 8 ) === "https://")) {
1315
+					$sub_dir = str_replace($uploads['baseurl'], "", $sub_dir);
1316
+				}
1317
+			}
1318
+
1319
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1320
+			$uploads_baseurl = $uploads['baseurl'];
1321
+			$uploads_path = $uploads['path'];
1322
+
1323
+			$file_name = $file_info['basename'];
1324
+
1325
+			$uploads_url = $uploads_baseurl . $sub_dir;
1326
+			/*
1327 1327
              * Allows the filter of image src for such things as CDN change.
1328 1328
              *
1329 1329
              * @since 1.5.7
@@ -1332,158 +1332,158 @@  discard block
 block discarded – undo
1332 1332
              * @param string $uploads_url The server upload directory url.
1333 1333
              * @param string $uploads_baseurl The uploads dir base url.
1334 1334
              */
1335
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1336
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1337
-            $width = 0;
1338
-            $height = 0;
1339
-            if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1340
-                $imagesize = getimagesize($img_arr['path']);
1341
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1342
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1343
-            }
1344
-            $img_arr['width'] = $width;
1345
-            $img_arr['height'] = $height;
1346
-            $img_arr['title'] = '';
1347
-        } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1348
-            foreach ($post_images as $image) {
1349
-                return $image;
1350
-            }
1351
-        } else if ($no_image) {
1352
-            $img_arr = array();
1353
-
1354
-            $default_img = '';
1355
-            if (isset($post->default_category) && $post->default_category) {
1356
-                $default_cat = $post->default_category;
1357
-            } else {
1358
-                $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1359
-            }
1360
-
1361
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1362
-                $default_img = $default_catimg['src'];
1363
-            elseif ($no_image) {
1364
-                $default_img = get_option('geodir_listing_no_img');
1365
-            }
1366
-
1367
-            if (!empty($default_img)) {
1368
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1369
-                $uploads_baseurl = $uploads['baseurl'];
1370
-                $uploads_path = $uploads['path'];
1371
-
1372
-                $img_arr = array();
1373
-
1374
-                $file_info = pathinfo($default_img);
1375
-
1376
-                $file_name = $file_info['basename'];
1377
-
1378
-                $img_arr['src'] = $default_img;
1379
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1380
-
1381
-                $width = 0;
1382
-                $height = 0;
1383
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1384
-                    $imagesize = getimagesize($img_arr['path']);
1385
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1386
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1387
-                }
1388
-                $img_arr['width'] = $width;
1389
-                $img_arr['height'] = $height;
1390
-
1391
-                $img_arr['title'] = ''; // add the title to the array
1392
-            }
1393
-        }
1394
-
1395
-        if (!empty($img_arr))
1396
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1397
-        else
1398
-            return false;
1399
-    }
1335
+			$img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1336
+			$img_arr['path'] = $uploads_path . '/' . $file_name;
1337
+			$width = 0;
1338
+			$height = 0;
1339
+			if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1340
+				$imagesize = getimagesize($img_arr['path']);
1341
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1342
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1343
+			}
1344
+			$img_arr['width'] = $width;
1345
+			$img_arr['height'] = $height;
1346
+			$img_arr['title'] = '';
1347
+		} elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1348
+			foreach ($post_images as $image) {
1349
+				return $image;
1350
+			}
1351
+		} else if ($no_image) {
1352
+			$img_arr = array();
1353
+
1354
+			$default_img = '';
1355
+			if (isset($post->default_category) && $post->default_category) {
1356
+				$default_cat = $post->default_category;
1357
+			} else {
1358
+				$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1359
+			}
1360
+
1361
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1362
+				$default_img = $default_catimg['src'];
1363
+			elseif ($no_image) {
1364
+				$default_img = get_option('geodir_listing_no_img');
1365
+			}
1366
+
1367
+			if (!empty($default_img)) {
1368
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1369
+				$uploads_baseurl = $uploads['baseurl'];
1370
+				$uploads_path = $uploads['path'];
1371
+
1372
+				$img_arr = array();
1373
+
1374
+				$file_info = pathinfo($default_img);
1375
+
1376
+				$file_name = $file_info['basename'];
1377
+
1378
+				$img_arr['src'] = $default_img;
1379
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1380
+
1381
+				$width = 0;
1382
+				$height = 0;
1383
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1384
+					$imagesize = getimagesize($img_arr['path']);
1385
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1386
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1387
+				}
1388
+				$img_arr['width'] = $width;
1389
+				$img_arr['height'] = $height;
1390
+
1391
+				$img_arr['title'] = ''; // add the title to the array
1392
+			}
1393
+		}
1394
+
1395
+		if (!empty($img_arr))
1396
+			return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1397
+		else
1398
+			return false;
1399
+	}
1400 1400
 }
1401 1401
 
1402 1402
 if (!function_exists('geodir_show_featured_image')) {
1403
-    /**
1404
-     * Gets the post featured image.
1405
-     *
1406
-     * @since 1.0.0
1407
-     * @package GeoDirectory
1408
-     * @param int|string $post_id The post ID.
1409
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1410
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1411
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1412
-     * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1413
-     * @return bool|string Returns image html.
1414
-     */
1415
-    function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1416
-    {
1417
-        $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1418
-
1419
-        $html = geodir_show_image($image, $size, $no_image, false);
1420
-
1421
-        if (!empty($html) && $echo) {
1422
-            echo $html;
1423
-        } elseif (!empty($html)) {
1424
-            return $html;
1425
-        } else
1426
-            return false;
1427
-    }
1403
+	/**
1404
+	 * Gets the post featured image.
1405
+	 *
1406
+	 * @since 1.0.0
1407
+	 * @package GeoDirectory
1408
+	 * @param int|string $post_id The post ID.
1409
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1410
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1411
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1412
+	 * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1413
+	 * @return bool|string Returns image html.
1414
+	 */
1415
+	function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1416
+	{
1417
+		$image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1418
+
1419
+		$html = geodir_show_image($image, $size, $no_image, false);
1420
+
1421
+		if (!empty($html) && $echo) {
1422
+			echo $html;
1423
+		} elseif (!empty($html)) {
1424
+			return $html;
1425
+		} else
1426
+			return false;
1427
+	}
1428 1428
 }
1429 1429
 
1430 1430
 if (!function_exists('geodir_get_images')) {
1431
-    /**
1432
-     * Gets the post images.
1433
-     *
1434
-     * @since 1.0.0
1435
-     * @package GeoDirectory
1436
-     * @global object $wpdb WordPress Database object.
1437
-     * @param int $post_id The post ID.
1438
-     * @param string $img_size Optional. Thumbnail size.
1439
-     * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1440
-     * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1441
-     * @param int|string $limit Optional. Number of images.
1442
-     * @return array|bool Returns images as an array. Each item is an object.
1443
-     */
1444
-    function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1445
-    {
1446
-        global $wpdb;
1447
-        if ($limit) {
1448
-            $limit_q = " LIMIT $limit ";
1449
-        } else {
1450
-            $limit_q = '';
1451
-        }
1452
-        $not_featured = '';
1453
-        $sub_dir = '';
1454
-        if (!$add_featured)
1455
-            $not_featured = " AND is_featured = 0 ";
1456
-
1457
-        $arrImages = $wpdb->get_results(
1458
-            $wpdb->prepare(
1459
-                "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 ",
1460
-                array('%image%', $post_id)
1461
-            )
1462
-        );
1463
-
1464
-        $counter = 0;
1465
-        $return_arr = array();
1466
-
1467
-        if (!empty($arrImages)) {
1468
-            foreach ($arrImages as $attechment) {
1469
-
1470
-                $img_arr = array();
1471
-                $img_arr['id'] = $attechment->ID;
1472
-                $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1473
-
1474
-                $file_info = pathinfo($attechment->file);
1475
-
1476
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1477
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1478
-
1479
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1480
-                $uploads_baseurl = $uploads['baseurl'];
1481
-                $uploads_path = $uploads['path'];
1482
-
1483
-                $file_name = $file_info['basename'];
1484
-
1485
-                $uploads_url = $uploads_baseurl . $sub_dir;
1486
-                /*
1431
+	/**
1432
+	 * Gets the post images.
1433
+	 *
1434
+	 * @since 1.0.0
1435
+	 * @package GeoDirectory
1436
+	 * @global object $wpdb WordPress Database object.
1437
+	 * @param int $post_id The post ID.
1438
+	 * @param string $img_size Optional. Thumbnail size.
1439
+	 * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1440
+	 * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1441
+	 * @param int|string $limit Optional. Number of images.
1442
+	 * @return array|bool Returns images as an array. Each item is an object.
1443
+	 */
1444
+	function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1445
+	{
1446
+		global $wpdb;
1447
+		if ($limit) {
1448
+			$limit_q = " LIMIT $limit ";
1449
+		} else {
1450
+			$limit_q = '';
1451
+		}
1452
+		$not_featured = '';
1453
+		$sub_dir = '';
1454
+		if (!$add_featured)
1455
+			$not_featured = " AND is_featured = 0 ";
1456
+
1457
+		$arrImages = $wpdb->get_results(
1458
+			$wpdb->prepare(
1459
+				"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 ",
1460
+				array('%image%', $post_id)
1461
+			)
1462
+		);
1463
+
1464
+		$counter = 0;
1465
+		$return_arr = array();
1466
+
1467
+		if (!empty($arrImages)) {
1468
+			foreach ($arrImages as $attechment) {
1469
+
1470
+				$img_arr = array();
1471
+				$img_arr['id'] = $attechment->ID;
1472
+				$img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1473
+
1474
+				$file_info = pathinfo($attechment->file);
1475
+
1476
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1477
+					$sub_dir = stripslashes_deep($file_info['dirname']);
1478
+
1479
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1480
+				$uploads_baseurl = $uploads['baseurl'];
1481
+				$uploads_path = $uploads['path'];
1482
+
1483
+				$file_name = $file_info['basename'];
1484
+
1485
+				$uploads_url = $uploads_baseurl . $sub_dir;
1486
+				/*
1487 1487
                 * Allows the filter of image src for such things as CDN change.
1488 1488
                 *
1489 1489
                 * @since 1.5.7
@@ -1492,514 +1492,514 @@  discard block
 block discarded – undo
1492 1492
                 * @param string $uploads_url The server upload directory url.
1493 1493
                 * @param string $uploads_baseurl The uploads dir base url.
1494 1494
                 */
1495
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1496
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1497
-                $width = 0;
1498
-                $height = 0;
1499
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1500
-                    $imagesize = getimagesize($img_arr['path']);
1501
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1502
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1503
-                }
1504
-                $img_arr['width'] = $width;
1505
-                $img_arr['height'] = $height;
1506
-
1507
-                $img_arr['file'] = $file_name; // add the title to the array
1508
-                $img_arr['title'] = $attechment->title; // add the title to the array
1509
-                $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1510
-                $img_arr['content'] = $attechment->content; // add the description to the array
1511
-                $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1512
-
1513
-                $return_arr[] = (object)$img_arr;
1514
-
1515
-                $counter++;
1516
-            }
1517
-            return (object)$return_arr;
1518
-        } else if ($no_images) {
1519
-            $default_img = '';
1520
-            $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1521
-            $post_type = get_post_type($post_id);
1522
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1523
-                $default_img = $default_catimg['src'];
1524
-            elseif ($no_images) {
1525
-                $default_img = get_option('geodir_listing_no_img');
1526
-            }
1527
-
1528
-            if (!empty($default_img)) {
1529
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1495
+				$img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1496
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1497
+				$width = 0;
1498
+				$height = 0;
1499
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1500
+					$imagesize = getimagesize($img_arr['path']);
1501
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1502
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1503
+				}
1504
+				$img_arr['width'] = $width;
1505
+				$img_arr['height'] = $height;
1506
+
1507
+				$img_arr['file'] = $file_name; // add the title to the array
1508
+				$img_arr['title'] = $attechment->title; // add the title to the array
1509
+				$img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1510
+				$img_arr['content'] = $attechment->content; // add the description to the array
1511
+				$img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1512
+
1513
+				$return_arr[] = (object)$img_arr;
1514
+
1515
+				$counter++;
1516
+			}
1517
+			return (object)$return_arr;
1518
+		} else if ($no_images) {
1519
+			$default_img = '';
1520
+			$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1521
+			$post_type = get_post_type($post_id);
1522
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1523
+				$default_img = $default_catimg['src'];
1524
+			elseif ($no_images) {
1525
+				$default_img = get_option('geodir_listing_no_img');
1526
+			}
1527
+
1528
+			if (!empty($default_img)) {
1529
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1530 1530
                 
1531
-                $image_path = $default_img;
1532
-                if (!path_is_absolute($image_path)) {
1533
-                    $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1534
-                }
1535
-
1536
-                $file_info = pathinfo($default_img);
1537
-                $file_name = $file_info['basename'];
1538
-
1539
-                $width = '';
1540
-                $height = '';
1541
-                if (is_file($image_path) && file_exists($image_path)) {
1542
-                    $imagesize = getimagesize($image_path);
1543
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1544
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1545
-                }
1531
+				$image_path = $default_img;
1532
+				if (!path_is_absolute($image_path)) {
1533
+					$image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1534
+				}
1535
+
1536
+				$file_info = pathinfo($default_img);
1537
+				$file_name = $file_info['basename'];
1538
+
1539
+				$width = '';
1540
+				$height = '';
1541
+				if (is_file($image_path) && file_exists($image_path)) {
1542
+					$imagesize = getimagesize($image_path);
1543
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1544
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1545
+				}
1546 1546
                 
1547
-                $img_arr = array();
1548
-                $img_arr['src'] = $default_img;
1549
-                $img_arr['path'] = $image_path;
1550
-                $img_arr['width'] = $width;
1551
-                $img_arr['height'] = $height;
1552
-                $img_arr['file'] = $file_name; // add the title to the array
1553
-                $img_arr['title'] = $file_info['filename']; // add the title to the array
1554
-                $img_arr['content'] = $file_info['filename']; // add the description to the array
1555
-
1556
-                $return_arr[] = (object)$img_arr;
1557
-
1558
-                return $return_arr;
1559
-            } else
1560
-                return false;
1561
-        }
1562
-    }
1547
+				$img_arr = array();
1548
+				$img_arr['src'] = $default_img;
1549
+				$img_arr['path'] = $image_path;
1550
+				$img_arr['width'] = $width;
1551
+				$img_arr['height'] = $height;
1552
+				$img_arr['file'] = $file_name; // add the title to the array
1553
+				$img_arr['title'] = $file_info['filename']; // add the title to the array
1554
+				$img_arr['content'] = $file_info['filename']; // add the description to the array
1555
+
1556
+				$return_arr[] = (object)$img_arr;
1557
+
1558
+				return $return_arr;
1559
+			} else
1560
+				return false;
1561
+		}
1562
+	}
1563 1563
 }
1564 1564
 
1565 1565
 if (!function_exists('geodir_show_image')) {
1566
-    /**
1567
-     * Show image using image details.
1568
-     *
1569
-     * @since 1.0.0
1570
-     * @package GeoDirectory
1571
-     * @param array|object $request Image info either as an array or object.
1572
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1573
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1574
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1575
-     * @return bool|string Returns image html.
1576
-     */
1577
-    function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1578
-    {
1579
-        $image = new stdClass();
1580
-
1581
-        $html = '';
1582
-        if (!empty($request)) {
1583
-            if (!is_object($request)){
1584
-                $request = (object)$request;
1585
-            }
1586
-
1587
-            if (isset($request->src) && !isset($request->path)) {
1588
-                $request->path = $request->src;
1589
-            }
1590
-
1591
-            /*
1566
+	/**
1567
+	 * Show image using image details.
1568
+	 *
1569
+	 * @since 1.0.0
1570
+	 * @package GeoDirectory
1571
+	 * @param array|object $request Image info either as an array or object.
1572
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1573
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1574
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1575
+	 * @return bool|string Returns image html.
1576
+	 */
1577
+	function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1578
+	{
1579
+		$image = new stdClass();
1580
+
1581
+		$html = '';
1582
+		if (!empty($request)) {
1583
+			if (!is_object($request)){
1584
+				$request = (object)$request;
1585
+			}
1586
+
1587
+			if (isset($request->src) && !isset($request->path)) {
1588
+				$request->path = $request->src;
1589
+			}
1590
+
1591
+			/*
1592 1592
              * getimagesize() works faster from path than url so we try and get path if we can.
1593 1593
              */
1594
-            $upload_dir = wp_upload_dir();
1595
-            $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1596
-            $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1597
-            if (strpos($img_no_http, $upload_no_http) !== false) {
1598
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1599
-            }
1594
+			$upload_dir = wp_upload_dir();
1595
+			$img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1596
+			$upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1597
+			if (strpos($img_no_http, $upload_no_http) !== false) {
1598
+				$request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1599
+			}
1600 1600
             
1601
-            $width = 0;
1602
-            $height = 0;
1603
-            if (is_file($request->path) && file_exists($request->path)) {
1604
-                $imagesize = getimagesize($request->path);
1605
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1606
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1607
-            }
1608
-
1609
-            $image->src = $request->src;
1610
-            $image->width = $width;
1611
-            $image->height = $height;
1612
-
1613
-            $max_size = (object)geodir_get_imagesize($size);
1614
-
1615
-            if (!is_wp_error($max_size)) {
1616
-                if ($image->width) {
1617
-                    if ($image->height >= $image->width) {
1618
-                        $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1619
-                    } else if ($image->width < ($max_size->h)) {
1620
-                        $width_per = round((($image->width / $max_size->w) * 100), 2);
1621
-                    } else
1622
-                        $width_per = 100;
1623
-                }
1624
-
1625
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1626
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1627
-                } else {
1628
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1629
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1630
-                    }else{
1631
-                        //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1632
-                        //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1633
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1634
-
1635
-                    }
1636
-
1637
-                }
1638
-            }
1639
-        }
1640
-
1641
-        if (!empty($html) && $echo) {
1642
-            echo $html;
1643
-        } elseif (!empty($html)) {
1644
-            return $html;
1645
-        } else
1646
-            return false;
1647
-    }
1648
-}
1601
+			$width = 0;
1602
+			$height = 0;
1603
+			if (is_file($request->path) && file_exists($request->path)) {
1604
+				$imagesize = getimagesize($request->path);
1605
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1606
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1607
+			}
1649 1608
 
1650
-if (!function_exists('geodir_set_post_terms')) {
1651
-    /**
1652
-     * Set post Categories.
1653
-     *
1654
-     * @since 1.0.0
1655
-     * @package GeoDirectory
1656
-     * @global object $wpdb WordPress Database object.
1657
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1658
-     * @param int $post_id The post ID.
1659
-     * @param array $terms An array of term objects.
1660
-     * @param array $tt_ids An array of term taxonomy IDs.
1661
-     * @param string $taxonomy Taxonomy slug.
1662
-     */
1663
-    function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1664
-    {
1665
-        global $wpdb, $plugin_prefix;
1609
+			$image->src = $request->src;
1610
+			$image->width = $width;
1611
+			$image->height = $height;
1666 1612
 
1667
-        $post_type = get_post_type($post_id);
1613
+			$max_size = (object)geodir_get_imagesize($size);
1668 1614
 
1669
-        $table = $plugin_prefix . $post_type . '_detail';
1615
+			if (!is_wp_error($max_size)) {
1616
+				if ($image->width) {
1617
+					if ($image->height >= $image->width) {
1618
+						$width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1619
+					} else if ($image->width < ($max_size->h)) {
1620
+						$width_per = round((($image->width / $max_size->w) * 100), 2);
1621
+					} else
1622
+						$width_per = 100;
1623
+				}
1670 1624
 
1671
-        if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1625
+				if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1626
+					$html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1627
+				} else {
1628
+					if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1629
+						$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1630
+					}else{
1631
+						//$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1632
+						//$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1633
+						$html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1672 1634
 
1673
-            if ($taxonomy == $post_type . '_tags') {
1674
-                if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1675
-                    geodir_save_post_meta($post_id, 'post_tags', $terms);
1676
-                }
1677
-            } elseif ($taxonomy == $post_type . 'category') {
1678
-                $srcharr = array('"', '\\');
1679
-                $replarr = array("&quot;", '');
1635
+					}
1680 1636
 
1681
-                $post_obj = get_post($post_id);
1637
+				}
1638
+			}
1639
+		}
1640
+
1641
+		if (!empty($html) && $echo) {
1642
+			echo $html;
1643
+		} elseif (!empty($html)) {
1644
+			return $html;
1645
+		} else
1646
+			return false;
1647
+	}
1648
+}
1682 1649
 
1683
-                $cat_ids = array('0');
1684
-                if (is_array($tt_ids))
1685
-                    $cat_ids = $tt_ids;
1650
+if (!function_exists('geodir_set_post_terms')) {
1651
+	/**
1652
+	 * Set post Categories.
1653
+	 *
1654
+	 * @since 1.0.0
1655
+	 * @package GeoDirectory
1656
+	 * @global object $wpdb WordPress Database object.
1657
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1658
+	 * @param int $post_id The post ID.
1659
+	 * @param array $terms An array of term objects.
1660
+	 * @param array $tt_ids An array of term taxonomy IDs.
1661
+	 * @param string $taxonomy Taxonomy slug.
1662
+	 */
1663
+	function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1664
+	{
1665
+		global $wpdb, $plugin_prefix;
1666
+
1667
+		$post_type = get_post_type($post_id);
1668
+
1669
+		$table = $plugin_prefix . $post_type . '_detail';
1670
+
1671
+		if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1672
+
1673
+			if ($taxonomy == $post_type . '_tags') {
1674
+				if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1675
+					geodir_save_post_meta($post_id, 'post_tags', $terms);
1676
+				}
1677
+			} elseif ($taxonomy == $post_type . 'category') {
1678
+				$srcharr = array('"', '\\');
1679
+				$replarr = array("&quot;", '');
1686 1680
 
1681
+				$post_obj = get_post($post_id);
1687 1682
 
1688
-                if (!empty($cat_ids)) {
1689
-                    $cat_ids_array = $cat_ids;
1690
-                    $cat_ids_length = count($cat_ids_array);
1691
-                    $cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1692
-                    $format = implode(',', $cat_ids_format);
1683
+				$cat_ids = array('0');
1684
+				if (is_array($tt_ids))
1685
+					$cat_ids = $tt_ids;
1693 1686
 
1694
-                    $cat_ids_array_del = $cat_ids_array;
1695
-                    $cat_ids_array_del[] = $post_id;
1696 1687
 
1697
-                    $wpdb->get_var(
1698
-                        $wpdb->prepare(
1699
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1700
-                            $cat_ids_array_del
1701
-                        )
1702
-                    );
1688
+				if (!empty($cat_ids)) {
1689
+					$cat_ids_array = $cat_ids;
1690
+					$cat_ids_length = count($cat_ids_array);
1691
+					$cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1692
+					$format = implode(',', $cat_ids_format);
1703 1693
 
1694
+					$cat_ids_array_del = $cat_ids_array;
1695
+					$cat_ids_array_del[] = $post_id;
1704 1696
 
1705
-                    $post_term = $wpdb->get_col(
1706
-                        $wpdb->prepare(
1707
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1708
-                            $cat_ids_array
1709
-                        )
1710
-                    );
1697
+					$wpdb->get_var(
1698
+						$wpdb->prepare(
1699
+							"DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1700
+							$cat_ids_array_del
1701
+						)
1702
+					);
1711 1703
 
1712
-                }
1713 1704
 
1714
-                $post_marker_json = '';
1705
+					$post_term = $wpdb->get_col(
1706
+						$wpdb->prepare(
1707
+							"SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1708
+							$cat_ids_array
1709
+						)
1710
+					);
1715 1711
 
1716
-                if (!empty($post_term)):
1712
+				}
1717 1713
 
1718
-                    foreach ($post_term as $cat_id):
1714
+				$post_marker_json = '';
1719 1715
 
1720
-                        $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1721
-                        $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1716
+				if (!empty($post_term)):
1722 1717
 
1723
-                        $post_title = $post_obj->title;
1724
-                        $title = str_replace($srcharr, $replarr, $post_title);
1718
+					foreach ($post_term as $cat_id):
1725 1719
 
1726
-                        $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1727
-                        $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1720
+						$term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1721
+						$term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1728 1722
 
1729
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1730
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1723
+						$post_title = $post_obj->title;
1724
+						$title = str_replace($srcharr, $replarr, $post_title);
1731 1725
 
1732
-                        $json = '{';
1733
-                        $json .= '"id":"' . $post_id . '",';
1734
-                        $json .= '"lat_pos": "' . $lat . '",';
1735
-                        $json .= '"long_pos": "' . $lng . '",';
1736
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1737
-                        $json .= '"icon":"' . $term_icon . '",';
1738
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1739
-                        $json .= '}';
1726
+						$lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1727
+						$lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1740 1728
 
1729
+						$timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1730
+						$timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1741 1731
 
1742
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1743
-                            $post_marker_json = $json;
1732
+						$json = '{';
1733
+						$json .= '"id":"' . $post_id . '",';
1734
+						$json .= '"lat_pos": "' . $lat . '",';
1735
+						$json .= '"long_pos": "' . $lng . '",';
1736
+						$json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1737
+						$json .= '"icon":"' . $term_icon . '",';
1738
+						$json .= '"group":"catgroup' . $cat_id . '"';
1739
+						$json .= '}';
1744 1740
 
1745 1741
 
1746
-                        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)))) {
1742
+						if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1743
+							$post_marker_json = $json;
1747 1744
 
1748
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1745
+
1746
+						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)))) {
1747
+
1748
+							$json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1749 1749
 										post_title = %s,
1750 1750
 										json = %s
1751 1751
 										WHERE post_id = %d AND cat_id = %d ",
1752
-                                array($post_title, $json, $post_id, $cat_id));
1752
+								array($post_title, $json, $post_id, $cat_id));
1753 1753
 
1754
-                        } else {
1754
+						} else {
1755 1755
 
1756
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1756
+							$json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1757 1757
 										post_id = %d,
1758 1758
 										post_title = %s,
1759 1759
 										cat_id = %d,
1760 1760
 										json = %s",
1761
-                                array($post_id, $post_title, $cat_id, $json));
1761
+								array($post_id, $post_title, $cat_id, $json));
1762 1762
 
1763
-                        }
1763
+						}
1764 1764
 
1765
-                        $wpdb->query($json_query);
1765
+						$wpdb->query($json_query);
1766 1766
 
1767
-                    endforeach;
1767
+					endforeach;
1768 1768
 
1769
-                endif;
1769
+				endif;
1770 1770
 
1771
-                if (!empty($post_term) && is_array($post_term)) {
1772
-                    $categories = implode(',', $post_term);
1771
+				if (!empty($post_term) && is_array($post_term)) {
1772
+					$categories = implode(',', $post_term);
1773 1773
 
1774
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1774
+					if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1775 1775
 
1776
-                    if (empty($post_marker_json))
1777
-                        $post_marker_json = isset($json) ? $json : '';
1776
+					if (empty($post_marker_json))
1777
+						$post_marker_json = isset($json) ? $json : '';
1778 1778
 
1779
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1779
+					if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1780 1780
 
1781
-                        $wpdb->query(
1782
-                            $wpdb->prepare(
1783
-                                "UPDATE " . $table . " SET
1781
+						$wpdb->query(
1782
+							$wpdb->prepare(
1783
+								"UPDATE " . $table . " SET
1784 1784
 								" . $taxonomy . " = %s,
1785 1785
 								marker_json = %s
1786 1786
 								where post_id = %d",
1787
-                                array($categories, $post_marker_json, $post_id)
1788
-                            )
1789
-                        );
1787
+								array($categories, $post_marker_json, $post_id)
1788
+							)
1789
+						);
1790 1790
 
1791
-                        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1791
+						if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1792 1792
 
1793
-                            $categories = trim($categories, ',');
1793
+							$categories = trim($categories, ',');
1794 1794
 
1795
-                            if ($categories) {
1795
+							if ($categories) {
1796 1796
 
1797
-                                $categories = explode(',', $categories);
1797
+								$categories = explode(',', $categories);
1798 1798
 
1799
-                                $default_category = geodir_get_post_meta($post_id, 'default_category', true);
1799
+								$default_category = geodir_get_post_meta($post_id, 'default_category', true);
1800 1800
 
1801
-                                if (!in_array($default_category, $categories)) {
1801
+								if (!in_array($default_category, $categories)) {
1802 1802
 
1803
-                                    $wpdb->query(
1804
-                                        $wpdb->prepare(
1805
-                                            "UPDATE " . $table . " SET
1803
+									$wpdb->query(
1804
+										$wpdb->prepare(
1805
+											"UPDATE " . $table . " SET
1806 1806
 											default_category = %s
1807 1807
 											where post_id = %d",
1808
-                                            array($categories[0], $post_id)
1809
-                                        )
1810
-                                    );
1808
+											array($categories[0], $post_id)
1809
+										)
1810
+									);
1811 1811
 
1812
-                                    $default_category = $categories[0];
1812
+									$default_category = $categories[0];
1813 1813
 
1814
-                                }
1814
+								}
1815 1815
 
1816
-                                if ($default_category == '')
1817
-                                    $default_category = $categories[0];
1816
+								if ($default_category == '')
1817
+									$default_category = $categories[0];
1818 1818
 
1819
-                                geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1819
+								geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1820 1820
 
1821
-                            }
1821
+							}
1822 1822
 
1823
-                        }
1823
+						}
1824 1824
 
1825 1825
 
1826
-                    } else {
1826
+					} else {
1827 1827
 
1828
-                        $wpdb->query(
1829
-                            $wpdb->prepare(
1830
-                                "INSERT INTO " . $table . " SET
1828
+						$wpdb->query(
1829
+							$wpdb->prepare(
1830
+								"INSERT INTO " . $table . " SET
1831 1831
 								post_id = %d,
1832 1832
 								" . $taxonomy . " = %s,
1833 1833
 								marker_json = %s ",
1834 1834
 
1835
-                                array($post_id, $categories, $post_marker_json)
1836
-                            )
1837
-                        );
1838
-                    }
1839
-                }
1840
-            }
1841
-        }
1842
-    }
1835
+								array($post_id, $categories, $post_marker_json)
1836
+							)
1837
+						);
1838
+					}
1839
+				}
1840
+			}
1841
+		}
1842
+	}
1843 1843
 }
1844 1844
 
1845 1845
 if (!function_exists('geodir_get_infowindow_html')) {
1846
-    /**
1847
-     * Set post Map Marker info html.
1848
-     *
1849
-     * @since 1.0.0
1850
-     * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1851
-     * @since 1.6.16 Changes for disable review stars for certain post type.
1852
-     * @package GeoDirectory
1853
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
1854
-     * @global object $gd_session GeoDirectory Session object.
1855
-     * @param object $postinfo_obj The post details object.
1856
-     * @param string $post_preview Is this a post preview?.
1857
-     * @return mixed|string|void
1858
-     */
1859
-    function geodir_get_infowindow_html($postinfo_obj, $post_preview = '')
1860
-    {
1861
-        global $preview, $gd_session;
1862
-        $srcharr = array("'", "/", "-", '"', '\\');
1863
-        $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1864
-
1865
-        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1866
-            $ID = '';
1867
-            $plink = '';
1868
-
1869
-            if (isset($postinfo_obj->pid)) {
1870
-                $ID = $postinfo_obj->pid;
1871
-                $plink = get_permalink($ID);
1872
-            }
1873
-
1874
-            $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1875
-            $lat = $postinfo_obj->post_latitude;
1876
-            $lng = $postinfo_obj->post_longitude;
1877
-        } else {
1878
-            $ID = $postinfo_obj->post_id;
1879
-            $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1880
-            $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1881
-            $plink = get_permalink($ID);
1882
-            $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1883
-            $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1884
-        }
1846
+	/**
1847
+	 * Set post Map Marker info html.
1848
+	 *
1849
+	 * @since 1.0.0
1850
+	 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1851
+	 * @since 1.6.16 Changes for disable review stars for certain post type.
1852
+	 * @package GeoDirectory
1853
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
1854
+	 * @global object $gd_session GeoDirectory Session object.
1855
+	 * @param object $postinfo_obj The post details object.
1856
+	 * @param string $post_preview Is this a post preview?.
1857
+	 * @return mixed|string|void
1858
+	 */
1859
+	function geodir_get_infowindow_html($postinfo_obj, $post_preview = '')
1860
+	{
1861
+		global $preview, $gd_session;
1862
+		$srcharr = array("'", "/", "-", '"', '\\');
1863
+		$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1864
+
1865
+		if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1866
+			$ID = '';
1867
+			$plink = '';
1868
+
1869
+			if (isset($postinfo_obj->pid)) {
1870
+				$ID = $postinfo_obj->pid;
1871
+				$plink = get_permalink($ID);
1872
+			}
1873
+
1874
+			$title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1875
+			$lat = $postinfo_obj->post_latitude;
1876
+			$lng = $postinfo_obj->post_longitude;
1877
+		} else {
1878
+			$ID = $postinfo_obj->post_id;
1879
+			$title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1880
+			$title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1881
+			$plink = get_permalink($ID);
1882
+			$lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1883
+			$lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1884
+		}
1885 1885
         
1886
-        $post_type = $ID ? get_post_type($ID) : '';
1887
-
1888
-        // filter field as per price package
1889
-        global $geodir_addon_list;
1890
-        if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1891
-            $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1892
-            $field_name = 'geodir_contact';
1893
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1894
-                $contact = '';
1895
-            }
1896
-
1897
-            $field_name = 'geodir_timing';
1898
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1899
-                $timing = '';
1900
-            }
1901
-        }
1902
-
1903
-        if ($lat && $lng) {
1904
-            ob_start(); ?>
1886
+		$post_type = $ID ? get_post_type($ID) : '';
1887
+
1888
+		// filter field as per price package
1889
+		global $geodir_addon_list;
1890
+		if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1891
+			$package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1892
+			$field_name = 'geodir_contact';
1893
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1894
+				$contact = '';
1895
+			}
1896
+
1897
+			$field_name = 'geodir_timing';
1898
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1899
+				$timing = '';
1900
+			}
1901
+		}
1902
+
1903
+		if ($lat && $lng) {
1904
+			ob_start(); ?>
1905 1905
             <div class="gd-bubble" style="">
1906 1906
                 <div class="gd-bubble-inside">
1907 1907
                     <?php
1908
-                    $comment_count = '';
1909
-                    $rating_star = '';
1910
-                    if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1911
-                        $rating_star = '';
1912
-                        $comment_count = geodir_get_review_count_total($ID);
1913
-
1914
-                        if (!$preview) {
1915
-                            $post_avgratings = geodir_get_post_rating($ID);
1916
-
1917
-                            $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1918
-
1919
-                            /**
1920
-                             * Filter to change rating stars
1921
-                             *
1922
-                             * You can use this filter to change Rating stars.
1923
-                             *
1924
-                             * @since 1.0.0
1925
-                             * @package GeoDirectory
1926
-                             * @param string $rating_star Rating stars.
1927
-                             * @param float $post_avgratings Average ratings of the post.
1928
-                             * @param int $ID The post ID.
1929
-                             */
1930
-                            $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1931
-                        }
1932
-                    }
1933
-                    ?>
1908
+					$comment_count = '';
1909
+					$rating_star = '';
1910
+					if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1911
+						$rating_star = '';
1912
+						$comment_count = geodir_get_review_count_total($ID);
1913
+
1914
+						if (!$preview) {
1915
+							$post_avgratings = geodir_get_post_rating($ID);
1916
+
1917
+							$rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1918
+
1919
+							/**
1920
+							 * Filter to change rating stars
1921
+							 *
1922
+							 * You can use this filter to change Rating stars.
1923
+							 *
1924
+							 * @since 1.0.0
1925
+							 * @package GeoDirectory
1926
+							 * @param string $rating_star Rating stars.
1927
+							 * @param float $post_avgratings Average ratings of the post.
1928
+							 * @param int $ID The post ID.
1929
+							 */
1930
+							$rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1931
+						}
1932
+					}
1933
+					?>
1934 1934
                     <div class="geodir-bubble_desc">
1935 1935
                         <h4>
1936 1936
                             <a href="<?php if ($plink != '') {
1937
-                                echo $plink;
1938
-                            } else {
1939
-                                echo 'javascript:void(0);';
1940
-                            } ?>"><?php echo $title; ?></a>
1937
+								echo $plink;
1938
+							} else {
1939
+								echo 'javascript:void(0);';
1940
+							} ?>"><?php echo $title; ?></a>
1941 1941
                         </h4>
1942 1942
                         <?php
1943
-                        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1944
-                            $post_images = array();
1945
-                            if (!empty($postinfo_obj->post_images)) {
1946
-                                $post_images = explode(",", $postinfo_obj->post_images);
1947
-                            }
1948
-
1949
-                            if (!empty($post_images)) {
1950
-                                ?>
1943
+						if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1944
+							$post_images = array();
1945
+							if (!empty($postinfo_obj->post_images)) {
1946
+								$post_images = explode(",", $postinfo_obj->post_images);
1947
+							}
1948
+
1949
+							if (!empty($post_images)) {
1950
+								?>
1951 1951
                                 <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
1952
-                                        echo $plink;
1953
-                                    } else {
1954
-                                        echo 'javascript:void(0);';
1955
-                                    } ?>"><img alt="bubble image" style="max-height:50px;"
1952
+										echo $plink;
1953
+									} else {
1954
+										echo 'javascript:void(0);';
1955
+									} ?>"><img alt="bubble image" style="max-height:50px;"
1956 1956
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1957 1957
                             <?php
1958
-                            }else{
1959
-                                echo '<div class="geodir-bubble_image"></div>';
1960
-                            }
1961
-                        } else {
1962
-                            if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1963
-                                ?>
1958
+							}else{
1959
+								echo '<div class="geodir-bubble_image"></div>';
1960
+							}
1961
+						} else {
1962
+							if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1963
+								?>
1964 1964
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1965 1965
                             <?php
1966
-                            }else{
1967
-                                echo '<div class="geodir-bubble_image"></div>';
1968
-                            }
1969
-                        }
1970
-                        ?>
1966
+							}else{
1967
+								echo '<div class="geodir-bubble_image"></div>';
1968
+							}
1969
+						}
1970
+						?>
1971 1971
                         <div class="geodir-bubble-meta-side">
1972 1972
                             <?php
1973
-                            /**
1974
-                             * Fires before the meta info in the map info window.
1975
-                             *
1976
-                             * This can be used to add more info to the map info window before the normal meta info.
1977
-                             *
1978
-                             * @since 1.5.4
1979
-                             * @param int $ID The post id.
1980
-                             * @param object $postinfo_obj The posts info as an object.
1981
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1982
-                             */
1983
-                            do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1984
-
1985
-                            echo geodir_show_listing_info('mapbubble');
1986
-
1987
-                            /**
1988
-                             * Fires after the meta info in the map info window.
1989
-                             *
1990
-                             * This can be used to add more info to the map info window after the normal meta info.
1991
-                             *
1992
-                             * @since 1.4.2
1993
-                             * @param object $postinfo_obj The posts info as an object.
1994
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1995
-                             */
1996
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1997
-                            ?>
1973
+							/**
1974
+							 * Fires before the meta info in the map info window.
1975
+							 *
1976
+							 * This can be used to add more info to the map info window before the normal meta info.
1977
+							 *
1978
+							 * @since 1.5.4
1979
+							 * @param int $ID The post id.
1980
+							 * @param object $postinfo_obj The posts info as an object.
1981
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1982
+							 */
1983
+							do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1984
+
1985
+							echo geodir_show_listing_info('mapbubble');
1986
+
1987
+							/**
1988
+							 * Fires after the meta info in the map info window.
1989
+							 *
1990
+							 * This can be used to add more info to the map info window after the normal meta info.
1991
+							 *
1992
+							 * @since 1.4.2
1993
+							 * @param object $postinfo_obj The posts info as an object.
1994
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1995
+							 */
1996
+							do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1997
+							?>
1998 1998
                         </div>
1999 1999
                         <?php
2000
-                        if ($ID) {
2001
-                            $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2002
-                            ?>
2000
+						if ($ID) {
2001
+							$post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2002
+							?>
2003 2003
                             <div class="geodir-bubble-meta-fade"></div>
2004 2004
                             <div class="geodir-bubble-meta-bottom">
2005 2005
                                 <?php if ($rating_star != '') { ?>
@@ -2015,69 +2015,69 @@  discard block
 block discarded – undo
2015 2015
                 </div>
2016 2016
             </div>
2017 2017
             <?php
2018
-            $html = ob_get_clean();
2019
-            /**
2020
-             * Filter to change infowindow html
2021
-             *
2022
-             * You can use this filter to change infowindow html.
2023
-             *
2024
-             * @since 1.0.0
2025
-             * @package GeoDirectory
2026
-             * @param string $html Infowindow html.
2027
-             * @param object $postinfo_obj The Post object.
2028
-             * @param bool|string $post_preview Is this a post preview?
2029
-             */
2030
-            $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2031
-            return $html;
2032
-        }
2033
-    }
2018
+			$html = ob_get_clean();
2019
+			/**
2020
+			 * Filter to change infowindow html
2021
+			 *
2022
+			 * You can use this filter to change infowindow html.
2023
+			 *
2024
+			 * @since 1.0.0
2025
+			 * @package GeoDirectory
2026
+			 * @param string $html Infowindow html.
2027
+			 * @param object $postinfo_obj The Post object.
2028
+			 * @param bool|string $post_preview Is this a post preview?
2029
+			 */
2030
+			$html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2031
+			return $html;
2032
+		}
2033
+	}
2034 2034
 }
2035 2035
 
2036 2036
 
2037 2037
 if (!function_exists('geodir_new_post_default_status')) {
2038
-    /**
2039
-     * Default post status for new posts.
2040
-     *
2041
-     * @since 1.0.0
2042
-     * @package GeoDirectory
2043
-     * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2044
-     */
2045
-    function geodir_new_post_default_status()
2046
-    {
2047
-        if (get_option('geodir_new_post_default_status'))
2048
-            return get_option('geodir_new_post_default_status');
2049
-        else
2050
-            return 'publish';
2051
-
2052
-    }
2038
+	/**
2039
+	 * Default post status for new posts.
2040
+	 *
2041
+	 * @since 1.0.0
2042
+	 * @package GeoDirectory
2043
+	 * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2044
+	 */
2045
+	function geodir_new_post_default_status()
2046
+	{
2047
+		if (get_option('geodir_new_post_default_status'))
2048
+			return get_option('geodir_new_post_default_status');
2049
+		else
2050
+			return 'publish';
2051
+
2052
+	}
2053 2053
 }
2054 2054
 
2055 2055
 if (!function_exists('geodir_change_post_status')) {
2056
-    /**
2057
-     * Change post status of a post.
2058
-     *
2059
-     * @global object $wpdb WordPress Database object.
2060
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2061
-     * @param int|string $post_id The post ID.
2062
-     * @param string $status New post status. Ex: draft, publish etc.
2063
-     */
2064
-    function geodir_change_post_status($post_id = '', $status = '')
2065
-    {
2066
-        global $wpdb, $plugin_prefix;
2067
-
2068
-        $post_type = get_post_type($post_id);
2069
-
2070
-        $table = $plugin_prefix . $post_type . '_detail';
2071
-
2072
-        $wpdb->query(
2073
-            $wpdb->prepare(
2074
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2075
-                array($status, $post_id)
2076
-            )
2077
-        );
2078
-
2079
-
2080
-    }
2056
+	/**
2057
+	 * Change post status of a post.
2058
+	 *
2059
+	 * @global object $wpdb WordPress Database object.
2060
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2061
+	 * @param int|string $post_id The post ID.
2062
+	 * @param string $status New post status. Ex: draft, publish etc.
2063
+	 */
2064
+	function geodir_change_post_status($post_id = '', $status = '')
2065
+	{
2066
+		global $wpdb, $plugin_prefix;
2067
+
2068
+		$post_type = get_post_type($post_id);
2069
+
2070
+		$table = $plugin_prefix . $post_type . '_detail';
2071
+
2072
+		$wpdb->query(
2073
+			$wpdb->prepare(
2074
+				"UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2075
+				array($status, $post_id)
2076
+			)
2077
+		);
2078
+
2079
+
2080
+	}
2081 2081
 }
2082 2082
 
2083 2083
 /**
@@ -2091,13 +2091,13 @@  discard block
 block discarded – undo
2091 2091
  */
2092 2092
 function geodir_set_post_status($pid, $status)
2093 2093
 {
2094
-    if ($pid) {
2095
-        global $wpdb;
2096
-        $my_post = array();
2097
-        $my_post['post_status'] = $status;
2098
-        $my_post['ID'] = $pid;
2099
-        $last_postid = wp_update_post($my_post);
2100
-    }
2094
+	if ($pid) {
2095
+		global $wpdb;
2096
+		$my_post = array();
2097
+		$my_post['post_status'] = $status;
2098
+		$my_post['ID'] = $pid;
2099
+		$last_postid = wp_update_post($my_post);
2100
+	}
2101 2101
 }
2102 2102
 
2103 2103
 
@@ -2113,384 +2113,384 @@  discard block
 block discarded – undo
2113 2113
  */
2114 2114
 function geodir_update_poststatus($new_status, $old_status, $post)
2115 2115
 {
2116
-    global $wpdb;
2116
+	global $wpdb;
2117 2117
 
2118
-    $geodir_posttypes = geodir_get_posttypes();
2118
+	$geodir_posttypes = geodir_get_posttypes();
2119 2119
 
2120
-    if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2120
+	if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2121 2121
 
2122
-        geodir_change_post_status($post->ID, $new_status);
2123
-    }
2122
+		geodir_change_post_status($post->ID, $new_status);
2123
+	}
2124 2124
 }
2125 2125
 
2126 2126
 
2127 2127
 if (!function_exists('geodir_update_listing_info')) {
2128
-    /**
2129
-     * Update post info.
2130
-     *
2131
-     * @since 1.0.0
2132
-     * @package GeoDirectory
2133
-     * @global object $wpdb WordPress Database object.
2134
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2135
-     * @param int $updatingpost The updating post ID.
2136
-     * @param int $temppost The temporary post ID.
2137
-     * @todo fix post_id variable
2138
-     */
2139
-    function geodir_update_listing_info($updatingpost, $temppost)
2140
-    {
2141
-
2142
-        global $wpdb, $plugin_prefix;
2143
-
2144
-        $post_type = get_post_type($post_id);
2145
-
2146
-        $table = $plugin_prefix . $post_type . '_detail';
2147
-
2148
-        $wpdb->query(
2149
-            $wpdb->prepare(
2150
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2151
-                array($updatingpost, $temppost)
2152
-            )
2153
-        );
2154
-
2155
-        $wpdb->query(
2156
-            $wpdb->prepare(
2157
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2158
-                array($updatingpost, $temppost)
2159
-            )
2160
-        );
2161
-
2162
-        /* Update Attachments*/
2163
-
2164
-        $wpdb->query(
2165
-            $wpdb->prepare(
2166
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2167
-                array($updatingpost, $temppost)
2168
-            )
2169
-        );
2170
-
2171
-    }
2128
+	/**
2129
+	 * Update post info.
2130
+	 *
2131
+	 * @since 1.0.0
2132
+	 * @package GeoDirectory
2133
+	 * @global object $wpdb WordPress Database object.
2134
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2135
+	 * @param int $updatingpost The updating post ID.
2136
+	 * @param int $temppost The temporary post ID.
2137
+	 * @todo fix post_id variable
2138
+	 */
2139
+	function geodir_update_listing_info($updatingpost, $temppost)
2140
+	{
2141
+
2142
+		global $wpdb, $plugin_prefix;
2143
+
2144
+		$post_type = get_post_type($post_id);
2145
+
2146
+		$table = $plugin_prefix . $post_type . '_detail';
2147
+
2148
+		$wpdb->query(
2149
+			$wpdb->prepare(
2150
+				"UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2151
+				array($updatingpost, $temppost)
2152
+			)
2153
+		);
2154
+
2155
+		$wpdb->query(
2156
+			$wpdb->prepare(
2157
+				"UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2158
+				array($updatingpost, $temppost)
2159
+			)
2160
+		);
2161
+
2162
+		/* Update Attachments*/
2163
+
2164
+		$wpdb->query(
2165
+			$wpdb->prepare(
2166
+				"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2167
+				array($updatingpost, $temppost)
2168
+			)
2169
+		);
2170
+
2171
+	}
2172 2172
 }
2173 2173
 
2174 2174
 
2175 2175
 if (!function_exists('geodir_delete_listing_info')) {
2176
-    /**
2177
-     * Delete Listing info from details table for the given post id.
2178
-     *
2179
-     * @since 1.0.0
2180
-     * @package GeoDirectory
2181
-     * @global object $wpdb WordPress Database object.
2182
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2183
-     * @param int $deleted_postid The post ID.
2184
-     * @param bool $force Optional. Do you want to force delete it? Default: false.
2185
-     * @return bool|void
2186
-     */
2187
-    function geodir_delete_listing_info($deleted_postid, $force = false)
2188
-    {
2189
-        global $wpdb, $plugin_prefix;
2190
-
2191
-        // check for multisite deletions
2192
-        if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2193
-        } else {
2194
-            return;
2195
-        }
2196
-
2197
-        $post_type = get_post_type($deleted_postid);
2198
-
2199
-        $all_postypes = geodir_get_posttypes();
2200
-
2201
-        if (!in_array($post_type, $all_postypes))
2202
-            return false;
2203
-
2204
-        $table = $plugin_prefix . $post_type . '_detail';
2205
-
2206
-        /* Delete custom post meta*/
2207
-        $wpdb->query(
2208
-            $wpdb->prepare(
2209
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2210
-                array($deleted_postid)
2211
-            )
2212
-        );
2213
-
2214
-        /* Delete post map icons*/
2215
-
2216
-        $wpdb->query(
2217
-            $wpdb->prepare(
2218
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2219
-                array($deleted_postid)
2220
-            )
2221
-        );
2222
-
2223
-        /* Delete Attachments*/
2224
-        $postcurr_images = geodir_get_images($deleted_postid);
2225
-
2226
-        $wpdb->query(
2227
-            $wpdb->prepare(
2228
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2229
-                array($deleted_postid)
2230
-            )
2231
-        );
2232
-        geodir_remove_attachments($postcurr_images);
2233
-
2234
-    }
2176
+	/**
2177
+	 * Delete Listing info from details table for the given post id.
2178
+	 *
2179
+	 * @since 1.0.0
2180
+	 * @package GeoDirectory
2181
+	 * @global object $wpdb WordPress Database object.
2182
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2183
+	 * @param int $deleted_postid The post ID.
2184
+	 * @param bool $force Optional. Do you want to force delete it? Default: false.
2185
+	 * @return bool|void
2186
+	 */
2187
+	function geodir_delete_listing_info($deleted_postid, $force = false)
2188
+	{
2189
+		global $wpdb, $plugin_prefix;
2190
+
2191
+		// check for multisite deletions
2192
+		if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2193
+		} else {
2194
+			return;
2195
+		}
2196
+
2197
+		$post_type = get_post_type($deleted_postid);
2198
+
2199
+		$all_postypes = geodir_get_posttypes();
2200
+
2201
+		if (!in_array($post_type, $all_postypes))
2202
+			return false;
2203
+
2204
+		$table = $plugin_prefix . $post_type . '_detail';
2205
+
2206
+		/* Delete custom post meta*/
2207
+		$wpdb->query(
2208
+			$wpdb->prepare(
2209
+				"DELETE FROM " . $table . " WHERE `post_id` = %d",
2210
+				array($deleted_postid)
2211
+			)
2212
+		);
2213
+
2214
+		/* Delete post map icons*/
2215
+
2216
+		$wpdb->query(
2217
+			$wpdb->prepare(
2218
+				"DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2219
+				array($deleted_postid)
2220
+			)
2221
+		);
2222
+
2223
+		/* Delete Attachments*/
2224
+		$postcurr_images = geodir_get_images($deleted_postid);
2225
+
2226
+		$wpdb->query(
2227
+			$wpdb->prepare(
2228
+				"DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2229
+				array($deleted_postid)
2230
+			)
2231
+		);
2232
+		geodir_remove_attachments($postcurr_images);
2233
+
2234
+	}
2235 2235
 }
2236 2236
 
2237 2237
 
2238 2238
 if (!function_exists('geodir_add_to_favorite')) {
2239
-    /**
2240
-     * This function would add listing to favorite listing.
2241
-     *
2242
-     * @since 1.0.0
2243
-     * @package GeoDirectory
2244
-     * @global object $current_user Current user object.
2245
-     * @param int $post_id The post ID.
2246
-     */
2247
-    function geodir_add_to_favorite($post_id)
2248
-    {
2249
-
2250
-        global $current_user;
2251
-
2252
-        /**
2253
-         * Filter to modify "Unfavorite" text
2254
-         *
2255
-         * You can use this filter to rename "Unfavorite" text to something else.
2256
-         *
2257
-         * @since 1.0.0
2258
-         * @package GeoDirectory
2259
-         */
2260
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2261
-
2262
-        /**
2263
-         * Filter to modify "Remove from Favorites" text
2264
-         *
2265
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2266
-         *
2267
-         * @since 1.0.0
2268
-         * @package GeoDirectory
2269
-         */
2270
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2271
-
2272
-        /**
2273
-         * Filter to modify "fa fa-heart" icon
2274
-         *
2275
-         * You can use this filter to change "fa fa-heart" icon to something else.
2276
-         *
2277
-         * @since 1.0.0
2278
-         * @package GeoDirectory
2279
-         */
2280
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2281
-
2282
-        $user_meta_data = array();
2283
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2284
-
2285
-        if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2286
-            $user_meta_data[] = $post_id;
2287
-        }
2239
+	/**
2240
+	 * This function would add listing to favorite listing.
2241
+	 *
2242
+	 * @since 1.0.0
2243
+	 * @package GeoDirectory
2244
+	 * @global object $current_user Current user object.
2245
+	 * @param int $post_id The post ID.
2246
+	 */
2247
+	function geodir_add_to_favorite($post_id)
2248
+	{
2249
+
2250
+		global $current_user;
2251
+
2252
+		/**
2253
+		 * Filter to modify "Unfavorite" text
2254
+		 *
2255
+		 * You can use this filter to rename "Unfavorite" text to something else.
2256
+		 *
2257
+		 * @since 1.0.0
2258
+		 * @package GeoDirectory
2259
+		 */
2260
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2261
+
2262
+		/**
2263
+		 * Filter to modify "Remove from Favorites" text
2264
+		 *
2265
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2266
+		 *
2267
+		 * @since 1.0.0
2268
+		 * @package GeoDirectory
2269
+		 */
2270
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2271
+
2272
+		/**
2273
+		 * Filter to modify "fa fa-heart" icon
2274
+		 *
2275
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2276
+		 *
2277
+		 * @since 1.0.0
2278
+		 * @package GeoDirectory
2279
+		 */
2280
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2281
+
2282
+		$user_meta_data = array();
2283
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2284
+
2285
+		if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2286
+			$user_meta_data[] = $post_id;
2287
+		}
2288
+
2289
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2290
+
2291
+		/**
2292
+		 * Called before adding the post from favourites.
2293
+		 *
2294
+		 * @since 1.0.0
2295
+		 * @package GeoDirectory
2296
+		 * @param int $post_id The post ID.
2297
+		 */
2298
+		do_action('geodir_before_add_from_favorite', $post_id);
2299
+
2300
+		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>';
2301
+
2302
+		/**
2303
+		 * Called after adding the post from favourites.
2304
+		 *
2305
+		 * @since 1.0.0
2306
+		 * @package GeoDirectory
2307
+		 * @param int $post_id The post ID.
2308
+		 */
2309
+		do_action('geodir_after_add_from_favorite', $post_id);
2288 2310
 
2289
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2290
-
2291
-        /**
2292
-         * Called before adding the post from favourites.
2293
-         *
2294
-         * @since 1.0.0
2295
-         * @package GeoDirectory
2296
-         * @param int $post_id The post ID.
2297
-         */
2298
-        do_action('geodir_before_add_from_favorite', $post_id);
2299
-
2300
-        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>';
2301
-
2302
-        /**
2303
-         * Called after adding the post from favourites.
2304
-         *
2305
-         * @since 1.0.0
2306
-         * @package GeoDirectory
2307
-         * @param int $post_id The post ID.
2308
-         */
2309
-        do_action('geodir_after_add_from_favorite', $post_id);
2310
-
2311
-    }
2311
+	}
2312 2312
 }
2313 2313
 
2314 2314
 if (!function_exists('geodir_remove_from_favorite')) {
2315
-    /**
2316
-     * This function would remove the favourited property earlier.
2317
-     *
2318
-     * @since 1.0.0
2319
-     * @package GeoDirectory
2320
-     * @global object $current_user Current user object.
2321
-     * @param int $post_id The post ID.
2322
-     */
2323
-    function geodir_remove_from_favorite($post_id)
2324
-    {
2325
-        global $current_user;
2326
-
2327
-        /**
2328
-         * Filter to modify "Add to Favorites" text
2329
-         *
2330
-         * You can use this filter to rename "Add to Favorites" text to something else.
2331
-         *
2332
-         * @since 1.0.0
2333
-         * @package GeoDirectory
2334
-         */
2335
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2336
-
2337
-        /**
2338
-         * Filter to modify "Favourite" text
2339
-         *
2340
-         * You can use this filter to rename "Favourite" text to something else.
2341
-         *
2342
-         * @since 1.0.0
2343
-         * @package GeoDirectory
2344
-         */
2345
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2346
-
2347
-        /**
2348
-         * Filter to modify "fa fa-heart" icon
2349
-         *
2350
-         * You can use this filter to change "fa fa-heart" icon to something else.
2351
-         *
2352
-         * @since 1.0.0
2353
-         * @package GeoDirectory
2354
-         */
2355
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2356
-
2357
-        $user_meta_data = array();
2358
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2359
-
2360
-        if (!empty($user_meta_data)) {
2315
+	/**
2316
+	 * This function would remove the favourited property earlier.
2317
+	 *
2318
+	 * @since 1.0.0
2319
+	 * @package GeoDirectory
2320
+	 * @global object $current_user Current user object.
2321
+	 * @param int $post_id The post ID.
2322
+	 */
2323
+	function geodir_remove_from_favorite($post_id)
2324
+	{
2325
+		global $current_user;
2326
+
2327
+		/**
2328
+		 * Filter to modify "Add to Favorites" text
2329
+		 *
2330
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2331
+		 *
2332
+		 * @since 1.0.0
2333
+		 * @package GeoDirectory
2334
+		 */
2335
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2336
+
2337
+		/**
2338
+		 * Filter to modify "Favourite" text
2339
+		 *
2340
+		 * You can use this filter to rename "Favourite" text to something else.
2341
+		 *
2342
+		 * @since 1.0.0
2343
+		 * @package GeoDirectory
2344
+		 */
2345
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2346
+
2347
+		/**
2348
+		 * Filter to modify "fa fa-heart" icon
2349
+		 *
2350
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2351
+		 *
2352
+		 * @since 1.0.0
2353
+		 * @package GeoDirectory
2354
+		 */
2355
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2356
+
2357
+		$user_meta_data = array();
2358
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2359
+
2360
+		if (!empty($user_meta_data)) {
2361
+
2362
+			if (($key = array_search($post_id, $user_meta_data)) !== false) {
2363
+				unset($user_meta_data[$key]);
2364
+			}
2361 2365
 
2362
-            if (($key = array_search($post_id, $user_meta_data)) !== false) {
2363
-                unset($user_meta_data[$key]);
2364
-            }
2366
+		}
2365 2367
 
2366
-        }
2368
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2367 2369
 
2368
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2370
+		/**
2371
+		 * Called before removing the post from favourites.
2372
+		 *
2373
+		 * @since 1.0.0
2374
+		 * @package GeoDirectory
2375
+		 * @param int $post_id The post ID.
2376
+		 */
2377
+		do_action('geodir_before_remove_from_favorite', $post_id);
2369 2378
 
2370
-        /**
2371
-         * Called before removing the post from favourites.
2372
-         *
2373
-         * @since 1.0.0
2374
-         * @package GeoDirectory
2375
-         * @param int $post_id The post ID.
2376
-         */
2377
-        do_action('geodir_before_remove_from_favorite', $post_id);
2379
+		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>';
2378 2380
 
2379
-        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>';
2381
+		/**
2382
+		 * Called after removing the post from favourites.
2383
+		 *
2384
+		 * @since 1.0.0
2385
+		 * @package GeoDirectory
2386
+		 * @param int $post_id The post ID.
2387
+		 */
2388
+		do_action('geodir_after_remove_from_favorite', $post_id);
2380 2389
 
2381
-        /**
2382
-         * Called after removing the post from favourites.
2383
-         *
2384
-         * @since 1.0.0
2385
-         * @package GeoDirectory
2386
-         * @param int $post_id The post ID.
2387
-         */
2388
-        do_action('geodir_after_remove_from_favorite', $post_id);
2389
-
2390
-    }
2390
+	}
2391 2391
 }
2392 2392
 
2393 2393
 if (!function_exists('geodir_favourite_html')) {
2394
-    /**
2395
-     * This function would display the html content for add to favorite or remove from favorite.
2396
-     *
2397
-     * @since 1.0.0
2398
-     * @package GeoDirectory
2399
-     * @global object $current_user Current user object.
2400
-     * @global object $post The current post object.
2401
-     * @param int $user_id The user ID.
2402
-     * @param int $post_id The post ID.
2403
-     */
2404
-    function geodir_favourite_html($user_id, $post_id)
2405
-    {
2406
-
2407
-        global $current_user, $post;
2408
-
2409
-        /**
2410
-         * Filter to modify "Add to Favorites" text
2411
-         *
2412
-         * You can use this filter to rename "Add to Favorites" text to something else.
2413
-         *
2414
-         * @since 1.0.0
2415
-         * @package GeoDirectory
2416
-         */
2417
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2418
-
2419
-        /**
2420
-         * Filter to modify "Favourite" text
2421
-         *
2422
-         * You can use this filter to rename "Favourite" text to something else.
2423
-         *
2424
-         * @since 1.0.0
2425
-         * @package GeoDirectory
2426
-         */
2427
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2428
-
2429
-        /**
2430
-         * Filter to modify "Unfavorite" text
2431
-         *
2432
-         * You can use this filter to rename "Unfavorite" text to something else.
2433
-         *
2434
-         * @since 1.0.0
2435
-         * @package GeoDirectory
2436
-         */
2437
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2438
-
2439
-        /**
2440
-         * Filter to modify "Remove from Favorites" text
2441
-         *
2442
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2443
-         *
2444
-         * @since 1.0.0
2445
-         * @package GeoDirectory
2446
-         */
2447
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2448
-
2449
-        /**
2450
-         * Filter to modify "fa fa-heart" icon
2451
-         *
2452
-         * You can use this filter to change "fa fa-heart" icon to something else.
2453
-         *
2454
-         * @since 1.0.0
2455
-         * @package GeoDirectory
2456
-         */
2457
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2458
-
2459
-        /**
2460
-         * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2461
-         *
2462
-         * You can use this filter to change "fa fa-heart" icon to something else.
2463
-         *
2464
-         * @since 1.0.0
2465
-         * @package GeoDirectory
2466
-         */
2467
-        $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2468
-
2469
-        $user_meta_data = '';
2470
-        if (isset($current_user->data->ID))
2471
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2472
-
2473
-        if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2474
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2394
+	/**
2395
+	 * This function would display the html content for add to favorite or remove from favorite.
2396
+	 *
2397
+	 * @since 1.0.0
2398
+	 * @package GeoDirectory
2399
+	 * @global object $current_user Current user object.
2400
+	 * @global object $post The current post object.
2401
+	 * @param int $user_id The user ID.
2402
+	 * @param int $post_id The post ID.
2403
+	 */
2404
+	function geodir_favourite_html($user_id, $post_id)
2405
+	{
2406
+
2407
+		global $current_user, $post;
2408
+
2409
+		/**
2410
+		 * Filter to modify "Add to Favorites" text
2411
+		 *
2412
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2413
+		 *
2414
+		 * @since 1.0.0
2415
+		 * @package GeoDirectory
2416
+		 */
2417
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2418
+
2419
+		/**
2420
+		 * Filter to modify "Favourite" text
2421
+		 *
2422
+		 * You can use this filter to rename "Favourite" text to something else.
2423
+		 *
2424
+		 * @since 1.0.0
2425
+		 * @package GeoDirectory
2426
+		 */
2427
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2428
+
2429
+		/**
2430
+		 * Filter to modify "Unfavorite" text
2431
+		 *
2432
+		 * You can use this filter to rename "Unfavorite" text to something else.
2433
+		 *
2434
+		 * @since 1.0.0
2435
+		 * @package GeoDirectory
2436
+		 */
2437
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2438
+
2439
+		/**
2440
+		 * Filter to modify "Remove from Favorites" text
2441
+		 *
2442
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2443
+		 *
2444
+		 * @since 1.0.0
2445
+		 * @package GeoDirectory
2446
+		 */
2447
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2448
+
2449
+		/**
2450
+		 * Filter to modify "fa fa-heart" icon
2451
+		 *
2452
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2453
+		 *
2454
+		 * @since 1.0.0
2455
+		 * @package GeoDirectory
2456
+		 */
2457
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2458
+
2459
+		/**
2460
+		 * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2461
+		 *
2462
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2463
+		 *
2464
+		 * @since 1.0.0
2465
+		 * @package GeoDirectory
2466
+		 */
2467
+		$unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2468
+
2469
+		$user_meta_data = '';
2470
+		if (isset($current_user->data->ID))
2471
+			$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2472
+
2473
+		if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2474
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2475 2475
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2476 2476
                 onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2477 2477
                 title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2478 2478
             </a>   </span><?php
2479 2479
 
2480
-        } else {
2480
+		} else {
2481 2481
 
2482
-            if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2483
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2484
-            } else
2485
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2482
+			if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2483
+				$script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2484
+			} else
2485
+				$script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2486 2486
 
2487
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2487
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2488 2488
                                                                                         href="javascript:void(0);"
2489 2489
                                                                                         onclick="<?php echo $script_text;?>"
2490 2490
                                                                                         title="<?php echo $add_favourite_text;?>"><i
2491 2491
                     class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2492 2492
         <?php }
2493
-    }
2493
+	}
2494 2494
 }
2495 2495
 
2496 2496
 
@@ -2507,54 +2507,54 @@  discard block
 block discarded – undo
2507 2507
 function geodir_get_cat_postcount($term = array())
2508 2508
 {
2509 2509
 
2510
-    if (!empty($term)) {
2510
+	if (!empty($term)) {
2511 2511
 
2512
-        global $wpdb, $plugin_prefix;
2512
+		global $wpdb, $plugin_prefix;
2513 2513
 
2514
-        $where = '';
2515
-        $join = '';
2516
-        if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2517
-            $taxonomy_obj = get_taxonomy($term->taxonomy);
2514
+		$where = '';
2515
+		$join = '';
2516
+		if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2517
+			$taxonomy_obj = get_taxonomy($term->taxonomy);
2518 2518
 
2519
-            $post_type = $taxonomy_obj->object_type[0];
2519
+			$post_type = $taxonomy_obj->object_type[0];
2520 2520
 
2521
-            $table = $plugin_prefix . $post_type . '_detail';
2521
+			$table = $plugin_prefix . $post_type . '_detail';
2522 2522
 
2523
-            /**
2524
-             * Filter to modify the 'join' query
2525
-             *
2526
-             * @since 1.0.0
2527
-             * @package GeoDirectory
2528
-             * @param object|array $term category / term object that need to be processed.
2529
-             * @param string $join The join query.
2530
-             */
2531
-            $join = apply_filters('geodir_cat_post_count_join', $join, $term);
2523
+			/**
2524
+			 * Filter to modify the 'join' query
2525
+			 *
2526
+			 * @since 1.0.0
2527
+			 * @package GeoDirectory
2528
+			 * @param object|array $term category / term object that need to be processed.
2529
+			 * @param string $join The join query.
2530
+			 */
2531
+			$join = apply_filters('geodir_cat_post_count_join', $join, $term);
2532 2532
 
2533
-            /**
2534
-             * Filter to modify the 'where' query
2535
-             *
2536
-             * @since 1.0.0
2537
-             * @package GeoDirectory
2538
-             * @param object|array $term category / term object that need to be processed.
2539
-             * @param string $where The where query.
2540
-             */
2541
-            $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2533
+			/**
2534
+			 * Filter to modify the 'where' query
2535
+			 *
2536
+			 * @since 1.0.0
2537
+			 * @package GeoDirectory
2538
+			 * @param object|array $term category / term object that need to be processed.
2539
+			 * @param string $where The where query.
2540
+			 */
2541
+			$where = apply_filters('geodir_cat_post_count_where', $where, $term);
2542 2542
 
2543
-            $count_query = "SELECT count(post_id) FROM
2543
+			$count_query = "SELECT count(post_id) FROM
2544 2544
 							" . $table . " as pd " . $join . "
2545 2545
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2546 2546
 
2547
-            $cat_post_count = $wpdb->get_var($count_query);
2548
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2549
-                $cat_post_count = 0;
2547
+			$cat_post_count = $wpdb->get_var($count_query);
2548
+			if (empty($cat_post_count) || is_wp_error($cat_post_count))
2549
+				$cat_post_count = 0;
2550 2550
 
2551
-            return $cat_post_count;
2551
+			return $cat_post_count;
2552 2552
 
2553
-        } else
2553
+		} else
2554 2554
 
2555
-            return $term->count;
2556
-    }
2557
-    return false;
2555
+			return $term->count;
2556
+	}
2557
+	return false;
2558 2558
 
2559 2559
 }
2560 2560
 
@@ -2567,17 +2567,17 @@  discard block
 block discarded – undo
2567 2567
  */
2568 2568
 function geodir_allow_post_type_frontend()
2569 2569
 {
2570
-    $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2570
+	$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2571 2571
 
2572
-    if (!is_admin() && isset($_REQUEST['listing_type'])
2573
-        && !empty($geodir_allow_posttype_frontend)
2574
-        && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2575
-    ) {
2572
+	if (!is_admin() && isset($_REQUEST['listing_type'])
2573
+		&& !empty($geodir_allow_posttype_frontend)
2574
+		&& !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2575
+	) {
2576 2576
 
2577
-        wp_redirect(home_url());
2578
-        exit;
2577
+		wp_redirect(home_url());
2578
+		exit;
2579 2579
 
2580
-    }
2580
+	}
2581 2581
 
2582 2582
 }
2583 2583
 
@@ -2594,20 +2594,20 @@  discard block
 block discarded – undo
2594 2594
  */
2595 2595
 function geodir_excerpt_length($length)
2596 2596
 {
2597
-    global $wp_query, $geodir_is_widget_listing;
2597
+	global $wp_query, $geodir_is_widget_listing;
2598 2598
 	if ($geodir_is_widget_listing) {
2599 2599
 		return $length;
2600 2600
 	}
2601 2601
 	
2602
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2603
-        $length = get_option('geodir_desc_word_limit');
2604
-    elseif (get_query_var('excerpt_length'))
2605
-        $length = get_query_var('excerpt_length');
2602
+	if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2603
+		$length = get_option('geodir_desc_word_limit');
2604
+	elseif (get_query_var('excerpt_length'))
2605
+		$length = get_query_var('excerpt_length');
2606 2606
 
2607
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2608
-        $length = get_option('geodir_author_desc_word_limit');
2607
+	if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2608
+		$length = get_option('geodir_author_desc_word_limit');
2609 2609
 
2610
-    return $length;
2610
+	return $length;
2611 2611
 }
2612 2612
 
2613 2613
 /**
@@ -2622,13 +2622,13 @@  discard block
 block discarded – undo
2622 2622
  */
2623 2623
 function geodir_excerpt_more($more)
2624 2624
 {
2625
-    global $post;
2626
-    $all_postypes = geodir_get_posttypes();
2627
-    if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2628
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2629
-    }
2625
+	global $post;
2626
+	$all_postypes = geodir_get_posttypes();
2627
+	if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2628
+		return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2629
+	}
2630 2630
 
2631
-    return $more;
2631
+	return $more;
2632 2632
 }
2633 2633
 
2634 2634
 
@@ -2645,63 +2645,63 @@  discard block
 block discarded – undo
2645 2645
  */
2646 2646
 function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
2647 2647
 {
2648
-    global $plugin_prefix, $wpdb;
2648
+	global $plugin_prefix, $wpdb;
2649 2649
 
2650
-    $gd_taxonomies = geodir_get_taxonomies();
2650
+	$gd_taxonomies = geodir_get_taxonomies();
2651 2651
 
2652
-    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2652
+	if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2653 2653
 
2654
-        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2655
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2654
+		$geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2655
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
2656 2656
 
2657
-        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2658
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2657
+		$path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2658
+		$term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2659 2659
 
2660
-        $posts = $wpdb->get_results(
2661
-            $wpdb->prepare(
2662
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2663
-                array($term_id, $taxonomy)
2664
-            )
2665
-        );
2660
+		$posts = $wpdb->get_results(
2661
+			$wpdb->prepare(
2662
+				"SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2663
+				array($term_id, $taxonomy)
2664
+			)
2665
+		);
2666 2666
 
2667
-        if (!empty($posts)):
2668
-            foreach ($posts as $post_obj) {
2667
+		if (!empty($posts)):
2668
+			foreach ($posts as $post_obj) {
2669 2669
 
2670
-                $lat = $post_obj->post_latitude;
2671
-                $lng = $post_obj->post_longitude;
2670
+				$lat = $post_obj->post_latitude;
2671
+				$lng = $post_obj->post_longitude;
2672 2672
 
2673
-                $json = '{';
2674
-                $json .= '"id":"' . $post_obj->post_id . '",';
2675
-                $json .= '"lat_pos": "' . $lat . '",';
2676
-                $json .= '"long_pos": "' . $lng . '",';
2677
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2678
-                $json .= '"icon":"' . $term_icon . '",';
2679
-                $json .= '"group":"catgroup' . $term_id . '"';
2680
-                $json .= '}';
2673
+				$json = '{';
2674
+				$json .= '"id":"' . $post_obj->post_id . '",';
2675
+				$json .= '"lat_pos": "' . $lat . '",';
2676
+				$json .= '"long_pos": "' . $lng . '",';
2677
+				$json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2678
+				$json .= '"icon":"' . $term_icon . '",';
2679
+				$json .= '"group":"catgroup' . $term_id . '"';
2680
+				$json .= '}';
2681 2681
 
2682
-                if ($post_obj->default_category == $term_id) {
2682
+				if ($post_obj->default_category == $term_id) {
2683 2683
 
2684
-                    $wpdb->query(
2685
-                        $wpdb->prepare(
2686
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2687
-                            array($json, $post_obj->post_id)
2688
-                        )
2689
-                    );
2690
-                }
2684
+					$wpdb->query(
2685
+						$wpdb->prepare(
2686
+							"UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2687
+							array($json, $post_obj->post_id)
2688
+						)
2689
+					);
2690
+				}
2691 2691
 
2692
-                $wpdb->query(
2693
-                    $wpdb->prepare(
2694
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2695
-                        array($json, $post_obj->post_id, $term_id)
2696
-                    )
2697
-                );
2692
+				$wpdb->query(
2693
+					$wpdb->prepare(
2694
+						"UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2695
+						array($json, $post_obj->post_id, $term_id)
2696
+					)
2697
+				);
2698 2698
 
2699
-            }
2699
+			}
2700 2700
 
2701 2701
 
2702
-        endif;
2702
+		endif;
2703 2703
 
2704
-    }
2704
+	}
2705 2705
 
2706 2706
 }
2707 2707
 
@@ -2715,14 +2715,14 @@  discard block
 block discarded – undo
2715 2715
  */
2716 2716
 function geodir_get_listing_author($listing_id = '')
2717 2717
 {
2718
-    if ($listing_id == '') {
2719
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2720
-            $listing_id = $_REQUEST['pid'];
2721
-        }
2722
-    }
2723
-    $listing = get_post(strip_tags($listing_id));
2724
-    $listing_author_id = $listing->post_author;
2725
-    return $listing_author_id;
2718
+	if ($listing_id == '') {
2719
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2720
+			$listing_id = $_REQUEST['pid'];
2721
+		}
2722
+	}
2723
+	$listing = get_post(strip_tags($listing_id));
2724
+	$listing_author_id = $listing->post_author;
2725
+	return $listing_author_id;
2726 2726
 }
2727 2727
 
2728 2728
 
@@ -2737,11 +2737,11 @@  discard block
 block discarded – undo
2737 2737
  */
2738 2738
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2739 2739
 {
2740
-    $listing_author_id = geodir_get_listing_author($listing_id);
2741
-    if ($listing_author_id == $user_id)
2742
-        return true;
2743
-    else
2744
-        return false;
2740
+	$listing_author_id = geodir_get_listing_author($listing_id);
2741
+	if ($listing_author_id == $user_id)
2742
+		return true;
2743
+	else
2744
+		return false;
2745 2745
 
2746 2746
 }
2747 2747
 
@@ -2757,17 +2757,17 @@  discard block
 block discarded – undo
2757 2757
  */
2758 2758
 function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true)
2759 2759
 {
2760
-    global $current_user;
2761
-    if ($exclude_admin) {
2762
-        foreach ($current_user->caps as $key => $caps) {
2763
-            if (geodir_strtolower($key) == 'administrator') {
2764
-                return true;
2765
-                break;
2766
-            }
2767
-        }
2768
-    }
2769
-
2770
-    return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2760
+	global $current_user;
2761
+	if ($exclude_admin) {
2762
+		foreach ($current_user->caps as $key => $caps) {
2763
+			if (geodir_strtolower($key) == 'administrator') {
2764
+				return true;
2765
+				break;
2766
+			}
2767
+		}
2768
+	}
2769
+
2770
+	return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2771 2771
 }
2772 2772
 
2773 2773
 
@@ -2783,17 +2783,17 @@  discard block
 block discarded – undo
2783 2783
 function geodir_only_supportable_attachments_remove($file)
2784 2784
 {
2785 2785
 
2786
-    global $wpdb;
2786
+	global $wpdb;
2787 2787
 
2788
-    $matches = array();
2788
+	$matches = array();
2789 2789
 
2790
-    $pattern = '/-\d+x\d+\./';
2791
-    preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2790
+	$pattern = '/-\d+x\d+\./';
2791
+	preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2792 2792
 
2793
-    if (empty($matches))
2794
-        return '';
2795
-    else
2796
-        return $file;
2793
+	if (empty($matches))
2794
+		return '';
2795
+	else
2796
+		return $file;
2797 2797
 
2798 2798
 }
2799 2799
 
@@ -2810,78 +2810,78 @@  discard block
 block discarded – undo
2810 2810
 function geodir_set_wp_featured_image($post_id)
2811 2811
 {
2812 2812
 
2813
-    global $wpdb, $plugin_prefix;
2814
-    $uploads = wp_upload_dir();
2813
+	global $wpdb, $plugin_prefix;
2814
+	$uploads = wp_upload_dir();
2815 2815
 //	print_r($uploads ) ;
2816
-    $post_first_image = $wpdb->get_results(
2817
-        $wpdb->prepare(
2818
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2819
-        )
2820
-    );
2816
+	$post_first_image = $wpdb->get_results(
2817
+		$wpdb->prepare(
2818
+			"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2819
+		)
2820
+	);
2821 2821
 
2822
-    $old_attachment_name = '';
2823
-    $post_thumbnail_id = '';
2824
-    if (has_post_thumbnail($post_id)) {
2822
+	$old_attachment_name = '';
2823
+	$post_thumbnail_id = '';
2824
+	if (has_post_thumbnail($post_id)) {
2825 2825
 
2826
-        if (has_post_thumbnail($post_id)) {
2826
+		if (has_post_thumbnail($post_id)) {
2827 2827
 
2828
-            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2828
+			$post_thumbnail_id = get_post_thumbnail_id($post_id);
2829 2829
 
2830
-            $old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2830
+			$old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2831 2831
 
2832
-        }
2833
-    }
2834
-
2835
-    if (!empty($post_first_image)) {
2832
+		}
2833
+	}
2836 2834
 
2837
-        $post_type = get_post_type($post_id);
2835
+	if (!empty($post_first_image)) {
2838 2836
 
2839
-        $table_name = $plugin_prefix . $post_type . '_detail';
2837
+		$post_type = get_post_type($post_id);
2840 2838
 
2841
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2839
+		$table_name = $plugin_prefix . $post_type . '_detail';
2842 2840
 
2843
-        $new_attachment_name = basename($post_first_image[0]->file);
2841
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2844 2842
 
2845
-        if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2843
+		$new_attachment_name = basename($post_first_image[0]->file);
2846 2844
 
2847
-            if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2845
+		if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2848 2846
 
2849
-                add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2847
+			if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2850 2848
 
2851
-                wp_delete_attachment($post_thumbnail_id);
2849
+				add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2852 2850
 
2853
-            }
2854
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2851
+				wp_delete_attachment($post_thumbnail_id);
2855 2852
 
2856
-            $attachment = array(
2857
-                'post_mime_type' => $post_first_image[0]->mime_type,
2858
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2859
-                'post_parent' => $post_id,
2860
-                'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2861
-                'post_content' => ''
2862
-            );
2853
+			}
2854
+			$filename = $uploads['basedir'] . $post_first_image[0]->file;
2855
+
2856
+			$attachment = array(
2857
+				'post_mime_type' => $post_first_image[0]->mime_type,
2858
+				'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2859
+				'post_parent' => $post_id,
2860
+				'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2861
+				'post_content' => ''
2862
+			);
2863 2863
 
2864 2864
 
2865
-            $id = wp_insert_attachment($attachment, $filename, $post_id);
2865
+			$id = wp_insert_attachment($attachment, $filename, $post_id);
2866 2866
 
2867
-            if (!is_wp_error($id)) {
2867
+			if (!is_wp_error($id)) {
2868 2868
 
2869
-                set_post_thumbnail($post_id, $id);
2869
+				set_post_thumbnail($post_id, $id);
2870 2870
 
2871
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2872
-                wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2871
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
2872
+				wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2873 2873
 
2874
-            }
2874
+			}
2875 2875
 
2876
-        }
2876
+		}
2877 2877
 
2878
-    } else {
2879
-        //set_post_thumbnail($post_id,-1);
2878
+	} else {
2879
+		//set_post_thumbnail($post_id,-1);
2880 2880
 
2881
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2882
-            wp_delete_attachment($post_thumbnail_id);
2881
+		if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2882
+			wp_delete_attachment($post_thumbnail_id);
2883 2883
 
2884
-    }
2884
+	}
2885 2885
 }
2886 2886
 
2887 2887
 
@@ -2896,53 +2896,53 @@  discard block
 block discarded – undo
2896 2896
  */
2897 2897
 function gd_copy_original_translation()
2898 2898
 {
2899
-    if (function_exists('icl_object_id')) {
2900
-        global $wpdb, $table_prefix, $plugin_prefix;
2901
-        $post_id = absint($_POST['post_id']);
2902
-        $upload_dir = wp_upload_dir();
2903
-        $post_type = get_post_type($_POST['post_id']);
2904
-        $table = $plugin_prefix . $post_type . '_detail';
2905
-
2906
-        $post_arr = $wpdb->get_results($wpdb->prepare(
2907
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2908
-            array($post_id)
2909
-        )
2910
-            , ARRAY_A);
2911
-
2912
-        $arrImages = $wpdb->get_results(
2913
-            $wpdb->prepare(
2914
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2915
-                array('%image%', $post_id)
2916
-            )
2917
-        );
2918
-        if ($arrImages) {
2919
-            $image_arr = array();
2920
-            foreach ($arrImages as $img) {
2921
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2922
-            }
2923
-            $comma_separated = implode(",", $image_arr);
2924
-            $post_arr[0]['post_images'] = $comma_separated;
2925
-        }
2926
-
2927
-
2928
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2929
-        $cat_arr = array_filter(explode(",", $cats));
2930
-        $trans_cat = array();
2931
-        foreach ($cat_arr as $cat) {
2932
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2933
-        }
2934
-
2935
-
2936
-        $post_arr[0]['categories'] = array_filter($trans_cat);
2899
+	if (function_exists('icl_object_id')) {
2900
+		global $wpdb, $table_prefix, $plugin_prefix;
2901
+		$post_id = absint($_POST['post_id']);
2902
+		$upload_dir = wp_upload_dir();
2903
+		$post_type = get_post_type($_POST['post_id']);
2904
+		$table = $plugin_prefix . $post_type . '_detail';
2905
+
2906
+		$post_arr = $wpdb->get_results($wpdb->prepare(
2907
+			"SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2908
+			array($post_id)
2909
+		)
2910
+			, ARRAY_A);
2911
+
2912
+		$arrImages = $wpdb->get_results(
2913
+			$wpdb->prepare(
2914
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2915
+				array('%image%', $post_id)
2916
+			)
2917
+		);
2918
+		if ($arrImages) {
2919
+			$image_arr = array();
2920
+			foreach ($arrImages as $img) {
2921
+				$image_arr[] = $upload_dir['baseurl'] . $img->file;
2922
+			}
2923
+			$comma_separated = implode(",", $image_arr);
2924
+			$post_arr[0]['post_images'] = $comma_separated;
2925
+		}
2926
+
2927
+
2928
+		$cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2929
+		$cat_arr = array_filter(explode(",", $cats));
2930
+		$trans_cat = array();
2931
+		foreach ($cat_arr as $cat) {
2932
+			$trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2933
+		}
2934
+
2935
+
2936
+		$post_arr[0]['categories'] = array_filter($trans_cat);
2937 2937
 //print_r($image_arr);
2938
-        //print_r($arrImages);
2939
-        //echo $_REQUEST['lang'];
2938
+		//print_r($arrImages);
2939
+		//echo $_REQUEST['lang'];
2940 2940
 //print_r($post_arr);
2941 2941
 //print_r($trans_cat);
2942
-        echo json_encode($post_arr[0]);
2942
+		echo json_encode($post_arr[0]);
2943 2943
 
2944
-    }
2945
-    die();
2944
+	}
2945
+	die();
2946 2946
 }
2947 2947
 
2948 2948
 
@@ -2962,54 +2962,54 @@  discard block
 block discarded – undo
2962 2962
 function geodir_get_custom_fields_type($listing_type = '')
2963 2963
 {
2964 2964
 
2965
-    global $wpdb;
2965
+	global $wpdb;
2966 2966
 
2967
-    if ($listing_type == '')
2968
-        $listing_type = 'gd_place';
2967
+	if ($listing_type == '')
2968
+		$listing_type = 'gd_place';
2969 2969
 
2970
-    $fields_info = array();
2970
+	$fields_info = array();
2971 2971
 
2972
-    $get_data = $wpdb->get_results(
2973
-        $wpdb->prepare(
2974
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2975
-            array($listing_type)
2976
-        )
2977
-    );
2972
+	$get_data = $wpdb->get_results(
2973
+		$wpdb->prepare(
2974
+			"SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2975
+			array($listing_type)
2976
+		)
2977
+	);
2978 2978
 
2979
-    if (!empty($get_data)) {
2979
+	if (!empty($get_data)) {
2980 2980
 
2981
-        foreach ($get_data as $data) {
2981
+		foreach ($get_data as $data) {
2982 2982
 
2983
-            if ($data->field_type == 'address') {
2983
+			if ($data->field_type == 'address') {
2984 2984
 
2985
-                $extra_fields = unserialize($data->extra_fields);
2985
+				$extra_fields = unserialize($data->extra_fields);
2986 2986
 
2987
-                $prefix = $data->htmlvar_name . '_';
2987
+				$prefix = $data->htmlvar_name . '_';
2988 2988
 
2989
-                $fields_info[$prefix . 'address'] = $data->field_type;
2989
+				$fields_info[$prefix . 'address'] = $data->field_type;
2990 2990
 
2991
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2992
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
2991
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2992
+					$fields_info[$prefix . 'zip'] = $data->field_type;
2993 2993
 
2994
-            } else {
2994
+			} else {
2995 2995
 
2996
-                $fields_info[$data->htmlvar_name] = $data->field_type;
2996
+				$fields_info[$data->htmlvar_name] = $data->field_type;
2997 2997
 
2998
-            }
2998
+			}
2999 2999
 
3000
-        }
3000
+		}
3001 3001
 
3002
-    }
3002
+	}
3003 3003
 
3004
-    /**
3005
-     * Filter to modify custom fields info using listing post type.
3006
-     *
3007
-     * @since 1.0.0
3008
-     * @package GeoDirectory
3009
-     * @return array $fields_info Custom fields info.
3010
-     * @param string $listing_type The listing post type.
3011
-     */
3012
-    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3004
+	/**
3005
+	 * Filter to modify custom fields info using listing post type.
3006
+	 *
3007
+	 * @since 1.0.0
3008
+	 * @package GeoDirectory
3009
+	 * @return array $fields_info Custom fields info.
3010
+	 * @param string $listing_type The listing post type.
3011
+	 */
3012
+	return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3013 3013
 }
3014 3014
 
3015 3015
 
@@ -3024,58 +3024,58 @@  discard block
 block discarded – undo
3024 3024
  */
3025 3025
 function geodir_function_post_updated($post_ID, $post_after, $post_before)
3026 3026
 {
3027
-    $post_type = get_post_type($post_ID);
3027
+	$post_type = get_post_type($post_ID);
3028 3028
 
3029
-    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3030
-        // send notification to client when post moves from draft to publish
3031
-        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')) {
3032
-            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3033
-            $post_author_data = get_userdata($post_author_id);
3029
+	if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3030
+		// send notification to client when post moves from draft to publish
3031
+		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')) {
3032
+			$post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3033
+			$post_author_data = get_userdata($post_author_id);
3034 3034
 
3035
-            $to_name = geodir_get_client_name($post_author_id);
3035
+			$to_name = geodir_get_client_name($post_author_id);
3036 3036
 
3037
-            $from_email = geodir_get_site_email_id();
3038
-            $from_name = get_site_emailName();
3039
-            $to_email = $post_author_data->user_email;
3037
+			$from_email = geodir_get_site_email_id();
3038
+			$from_name = get_site_emailName();
3039
+			$to_email = $post_author_data->user_email;
3040 3040
 
3041
-            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3042
-                $to_email = $post_author_data->user_email;
3043
-            }
3041
+			if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3042
+				$to_email = $post_author_data->user_email;
3043
+			}
3044 3044
 
3045
-            $message_type = 'listing_published';
3045
+			$message_type = 'listing_published';
3046 3046
 
3047
-            if (get_option('geodir_post_published_email_subject') == '') {
3048
-                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3049
-            }
3047
+			if (get_option('geodir_post_published_email_subject') == '') {
3048
+				update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3049
+			}
3050 3050
 
3051
-            if (get_option('geodir_post_published_email_content') == '') {
3052
-                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'));
3053
-            }
3051
+			if (get_option('geodir_post_published_email_content') == '') {
3052
+				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'));
3053
+			}
3054 3054
 
3055
-            /**
3056
-             * Called before sending the email when listing gets published.
3057
-             *
3058
-             * @since 1.0.0
3059
-             * @package GeoDirectory
3060
-             * @param object $post_after The post object after update.
3061
-             * @param object $post_before The post object before update.
3062
-             */
3063
-            do_action('geodir_before_listing_published_email', $post_after, $post_before);
3064
-            if (is_email($to_email)) {
3065
-                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3066
-            }
3055
+			/**
3056
+			 * Called before sending the email when listing gets published.
3057
+			 *
3058
+			 * @since 1.0.0
3059
+			 * @package GeoDirectory
3060
+			 * @param object $post_after The post object after update.
3061
+			 * @param object $post_before The post object before update.
3062
+			 */
3063
+			do_action('geodir_before_listing_published_email', $post_after, $post_before);
3064
+			if (is_email($to_email)) {
3065
+				geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3066
+			}
3067 3067
 
3068
-            /**
3069
-             * Called after sending the email when listing gets published.
3070
-             *
3071
-             * @since 1.0.0
3072
-             * @package GeoDirectory
3073
-             * @param object $post_after The post object after update.
3074
-             * @param object $post_before The post object before update.
3075
-             */
3076
-            do_action('geodir_after_listing_published_email', $post_after, $post_before);
3077
-        }
3078
-    }
3068
+			/**
3069
+			 * Called after sending the email when listing gets published.
3070
+			 *
3071
+			 * @since 1.0.0
3072
+			 * @package GeoDirectory
3073
+			 * @param object $post_after The post object after update.
3074
+			 * @param object $post_before The post object before update.
3075
+			 */
3076
+			do_action('geodir_after_listing_published_email', $post_after, $post_before);
3077
+		}
3078
+	}
3079 3079
 }
3080 3080
 
3081 3081
 add_action('wp_head', 'geodir_fb_like_thumbnail');
@@ -3089,14 +3089,14 @@  discard block
 block discarded – undo
3089 3089
  */
3090 3090
 function geodir_fb_like_thumbnail(){
3091 3091
 
3092
-    // return if not a single post
3093
-    if(!is_single()){return;}
3092
+	// return if not a single post
3093
+	if(!is_single()){return;}
3094 3094
 
3095
-    global $post;
3096
-    if(isset($post->featured_image) && $post->featured_image){
3097
-        $upload_dir = wp_upload_dir();
3098
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3099
-        echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3095
+	global $post;
3096
+	if(isset($post->featured_image) && $post->featured_image){
3097
+		$upload_dir = wp_upload_dir();
3098
+		$thumb = $upload_dir['baseurl'].$post->featured_image;
3099
+		echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3100 3100
 
3101
-    }
3101
+	}
3102 3102
 }
3103 3103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +205 added lines, -205 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
             if ($meta_value && $meta_value !== '') {
901 901
                 return maybe_serialize($meta_value);
902 902
             } else
@@ -929,13 +929,13 @@  discard block
 block discarded – undo
929 929
 
930 930
         $post_type = get_post_type($post_id);
931 931
 
932
-        $table = $plugin_prefix . $post_type . '_detail';
932
+        $table = $plugin_prefix.$post_type.'_detail';
933 933
 
934 934
         $post_images = geodir_get_images($post_id);
935 935
 
936 936
         $wpdb->query(
937 937
             $wpdb->prepare(
938
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
938
+                "UPDATE ".$table." SET featured_image = '' where post_id =%d",
939 939
                 array($post_id)
940 940
             )
941 941
         );
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
                 $file_path = '';
966 966
                 /* --------- start ------- */
967 967
 
968
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
968
+                $split_img_path = explode(str_replace(array('http://', 'https://'), '', $uploads['baseurl']), str_replace(array('http://', 'https://'), '', $post_image[$m]));
969 969
 
970 970
                 $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
971 971
 
972 972
 
973
-                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)))) {
973
+                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)))) {
974 974
 
975 975
                     /* --------- end ------- */
976 976
                     $curr_img_url = $post_image[$m];
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
                     // If the uploaded file is the right format
1015 1015
                     if (in_array($uploaded_file_type, $allowed_file_types)) {
1016 1016
                         if (!function_exists('wp_handle_upload')) {
1017
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1017
+                            require_once(ABSPATH.'wp-admin/includes/file.php');
1018 1018
                         }
1019 1019
 
1020 1020
                         if (!is_dir($geodir_uploadpath)) {
@@ -1022,41 +1022,41 @@  discard block
 block discarded – undo
1022 1022
                         }
1023 1023
 
1024 1024
                         $external_img = false;
1025
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1025
+                        if (strpos(str_replace(array('http://', 'https://'), '', $curr_img_url), str_replace(array('http://', 'https://'), '', $uploads['baseurl'])) !== false) {
1026 1026
                         } else {
1027 1027
                             $external_img = true;
1028 1028
                         }
1029 1029
 
1030 1030
                         if ($dummy || $external_img) {
1031 1031
                             $uploaded_file = array();
1032
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1032
+                            $uploaded = (array) fetch_remote_file($curr_img_url);
1033 1033
 
1034 1034
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035 1035
                                 $new_name = basename($uploaded['file']);
1036 1036
                                 $uploaded_file = $uploaded;
1037
-                            }else{
1038
-                                print_r($uploaded);exit;
1037
+                            } else {
1038
+                                print_r($uploaded); exit;
1039 1039
                             }
1040 1040
                             $external_img = false;
1041 1041
                         } else {
1042
-                            $new_name = $post_id . '_' . $file_name;
1042
+                            $new_name = $post_id.'_'.$file_name;
1043 1043
 
1044 1044
                             if ($curr_img_dir == $sub_dir) {
1045
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1046
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1045
+                                $img_path = $geodir_uploadpath.'/'.$filename;
1046
+                                $img_url = $geodir_uploadurl.'/'.$filename;
1047 1047
                             } else {
1048
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1048
+                                $img_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1049
+                                $img_url = $uploads['url'].'/temp_'.$current_user->data->ID.'/'.$filename;
1050 1050
                             }
1051 1051
 
1052 1052
                             $uploaded_file = '';
1053 1053
 
1054 1054
                             if (file_exists($img_path)) {
1055
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1055
+                                $uploaded_file = copy($img_path, $geodir_uploadpath.'/'.$new_name);
1056 1056
                                 $file_path = '';
1057
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1057
+                            } else if (file_exists($uploads['basedir'].$curr_img_dir.$filename)) {
1058 1058
                                 $uploaded_file = true;
1059
-                                $file_path = $curr_img_dir . '/' . $filename;
1059
+                                $file_path = $curr_img_dir.'/'.$filename;
1060 1060
                             }
1061 1061
 
1062 1062
                             if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
@@ -1065,14 +1065,14 @@  discard block
 block discarded – undo
1065 1065
 
1066 1066
                         if (!empty($uploaded_file)) {
1067 1067
                             if (!isset($file_path) || !$file_path) {
1068
-                                $file_path = $sub_dir . '/' . $new_name;
1068
+                                $file_path = $sub_dir.'/'.$new_name;
1069 1069
                             }
1070 1070
 
1071
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1071
+                            $postcurr_images[] = str_replace(array('http://', 'https://'), '', $uploads['baseurl'].$file_path);
1072 1072
 
1073 1073
                             if ($menu_order == 1) {
1074 1074
 
1075
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1075
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1076 1076
 
1077 1077
                             }
1078 1078
 
@@ -1090,12 +1090,12 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
                             foreach ($attachment as $key => $val) {
1092 1092
                                 if ($val != '')
1093
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1093
+                                    $attachment_set .= $key." = '".$val."', ";
1094 1094
                             }
1095 1095
 
1096 1096
                             $attachment_set = trim($attachment_set, ", ");
1097 1097
 
1098
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1098
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
1099 1099
 
1100 1100
                             $valid_file_ids[] = $wpdb->insert_id;
1101 1101
                         }
@@ -1106,17 +1106,17 @@  discard block
 block discarded – undo
1106 1106
                 } else {
1107 1107
                     $valid_file_ids[] = $find_image;
1108 1108
 
1109
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1109
+                    $postcurr_images[] = str_replace(array('http://', 'https://'), '', $post_image[$m]);
1110 1110
 
1111 1111
                     $wpdb->query(
1112 1112
                         $wpdb->prepare(
1113
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1113
+                            "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d where file =%s AND post_id =%d",
1114 1114
                             array($menu_order, $split_img_path[1], $post_id)
1115 1115
                         )
1116 1116
                     );
1117 1117
 
1118 1118
                     if ($menu_order == 1)
1119
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1119
+                        $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1120 1120
 
1121 1121
                 }
1122 1122
 
@@ -1140,9 +1140,9 @@  discard block
 block discarded – undo
1140 1140
 
1141 1141
                 foreach ($post_images as $img) {
1142 1142
 
1143
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1143
+                    if (!in_array(str_replace(array('http://', 'https://'), '', $img->src), $postcurr_images)) {
1144 1144
 
1145
-                        $invalid_files[] = (object)array('src' => $img->src);
1145
+                        $invalid_files[] = (object) array('src' => $img->src);
1146 1146
 
1147 1147
                     }
1148 1148
 
@@ -1150,12 +1150,12 @@  discard block
 block discarded – undo
1150 1150
 
1151 1151
             }
1152 1152
 
1153
-            $invalid_files = (object)$invalid_files;
1153
+            $invalid_files = (object) $invalid_files;
1154 1154
         }
1155 1155
 
1156 1156
         $remove_files[] = $post_id;
1157 1157
 
1158
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1158
+        $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ".$valid_files_condition." post_id = %d", $remove_files));
1159 1159
 
1160 1160
         if (!empty($invalid_files))
1161 1161
             geodir_remove_attachments($invalid_files);
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 			rmdir($dirPath);
1196 1196
 	}	*/
1197 1197
 
1198
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1198
+    $dirname = $uploads_dir.'/temp_'.$current_user->ID;
1199 1199
     geodir_delete_directory($dirname);
1200 1200
 }
1201 1201
 
@@ -1217,10 +1217,10 @@  discard block
 block discarded – undo
1217 1217
         return false;
1218 1218
     while ($file = readdir($dir_handle)) {
1219 1219
         if ($file != "." && $file != "..") {
1220
-            if (!is_dir($dirname . "/" . $file))
1221
-                unlink($dirname . "/" . $file);
1220
+            if (!is_dir($dirname."/".$file))
1221
+                unlink($dirname."/".$file);
1222 1222
             else
1223
-                geodir_delete_directory($dirname . '/' . $file);
1223
+                geodir_delete_directory($dirname.'/'.$file);
1224 1224
         }
1225 1225
     }
1226 1226
     closedir($dir_handle);
@@ -1249,8 +1249,8 @@  discard block
 block discarded – undo
1249 1249
             foreach ($postcurr_images as $postimg) {
1250 1250
                 $image_name_arr = explode('/', $postimg->src);
1251 1251
                 $filename = end($image_name_arr);
1252
-                if (file_exists($uploads_dir . '/' . $filename))
1253
-                    unlink($uploads_dir . '/' . $filename);
1252
+                if (file_exists($uploads_dir.'/'.$filename))
1253
+                    unlink($uploads_dir.'/'.$filename);
1254 1254
             }
1255 1255
 
1256 1256
         } // endif
@@ -1291,16 +1291,16 @@  discard block
 block discarded – undo
1291 1291
         }
1292 1292
 
1293 1293
         if (!in_array($post_type, geodir_get_posttypes())) {
1294
-            return false;// if not a GD CPT return;
1294
+            return false; // if not a GD CPT return;
1295 1295
         }
1296 1296
 
1297
-        $table = $plugin_prefix . $post_type . '_detail';
1297
+        $table = $plugin_prefix.$post_type.'_detail';
1298 1298
 
1299 1299
         if (!$file) {
1300 1300
             if (isset($post->featured_image)) {
1301 1301
                 $file = $post->featured_image;
1302 1302
             } else {
1303
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1303
+                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM ".$table." WHERE post_id = %d", array($post_id)));
1304 1304
             }
1305 1305
         }
1306 1306
 
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
             $sub_dir = '';
1312 1312
             if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1313 1313
                 $sub_dir = stripslashes_deep($file_info['dirname']);
1314
-                if ((substr( $sub_dir, 0, 7 ) === "http://") || (substr( $sub_dir, 0, 8 ) === "https://")) {
1314
+                if ((substr($sub_dir, 0, 7) === "http://") || (substr($sub_dir, 0, 8) === "https://")) {
1315 1315
                     $sub_dir = str_replace($uploads['baseurl'], "", $sub_dir);
1316 1316
                 }
1317 1317
             }
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
 
1323 1323
             $file_name = $file_info['basename'];
1324 1324
 
1325
-            $uploads_url = $uploads_baseurl . $sub_dir;
1325
+            $uploads_url = $uploads_baseurl.$sub_dir;
1326 1326
             /*
1327 1327
              * Allows the filter of image src for such things as CDN change.
1328 1328
              *
@@ -1332,8 +1332,8 @@  discard block
 block discarded – undo
1332 1332
              * @param string $uploads_url The server upload directory url.
1333 1333
              * @param string $uploads_baseurl The uploads dir base url.
1334 1334
              */
1335
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1336
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1335
+            $img_arr['src'] = apply_filters('geodir_get_featured_image_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
1336
+            $img_arr['path'] = $uploads_path.'/'.$file_name;
1337 1337
             $width = 0;
1338 1338
             $height = 0;
1339 1339
             if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
                 $file_name = $file_info['basename'];
1377 1377
 
1378 1378
                 $img_arr['src'] = $default_img;
1379
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1379
+                $img_arr['path'] = $uploads_path.'/'.$file_name;
1380 1380
 
1381 1381
                 $width = 0;
1382 1382
                 $height = 0;
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
         }
1394 1394
 
1395 1395
         if (!empty($img_arr))
1396
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1396
+            return (object) $img_arr; //return (object)array( 'src' => $file_url, 'path' => $file_path );
1397 1397
         else
1398 1398
             return false;
1399 1399
     }
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 
1457 1457
         $arrImages = $wpdb->get_results(
1458 1458
             $wpdb->prepare(
1459
-                "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 ",
1459
+                "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 ",
1460 1460
                 array('%image%', $post_id)
1461 1461
             )
1462 1462
         );
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 
1483 1483
                 $file_name = $file_info['basename'];
1484 1484
 
1485
-                $uploads_url = $uploads_baseurl . $sub_dir;
1485
+                $uploads_url = $uploads_baseurl.$sub_dir;
1486 1486
                 /*
1487 1487
                 * Allows the filter of image src for such things as CDN change.
1488 1488
                 *
@@ -1492,8 +1492,8 @@  discard block
 block discarded – undo
1492 1492
                 * @param string $uploads_url The server upload directory url.
1493 1493
                 * @param string $uploads_baseurl The uploads dir base url.
1494 1494
                 */
1495
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1496
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1495
+                $img_arr['src'] = apply_filters('geodir_get_images_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
1496
+                $img_arr['path'] = $uploads_path.'/'.$file_name;
1497 1497
                 $width = 0;
1498 1498
                 $height = 0;
1499 1499
                 if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
@@ -1510,11 +1510,11 @@  discard block
 block discarded – undo
1510 1510
                 $img_arr['content'] = $attechment->content; // add the description to the array
1511 1511
                 $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1512 1512
 
1513
-                $return_arr[] = (object)$img_arr;
1513
+                $return_arr[] = (object) $img_arr;
1514 1514
 
1515 1515
                 $counter++;
1516 1516
             }
1517
-            return (object)$return_arr;
1517
+            return (object) $return_arr;
1518 1518
         } else if ($no_images) {
1519 1519
             $default_img = '';
1520 1520
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
                 $img_arr['title'] = $file_info['filename']; // add the title to the array
1554 1554
                 $img_arr['content'] = $file_info['filename']; // add the description to the array
1555 1555
 
1556
-                $return_arr[] = (object)$img_arr;
1556
+                $return_arr[] = (object) $img_arr;
1557 1557
 
1558 1558
                 return $return_arr;
1559 1559
             } else
@@ -1580,8 +1580,8 @@  discard block
 block discarded – undo
1580 1580
 
1581 1581
         $html = '';
1582 1582
         if (!empty($request)) {
1583
-            if (!is_object($request)){
1584
-                $request = (object)$request;
1583
+            if (!is_object($request)) {
1584
+                $request = (object) $request;
1585 1585
             }
1586 1586
 
1587 1587
             if (isset($request->src) && !isset($request->path)) {
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
             $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1596 1596
             $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1597 1597
             if (strpos($img_no_http, $upload_no_http) !== false) {
1598
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1598
+                $request->path = str_replace($img_no_http, $upload_dir['basedir'], $request->path);
1599 1599
             }
1600 1600
             
1601 1601
             $width = 0;
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
             $image->width = $width;
1611 1611
             $image->height = $height;
1612 1612
 
1613
-            $max_size = (object)geodir_get_imagesize($size);
1613
+            $max_size = (object) geodir_get_imagesize($size);
1614 1614
 
1615 1615
             if (!is_wp_error($max_size)) {
1616 1616
                 if ($image->width) {
@@ -1622,15 +1622,15 @@  discard block
 block discarded – undo
1622 1622
                         $width_per = 100;
1623 1623
                 }
1624 1624
 
1625
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1626
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1625
+                if (is_admin() && !isset($_REQUEST['geodir_ajax'])) {
1626
+                    $html = '<div class="geodir_thumbnail"><img style="max-height:'.$max_size->h.'px;" alt="place image" src="'.$image->src.'"  /></div>';
1627 1627
                 } else {
1628
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1629
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1630
-                    }else{
1628
+                    if ($size == 'widget-thumb' || !get_option('geodir_lazy_load', 1)) {
1629
+                        $html = '<div class="geodir_thumbnail" style="background-image:url(\''.$image->src.'\');"></div>';
1630
+                    } else {
1631 1631
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1632 1632
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1633
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1633
+                        $html = '<div data-src="'.str_replace(' ', '%20', $image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1634 1634
 
1635 1635
                     }
1636 1636
 
@@ -1666,15 +1666,15 @@  discard block
 block discarded – undo
1666 1666
 
1667 1667
         $post_type = get_post_type($post_id);
1668 1668
 
1669
-        $table = $plugin_prefix . $post_type . '_detail';
1669
+        $table = $plugin_prefix.$post_type.'_detail';
1670 1670
 
1671 1671
         if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1672 1672
 
1673
-            if ($taxonomy == $post_type . '_tags') {
1673
+            if ($taxonomy == $post_type.'_tags') {
1674 1674
                 if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1675 1675
                     geodir_save_post_meta($post_id, 'post_tags', $terms);
1676 1676
                 }
1677
-            } elseif ($taxonomy == $post_type . 'category') {
1677
+            } elseif ($taxonomy == $post_type.'category') {
1678 1678
                 $srcharr = array('"', '\\');
1679 1679
                 $replarr = array("&quot;", '');
1680 1680
 
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 
1697 1697
                     $wpdb->get_var(
1698 1698
                         $wpdb->prepare(
1699
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1699
+                            "DELETE from ".GEODIR_ICON_TABLE." WHERE cat_id NOT IN ($format) AND post_id = %d ",
1700 1700
                             $cat_ids_array_del
1701 1701
                         )
1702 1702
                     );
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 
1705 1705
                     $post_term = $wpdb->get_col(
1706 1706
                         $wpdb->prepare(
1707
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1707
+                            "SELECT term_id FROM ".$wpdb->term_taxonomy." WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1708 1708
                             $cat_ids_array
1709 1709
                         )
1710 1710
                     );
@@ -1726,16 +1726,16 @@  discard block
 block discarded – undo
1726 1726
                         $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1727 1727
                         $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1728 1728
 
1729
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1730
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1729
+                        $timing = ' - '.date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1730
+                        $timing .= ' - '.geodir_get_post_meta($post_id, 'st_time', true);
1731 1731
 
1732 1732
                         $json = '{';
1733
-                        $json .= '"id":"' . $post_id . '",';
1734
-                        $json .= '"lat_pos": "' . $lat . '",';
1735
-                        $json .= '"long_pos": "' . $lng . '",';
1736
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1737
-                        $json .= '"icon":"' . $term_icon . '",';
1738
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1733
+                        $json .= '"id":"'.$post_id.'",';
1734
+                        $json .= '"lat_pos": "'.$lat.'",';
1735
+                        $json .= '"long_pos": "'.$lng.'",';
1736
+                        $json .= '"marker_id":"'.$post_id.'_'.$cat_id.'",';
1737
+                        $json .= '"icon":"'.$term_icon.'",';
1738
+                        $json .= '"group":"catgroup'.$cat_id.'"';
1739 1739
                         $json .= '}';
1740 1740
 
1741 1741
 
@@ -1743,9 +1743,9 @@  discard block
 block discarded – undo
1743 1743
                             $post_marker_json = $json;
1744 1744
 
1745 1745
 
1746
-                        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)))) {
1746
+                        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)))) {
1747 1747
 
1748
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1748
+                            $json_query = $wpdb->prepare("UPDATE ".GEODIR_ICON_TABLE." SET
1749 1749
 										post_title = %s,
1750 1750
 										json = %s
1751 1751
 										WHERE post_id = %d AND cat_id = %d ",
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 
1754 1754
                         } else {
1755 1755
 
1756
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1756
+                            $json_query = $wpdb->prepare("INSERT INTO ".GEODIR_ICON_TABLE." SET
1757 1757
 										post_id = %d,
1758 1758
 										post_title = %s,
1759 1759
 										cat_id = %d,
@@ -1771,17 +1771,17 @@  discard block
 block discarded – undo
1771 1771
                 if (!empty($post_term) && is_array($post_term)) {
1772 1772
                     $categories = implode(',', $post_term);
1773 1773
 
1774
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1774
+                    if ($categories != '' && $categories != 0) $categories = ','.$categories.',';
1775 1775
 
1776 1776
                     if (empty($post_marker_json))
1777 1777
                         $post_marker_json = isset($json) ? $json : '';
1778 1778
 
1779
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1779
+                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
1780 1780
 
1781 1781
                         $wpdb->query(
1782 1782
                             $wpdb->prepare(
1783
-                                "UPDATE " . $table . " SET
1784
-								" . $taxonomy . " = %s,
1783
+                                "UPDATE ".$table." SET
1784
+								" . $taxonomy." = %s,
1785 1785
 								marker_json = %s
1786 1786
 								where post_id = %d",
1787 1787
                                 array($categories, $post_marker_json, $post_id)
@@ -1802,7 +1802,7 @@  discard block
 block discarded – undo
1802 1802
 
1803 1803
                                     $wpdb->query(
1804 1804
                                         $wpdb->prepare(
1805
-                                            "UPDATE " . $table . " SET
1805
+                                            "UPDATE ".$table." SET
1806 1806
 											default_category = %s
1807 1807
 											where post_id = %d",
1808 1808
                                             array($categories[0], $post_id)
@@ -1827,9 +1827,9 @@  discard block
 block discarded – undo
1827 1827
 
1828 1828
                         $wpdb->query(
1829 1829
                             $wpdb->prepare(
1830
-                                "INSERT INTO " . $table . " SET
1830
+                                "INSERT INTO ".$table." SET
1831 1831
 								post_id = %d,
1832
-								" . $taxonomy . " = %s,
1832
+								" . $taxonomy." = %s,
1833 1833
 								marker_json = %s ",
1834 1834
 
1835 1835
                                 array($post_id, $categories, $post_marker_json)
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1956 1956
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1957 1957
                             <?php
1958
-                            }else{
1958
+                            } else {
1959 1959
                                 echo '<div class="geodir-bubble_image"></div>';
1960 1960
                             }
1961 1961
                         } else {
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
                                 ?>
1964 1964
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1965 1965
                             <?php
1966
-                            }else{
1966
+                            } else {
1967 1967
                                 echo '<div class="geodir-bubble_image"></div>';
1968 1968
                             }
1969 1969
                         }
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
                              * @param object $postinfo_obj The posts info as an object.
1994 1994
                              * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1995 1995
                              */
1996
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1996
+                            do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview);
1997 1997
                             ?>
1998 1998
                         </div>
1999 1999
                         <?php
@@ -2003,9 +2003,9 @@  discard block
 block discarded – undo
2003 2003
                             <div class="geodir-bubble-meta-fade"></div>
2004 2004
                             <div class="geodir-bubble-meta-bottom">
2005 2005
                                 <?php if ($rating_star != '') { ?>
2006
-                                <span class="geodir-bubble-rating"><?php echo $rating_star;?></span>
2006
+                                <span class="geodir-bubble-rating"><?php echo $rating_star; ?></span>
2007 2007
                                 <?php } ?>
2008
-                                <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID);?></span>
2008
+                                <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?></span>
2009 2009
                                 <span class="geodir-bubble-reviews">
2010 2010
                                     <a href="<?php echo get_comments_link($ID); ?>" class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?></a>
2011 2011
                                 </span>
@@ -2067,11 +2067,11 @@  discard block
 block discarded – undo
2067 2067
 
2068 2068
         $post_type = get_post_type($post_id);
2069 2069
 
2070
-        $table = $plugin_prefix . $post_type . '_detail';
2070
+        $table = $plugin_prefix.$post_type.'_detail';
2071 2071
 
2072 2072
         $wpdb->query(
2073 2073
             $wpdb->prepare(
2074
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2074
+                "UPDATE ".$table." SET post_status=%s WHERE post_id=%d",
2075 2075
                 array($status, $post_id)
2076 2076
             )
2077 2077
         );
@@ -2143,18 +2143,18 @@  discard block
 block discarded – undo
2143 2143
 
2144 2144
         $post_type = get_post_type($post_id);
2145 2145
 
2146
-        $table = $plugin_prefix . $post_type . '_detail';
2146
+        $table = $plugin_prefix.$post_type.'_detail';
2147 2147
 
2148 2148
         $wpdb->query(
2149 2149
             $wpdb->prepare(
2150
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2150
+                "UPDATE ".$table." SET `post_id` = %d WHERE `post_id` = %d",
2151 2151
                 array($updatingpost, $temppost)
2152 2152
             )
2153 2153
         );
2154 2154
 
2155 2155
         $wpdb->query(
2156 2156
             $wpdb->prepare(
2157
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2157
+                "UPDATE ".GEODIR_ICON_TABLE." SET `post_id` = %d WHERE `post_id` = %d",
2158 2158
                 array($updatingpost, $temppost)
2159 2159
             )
2160 2160
         );
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
 
2164 2164
         $wpdb->query(
2165 2165
             $wpdb->prepare(
2166
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2166
+                "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET `post_id` = %d WHERE `post_id` = %d",
2167 2167
                 array($updatingpost, $temppost)
2168 2168
             )
2169 2169
         );
@@ -2201,12 +2201,12 @@  discard block
 block discarded – undo
2201 2201
         if (!in_array($post_type, $all_postypes))
2202 2202
             return false;
2203 2203
 
2204
-        $table = $plugin_prefix . $post_type . '_detail';
2204
+        $table = $plugin_prefix.$post_type.'_detail';
2205 2205
 
2206 2206
         /* Delete custom post meta*/
2207 2207
         $wpdb->query(
2208 2208
             $wpdb->prepare(
2209
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2209
+                "DELETE FROM ".$table." WHERE `post_id` = %d",
2210 2210
                 array($deleted_postid)
2211 2211
             )
2212 2212
         );
@@ -2215,7 +2215,7 @@  discard block
 block discarded – undo
2215 2215
 
2216 2216
         $wpdb->query(
2217 2217
             $wpdb->prepare(
2218
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2218
+                "DELETE FROM ".GEODIR_ICON_TABLE." WHERE `post_id` = %d",
2219 2219
                 array($deleted_postid)
2220 2220
             )
2221 2221
         );
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
 
2226 2226
         $wpdb->query(
2227 2227
             $wpdb->prepare(
2228
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2228
+                "DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE `post_id` = %d",
2229 2229
                 array($deleted_postid)
2230 2230
             )
2231 2231
         );
@@ -2297,7 +2297,7 @@  discard block
 block discarded – undo
2297 2297
          */
2298 2298
         do_action('geodir_before_add_from_favorite', $post_id);
2299 2299
 
2300
-        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>';
2300
+        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>';
2301 2301
 
2302 2302
         /**
2303 2303
          * Called after adding the post from favourites.
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
          */
2377 2377
         do_action('geodir_before_remove_from_favorite', $post_id);
2378 2378
 
2379
-        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>';
2379
+        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>';
2380 2380
 
2381 2381
         /**
2382 2382
          * Called after removing the post from favourites.
@@ -2471,24 +2471,24 @@  discard block
 block discarded – undo
2471 2471
             $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2472 2472
 
2473 2473
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2474
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2474
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"  ><a
2475 2475
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2476
-                onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2477
-                title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2476
+                onclick="javascript:addToFavourite(<?php echo $post_id; ?>,'remove');"
2477
+                title="<?php echo $remove_favourite_text; ?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text; ?>
2478 2478
             </a>   </span><?php
2479 2479
 
2480 2480
         } else {
2481 2481
 
2482 2482
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2483
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2483
+                $script_text = 'javascript:window.location.href=\''.geodir_login_url().'\'';
2484 2484
             } else
2485
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2485
+                $script_text = 'javascript:addToFavourite('.$post_id.',\'add\')';
2486 2486
 
2487
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2487
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"><a class="geodir-addtofav-icon"
2488 2488
                                                                                         href="javascript:void(0);"
2489
-                                                                                        onclick="<?php echo $script_text;?>"
2490
-                                                                                        title="<?php echo $add_favourite_text;?>"><i
2491
-                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2489
+                                                                                        onclick="<?php echo $script_text; ?>"
2490
+                                                                                        title="<?php echo $add_favourite_text; ?>"><i
2491
+                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text; ?></a></span>
2492 2492
         <?php }
2493 2493
     }
2494 2494
 }
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
 
2519 2519
             $post_type = $taxonomy_obj->object_type[0];
2520 2520
 
2521
-            $table = $plugin_prefix . $post_type . '_detail';
2521
+            $table = $plugin_prefix.$post_type.'_detail';
2522 2522
 
2523 2523
             /**
2524 2524
              * Filter to modify the 'join' query
@@ -2541,8 +2541,8 @@  discard block
 block discarded – undo
2541 2541
             $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2542 2542
 
2543 2543
             $count_query = "SELECT count(post_id) FROM
2544
-							" . $table . " as pd " . $join . "
2545
-							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2544
+							" . $table." as pd ".$join."
2545
+							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id."',".$term->taxonomy.") ".$where;
2546 2546
 
2547 2547
             $cat_post_count = $wpdb->get_var($count_query);
2548 2548
             if (empty($cat_post_count) || is_wp_error($cat_post_count))
@@ -2625,7 +2625,7 @@  discard block
 block discarded – undo
2625 2625
     global $post;
2626 2626
     $all_postypes = geodir_get_posttypes();
2627 2627
     if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2628
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2628
+        return ' <a href="'.get_permalink($post->ID).'">'.READ_MORE_TXT.'</a>';
2629 2629
     }
2630 2630
 
2631 2631
     return $more;
@@ -2652,14 +2652,14 @@  discard block
 block discarded – undo
2652 2652
     if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2653 2653
 
2654 2654
         $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2655
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2655
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
2656 2656
 
2657 2657
         $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2658
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2658
+        $term_icon = $path_parts['dirname'].'/cat_icon_'.$term_id.'.png';
2659 2659
 
2660 2660
         $posts = $wpdb->get_results(
2661 2661
             $wpdb->prepare(
2662
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2662
+                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM ".$table." WHERE FIND_IN_SET(%s,%1\$s ) ",
2663 2663
                 array($term_id, $taxonomy)
2664 2664
             )
2665 2665
         );
@@ -2671,19 +2671,19 @@  discard block
 block discarded – undo
2671 2671
                 $lng = $post_obj->post_longitude;
2672 2672
 
2673 2673
                 $json = '{';
2674
-                $json .= '"id":"' . $post_obj->post_id . '",';
2675
-                $json .= '"lat_pos": "' . $lat . '",';
2676
-                $json .= '"long_pos": "' . $lng . '",';
2677
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2678
-                $json .= '"icon":"' . $term_icon . '",';
2679
-                $json .= '"group":"catgroup' . $term_id . '"';
2674
+                $json .= '"id":"'.$post_obj->post_id.'",';
2675
+                $json .= '"lat_pos": "'.$lat.'",';
2676
+                $json .= '"long_pos": "'.$lng.'",';
2677
+                $json .= '"marker_id":"'.$post_obj->post_id.'_'.$term_id.'",';
2678
+                $json .= '"icon":"'.$term_icon.'",';
2679
+                $json .= '"group":"catgroup'.$term_id.'"';
2680 2680
                 $json .= '}';
2681 2681
 
2682 2682
                 if ($post_obj->default_category == $term_id) {
2683 2683
 
2684 2684
                     $wpdb->query(
2685 2685
                         $wpdb->prepare(
2686
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2686
+                            "UPDATE ".$table." SET marker_json = %s where post_id = %d",
2687 2687
                             array($json, $post_obj->post_id)
2688 2688
                         )
2689 2689
                     );
@@ -2691,7 +2691,7 @@  discard block
 block discarded – undo
2691 2691
 
2692 2692
                 $wpdb->query(
2693 2693
                     $wpdb->prepare(
2694
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2694
+                        "UPDATE ".GEODIR_ICON_TABLE." SET json = %s WHERE post_id = %d AND cat_id = %d",
2695 2695
                         array($json, $post_obj->post_id, $term_id)
2696 2696
                     )
2697 2697
                 );
@@ -2815,7 +2815,7 @@  discard block
 block discarded – undo
2815 2815
 //	print_r($uploads ) ;
2816 2816
     $post_first_image = $wpdb->get_results(
2817 2817
         $wpdb->prepare(
2818
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2818
+            "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d and menu_order = 1  ", array($post_id)
2819 2819
         )
2820 2820
     );
2821 2821
 
@@ -2836,9 +2836,9 @@  discard block
 block discarded – undo
2836 2836
 
2837 2837
         $post_type = get_post_type($post_id);
2838 2838
 
2839
-        $table_name = $plugin_prefix . $post_type . '_detail';
2839
+        $table_name = $plugin_prefix.$post_type.'_detail';
2840 2840
 
2841
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2841
+        $wpdb->query("UPDATE ".$table_name." SET featured_image='".$post_first_image[0]->file."' WHERE post_id =".$post_id);
2842 2842
 
2843 2843
         $new_attachment_name = basename($post_first_image[0]->file);
2844 2844
 
@@ -2851,11 +2851,11 @@  discard block
 block discarded – undo
2851 2851
                 wp_delete_attachment($post_thumbnail_id);
2852 2852
 
2853 2853
             }
2854
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2854
+            $filename = $uploads['basedir'].$post_first_image[0]->file;
2855 2855
 
2856 2856
             $attachment = array(
2857 2857
                 'post_mime_type' => $post_first_image[0]->mime_type,
2858
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2858
+                'guid' => $uploads['baseurl'].$post_first_image[0]->file,
2859 2859
                 'post_parent' => $post_id,
2860 2860
                 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2861 2861
                 'post_content' => ''
@@ -2868,7 +2868,7 @@  discard block
 block discarded – undo
2868 2868
 
2869 2869
                 set_post_thumbnail($post_id, $id);
2870 2870
 
2871
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2871
+                require_once(ABSPATH.'wp-admin/includes/image.php');
2872 2872
                 wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2873 2873
 
2874 2874
             }
@@ -2901,35 +2901,35 @@  discard block
 block discarded – undo
2901 2901
         $post_id = absint($_POST['post_id']);
2902 2902
         $upload_dir = wp_upload_dir();
2903 2903
         $post_type = get_post_type($_POST['post_id']);
2904
-        $table = $plugin_prefix . $post_type . '_detail';
2904
+        $table = $plugin_prefix.$post_type.'_detail';
2905 2905
 
2906 2906
         $post_arr = $wpdb->get_results($wpdb->prepare(
2907
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2907
+            "SELECT * FROM $wpdb->posts p JOIN ".$table." gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2908 2908
             array($post_id)
2909 2909
         )
2910 2910
             , ARRAY_A);
2911 2911
 
2912 2912
         $arrImages = $wpdb->get_results(
2913 2913
             $wpdb->prepare(
2914
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2914
+                "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2915 2915
                 array('%image%', $post_id)
2916 2916
             )
2917 2917
         );
2918 2918
         if ($arrImages) {
2919 2919
             $image_arr = array();
2920 2920
             foreach ($arrImages as $img) {
2921
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2921
+                $image_arr[] = $upload_dir['baseurl'].$img->file;
2922 2922
             }
2923 2923
             $comma_separated = implode(",", $image_arr);
2924 2924
             $post_arr[0]['post_images'] = $comma_separated;
2925 2925
         }
2926 2926
 
2927 2927
 
2928
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2928
+        $cats = $post_arr[0][$post_arr[0]['post_type'].'category'];
2929 2929
         $cat_arr = array_filter(explode(",", $cats));
2930 2930
         $trans_cat = array();
2931 2931
         foreach ($cat_arr as $cat) {
2932
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2932
+            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'].'category', false);
2933 2933
         }
2934 2934
 
2935 2935
 
@@ -2971,7 +2971,7 @@  discard block
 block discarded – undo
2971 2971
 
2972 2972
     $get_data = $wpdb->get_results(
2973 2973
         $wpdb->prepare(
2974
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2974
+            "SELECT htmlvar_name, field_type, extra_fields FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1'",
2975 2975
             array($listing_type)
2976 2976
         )
2977 2977
     );
@@ -2984,12 +2984,12 @@  discard block
 block discarded – undo
2984 2984
 
2985 2985
                 $extra_fields = unserialize($data->extra_fields);
2986 2986
 
2987
-                $prefix = $data->htmlvar_name . '_';
2987
+                $prefix = $data->htmlvar_name.'_';
2988 2988
 
2989
-                $fields_info[$prefix . 'address'] = $data->field_type;
2989
+                $fields_info[$prefix.'address'] = $data->field_type;
2990 2990
 
2991 2991
                 if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2992
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
2992
+                    $fields_info[$prefix.'zip'] = $data->field_type;
2993 2993
 
2994 2994
             } else {
2995 2995
 
@@ -3087,13 +3087,13 @@  discard block
 block discarded – undo
3087 3087
  * @since 1.4.9
3088 3088
  * @package GeoDirectory
3089 3089
  */
3090
-function geodir_fb_like_thumbnail(){
3090
+function geodir_fb_like_thumbnail() {
3091 3091
 
3092 3092
     // return if not a single post
3093
-    if(!is_single()){return;}
3093
+    if (!is_single()) {return; }
3094 3094
 
3095 3095
     global $post;
3096
-    if(isset($post->featured_image) && $post->featured_image){
3096
+    if (isset($post->featured_image) && $post->featured_image) {
3097 3097
         $upload_dir = wp_upload_dir();
3098 3098
         $thumb = $upload_dir['baseurl'].$post->featured_image;
3099 3099
         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   +171 added lines, -121 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
 
@@ -899,8 +912,9 @@  discard block
 block discarded – undo
899 912
             $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
900 913
             if ($meta_value && $meta_value !== '') {
901 914
                 return maybe_serialize($meta_value);
902
-            } else
903
-                return $meta_value;
915
+            } else {
916
+                            return $meta_value;
917
+            }
904 918
         } else {
905 919
             return false;
906 920
         }
@@ -1034,7 +1048,7 @@  discard block
 block discarded – undo
1034 1048
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035 1049
                                 $new_name = basename($uploaded['file']);
1036 1050
                                 $uploaded_file = $uploaded;
1037
-                            }else{
1051
+                            } else{
1038 1052
                                 print_r($uploaded);exit;
1039 1053
                             }
1040 1054
                             $external_img = false;
@@ -1059,8 +1073,9 @@  discard block
 block discarded – undo
1059 1073
                                 $file_path = $curr_img_dir . '/' . $filename;
1060 1074
                             }
1061 1075
 
1062
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
-                                unlink($img_path);
1076
+                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) {
1077
+                                                            unlink($img_path);
1078
+                            }
1064 1079
                         }
1065 1080
 
1066 1081
                         if (!empty($uploaded_file)) {
@@ -1089,8 +1104,9 @@  discard block
 block discarded – undo
1089 1104
                             $attachment_set = '';
1090 1105
 
1091 1106
                             foreach ($attachment as $key => $val) {
1092
-                                if ($val != '')
1093
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1107
+                                if ($val != '') {
1108
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1109
+                                }
1094 1110
                             }
1095 1111
 
1096 1112
                             $attachment_set = trim($attachment_set, ", ");
@@ -1115,8 +1131,9 @@  discard block
 block discarded – undo
1115 1131
                         )
1116 1132
                     );
1117 1133
 
1118
-                    if ($menu_order == 1)
1119
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1134
+                    if ($menu_order == 1) {
1135
+                                            $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1136
+                    }
1120 1137
 
1121 1138
                 }
1122 1139
 
@@ -1157,8 +1174,9 @@  discard block
 block discarded – undo
1157 1174
 
1158 1175
         $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1159 1176
 
1160
-        if (!empty($invalid_files))
1161
-            geodir_remove_attachments($invalid_files);
1177
+        if (!empty($invalid_files)) {
1178
+                    geodir_remove_attachments($invalid_files);
1179
+        }
1162 1180
     }
1163 1181
 
1164 1182
 }
@@ -1211,16 +1229,19 @@  discard block
 block discarded – undo
1211 1229
 function geodir_delete_directory($dirname)
1212 1230
 {
1213 1231
     $dir_handle = '';
1214
-    if (is_dir($dirname))
1215
-        $dir_handle = opendir($dirname);
1216
-    if (!$dir_handle)
1217
-        return false;
1232
+    if (is_dir($dirname)) {
1233
+            $dir_handle = opendir($dirname);
1234
+    }
1235
+    if (!$dir_handle) {
1236
+            return false;
1237
+    }
1218 1238
     while ($file = readdir($dir_handle)) {
1219 1239
         if ($file != "." && $file != "..") {
1220
-            if (!is_dir($dirname . "/" . $file))
1221
-                unlink($dirname . "/" . $file);
1222
-            else
1223
-                geodir_delete_directory($dirname . '/' . $file);
1240
+            if (!is_dir($dirname . "/" . $file)) {
1241
+                            unlink($dirname . "/" . $file);
1242
+            } else {
1243
+                            geodir_delete_directory($dirname . '/' . $file);
1244
+            }
1224 1245
         }
1225 1246
     }
1226 1247
     closedir($dir_handle);
@@ -1249,8 +1270,9 @@  discard block
 block discarded – undo
1249 1270
             foreach ($postcurr_images as $postimg) {
1250 1271
                 $image_name_arr = explode('/', $postimg->src);
1251 1272
                 $filename = end($image_name_arr);
1252
-                if (file_exists($uploads_dir . '/' . $filename))
1253
-                    unlink($uploads_dir . '/' . $filename);
1273
+                if (file_exists($uploads_dir . '/' . $filename)) {
1274
+                                    unlink($uploads_dir . '/' . $filename);
1275
+                }
1254 1276
             }
1255 1277
 
1256 1278
         } // endif
@@ -1358,9 +1380,9 @@  discard block
 block discarded – undo
1358 1380
                 $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1359 1381
             }
1360 1382
 
1361
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1362
-                $default_img = $default_catimg['src'];
1363
-            elseif ($no_image) {
1383
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1384
+                            $default_img = $default_catimg['src'];
1385
+            } elseif ($no_image) {
1364 1386
                 $default_img = get_option('geodir_listing_no_img');
1365 1387
             }
1366 1388
 
@@ -1392,10 +1414,13 @@  discard block
 block discarded – undo
1392 1414
             }
1393 1415
         }
1394 1416
 
1395
-        if (!empty($img_arr))
1396
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1397
-        else
1398
-            return false;
1417
+        if (!empty($img_arr)) {
1418
+                    return (object)$img_arr;
1419
+        }
1420
+        //return (object)array( 'src' => $file_url, 'path' => $file_path );
1421
+        else {
1422
+                    return false;
1423
+        }
1399 1424
     }
1400 1425
 }
1401 1426
 
@@ -1422,8 +1447,9 @@  discard block
 block discarded – undo
1422 1447
             echo $html;
1423 1448
         } elseif (!empty($html)) {
1424 1449
             return $html;
1425
-        } else
1426
-            return false;
1450
+        } else {
1451
+                    return false;
1452
+        }
1427 1453
     }
1428 1454
 }
1429 1455
 
@@ -1451,8 +1477,9 @@  discard block
 block discarded – undo
1451 1477
         }
1452 1478
         $not_featured = '';
1453 1479
         $sub_dir = '';
1454
-        if (!$add_featured)
1455
-            $not_featured = " AND is_featured = 0 ";
1480
+        if (!$add_featured) {
1481
+                    $not_featured = " AND is_featured = 0 ";
1482
+        }
1456 1483
 
1457 1484
         $arrImages = $wpdb->get_results(
1458 1485
             $wpdb->prepare(
@@ -1473,8 +1500,9 @@  discard block
 block discarded – undo
1473 1500
 
1474 1501
                 $file_info = pathinfo($attechment->file);
1475 1502
 
1476
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1477
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1503
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1504
+                                    $sub_dir = stripslashes_deep($file_info['dirname']);
1505
+                }
1478 1506
 
1479 1507
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1480 1508
                 $uploads_baseurl = $uploads['baseurl'];
@@ -1519,9 +1547,9 @@  discard block
 block discarded – undo
1519 1547
             $default_img = '';
1520 1548
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1521 1549
             $post_type = get_post_type($post_id);
1522
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1523
-                $default_img = $default_catimg['src'];
1524
-            elseif ($no_images) {
1550
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1551
+                            $default_img = $default_catimg['src'];
1552
+            } elseif ($no_images) {
1525 1553
                 $default_img = get_option('geodir_listing_no_img');
1526 1554
             }
1527 1555
 
@@ -1556,8 +1584,9 @@  discard block
 block discarded – undo
1556 1584
                 $return_arr[] = (object)$img_arr;
1557 1585
 
1558 1586
                 return $return_arr;
1559
-            } else
1560
-                return false;
1587
+            } else {
1588
+                            return false;
1589
+            }
1561 1590
         }
1562 1591
     }
1563 1592
 }
@@ -1618,8 +1647,9 @@  discard block
 block discarded – undo
1618 1647
                         $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1619 1648
                     } else if ($image->width < ($max_size->h)) {
1620 1649
                         $width_per = round((($image->width / $max_size->w) * 100), 2);
1621
-                    } else
1622
-                        $width_per = 100;
1650
+                    } else {
1651
+                                            $width_per = 100;
1652
+                    }
1623 1653
                 }
1624 1654
 
1625 1655
                 if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
@@ -1627,7 +1657,7 @@  discard block
 block discarded – undo
1627 1657
                 } else {
1628 1658
                     if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1629 1659
                         $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1630
-                    }else{
1660
+                    } else{
1631 1661
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1632 1662
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1633 1663
                         $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
@@ -1642,8 +1672,9 @@  discard block
 block discarded – undo
1642 1672
             echo $html;
1643 1673
         } elseif (!empty($html)) {
1644 1674
             return $html;
1645
-        } else
1646
-            return false;
1675
+        } else {
1676
+                    return false;
1677
+        }
1647 1678
     }
1648 1679
 }
1649 1680
 
@@ -1681,8 +1712,9 @@  discard block
 block discarded – undo
1681 1712
                 $post_obj = get_post($post_id);
1682 1713
 
1683 1714
                 $cat_ids = array('0');
1684
-                if (is_array($tt_ids))
1685
-                    $cat_ids = $tt_ids;
1715
+                if (is_array($tt_ids)) {
1716
+                                    $cat_ids = $tt_ids;
1717
+                }
1686 1718
 
1687 1719
 
1688 1720
                 if (!empty($cat_ids)) {
@@ -1739,8 +1771,9 @@  discard block
 block discarded – undo
1739 1771
                         $json .= '}';
1740 1772
 
1741 1773
 
1742
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1743
-                            $post_marker_json = $json;
1774
+                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) {
1775
+                                                    $post_marker_json = $json;
1776
+                        }
1744 1777
 
1745 1778
 
1746 1779
                         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)))) {
@@ -1771,10 +1804,13 @@  discard block
 block discarded – undo
1771 1804
                 if (!empty($post_term) && is_array($post_term)) {
1772 1805
                     $categories = implode(',', $post_term);
1773 1806
 
1774
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1807
+                    if ($categories != '' && $categories != 0) {
1808
+                    	$categories = ',' . $categories . ',';
1809
+                    }
1775 1810
 
1776
-                    if (empty($post_marker_json))
1777
-                        $post_marker_json = isset($json) ? $json : '';
1811
+                    if (empty($post_marker_json)) {
1812
+                                            $post_marker_json = isset($json) ? $json : '';
1813
+                    }
1778 1814
 
1779 1815
                     if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1780 1816
 
@@ -1813,8 +1849,9 @@  discard block
 block discarded – undo
1813 1849
 
1814 1850
                                 }
1815 1851
 
1816
-                                if ($default_category == '')
1817
-                                    $default_category = $categories[0];
1852
+                                if ($default_category == '') {
1853
+                                                                    $default_category = $categories[0];
1854
+                                }
1818 1855
 
1819 1856
                                 geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1820 1857
 
@@ -1955,7 +1992,7 @@  discard block
 block discarded – undo
1955 1992
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1956 1993
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1957 1994
                             <?php
1958
-                            }else{
1995
+                            } else{
1959 1996
                                 echo '<div class="geodir-bubble_image"></div>';
1960 1997
                             }
1961 1998
                         } else {
@@ -1963,7 +2000,7 @@  discard block
 block discarded – undo
1963 2000
                                 ?>
1964 2001
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1965 2002
                             <?php
1966
-                            }else{
2003
+                            } else{
1967 2004
                                 echo '<div class="geodir-bubble_image"></div>';
1968 2005
                             }
1969 2006
                         }
@@ -2044,10 +2081,11 @@  discard block
 block discarded – undo
2044 2081
      */
2045 2082
     function geodir_new_post_default_status()
2046 2083
     {
2047
-        if (get_option('geodir_new_post_default_status'))
2048
-            return get_option('geodir_new_post_default_status');
2049
-        else
2050
-            return 'publish';
2084
+        if (get_option('geodir_new_post_default_status')) {
2085
+                    return get_option('geodir_new_post_default_status');
2086
+        } else {
2087
+                    return 'publish';
2088
+        }
2051 2089
 
2052 2090
     }
2053 2091
 }
@@ -2198,8 +2236,9 @@  discard block
 block discarded – undo
2198 2236
 
2199 2237
         $all_postypes = geodir_get_posttypes();
2200 2238
 
2201
-        if (!in_array($post_type, $all_postypes))
2202
-            return false;
2239
+        if (!in_array($post_type, $all_postypes)) {
2240
+                    return false;
2241
+        }
2203 2242
 
2204 2243
         $table = $plugin_prefix . $post_type . '_detail';
2205 2244
 
@@ -2467,8 +2506,9 @@  discard block
 block discarded – undo
2467 2506
         $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2468 2507
 
2469 2508
         $user_meta_data = '';
2470
-        if (isset($current_user->data->ID))
2471
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2509
+        if (isset($current_user->data->ID)) {
2510
+                    $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2511
+        }
2472 2512
 
2473 2513
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2474 2514
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
@@ -2481,8 +2521,9 @@  discard block
 block discarded – undo
2481 2521
 
2482 2522
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2483 2523
                 $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2484
-            } else
2485
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2524
+            } else {
2525
+                            $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2526
+            }
2486 2527
 
2487 2528
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2488 2529
                                                                                         href="javascript:void(0);"
@@ -2545,14 +2586,16 @@  discard block
 block discarded – undo
2545 2586
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2546 2587
 
2547 2588
             $cat_post_count = $wpdb->get_var($count_query);
2548
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2549
-                $cat_post_count = 0;
2589
+            if (empty($cat_post_count) || is_wp_error($cat_post_count)) {
2590
+                            $cat_post_count = 0;
2591
+            }
2550 2592
 
2551 2593
             return $cat_post_count;
2552 2594
 
2553
-        } else
2554
-
2555
-            return $term->count;
2595
+        } else {
2596
+        
2597
+            return $term->count;
2598
+        }
2556 2599
     }
2557 2600
     return false;
2558 2601
 
@@ -2599,13 +2642,15 @@  discard block
 block discarded – undo
2599 2642
 		return $length;
2600 2643
 	}
2601 2644
 	
2602
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2603
-        $length = get_option('geodir_desc_word_limit');
2604
-    elseif (get_query_var('excerpt_length'))
2605
-        $length = get_query_var('excerpt_length');
2645
+    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) {
2646
+            $length = get_option('geodir_desc_word_limit');
2647
+    } elseif (get_query_var('excerpt_length')) {
2648
+            $length = get_query_var('excerpt_length');
2649
+    }
2606 2650
 
2607
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2608
-        $length = get_option('geodir_author_desc_word_limit');
2651
+    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) {
2652
+            $length = get_option('geodir_author_desc_word_limit');
2653
+    }
2609 2654
 
2610 2655
     return $length;
2611 2656
 }
@@ -2738,10 +2783,11 @@  discard block
 block discarded – undo
2738 2783
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2739 2784
 {
2740 2785
     $listing_author_id = geodir_get_listing_author($listing_id);
2741
-    if ($listing_author_id == $user_id)
2742
-        return true;
2743
-    else
2744
-        return false;
2786
+    if ($listing_author_id == $user_id) {
2787
+            return true;
2788
+    } else {
2789
+            return false;
2790
+    }
2745 2791
 
2746 2792
 }
2747 2793
 
@@ -2790,10 +2836,11 @@  discard block
 block discarded – undo
2790 2836
     $pattern = '/-\d+x\d+\./';
2791 2837
     preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2792 2838
 
2793
-    if (empty($matches))
2794
-        return '';
2795
-    else
2796
-        return $file;
2839
+    if (empty($matches)) {
2840
+            return '';
2841
+    } else {
2842
+            return $file;
2843
+    }
2797 2844
 
2798 2845
 }
2799 2846
 
@@ -2878,8 +2925,9 @@  discard block
 block discarded – undo
2878 2925
     } else {
2879 2926
         //set_post_thumbnail($post_id,-1);
2880 2927
 
2881
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2882
-            wp_delete_attachment($post_thumbnail_id);
2928
+        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2929
+                    wp_delete_attachment($post_thumbnail_id);
2930
+        }
2883 2931
 
2884 2932
     }
2885 2933
 }
@@ -2964,8 +3012,9 @@  discard block
 block discarded – undo
2964 3012
 
2965 3013
     global $wpdb;
2966 3014
 
2967
-    if ($listing_type == '')
2968
-        $listing_type = 'gd_place';
3015
+    if ($listing_type == '') {
3016
+            $listing_type = 'gd_place';
3017
+    }
2969 3018
 
2970 3019
     $fields_info = array();
2971 3020
 
@@ -2988,8 +3037,9 @@  discard block
 block discarded – undo
2988 3037
 
2989 3038
                 $fields_info[$prefix . 'address'] = $data->field_type;
2990 3039
 
2991
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2992
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3040
+                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
3041
+                                    $fields_info[$prefix . 'zip'] = $data->field_type;
3042
+                }
2993 3043
 
2994 3044
             } else {
2995 3045
 
Please login to merge, or discard this patch.