Test Failed
Pull Request — master (#380)
by Kiran
14:52
created
geodirectory-functions/custom_fields_functions.php 2 patches
Indentation   +2258 added lines, -2258 removed lines patch added patch discarded remove patch
@@ -10,52 +10,52 @@  discard block
 block discarded – undo
10 10
 global $wpdb, $table_prefix;
11 11
 
12 12
 if (!function_exists('geodir_column_exist')) {
13
-    /**
14
-     * Check table column exist or not.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global object $wpdb WordPress Database object.
19
-     * @param string $db The table name.
20
-     * @param string $column The column name.
21
-     * @return bool If column exists returns true. Otherwise false.
22
-     */
23
-    function geodir_column_exist($db, $column)
24
-    {
25
-        global $wpdb;
26
-        $exists = false;
27
-        $columns = $wpdb->get_col("show columns from $db");
28
-        foreach ($columns as $c) {
29
-            if ($c == $column) {
30
-                $exists = true;
31
-                break;
32
-            }
33
-        }
34
-        return $exists;
35
-    }
13
+	/**
14
+	 * Check table column exist or not.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global object $wpdb WordPress Database object.
19
+	 * @param string $db The table name.
20
+	 * @param string $column The column name.
21
+	 * @return bool If column exists returns true. Otherwise false.
22
+	 */
23
+	function geodir_column_exist($db, $column)
24
+	{
25
+		global $wpdb;
26
+		$exists = false;
27
+		$columns = $wpdb->get_col("show columns from $db");
28
+		foreach ($columns as $c) {
29
+			if ($c == $column) {
30
+				$exists = true;
31
+				break;
32
+			}
33
+		}
34
+		return $exists;
35
+	}
36 36
 }
37 37
 
38 38
 if (!function_exists('geodir_add_column_if_not_exist')) {
39
-    /**
40
-     * Add column if table column not exist.
41
-     *
42
-     * @since 1.0.0
43
-     * @package GeoDirectory
44
-     * @global object $wpdb WordPress Database object.
45
-     * @param string $db The table name.
46
-     * @param string $column The column name.
47
-     * @param string $column_attr The column attributes.
48
-     */
49
-    function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50
-    {
51
-        global $wpdb;
52
-        $result = 0;// no rows affected
53
-        if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
-        }
57
-        return $result;
58
-    }
39
+	/**
40
+	 * Add column if table column not exist.
41
+	 *
42
+	 * @since 1.0.0
43
+	 * @package GeoDirectory
44
+	 * @global object $wpdb WordPress Database object.
45
+	 * @param string $db The table name.
46
+	 * @param string $column The column name.
47
+	 * @param string $column_attr The column attributes.
48
+	 */
49
+	function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL")
50
+	{
51
+		global $wpdb;
52
+		$result = 0;// no rows affected
53
+		if (!geodir_column_exist($db, $column)) {
54
+			if (!empty($db) && !empty($column))
55
+				$result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+		}
57
+		return $result;
58
+	}
59 59
 }
60 60
 
61 61
 /**
@@ -72,706 +72,706 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function geodir_post_custom_fields($package_id = '', $default = 'all', $post_type = 'gd_place', $fields_location = 'none')
74 74
 {
75
-    global $wpdb, $geodir_post_custom_fields_cache;
76
-
77
-    $cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
78
-
79
-    if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80
-        return $geodir_post_custom_fields_cache[$cache_stored];
81
-    }
82
-
83
-    $default_query = '';
84
-
85
-    if ($default == 'default')
86
-        $default_query .= " and is_admin IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query .= " and is_admin = '0' ";
89
-
90
-    if ($fields_location == 'none') {
91
-    } else{
92
-        $fields_location = esc_sql( $fields_location );
93
-        $default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94
-    }
95
-
96
-    $post_meta_info = $wpdb->get_results(
97
-        $wpdb->prepare(
98
-            "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99
-            array($post_type)
100
-        )
101
-    );
102
-
103
-
104
-    $return_arr = array();
105
-    if ($post_meta_info) {
106
-
107
-        foreach ($post_meta_info as $post_meta_info_obj) {
108
-
109
-            $custom_fields = array(
110
-                "name" => $post_meta_info_obj->htmlvar_name,
111
-                "label" => $post_meta_info_obj->clabels,
112
-                "default" => $post_meta_info_obj->default_value,
113
-                "type" => $post_meta_info_obj->field_type,
114
-                "desc" => $post_meta_info_obj->admin_desc);
115
-
116
-            if ($post_meta_info_obj->field_type) {
117
-                $options = explode(',', $post_meta_info_obj->option_values);
118
-                $custom_fields["options"] = $options;
119
-            }
120
-
121
-            foreach ($post_meta_info_obj as $key => $val) {
122
-                $custom_fields[$key] = $val;
123
-            }
124
-
125
-            $pricearr = array();
126
-            $pricearr = explode(',', $post_meta_info_obj->packages);
127
-
128
-            if ($package_id != '' && in_array($package_id, $pricearr)) {
129
-                $return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
130
-            } elseif ($package_id == '') {
131
-                $return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
132
-            }
133
-        }
134
-    }
135
-    $geodir_post_custom_fields_cache[$cache_stored] = $return_arr;
136
-
137
-    if (has_filter('geodir_filter_geodir_post_custom_fields')) {
138
-        /**
139
-         * Filter the post custom fields array.
140
-         *
141
-         * @since 1.0.0
142
-         *
143
-         * @param array $return_arr Post custom fields array.
144
-         * @param int|string $package_id The package ID.
145
-         * @param string $post_type Optional. The wordpress post type.
146
-         * @param string $fields_location Optional. Where exactly are you going to place this custom fields?.
147
-         */
148
-        $return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
149
-    }
150
-
151
-    return $return_arr;
75
+	global $wpdb, $geodir_post_custom_fields_cache;
76
+
77
+	$cache_stored = $post_type . '_' . $package_id . '_' . $default . '_' . $fields_location;
78
+
79
+	if (array_key_exists($cache_stored, $geodir_post_custom_fields_cache)) {
80
+		return $geodir_post_custom_fields_cache[$cache_stored];
81
+	}
82
+
83
+	$default_query = '';
84
+
85
+	if ($default == 'default')
86
+		$default_query .= " and is_admin IN ('1') ";
87
+	elseif ($default == 'custom')
88
+		$default_query .= " and is_admin = '0' ";
89
+
90
+	if ($fields_location == 'none') {
91
+	} else{
92
+		$fields_location = esc_sql( $fields_location );
93
+		$default_query .= " and show_in LIKE '%%[$fields_location]%%' ";
94
+	}
95
+
96
+	$post_meta_info = $wpdb->get_results(
97
+		$wpdb->prepare(
98
+			"select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where is_active = '1' and post_type = %s {$default_query} order by sort_order asc,admin_title asc",
99
+			array($post_type)
100
+		)
101
+	);
102
+
103
+
104
+	$return_arr = array();
105
+	if ($post_meta_info) {
106
+
107
+		foreach ($post_meta_info as $post_meta_info_obj) {
108
+
109
+			$custom_fields = array(
110
+				"name" => $post_meta_info_obj->htmlvar_name,
111
+				"label" => $post_meta_info_obj->clabels,
112
+				"default" => $post_meta_info_obj->default_value,
113
+				"type" => $post_meta_info_obj->field_type,
114
+				"desc" => $post_meta_info_obj->admin_desc);
115
+
116
+			if ($post_meta_info_obj->field_type) {
117
+				$options = explode(',', $post_meta_info_obj->option_values);
118
+				$custom_fields["options"] = $options;
119
+			}
120
+
121
+			foreach ($post_meta_info_obj as $key => $val) {
122
+				$custom_fields[$key] = $val;
123
+			}
124
+
125
+			$pricearr = array();
126
+			$pricearr = explode(',', $post_meta_info_obj->packages);
127
+
128
+			if ($package_id != '' && in_array($package_id, $pricearr)) {
129
+				$return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
130
+			} elseif ($package_id == '') {
131
+				$return_arr[$post_meta_info_obj->sort_order] = $custom_fields;
132
+			}
133
+		}
134
+	}
135
+	$geodir_post_custom_fields_cache[$cache_stored] = $return_arr;
136
+
137
+	if (has_filter('geodir_filter_geodir_post_custom_fields')) {
138
+		/**
139
+		 * Filter the post custom fields array.
140
+		 *
141
+		 * @since 1.0.0
142
+		 *
143
+		 * @param array $return_arr Post custom fields array.
144
+		 * @param int|string $package_id The package ID.
145
+		 * @param string $post_type Optional. The wordpress post type.
146
+		 * @param string $fields_location Optional. Where exactly are you going to place this custom fields?.
147
+		 */
148
+		$return_arr = apply_filters('geodir_filter_geodir_post_custom_fields', $return_arr, $package_id, $post_type, $fields_location);
149
+	}
150
+
151
+	return $return_arr;
152 152
 }
153 153
 
154
-    /**
155
-     * Adds admin html for custom fields.
156
-     *
157
-     * @since 1.0.0
158
-     * @package GeoDirectory
159
-     * @global object $wpdb WordPress Database object.
160
-     * @param string $field_type The form field type.
161
-     * @param object|int $result_str The custom field results object or row id.
162
-     * @param string $field_ins_upd When set to "submit" displays form.
163
-     * @param string $field_type_key The key of the custom field.
164
-     */
165
-    function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
166
-    {
167
-        global $wpdb;
168
-        $cf = $result_str;
169
-        if (!is_object($cf)) {
170
-
171
-            $field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
172
-
173
-        } else {
174
-            $field_info = $cf;
175
-            $result_str = $cf->id;
176
-        }
177
-        /**
178
-         * Contains custom field html.
179
-         *
180
-         * @since 1.0.0
181
-         */
182
-        include('custom_field_html.php');
183
-
184
-    }
154
+	/**
155
+	 * Adds admin html for custom fields.
156
+	 *
157
+	 * @since 1.0.0
158
+	 * @package GeoDirectory
159
+	 * @global object $wpdb WordPress Database object.
160
+	 * @param string $field_type The form field type.
161
+	 * @param object|int $result_str The custom field results object or row id.
162
+	 * @param string $field_ins_upd When set to "submit" displays form.
163
+	 * @param string $field_type_key The key of the custom field.
164
+	 */
165
+	function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key ='')
166
+	{
167
+		global $wpdb;
168
+		$cf = $result_str;
169
+		if (!is_object($cf)) {
170
+
171
+			$field_info = $wpdb->get_row($wpdb->prepare("select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)));
172
+
173
+		} else {
174
+			$field_info = $cf;
175
+			$result_str = $cf->id;
176
+		}
177
+		/**
178
+		 * Contains custom field html.
179
+		 *
180
+		 * @since 1.0.0
181
+		 */
182
+		include('custom_field_html.php');
183
+
184
+	}
185 185
 
186 186
 
187 187
 if (!function_exists('geodir_custom_field_delete')) {
188
-    /**
189
-     * Delete custom field using field id.
190
-     *
191
-     * @since 1.0.0
192
-     * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
193
-     * @package GeoDirectory
194
-     * @global object $wpdb WordPress Database object.
195
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
196
-     * @param string $field_id The custom field ID.
197
-     * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
198
-     */
199
-    function geodir_custom_field_delete($field_id = '') {
200
-        global $wpdb, $plugin_prefix;
201
-
202
-        if ($field_id != '') {
203
-            $cf = trim($field_id, '_');
204
-
205
-            if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
-                $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
207
-
208
-                $post_type = $field->post_type;
209
-                $htmlvar_name = $field->htmlvar_name;
210
-
211
-                if ($post_type != '' && $htmlvar_name != '') {
212
-                    $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213
-                }
214
-
215
-                /**
216
-                 * Called after a custom field is deleted.
217
-                 *
218
-                 * @since 1.0.0
219
-                 * @param string $cf The fields ID.
220
-                 * @param string $field->htmlvar_name The html variable name for the field.
221
-                 * @param string $post_type The post type the field belongs to.
222
-                 */
223
-                do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224
-
225
-                if ($field->field_type == 'address') {
226
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
-                    $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
235
-                } else {
236
-                    if ($field->field_type != 'fieldset') {
237
-                        $wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
238
-                    }
239
-                }
240
-
241
-                return $field_id;
242
-            } else
243
-                return 0;
244
-        } else
245
-            return 0;
246
-    }
188
+	/**
189
+	 * Delete custom field using field id.
190
+	 *
191
+	 * @since 1.0.0
192
+	 * @since 1.5.7 Delete field from sorting fields table when custom field deleted.
193
+	 * @package GeoDirectory
194
+	 * @global object $wpdb WordPress Database object.
195
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
196
+	 * @param string $field_id The custom field ID.
197
+	 * @return int|string If field deleted successfully, returns field id. Otherwise returns 0.
198
+	 */
199
+	function geodir_custom_field_delete($field_id = '') {
200
+		global $wpdb, $plugin_prefix;
201
+
202
+		if ($field_id != '') {
203
+			$cf = trim($field_id, '_');
204
+
205
+			if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
206
+				$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
207
+
208
+				$post_type = $field->post_type;
209
+				$htmlvar_name = $field->htmlvar_name;
210
+
211
+				if ($post_type != '' && $htmlvar_name != '') {
212
+					$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
213
+				}
214
+
215
+				/**
216
+				 * Called after a custom field is deleted.
217
+				 *
218
+				 * @since 1.0.0
219
+				 * @param string $cf The fields ID.
220
+				 * @param string $field->htmlvar_name The html variable name for the field.
221
+				 * @param string $post_type The post type the field belongs to.
222
+				 */
223
+				do_action('geodir_after_custom_field_deleted', $cf, $field->htmlvar_name, $post_type);
224
+
225
+				if ($field->field_type == 'address') {
226
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_address`");
227
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_city`");
228
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_region`");
229
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_country`");
230
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_zip`");
231
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_latitude`");
232
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_longitude`");
233
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapview`");
234
+					$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "_mapzoom`");
235
+				} else {
236
+					if ($field->field_type != 'fieldset') {
237
+						$wpdb->query("ALTER TABLE " . $plugin_prefix . $post_type . "_detail DROP `" . $field->htmlvar_name . "`");
238
+					}
239
+				}
240
+
241
+				return $field_id;
242
+			} else
243
+				return 0;
244
+		} else
245
+			return 0;
246
+	}
247 247
 }
248 248
 
249 249
 if (!function_exists('geodir_custom_field_save')) {
250
-    /**
251
-     * Save or Update custom fields into the database.
252
-     *
253
-     * @since 1.0.0
254
-     * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
-     * @package GeoDirectory
256
-     * @global object $wpdb WordPress Database object.
257
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
258
-     * @param array $request_field {
259
-     *    Attributes of the request field array.
260
-     *
261
-     *    @type string $action Ajax Action name. Default "geodir_ajax_action".
262
-     *    @type string $manage_field_type Field type Default "custom_fields".
263
-     *    @type string $create_field Create field Default "true".
264
-     *    @type string $field_ins_upd Field ins upd Default "submit".
265
-     *    @type string $_wpnonce WP nonce value.
266
-     *    @type string $listing_type Listing type Example "gd_place".
267
-     *    @type string $field_type Field type Example "radio".
268
-     *    @type string $field_id Field id Example "12".
269
-     *    @type string $data_type Data type Example "VARCHAR".
270
-     *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
271
-     *    @type array $show_on_pkg Package list to display this field.
272
-     *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
273
-     *    @type string $site_title Section title which you wish to display in frontend.
274
-     *    @type string $admin_desc Section description which will appear in frontend.
275
-     *    @type string $htmlvar_name Html variable name. This should be a unique name.
276
-     *    @type string $clabels Section Title which will appear in backend.
277
-     *    @type string $default_value The default value (for "link" this will be used as the link text).
278
-     *    @type string $sort_order The display order of this field in backend. e.g. 5.
279
-     *    @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field.
280
-     *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
281
-     *    @type string $is_required Use "1" to set field as required.
282
-     *    @type string $required_msg Enter text for error message if field required and have not full fill requirement.
283
-     *    @type string $show_on_listing Want to show this on listing page?.
284
-     *    @type string $show_in What locations to show the custom field in.
285
-     *    @type string $show_on_detail Want to show this in More Info tab on detail page?.
286
-     *    @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes.
287
-     *    @type string $option_values Option Values should be separated by comma.
288
-     *    @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class.
289
-     *    @type string $css_class Enter custom css class for field custom style.
290
-     *    @type array $extra_fields An array of extra fields to store.
291
-     *
292
-     * }
293
-     * @param bool $default Not yet implemented.
294
-     * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
295
-     */
296
-    function geodir_custom_field_save($request_field = array(), $default = false)
297
-    {
298
-
299
-        global $wpdb, $plugin_prefix;
300
-
301
-        $old_html_variable = '';
302
-
303
-        $data_type = trim($request_field['data_type']);
304
-
305
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
306
-
307
-        // some servers fail if a POST value is VARCHAR so we change it.
308
-        if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
309
-            $request_field['data_type'] = 'VARCHAR';
310
-        }
311
-
312
-        $cf = trim($result_str, '_');
313
-
314
-
315
-        /*-------- check duplicate validation --------*/
316
-
317
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
318
-        $post_type = $request_field['listing_type'];
319
-
320
-        if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
321
-            $cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
322
-        }
323
-
324
-        $check_html_variable = $wpdb->get_var(
325
-            $wpdb->prepare(
326
-                "select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
327
-                array($cf, $cehhtmlvar_name, $post_type)
328
-            )
329
-        );
330
-
331
-
332
-        if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
333
-
334
-            if ($cf != '') {
335
-
336
-                $post_meta_info = $wpdb->get_row(
337
-                    $wpdb->prepare(
338
-                        "select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
339
-                        array($cf)
340
-                    )
341
-                );
342
-
343
-            }
344
-
345
-            if (!empty($post_meta_info)) {
346
-                $post_val = $post_meta_info;
347
-                $old_html_variable = $post_val->htmlvar_name;
348
-
349
-            }
350
-
351
-
352
-
353
-            if ($post_type == '') $post_type = 'gd_place';
354
-
355
-
356
-            $detail_table = $plugin_prefix . $post_type . '_detail';
357
-
358
-            $admin_title = $request_field['admin_title'];
359
-            $site_title = $request_field['site_title'];
360
-            $data_type = $request_field['data_type'];
361
-            $field_type = $request_field['field_type'];
362
-            $field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type;
363
-            $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
364
-            $admin_desc = $request_field['admin_desc'];
365
-            $clabels = isset($request_field['clabels']) ? $request_field['clabels'] : '';
366
-            $default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
367
-            $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
368
-            $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
369
-            $is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
370
-            $required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
371
-            $css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
372
-            $field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
373
-            $show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
374
-            $show_in = isset($request_field['show_in']) ? $request_field['show_in'] : '';
375
-            $show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
376
-            $show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
377
-            $decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
378
-            $decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
379
-            $validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
380
-            $validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
381
-            $for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
250
+	/**
251
+	 * Save or Update custom fields into the database.
252
+	 *
253
+	 * @since 1.0.0
254
+	 * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt.
255
+	 * @package GeoDirectory
256
+	 * @global object $wpdb WordPress Database object.
257
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
258
+	 * @param array $request_field {
259
+	 *    Attributes of the request field array.
260
+	 *
261
+	 *    @type string $action Ajax Action name. Default "geodir_ajax_action".
262
+	 *    @type string $manage_field_type Field type Default "custom_fields".
263
+	 *    @type string $create_field Create field Default "true".
264
+	 *    @type string $field_ins_upd Field ins upd Default "submit".
265
+	 *    @type string $_wpnonce WP nonce value.
266
+	 *    @type string $listing_type Listing type Example "gd_place".
267
+	 *    @type string $field_type Field type Example "radio".
268
+	 *    @type string $field_id Field id Example "12".
269
+	 *    @type string $data_type Data type Example "VARCHAR".
270
+	 *    @type string $is_active Either "1" or "0". If "0" is used then the field will not be displayed anywhere.
271
+	 *    @type array $show_on_pkg Package list to display this field.
272
+	 *    @type string $admin_title Personal comment, it would not be displayed anywhere except in custom field settings.
273
+	 *    @type string $site_title Section title which you wish to display in frontend.
274
+	 *    @type string $admin_desc Section description which will appear in frontend.
275
+	 *    @type string $htmlvar_name Html variable name. This should be a unique name.
276
+	 *    @type string $clabels Section Title which will appear in backend.
277
+	 *    @type string $default_value The default value (for "link" this will be used as the link text).
278
+	 *    @type string $sort_order The display order of this field in backend. e.g. 5.
279
+	 *    @type string $is_default Either "1" or "0". If "0" is used then the field will be displayed as main form field or additional field.
280
+	 *    @type string $for_admin_use Either "1" or "0". If "0" is used then only site admin can edit this field.
281
+	 *    @type string $is_required Use "1" to set field as required.
282
+	 *    @type string $required_msg Enter text for error message if field required and have not full fill requirement.
283
+	 *    @type string $show_on_listing Want to show this on listing page?.
284
+	 *    @type string $show_in What locations to show the custom field in.
285
+	 *    @type string $show_on_detail Want to show this in More Info tab on detail page?.
286
+	 *    @type string $show_as_tab Want to display this as a tab on detail page? If "1" then "Show on detail page?" must be Yes.
287
+	 *    @type string $option_values Option Values should be separated by comma.
288
+	 *    @type string $field_icon Upload icon using media and enter its url path, or enter font awesome class.
289
+	 *    @type string $css_class Enter custom css class for field custom style.
290
+	 *    @type array $extra_fields An array of extra fields to store.
291
+	 *
292
+	 * }
293
+	 * @param bool $default Not yet implemented.
294
+	 * @return int|string If field is unique returns inserted row id. Otherwise returns error string.
295
+	 */
296
+	function geodir_custom_field_save($request_field = array(), $default = false)
297
+	{
298
+
299
+		global $wpdb, $plugin_prefix;
300
+
301
+		$old_html_variable = '';
302
+
303
+		$data_type = trim($request_field['data_type']);
304
+
305
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
306
+
307
+		// some servers fail if a POST value is VARCHAR so we change it.
308
+		if(isset($request_field['data_type']) && $request_field['data_type']=='XVARCHAR'){
309
+			$request_field['data_type'] = 'VARCHAR';
310
+		}
311
+
312
+		$cf = trim($result_str, '_');
313
+
314
+
315
+		/*-------- check duplicate validation --------*/
316
+
317
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
318
+		$post_type = $request_field['listing_type'];
319
+
320
+		if ($request_field['field_type'] != 'address' && $request_field['field_type'] != 'taxonomy' && $request_field['field_type'] != 'fieldset') {
321
+			$cehhtmlvar_name = 'geodir_' . $cehhtmlvar_name;
322
+		}
323
+
324
+		$check_html_variable = $wpdb->get_var(
325
+			$wpdb->prepare(
326
+				"select htmlvar_name from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id <> %d and htmlvar_name = %s and post_type = %s ",
327
+				array($cf, $cehhtmlvar_name, $post_type)
328
+			)
329
+		);
330
+
331
+
332
+		if (!$check_html_variable || $request_field['field_type'] == 'fieldset') {
333
+
334
+			if ($cf != '') {
335
+
336
+				$post_meta_info = $wpdb->get_row(
337
+					$wpdb->prepare(
338
+						"select * from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id = %d",
339
+						array($cf)
340
+					)
341
+				);
342
+
343
+			}
344
+
345
+			if (!empty($post_meta_info)) {
346
+				$post_val = $post_meta_info;
347
+				$old_html_variable = $post_val->htmlvar_name;
348
+
349
+			}
350
+
351
+
352
+
353
+			if ($post_type == '') $post_type = 'gd_place';
354
+
355
+
356
+			$detail_table = $plugin_prefix . $post_type . '_detail';
357
+
358
+			$admin_title = $request_field['admin_title'];
359
+			$site_title = $request_field['site_title'];
360
+			$data_type = $request_field['data_type'];
361
+			$field_type = $request_field['field_type'];
362
+			$field_type_key = isset($request_field['field_type_key']) ? $request_field['field_type_key'] : $field_type;
363
+			$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
364
+			$admin_desc = $request_field['admin_desc'];
365
+			$clabels = isset($request_field['clabels']) ? $request_field['clabels'] : '';
366
+			$default_value = isset($request_field['default_value']) ? $request_field['default_value'] : '';
367
+			$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : '';
368
+			$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : '';
369
+			$is_required = isset($request_field['is_required']) ? $request_field['is_required'] : '';
370
+			$required_msg = isset($request_field['required_msg']) ? $request_field['required_msg'] : '';
371
+			$css_class = isset($request_field['css_class']) ? $request_field['css_class'] : '';
372
+			$field_icon = isset($request_field['field_icon']) ? $request_field['field_icon'] : '';
373
+			$show_on_listing = isset($request_field['show_on_listing']) ? $request_field['show_on_listing'] : '';
374
+			$show_in = isset($request_field['show_in']) ? $request_field['show_in'] : '';
375
+			$show_on_detail = isset($request_field['show_on_detail']) ? $request_field['show_on_detail'] : '';
376
+			$show_as_tab = isset($request_field['show_as_tab']) ? $request_field['show_as_tab'] : '';
377
+			$decimal_point = isset($request_field['decimal_point']) ? trim($request_field['decimal_point']) : ''; // decimal point for DECIMAL data type
378
+			$decimal_point = $decimal_point > 0 ? ($decimal_point > 10 ? 10 : $decimal_point) : '';
379
+			$validation_pattern = isset($request_field['validation_pattern']) ? $request_field['validation_pattern'] : '';
380
+			$validation_msg = isset($request_field['validation_msg']) ? $request_field['validation_msg'] : '';
381
+			$for_admin_use = isset($request_field['for_admin_use']) ? $request_field['for_admin_use'] : '';
382 382
 
383 383
             
384
-            if(is_array($show_in)){
385
-                $show_in = implode(",", $request_field['show_in']);
386
-            }
384
+			if(is_array($show_in)){
385
+				$show_in = implode(",", $request_field['show_in']);
386
+			}
387 387
             
388
-            if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
389
-                $htmlvar_name = 'geodir_' . $htmlvar_name;
390
-            }
388
+			if ($field_type != 'address' && $field_type != 'taxonomy' && $field_type != 'fieldset') {
389
+				$htmlvar_name = 'geodir_' . $htmlvar_name;
390
+			}
391 391
 
392
-            $option_values = '';
393
-            if (isset($request_field['option_values']))
394
-                $option_values = $request_field['option_values'];
392
+			$option_values = '';
393
+			if (isset($request_field['option_values']))
394
+				$option_values = $request_field['option_values'];
395 395
 
396
-            $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
396
+			$cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
397 397
 
398
-            $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
398
+			$cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
399 399
 
400
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
402
-            else {
403
-                $package_info = array();
400
+			if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
+				$price_pkg = implode(",", $request_field['show_on_pkg']);
402
+			else {
403
+				$package_info = array();
404 404
 
405
-                $package_info = geodir_post_package_info($package_info, '', $post_type);
406
-                $price_pkg = !empty($package_info->pid) ? $package_info->pid : '';
407
-            }
405
+				$package_info = geodir_post_package_info($package_info, '', $post_type);
406
+				$price_pkg = !empty($package_info->pid) ? $package_info->pid : '';
407
+			}
408 408
 
409 409
 
410
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
411
-                $extra_fields = $request_field['extra'];
410
+			if (isset($request_field['extra']) && !empty($request_field['extra']))
411
+				$extra_fields = $request_field['extra'];
412 412
 
413
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
-                $is_default = $request_field['is_default'];
415
-            else
416
-                $is_default = '0';
413
+			if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
+				$is_default = $request_field['is_default'];
415
+			else
416
+				$is_default = '0';
417 417
 
418
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
-                $is_admin = $request_field['is_admin'];
420
-            else
421
-                $is_admin = '0';
418
+			if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
+				$is_admin = $request_field['is_admin'];
420
+			else
421
+				$is_admin = '0';
422 422
 
423 423
 
424
-            if ($is_active == '') $is_active = 1;
425
-            if ($is_required == '') $is_required = 0;
424
+			if ($is_active == '') $is_active = 1;
425
+			if ($is_required == '') $is_required = 0;
426 426
 
427 427
 
428
-            if ($sort_order == '') {
428
+			if ($sort_order == '') {
429 429
 
430
-                $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
430
+				$last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
431 431
 
432
-                $sort_order = (int)$last_order + 1;
433
-            }
432
+				$sort_order = (int)$last_order + 1;
433
+			}
434 434
 
435
-            $default_value_add = '';
435
+			$default_value_add = '';
436 436
 
437 437
 
438
-            if (!empty($post_meta_info)) {
439
-                switch ($field_type):
438
+			if (!empty($post_meta_info)) {
439
+				switch ($field_type):
440 440
 
441
-                    case 'address':
441
+					case 'address':
442 442
 
443
-                        if ($htmlvar_name != '') {
444
-                            $prefix = $htmlvar_name . '_';
445
-                        }
446
-                        $old_prefix = $old_html_variable . '_';
443
+						if ($htmlvar_name != '') {
444
+							$prefix = $htmlvar_name . '_';
445
+						}
446
+						$old_prefix = $old_html_variable . '_';
447 447
 
448 448
 
449
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
449
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "address` `" . $prefix . "address` VARCHAR( 254 ) NULL";
450 450
 
451
-                        if ($default_value != '') {
452
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
453
-                        }
451
+						if ($default_value != '') {
452
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
453
+						}
454 454
 
455
-                        $wpdb->query($meta_field_add);
455
+						$wpdb->query($meta_field_add);
456 456
 
457
-                        if ($extra_fields != '') {
457
+						if ($extra_fields != '') {
458 458
 
459
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
459
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
460 460
 
461
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
462
-                                if ($is_column) {
463
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
461
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "city'");
462
+								if ($is_column) {
463
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "city` `" . $prefix . "city` VARCHAR( 50 ) NULL";
464 464
 
465
-                                    if ($default_value != '') {
466
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
467
-                                    }
465
+									if ($default_value != '') {
466
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
467
+									}
468 468
 
469
-                                    $wpdb->query($meta_field_add);
470
-                                } else {
469
+									$wpdb->query($meta_field_add);
470
+								} else {
471 471
 
472
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
473
-                                    if ($default_value != '') {
474
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
475
-                                    }
476
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
472
+									$meta_field_add = "VARCHAR( 50 ) NULL";
473
+									if ($default_value != '') {
474
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
475
+									}
476
+									geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
477 477
 
478
-                                }
478
+								}
479 479
 
480 480
 
481
-                            }
481
+							}
482 482
 
483 483
 
484
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
484
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
485 485
 
486
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
486
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "region'");
487 487
 
488
-                                if ($is_column) {
489
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
488
+								if ($is_column) {
489
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "region` `" . $prefix . "region` VARCHAR( 50 ) NULL";
490 490
 
491
-                                    if ($default_value != '') {
492
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
493
-                                    }
491
+									if ($default_value != '') {
492
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
493
+									}
494 494
 
495
-                                    $wpdb->query($meta_field_add);
496
-                                } else {
497
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
498
-                                    if ($default_value != '') {
499
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
500
-                                    }
495
+									$wpdb->query($meta_field_add);
496
+								} else {
497
+									$meta_field_add = "VARCHAR( 50 ) NULL";
498
+									if ($default_value != '') {
499
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
500
+									}
501 501
 
502
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
503
-                                }
502
+									geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
503
+								}
504 504
 
505
-                            }
506
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
505
+							}
506
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
507 507
 
508
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
508
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "country'");
509 509
 
510
-                                if ($is_column) {
510
+								if ($is_column) {
511 511
 
512
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
512
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "country` `" . $prefix . "country` VARCHAR( 50 ) NULL";
513 513
 
514
-                                    if ($default_value != '') {
515
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
516
-                                    }
514
+									if ($default_value != '') {
515
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
516
+									}
517 517
 
518
-                                    $wpdb->query($meta_field_add);
519
-                                } else {
518
+									$wpdb->query($meta_field_add);
519
+								} else {
520 520
 
521
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
522
-                                    if ($default_value != '') {
523
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
524
-                                    }
521
+									$meta_field_add = "VARCHAR( 50 ) NULL";
522
+									if ($default_value != '') {
523
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
524
+									}
525 525
 
526
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
526
+									geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
527 527
 
528
-                                }
528
+								}
529 529
 
530
-                            }
531
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
530
+							}
531
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
532 532
 
533
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
533
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "zip'");
534 534
 
535
-                                if ($is_column) {
535
+								if ($is_column) {
536 536
 
537
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
537
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "zip` `" . $prefix . "zip` VARCHAR( 50 ) NULL";
538 538
 
539
-                                    if ($default_value != '') {
540
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
541
-                                    }
539
+									if ($default_value != '') {
540
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
541
+									}
542 542
 
543
-                                    $wpdb->query($meta_field_add);
544
-                                } else {
543
+									$wpdb->query($meta_field_add);
544
+								} else {
545 545
 
546
-                                    $meta_field_add = "VARCHAR( 50 ) NULL";
547
-                                    if ($default_value != '') {
548
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
549
-                                    }
546
+									$meta_field_add = "VARCHAR( 50 ) NULL";
547
+									if ($default_value != '') {
548
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
549
+									}
550 550
 
551
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
551
+									geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
552 552
 
553
-                                }
553
+								}
554 554
 
555
-                            }
556
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
555
+							}
556
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
557 557
 
558
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
559
-                                if ($is_column) {
558
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latitude'");
559
+								if ($is_column) {
560 560
 
561
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
561
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latitude` `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
562 562
 
563
-                                    if ($default_value != '') {
564
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
565
-                                    }
563
+									if ($default_value != '') {
564
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
565
+									}
566 566
 
567
-                                    $wpdb->query($meta_field_add);
568
-                                } else {
567
+									$wpdb->query($meta_field_add);
568
+								} else {
569 569
 
570
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
571
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
572
-                                    if ($default_value != '') {
573
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
574
-                                    }
570
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
571
+									$meta_field_add = "VARCHAR( 20 ) NULL";
572
+									if ($default_value != '') {
573
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
574
+									}
575 575
 
576
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
576
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
577 577
 
578
-                                }
578
+								}
579 579
 
580 580
 
581
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
581
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "longitude'");
582 582
 
583
-                                if ($is_column) {
584
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
583
+								if ($is_column) {
584
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "longitude` `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
585 585
 
586
-                                    if ($default_value != '') {
587
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
588
-                                    }
586
+									if ($default_value != '') {
587
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
588
+									}
589 589
 
590
-                                    $wpdb->query($meta_field_add);
591
-                                } else {
590
+									$wpdb->query($meta_field_add);
591
+								} else {
592 592
 
593
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
594
-                                    $meta_field_add = "VARCHAR( 20 ) NULL";
595
-                                    if ($default_value != '') {
596
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
597
-                                    }
593
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
594
+									$meta_field_add = "VARCHAR( 20 ) NULL";
595
+									if ($default_value != '') {
596
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
597
+									}
598 598
 
599
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
600
-                                }
599
+									geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
600
+								}
601 601
 
602
-                            }
603
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
602
+							}
603
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
604 604
 
605
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
605
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapview'");
606 606
 
607
-                                if ($is_column) {
608
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
607
+								if ($is_column) {
608
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapview` `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
609 609
 
610
-                                    if ($default_value != '') {
611
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
612
-                                    }
610
+									if ($default_value != '') {
611
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
612
+									}
613 613
 
614
-                                    $wpdb->query($meta_field_add);
615
-                                } else {
614
+									$wpdb->query($meta_field_add);
615
+								} else {
616 616
 
617
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
617
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
618 618
 
619
-                                    $meta_field_add = "VARCHAR( 15 ) NULL";
620
-                                    if ($default_value != '') {
621
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
622
-                                    }
619
+									$meta_field_add = "VARCHAR( 15 ) NULL";
620
+									if ($default_value != '') {
621
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
622
+									}
623 623
 
624
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
625
-                                }
624
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
625
+								}
626 626
 
627 627
 
628
-                            }
629
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
628
+							}
629
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
630 630
 
631
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
632
-                                if ($is_column) {
633
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
631
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "mapzoom'");
632
+								if ($is_column) {
633
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "mapzoom` `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
634 634
 
635
-                                    if ($default_value != '') {
636
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
637
-                                    }
635
+									if ($default_value != '') {
636
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
637
+									}
638 638
 
639
-                                    $wpdb->query($meta_field_add);
639
+									$wpdb->query($meta_field_add);
640 640
 
641
-                                } else {
641
+								} else {
642 642
 
643
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
643
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
644 644
 
645
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
646
-                                    if ($default_value != '') {
647
-                                        $meta_field_add .= " DEFAULT '" . $default_value . "'";
648
-                                    }
645
+									$meta_field_add = "VARCHAR( 3 ) NULL";
646
+									if ($default_value != '') {
647
+										$meta_field_add .= " DEFAULT '" . $default_value . "'";
648
+									}
649 649
 
650
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
651
-                                }
650
+									geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
651
+								}
652 652
 
653
-                            }
654
-                            // show lat lng
655
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
656
-                                $is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
653
+							}
654
+							// show lat lng
655
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
656
+								$is_column = $wpdb->get_var("SHOW COLUMNS FROM " . $detail_table . " where field='" . $old_prefix . "latlng'");
657 657
 
658
-                                if ($is_column) {
659
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
660
-                                    $meta_field_add .= " DEFAULT '1'";
658
+								if ($is_column) {
659
+									$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_prefix . "latlng` `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
660
+									$meta_field_add .= " DEFAULT '1'";
661 661
 
662
-                                    $wpdb->query($meta_field_add);
663
-                                } else {
664
-                                    $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
662
+									$wpdb->query($meta_field_add);
663
+								} else {
664
+									$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
665 665
 
666
-                                    $meta_field_add = "VARCHAR( 3 ) NULL";
667
-                                    $meta_field_add .= " DEFAULT '1'";
666
+									$meta_field_add = "VARCHAR( 3 ) NULL";
667
+									$meta_field_add .= " DEFAULT '1'";
668 668
 
669
-                                    geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
670
-                                }
669
+									geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
670
+								}
671 671
 
672
-                            }
673
-                        }// end extra
672
+							}
673
+						}// end extra
674 674
 
675
-                        break;
675
+						break;
676 676
 
677
-                    case 'checkbox':
678
-                    case 'multiselect':
679
-                    case 'select':
680
-                    case 'taxonomy':
677
+					case 'checkbox':
678
+					case 'multiselect':
679
+					case 'select':
680
+					case 'taxonomy':
681 681
 
682
-                        $op_size = '500';
682
+						$op_size = '500';
683 683
 
684
-                        // only make the field as big as it needs to be.
685
-                        if(isset($option_values) && $option_values && $field_type=='select'){
686
-                            $option_values_arr = explode(',',$option_values);
687
-                            if(is_array($option_values_arr)){
688
-                                $op_max = 0;
689
-                                foreach($option_values_arr as $op_val){
690
-                                    if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
691
-                                }
692
-                                if($op_max){$op_size =$op_max; }
693
-                            }
694
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695
-                            if(strlen($option_values)){
696
-                                $op_size =  strlen($option_values);
697
-                            }
698
-                        }
684
+						// only make the field as big as it needs to be.
685
+						if(isset($option_values) && $option_values && $field_type=='select'){
686
+							$option_values_arr = explode(',',$option_values);
687
+							if(is_array($option_values_arr)){
688
+								$op_max = 0;
689
+								foreach($option_values_arr as $op_val){
690
+									if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
691
+								}
692
+								if($op_max){$op_size =$op_max; }
693
+							}
694
+						}elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695
+							if(strlen($option_values)){
696
+								$op_size =  strlen($option_values);
697
+							}
698
+						}
699 699
 
700
-                        $meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
700
+						$meta_field_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "`VARCHAR( $op_size ) NULL";
701 701
 
702
-                        if ($default_value != '') {
703
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
704
-                        }
702
+						if ($default_value != '') {
703
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
704
+						}
705 705
 
706
-                        $alter_result = $wpdb->query($meta_field_add);
707
-                        if($alter_result===false){
708
-                            return __('Column change failed, you may have too many columns.','geodirectory');
709
-                        }
706
+						$alter_result = $wpdb->query($meta_field_add);
707
+						if($alter_result===false){
708
+							return __('Column change failed, you may have too many columns.','geodirectory');
709
+						}
710 710
 
711
-                        if (isset($request_field['cat_display_type']))
712
-                            $extra_fields = $request_field['cat_display_type'];
711
+						if (isset($request_field['cat_display_type']))
712
+							$extra_fields = $request_field['cat_display_type'];
713 713
 
714
-                        if (isset($request_field['multi_display_type']))
715
-                            $extra_fields = $request_field['multi_display_type'];
714
+						if (isset($request_field['multi_display_type']))
715
+							$extra_fields = $request_field['multi_display_type'];
716 716
 
717 717
 
718
-                        break;
718
+						break;
719 719
 
720
-                    case 'textarea':
721
-                    case 'html':
722
-                    case 'url':
723
-                    case 'file':
720
+					case 'textarea':
721
+					case 'html':
722
+					case 'url':
723
+					case 'file':
724 724
 
725
-                        $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
726
-                        if($alter_result===false){
727
-                            return __('Column change failed, you may have too many columns.','geodirectory');
728
-                        }
729
-                        if (isset($request_field['advanced_editor']))
730
-                            $extra_fields = $request_field['advanced_editor'];
731
-
732
-                        break;
725
+						$alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
726
+						if($alter_result===false){
727
+							return __('Column change failed, you may have too many columns.','geodirectory');
728
+						}
729
+						if (isset($request_field['advanced_editor']))
730
+							$extra_fields = $request_field['advanced_editor'];
731
+
732
+						break;
733 733
 
734
-                    case 'fieldset':
735
-                        // Nothing happened for fieldset
736
-                        break;
734
+					case 'fieldset':
735
+						// Nothing happened for fieldset
736
+						break;
737 737
 
738
-                    default:
739
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
740
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
741
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
742
-                            } else {
743
-                                $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
744
-                            }
745
-
746
-                            if (is_numeric($default_value) && $default_value != '') {
747
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
748
-                            }
749
-                        } else {
750
-                            $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
751
-                            if ($default_value != '') {
752
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
753
-                            }
754
-                        }
755
-
756
-                        $alter_result = $wpdb->query($default_value_add);
757
-                        if($alter_result===false){
758
-                            return __('Column change failed, you may have too many columns.','geodirectory');
759
-                        }
760
-                        break;
761
-                endswitch;
762
-
763
-                $extra_field_query = '';
764
-                if (!empty($extra_fields)) {
765
-                    $extra_field_query = serialize($extra_fields);
766
-                }
767
-
768
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
769
-
770
-                $wpdb->query(
771
-
772
-                    $wpdb->prepare(
773
-
774
-                        "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
738
+					default:
739
+						if ($data_type != 'VARCHAR' && $data_type != '') {
740
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
741
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL";
742
+							} else {
743
+								$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL";
744
+							}
745
+
746
+							if (is_numeric($default_value) && $default_value != '') {
747
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
748
+							}
749
+						} else {
750
+							$default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` VARCHAR( 254 ) NULL";
751
+							if ($default_value != '') {
752
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
753
+							}
754
+						}
755
+
756
+						$alter_result = $wpdb->query($default_value_add);
757
+						if($alter_result===false){
758
+							return __('Column change failed, you may have too many columns.','geodirectory');
759
+						}
760
+						break;
761
+				endswitch;
762
+
763
+				$extra_field_query = '';
764
+				if (!empty($extra_fields)) {
765
+					$extra_field_query = serialize($extra_fields);
766
+				}
767
+
768
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
769
+
770
+				$wpdb->query(
771
+
772
+					$wpdb->prepare(
773
+
774
+						"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
775 775
 					post_type = %s,
776 776
 					admin_title = %s,
777 777
 					site_title = %s,
@@ -805,308 +805,308 @@  discard block
 block discarded – undo
805 805
 					for_admin_use = %s
806 806
 					where id = %d",
807 807
 
808
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
809
-                    )
808
+						array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf)
809
+					)
810 810
 
811
-                );
811
+				);
812 812
 
813
-                $lastid = trim($cf);
813
+				$lastid = trim($cf);
814 814
 
815 815
 
816
-                $wpdb->query(
817
-                    $wpdb->prepare(
818
-                        "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
816
+				$wpdb->query(
817
+					$wpdb->prepare(
818
+						"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
819 819
 					 	site_title=%s
820 820
 					where post_type = %s and htmlvar_name = %s",
821
-                        array($site_title, $post_type, $htmlvar_name)
822
-                    )
823
-                );
824
-
825
-
826
-                if ($cat_sort == '')
827
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
828
-
829
-
830
-                /**
831
-                 * Called after all custom fields are saved for a post.
832
-                 *
833
-                 * @since 1.0.0
834
-                 * @param int $lastid The post ID.
835
-                 */
836
-                do_action('geodir_after_custom_fields_updated', $lastid);
837
-
838
-            } else {
839
-
840
-                switch ($field_type):
841
-
842
-                    case 'address':
843
-
844
-                        $data_type = '';
845
-
846
-                        if ($htmlvar_name != '') {
847
-                            $prefix = $htmlvar_name . '_';
848
-                        }
849
-                        $old_prefix = $old_html_variable;
850
-
851
-                        //$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
852
-
853
-                        $meta_field_add = "VARCHAR( 254 ) NULL";
854
-                        if ($default_value != '') {
855
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
856
-                        }
857
-
858
-                        geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
859
-                        //$wpdb->query($meta_field_add);
860
-
861
-
862
-                        if (!empty($extra_fields)) {
821
+						array($site_title, $post_type, $htmlvar_name)
822
+					)
823
+				);
824
+
825
+
826
+				if ($cat_sort == '')
827
+					$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
828
+
829
+
830
+				/**
831
+				 * Called after all custom fields are saved for a post.
832
+				 *
833
+				 * @since 1.0.0
834
+				 * @param int $lastid The post ID.
835
+				 */
836
+				do_action('geodir_after_custom_fields_updated', $lastid);
837
+
838
+			} else {
839
+
840
+				switch ($field_type):
841
+
842
+					case 'address':
843
+
844
+						$data_type = '';
845
+
846
+						if ($htmlvar_name != '') {
847
+							$prefix = $htmlvar_name . '_';
848
+						}
849
+						$old_prefix = $old_html_variable;
850
+
851
+						//$meta_field_add = "ALTER TABLE ".$detail_table." ADD `".$prefix."address` VARCHAR( 254 ) NULL";
852
+
853
+						$meta_field_add = "VARCHAR( 254 ) NULL";
854
+						if ($default_value != '') {
855
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
856
+						}
857
+
858
+						geodir_add_column_if_not_exist($detail_table, $prefix . "address", $meta_field_add);
859
+						//$wpdb->query($meta_field_add);
860
+
861
+
862
+						if (!empty($extra_fields)) {
863 863
 
864
-                            if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
865
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
866
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
867
-                                if ($default_value != '') {
868
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
869
-                                }
870
-
871
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
872
-                                //$wpdb->query($meta_field_add);
873
-                            }
874
-                            if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
875
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
876
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
877
-                                if ($default_value != '') {
878
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
879
-                                }
880
-
881
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
882
-                                //$wpdb->query($meta_field_add);
883
-                            }
884
-                            if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
885
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
886
-
887
-                                $meta_field_add = "VARCHAR( 30 ) NULL";
888
-                                if ($default_value != '') {
889
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
890
-                                }
891
-
892
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
893
-                                //$wpdb->query($meta_field_add);
894
-                            }
895
-                            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
896
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
897
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
898
-                                if ($default_value != '') {
899
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
900
-                                }
901
-
902
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
903
-                                //$wpdb->query($meta_field_add);
904
-                            }
905
-                            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
906
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
907
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
908
-                                if ($default_value != '') {
909
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
910
-                                }
911
-
912
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
913
-                                //$wpdb->query($meta_field_add);
914
-
915
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
916
-
917
-                                $meta_field_add = "VARCHAR( 20 ) NULL";
918
-                                if ($default_value != '') {
919
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
920
-                                }
921
-
922
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
923
-
924
-                                //$wpdb->query($meta_field_add);
925
-                            }
926
-                            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
927
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
928
-
929
-                                $meta_field_add = "VARCHAR( 15 ) NULL";
930
-                                if ($default_value != '') {
931
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
932
-                                }
933
-
934
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
935
-
936
-                                //$wpdb->query($meta_field_add);
937
-                            }
938
-                            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
939
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
940
-
941
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
942
-                                if ($default_value != '') {
943
-                                    $meta_field_add .= " DEFAULT '" . $default_value . "'";
944
-                                }
945
-
946
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
947
-
948
-                                //$wpdb->query($meta_field_add);
949
-                            }
950
-                            // show lat lng
951
-                            if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
952
-                                $meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
953
-
954
-                                $meta_field_add = "VARCHAR( 3 ) NULL";
955
-                                $meta_field_add .= " DEFAULT '1'";
956
-
957
-                                geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
958
-                                //$wpdb->query($meta_field_add);
959
-                            }
960
-                        }
961
-
962
-                        break;
963
-
964
-                    case 'checkbox':
965
-                        $data_type = 'TINYINT';
966
-
967
-                        $meta_field_add = $data_type . "( 1 ) NOT NULL ";
968
-                        if ((int)$default_value === 1) {
969
-                            $meta_field_add .= " DEFAULT '1'";
970
-                        }
971
-
972
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
973
-                        if ($add_result === false) {
974
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
975
-                        }
976
-                        break;
977
-                    case 'multiselect':
978
-                    case 'select':
979
-                        $data_type = 'VARCHAR';
980
-                        $op_size = '500';
981
-
982
-                        // only make the field as big as it needs to be.
983
-                        if (isset($option_values) && $option_values && $field_type == 'select') {
984
-                            $option_values_arr = explode(',', $option_values);
985
-
986
-                            if (is_array($option_values_arr)) {
987
-                                $op_max = 0;
988
-
989
-                                foreach ($option_values_arr as $op_val) {
990
-                                    if (strlen($op_val) && strlen($op_val) > $op_max) {
991
-                                        $op_max = strlen($op_val);
992
-                                    }
993
-                                }
994
-
995
-                                if ($op_max) {
996
-                                    $op_size = $op_max;
997
-                                }
998
-                            }
999
-                        } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
1000
-                            if (strlen($option_values)) {
1001
-                                $op_size =  strlen($option_values);
1002
-                            }
1003
-
1004
-                            if (isset($request_field['multi_display_type'])) {
1005
-                                $extra_fields = $request_field['multi_display_type'];
1006
-                            }
1007
-                        }
1008
-
1009
-                        $meta_field_add = $data_type . "( $op_size ) NULL ";
1010
-                        if ($default_value != '') {
1011
-                            $meta_field_add .= " DEFAULT '" . $default_value . "'";
1012
-                        }
1013
-
1014
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1015
-                        if ($add_result === false) {
1016
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1017
-                        }
1018
-                        break;
1019
-                    case 'textarea':
1020
-                    case 'html':
1021
-                    case 'url':
1022
-                    case 'file':
1023
-
1024
-                        $data_type = 'TEXT';
1025
-
1026
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1027
-
1028
-                        $meta_field_add = $data_type . " NULL ";
1029
-                        /*if($default_value != '')
864
+							if (isset($extra_fields['show_city']) && $extra_fields['show_city']) {
865
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "city` VARCHAR( 30 ) NULL";
866
+								$meta_field_add = "VARCHAR( 30 ) NULL";
867
+								if ($default_value != '') {
868
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
869
+								}
870
+
871
+								geodir_add_column_if_not_exist($detail_table, $prefix . "city", $meta_field_add);
872
+								//$wpdb->query($meta_field_add);
873
+							}
874
+							if (isset($extra_fields['show_region']) && $extra_fields['show_region']) {
875
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "region` VARCHAR( 30 ) NULL";
876
+								$meta_field_add = "VARCHAR( 30 ) NULL";
877
+								if ($default_value != '') {
878
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
879
+								}
880
+
881
+								geodir_add_column_if_not_exist($detail_table, $prefix . "region", $meta_field_add);
882
+								//$wpdb->query($meta_field_add);
883
+							}
884
+							if (isset($extra_fields['show_country']) && $extra_fields['show_country']) {
885
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "country` VARCHAR( 30 ) NULL";
886
+
887
+								$meta_field_add = "VARCHAR( 30 ) NULL";
888
+								if ($default_value != '') {
889
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
890
+								}
891
+
892
+								geodir_add_column_if_not_exist($detail_table, $prefix . "country", $meta_field_add);
893
+								//$wpdb->query($meta_field_add);
894
+							}
895
+							if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
896
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "zip` VARCHAR( 15 ) NULL";
897
+								$meta_field_add = "VARCHAR( 15 ) NULL";
898
+								if ($default_value != '') {
899
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
900
+								}
901
+
902
+								geodir_add_column_if_not_exist($detail_table, $prefix . "zip", $meta_field_add);
903
+								//$wpdb->query($meta_field_add);
904
+							}
905
+							if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
906
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latitude` VARCHAR( 20 ) NULL";
907
+								$meta_field_add = "VARCHAR( 20 ) NULL";
908
+								if ($default_value != '') {
909
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
910
+								}
911
+
912
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latitude", $meta_field_add);
913
+								//$wpdb->query($meta_field_add);
914
+
915
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "longitude` VARCHAR( 20 ) NULL";
916
+
917
+								$meta_field_add = "VARCHAR( 20 ) NULL";
918
+								if ($default_value != '') {
919
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
920
+								}
921
+
922
+								geodir_add_column_if_not_exist($detail_table, $prefix . "longitude", $meta_field_add);
923
+
924
+								//$wpdb->query($meta_field_add);
925
+							}
926
+							if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
927
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapview` VARCHAR( 15 ) NULL";
928
+
929
+								$meta_field_add = "VARCHAR( 15 ) NULL";
930
+								if ($default_value != '') {
931
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
932
+								}
933
+
934
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapview", $meta_field_add);
935
+
936
+								//$wpdb->query($meta_field_add);
937
+							}
938
+							if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
939
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "mapzoom` VARCHAR( 3 ) NULL";
940
+
941
+								$meta_field_add = "VARCHAR( 3 ) NULL";
942
+								if ($default_value != '') {
943
+									$meta_field_add .= " DEFAULT '" . $default_value . "'";
944
+								}
945
+
946
+								geodir_add_column_if_not_exist($detail_table, $prefix . "mapzoom", $meta_field_add);
947
+
948
+								//$wpdb->query($meta_field_add);
949
+							}
950
+							// show lat lng
951
+							if (isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) {
952
+								$meta_field_add = "ALTER TABLE " . $detail_table . " ADD `" . $prefix . "latlng` VARCHAR( 3 ) NULL";
953
+
954
+								$meta_field_add = "VARCHAR( 3 ) NULL";
955
+								$meta_field_add .= " DEFAULT '1'";
956
+
957
+								geodir_add_column_if_not_exist($detail_table, $prefix . "latlng", $meta_field_add);
958
+								//$wpdb->query($meta_field_add);
959
+							}
960
+						}
961
+
962
+						break;
963
+
964
+					case 'checkbox':
965
+						$data_type = 'TINYINT';
966
+
967
+						$meta_field_add = $data_type . "( 1 ) NOT NULL ";
968
+						if ((int)$default_value === 1) {
969
+							$meta_field_add .= " DEFAULT '1'";
970
+						}
971
+
972
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
973
+						if ($add_result === false) {
974
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
975
+						}
976
+						break;
977
+					case 'multiselect':
978
+					case 'select':
979
+						$data_type = 'VARCHAR';
980
+						$op_size = '500';
981
+
982
+						// only make the field as big as it needs to be.
983
+						if (isset($option_values) && $option_values && $field_type == 'select') {
984
+							$option_values_arr = explode(',', $option_values);
985
+
986
+							if (is_array($option_values_arr)) {
987
+								$op_max = 0;
988
+
989
+								foreach ($option_values_arr as $op_val) {
990
+									if (strlen($op_val) && strlen($op_val) > $op_max) {
991
+										$op_max = strlen($op_val);
992
+									}
993
+								}
994
+
995
+								if ($op_max) {
996
+									$op_size = $op_max;
997
+								}
998
+							}
999
+						} elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
1000
+							if (strlen($option_values)) {
1001
+								$op_size =  strlen($option_values);
1002
+							}
1003
+
1004
+							if (isset($request_field['multi_display_type'])) {
1005
+								$extra_fields = $request_field['multi_display_type'];
1006
+							}
1007
+						}
1008
+
1009
+						$meta_field_add = $data_type . "( $op_size ) NULL ";
1010
+						if ($default_value != '') {
1011
+							$meta_field_add .= " DEFAULT '" . $default_value . "'";
1012
+						}
1013
+
1014
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1015
+						if ($add_result === false) {
1016
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1017
+						}
1018
+						break;
1019
+					case 'textarea':
1020
+					case 'html':
1021
+					case 'url':
1022
+					case 'file':
1023
+
1024
+						$data_type = 'TEXT';
1025
+
1026
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1027
+
1028
+						$meta_field_add = $data_type . " NULL ";
1029
+						/*if($default_value != '')
1030 1030
 					{ $meta_field_add .= " DEFAULT '".$default_value."'"; }*/
1031 1031
 
1032
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1033
-                        if ($add_result === false) {
1034
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1035
-                        }
1032
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1033
+						if ($add_result === false) {
1034
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1035
+						}
1036 1036
 
1037
-                        break;
1037
+						break;
1038 1038
 
1039
-                    case 'datepicker':
1039
+					case 'datepicker':
1040 1040
 
1041
-                        $data_type = 'DATE';
1041
+						$data_type = 'DATE';
1042 1042
 
1043
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1043
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1044 1044
 
1045
-                        $meta_field_add = $data_type . " NULL ";
1045
+						$meta_field_add = $data_type . " NULL ";
1046 1046
 
1047
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1048
-                        if ($add_result === false) {
1049
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1050
-                        }
1047
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1048
+						if ($add_result === false) {
1049
+							return __('Column creation failed, you may have too many columns or the default value must have in valid date format.', 'geodirectory');
1050
+						}
1051 1051
 
1052
-                        break;
1052
+						break;
1053 1053
 
1054
-                    case 'time':
1054
+					case 'time':
1055 1055
 
1056
-                        $data_type = 'TIME';
1056
+						$data_type = 'TIME';
1057 1057
 
1058
-                        $default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1058
+						$default_value_add = " `" . $htmlvar_name . "` " . $data_type . " NULL ";
1059 1059
 
1060
-                        $meta_field_add = $data_type . " NULL ";
1060
+						$meta_field_add = $data_type . " NULL ";
1061 1061
 
1062
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1063
-                        if ($add_result === false) {
1064
-                            return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1065
-                        }
1062
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1063
+						if ($add_result === false) {
1064
+							return __('Column creation failed, you may have too many columns or the default value must have in valid time format.', 'geodirectory');
1065
+						}
1066 1066
 
1067
-                        break;
1067
+						break;
1068 1068
 
1069
-                    default:
1069
+					default:
1070 1070
 
1071
-                        if ($data_type != 'VARCHAR' && $data_type != '') {
1072
-                            $meta_field_add = $data_type . " NULL ";
1071
+						if ($data_type != 'VARCHAR' && $data_type != '') {
1072
+							$meta_field_add = $data_type . " NULL ";
1073 1073
 
1074
-                            if ($data_type == 'FLOAT' && $decimal_point > 0) {
1075
-                                $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1076
-                            }
1074
+							if ($data_type == 'FLOAT' && $decimal_point > 0) {
1075
+								$meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL ";
1076
+							}
1077 1077
 
1078
-                            if (is_numeric($default_value) && $default_value != '') {
1079
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1080
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1081
-                            }
1082
-                        } else {
1083
-                            $meta_field_add = " VARCHAR( 254 ) NULL ";
1078
+							if (is_numeric($default_value) && $default_value != '') {
1079
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1080
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1081
+							}
1082
+						} else {
1083
+							$meta_field_add = " VARCHAR( 254 ) NULL ";
1084 1084
 
1085
-                            if ($default_value != '') {
1086
-                                $default_value_add .= " DEFAULT '" . $default_value . "'";
1087
-                                $meta_field_add .= " DEFAULT '" . $default_value . "'";
1088
-                            }
1089
-                        }
1085
+							if ($default_value != '') {
1086
+								$default_value_add .= " DEFAULT '" . $default_value . "'";
1087
+								$meta_field_add .= " DEFAULT '" . $default_value . "'";
1088
+							}
1089
+						}
1090 1090
 
1091
-                        $add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1092
-                        if ($add_result === false) {
1093
-                            return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1094
-                        }
1095
-                        break;
1096
-                endswitch;
1091
+						$add_result = geodir_add_column_if_not_exist($detail_table, $htmlvar_name, $meta_field_add);
1092
+						if ($add_result === false) {
1093
+							return __('Column creation failed, you may have too many columns or the default value does not match with field data type.', 'geodirectory');
1094
+						}
1095
+						break;
1096
+				endswitch;
1097 1097
 
1098
-                $extra_field_query = '';
1099
-                if (!empty($extra_fields)) {
1100
-                    $extra_field_query = serialize($extra_fields);
1101
-                }
1098
+				$extra_field_query = '';
1099
+				if (!empty($extra_fields)) {
1100
+					$extra_field_query = serialize($extra_fields);
1101
+				}
1102 1102
 
1103
-                $decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1103
+				$decimal_point = $field_type == 'text' && $data_type == 'FLOAT' ? $decimal_point : '';
1104 1104
 
1105
-                $wpdb->query(
1105
+				$wpdb->query(
1106 1106
 
1107
-                    $wpdb->prepare(
1107
+					$wpdb->prepare(
1108 1108
 
1109
-                        "insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1109
+						"insert into " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1110 1110
 					post_type = %s,
1111 1111
 					admin_title = %s,
1112 1112
 					site_title = %s,
@@ -1139,26 +1139,26 @@  discard block
 block discarded – undo
1139 1139
 					validation_msg = %s,
1140 1140
 					for_admin_use = %s ",
1141 1141
 
1142
-                        array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1142
+						array($post_type, $admin_title, $site_title, $field_type, $field_type_key, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing,$show_in, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use)
1143 1143
 
1144
-                    )
1144
+					)
1145 1145
 
1146
-                );
1146
+				);
1147 1147
 
1148
-                $lastid = $wpdb->insert_id;
1148
+				$lastid = $wpdb->insert_id;
1149 1149
 
1150
-                $lastid = trim($lastid);
1150
+				$lastid = trim($lastid);
1151 1151
 
1152
-            }
1152
+			}
1153 1153
 
1154
-            return (int)$lastid;
1154
+			return (int)$lastid;
1155 1155
 
1156 1156
 
1157
-        } else {
1158
-            return 'HTML Variable Name should be a unique name';
1159
-        }
1157
+		} else {
1158
+			return 'HTML Variable Name should be a unique name';
1159
+		}
1160 1160
 
1161
-    }
1161
+	}
1162 1162
 }
1163 1163
 
1164 1164
 /**
@@ -1173,54 +1173,54 @@  discard block
 block discarded – undo
1173 1173
 function godir_set_field_order($field_ids = array())
1174 1174
 {
1175 1175
 
1176
-    global $wpdb;
1176
+	global $wpdb;
1177 1177
 
1178
-    $count = 0;
1179
-    if (!empty($field_ids)):
1180
-        $post_meta_info = false;
1181
-        foreach ($field_ids as $id) {
1178
+	$count = 0;
1179
+	if (!empty($field_ids)):
1180
+		$post_meta_info = false;
1181
+		foreach ($field_ids as $id) {
1182 1182
 
1183
-            $cf = trim($id, '_');
1183
+			$cf = trim($id, '_');
1184 1184
 
1185
-            $post_meta_info = $wpdb->query(
1186
-                $wpdb->prepare(
1187
-                    "update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1185
+			$post_meta_info = $wpdb->query(
1186
+				$wpdb->prepare(
1187
+					"update " . GEODIR_CUSTOM_FIELDS_TABLE . " set 
1188 1188
 															sort_order=%d 
1189 1189
 															where id= %d",
1190
-                    array($count, $cf)
1191
-                )
1192
-            );
1193
-            $count++;
1194
-        }
1195
-
1196
-        return $post_meta_info;
1197
-    else:
1198
-        return false;
1199
-    endif;
1190
+					array($count, $cf)
1191
+				)
1192
+			);
1193
+			$count++;
1194
+		}
1195
+
1196
+		return $post_meta_info;
1197
+	else:
1198
+		return false;
1199
+	endif;
1200 1200
 }
1201 1201
 
1202 1202
 
1203 1203
 function geodir_get_cf_value($cf){
1204
-    global $gd_session;
1205
-    $value = '';
1206
-    if (is_admin()) {
1207
-        global $post,$gd_session;
1208
-
1209
-        if (isset($_REQUEST['post']))
1210
-            $_REQUEST['pid'] = $_REQUEST['post'];
1211
-    }
1212
-
1213
-    if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1214
-        $post = $gd_ses_listing;
1215
-        $value = isset($post[$cf['name']]) ? $post[$cf['name']] : '';
1216
-    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1217
-        $value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true);
1218
-    } else {
1219
-        if ($value == '') {
1220
-            $value = $cf['default'];
1221
-        }
1222
-    }
1223
-    return $value;
1204
+	global $gd_session;
1205
+	$value = '';
1206
+	if (is_admin()) {
1207
+		global $post,$gd_session;
1208
+
1209
+		if (isset($_REQUEST['post']))
1210
+			$_REQUEST['pid'] = $_REQUEST['post'];
1211
+	}
1212
+
1213
+	if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
1214
+		$post = $gd_ses_listing;
1215
+		$value = isset($post[$cf['name']]) ? $post[$cf['name']] : '';
1216
+	} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
1217
+		$value = geodir_get_post_meta($_REQUEST['pid'], $cf['name'], true);
1218
+	} else {
1219
+		if ($value == '') {
1220
+			$value = $cf['default'];
1221
+		}
1222
+	}
1223
+	return $value;
1224 1224
 }
1225 1225
 
1226 1226
 /**
@@ -1239,422 +1239,422 @@  discard block
 block discarded – undo
1239 1239
  * @param string $post_type Optional. The wordpress post type.
1240 1240
  */
1241 1241
 function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place') {
1242
-    global $is_default, $mapzoom, $gd_session;
1242
+	global $is_default, $mapzoom, $gd_session;
1243 1243
 
1244
-    $listing_type = $post_type;
1244
+	$listing_type = $post_type;
1245 1245
 
1246
-    $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1246
+	$custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
1247 1247
 
1248
-    foreach ($custom_fields as $key => $val) {
1249
-        if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
1250
-        $val = stripslashes_deep($val); // strip slashes from labels
1251
-        if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
1248
+	foreach ($custom_fields as $key => $val) {
1249
+		if(isset($val['extra_fields'])){$extra_fields = $val['extra_fields'];}
1250
+		$val = stripslashes_deep($val); // strip slashes from labels
1251
+		if(isset($val['extra_fields'])){$val['extra_fields'] = $extra_fields;}
1252 1252
 
1253
-        $name = $val['name'];
1254
-        $type = $val['type'];
1255
-        $is_default = $val['is_default'];
1253
+		$name = $val['name'];
1254
+		$type = $val['type'];
1255
+		$is_default = $val['is_default'];
1256 1256
 
1257
-        /* field available to site admin only for edit */
1258
-        $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1259
-        if ($for_admin_use && !is_super_admin()) {
1260
-            continue;
1261
-        }
1257
+		/* field available to site admin only for edit */
1258
+		$for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false;
1259
+		if ($for_admin_use && !is_super_admin()) {
1260
+			continue;
1261
+		}
1262 1262
 
1263
-        if (is_admin()) {
1264
-            global $post;
1263
+		if (is_admin()) {
1264
+			global $post;
1265 1265
 
1266
-            if (isset($_REQUEST['post']))
1267
-                $_REQUEST['pid'] = $_REQUEST['post'];
1268
-        }
1266
+			if (isset($_REQUEST['post']))
1267
+				$_REQUEST['pid'] = $_REQUEST['post'];
1268
+		}
1269 1269
 
1270 1270
         
1271 1271
 
1272
-        /**
1273
-         * Called before the custom fields info is output for submitting a post.
1274
-         *
1275
-         * Used dynamic hook type geodir_before_custom_form_field_$name.
1276
-         *
1277
-         * @since 1.0.0
1278
-         * @param string $listing_type The post post type.
1279
-         * @param int $package_id The price package ID for the post.
1280
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1281
-         * @see 'geodir_after_custom_form_field_$name'
1282
-         */
1283
-        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1284
-
1285
-
1286
-        $custom_field = $val;
1287
-        $html ='';
1288
-        /**
1289
-         * Filter the output for custom fields.
1290
-         *
1291
-         * Here we can remove or add new functions depending on the field type.
1292
-         *
1293
-         * @param string $html The html to be filtered (blank).
1294
-         * @param array $custom_field The custom field array values.
1295
-         */
1296
-        echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1297
-
1298
-
1299
-
1300
-        /**
1301
-         * Called after the custom fields info is output for submitting a post.
1302
-         *
1303
-         * Used dynamic hook type geodir_after_custom_form_field_$name.
1304
-         *
1305
-         * @since 1.0.0
1306
-         * @param string $listing_type The post post type.
1307
-         * @param int $package_id The price package ID for the post.
1308
-         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1309
-         * @see 'geodir_before_custom_form_field_$name'
1310
-         */
1311
-        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1312
-
1313
-    }
1272
+		/**
1273
+		 * Called before the custom fields info is output for submitting a post.
1274
+		 *
1275
+		 * Used dynamic hook type geodir_before_custom_form_field_$name.
1276
+		 *
1277
+		 * @since 1.0.0
1278
+		 * @param string $listing_type The post post type.
1279
+		 * @param int $package_id The price package ID for the post.
1280
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1281
+		 * @see 'geodir_after_custom_form_field_$name'
1282
+		 */
1283
+		do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
1284
+
1285
+
1286
+		$custom_field = $val;
1287
+		$html ='';
1288
+		/**
1289
+		 * Filter the output for custom fields.
1290
+		 *
1291
+		 * Here we can remove or add new functions depending on the field type.
1292
+		 *
1293
+		 * @param string $html The html to be filtered (blank).
1294
+		 * @param array $custom_field The custom field array values.
1295
+		 */
1296
+		echo apply_filters("geodir_custom_field_input_{$type}",$html,$custom_field);
1297
+
1298
+
1299
+
1300
+		/**
1301
+		 * Called after the custom fields info is output for submitting a post.
1302
+		 *
1303
+		 * Used dynamic hook type geodir_after_custom_form_field_$name.
1304
+		 *
1305
+		 * @since 1.0.0
1306
+		 * @param string $listing_type The post post type.
1307
+		 * @param int $package_id The price package ID for the post.
1308
+		 * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
1309
+		 * @see 'geodir_before_custom_form_field_$name'
1310
+		 */
1311
+		do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
1312
+
1313
+	}
1314 1314
 
1315 1315
 }
1316 1316
 
1317 1317
 
1318 1318
 if (!function_exists('geodir_get_field_infoby')) {
1319
-    /**
1320
-     * Get custom field using key and value.
1321
-     *
1322
-     * @since 1.0.0
1323
-     * @package GeoDirectory
1324
-     * @global object $wpdb WordPress Database object.
1325
-     * @param string $key The key you want to look for.
1326
-     * @param string $value The value of the key you want to look for.
1327
-     * @param string $geodir_post_type The post type.
1328
-     * @return bool|mixed Returns field info when available. otherwise returns false.
1329
-     */
1330
-    function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
1331
-    {
1332
-
1333
-        global $wpdb;
1334
-
1335
-        $filter = $wpdb->get_row(
1336
-            $wpdb->prepare(
1337
-                "SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1338
-                array($geodir_post_type)
1339
-            )
1340
-        );
1341
-
1342
-        if ($filter) {
1343
-            return $filter;
1344
-        } else {
1345
-            return false;
1346
-        }
1347
-
1348
-    }
1319
+	/**
1320
+	 * Get custom field using key and value.
1321
+	 *
1322
+	 * @since 1.0.0
1323
+	 * @package GeoDirectory
1324
+	 * @global object $wpdb WordPress Database object.
1325
+	 * @param string $key The key you want to look for.
1326
+	 * @param string $value The value of the key you want to look for.
1327
+	 * @param string $geodir_post_type The post type.
1328
+	 * @return bool|mixed Returns field info when available. otherwise returns false.
1329
+	 */
1330
+	function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '')
1331
+	{
1332
+
1333
+		global $wpdb;
1334
+
1335
+		$filter = $wpdb->get_row(
1336
+			$wpdb->prepare(
1337
+				"SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND " . $key . "='" . $value . "'",
1338
+				array($geodir_post_type)
1339
+			)
1340
+		);
1341
+
1342
+		if ($filter) {
1343
+			return $filter;
1344
+		} else {
1345
+			return false;
1346
+		}
1347
+
1348
+	}
1349 1349
 }
1350 1350
 
1351 1351
 
1352 1352
 function geodir_field_icon_proccess($cf){
1353 1353
 
1354 1354
 
1355
-    if (strpos($cf['field_icon'], 'http') !== false) {
1356
-        $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1357
-    } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1358
-        $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1359
-    }else{
1360
-        $field_icon = $cf['field_icon'];
1361
-    }
1355
+	if (strpos($cf['field_icon'], 'http') !== false) {
1356
+		$field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1357
+	} elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1358
+		$field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1359
+	}else{
1360
+		$field_icon = $cf['field_icon'];
1361
+	}
1362 1362
 
1363
-    return $field_icon;
1363
+	return $field_icon;
1364 1364
 }
1365 1365
 
1366 1366
 if (!function_exists('geodir_show_listing_info')) {
1367
-    /**
1368
-     * Show listing info depending on field location.
1369
-     *
1370
-     * @since 1.0.0
1371
-     * @since 1.5.7 Custom fields option values added to db translation.
1372
-     *              Changes to display url fields title.
1373
-     * @package GeoDirectory
1374
-     * @global object $wpdb WordPress Database object.
1375
-     * @global object $post The current post object.
1376
-     * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
1377
-     *
1378
-     * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
1379
-     * @return string Returns listing info html.
1380
-     */
1381
-    function geodir_show_listing_info($fields_location = '') {
1382
-        global $post, $preview, $wpdb, $send_to_friend;
1383
-
1384
-        $package_info = array();
1385
-
1386
-        $package_info = geodir_post_package_info($package_info, $post);
1387
-        $post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
1388
-        $p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype();
1389
-        $send_to_friend = false;
1390
-
1391
-        ob_start();
1392
-        $fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location);
1393
-
1394
-        if (!empty($fields_info)) {
1395
-            $post = stripslashes_deep($post); // strip slashes
1367
+	/**
1368
+	 * Show listing info depending on field location.
1369
+	 *
1370
+	 * @since 1.0.0
1371
+	 * @since 1.5.7 Custom fields option values added to db translation.
1372
+	 *              Changes to display url fields title.
1373
+	 * @package GeoDirectory
1374
+	 * @global object $wpdb WordPress Database object.
1375
+	 * @global object $post The current post object.
1376
+	 * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false.
1377
+	 *
1378
+	 * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc.
1379
+	 * @return string Returns listing info html.
1380
+	 */
1381
+	function geodir_show_listing_info($fields_location = '') {
1382
+		global $post, $preview, $wpdb, $send_to_friend;
1383
+
1384
+		$package_info = array();
1385
+
1386
+		$package_info = geodir_post_package_info($package_info, $post);
1387
+		$post_package_id = !empty($package_info->pid) ? $package_info->pid : '';
1388
+		$p_type = !empty($post->post_type) ? $post->post_type : geodir_get_current_posttype();
1389
+		$send_to_friend = false;
1390
+
1391
+		ob_start();
1392
+		$fields_info = geodir_post_custom_fields($post_package_id, 'all', $p_type, $fields_location);
1393
+
1394
+		if (!empty($fields_info)) {
1395
+			$post = stripslashes_deep($post); // strip slashes
1396 1396
             
1397
-            //echo '<div class="geodir-company_info field-group">';
1398
-            global $field_set_start;
1399
-            $field_set_start = 0;
1400
-
1401
-
1402
-
1403
-            foreach ($fields_info as $type) {
1404
-                if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
1405
-                $type = stripslashes_deep($type); // strip slashes
1406
-                if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
1407
-                $html = '';
1408
-                $field_icon = geodir_field_icon_proccess($type);
1409
-                $filed_type = $type['type'];
1410
-                $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
1411
-                if($html_var=='post'){$html_var='post_address';}
1412
-
1413
-                /**
1414
-                 * Filter the output for custom fields.
1415
-                 *
1416
-                 * Here we can remove or add new functions depending on the field type.
1417
-                 *
1418
-                 * @param string $html The html to be filtered (blank).
1419
-                 * @param string $fields_location The location the field is to be show.
1420
-                 * @param array $type The array of field values.
1421
-                 */
1422
-                $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1423
-
1424
-                $variables_array = array();
1425
-
1426
-
1427
-                if ($type['type'] != 'fieldset'):
1428
-                    $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1429
-                    $variables_array['label'] = __($type['site_title'], 'geodirectory');
1430
-                    $variables_array['value'] = '';
1431
-                    if (isset($post->{$type['htmlvar_name']}))
1432
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
1433
-                endif;
1434
-
1435
-
1436
-                if ($html):
1437
-
1438
-                    /**
1439
-                     * Called before a custom fields is output on the frontend.
1440
-                     *
1441
-                     * @since 1.0.0
1442
-                     * @param string $html_var The HTML variable name for the field.
1443
-                     */
1444
-                    do_action("geodir_before_show_{$html_var}");
1445
-                    /**
1446
-                     * Filter custom field output.
1447
-                     *
1448
-                     * @since 1.0.0
1449
-                     *
1450
-                     * @param string $html_var The HTML variable name for the field.
1451
-                     * @param string $html Custom field unfiltered HTML.
1452
-                     * @param array $variables_array Custom field variables array.
1453
-                     */
1454
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1455
-
1456
-                    /**
1457
-                     * Called after a custom fields is output on the frontend.
1458
-                     *
1459
-                     * @since 1.0.0
1460
-                     * @param string $html_var The HTML variable name for the field.
1461
-                     */
1462
-                    do_action("geodir_after_show_{$html_var}");
1463
-
1464
-                endif;
1465
-
1466
-            }
1467
-
1468
-            //echo '</div>';
1469
-
1470
-        }
1471
-
1472
-
1473
-        $html = ob_get_clean();
1474
-
1475
-        /**
1476
-         * Filter the custom fields over all output.
1477
-         *
1478
-         * @param string $html The html of the custom fields.
1479
-         * @param string $fields_location The location the fields are being output.
1480
-         * @since 1.6.9
1481
-         */
1482
-        return apply_filters('geodir_show_listing_info',$html,$fields_location);
1483
-
1484
-    }
1397
+			//echo '<div class="geodir-company_info field-group">';
1398
+			global $field_set_start;
1399
+			$field_set_start = 0;
1400
+
1401
+
1402
+
1403
+			foreach ($fields_info as $type) {
1404
+				if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];}
1405
+				$type = stripslashes_deep($type); // strip slashes
1406
+				if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;}
1407
+				$html = '';
1408
+				$field_icon = geodir_field_icon_proccess($type);
1409
+				$filed_type = $type['type'];
1410
+				$html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : '';
1411
+				if($html_var=='post'){$html_var='post_address';}
1412
+
1413
+				/**
1414
+				 * Filter the output for custom fields.
1415
+				 *
1416
+				 * Here we can remove or add new functions depending on the field type.
1417
+				 *
1418
+				 * @param string $html The html to be filtered (blank).
1419
+				 * @param string $fields_location The location the field is to be show.
1420
+				 * @param array $type The array of field values.
1421
+				 */
1422
+				$html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type);
1423
+
1424
+				$variables_array = array();
1425
+
1426
+
1427
+				if ($type['type'] != 'fieldset'):
1428
+					$variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1429
+					$variables_array['label'] = __($type['site_title'], 'geodirectory');
1430
+					$variables_array['value'] = '';
1431
+					if (isset($post->{$type['htmlvar_name']}))
1432
+						$variables_array['value'] = $post->{$type['htmlvar_name']};
1433
+				endif;
1434
+
1435
+
1436
+				if ($html):
1437
+
1438
+					/**
1439
+					 * Called before a custom fields is output on the frontend.
1440
+					 *
1441
+					 * @since 1.0.0
1442
+					 * @param string $html_var The HTML variable name for the field.
1443
+					 */
1444
+					do_action("geodir_before_show_{$html_var}");
1445
+					/**
1446
+					 * Filter custom field output.
1447
+					 *
1448
+					 * @since 1.0.0
1449
+					 *
1450
+					 * @param string $html_var The HTML variable name for the field.
1451
+					 * @param string $html Custom field unfiltered HTML.
1452
+					 * @param array $variables_array Custom field variables array.
1453
+					 */
1454
+					if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1455
+
1456
+					/**
1457
+					 * Called after a custom fields is output on the frontend.
1458
+					 *
1459
+					 * @since 1.0.0
1460
+					 * @param string $html_var The HTML variable name for the field.
1461
+					 */
1462
+					do_action("geodir_after_show_{$html_var}");
1463
+
1464
+				endif;
1465
+
1466
+			}
1467
+
1468
+			//echo '</div>';
1469
+
1470
+		}
1471
+
1472
+
1473
+		$html = ob_get_clean();
1474
+
1475
+		/**
1476
+		 * Filter the custom fields over all output.
1477
+		 *
1478
+		 * @param string $html The html of the custom fields.
1479
+		 * @param string $fields_location The location the fields are being output.
1480
+		 * @since 1.6.9
1481
+		 */
1482
+		return apply_filters('geodir_show_listing_info',$html,$fields_location);
1483
+
1484
+	}
1485 1485
 }
1486 1486
 
1487 1487
 if (!function_exists('geodir_default_date_format')) {
1488
-    /**
1489
-     * Returns default date format.
1490
-     *
1491
-     * @since 1.0.0
1492
-     * @package GeoDirectory
1493
-     * @return mixed|string|void Returns default date format.
1494
-     */
1495
-    function geodir_default_date_format()
1496
-    {
1497
-        if ($format = get_option('date_format'))
1498
-            return $format;
1499
-        else
1500
-            return 'dd-mm-yy';
1501
-    }
1488
+	/**
1489
+	 * Returns default date format.
1490
+	 *
1491
+	 * @since 1.0.0
1492
+	 * @package GeoDirectory
1493
+	 * @return mixed|string|void Returns default date format.
1494
+	 */
1495
+	function geodir_default_date_format()
1496
+	{
1497
+		if ($format = get_option('date_format'))
1498
+			return $format;
1499
+		else
1500
+			return 'dd-mm-yy';
1501
+	}
1502 1502
 }
1503 1503
 
1504 1504
 if (!function_exists('geodir_get_formated_date')) {
1505
-    /**
1506
-     * Returns formatted date.
1507
-     *
1508
-     * @since 1.0.0
1509
-     * @package GeoDirectory
1510
-     * @param string $date Date string to convert.
1511
-     * @return bool|int|string Returns formatted date.
1512
-     */
1513
-    function geodir_get_formated_date($date)
1514
-    {
1515
-        return mysql2date(get_option('date_format'), $date);
1516
-    }
1505
+	/**
1506
+	 * Returns formatted date.
1507
+	 *
1508
+	 * @since 1.0.0
1509
+	 * @package GeoDirectory
1510
+	 * @param string $date Date string to convert.
1511
+	 * @return bool|int|string Returns formatted date.
1512
+	 */
1513
+	function geodir_get_formated_date($date)
1514
+	{
1515
+		return mysql2date(get_option('date_format'), $date);
1516
+	}
1517 1517
 }
1518 1518
 
1519 1519
 if (!function_exists('geodir_get_formated_time')) {
1520
-    /**
1521
-     * Returns formatted time.
1522
-     *
1523
-     * @since 1.0.0
1524
-     * @package GeoDirectory
1525
-     * @param string $time Time string to convert.
1526
-     * @return bool|int|string Returns formatted time.
1527
-     */
1528
-    function geodir_get_formated_time($time)
1529
-    {
1530
-        return mysql2date(get_option('time_format'), $time, $translate = true);
1531
-    }
1520
+	/**
1521
+	 * Returns formatted time.
1522
+	 *
1523
+	 * @since 1.0.0
1524
+	 * @package GeoDirectory
1525
+	 * @param string $time Time string to convert.
1526
+	 * @return bool|int|string Returns formatted time.
1527
+	 */
1528
+	function geodir_get_formated_time($time)
1529
+	{
1530
+		return mysql2date(get_option('time_format'), $time, $translate = true);
1531
+	}
1532 1532
 }
1533 1533
 
1534 1534
 
1535 1535
 if (!function_exists('geodir_save_post_file_fields')) {
1536
-    /**
1537
-     * Save post file fields
1538
-     *
1539
-     * @since 1.0.0
1540
-     * @since 1.4.7 Added `$extra_fields` parameter.
1541
-     * @package GeoDirectory
1542
-     * @global object $wpdb WordPress Database object.
1543
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1544
-     * @global object $current_user Current user object.
1545
-     * @param int $post_id
1546
-     * @param string $field_id
1547
-     * @param array $post_image
1548
-     * @param array $extra_fields Array of extra fields.
1549
-     */
1550
-    function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
1551
-    {
1536
+	/**
1537
+	 * Save post file fields
1538
+	 *
1539
+	 * @since 1.0.0
1540
+	 * @since 1.4.7 Added `$extra_fields` parameter.
1541
+	 * @package GeoDirectory
1542
+	 * @global object $wpdb WordPress Database object.
1543
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1544
+	 * @global object $current_user Current user object.
1545
+	 * @param int $post_id
1546
+	 * @param string $field_id
1547
+	 * @param array $post_image
1548
+	 * @param array $extra_fields Array of extra fields.
1549
+	 */
1550
+	function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array())
1551
+	{
1552 1552
 
1553
-        global $wpdb, $plugin_prefix, $current_user;
1553
+		global $wpdb, $plugin_prefix, $current_user;
1554 1554
 
1555
-        $post_type = get_post_type($post_id);
1556
-        //echo $field_id; exit;
1557
-        $table = $plugin_prefix . $post_type . '_detail';
1555
+		$post_type = get_post_type($post_id);
1556
+		//echo $field_id; exit;
1557
+		$table = $plugin_prefix . $post_type . '_detail';
1558 1558
 
1559
-        $postcurr_images = array();
1560
-        $postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
1561
-        $file_urls = '';
1559
+		$postcurr_images = array();
1560
+		$postcurr_images = geodir_get_post_meta($post_id, $field_id, true);
1561
+		$file_urls = '';
1562 1562
 
1563
-        if (!empty($post_image)) {
1563
+		if (!empty($post_image)) {
1564 1564
 
1565
-            $invalid_files = array();
1565
+			$invalid_files = array();
1566 1566
 
1567
-            //Get and remove all old images of post from database to set by new order
1568
-            $geodir_uploaddir = '';
1569
-            $uploads = wp_upload_dir();
1570
-            $uploads_dir = $uploads['path'];
1567
+			//Get and remove all old images of post from database to set by new order
1568
+			$geodir_uploaddir = '';
1569
+			$uploads = wp_upload_dir();
1570
+			$uploads_dir = $uploads['path'];
1571 1571
 
1572
-            $geodir_uploadpath = $uploads['path'];
1573
-            $geodir_uploadurl = $uploads['url'];
1574
-            $sub_dir = $uploads['subdir'];
1572
+			$geodir_uploadpath = $uploads['path'];
1573
+			$geodir_uploadurl = $uploads['url'];
1574
+			$sub_dir = $uploads['subdir'];
1575 1575
 
1576
-            $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1576
+			$allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
1577 1577
 
1578
-            for ($m = 0; $m < count($post_image); $m++) {
1578
+			for ($m = 0; $m < count($post_image); $m++) {
1579 1579
 
1580
-                /* --------- start ------- */
1580
+				/* --------- start ------- */
1581 1581
 
1582
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1582
+				if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM " . $table . " WHERE $field_id = %s AND post_id = %d", array($post_image[$m], $post_id)))) {
1583 1583
 
1584 1584
 
1585
-                    $curr_img_url = $post_image[$m];
1586
-                    $image_name_arr = explode('/', $curr_img_url);
1587
-                    $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1588
-                    $filename = end($image_name_arr);
1589
-                    $img_name_arr = explode('.', $filename);
1585
+					$curr_img_url = $post_image[$m];
1586
+					$image_name_arr = explode('/', $curr_img_url);
1587
+					$curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
1588
+					$filename = end($image_name_arr);
1589
+					$img_name_arr = explode('.', $filename);
1590 1590
 
1591
-                    $arr_file_type = wp_check_filetype($filename);
1591
+					$arr_file_type = wp_check_filetype($filename);
1592 1592
 
1593
-                    if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1594
-                        continue;
1595
-                    }
1593
+					if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
1594
+						continue;
1595
+					}
1596 1596
 
1597
-                    $uploaded_file_type = $arr_file_type['type'];
1598
-                    $uploaded_file_ext = $arr_file_type['ext'];
1597
+					$uploaded_file_type = $arr_file_type['type'];
1598
+					$uploaded_file_ext = $arr_file_type['ext'];
1599 1599
 
1600
-                    if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1601
-                        continue; // Invalid file type.
1602
-                    }
1600
+					if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
1601
+						continue; // Invalid file type.
1602
+					}
1603 1603
 
1604
-                    // Set an array containing a list of acceptable formats
1605
-                    //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1604
+					// Set an array containing a list of acceptable formats
1605
+					//$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1606 1606
 
1607
-                    if (!function_exists('wp_handle_upload'))
1608
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1607
+					if (!function_exists('wp_handle_upload'))
1608
+						require_once(ABSPATH . 'wp-admin/includes/file.php');
1609 1609
 
1610
-                    if (!is_dir($geodir_uploadpath))
1611
-                        mkdir($geodir_uploadpath);
1610
+					if (!is_dir($geodir_uploadpath))
1611
+						mkdir($geodir_uploadpath);
1612 1612
 
1613
-                    $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1614
-                    $explode_sub_dir = explode("/", $sub_dir);
1615
-                    if ($curr_img_dir == end($explode_sub_dir)) {
1616
-                        $img_path = $geodir_uploadpath . '/' . $filename;
1617
-                        $img_url = $geodir_uploadurl . '/' . $filename;
1618
-                    } else {
1619
-                        $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1620
-                        $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1621
-                    }
1613
+					$new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1614
+					$explode_sub_dir = explode("/", $sub_dir);
1615
+					if ($curr_img_dir == end($explode_sub_dir)) {
1616
+						$img_path = $geodir_uploadpath . '/' . $filename;
1617
+						$img_url = $geodir_uploadurl . '/' . $filename;
1618
+					} else {
1619
+						$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1620
+						$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1621
+					}
1622 1622
 
1623
-                    $uploaded_file = '';
1624
-                    if (file_exists($img_path))
1625
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1623
+					$uploaded_file = '';
1624
+					if (file_exists($img_path))
1625
+						$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1626 1626
 
1627
-                    if ($curr_img_dir != $geodir_uploaddir) {
1628
-                        if (file_exists($img_path))
1629
-                            unlink($img_path);
1630
-                    }
1627
+					if ($curr_img_dir != $geodir_uploaddir) {
1628
+						if (file_exists($img_path))
1629
+							unlink($img_path);
1630
+					}
1631 1631
 
1632
-                    if (!empty($uploaded_file))
1633
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1632
+					if (!empty($uploaded_file))
1633
+						$file_urls = $geodir_uploadurl . '/' . $new_name;
1634 1634
 
1635
-                } else {
1636
-                    $file_urls = $post_image[$m];
1637
-                }
1638
-            }
1635
+				} else {
1636
+					$file_urls = $post_image[$m];
1637
+				}
1638
+			}
1639 1639
 
1640 1640
 
1641
-        }
1641
+		}
1642 1642
 
1643
-        //Remove all old attachments and temp images
1644
-        if (!empty($postcurr_images)) {
1643
+		//Remove all old attachments and temp images
1644
+		if (!empty($postcurr_images)) {
1645 1645
 
1646
-            if ($file_urls != $postcurr_images) {
1647
-                $invalid_files[] = (object)array('src' => $postcurr_images);
1648
-                $invalid_files = (object)$invalid_files;
1649
-            }
1650
-        }
1646
+			if ($file_urls != $postcurr_images) {
1647
+				$invalid_files[] = (object)array('src' => $postcurr_images);
1648
+				$invalid_files = (object)$invalid_files;
1649
+			}
1650
+		}
1651 1651
 
1652
-        geodir_save_post_meta($post_id, $field_id, $file_urls);
1652
+		geodir_save_post_meta($post_id, $field_id, $file_urls);
1653 1653
 
1654
-        if (!empty($invalid_files))
1655
-            geodir_remove_attachments($invalid_files);
1654
+		if (!empty($invalid_files))
1655
+			geodir_remove_attachments($invalid_files);
1656 1656
 
1657
-    }
1657
+	}
1658 1658
 }
1659 1659
 
1660 1660
 
@@ -1669,76 +1669,76 @@  discard block
 block discarded – undo
1669 1669
  */
1670 1670
 function geodir_custom_upload_mimes($existing_mimes = array())
1671 1671
 {
1672
-    $existing_mimes['wif'] = 'text/plain';
1673
-    $existing_mimes['jpg|jpeg'] = 'image/jpeg';
1674
-    $existing_mimes['gif'] = 'image/gif';
1675
-    $existing_mimes['png'] = 'image/png';
1676
-    $existing_mimes['pdf'] = 'application/pdf';
1677
-    $existing_mimes['txt'] = 'text/text';
1678
-    $existing_mimes['csv'] = 'application/octet-stream';
1679
-    $existing_mimes['doc'] = 'application/msword';
1680
-    $existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
1681
-    $existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1682
-    $existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
1683
-    return $existing_mimes;
1672
+	$existing_mimes['wif'] = 'text/plain';
1673
+	$existing_mimes['jpg|jpeg'] = 'image/jpeg';
1674
+	$existing_mimes['gif'] = 'image/gif';
1675
+	$existing_mimes['png'] = 'image/png';
1676
+	$existing_mimes['pdf'] = 'application/pdf';
1677
+	$existing_mimes['txt'] = 'text/text';
1678
+	$existing_mimes['csv'] = 'application/octet-stream';
1679
+	$existing_mimes['doc'] = 'application/msword';
1680
+	$existing_mimes['xla|xls|xlt|xlw'] = 'application/vnd.ms-excel';
1681
+	$existing_mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
1682
+	$existing_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
1683
+	return $existing_mimes;
1684 1684
 }
1685 1685
 
1686 1686
 if (!function_exists('geodir_plupload_action')) {
1687 1687
 
1688
-    /**
1689
-     * Get upload directory path details
1690
-     *
1691
-     * @since 1.0.0
1692
-     * @package GeoDirectory
1693
-     * @global object $current_user Current user object.
1694
-     * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
1695
-     * @return mixed Returns upload directory details as an array.
1696
-     */
1697
-    function geodir_upload_dir($upload)
1698
-    {
1699
-        global $current_user;
1700
-        $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1701
-        $upload['path'] = $upload['basedir'] . $upload['subdir'];
1702
-        $upload['url'] = $upload['baseurl'] . $upload['subdir'];
1703
-        return $upload;
1704
-    }
1705
-
1706
-    /**
1707
-     * Handles place file and image upload.
1708
-     *
1709
-     * @since 1.0.0
1710
-     * @package GeoDirectory
1711
-     */
1712
-    function geodir_plupload_action()
1713
-    {
1714
-        // check ajax nonce
1715
-        $imgid = $_POST["imgid"];
1716
-
1717
-        check_ajax_referer($imgid . 'pluploadan');
1718
-
1719
-        // handle custom file uploaddir
1720
-        add_filter('upload_dir', 'geodir_upload_dir');
1721
-
1722
-        // change file orientation if needed
1723
-        $fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1724
-
1725
-        // handle file upload
1726
-        $status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1727
-        // remove handle custom file uploaddir
1728
-        remove_filter('upload_dir', 'geodir_upload_dir');
1729
-
1730
-        if(!isset($status['url']) && isset($status['error'])){
1731
-            print_r($status);
1732
-        }
1733
-
1734
-        // send the uploaded file url in response
1735
-        if (isset($status['url'])) {
1736
-            echo $status['url'];
1737
-        } else {
1738
-            echo 'x';
1739
-        }
1740
-        exit;
1741
-    }
1688
+	/**
1689
+	 * Get upload directory path details
1690
+	 *
1691
+	 * @since 1.0.0
1692
+	 * @package GeoDirectory
1693
+	 * @global object $current_user Current user object.
1694
+	 * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'.
1695
+	 * @return mixed Returns upload directory details as an array.
1696
+	 */
1697
+	function geodir_upload_dir($upload)
1698
+	{
1699
+		global $current_user;
1700
+		$upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID;
1701
+		$upload['path'] = $upload['basedir'] . $upload['subdir'];
1702
+		$upload['url'] = $upload['baseurl'] . $upload['subdir'];
1703
+		return $upload;
1704
+	}
1705
+
1706
+	/**
1707
+	 * Handles place file and image upload.
1708
+	 *
1709
+	 * @since 1.0.0
1710
+	 * @package GeoDirectory
1711
+	 */
1712
+	function geodir_plupload_action()
1713
+	{
1714
+		// check ajax nonce
1715
+		$imgid = $_POST["imgid"];
1716
+
1717
+		check_ajax_referer($imgid . 'pluploadan');
1718
+
1719
+		// handle custom file uploaddir
1720
+		add_filter('upload_dir', 'geodir_upload_dir');
1721
+
1722
+		// change file orientation if needed
1723
+		$fixed_file = geodir_exif($_FILES[$imgid . 'async-upload']);
1724
+
1725
+		// handle file upload
1726
+		$status = wp_handle_upload($fixed_file, array('test_form' => true, 'action' => 'plupload_action'));
1727
+		// remove handle custom file uploaddir
1728
+		remove_filter('upload_dir', 'geodir_upload_dir');
1729
+
1730
+		if(!isset($status['url']) && isset($status['error'])){
1731
+			print_r($status);
1732
+		}
1733
+
1734
+		// send the uploaded file url in response
1735
+		if (isset($status['url'])) {
1736
+			echo $status['url'];
1737
+		} else {
1738
+			echo 'x';
1739
+		}
1740
+		exit;
1741
+	}
1742 1742
 }
1743 1743
 
1744 1744
 /**
@@ -1753,17 +1753,17 @@  discard block
 block discarded – undo
1753 1753
  */
1754 1754
 function geodir_get_video($post_id)
1755 1755
 {
1756
-    global $wpdb, $plugin_prefix;
1756
+	global $wpdb, $plugin_prefix;
1757 1757
 
1758
-    $post_type = get_post_type($post_id);
1758
+	$post_type = get_post_type($post_id);
1759 1759
 
1760
-    $table = $plugin_prefix . $post_type . '_detail';
1760
+	$table = $plugin_prefix . $post_type . '_detail';
1761 1761
 
1762
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1762
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_video FROM " . $table . " WHERE post_id=%d", array($post_id)));
1763 1763
 
1764
-    if ($results) {
1765
-        return $results[0]->geodir_video;
1766
-    }
1764
+	if ($results) {
1765
+		return $results[0]->geodir_video;
1766
+	}
1767 1767
 
1768 1768
 }
1769 1769
 
@@ -1779,40 +1779,40 @@  discard block
 block discarded – undo
1779 1779
  */
1780 1780
 function geodir_get_special_offers($post_id)
1781 1781
 {
1782
-    global $wpdb, $plugin_prefix;
1782
+	global $wpdb, $plugin_prefix;
1783 1783
 
1784
-    $post_type = get_post_type($post_id);
1784
+	$post_type = get_post_type($post_id);
1785 1785
 
1786
-    $table = $plugin_prefix . $post_type . '_detail';
1786
+	$table = $plugin_prefix . $post_type . '_detail';
1787 1787
 
1788
-    $results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1788
+	$results = $wpdb->get_results($wpdb->prepare("SELECT geodir_special_offers FROM " . $table . " WHERE post_id=%d", array($post_id)));
1789 1789
 
1790
-    if ($results) {
1791
-        return $results[0]->geodir_special_offers;
1792
-    }
1790
+	if ($results) {
1791
+		return $results[0]->geodir_special_offers;
1792
+	}
1793 1793
 
1794 1794
 }
1795 1795
 
1796 1796
 if (!function_exists('geodir_max_upload_size')) {
1797
-    /**
1798
-     * Get max upload file size
1799
-     *
1800
-     * @since 1.0.0
1801
-     * @package GeoDirectory
1802
-     * @return mixed|void Returns max upload file size.
1803
-     */
1804
-    function geodir_max_upload_size()
1805
-    {
1806
-        $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1807
-
1808
-        if ($max_filesize > 0 && $max_filesize < 1) {
1809
-            $max_filesize = (int)($max_filesize * 1024) . 'kb';
1810
-        } else {
1811
-            $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1812
-        }
1813
-        /** Filter documented in geodirectory-functions/general_functions.php **/
1814
-        return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1815
-    }
1797
+	/**
1798
+	 * Get max upload file size
1799
+	 *
1800
+	 * @since 1.0.0
1801
+	 * @package GeoDirectory
1802
+	 * @return mixed|void Returns max upload file size.
1803
+	 */
1804
+	function geodir_max_upload_size()
1805
+	{
1806
+		$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1807
+
1808
+		if ($max_filesize > 0 && $max_filesize < 1) {
1809
+			$max_filesize = (int)($max_filesize * 1024) . 'kb';
1810
+		} else {
1811
+			$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1812
+		}
1813
+		/** Filter documented in geodirectory-functions/general_functions.php **/
1814
+		return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1815
+	}
1816 1816
 }
1817 1817
 
1818 1818
 
@@ -1830,33 +1830,33 @@  discard block
 block discarded – undo
1830 1830
  */
1831 1831
 function geodir_add_custom_sort_options($fields, $post_type)
1832 1832
 {
1833
-    global $wpdb;
1833
+	global $wpdb;
1834 1834
 
1835
-    if ($post_type != '') {
1835
+	if ($post_type != '') {
1836 1836
 
1837
-        $all_postypes = geodir_get_posttypes();
1837
+		$all_postypes = geodir_get_posttypes();
1838 1838
 
1839
-        if (in_array($post_type, $all_postypes)) {
1839
+		if (in_array($post_type, $all_postypes)) {
1840 1840
 
1841
-            $custom_fields = $wpdb->get_results(
1842
-                $wpdb->prepare(
1843
-                    "select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1844
-                    array($post_type)
1845
-                ), 'ARRAY_A'
1846
-            );
1841
+			$custom_fields = $wpdb->get_results(
1842
+				$wpdb->prepare(
1843
+					"select post_type,data_type,field_type,site_title,htmlvar_name,field_icon from " . GEODIR_CUSTOM_FIELDS_TABLE . " where post_type = %s and is_active='1' and cat_sort='1' AND field_type != 'address' order by sort_order asc",
1844
+					array($post_type)
1845
+				), 'ARRAY_A'
1846
+			);
1847 1847
 
1848
-            if (!empty($custom_fields)) {
1848
+			if (!empty($custom_fields)) {
1849 1849
 
1850
-                foreach ($custom_fields as $val) {
1851
-                    $fields[] = $val;
1852
-                }
1853
-            }
1850
+				foreach ($custom_fields as $val) {
1851
+					$fields[] = $val;
1852
+				}
1853
+			}
1854 1854
 
1855
-        }
1855
+		}
1856 1856
 
1857
-    }
1857
+	}
1858 1858
 
1859
-    return $fields;
1859
+	return $fields;
1860 1860
 }
1861 1861
 
1862 1862
 
@@ -1872,76 +1872,76 @@  discard block
 block discarded – undo
1872 1872
 function geodir_get_custom_sort_options($post_type = '')
1873 1873
 {
1874 1874
 
1875
-    global $wpdb;
1876
-
1877
-    if ($post_type != '') {
1878
-
1879
-        $all_postypes = geodir_get_posttypes();
1880
-
1881
-        if (!in_array($post_type, $all_postypes))
1882
-            return false;
1883
-
1884
-        $fields = array();
1885
-
1886
-        $fields[] = array(
1887
-            'post_type' => $post_type,
1888
-            'data_type' => '',
1889
-            'field_type' => 'random',
1890
-            'site_title' => 'Random',
1891
-            'htmlvar_name' => 'post_title',
1892
-            'field_icon' =>  'fa fa-random',
1893
-            'description' =>  __('Random sort (not recommended for large sites)', 'geodirectory')
1894
-        );
1895
-
1896
-        $fields[] = array(
1897
-            'post_type' => $post_type,
1898
-            'data_type' => '',
1899
-            'field_type' => 'datetime',
1900
-            'site_title' => __('Add date', 'geodirectory'),
1901
-            'htmlvar_name' => 'post_date',
1902
-            'field_icon' =>  'fa fa-calendar',
1903
-            'description' =>  __('Sort by date added', 'geodirectory')
1904
-        );
1905
-        $fields[] = array(
1906
-            'post_type' => $post_type,
1907
-            'data_type' => '',
1908
-            'field_type' => 'bigint',
1909
-            'site_title' => __('Review', 'geodirectory'),
1910
-            'htmlvar_name' => 'comment_count',
1911
-            'field_icon' =>  'fa fa-commenting-o',
1912
-            'description' =>  __('Sort by the number of reviews', 'geodirectory')
1913
-        );
1914
-        $fields[] = array(
1915
-            'post_type' => $post_type,
1916
-            'data_type' => '',
1917
-            'field_type' => 'float',
1918
-            'site_title' => __('Rating', 'geodirectory'),
1919
-            'htmlvar_name' => 'overall_rating',
1920
-            'field_icon' =>  'fa fa-star-o',
1921
-            'description' =>  __('Sort by the overall rating value', 'geodirectory')
1922
-        );
1923
-        $fields[] = array(
1924
-            'post_type' => $post_type,
1925
-            'data_type' => '',
1926
-            'field_type' => 'text',
1927
-            'site_title' => __('Title', 'geodirectory'),
1928
-            'htmlvar_name' => 'post_title',
1929
-            'field_icon' =>  'fa fa-sort-alpha-desc',
1930
-            'description' =>  __('Sort alphabetically by title', 'geodirectory')
1931
-        );
1932
-
1933
-        /**
1934
-         * Hook to add custom sort options.
1935
-         *
1936
-         * @since 1.0.0
1937
-         * @param array $fields Unmodified sort options array.
1938
-         * @param string $post_type Post type.
1939
-         */
1940
-        return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
1941
-
1942
-    }
1943
-
1944
-    return false;
1875
+	global $wpdb;
1876
+
1877
+	if ($post_type != '') {
1878
+
1879
+		$all_postypes = geodir_get_posttypes();
1880
+
1881
+		if (!in_array($post_type, $all_postypes))
1882
+			return false;
1883
+
1884
+		$fields = array();
1885
+
1886
+		$fields[] = array(
1887
+			'post_type' => $post_type,
1888
+			'data_type' => '',
1889
+			'field_type' => 'random',
1890
+			'site_title' => 'Random',
1891
+			'htmlvar_name' => 'post_title',
1892
+			'field_icon' =>  'fa fa-random',
1893
+			'description' =>  __('Random sort (not recommended for large sites)', 'geodirectory')
1894
+		);
1895
+
1896
+		$fields[] = array(
1897
+			'post_type' => $post_type,
1898
+			'data_type' => '',
1899
+			'field_type' => 'datetime',
1900
+			'site_title' => __('Add date', 'geodirectory'),
1901
+			'htmlvar_name' => 'post_date',
1902
+			'field_icon' =>  'fa fa-calendar',
1903
+			'description' =>  __('Sort by date added', 'geodirectory')
1904
+		);
1905
+		$fields[] = array(
1906
+			'post_type' => $post_type,
1907
+			'data_type' => '',
1908
+			'field_type' => 'bigint',
1909
+			'site_title' => __('Review', 'geodirectory'),
1910
+			'htmlvar_name' => 'comment_count',
1911
+			'field_icon' =>  'fa fa-commenting-o',
1912
+			'description' =>  __('Sort by the number of reviews', 'geodirectory')
1913
+		);
1914
+		$fields[] = array(
1915
+			'post_type' => $post_type,
1916
+			'data_type' => '',
1917
+			'field_type' => 'float',
1918
+			'site_title' => __('Rating', 'geodirectory'),
1919
+			'htmlvar_name' => 'overall_rating',
1920
+			'field_icon' =>  'fa fa-star-o',
1921
+			'description' =>  __('Sort by the overall rating value', 'geodirectory')
1922
+		);
1923
+		$fields[] = array(
1924
+			'post_type' => $post_type,
1925
+			'data_type' => '',
1926
+			'field_type' => 'text',
1927
+			'site_title' => __('Title', 'geodirectory'),
1928
+			'htmlvar_name' => 'post_title',
1929
+			'field_icon' =>  'fa fa-sort-alpha-desc',
1930
+			'description' =>  __('Sort alphabetically by title', 'geodirectory')
1931
+		);
1932
+
1933
+		/**
1934
+		 * Hook to add custom sort options.
1935
+		 *
1936
+		 * @since 1.0.0
1937
+		 * @param array $fields Unmodified sort options array.
1938
+		 * @param string $post_type Post type.
1939
+		 */
1940
+		return $fields = apply_filters('geodir_add_custom_sort_options', $fields, $post_type);
1941
+
1942
+	}
1943
+
1944
+	return false;
1945 1945
 }
1946 1946
 
1947 1947
 
@@ -1957,117 +1957,117 @@  discard block
 block discarded – undo
1957 1957
 function godir_set_sort_field_order($field_ids = array())
1958 1958
 {
1959 1959
 
1960
-    global $wpdb;
1960
+	global $wpdb;
1961 1961
 
1962
-    $count = 0;
1963
-    if (!empty($field_ids)):
1964
-        foreach ($field_ids as $id) {
1962
+	$count = 0;
1963
+	if (!empty($field_ids)):
1964
+		foreach ($field_ids as $id) {
1965 1965
 
1966
-            $cf = trim($id, '_');
1966
+			$cf = trim($id, '_');
1967 1967
 
1968
-            $post_meta_info = $wpdb->query(
1969
-                $wpdb->prepare(
1970
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1968
+			$post_meta_info = $wpdb->query(
1969
+				$wpdb->prepare(
1970
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1971 1971
 															sort_order=%d 
1972 1972
 															where id= %d",
1973
-                    array($count, $cf)
1974
-                )
1975
-            );
1976
-            $count++;
1977
-        }
1978
-
1979
-        return $field_ids;
1980
-    else:
1981
-        return false;
1982
-    endif;
1973
+					array($count, $cf)
1974
+				)
1975
+			);
1976
+			$count++;
1977
+		}
1978
+
1979
+		return $field_ids;
1980
+	else:
1981
+		return false;
1982
+	endif;
1983 1983
 }
1984 1984
 
1985 1985
 
1986 1986
 if (!function_exists('geodir_custom_sort_field_save')) {
1987
-    /**
1988
-     * Save or Update custom sort fields into the database.
1989
-     *
1990
-     * @since 1.0.0
1991
-     * @package GeoDirectory
1992
-     * @global object $wpdb WordPress Database object.
1993
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1994
-     * @param array $request_field {
1995
-     *    Attributes of the Request field.
1996
-     *
1997
-     *    @type string $action Ajax action name.
1998
-     *    @type string $manage_field_type Manage field type Default "sorting_options".
1999
-     *    @type string $create_field Do you want to create this field?.
2000
-     *    @type string $field_ins_upd Field created or updated?.
2001
-     *    @type string $_wpnonce Nonce value.
2002
-     *    @type string $listing_type The Post type.
2003
-     *    @type string $field_type Field Type.
2004
-     *    @type string $field_id Field ID.
2005
-     *    @type string $data_type Data Type.
2006
-     *    @type string $htmlvar_name HTML variable name.
2007
-     *    @type string $site_title Section title which you wish to display in frontend.
2008
-     *    @type string $is_default Is this default sorting?.
2009
-     *    @type string $is_active If not active then the field will not be displayed anywhere.
2010
-     *    @type string $sort_order Sort Order.
2011
-     *
2012
-     * }
2013
-     * @param bool $default Not yet implemented.
2014
-     * @return int Returns the last affected db table row id.
2015
-     */
2016
-    function geodir_custom_sort_field_save($request_field = array(), $default = false)
2017
-    {
2018
-
2019
-        global $wpdb, $plugin_prefix;
2020
-
2021
-        $result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
2022
-
2023
-        $cf = trim($result_str, '_');
2024
-
2025
-        /*-------- check duplicate validation --------*/
2026
-
2027
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2028
-        $cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2029
-
2030
-        $post_type = $request_field['listing_type'];
2031
-        $data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
2032
-        $field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2033
-        $site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
2034
-        $htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2035
-        $sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
2036
-        $is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
2037
-        $is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
2038
-        $asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
2039
-        $desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
2040
-        $asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
2041
-        $desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
2042
-
2043
-        $default_order = '';
2044
-        if ($is_default != '') {
2045
-            $default_order = $is_default;
2046
-            $is_default = '1';
2047
-        }
2048
-
2049
-
2050
-        $check_html_variable = $wpdb->get_var(
2051
-            $wpdb->prepare(
2052
-                "select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2053
-                array($cehhtmlvar_name, $post_type, $field_type)
2054
-            )
2055
-        );
2056
-
2057
-        if ($is_default == 1) {
2058
-
2059
-            $wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2060
-
2061
-        }
2062
-
2063
-
2064
-        if (!$check_html_variable) {
2065
-
2066
-            $wpdb->query(
2067
-
2068
-                $wpdb->prepare(
2069
-
2070
-                    "insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
1987
+	/**
1988
+	 * Save or Update custom sort fields into the database.
1989
+	 *
1990
+	 * @since 1.0.0
1991
+	 * @package GeoDirectory
1992
+	 * @global object $wpdb WordPress Database object.
1993
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1994
+	 * @param array $request_field {
1995
+	 *    Attributes of the Request field.
1996
+	 *
1997
+	 *    @type string $action Ajax action name.
1998
+	 *    @type string $manage_field_type Manage field type Default "sorting_options".
1999
+	 *    @type string $create_field Do you want to create this field?.
2000
+	 *    @type string $field_ins_upd Field created or updated?.
2001
+	 *    @type string $_wpnonce Nonce value.
2002
+	 *    @type string $listing_type The Post type.
2003
+	 *    @type string $field_type Field Type.
2004
+	 *    @type string $field_id Field ID.
2005
+	 *    @type string $data_type Data Type.
2006
+	 *    @type string $htmlvar_name HTML variable name.
2007
+	 *    @type string $site_title Section title which you wish to display in frontend.
2008
+	 *    @type string $is_default Is this default sorting?.
2009
+	 *    @type string $is_active If not active then the field will not be displayed anywhere.
2010
+	 *    @type string $sort_order Sort Order.
2011
+	 *
2012
+	 * }
2013
+	 * @param bool $default Not yet implemented.
2014
+	 * @return int Returns the last affected db table row id.
2015
+	 */
2016
+	function geodir_custom_sort_field_save($request_field = array(), $default = false)
2017
+	{
2018
+
2019
+		global $wpdb, $plugin_prefix;
2020
+
2021
+		$result_str = isset($request_field['field_id']) ? trim($request_field['field_id']) : '';
2022
+
2023
+		$cf = trim($result_str, '_');
2024
+
2025
+		/*-------- check duplicate validation --------*/
2026
+
2027
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2028
+		$cehhtmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2029
+
2030
+		$post_type = $request_field['listing_type'];
2031
+		$data_type = isset($request_field['data_type']) ? $request_field['data_type'] : '';
2032
+		$field_type = isset($request_field['field_type']) ? $request_field['field_type'] : '';
2033
+		$site_title = isset($request_field['site_title']) ? $request_field['site_title'] : '';
2034
+		$htmlvar_name = isset($request_field['htmlvar_name']) ? $request_field['htmlvar_name'] : '';
2035
+		$sort_order = isset($request_field['sort_order']) ? $request_field['sort_order'] : 0;
2036
+		$is_active = isset($request_field['is_active']) ? $request_field['is_active'] : 0;
2037
+		$is_default = isset($request_field['is_default']) ? $request_field['is_default'] : '';
2038
+		$asc = isset($request_field['asc']) ? $request_field['asc'] : 0;
2039
+		$desc = isset($request_field['desc']) ? $request_field['desc'] : 0;
2040
+		$asc_title = isset($request_field['asc_title']) ? $request_field['asc_title'] : '';
2041
+		$desc_title = isset($request_field['desc_title']) ? $request_field['desc_title'] : '';
2042
+
2043
+		$default_order = '';
2044
+		if ($is_default != '') {
2045
+			$default_order = $is_default;
2046
+			$is_default = '1';
2047
+		}
2048
+
2049
+
2050
+		$check_html_variable = $wpdb->get_var(
2051
+			$wpdb->prepare(
2052
+				"select htmlvar_name from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s and field_type=%s ",
2053
+				array($cehhtmlvar_name, $post_type, $field_type)
2054
+			)
2055
+		);
2056
+
2057
+		if ($is_default == 1) {
2058
+
2059
+			$wpdb->query($wpdb->prepare("update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set is_default='0', default_order='' where post_type = %s", array($post_type)));
2060
+
2061
+		}
2062
+
2063
+
2064
+		if (!$check_html_variable) {
2065
+
2066
+			$wpdb->query(
2067
+
2068
+				$wpdb->prepare(
2069
+
2070
+					"insert into " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2071 2071
 				post_type = %s,
2072 2072
 				data_type = %s,
2073 2073
 				field_type = %s,
@@ -2082,23 +2082,23 @@  discard block
 block discarded – undo
2082 2082
 				asc_title = %s,
2083 2083
 				desc_title = %s",
2084 2084
 
2085
-                    array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title)
2086
-                )
2085
+					array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title)
2086
+				)
2087 2087
 
2088
-            );
2088
+			);
2089 2089
 
2090 2090
 
2091
-            $lastid = $wpdb->insert_id;
2091
+			$lastid = $wpdb->insert_id;
2092 2092
 
2093
-            $lastid = trim($lastid);
2093
+			$lastid = trim($lastid);
2094 2094
 
2095
-        } else {
2095
+		} else {
2096 2096
 
2097
-            $wpdb->query(
2097
+			$wpdb->query(
2098 2098
 
2099
-                $wpdb->prepare(
2099
+				$wpdb->prepare(
2100 2100
 
2101
-                    "update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2101
+					"update " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " set 
2102 2102
 				post_type = %s,
2103 2103
 				data_type = %s,
2104 2104
 				field_type = %s,
@@ -2114,123 +2114,123 @@  discard block
 block discarded – undo
2114 2114
 				desc_title = %s
2115 2115
 				where id = %d",
2116 2116
 
2117
-                    array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf)
2118
-                )
2117
+					array($post_type, $data_type, $field_type, $site_title, $htmlvar_name, $sort_order, $is_active, $is_default, $default_order, $asc, $desc, $asc_title, $desc_title, $cf)
2118
+				)
2119 2119
 
2120
-            );
2120
+			);
2121 2121
 
2122
-            $lastid = trim($cf);
2122
+			$lastid = trim($cf);
2123 2123
 
2124
-        }
2124
+		}
2125 2125
 
2126 2126
 
2127
-        return (int)$lastid;
2127
+		return (int)$lastid;
2128 2128
 
2129
-    }
2129
+	}
2130 2130
 }
2131 2131
 
2132 2132
 
2133 2133
 if (!function_exists('geodir_custom_sort_field_delete')) {
2134
-    /**
2135
-     * Delete a custom sort field using field id.
2136
-     * @since 1.0.0
2137
-     * @package GeoDirectory
2138
-     * @global object $wpdb WordPress Database object.
2139
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2140
-     * @param string $field_id The field ID.
2141
-     * @return int|string Returns field id when successful deletion, else returns 0.
2142
-     */
2143
-    function geodir_custom_sort_field_delete($field_id = '')
2144
-    {
2145
-
2146
-        global $wpdb, $plugin_prefix;
2147
-        if ($field_id != '') {
2148
-            $cf = trim($field_id, '_');
2149
-
2150
-            $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2151
-
2152
-            return $field_id;
2153
-
2154
-        } else
2155
-            return 0;
2156
-
2157
-    }
2134
+	/**
2135
+	 * Delete a custom sort field using field id.
2136
+	 * @since 1.0.0
2137
+	 * @package GeoDirectory
2138
+	 * @global object $wpdb WordPress Database object.
2139
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2140
+	 * @param string $field_id The field ID.
2141
+	 * @return int|string Returns field id when successful deletion, else returns 0.
2142
+	 */
2143
+	function geodir_custom_sort_field_delete($field_id = '')
2144
+	{
2145
+
2146
+		global $wpdb, $plugin_prefix;
2147
+		if ($field_id != '') {
2148
+			$cf = trim($field_id, '_');
2149
+
2150
+			$wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where id= %d ", array($cf)));
2151
+
2152
+			return $field_id;
2153
+
2154
+		} else
2155
+			return 0;
2156
+
2157
+	}
2158 2158
 }
2159 2159
 
2160 2160
 
2161 2161
 if (!function_exists('geodir_custom_sort_field_adminhtml')) {
2162
-    /**
2163
-     * Custom sort field admin html.
2164
-     *
2165
-     * @since 1.0.0
2166
-     * @package GeoDirectory
2167
-     * @global object $wpdb WordPress Database object.
2168
-     * @param string $field_type The form field type.
2169
-     * @param object|int $result_str The custom field results object or row id.
2170
-     * @param string $field_ins_upd When set to "submit" displays form.
2171
-     * @param bool $default when set to true field will be for admin use only.
2172
-     */
2173
-    function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='')
2174
-    {
2175
-        global $wpdb;
2176
-        $cf = $result_str;
2177
-        if (!is_object($cf)) {
2178
-            $field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2179
-        } else {
2180
-            $field_info = $cf;
2181
-            $result_str = $cf->id;
2182
-        }
2183
-
2184
-        $field_info = stripslashes_deep($field_info); // strip slashes
2185
-
2186
-        if (!isset($field_info->post_type)) {
2187
-            $post_type = sanitize_text_field($_REQUEST['listing_type']);
2188
-        } else {
2189
-            $post_type = $field_info->post_type;
2190
-        }
2191
-
2192
-
2193
-        $htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2194
-
2195
-        $site_title = '';
2196
-        if ($site_title == '')
2197
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2198
-
2199
-        if ($site_title == '') {
2200
-            $fields = geodir_get_custom_sort_options($post_type);
2201
-
2202
-            foreach ($fields as $val) {
2203
-                $val = stripslashes_deep($val); // strip slashes
2204
-
2205
-                if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
2206
-                    $site_title = isset($val['site_title']) ? $val['site_title'] : '';
2207
-                }
2208
-            }
2209
-        }
2210
-
2211
-        if ($htmlvar_name == '')
2212
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2213
-
2214
-        $nonce = wp_create_nonce('custom_fields_' . $result_str);
2215
-
2216
-        $field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
2217
-        $cso_arr = geodir_get_custom_sort_options($post_type);
2218
-
2219
-        $cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']);
2220
-        foreach($cso_arr as $cso){
2221
-            if($cur_field_type==$cso['field_type']){
2222
-
2223
-                if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2224
-                    $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2225
-                }elseif(isset($cso['field_icon']) && $cso['field_icon']){
2226
-                    $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2227
-                }
2228
-
2229
-            }
2230
-        }
2231
-
2232
-        $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500);
2233
-        ?>
2162
+	/**
2163
+	 * Custom sort field admin html.
2164
+	 *
2165
+	 * @since 1.0.0
2166
+	 * @package GeoDirectory
2167
+	 * @global object $wpdb WordPress Database object.
2168
+	 * @param string $field_type The form field type.
2169
+	 * @param object|int $result_str The custom field results object or row id.
2170
+	 * @param string $field_ins_upd When set to "submit" displays form.
2171
+	 * @param bool $default when set to true field will be for admin use only.
2172
+	 */
2173
+	function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $field_type_key='')
2174
+	{
2175
+		global $wpdb;
2176
+		$cf = $result_str;
2177
+		if (!is_object($cf)) {
2178
+			$field_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE id = %d", array($cf)));
2179
+		} else {
2180
+			$field_info = $cf;
2181
+			$result_str = $cf->id;
2182
+		}
2183
+
2184
+		$field_info = stripslashes_deep($field_info); // strip slashes
2185
+
2186
+		if (!isset($field_info->post_type)) {
2187
+			$post_type = sanitize_text_field($_REQUEST['listing_type']);
2188
+		} else {
2189
+			$post_type = $field_info->post_type;
2190
+		}
2191
+
2192
+
2193
+		$htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2194
+
2195
+		$site_title = '';
2196
+		if ($site_title == '')
2197
+			$site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2198
+
2199
+		if ($site_title == '') {
2200
+			$fields = geodir_get_custom_sort_options($post_type);
2201
+
2202
+			foreach ($fields as $val) {
2203
+				$val = stripslashes_deep($val); // strip slashes
2204
+
2205
+				if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
2206
+					$site_title = isset($val['site_title']) ? $val['site_title'] : '';
2207
+				}
2208
+			}
2209
+		}
2210
+
2211
+		if ($htmlvar_name == '')
2212
+			$htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2213
+
2214
+		$nonce = wp_create_nonce('custom_fields_' . $result_str);
2215
+
2216
+		$field_icon = '<i class="fa fa-cog" aria-hidden="true"></i>';
2217
+		$cso_arr = geodir_get_custom_sort_options($post_type);
2218
+
2219
+		$cur_field_type = (isset($cf->field_type)) ? $cf->field_type : esc_html($_REQUEST['field_type']);
2220
+		foreach($cso_arr as $cso){
2221
+			if($cur_field_type==$cso['field_type']){
2222
+
2223
+				if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2224
+					$field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2225
+				}elseif(isset($cso['field_icon']) && $cso['field_icon']){
2226
+					$field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2227
+				}
2228
+
2229
+			}
2230
+		}
2231
+
2232
+		$radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name.$field_type : rand(5, 500);
2233
+		?>
2234 2234
 
2235 2235
         <li class="text" id="licontainer_<?php echo $result_str;?>">
2236 2236
             <form><!-- we need to wrap in a form so we can use radio buttons with same name -->
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
                  ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
2240 2240
                 <?php
2241 2241
 
2242
-                ?>
2242
+				?>
2243 2243
 
2244 2244
                 <div title="<?php _e('Click to remove field', 'geodirectory');?>"
2245 2245
                      onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
@@ -2254,17 +2254,17 @@  discard block
 block discarded – undo
2254 2254
 
2255 2255
             <div id="field_frm<?php echo $result_str;?>" class="field_frm"
2256 2256
                  style="display:<?php if ($field_ins_upd == 'submit') {
2257
-                     echo 'block;';
2258
-                 } else {
2259
-                     echo 'none;';
2260
-                 } ?>">
2257
+					 echo 'block;';
2258
+				 } else {
2259
+					 echo 'none;';
2260
+				 } ?>">
2261 2261
                 <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/>
2262 2262
                 <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/>
2263 2263
                 <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/>
2264 2264
                 <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/>
2265 2265
                 <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
2266
-                    echo $field_info->data_type;
2267
-                }?>"/>
2266
+					echo $field_info->data_type;
2267
+				}?>"/>
2268 2268
                 <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/>
2269 2269
 
2270 2270
 
@@ -2287,14 +2287,14 @@  discard block
 block discarded – undo
2287 2287
 
2288 2288
                                 <input type="radio" id="asc_yes<?php echo $radio_id;?>" name="asc" class="gdri-enabled"  value="1"
2289 2289
                                     <?php if ($value == '1') {
2290
-                                        echo 'checked';
2291
-                                    } ?>/>
2290
+										echo 'checked';
2291
+									} ?>/>
2292 2292
                                 <label onclick="show_hide_radio(this,'show','cfs-asc-title');" for="asc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2293 2293
 
2294 2294
                                 <input type="radio" id="asc_no<?php echo $radio_id;?>" name="asc" class="gdri-disabled" value="0"
2295 2295
                                     <?php if ($value == '0' || !$value) {
2296
-                                        echo 'checked';
2297
-                                    } ?>/>
2296
+										echo 'checked';
2297
+									} ?>/>
2298 2298
                                 <label onclick="show_hide_radio(this,'hide','cfs-asc-title');" for="asc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2299 2299
 
2300 2300
                             </div>
@@ -2331,8 +2331,8 @@  discard block
 block discarded – undo
2331 2331
 
2332 2332
                                 <input type="radio" name="is_default"
2333 2333
                                        value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
2334
-                                    echo 'checked="checked"';
2335
-                                } ?>/>
2334
+									echo 'checked="checked"';
2335
+								} ?>/>
2336 2336
                             </div>
2337 2337
 
2338 2338
                         </li>
@@ -2352,14 +2352,14 @@  discard block
 block discarded – undo
2352 2352
 
2353 2353
                                 <input type="radio" id="desc_yes<?php echo $radio_id;?>" name="desc" class="gdri-enabled"  value="1"
2354 2354
                                     <?php if ($value == '1') {
2355
-                                        echo 'checked';
2356
-                                    } ?>/>
2355
+										echo 'checked';
2356
+									} ?>/>
2357 2357
                                 <label onclick="show_hide_radio(this,'show','cfs-desc-title');" for="desc_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2358 2358
 
2359 2359
                                 <input type="radio" id="desc_no<?php echo $radio_id;?>" name="desc" class="gdri-disabled" value="0"
2360 2360
                                     <?php if ($value == '0' || !$value) {
2361
-                                        echo 'checked';
2362
-                                    } ?>/>
2361
+										echo 'checked';
2362
+									} ?>/>
2363 2363
                                 <label onclick="show_hide_radio(this,'hide','cfs-desc-title');" for="desc_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2364 2364
 
2365 2365
                             </div>
@@ -2395,8 +2395,8 @@  discard block
 block discarded – undo
2395 2395
 
2396 2396
                                 <input type="radio" name="is_default"
2397 2397
                                        value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
2398
-                                    echo 'checked="checked"';
2399
-                                } ?>/>
2398
+									echo 'checked="checked"';
2399
+								} ?>/>
2400 2400
                             </div>
2401 2401
 
2402 2402
                         </li>
@@ -2438,8 +2438,8 @@  discard block
 block discarded – undo
2438 2438
 
2439 2439
                                 <input type="checkbox" name="is_default"
2440 2440
                                        value="<?php echo $field_type; ?>"  <?php if (isset($value) && $value == '1') {
2441
-                                    echo 'checked="checked"';
2442
-                                } ?>/>
2441
+									echo 'checked="checked"';
2442
+								} ?>/>
2443 2443
                             </div>
2444 2444
 
2445 2445
 
@@ -2462,14 +2462,14 @@  discard block
 block discarded – undo
2462 2462
 
2463 2463
                             <input type="radio" id="is_active_yes<?php echo $radio_id;?>" name="is_active" class="gdri-enabled"  value="1"
2464 2464
                                 <?php if ($value == '1') {
2465
-                                    echo 'checked';
2466
-                                } ?>/>
2465
+									echo 'checked';
2466
+								} ?>/>
2467 2467
                             <label for="is_active_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2468 2468
 
2469 2469
                             <input type="radio" id="is_active_no<?php echo $radio_id;?>" name="is_active" class="gdri-disabled" value="0"
2470 2470
                                 <?php if ($value == '0' || !$value) {
2471
-                                    echo 'checked';
2472
-                                } ?>/>
2471
+									echo 'checked';
2472
+								} ?>/>
2473 2473
                             <label for="is_active_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2474 2474
 
2475 2475
                         </div>
@@ -2479,8 +2479,8 @@  discard block
 block discarded – undo
2479 2479
 
2480 2480
                     <input type="hidden" readonly="readonly" name="sort_order" id="sort_order"
2481 2481
                                                 value="<?php if (isset($field_info->sort_order)) {
2482
-                                                    echo esc_attr($field_info->sort_order);
2483
-                                                }?>" size="50"/>
2482
+													echo esc_attr($field_info->sort_order);
2483
+												}?>" size="50"/>
2484 2484
 
2485 2485
 
2486 2486
 
@@ -2504,38 +2504,38 @@  discard block
 block discarded – undo
2504 2504
             </form>
2505 2505
         </li> <?php
2506 2506
 
2507
-    }
2507
+	}
2508 2508
 }
2509 2509
 
2510 2510
 if (!function_exists('check_field_visibility')) {
2511
-    /**
2512
-     * Check field visibility as per price package.
2513
-     *
2514
-     * @since 1.0.0
2515
-     * @package GeoDirectory
2516
-     * @global object $wpdb WordPress Database object.
2517
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
2518
-     * @param int|string $package_id The package ID.
2519
-     * @param string $field_name The field name.
2520
-     * @param string $post_type Optional. The wordpress post type.
2521
-     * @return bool Returns true when field visible, otherwise false.
2522
-     */
2523
-    function check_field_visibility($package_id, $field_name, $post_type)
2524
-    {
2525
-        global $wpdb, $geodir_addon_list;
2526
-        if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
2527
-            return true;
2528
-        }
2529
-        if (!$package_id || !$field_name || !$post_type) {
2530
-            return true;
2531
-        }
2532
-        $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2533
-
2534
-        if ($wpdb->get_var($sql)) {
2535
-            return true;
2536
-        }
2537
-        return false;
2538
-    }
2511
+	/**
2512
+	 * Check field visibility as per price package.
2513
+	 *
2514
+	 * @since 1.0.0
2515
+	 * @package GeoDirectory
2516
+	 * @global object $wpdb WordPress Database object.
2517
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
2518
+	 * @param int|string $package_id The package ID.
2519
+	 * @param string $field_name The field name.
2520
+	 * @param string $post_type Optional. The wordpress post type.
2521
+	 * @return bool Returns true when field visible, otherwise false.
2522
+	 */
2523
+	function check_field_visibility($package_id, $field_name, $post_type)
2524
+	{
2525
+		global $wpdb, $geodir_addon_list;
2526
+		if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
2527
+			return true;
2528
+		}
2529
+		if (!$package_id || !$field_name || !$post_type) {
2530
+			return true;
2531
+		}
2532
+		$sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
2533
+
2534
+		if ($wpdb->get_var($sql)) {
2535
+			return true;
2536
+		}
2537
+		return false;
2538
+	}
2539 2539
 }
2540 2540
 
2541 2541
 /**
@@ -2551,43 +2551,43 @@  discard block
 block discarded – undo
2551 2551
  */
2552 2552
 function geodir_string_to_options($input = '', $translated = false)
2553 2553
 {
2554
-    $return = array();
2555
-    if ($input != '') {
2556
-        $input = trim($input);
2557
-        $input = rtrim($input, ",");
2558
-        $input = ltrim($input, ",");
2559
-        $input = trim($input);
2560
-    }
2561
-
2562
-    $input_arr = explode(',', $input);
2563
-
2564
-    if (!empty($input_arr)) {
2565
-        foreach ($input_arr as $input_str) {
2566
-            $input_str = trim($input_str);
2567
-
2568
-            if (strpos($input_str, "/") !== false) {
2569
-                $input_str = explode("/", $input_str, 2);
2570
-                $label = trim($input_str[0]);
2571
-                if ($translated && $label != '') {
2572
-                    $label = __($label, 'geodirectory');
2573
-                }
2574
-                $label = geodir_utf8_ucfirst($label);
2575
-                $value = trim($input_str[1]);
2576
-            } else {
2577
-                $value = $input_str;
2578
-                if ($translated && $input_str != '') {
2579
-                    $input_str = __($input_str, 'geodirectory');
2580
-                }
2581
-                $label = geodir_utf8_ucfirst($input_str);
2582
-            }
2583
-
2584
-            if ($label != '') {
2585
-                $return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
2586
-            }
2587
-        }
2588
-    }
2589
-
2590
-    return $return;
2554
+	$return = array();
2555
+	if ($input != '') {
2556
+		$input = trim($input);
2557
+		$input = rtrim($input, ",");
2558
+		$input = ltrim($input, ",");
2559
+		$input = trim($input);
2560
+	}
2561
+
2562
+	$input_arr = explode(',', $input);
2563
+
2564
+	if (!empty($input_arr)) {
2565
+		foreach ($input_arr as $input_str) {
2566
+			$input_str = trim($input_str);
2567
+
2568
+			if (strpos($input_str, "/") !== false) {
2569
+				$input_str = explode("/", $input_str, 2);
2570
+				$label = trim($input_str[0]);
2571
+				if ($translated && $label != '') {
2572
+					$label = __($label, 'geodirectory');
2573
+				}
2574
+				$label = geodir_utf8_ucfirst($label);
2575
+				$value = trim($input_str[1]);
2576
+			} else {
2577
+				$value = $input_str;
2578
+				if ($translated && $input_str != '') {
2579
+					$input_str = __($input_str, 'geodirectory');
2580
+				}
2581
+				$label = geodir_utf8_ucfirst($input_str);
2582
+			}
2583
+
2584
+			if ($label != '') {
2585
+				$return[] = array('label' => $label, 'value' => $value, 'optgroup' => NULL);
2586
+			}
2587
+		}
2588
+	}
2589
+
2590
+	return $return;
2591 2591
 }
2592 2592
 
2593 2593
 /**
@@ -2602,66 +2602,66 @@  discard block
 block discarded – undo
2602 2602
  */
2603 2603
 function geodir_string_values_to_options($option_values = '', $translated = false)
2604 2604
 {
2605
-    $options = array();
2606
-    if ($option_values == '') {
2607
-        return NULL;
2608
-    }
2609
-
2610
-    if (strpos($option_values, "{/optgroup}") !== false) {
2611
-        $option_values_arr = explode("{/optgroup}", $option_values);
2612
-
2613
-        foreach ($option_values_arr as $optgroup) {
2614
-            if (strpos($optgroup, "{optgroup}") !== false) {
2615
-                $optgroup_arr = explode("{optgroup}", $optgroup);
2616
-
2617
-                $count = 0;
2618
-                foreach ($optgroup_arr as $optgroup_str) {
2619
-                    $count++;
2620
-                    $optgroup_str = trim($optgroup_str);
2621
-
2622
-                    $optgroup_label = '';
2623
-                    if (strpos($optgroup_str, "|") !== false) {
2624
-                        $optgroup_str_arr = explode("|", $optgroup_str, 2);
2625
-                        $optgroup_label = trim($optgroup_str_arr[0]);
2626
-                        if ($translated && $optgroup_label != '') {
2627
-                            $optgroup_label = __($optgroup_label, 'geodirectory');
2628
-                        }
2629
-                        $optgroup_label = geodir_utf8_ucfirst($optgroup_label);
2630
-                        $optgroup_str = $optgroup_str_arr[1];
2631
-                    }
2632
-
2633
-                    $optgroup3 = geodir_string_to_options($optgroup_str, $translated);
2634
-
2635
-                    if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
2636
-                        $optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
2637
-                        $optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
2638
-                        $optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
2639
-                    }
2640
-                    $options = array_merge($options, $optgroup3);
2641
-                }
2642
-            } else {
2643
-                $optgroup1 = geodir_string_to_options($optgroup, $translated);
2644
-                $options = array_merge($options, $optgroup1);
2645
-            }
2646
-        }
2647
-    } else {
2648
-        $options = geodir_string_to_options($option_values, $translated);
2649
-    }
2650
-
2651
-    return $options;
2605
+	$options = array();
2606
+	if ($option_values == '') {
2607
+		return NULL;
2608
+	}
2609
+
2610
+	if (strpos($option_values, "{/optgroup}") !== false) {
2611
+		$option_values_arr = explode("{/optgroup}", $option_values);
2612
+
2613
+		foreach ($option_values_arr as $optgroup) {
2614
+			if (strpos($optgroup, "{optgroup}") !== false) {
2615
+				$optgroup_arr = explode("{optgroup}", $optgroup);
2616
+
2617
+				$count = 0;
2618
+				foreach ($optgroup_arr as $optgroup_str) {
2619
+					$count++;
2620
+					$optgroup_str = trim($optgroup_str);
2621
+
2622
+					$optgroup_label = '';
2623
+					if (strpos($optgroup_str, "|") !== false) {
2624
+						$optgroup_str_arr = explode("|", $optgroup_str, 2);
2625
+						$optgroup_label = trim($optgroup_str_arr[0]);
2626
+						if ($translated && $optgroup_label != '') {
2627
+							$optgroup_label = __($optgroup_label, 'geodirectory');
2628
+						}
2629
+						$optgroup_label = geodir_utf8_ucfirst($optgroup_label);
2630
+						$optgroup_str = $optgroup_str_arr[1];
2631
+					}
2632
+
2633
+					$optgroup3 = geodir_string_to_options($optgroup_str, $translated);
2634
+
2635
+					if ($count > 1 && $optgroup_label != '' && !empty($optgroup3)) {
2636
+						$optgroup_start = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'start'));
2637
+						$optgroup_end = array(array('label' => $optgroup_label, 'value' => NULL, 'optgroup' => 'end'));
2638
+						$optgroup3 = array_merge($optgroup_start, $optgroup3, $optgroup_end);
2639
+					}
2640
+					$options = array_merge($options, $optgroup3);
2641
+				}
2642
+			} else {
2643
+				$optgroup1 = geodir_string_to_options($optgroup, $translated);
2644
+				$options = array_merge($options, $optgroup1);
2645
+			}
2646
+		}
2647
+	} else {
2648
+		$options = geodir_string_to_options($option_values, $translated);
2649
+	}
2650
+
2651
+	return $options;
2652 2652
 }
2653 2653
 
2654 2654
 
2655 2655
 function geodir_cfa_data_type_text($output,$result_str,$cf,$field_info){
2656
-    ob_start();
2657
-
2658
-    $dt_value = '';
2659
-    if (isset($field_info->data_type)) {
2660
-        $dt_value  = esc_attr($field_info->data_type);
2661
-    }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2662
-        $dt_value  = $cf['defaults']['data_type'];
2663
-    }
2664
-    ?>
2656
+	ob_start();
2657
+
2658
+	$dt_value = '';
2659
+	if (isset($field_info->data_type)) {
2660
+		$dt_value  = esc_attr($field_info->data_type);
2661
+	}elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2662
+		$dt_value  = $cf['defaults']['data_type'];
2663
+	}
2664
+	?>
2665 2665
     <li>
2666 2666
         <label for="data_type"><?php _e('Field Data Type ? :', 'geodirectory'); ?></label>
2667 2667
         <div class="gd-cf-input-wrap">
@@ -2670,16 +2670,16 @@  discard block
 block discarded – undo
2670 2670
                     onchange="javascript:gd_data_type_changed(this, '<?php echo $result_str; ?>');">
2671 2671
                 <option
2672 2672
                     value="XVARCHAR" <?php if ($dt_value  == 'VARCHAR') {
2673
-                    echo 'selected="selected"';
2674
-                } ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2673
+					echo 'selected="selected"';
2674
+				} ?>><?php _e('CHARACTER', 'geodirectory'); ?></option>
2675 2675
                 <option
2676 2676
                     value="INT" <?php if ($dt_value   == 'INT') {
2677
-                    echo 'selected="selected"';
2678
-                } ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2677
+					echo 'selected="selected"';
2678
+				} ?>><?php _e('NUMBER', 'geodirectory'); ?></option>
2679 2679
                 <option
2680 2680
                     value="FLOAT" <?php if ($dt_value   == 'FLOAT') {
2681
-                    echo 'selected="selected"';
2682
-                } ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2681
+					echo 'selected="selected"';
2682
+				} ?>><?php _e('DECIMAL', 'geodirectory'); ?></option>
2683 2683
             </select>
2684 2684
             <br/> <span><?php _e('Select Custom Field type', 'geodirectory'); ?></span>
2685 2685
 
@@ -2687,13 +2687,13 @@  discard block
 block discarded – undo
2687 2687
     </li>
2688 2688
 
2689 2689
     <?php
2690
-    $value = '';
2691
-    if (isset($field_info->decimal_point)) {
2692
-        $value = esc_attr($field_info->decimal_point);
2693
-    }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2694
-        $value = $cf['defaults']['decimal_point'];
2695
-    }
2696
-    ?>
2690
+	$value = '';
2691
+	if (isset($field_info->decimal_point)) {
2692
+		$value = esc_attr($field_info->decimal_point);
2693
+	}elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2694
+		$value = $cf['defaults']['decimal_point'];
2695
+	}
2696
+	?>
2697 2697
 
2698 2698
     <li class="decimal-point-wrapper"
2699 2699
         style="<?php echo ($dt_value  == 'FLOAT') ? '' : 'display:none' ?>">
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
             <select name="decimal_point" id="decimal_point">
2703 2703
                 <option value=""><?php echo _e('Select', 'geodirectory'); ?></option>
2704 2704
                 <?php for ($i = 1; $i <= 10; $i++) {
2705
-                    $selected = $i == $value ? 'selected="selected"' : ''; ?>
2705
+					$selected = $i == $value ? 'selected="selected"' : ''; ?>
2706 2706
                     <option value="<?php echo $i; ?>" <?php echo $selected; ?>><?php echo $i; ?></option>
2707 2707
                 <?php } ?>
2708 2708
             </select>
@@ -2711,8 +2711,8 @@  discard block
 block discarded – undo
2711 2711
     </li>
2712 2712
 <?php
2713 2713
 
2714
-    $output = ob_get_clean();
2715
-    return $output;
2714
+	$output = ob_get_clean();
2715
+	return $output;
2716 2716
 }
2717 2717
 add_filter('geodir_cfa_data_type_text','geodir_cfa_data_type_text',10,4);
2718 2718
 
@@ -2748,9 +2748,9 @@  discard block
 block discarded – undo
2748 2748
 
2749 2749
 
2750 2750
 function geodir_cfa_advanced_editor_geodir_special_offers($output,$result_str,$cf,$field_info){
2751
-    if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2752
-    ob_start();
2753
-    ?>
2751
+	if($field_info->htmlvar_name != 'geodir_special_offers'){return '';}
2752
+	ob_start();
2753
+	?>
2754 2754
     <li>
2755 2755
         <label for="advanced_editor" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Show advanced editor :', 'geodirectory'); ?>
2756 2756
             <div class="gdcf-tooltip">
@@ -2761,13 +2761,13 @@  discard block
 block discarded – undo
2761 2761
         <div class="gd-cf-input-wrap">
2762 2762
 
2763 2763
             <?php
2764
-            $selected = '';
2765
-            if (isset($field_info->extra_fields))
2766
-                $advanced_editor = unserialize($field_info->extra_fields);
2764
+			$selected = '';
2765
+			if (isset($field_info->extra_fields))
2766
+				$advanced_editor = unserialize($field_info->extra_fields);
2767 2767
 
2768
-            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2769
-                $selected = 'checked="checked"';
2770
-            ?>
2768
+			if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2769
+				$selected = 'checked="checked"';
2770
+			?>
2771 2771
 
2772 2772
             <input type="checkbox" name="advanced_editor[]" id="advanced_editor"
2773 2773
                    value="1" <?php echo $selected; ?>/>
@@ -2776,22 +2776,22 @@  discard block
 block discarded – undo
2776 2776
     </li>
2777 2777
     <?php
2778 2778
 
2779
-    $output = ob_get_clean();
2780
-    return $output;
2779
+	$output = ob_get_clean();
2780
+	return $output;
2781 2781
 }
2782 2782
 add_filter('geodir_cfa_advanced_editor_textarea','geodir_cfa_advanced_editor_geodir_special_offers',10,4);
2783 2783
 
2784 2784
 
2785 2785
 function geodir_cfa_validation_pattern_text($output,$result_str,$cf,$field_info){
2786
-    ob_start();
2787
-
2788
-    $value = '';
2789
-    if (isset($field_info->validation_pattern)) {
2790
-        $value = esc_attr($field_info->validation_pattern);
2791
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2792
-        $value = esc_attr($cf['defaults']['validation_pattern']);
2793
-    }
2794
-    ?>
2786
+	ob_start();
2787
+
2788
+	$value = '';
2789
+	if (isset($field_info->validation_pattern)) {
2790
+		$value = esc_attr($field_info->validation_pattern);
2791
+	}elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2792
+		$value = esc_attr($cf['defaults']['validation_pattern']);
2793
+	}
2794
+	?>
2795 2795
     <li>
2796 2796
         <label for="validation_pattern" class="gd-cf-tooltip-wrap">
2797 2797
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Pattern:', 'geodirectory'); ?>
@@ -2805,13 +2805,13 @@  discard block
 block discarded – undo
2805 2805
         </div>
2806 2806
     </li>
2807 2807
     <?php
2808
-    $value = '';
2809
-    if (isset($field_info->validation_msg)) {
2810
-        $value = esc_attr($field_info->validation_msg);
2811
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2812
-        $value = esc_attr($cf['defaults']['validation_msg']);
2813
-    }
2814
-    ?>
2808
+	$value = '';
2809
+	if (isset($field_info->validation_msg)) {
2810
+		$value = esc_attr($field_info->validation_msg);
2811
+	}elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2812
+		$value = esc_attr($cf['defaults']['validation_msg']);
2813
+	}
2814
+	?>
2815 2815
     <li>
2816 2816
         <label for="validation_msg" class="gd-cf-tooltip-wrap">
2817 2817
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Validation Message:', 'geodirectory'); ?>
@@ -2826,21 +2826,21 @@  discard block
 block discarded – undo
2826 2826
     </li>
2827 2827
     <?php
2828 2828
 
2829
-    $output = ob_get_clean();
2830
-    return $output;
2829
+	$output = ob_get_clean();
2830
+	return $output;
2831 2831
 }
2832 2832
 add_filter('geodir_cfa_validation_pattern_text','geodir_cfa_validation_pattern_text',10,4);
2833 2833
 
2834 2834
 
2835 2835
 function geodir_cfa_htmlvar_name_taxonomy($output,$result_str,$cf,$field_info){
2836
-    ob_start();
2837
-    global $post_type;
2838
-
2839
-    if (!isset($field_info->post_type)) {
2840
-        $post_type = sanitize_text_field($_REQUEST['listing_type']);
2841
-    } else
2842
-        $post_type = $field_info->post_type;
2843
-    ?>
2836
+	ob_start();
2837
+	global $post_type;
2838
+
2839
+	if (!isset($field_info->post_type)) {
2840
+		$post_type = sanitize_text_field($_REQUEST['listing_type']);
2841
+	} else
2842
+		$post_type = $field_info->post_type;
2843
+	?>
2844 2844
     <li style="display: none;">
2845 2845
         <label for="htmlvar_name" class="gd-cf-tooltip-wrap">
2846 2846
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Select taxonomy:', 'geodirectory'); ?>
@@ -2851,15 +2851,15 @@  discard block
 block discarded – undo
2851 2851
         <div class="gd-cf-input-wrap">
2852 2852
             <select name="htmlvar_name" id="htmlvar_name">
2853 2853
                 <?php
2854
-                $gd_taxonomy = geodir_get_taxonomies($post_type);
2854
+				$gd_taxonomy = geodir_get_taxonomies($post_type);
2855 2855
 
2856
-                foreach ($gd_taxonomy as $gd_tax) {
2857
-                    ?>
2856
+				foreach ($gd_taxonomy as $gd_tax) {
2857
+					?>
2858 2858
                     <option <?php if (isset($field_info->htmlvar_name) && $field_info->htmlvar_name == $gd_tax) {
2859
-                        echo 'selected="selected"';
2860
-                    }?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2861
-                }
2862
-                ?>
2859
+						echo 'selected="selected"';
2860
+					}?> id="<?php echo $gd_tax;?>"><?php echo $gd_tax;?></option><?php
2861
+				}
2862
+				?>
2863 2863
             </select>
2864 2864
         </div>
2865 2865
     </li>
@@ -2875,49 +2875,49 @@  discard block
 block discarded – undo
2875 2875
 
2876 2876
             <select name="cat_display_type" id="cat_display_type">
2877 2877
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'ajax_chained') {
2878
-                    echo 'selected="selected"';
2879
-                }?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2878
+					echo 'selected="selected"';
2879
+				}?> value="ajax_chained"><?php _e('Ajax Chained', 'geodirectory');?></option>
2880 2880
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
2881
-                    echo 'selected="selected"';
2882
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
2881
+					echo 'selected="selected"';
2882
+				}?> value="select"><?php _e('Select', 'geodirectory');?></option>
2883 2883
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'multiselect') {
2884
-                    echo 'selected="selected"';
2885
-                }?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2884
+					echo 'selected="selected"';
2885
+				}?> value="multiselect"><?php _e('Multiselect', 'geodirectory');?></option>
2886 2886
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
2887
-                    echo 'selected="selected"';
2888
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2887
+					echo 'selected="selected"';
2888
+				}?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
2889 2889
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
2890
-                    echo 'selected="selected"';
2891
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2890
+					echo 'selected="selected"';
2891
+				}?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
2892 2892
             </select>
2893 2893
         </div>
2894 2894
     </li>
2895 2895
     <?php
2896 2896
 
2897
-    $output = ob_get_clean();
2898
-    return $output;
2897
+	$output = ob_get_clean();
2898
+	return $output;
2899 2899
 }
2900 2900
 add_filter('geodir_cfa_htmlvar_name_taxonomy','geodir_cfa_htmlvar_name_taxonomy',10,4);
2901 2901
 
2902 2902
 
2903 2903
 function geodir_cfa_extra_fields_address($output,$result_str,$cf,$field_info){
2904 2904
 
2905
-    ob_start();
2906
-    if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2907
-        $address = stripslashes_deep(unserialize($field_info->extra_fields));
2908
-    }
2905
+	ob_start();
2906
+	if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
2907
+		$address = stripslashes_deep(unserialize($field_info->extra_fields));
2908
+	}
2909 2909
 
2910
-    $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
2911
-    ?>
2910
+	$radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
2911
+	?>
2912 2912
     <?php
2913
-    /**
2914
-     * Called on the add custom fields settings page before the address field is output.
2915
-     *
2916
-     * @since 1.0.0
2917
-     * @param array $address The address settings array.
2918
-     * @param object $field_info Extra fields info.
2919
-     */
2920
-    do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
2913
+	/**
2914
+	 * Called on the add custom fields settings page before the address field is output.
2915
+	 *
2916
+	 * @since 1.0.0
2917
+	 * @param array $address The address settings array.
2918
+	 * @param object $field_info Extra fields info.
2919
+	 */
2920
+	do_action('geodir_address_extra_admin_fields', $address, $field_info); ?>
2921 2921
 
2922 2922
     <li>
2923 2923
         <label for="show_zip" class="gd-cf-tooltip-wrap">
@@ -2930,14 +2930,14 @@  discard block
 block discarded – undo
2930 2930
 
2931 2931
             <input type="radio" id="show_zip_yes<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-enabled"  value="1"
2932 2932
                 <?php if (isset($address['show_zip']) && $address['show_zip'] == '1') {
2933
-                    echo 'checked';
2934
-                } ?>/>
2933
+					echo 'checked';
2934
+				} ?>/>
2935 2935
             <label onclick="show_hide_radio(this,'show','cf-zip-lable');" for="show_zip_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2936 2936
 
2937 2937
             <input type="radio" id="show_zip_no<?php echo $radio_id;?>" name="extra[show_zip]" class="gdri-disabled" value="0"
2938 2938
                 <?php if ((isset($address['show_zip']) && !$address['show_zip']) || !isset($address['show_zip'])) {
2939
-                    echo 'checked';
2940
-                } ?>/>
2939
+					echo 'checked';
2940
+				} ?>/>
2941 2941
             <label onclick="show_hide_radio(this,'hide','cf-zip-lable');" for="show_zip_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
2942 2942
 
2943 2943
 
@@ -2954,8 +2954,8 @@  discard block
 block discarded – undo
2954 2954
         <div class="gd-cf-input-wrap">
2955 2955
             <input type="text" name="extra[zip_lable]" id="zip_lable"
2956 2956
                    value="<?php if (isset($address['zip_lable'])) {
2957
-                       echo esc_attr($address['zip_lable']);
2958
-                   }?>"/>
2957
+					   echo esc_attr($address['zip_lable']);
2958
+				   }?>"/>
2959 2959
         </div>
2960 2960
     </li>
2961 2961
 
@@ -2972,8 +2972,8 @@  discard block
 block discarded – undo
2972 2972
         <div class="gd-cf-input-wrap">
2973 2973
             <input type="text" name="extra[map_lable]" id="map_lable"
2974 2974
                    value="<?php if (isset($address['map_lable'])) {
2975
-                       echo esc_attr($address['map_lable']);
2976
-                   }?>"/>
2975
+					   echo esc_attr($address['map_lable']);
2976
+				   }?>"/>
2977 2977
         </div>
2978 2978
     </li>
2979 2979
 
@@ -2988,14 +2988,14 @@  discard block
 block discarded – undo
2988 2988
 
2989 2989
             <input type="radio" id="show_mapzoom_yes<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-enabled"  value="1"
2990 2990
                 <?php if (isset($address['show_mapzoom']) && $address['show_mapzoom'] == '1') {
2991
-                    echo 'checked';
2992
-                } ?>/>
2991
+					echo 'checked';
2992
+				} ?>/>
2993 2993
             <label for="show_mapzoom_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
2994 2994
 
2995 2995
             <input type="radio" id="show_mapzoom_no<?php echo $radio_id;?>" name="extra[show_mapzoom]" class="gdri-disabled" value="0"
2996 2996
                 <?php if ((isset($address['show_mapzoom']) && !$address['show_mapzoom']) || !isset($address['show_mapzoom'])) {
2997
-                    echo 'checked';
2998
-                } ?>/>
2997
+					echo 'checked';
2998
+				} ?>/>
2999 2999
             <label for="show_mapzoom_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3000 3000
 
3001 3001
         </div>
@@ -3012,14 +3012,14 @@  discard block
 block discarded – undo
3012 3012
 
3013 3013
             <input type="radio" id="show_mapview_yes<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-enabled"  value="1"
3014 3014
                 <?php if (isset($address['show_mapview']) && $address['show_mapview'] == '1') {
3015
-                    echo 'checked';
3016
-                } ?>/>
3015
+					echo 'checked';
3016
+				} ?>/>
3017 3017
             <label for="show_mapview_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3018 3018
 
3019 3019
             <input type="radio" id="show_mapview_no<?php echo $radio_id;?>" name="extra[show_mapview]" class="gdri-disabled" value="0"
3020 3020
                 <?php if ((isset($address['show_mapview']) && !$address['show_mapview']) || !isset($address['show_mapview'])) {
3021
-                    echo 'checked';
3022
-                } ?>/>
3021
+					echo 'checked';
3022
+				} ?>/>
3023 3023
             <label for="show_mapview_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3024 3024
 
3025 3025
         </div>
@@ -3036,8 +3036,8 @@  discard block
 block discarded – undo
3036 3036
         <div class="gd-cf-input-wrap">
3037 3037
             <input type="text" name="extra[mapview_lable]" id="mapview_lable"
3038 3038
                    value="<?php if (isset($address['mapview_lable'])) {
3039
-                       echo esc_attr($address['mapview_lable']);
3040
-                   }?>"/>
3039
+					   echo esc_attr($address['mapview_lable']);
3040
+				   }?>"/>
3041 3041
         </div>
3042 3042
     </li>
3043 3043
     <li>
@@ -3051,29 +3051,29 @@  discard block
 block discarded – undo
3051 3051
 
3052 3052
             <input type="radio" id="show_latlng_yes<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-enabled"  value="1"
3053 3053
                 <?php if (isset($address['show_latlng']) && $address['show_latlng'] == '1') {
3054
-                    echo 'checked';
3055
-                } ?>/>
3054
+					echo 'checked';
3055
+				} ?>/>
3056 3056
             <label for="show_latlng_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3057 3057
 
3058 3058
             <input type="radio" id="show_latlng_no<?php echo $radio_id;?>" name="extra[show_latlng]" class="gdri-disabled" value="0"
3059 3059
                 <?php if ((isset($address['show_latlng']) && !$address['show_latlng']) || !isset($address['show_latlng'])) {
3060
-                    echo 'checked';
3061
-                } ?>/>
3060
+					echo 'checked';
3061
+				} ?>/>
3062 3062
             <label for="show_latlng_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3063 3063
 
3064 3064
         </div>
3065 3065
     </li>
3066 3066
     <?php
3067 3067
 
3068
-    $html = ob_get_clean();
3069
-    return $output.$html;
3068
+	$html = ob_get_clean();
3069
+	return $output.$html;
3070 3070
 }
3071 3071
 add_filter('geodir_cfa_extra_fields_address','geodir_cfa_extra_fields_address',10,4);
3072 3072
 
3073 3073
 
3074 3074
 function geodir_cfa_extra_fields_multiselect($output,$result_str,$cf,$field_info){
3075
-    ob_start();
3076
-    ?>
3075
+	ob_start();
3076
+	?>
3077 3077
     <li>
3078 3078
         <label for="multi_display_type" class="gd-cf-tooltip-wrap">
3079 3079
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Multiselect display type :', 'geodirectory'); ?>
@@ -3085,14 +3085,14 @@  discard block
 block discarded – undo
3085 3085
 
3086 3086
             <select name="multi_display_type" id="multi_display_type">
3087 3087
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'select') {
3088
-                    echo 'selected="selected"';
3089
-                }?> value="select"><?php _e('Select', 'geodirectory');?></option>
3088
+					echo 'selected="selected"';
3089
+				}?> value="select"><?php _e('Select', 'geodirectory');?></option>
3090 3090
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'checkbox') {
3091
-                    echo 'selected="selected"';
3092
-                }?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
3091
+					echo 'selected="selected"';
3092
+				}?> value="checkbox"><?php _e('Checkbox', 'geodirectory');?></option>
3093 3093
                 <option <?php if (isset($field_info->extra_fields) && unserialize($field_info->extra_fields) == 'radio') {
3094
-                    echo 'selected="selected"';
3095
-                }?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
3094
+					echo 'selected="selected"';
3095
+				}?> value="radio"><?php _e('Radio', 'geodirectory');?></option>
3096 3096
             </select>
3097 3097
 
3098 3098
             <br/>
@@ -3100,25 +3100,25 @@  discard block
 block discarded – undo
3100 3100
     </li>
3101 3101
     <?php
3102 3102
 
3103
-    $html = ob_get_clean();
3104
-    return $output.$html;
3103
+	$html = ob_get_clean();
3104
+	return $output.$html;
3105 3105
 }
3106 3106
 add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_multiselect',10,4);
3107 3107
 
3108 3108
 
3109 3109
 function geodir_cfa_extra_fields_smr($output,$result_str,$cf,$field_info){
3110 3110
 
3111
-    ob_start();
3111
+	ob_start();
3112 3112
 
3113
-    $value = '';
3114
-    if (isset($field_info->option_values)) {
3115
-        $value = esc_attr($field_info->option_values);
3116
-    }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3117
-        $value = esc_attr($cf['defaults']['option_values']);
3118
-    }
3113
+	$value = '';
3114
+	if (isset($field_info->option_values)) {
3115
+		$value = esc_attr($field_info->option_values);
3116
+	}elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3117
+		$value = esc_attr($cf['defaults']['option_values']);
3118
+	}
3119 3119
 
3120
-    $field_type = isset($field_info->field_type) ? $field_info->field_type : '';
3121
-    ?>
3120
+	$field_type = isset($field_info->field_type) ? $field_info->field_type : '';
3121
+	?>
3122 3122
     <li>
3123 3123
         <label for="option_values" class="gd-cf-tooltip-wrap">
3124 3124
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Option Values :', 'geodirectory'); ?>
@@ -3145,8 +3145,8 @@  discard block
 block discarded – undo
3145 3145
     </li>
3146 3146
     <?php
3147 3147
 
3148
-    $html = ob_get_clean();
3149
-    return $output.$html;
3148
+	$html = ob_get_clean();
3149
+	return $output.$html;
3150 3150
 }
3151 3151
 add_filter('geodir_cfa_extra_fields_multiselect','geodir_cfa_extra_fields_smr',10,4);
3152 3152
 add_filter('geodir_cfa_extra_fields_select','geodir_cfa_extra_fields_smr',10,4);
@@ -3154,12 +3154,12 @@  discard block
 block discarded – undo
3154 3154
 
3155 3155
 
3156 3156
 function geodir_cfa_extra_fields_datepicker($output,$result_str,$cf,$field_info){
3157
-    ob_start();
3158
-    $extra = array();
3159
-    if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
3160
-        $extra = unserialize($field_info->extra_fields);
3161
-    }
3162
-    ?>
3157
+	ob_start();
3158
+	$extra = array();
3159
+	if (isset($field_info->extra_fields) && $field_info->extra_fields != '') {
3160
+		$extra = unserialize($field_info->extra_fields);
3161
+	}
3162
+	?>
3163 3163
     <li>
3164 3164
         <label for="date_format" class="gd-cf-tooltip-wrap">
3165 3165
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Date Format :', 'geodirectory'); ?>
@@ -3169,52 +3169,52 @@  discard block
 block discarded – undo
3169 3169
         </label>
3170 3170
         <div class="gd-cf-input-wrap" style="overflow:inherit;">
3171 3171
             <?php
3172
-            $date_formats = array(
3173
-                'm/d/Y',
3174
-                'd/m/Y',
3175
-                'Y/m/d',
3176
-                'm-d-Y',
3177
-                'd-m-Y',
3178
-                'Y-m-d',
3179
-                'F j, Y',
3180
-            );
3181
-            /**
3182
-             * Filter the custom field date format options.
3183
-             *
3184
-             * @since 1.6.5
3185
-             * @param array $date_formats The PHP date format array.
3186
-             */
3187
-            $date_formats = apply_filters('geodir_date_formats',$date_formats);
3188
-            ?>
3172
+			$date_formats = array(
3173
+				'm/d/Y',
3174
+				'd/m/Y',
3175
+				'Y/m/d',
3176
+				'm-d-Y',
3177
+				'd-m-Y',
3178
+				'Y-m-d',
3179
+				'F j, Y',
3180
+			);
3181
+			/**
3182
+			 * Filter the custom field date format options.
3183
+			 *
3184
+			 * @since 1.6.5
3185
+			 * @param array $date_formats The PHP date format array.
3186
+			 */
3187
+			$date_formats = apply_filters('geodir_date_formats',$date_formats);
3188
+			?>
3189 3189
             <select name="extra[date_format]" id="date_format">
3190 3190
                 <?php
3191
-                foreach($date_formats as $format){
3192
-                    $selected = '';
3193
-                    if(!empty($extra) && esc_attr($extra['date_format'])==$format){
3194
-                        $selected = "selected='selected'";
3195
-                    }
3196
-                    echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3197
-                }
3198
-                ?>
3191
+				foreach($date_formats as $format){
3192
+					$selected = '';
3193
+					if(!empty($extra) && esc_attr($extra['date_format'])==$format){
3194
+						$selected = "selected='selected'";
3195
+					}
3196
+					echo "<option $selected value='$format'>$format       (".date_i18n( $format, time()).")</option>";
3197
+				}
3198
+				?>
3199 3199
             </select>
3200 3200
 
3201 3201
         </div>
3202 3202
     </li>
3203 3203
     <?php
3204 3204
 
3205
-    $html = ob_get_clean();
3206
-    return $output.$html;
3205
+	$html = ob_get_clean();
3206
+	return $output.$html;
3207 3207
 }
3208 3208
 add_filter('geodir_cfa_extra_fields_datepicker','geodir_cfa_extra_fields_datepicker',10,4);
3209 3209
 
3210 3210
 
3211 3211
 function geodir_cfa_extra_fields_file($output,$result_str,$cf,$field_info){
3212
-    ob_start();
3213
-    $allowed_file_types = geodir_allowed_mime_types();
3212
+	ob_start();
3213
+	$allowed_file_types = geodir_allowed_mime_types();
3214 3214
 
3215
-    $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3216
-    $gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
3217
-    ?>
3215
+	$extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3216
+	$gd_file_types = !empty($extra_fields) && !empty($extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : array('*');
3217
+	?>
3218 3218
     <li>
3219 3219
         <label for="gd_file_types" class="gd-cf-tooltip-wrap">
3220 3220
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Allowed file types :', 'geodirectory'); ?>
@@ -3237,33 +3237,33 @@  discard block
 block discarded – undo
3237 3237
     </li>
3238 3238
     <?php
3239 3239
 
3240
-    $html = ob_get_clean();
3241
-    return $output.$html;
3240
+	$html = ob_get_clean();
3241
+	return $output.$html;
3242 3242
 }
3243 3243
 add_filter('geodir_cfa_extra_fields_file','geodir_cfa_extra_fields_file',10,4);
3244 3244
 
3245 3245
 function geodir_cfa_extra_fields_text($output,$result_str,$cf,$field_info){
3246
-    ob_start();
3246
+	ob_start();
3247 3247
 
3248
-    $extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3248
+	$extra_fields = isset($field_info->extra_fields) && $field_info->extra_fields != '' ? maybe_unserialize($field_info->extra_fields) : '';
3249 3249
    // print_r($cf);echo '###';
3250 3250
 
3251 3251
 
3252 3252
 
3253
-    $radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
3253
+	$radio_id = (isset($field_info->htmlvar_name)) ? $field_info->htmlvar_name : rand(5, 500);
3254 3254
 
3255 3255
 
3256
-    $value = '';
3257
-    if ($extra_fields && isset($extra_fields['is_price'])) {
3258
-    $value = esc_attr($extra_fields['is_price']);
3259
-    }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3260
-    $value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3261
-    }
3256
+	$value = '';
3257
+	if ($extra_fields && isset($extra_fields['is_price'])) {
3258
+	$value = esc_attr($extra_fields['is_price']);
3259
+	}elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3260
+	$value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3261
+	}
3262 3262
 
3263
-    $show_price_extra = ($value==1) ? 1 : 0;
3263
+	$show_price_extra = ($value==1) ? 1 : 0;
3264 3264
 
3265
-    $show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0;
3266
-    ?>
3265
+	$show_price = (isset($field_info->data_type) && ($field_info->data_type=='INT' && $field_info->data_type=='FLOAT')) ? 1 : 0;
3266
+	?>
3267 3267
     <li class="gdcf-price-extra-set" <?php if(!$show_price){ echo "style='display:none;'";}?>>
3268 3268
         <label for="is_price" class="gd-cf-tooltip-wrap">
3269 3269
             <i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Display as price? :', 'geodirectory'); ?>
@@ -3275,14 +3275,14 @@  discard block
 block discarded – undo
3275 3275
 
3276 3276
             <input type="radio" id="is_price_yes<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-enabled"  value="1"
3277 3277
                 <?php if ($value == '1') {
3278
-                    echo 'checked';
3279
-                } ?>/>
3278
+					echo 'checked';
3279
+				} ?>/>
3280 3280
             <label onclick="show_hide_radio(this,'show','gdcf-price-extra');" for="is_price_yes<?php echo $radio_id;?>" class="gdcb-enable"><span><?php _e('Yes', 'geodirectory'); ?></span></label>
3281 3281
 
3282 3282
             <input type="radio" id="is_price_no<?php echo $radio_id;?>" name="extra[is_price]" class="gdri-disabled" value="0"
3283 3283
                 <?php if ($value == '0' || !$value) {
3284
-                    echo 'checked';
3285
-                } ?>/>
3284
+					echo 'checked';
3285
+				} ?>/>
3286 3286
             <label onclick="show_hide_radio(this,'hide','gdcf-price-extra');" for="is_price_no<?php echo $radio_id;?>" class="gdcb-disable"><span><?php _e('No', 'geodirectory'); ?></span></label>
3287 3287
 
3288 3288
         </div>
@@ -3290,13 +3290,13 @@  discard block
 block discarded – undo
3290 3290
 
3291 3291
     <?php
3292 3292
 
3293
-    $value = '';
3294
-    if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3295
-        $value = esc_attr($extra_fields['thousand_separator']);
3296
-    }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3297
-        $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3298
-    }
3299
-    ?>
3293
+	$value = '';
3294
+	if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3295
+		$value = esc_attr($extra_fields['thousand_separator']);
3296
+	}elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3297
+		$value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3298
+	}
3299
+	?>
3300 3300
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3301 3301
         <label for="thousand_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Thousand separator :', 'geodirectory');?>
3302 3302
             <div class="gdcf-tooltip">
@@ -3317,13 +3317,13 @@  discard block
 block discarded – undo
3317 3317
 
3318 3318
     <?php
3319 3319
 
3320
-    $value = '';
3321
-    if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3322
-        $value = esc_attr($extra_fields['decimal_separator']);
3323
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3324
-        $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3325
-    }
3326
-    ?>
3320
+	$value = '';
3321
+	if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3322
+		$value = esc_attr($extra_fields['decimal_separator']);
3323
+	}elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3324
+		$value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3325
+	}
3326
+	?>
3327 3327
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3328 3328
         <label for="decimal_separator" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal separator :', 'geodirectory');?>
3329 3329
             <div class="gdcf-tooltip">
@@ -3340,13 +3340,13 @@  discard block
 block discarded – undo
3340 3340
 
3341 3341
     <?php
3342 3342
 
3343
-    $value = '';
3344
-    if ($extra_fields && isset($extra_fields['decimal_display'])) {
3345
-        $value = esc_attr($extra_fields['decimal_display']);
3346
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3347
-        $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3348
-    }
3349
-    ?>
3343
+	$value = '';
3344
+	if ($extra_fields && isset($extra_fields['decimal_display'])) {
3345
+		$value = esc_attr($extra_fields['decimal_display']);
3346
+	}elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3347
+		$value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3348
+	}
3349
+	?>
3350 3350
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3351 3351
         <label for="decimal_display" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Decimal display :', 'geodirectory');?>
3352 3352
             <div class="gdcf-tooltip">
@@ -3363,13 +3363,13 @@  discard block
 block discarded – undo
3363 3363
 
3364 3364
     <?php
3365 3365
 
3366
-    $value = '';
3367
-    if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3368
-        $value = esc_attr($extra_fields['currency_symbol']);
3369
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3370
-        $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3371
-    }
3372
-    ?>
3366
+	$value = '';
3367
+	if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3368
+		$value = esc_attr($extra_fields['currency_symbol']);
3369
+	}elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3370
+		$value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3371
+	}
3372
+	?>
3373 3373
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3374 3374
         <label for="currency_symbol" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol :', 'geodirectory');?>
3375 3375
             <div class="gdcf-tooltip">
@@ -3384,13 +3384,13 @@  discard block
 block discarded – undo
3384 3384
 
3385 3385
     <?php
3386 3386
 
3387
-    $value = '';
3388
-    if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3389
-        $value = esc_attr($extra_fields['currency_symbol_placement']);
3390
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3391
-        $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3392
-    }
3393
-    ?>
3387
+	$value = '';
3388
+	if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3389
+		$value = esc_attr($extra_fields['currency_symbol_placement']);
3390
+	}elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3391
+		$value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3392
+	}
3393
+	?>
3394 3394
     <li class="gdcf-price-extra" <?php if(!$show_price_extra){ echo "style='display:none;'";}?>>
3395 3395
         <label for="currency_symbol_placement" class="gd-cf-tooltip-wrap"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Currency symbol placement :', 'geodirectory');?>
3396 3396
             <div class="gdcf-tooltip">
@@ -3408,225 +3408,225 @@  discard block
 block discarded – undo
3408 3408
 
3409 3409
     <?php
3410 3410
 
3411
-    $html = ob_get_clean();
3412
-    return $output.$html;
3411
+	$html = ob_get_clean();
3412
+	return $output.$html;
3413 3413
 }
3414 3414
 add_filter('geodir_cfa_extra_fields_text','geodir_cfa_extra_fields_text',10,4);
3415 3415
 
3416 3416
 function geodir_default_custom_fields($post_type='gd_place',$package_id=''){
3417
-    $fields = array();
3418
-    $package = ($package_id=='') ? '' : array($package_id);
3419
-
3420
-    $fields[] = array('listing_type' => $post_type,
3421
-                      'data_type' => 'VARCHAR',
3422
-                      'field_type' => 'taxonomy',
3423
-                      'admin_title' => __('Category', 'geodirectory'),
3424
-                      'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'),
3425
-                      'site_title' => __('Category', 'geodirectory'),
3426
-                      'htmlvar_name' => $post_type.'category',
3427
-                      'default_value' => '',
3428
-                      'is_default' => '1',
3429
-                      'is_admin' => '1',
3430
-                      'is_required' => '1',
3431
-                      'show_in'   =>  '[detail]',
3432
-                      'show_on_pkg' => $package,
3433
-                      'clabels' => __('Category', 'geodirectory'));
3434
-
3435
-    $fields[] = array('listing_type' => $post_type,
3436
-                      'data_type' => 'VARCHAR',
3437
-                      'field_type' => 'address',
3438
-                      'admin_title' => __('Address', 'geodirectory'),
3439
-                      'admin_desc' => ADDRESS_MSG,
3440
-                      'site_title' => __('Address', 'geodirectory'),
3441
-                      'htmlvar_name' => 'post',
3442
-                      'default_value' => '',
3443
-                      'option_values' => '',
3444
-                      'is_default' => '1',
3445
-                      'is_admin' => '1',
3446
-                      'is_required' => '1',
3447
-                      'show_in'   =>  '[detail],[mapbubble]',
3448
-                      'show_on_pkg' => $package,
3449
-                      'required_msg' => __('Address fields are required', 'geodirectory'),
3450
-                      'clabels' => __('Address', 'geodirectory'),
3451
-                      'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'),
3452
-                                       'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'),
3453
-                                       'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'),
3454
-                                       'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'),
3455
-                                       'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'),
3456
-                                       'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'),
3457
-                                       'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden',
3458
-                                       'show_latlng' => 1));
3459
-
3460
-    $fields[] = array('listing_type' => $post_type,
3461
-                      'data_type' => 'VARCHAR',
3462
-                      'field_type' => 'text',
3463
-                      'admin_title' => __('Time', 'geodirectory'),
3464
-                      'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'),
3465
-                      'site_title' => __('Time', 'geodirectory'),
3466
-                      'htmlvar_name' => 'timing',
3467
-                      'default_value' => '',
3468
-                      'option_values' => '',
3469
-                      'is_default' => '1',
3470
-                      'is_admin' => '1',
3471
-                      'show_in' =>  '[detail],[mapbubble]',
3472
-                      'show_on_pkg' => $package,
3473
-                      'clabels' => __('Time', 'geodirectory'));
3474
-
3475
-    $fields[] = array('listing_type' => $post_type,
3476
-                      'data_type' => 'VARCHAR',
3477
-                      'field_type' => 'phone',
3478
-                      'admin_title' => __('Phone', 'geodirectory'),
3479
-                      'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'),
3480
-                      'site_title' => __('Phone', 'geodirectory'),
3481
-                      'htmlvar_name' => 'contact',
3482
-                      'default_value' => '',
3483
-                      'option_values' => '',
3484
-                      'is_default' => '1',
3485
-                      'is_admin' => '1',
3486
-                      'show_in' =>  '[detail],[mapbubble]',
3487
-                      'show_on_pkg' => $package,
3488
-                      'clabels' => __('Phone', 'geodirectory'));
3489
-
3490
-    $fields[] = array('listing_type' => $post_type,
3491
-                      'data_type' => 'VARCHAR',
3492
-                      'field_type' => 'email',
3493
-                      'admin_title' => __('Email', 'geodirectory'),
3494
-                      'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'),
3495
-                      'site_title' => __('Email', 'geodirectory'),
3496
-                      'htmlvar_name' => 'email',
3497
-                      'default_value' => '',
3498
-                      'option_values' => '',
3499
-                      'is_default' => '1',
3500
-                      'is_admin' => '1',
3501
-                      'show_in' => '[detail]',
3502
-                      'show_on_pkg' => $package,
3503
-                      'clabels' => __('Email', 'geodirectory'));
3504
-
3505
-    $fields[] = array('listing_type' => $post_type,
3506
-                      'data_type' => 'VARCHAR',
3507
-                      'field_type' => 'url',
3508
-                      'admin_title' => __('Website', 'geodirectory'),
3509
-                      'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'),
3510
-                      'site_title' => __('Website', 'geodirectory'),
3511
-                      'htmlvar_name' => 'website',
3512
-                      'default_value' => '',
3513
-                      'option_values' => '',
3514
-                      'is_default' => '1',
3515
-                      'is_admin' => '1',
3516
-                      'show_in' => '[detail]',
3517
-                      'show_on_pkg' => $package,
3518
-                      'clabels' => __('Website', 'geodirectory'));
3519
-
3520
-    $fields[] = array('listing_type' => $post_type,
3521
-                      'data_type' => 'VARCHAR',
3522
-                      'field_type' => 'url',
3523
-                      'admin_title' => __('Twitter', 'geodirectory'),
3524
-                      'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'),
3525
-                      'site_title' => __('Twitter', 'geodirectory'),
3526
-                      'htmlvar_name' => 'twitter',
3527
-                      'default_value' => '',
3528
-                      'option_values' => '',
3529
-                      'is_default' => '1',
3530
-                      'is_admin' => '1',
3531
-                      'show_in' => '[detail]',
3532
-                      'show_on_pkg' => $package,
3533
-                      'clabels' => __('Twitter', 'geodirectory'));
3534
-
3535
-    $fields[] = array('listing_type' => $post_type,
3536
-                      'data_type' => 'VARCHAR',
3537
-                      'field_type' => 'url',
3538
-                      'admin_title' => __('Facebook', 'geodirectory'),
3539
-                      'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'),
3540
-                      'site_title' => __('Facebook', 'geodirectory'),
3541
-                      'htmlvar_name' => 'facebook',
3542
-                      'default_value' => '',
3543
-                      'option_values' => '',
3544
-                      'is_default' => '1',
3545
-                      'is_admin' => '1',
3546
-                      'show_in' => '[detail]',
3547
-                      'show_on_pkg' => $package,
3548
-                      'clabels' => __('Facebook', 'geodirectory'));
3549
-
3550
-    $fields[] = array('listing_type' => $post_type,
3551
-                      'data_type' => 'TEXT',
3552
-                      'field_type' => 'textarea',
3553
-                      'admin_title' => __('Video', 'geodirectory'),
3554
-                      'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'),
3555
-                      'site_title' => __('Video', 'geodirectory'),
3556
-                      'htmlvar_name' => 'video',
3557
-                      'default_value' => '',
3558
-                      'option_values' => '',
3559
-                      'is_default' => '0',
3560
-                      'is_admin' => '1',
3561
-                      'show_in' => '[owntab]',
3562
-                      'show_on_pkg' => $package,
3563
-                      'clabels' => __('Video', 'geodirectory'));
3564
-
3565
-    $fields[] = array('listing_type' => $post_type,
3566
-                      'data_type' => 'TEXT',
3567
-                      'field_type' => 'textarea',
3568
-                      'admin_title' => __('Special Offers', 'geodirectory'),
3569
-                      'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'),
3570
-                      'site_title' => __('Special Offers', 'geodirectory'),
3571
-                      'htmlvar_name' => 'special_offers',
3572
-                      'default_value' => '',
3573
-                      'option_values' => '',
3574
-                      'is_default' => '0',
3575
-                      'is_admin' => '1',
3576
-                      'show_in' => '[owntab]',
3577
-                      'show_on_pkg' => $package,
3578
-                      'clabels' => __('Special Offers', 'geodirectory'));
3579
-
3580
-    /**
3581
-     * Filter the array of default custom fields DB table data.
3582
-     *
3583
-     * @since 1.6.6
3584
-     * @param string $fields The default custom fields as an array.
3585
-     */
3586
-    $fields = apply_filters('geodir_default_custom_fields', $fields);
3587
-
3588
-    return  $fields;
3417
+	$fields = array();
3418
+	$package = ($package_id=='') ? '' : array($package_id);
3419
+
3420
+	$fields[] = array('listing_type' => $post_type,
3421
+					  'data_type' => 'VARCHAR',
3422
+					  'field_type' => 'taxonomy',
3423
+					  'admin_title' => __('Category', 'geodirectory'),
3424
+					  'admin_desc' => __('SELECT listing category FROM here. SELECT at least one CATEGORY', 'geodirectory'),
3425
+					  'site_title' => __('Category', 'geodirectory'),
3426
+					  'htmlvar_name' => $post_type.'category',
3427
+					  'default_value' => '',
3428
+					  'is_default' => '1',
3429
+					  'is_admin' => '1',
3430
+					  'is_required' => '1',
3431
+					  'show_in'   =>  '[detail]',
3432
+					  'show_on_pkg' => $package,
3433
+					  'clabels' => __('Category', 'geodirectory'));
3434
+
3435
+	$fields[] = array('listing_type' => $post_type,
3436
+					  'data_type' => 'VARCHAR',
3437
+					  'field_type' => 'address',
3438
+					  'admin_title' => __('Address', 'geodirectory'),
3439
+					  'admin_desc' => ADDRESS_MSG,
3440
+					  'site_title' => __('Address', 'geodirectory'),
3441
+					  'htmlvar_name' => 'post',
3442
+					  'default_value' => '',
3443
+					  'option_values' => '',
3444
+					  'is_default' => '1',
3445
+					  'is_admin' => '1',
3446
+					  'is_required' => '1',
3447
+					  'show_in'   =>  '[detail],[mapbubble]',
3448
+					  'show_on_pkg' => $package,
3449
+					  'required_msg' => __('Address fields are required', 'geodirectory'),
3450
+					  'clabels' => __('Address', 'geodirectory'),
3451
+					  'extra' => array('show_city' => 1, 'city_lable' => __('City', 'geodirectory'),
3452
+									   'show_region' => 1, 'region_lable' => __('Region', 'geodirectory'),
3453
+									   'show_country' => 1, 'country_lable' => __('Country', 'geodirectory'),
3454
+									   'show_zip' => 1, 'zip_lable' => __('Zip/Post Code', 'geodirectory'),
3455
+									   'show_map' => 1, 'map_lable' => __('Set Address On Map', 'geodirectory'),
3456
+									   'show_mapview' => 1, 'mapview_lable' => __('Select Map View', 'geodirectory'),
3457
+									   'show_mapzoom' => 1, 'mapzoom_lable' => 'hidden',
3458
+									   'show_latlng' => 1));
3459
+
3460
+	$fields[] = array('listing_type' => $post_type,
3461
+					  'data_type' => 'VARCHAR',
3462
+					  'field_type' => 'text',
3463
+					  'admin_title' => __('Time', 'geodirectory'),
3464
+					  'admin_desc' => __('Enter Business or Listing Timing Information.<br/>eg. : 10.00 am to 6 pm every day', 'geodirectory'),
3465
+					  'site_title' => __('Time', 'geodirectory'),
3466
+					  'htmlvar_name' => 'timing',
3467
+					  'default_value' => '',
3468
+					  'option_values' => '',
3469
+					  'is_default' => '1',
3470
+					  'is_admin' => '1',
3471
+					  'show_in' =>  '[detail],[mapbubble]',
3472
+					  'show_on_pkg' => $package,
3473
+					  'clabels' => __('Time', 'geodirectory'));
3474
+
3475
+	$fields[] = array('listing_type' => $post_type,
3476
+					  'data_type' => 'VARCHAR',
3477
+					  'field_type' => 'phone',
3478
+					  'admin_title' => __('Phone', 'geodirectory'),
3479
+					  'admin_desc' => __('You can enter phone number,cell phone number etc.', 'geodirectory'),
3480
+					  'site_title' => __('Phone', 'geodirectory'),
3481
+					  'htmlvar_name' => 'contact',
3482
+					  'default_value' => '',
3483
+					  'option_values' => '',
3484
+					  'is_default' => '1',
3485
+					  'is_admin' => '1',
3486
+					  'show_in' =>  '[detail],[mapbubble]',
3487
+					  'show_on_pkg' => $package,
3488
+					  'clabels' => __('Phone', 'geodirectory'));
3489
+
3490
+	$fields[] = array('listing_type' => $post_type,
3491
+					  'data_type' => 'VARCHAR',
3492
+					  'field_type' => 'email',
3493
+					  'admin_title' => __('Email', 'geodirectory'),
3494
+					  'admin_desc' => __('You can enter your business or listing email.', 'geodirectory'),
3495
+					  'site_title' => __('Email', 'geodirectory'),
3496
+					  'htmlvar_name' => 'email',
3497
+					  'default_value' => '',
3498
+					  'option_values' => '',
3499
+					  'is_default' => '1',
3500
+					  'is_admin' => '1',
3501
+					  'show_in' => '[detail]',
3502
+					  'show_on_pkg' => $package,
3503
+					  'clabels' => __('Email', 'geodirectory'));
3504
+
3505
+	$fields[] = array('listing_type' => $post_type,
3506
+					  'data_type' => 'VARCHAR',
3507
+					  'field_type' => 'url',
3508
+					  'admin_title' => __('Website', 'geodirectory'),
3509
+					  'admin_desc' => __('You can enter your business or listing website.', 'geodirectory'),
3510
+					  'site_title' => __('Website', 'geodirectory'),
3511
+					  'htmlvar_name' => 'website',
3512
+					  'default_value' => '',
3513
+					  'option_values' => '',
3514
+					  'is_default' => '1',
3515
+					  'is_admin' => '1',
3516
+					  'show_in' => '[detail]',
3517
+					  'show_on_pkg' => $package,
3518
+					  'clabels' => __('Website', 'geodirectory'));
3519
+
3520
+	$fields[] = array('listing_type' => $post_type,
3521
+					  'data_type' => 'VARCHAR',
3522
+					  'field_type' => 'url',
3523
+					  'admin_title' => __('Twitter', 'geodirectory'),
3524
+					  'admin_desc' => __('You can enter your business or listing twitter url.', 'geodirectory'),
3525
+					  'site_title' => __('Twitter', 'geodirectory'),
3526
+					  'htmlvar_name' => 'twitter',
3527
+					  'default_value' => '',
3528
+					  'option_values' => '',
3529
+					  'is_default' => '1',
3530
+					  'is_admin' => '1',
3531
+					  'show_in' => '[detail]',
3532
+					  'show_on_pkg' => $package,
3533
+					  'clabels' => __('Twitter', 'geodirectory'));
3534
+
3535
+	$fields[] = array('listing_type' => $post_type,
3536
+					  'data_type' => 'VARCHAR',
3537
+					  'field_type' => 'url',
3538
+					  'admin_title' => __('Facebook', 'geodirectory'),
3539
+					  'admin_desc' => __('You can enter your business or listing facebook url.', 'geodirectory'),
3540
+					  'site_title' => __('Facebook', 'geodirectory'),
3541
+					  'htmlvar_name' => 'facebook',
3542
+					  'default_value' => '',
3543
+					  'option_values' => '',
3544
+					  'is_default' => '1',
3545
+					  'is_admin' => '1',
3546
+					  'show_in' => '[detail]',
3547
+					  'show_on_pkg' => $package,
3548
+					  'clabels' => __('Facebook', 'geodirectory'));
3549
+
3550
+	$fields[] = array('listing_type' => $post_type,
3551
+					  'data_type' => 'TEXT',
3552
+					  'field_type' => 'textarea',
3553
+					  'admin_title' => __('Video', 'geodirectory'),
3554
+					  'admin_desc' => __('Add video code here, YouTube etc.', 'geodirectory'),
3555
+					  'site_title' => __('Video', 'geodirectory'),
3556
+					  'htmlvar_name' => 'video',
3557
+					  'default_value' => '',
3558
+					  'option_values' => '',
3559
+					  'is_default' => '0',
3560
+					  'is_admin' => '1',
3561
+					  'show_in' => '[owntab]',
3562
+					  'show_on_pkg' => $package,
3563
+					  'clabels' => __('Video', 'geodirectory'));
3564
+
3565
+	$fields[] = array('listing_type' => $post_type,
3566
+					  'data_type' => 'TEXT',
3567
+					  'field_type' => 'textarea',
3568
+					  'admin_title' => __('Special Offers', 'geodirectory'),
3569
+					  'admin_desc' => __('Note: List out any special offers (optional)', 'geodirectory'),
3570
+					  'site_title' => __('Special Offers', 'geodirectory'),
3571
+					  'htmlvar_name' => 'special_offers',
3572
+					  'default_value' => '',
3573
+					  'option_values' => '',
3574
+					  'is_default' => '0',
3575
+					  'is_admin' => '1',
3576
+					  'show_in' => '[owntab]',
3577
+					  'show_on_pkg' => $package,
3578
+					  'clabels' => __('Special Offers', 'geodirectory'));
3579
+
3580
+	/**
3581
+	 * Filter the array of default custom fields DB table data.
3582
+	 *
3583
+	 * @since 1.6.6
3584
+	 * @param string $fields The default custom fields as an array.
3585
+	 */
3586
+	$fields = apply_filters('geodir_default_custom_fields', $fields);
3587
+
3588
+	return  $fields;
3589 3589
 }
3590 3590
 
3591 3591
 function geodir_currency_format_number($number='',$cf=''){
3592 3592
 
3593
-    $cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : '';
3593
+	$cs = isset($cf['extra_fields']) ? maybe_unserialize($cf['extra_fields']) : '';
3594 3594
 
3595
-    $symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$';
3596
-    $decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2;
3597
-    $decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if');
3598
-    $decimalpoint = '.';
3595
+	$symbol = isset($cs['currency_symbol']) ? $cs['currency_symbol'] : '$';
3596
+	$decimals = isset($cf['decimal_point']) && $cf['decimal_point'] ? $cf['decimal_point'] : 2;
3597
+	$decimal_display = !empty($cf['decimal_display']) ? $cf['decimal_display'] : (!empty($cs['decimal_display']) ? $cs['decimal_display'] : 'if');
3598
+	$decimalpoint = '.';
3599 3599
 
3600
-    if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
3601
-        $decimalpoint = ',';
3602
-    }
3600
+	if(isset($cs['decimal_separator']) && $cs['decimal_separator']=='comma'){
3601
+		$decimalpoint = ',';
3602
+	}
3603 3603
 
3604
-    $separator = ',';
3604
+	$separator = ',';
3605 3605
 
3606
-    if(isset($cs['thousand_separator'])){
3607
-        if($cs['thousand_separator']=='comma'){$separator = ',';}
3608
-        if($cs['thousand_separator']=='slash'){$separator = '\\';}
3609
-        if($cs['thousand_separator']=='period'){$separator = '.';}
3610
-        if($cs['thousand_separator']=='space'){$separator = ' ';}
3611
-        if($cs['thousand_separator']=='none'){$separator = '';}
3612
-    }
3606
+	if(isset($cs['thousand_separator'])){
3607
+		if($cs['thousand_separator']=='comma'){$separator = ',';}
3608
+		if($cs['thousand_separator']=='slash'){$separator = '\\';}
3609
+		if($cs['thousand_separator']=='period'){$separator = '.';}
3610
+		if($cs['thousand_separator']=='space'){$separator = ' ';}
3611
+		if($cs['thousand_separator']=='none'){$separator = '';}
3612
+	}
3613 3613
 
3614
-    $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3614
+	$currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3615 3615
 
3616
-    if($decimals>0 && $decimal_display=='if'){
3617
-        if(is_int($number) || floor( $number ) == $number)
3618
-            $decimals = 0;
3619
-    }
3616
+	if($decimals>0 && $decimal_display=='if'){
3617
+		if(is_int($number) || floor( $number ) == $number)
3618
+			$decimals = 0;
3619
+	}
3620 3620
 
3621
-    $number = number_format($number,$decimals,$decimalpoint,$separator);
3621
+	$number = number_format($number,$decimals,$decimalpoint,$separator);
3622 3622
 
3623 3623
 
3624 3624
 
3625
-    if($currency_symbol_placement=='left'){
3626
-        $number = $symbol . $number;
3627
-    }else{
3628
-        $number = $number . $symbol;
3629
-    }
3625
+	if($currency_symbol_placement=='left'){
3626
+		$number = $symbol . $number;
3627
+	}else{
3628
+		$number = $number . $symbol;
3629
+	}
3630 3630
 
3631 3631
 
3632 3632
    return $number;
Please login to merge, or discard this patch.
Braces   +136 added lines, -94 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
         global $wpdb;
52 52
         $result = 0;// no rows affected
53 53
         if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
54
+            if (!empty($db) && !empty($column)) {
55
+                            $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+            }
56 57
         }
57 58
         return $result;
58 59
     }
@@ -82,10 +83,11 @@  discard block
 block discarded – undo
82 83
 
83 84
     $default_query = '';
84 85
 
85
-    if ($default == 'default')
86
-        $default_query .= " and is_admin IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query .= " and is_admin = '0' ";
86
+    if ($default == 'default') {
87
+            $default_query .= " and is_admin IN ('1') ";
88
+    } elseif ($default == 'custom') {
89
+            $default_query .= " and is_admin = '0' ";
90
+    }
89 91
 
90 92
     if ($fields_location == 'none') {
91 93
     } else{
@@ -239,10 +241,12 @@  discard block
 block discarded – undo
239 241
                 }
240 242
 
241 243
                 return $field_id;
242
-            } else
243
-                return 0;
244
-        } else
245
-            return 0;
244
+            } else {
245
+                            return 0;
246
+            }
247
+        } else {
248
+                    return 0;
249
+        }
246 250
     }
247 251
 }
248 252
 
@@ -350,7 +354,9 @@  discard block
 block discarded – undo
350 354
 
351 355
 
352 356
 
353
-            if ($post_type == '') $post_type = 'gd_place';
357
+            if ($post_type == '') {
358
+            	$post_type = 'gd_place';
359
+            }
354 360
 
355 361
 
356 362
             $detail_table = $plugin_prefix . $post_type . '_detail';
@@ -390,16 +396,17 @@  discard block
 block discarded – undo
390 396
             }
391 397
 
392 398
             $option_values = '';
393
-            if (isset($request_field['option_values']))
394
-                $option_values = $request_field['option_values'];
399
+            if (isset($request_field['option_values'])) {
400
+                            $option_values = $request_field['option_values'];
401
+            }
395 402
 
396 403
             $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
397 404
 
398 405
             $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
399 406
 
400
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
402
-            else {
407
+            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) {
408
+                            $price_pkg = implode(",", $request_field['show_on_pkg']);
409
+            } else {
403 410
                 $package_info = array();
404 411
 
405 412
                 $package_info = geodir_post_package_info($package_info, '', $post_type);
@@ -407,22 +414,29 @@  discard block
 block discarded – undo
407 414
             }
408 415
 
409 416
 
410
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
411
-                $extra_fields = $request_field['extra'];
417
+            if (isset($request_field['extra']) && !empty($request_field['extra'])) {
418
+                            $extra_fields = $request_field['extra'];
419
+            }
412 420
 
413
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
-                $is_default = $request_field['is_default'];
415
-            else
416
-                $is_default = '0';
421
+            if (isset($request_field['is_default']) && $request_field['is_default'] != '') {
422
+                            $is_default = $request_field['is_default'];
423
+            } else {
424
+                            $is_default = '0';
425
+            }
417 426
 
418
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
-                $is_admin = $request_field['is_admin'];
420
-            else
421
-                $is_admin = '0';
427
+            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') {
428
+                            $is_admin = $request_field['is_admin'];
429
+            } else {
430
+                            $is_admin = '0';
431
+            }
422 432
 
423 433
 
424
-            if ($is_active == '') $is_active = 1;
425
-            if ($is_required == '') $is_required = 0;
434
+            if ($is_active == '') {
435
+            	$is_active = 1;
436
+            }
437
+            if ($is_required == '') {
438
+            	$is_required = 0;
439
+            }
426 440
 
427 441
 
428 442
             if ($sort_order == '') {
@@ -691,7 +705,7 @@  discard block
 block discarded – undo
691 705
                                 }
692 706
                                 if($op_max){$op_size =$op_max; }
693 707
                             }
694
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
708
+                        } elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695 709
                             if(strlen($option_values)){
696 710
                                 $op_size =  strlen($option_values);
697 711
                             }
@@ -708,11 +722,13 @@  discard block
 block discarded – undo
708 722
                             return __('Column change failed, you may have too many columns.','geodirectory');
709 723
                         }
710 724
 
711
-                        if (isset($request_field['cat_display_type']))
712
-                            $extra_fields = $request_field['cat_display_type'];
725
+                        if (isset($request_field['cat_display_type'])) {
726
+                                                    $extra_fields = $request_field['cat_display_type'];
727
+                        }
713 728
 
714
-                        if (isset($request_field['multi_display_type']))
715
-                            $extra_fields = $request_field['multi_display_type'];
729
+                        if (isset($request_field['multi_display_type'])) {
730
+                                                    $extra_fields = $request_field['multi_display_type'];
731
+                        }
716 732
 
717 733
 
718 734
                         break;
@@ -726,8 +742,9 @@  discard block
 block discarded – undo
726 742
                         if($alter_result===false){
727 743
                             return __('Column change failed, you may have too many columns.','geodirectory');
728 744
                         }
729
-                        if (isset($request_field['advanced_editor']))
730
-                            $extra_fields = $request_field['advanced_editor'];
745
+                        if (isset($request_field['advanced_editor'])) {
746
+                                                    $extra_fields = $request_field['advanced_editor'];
747
+                        }
731 748
 
732 749
                         break;
733 750
 
@@ -823,8 +840,9 @@  discard block
 block discarded – undo
823 840
                 );
824 841
 
825 842
 
826
-                if ($cat_sort == '')
827
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
843
+                if ($cat_sort == '') {
844
+                                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
845
+                }
828 846
 
829 847
 
830 848
                 /**
@@ -1194,8 +1212,10 @@  discard block
 block discarded – undo
1194 1212
         }
1195 1213
 
1196 1214
         return $post_meta_info;
1197
-    else:
1198
-        return false;
1215
+    else {
1216
+    	:
1217
+        return false;
1218
+    }
1199 1219
     endif;
1200 1220
 }
1201 1221
 
@@ -1206,8 +1226,9 @@  discard block
 block discarded – undo
1206 1226
     if (is_admin()) {
1207 1227
         global $post,$gd_session;
1208 1228
 
1209
-        if (isset($_REQUEST['post']))
1210
-            $_REQUEST['pid'] = $_REQUEST['post'];
1229
+        if (isset($_REQUEST['post'])) {
1230
+                    $_REQUEST['pid'] = $_REQUEST['post'];
1231
+        }
1211 1232
     }
1212 1233
 
1213 1234
     if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
@@ -1263,8 +1284,9 @@  discard block
 block discarded – undo
1263 1284
         if (is_admin()) {
1264 1285
             global $post;
1265 1286
 
1266
-            if (isset($_REQUEST['post']))
1267
-                $_REQUEST['pid'] = $_REQUEST['post'];
1287
+            if (isset($_REQUEST['post'])) {
1288
+                            $_REQUEST['pid'] = $_REQUEST['post'];
1289
+            }
1268 1290
         }
1269 1291
 
1270 1292
         
@@ -1356,7 +1378,7 @@  discard block
 block discarded – undo
1356 1378
         $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1357 1379
     } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1358 1380
         $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1359
-    }else{
1381
+    } else{
1360 1382
         $field_icon = $cf['field_icon'];
1361 1383
     }
1362 1384
 
@@ -1428,8 +1450,9 @@  discard block
 block discarded – undo
1428 1450
                     $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1429 1451
                     $variables_array['label'] = __($type['site_title'], 'geodirectory');
1430 1452
                     $variables_array['value'] = '';
1431
-                    if (isset($post->{$type['htmlvar_name']}))
1432
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
1453
+                    if (isset($post->{$type['htmlvar_name']})) {
1454
+                                            $variables_array['value'] = $post->{$type['htmlvar_name']};
1455
+                    }
1433 1456
                 endif;
1434 1457
 
1435 1458
 
@@ -1451,7 +1474,9 @@  discard block
 block discarded – undo
1451 1474
                      * @param string $html Custom field unfiltered HTML.
1452 1475
                      * @param array $variables_array Custom field variables array.
1453 1476
                      */
1454
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1477
+                    if ($html) {
1478
+                    	echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1479
+                    }
1455 1480
 
1456 1481
                     /**
1457 1482
                      * Called after a custom fields is output on the frontend.
@@ -1494,10 +1519,11 @@  discard block
 block discarded – undo
1494 1519
      */
1495 1520
     function geodir_default_date_format()
1496 1521
     {
1497
-        if ($format = get_option('date_format'))
1498
-            return $format;
1499
-        else
1500
-            return 'dd-mm-yy';
1522
+        if ($format = get_option('date_format')) {
1523
+                    return $format;
1524
+        } else {
1525
+                    return 'dd-mm-yy';
1526
+        }
1501 1527
     }
1502 1528
 }
1503 1529
 
@@ -1604,11 +1630,13 @@  discard block
 block discarded – undo
1604 1630
                     // Set an array containing a list of acceptable formats
1605 1631
                     //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1606 1632
 
1607
-                    if (!function_exists('wp_handle_upload'))
1608
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1633
+                    if (!function_exists('wp_handle_upload')) {
1634
+                                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1635
+                    }
1609 1636
 
1610
-                    if (!is_dir($geodir_uploadpath))
1611
-                        mkdir($geodir_uploadpath);
1637
+                    if (!is_dir($geodir_uploadpath)) {
1638
+                                            mkdir($geodir_uploadpath);
1639
+                    }
1612 1640
 
1613 1641
                     $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1614 1642
                     $explode_sub_dir = explode("/", $sub_dir);
@@ -1621,16 +1649,19 @@  discard block
 block discarded – undo
1621 1649
                     }
1622 1650
 
1623 1651
                     $uploaded_file = '';
1624
-                    if (file_exists($img_path))
1625
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1652
+                    if (file_exists($img_path)) {
1653
+                                            $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1654
+                    }
1626 1655
 
1627 1656
                     if ($curr_img_dir != $geodir_uploaddir) {
1628
-                        if (file_exists($img_path))
1629
-                            unlink($img_path);
1657
+                        if (file_exists($img_path)) {
1658
+                                                    unlink($img_path);
1659
+                        }
1630 1660
                     }
1631 1661
 
1632
-                    if (!empty($uploaded_file))
1633
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1662
+                    if (!empty($uploaded_file)) {
1663
+                                            $file_urls = $geodir_uploadurl . '/' . $new_name;
1664
+                    }
1634 1665
 
1635 1666
                 } else {
1636 1667
                     $file_urls = $post_image[$m];
@@ -1651,8 +1682,9 @@  discard block
 block discarded – undo
1651 1682
 
1652 1683
         geodir_save_post_meta($post_id, $field_id, $file_urls);
1653 1684
 
1654
-        if (!empty($invalid_files))
1655
-            geodir_remove_attachments($invalid_files);
1685
+        if (!empty($invalid_files)) {
1686
+                    geodir_remove_attachments($invalid_files);
1687
+        }
1656 1688
 
1657 1689
     }
1658 1690
 }
@@ -1878,8 +1910,9 @@  discard block
 block discarded – undo
1878 1910
 
1879 1911
         $all_postypes = geodir_get_posttypes();
1880 1912
 
1881
-        if (!in_array($post_type, $all_postypes))
1882
-            return false;
1913
+        if (!in_array($post_type, $all_postypes)) {
1914
+                    return false;
1915
+        }
1883 1916
 
1884 1917
         $fields = array();
1885 1918
 
@@ -1977,8 +2010,10 @@  discard block
 block discarded – undo
1977 2010
         }
1978 2011
 
1979 2012
         return $field_ids;
1980
-    else:
1981
-        return false;
2013
+    else {
2014
+    	:
2015
+        return false;
2016
+    }
1982 2017
     endif;
1983 2018
 }
1984 2019
 
@@ -2151,8 +2186,9 @@  discard block
 block discarded – undo
2151 2186
 
2152 2187
             return $field_id;
2153 2188
 
2154
-        } else
2155
-            return 0;
2189
+        } else {
2190
+                    return 0;
2191
+        }
2156 2192
 
2157 2193
     }
2158 2194
 }
@@ -2193,8 +2229,9 @@  discard block
 block discarded – undo
2193 2229
         $htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2194 2230
 
2195 2231
         $site_title = '';
2196
-        if ($site_title == '')
2197
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2232
+        if ($site_title == '') {
2233
+                    $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2234
+        }
2198 2235
 
2199 2236
         if ($site_title == '') {
2200 2237
             $fields = geodir_get_custom_sort_options($post_type);
@@ -2208,8 +2245,9 @@  discard block
 block discarded – undo
2208 2245
             }
2209 2246
         }
2210 2247
 
2211
-        if ($htmlvar_name == '')
2212
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2248
+        if ($htmlvar_name == '') {
2249
+                    $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2250
+        }
2213 2251
 
2214 2252
         $nonce = wp_create_nonce('custom_fields_' . $result_str);
2215 2253
 
@@ -2222,7 +2260,7 @@  discard block
 block discarded – undo
2222 2260
 
2223 2261
                 if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2224 2262
                     $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2225
-                }elseif(isset($cso['field_icon']) && $cso['field_icon']){
2263
+                } elseif(isset($cso['field_icon']) && $cso['field_icon']){
2226 2264
                     $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2227 2265
                 }
2228 2266
 
@@ -2658,7 +2696,7 @@  discard block
 block discarded – undo
2658 2696
     $dt_value = '';
2659 2697
     if (isset($field_info->data_type)) {
2660 2698
         $dt_value  = esc_attr($field_info->data_type);
2661
-    }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2699
+    } elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2662 2700
         $dt_value  = $cf['defaults']['data_type'];
2663 2701
     }
2664 2702
     ?>
@@ -2690,7 +2728,7 @@  discard block
 block discarded – undo
2690 2728
     $value = '';
2691 2729
     if (isset($field_info->decimal_point)) {
2692 2730
         $value = esc_attr($field_info->decimal_point);
2693
-    }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2731
+    } elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2694 2732
         $value = $cf['defaults']['decimal_point'];
2695 2733
     }
2696 2734
     ?>
@@ -2762,11 +2800,13 @@  discard block
 block discarded – undo
2762 2800
 
2763 2801
             <?php
2764 2802
             $selected = '';
2765
-            if (isset($field_info->extra_fields))
2766
-                $advanced_editor = unserialize($field_info->extra_fields);
2803
+            if (isset($field_info->extra_fields)) {
2804
+                            $advanced_editor = unserialize($field_info->extra_fields);
2805
+            }
2767 2806
 
2768
-            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2769
-                $selected = 'checked="checked"';
2807
+            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) {
2808
+                            $selected = 'checked="checked"';
2809
+            }
2770 2810
             ?>
2771 2811
 
2772 2812
             <input type="checkbox" name="advanced_editor[]" id="advanced_editor"
@@ -2788,7 +2828,7 @@  discard block
 block discarded – undo
2788 2828
     $value = '';
2789 2829
     if (isset($field_info->validation_pattern)) {
2790 2830
         $value = esc_attr($field_info->validation_pattern);
2791
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2831
+    } elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2792 2832
         $value = esc_attr($cf['defaults']['validation_pattern']);
2793 2833
     }
2794 2834
     ?>
@@ -2808,7 +2848,7 @@  discard block
 block discarded – undo
2808 2848
     $value = '';
2809 2849
     if (isset($field_info->validation_msg)) {
2810 2850
         $value = esc_attr($field_info->validation_msg);
2811
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2851
+    } elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2812 2852
         $value = esc_attr($cf['defaults']['validation_msg']);
2813 2853
     }
2814 2854
     ?>
@@ -2838,8 +2878,9 @@  discard block
 block discarded – undo
2838 2878
 
2839 2879
     if (!isset($field_info->post_type)) {
2840 2880
         $post_type = sanitize_text_field($_REQUEST['listing_type']);
2841
-    } else
2842
-        $post_type = $field_info->post_type;
2881
+    } else {
2882
+            $post_type = $field_info->post_type;
2883
+    }
2843 2884
     ?>
2844 2885
     <li style="display: none;">
2845 2886
         <label for="htmlvar_name" class="gd-cf-tooltip-wrap">
@@ -3113,7 +3154,7 @@  discard block
 block discarded – undo
3113 3154
     $value = '';
3114 3155
     if (isset($field_info->option_values)) {
3115 3156
         $value = esc_attr($field_info->option_values);
3116
-    }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3157
+    } elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3117 3158
         $value = esc_attr($cf['defaults']['option_values']);
3118 3159
     }
3119 3160
 
@@ -3256,7 +3297,7 @@  discard block
 block discarded – undo
3256 3297
     $value = '';
3257 3298
     if ($extra_fields && isset($extra_fields['is_price'])) {
3258 3299
     $value = esc_attr($extra_fields['is_price']);
3259
-    }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3300
+    } elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3260 3301
     $value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3261 3302
     }
3262 3303
 
@@ -3293,7 +3334,7 @@  discard block
 block discarded – undo
3293 3334
     $value = '';
3294 3335
     if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3295 3336
         $value = esc_attr($extra_fields['thousand_separator']);
3296
-    }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3337
+    } elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3297 3338
         $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3298 3339
     }
3299 3340
     ?>
@@ -3320,7 +3361,7 @@  discard block
 block discarded – undo
3320 3361
     $value = '';
3321 3362
     if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3322 3363
         $value = esc_attr($extra_fields['decimal_separator']);
3323
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3364
+    } elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3324 3365
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3325 3366
     }
3326 3367
     ?>
@@ -3343,7 +3384,7 @@  discard block
 block discarded – undo
3343 3384
     $value = '';
3344 3385
     if ($extra_fields && isset($extra_fields['decimal_display'])) {
3345 3386
         $value = esc_attr($extra_fields['decimal_display']);
3346
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3387
+    } elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3347 3388
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3348 3389
     }
3349 3390
     ?>
@@ -3366,7 +3407,7 @@  discard block
 block discarded – undo
3366 3407
     $value = '';
3367 3408
     if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3368 3409
         $value = esc_attr($extra_fields['currency_symbol']);
3369
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3410
+    } elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3370 3411
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3371 3412
     }
3372 3413
     ?>
@@ -3387,7 +3428,7 @@  discard block
 block discarded – undo
3387 3428
     $value = '';
3388 3429
     if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3389 3430
         $value = esc_attr($extra_fields['currency_symbol_placement']);
3390
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3431
+    } elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3391 3432
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3392 3433
     }
3393 3434
     ?>
@@ -3614,8 +3655,9 @@  discard block
 block discarded – undo
3614 3655
     $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3615 3656
 
3616 3657
     if($decimals>0 && $decimal_display=='if'){
3617
-        if(is_int($number) || floor( $number ) == $number)
3618
-            $decimals = 0;
3658
+        if(is_int($number) || floor( $number ) == $number) {
3659
+                    $decimals = 0;
3660
+        }
3619 3661
     }
3620 3662
 
3621 3663
     $number = number_format($number,$decimals,$decimalpoint,$separator);
@@ -3624,7 +3666,7 @@  discard block
 block discarded – undo
3624 3666
 
3625 3667
     if($currency_symbol_placement=='left'){
3626 3668
         $number = $symbol . $number;
3627
-    }else{
3669
+    } else{
3628 3670
         $number = $number . $symbol;
3629 3671
     }
3630 3672
 
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 2 patches
Indentation   +1252 added lines, -1252 removed lines patch added patch discarded remove patch
@@ -33,265 +33,265 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function geodir_add_nav_menu_items()
35 35
 {
36
-    $items = '';
37
-    // apply filter to add more navigations // -Filter-Location-Manager
38
-
39
-    if (get_option('geodir_show_listing_nav')) {
40
-
41
-        $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
44
-
45
-
46
-        //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
-        $post_types = geodir_get_posttypes('object');
48
-        $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
-        if (!empty($post_types)) {
50
-            foreach ($post_types as $post_type => $args) {
51
-                if (!empty($show_post_type_main_nav)) {
52
-                    if (in_array($post_type, $show_post_type_main_nav)) {
53
-                        if (get_post_type_archive_link($post_type)) {
54
-                            $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
57
-                            /**
58
-                             * Filter the menu li class.
59
-                             *
60
-                             * @since 1.0.0
61
-                             * @param string $menu_class The menu HTML class.
62
-                             */
63
-                            $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
-                            /**
65
-                             * Filter the menu a class.
66
-                             *
67
-                             * @since 1.0.0
68
-                             */
69
-                            $a_class = apply_filters('geodir_menu_a_class', '');
70
-                            $items .= '<li class="' . $li_class . '">
36
+	$items = '';
37
+	// apply filter to add more navigations // -Filter-Location-Manager
38
+
39
+	if (get_option('geodir_show_listing_nav')) {
40
+
41
+		$menu_class = '';
42
+		if (geodir_is_page('listing'))
43
+			$menu_class = 'current-menu-item';
44
+
45
+
46
+		//SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
47
+		$post_types = geodir_get_posttypes('object');
48
+		$show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav');
49
+		if (!empty($post_types)) {
50
+			foreach ($post_types as $post_type => $args) {
51
+				if (!empty($show_post_type_main_nav)) {
52
+					if (in_array($post_type, $show_post_type_main_nav)) {
53
+						if (get_post_type_archive_link($post_type)) {
54
+							$menu_class = '';
55
+							if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
+								$menu_class = 'current-menu-item';
57
+							/**
58
+							 * Filter the menu li class.
59
+							 *
60
+							 * @since 1.0.0
61
+							 * @param string $menu_class The menu HTML class.
62
+							 */
63
+							$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
64
+							/**
65
+							 * Filter the menu a class.
66
+							 *
67
+							 * @since 1.0.0
68
+							 */
69
+							$a_class = apply_filters('geodir_menu_a_class', '');
70
+							$items .= '<li class="' . $li_class . '">
71 71
 									<a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '">
72 72
 										' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
73 73
 									</a>
74 74
 								</li>';
75
-                        }
76
-                    }
77
-                }
78
-            }
79
-        }
80
-        //END LISTING OF POST TYPE IN MAIN NAVIGATION
81
-
82
-        $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
-        $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
-        if ($is_listing_sub_meny_exists) {
85
-            /**
86
-             * Filter the menu li class.
87
-             *
88
-             * @since 1.0.0
89
-             * @param string $menu_class The menu HTML class.
90
-             */
91
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
-            /**
93
-             * Filter the sub menu li class.
94
-             *
95
-             * @since 1.0.0
96
-             * @param string $menu_class The menu HTML class.
97
-             */
98
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
-            /**
100
-             * Filter the sub menu ul class.
101
-             *
102
-             * @since 1.0.0
103
-             */
104
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
-            /**
106
-             * Filter the menu a class.
107
-             *
108
-             * @since 1.0.0
109
-             */
110
-            $a_class = apply_filters('geodir_menu_a_class', '');
111
-            /**
112
-             * Filter the sub menu a class.
113
-             *
114
-             * @since 1.0.0
115
-             */
116
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
-            $items .= '<li class="' . $li_class . '">
75
+						}
76
+					}
77
+				}
78
+			}
79
+		}
80
+		//END LISTING OF POST TYPE IN MAIN NAVIGATION
81
+
82
+		$view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav');
83
+		$is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false;
84
+		if ($is_listing_sub_meny_exists) {
85
+			/**
86
+			 * Filter the menu li class.
87
+			 *
88
+			 * @since 1.0.0
89
+			 * @param string $menu_class The menu HTML class.
90
+			 */
91
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class);
92
+			/**
93
+			 * Filter the sub menu li class.
94
+			 *
95
+			 * @since 1.0.0
96
+			 * @param string $menu_class The menu HTML class.
97
+			 */
98
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
99
+			/**
100
+			 * Filter the sub menu ul class.
101
+			 *
102
+			 * @since 1.0.0
103
+			 */
104
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
105
+			/**
106
+			 * Filter the menu a class.
107
+			 *
108
+			 * @since 1.0.0
109
+			 */
110
+			$a_class = apply_filters('geodir_menu_a_class', '');
111
+			/**
112
+			 * Filter the sub menu a class.
113
+			 *
114
+			 * @since 1.0.0
115
+			 */
116
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
117
+			$items .= '<li class="' . $li_class . '">
118 118
 					<a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a>
119 119
 					<ul class="' . $sub_ul_class . '">';
120
-            $post_types = geodir_get_posttypes('object');
120
+			$post_types = geodir_get_posttypes('object');
121 121
 
122
-            $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
122
+			$show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav');
123 123
 
124
-            if (!empty($post_types)) {
125
-                global $geodir_add_location_url;
126
-                $geodir_add_location_url = true;
127
-                foreach ($post_types as $post_type => $args) {
128
-                    if (!empty($show_listing_post_types)) {
129
-                        if (in_array($post_type, $show_listing_post_types)) {
130
-                            if (get_post_type_archive_link($post_type)) {
124
+			if (!empty($post_types)) {
125
+				global $geodir_add_location_url;
126
+				$geodir_add_location_url = true;
127
+				foreach ($post_types as $post_type => $args) {
128
+					if (!empty($show_listing_post_types)) {
129
+						if (in_array($post_type, $show_listing_post_types)) {
130
+							if (get_post_type_archive_link($post_type)) {
131 131
 
132
-                                $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
132
+								$menu_class = '';
133
+								if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
+									$menu_class = 'current-menu-item';
135 135
 
136
-                                $items .= '<li class="' . $sub_li_class . '">
136
+								$items .= '<li class="' . $sub_li_class . '">
137 137
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
138 138
 															' . __(geodir_utf8_ucfirst($args->labels->name),'geodirectory') . '
139 139
 														</a>
140 140
 													</li>';
141
-                            }
142
-                        }
143
-                    }
144
-                }
145
-                $geodir_add_location_url = NULL;
146
-            }
141
+							}
142
+						}
143
+					}
144
+				}
145
+				$geodir_add_location_url = NULL;
146
+			}
147 147
 
148
-            $items .= '	</ul> ';
149
-            /**
150
-             * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
-             *
152
-             * @since 1.5.9
153
-             */
154
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
155
-            $items .= '</li>';
156
-        }
157
-    }
158
-
159
-    if (get_option('geodir_show_addlisting_nav')) {
160
-
161
-        $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
164
-
165
-        //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
-        $post_types = geodir_get_posttypes('object');
167
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
-
170
-        if (!empty($post_types)) {
171
-            foreach ($post_types as $post_type => $args) {
172
-                if (!empty($geodir_allow_posttype_frontend)) {
173
-                    if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
-                        if (!empty($show_add_listing_post_types_main_nav)) {
175
-                            if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
-                                if (geodir_get_addlisting_link($post_type)) {
177
-
178
-                                    $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
181
-                                    /**
182
-                                     * Filter the menu li class.
183
-                                     *
184
-                                     * @since 1.0.0
185
-                                     * @param string $menu_class The menu HTML class.
186
-                                     */
187
-                                    $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
-                                    /**
189
-                                     * Filter the menu a class.
190
-                                     *
191
-                                     * @since 1.0.0
192
-                                     */
193
-                                    $a_class = apply_filters('geodir_menu_a_class', '');
194
-                                    $cpt_name = __($args->labels->singular_name, 'geodirectory');
195
-                                    $items .= '<li class="' . $li_class . '">
148
+			$items .= '	</ul> ';
149
+			/**
150
+			 * Filter called after the sub menu closing ul tag for dynamic added menu items.
151
+			 *
152
+			 * @since 1.5.9
153
+			 */
154
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
155
+			$items .= '</li>';
156
+		}
157
+	}
158
+
159
+	if (get_option('geodir_show_addlisting_nav')) {
160
+
161
+		$menu_class = '';
162
+		if (geodir_is_page('add-listing'))
163
+			$menu_class = 'current-menu-item';
164
+
165
+		//SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166
+		$post_types = geodir_get_posttypes('object');
167
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav');
168
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
169
+
170
+		if (!empty($post_types)) {
171
+			foreach ($post_types as $post_type => $args) {
172
+				if (!empty($geodir_allow_posttype_frontend)) {
173
+					if (in_array($post_type, $geodir_allow_posttype_frontend)) {
174
+						if (!empty($show_add_listing_post_types_main_nav)) {
175
+							if (in_array($post_type, $show_add_listing_post_types_main_nav)) {
176
+								if (geodir_get_addlisting_link($post_type)) {
177
+
178
+									$menu_class = '';
179
+									if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
+										$menu_class = 'current-menu-item';
181
+									/**
182
+									 * Filter the menu li class.
183
+									 *
184
+									 * @since 1.0.0
185
+									 * @param string $menu_class The menu HTML class.
186
+									 */
187
+									$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
188
+									/**
189
+									 * Filter the menu a class.
190
+									 *
191
+									 * @since 1.0.0
192
+									 */
193
+									$a_class = apply_filters('geodir_menu_a_class', '');
194
+									$cpt_name = __($args->labels->singular_name, 'geodirectory');
195
+									$items .= '<li class="' . $li_class . '">
196 196
 											<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '">
197 197
 												' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
198 198
 											</a>
199 199
 										</li>';
200
-                                }
201
-                            }
202
-                        }
203
-                    }
204
-                }
205
-            }
206
-        }
207
-        //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
-    }
209
-
210
-    $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
-    $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
-    if ($is_add_listing_sub_meny_exists) {
213
-
214
-        if (get_option('geodir_show_addlisting_nav')) {
215
-            /**
216
-             * Filter the menu li class.
217
-             *
218
-             * @since 1.0.0
219
-             * @param string $menu_class The menu HTML class.
220
-             */
221
-            $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
-            /**
223
-             * Filter the sub menu li class.
224
-             *
225
-             * @since 1.0.0
226
-             * @param string $menu_class The menu HTML class.
227
-             */
228
-            $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
-            /**
230
-             * Filter the sub menu ul class.
231
-             *
232
-             * @since 1.0.0
233
-             */
234
-            $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
-            /**
236
-             * Filter the menu a class.
237
-             *
238
-             * @since 1.0.0
239
-             */
240
-            $a_class = apply_filters('geodir_menu_a_class', '');
241
-            /**
242
-             * Filter the sub menu a class.
243
-             *
244
-             * @since 1.0.0
245
-             */
246
-            $sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
-            $items .= '<li  class="' . $li_class . '">
200
+								}
201
+							}
202
+						}
203
+					}
204
+				}
205
+			}
206
+		}
207
+		//END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
208
+	}
209
+
210
+	$view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav');
211
+	$is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false;
212
+	if ($is_add_listing_sub_meny_exists) {
213
+
214
+		if (get_option('geodir_show_addlisting_nav')) {
215
+			/**
216
+			 * Filter the menu li class.
217
+			 *
218
+			 * @since 1.0.0
219
+			 * @param string $menu_class The menu HTML class.
220
+			 */
221
+			$li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class);
222
+			/**
223
+			 * Filter the sub menu li class.
224
+			 *
225
+			 * @since 1.0.0
226
+			 * @param string $menu_class The menu HTML class.
227
+			 */
228
+			$sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class);
229
+			/**
230
+			 * Filter the sub menu ul class.
231
+			 *
232
+			 * @since 1.0.0
233
+			 */
234
+			$sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu');
235
+			/**
236
+			 * Filter the menu a class.
237
+			 *
238
+			 * @since 1.0.0
239
+			 */
240
+			$a_class = apply_filters('geodir_menu_a_class', '');
241
+			/**
242
+			 * Filter the sub menu a class.
243
+			 *
244
+			 * @since 1.0.0
245
+			 */
246
+			$sub_a_class = apply_filters('geodir_sub_menu_a_class', '');
247
+			$items .= '<li  class="' . $li_class . '">
248 248
 					<a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a>
249 249
 					<ul class="' . $sub_ul_class . '">';
250 250
 
251
-            $post_types = geodir_get_posttypes('object');
252
-
253
-            $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
-
255
-            if (!empty($post_types)) {
256
-                foreach ($post_types as $post_type => $args) {
257
-                    if (!empty($geodir_allow_posttype_frontend)) {
258
-                        if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
-                            if (!empty($show_add_listing_post_types)) {
260
-                                if (in_array($post_type, $show_add_listing_post_types)) {
261
-                                    if (geodir_get_addlisting_link($post_type)) {
262
-
263
-                                        $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
266
-                                        /**
267
-                                         * Filter the menu li class.
268
-                                         *
269
-                                         * @since 1.0.0
270
-                                         * @param string $menu_class The menu HTML class.
271
-                                         */
272
-                                        $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
-                                        $cpt_name = __($args->labels->singular_name, 'geodirectory');
274
-                                        $items .= '<li class="' . $sub_li_class . '">
251
+			$post_types = geodir_get_posttypes('object');
252
+
253
+			$show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav');
254
+
255
+			if (!empty($post_types)) {
256
+				foreach ($post_types as $post_type => $args) {
257
+					if (!empty($geodir_allow_posttype_frontend)) {
258
+						if (in_array($post_type, $geodir_allow_posttype_frontend)) {
259
+							if (!empty($show_add_listing_post_types)) {
260
+								if (in_array($post_type, $show_add_listing_post_types)) {
261
+									if (geodir_get_addlisting_link($post_type)) {
262
+
263
+										$menu_class = '';
264
+										if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
+											$menu_class = 'current-menu-item';
266
+										/**
267
+										 * Filter the menu li class.
268
+										 *
269
+										 * @since 1.0.0
270
+										 * @param string $menu_class The menu HTML class.
271
+										 */
272
+										$li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class);
273
+										$cpt_name = __($args->labels->singular_name, 'geodirectory');
274
+										$items .= '<li class="' . $sub_li_class . '">
275 275
 														<a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '">
276 276
 															' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . '
277 277
 														</a>
278 278
 													</li>';
279
-                                    }
280
-                                }
281
-                            }
282
-                        }
283
-                    }
284
-                }
285
-            }
279
+									}
280
+								}
281
+							}
282
+						}
283
+					}
284
+				}
285
+			}
286 286
 
287
-            $items .= '	</ul> ';
288
-            $items .= apply_filters('geodir_menu_after_sub_ul','');
289
-            $items .= '</li>';
287
+			$items .= '	</ul> ';
288
+			$items .= apply_filters('geodir_menu_after_sub_ul','');
289
+			$items .= '</li>';
290 290
 
291
-        }
292
-    }
293
-    // apply filter to add more navigations // -Filter-Location-Manager
294
-    return $items;
291
+		}
292
+	}
293
+	// apply filter to add more navigations // -Filter-Location-Manager
294
+	return $items;
295 295
 }
296 296
 
297 297
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function geodir_pagemenu_items($menu, $args)
311 311
 {
312
-    $locations = get_nav_menu_locations();
313
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
314
-    $geodir_theme_location_nav = array();
315
-    if (empty($locations) && empty($geodir_theme_location)) {
316
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
-        $geodir_theme_location_nav[] = $args['theme_location'];
318
-        update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
-    }
320
-    //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
312
+	$locations = get_nav_menu_locations();
313
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
314
+	$geodir_theme_location_nav = array();
315
+	if (empty($locations) && empty($geodir_theme_location)) {
316
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
317
+		$geodir_theme_location_nav[] = $args['theme_location'];
318
+		update_option('geodir_theme_location_nav', $geodir_theme_location_nav);
319
+	}
320
+	//else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 321
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
322
+	else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
+		$menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
324 324
 
325
-    return $menu;
325
+	return $menu;
326 326
 
327 327
 }
328 328
 
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
 function geodir_menu_items($items, $args)
343 343
 {
344 344
 
345
-    $location = $args->theme_location;
345
+	$location = $args->theme_location;
346 346
 
347
-    $geodir_theme_location = get_option('geodir_theme_location_nav');
347
+	$geodir_theme_location = get_option('geodir_theme_location_nav');
348 348
 
349
-    if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
349
+	if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) {
350 350
 
351
-        $items = $items . geodir_add_nav_menu_items();
352
-        return $items;
351
+		$items = $items . geodir_add_nav_menu_items();
352
+		return $items;
353 353
 
354
-    } else {
355
-        return $items;
356
-    }
354
+	} else {
355
+		return $items;
356
+	}
357 357
 }
358 358
 
359 359
 /**
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function geodir_get_category_all_array()
370 370
 {
371
-    global $wpdb;
372
-    $return_array = array();
373
-
374
-    $taxonomies = geodir_get_taxonomies();
375
-    $taxonomies = implode("','", $taxonomies);
376
-    $taxonomies = "'" . $taxonomies . "'";
377
-
378
-    $pn_categories = $wpdb->get_results(
379
-        $wpdb->prepare(
380
-            "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
-            array($wpdb->terms . term_id)
382
-        )
383
-    );
384
-
385
-    foreach ($pn_categories as $pn_categories_obj) {
386
-        $return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
-            "title" => $pn_categories_obj->name,);
388
-    }
389
-    return $return_array;
371
+	global $wpdb;
372
+	$return_array = array();
373
+
374
+	$taxonomies = geodir_get_taxonomies();
375
+	$taxonomies = implode("','", $taxonomies);
376
+	$taxonomies = "'" . $taxonomies . "'";
377
+
378
+	$pn_categories = $wpdb->get_results(
379
+		$wpdb->prepare(
380
+			"SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy,  $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name",
381
+			array($wpdb->terms . term_id)
382
+		)
383
+	);
384
+
385
+	foreach ($pn_categories as $pn_categories_obj) {
386
+		$return_array[] = array("id" => $pn_categories_obj->cat_ID,
387
+			"title" => $pn_categories_obj->name,);
388
+	}
389
+	return $return_array;
390 390
 }
391 391
 
392 392
 
@@ -402,49 +402,49 @@  discard block
 block discarded – undo
402 402
  * @return string The post type.
403 403
  */
404 404
 function geodir_get_current_posttype() {
405
-    global $wp_query, $post, $geodir_post_type;
405
+	global $wp_query, $post, $geodir_post_type;
406 406
 
407
-    $geodir_post_type = get_query_var('post_type');
407
+	$geodir_post_type = get_query_var('post_type');
408 408
 
409
-    if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
-    }
409
+	if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
+			$geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
+		elseif (isset($_REQUEST['listing_type']))
413
+			$geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
414
+	}
415 415
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
416
+	if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
418 418
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
419
+	if (is_tax())
420
+		$geodir_post_type = geodir_get_taxonomy_posttype();
421 421
 
422
-    // Retrive post type for map marker html ajax request on preview page.
423
-    if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
-        if (!empty($post->post_type)) {
425
-            $geodir_post_type = $post->post_type;
426
-        } else if (!empty($post->listing_type)) {
427
-            $geodir_post_type = $post->listing_type;
428
-        }
429
-    }
422
+	// Retrive post type for map marker html ajax request on preview page.
423
+	if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
424
+		if (!empty($post->post_type)) {
425
+			$geodir_post_type = $post->post_type;
426
+		} else if (!empty($post->listing_type)) {
427
+			$geodir_post_type = $post->listing_type;
428
+		}
429
+	}
430 430
 
431
-    $all_postypes = geodir_get_posttypes();
432
-    $all_postypes = stripslashes_deep($all_postypes);
431
+	$all_postypes = geodir_get_posttypes();
432
+	$all_postypes = stripslashes_deep($all_postypes);
433 433
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
434
+	if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
+		$geodir_post_type = '';
436 436
 
437
-    if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
-    }
437
+	if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438
+		$geodir_post_type = sanitize_text_field($_REQUEST['stype']);
439
+	}
440 440
 
441 441
 
442
-    /**
443
-     * Filter the default CPT return.
444
-     *
445
-     * @since 1.6.9
446
-     */
447
-    return apply_filters('geodir_get_current_posttype',$geodir_post_type);
442
+	/**
443
+	 * Filter the default CPT return.
444
+	 *
445
+	 * @since 1.6.9
446
+	 */
447
+	return apply_filters('geodir_get_current_posttype',$geodir_post_type);
448 448
 }
449 449
 
450 450
 /**
@@ -458,22 +458,22 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_get_default_posttype()
460 460
 {
461
-    $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
-
463
-    $stype = false;
464
-    foreach ( $post_types as $post_type => $info ) {
465
-        global $wpdb;
466
-        $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
-        if ( $has_posts ) {
468
-            $stype = $post_type; break;
469
-        }
470
-    }
471
-
472
-    if(!$stype){
473
-        $stype = 'gd_place';
474
-    }
475
-
476
-    return $stype;
461
+	$post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) );
462
+
463
+	$stype = false;
464
+	foreach ( $post_types as $post_type => $info ) {
465
+		global $wpdb;
466
+		$has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) );
467
+		if ( $has_posts ) {
468
+			$stype = $post_type; break;
469
+		}
470
+	}
471
+
472
+	if(!$stype){
473
+		$stype = 'gd_place';
474
+	}
475
+
476
+	return $stype;
477 477
 }
478 478
 
479 479
 /**
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
  */
488 488
 function geodir_get_posttypes($output = 'names')
489 489
 {
490
-    $post_types = array();
491
-    $post_types = get_option('geodir_post_types');
492
-    $post_types = stripslashes_deep($post_types);
493
-    if (!empty($post_types)) {
494
-        switch ($output):
495
-            case 'object':
496
-            case 'Object':
497
-                $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
-                break;
499
-            case 'array':
500
-            case 'Array':
501
-                $post_types = (array)$post_types;
502
-                break;
490
+	$post_types = array();
491
+	$post_types = get_option('geodir_post_types');
492
+	$post_types = stripslashes_deep($post_types);
493
+	if (!empty($post_types)) {
494
+		switch ($output):
495
+			case 'object':
496
+			case 'Object':
497
+				$post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types;
498
+				break;
499
+			case 'array':
500
+			case 'Array':
501
+				$post_types = (array)$post_types;
502
+				break;
503 503
 			case 'options':
504
-                $post_types = (array)$post_types;
504
+				$post_types = (array)$post_types;
505 505
 				
506 506
 				$options = array();
507 507
 				if (!empty($post_types)) {
@@ -510,17 +510,17 @@  discard block
 block discarded – undo
510 510
 					}
511 511
 				}
512 512
 				$post_types = $options;
513
-                break;
514
-            default:
515
-                $post_types = array_keys($post_types);
516
-                break;
517
-        endswitch;
518
-    }
519
-
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
513
+				break;
514
+			default:
515
+				$post_types = array_keys($post_types);
516
+				break;
517
+		endswitch;
518
+	}
519
+
520
+	if (!empty($post_types))
521
+		return $post_types;
522
+	else
523
+		return array();
524 524
 }
525 525
 
526 526
 /**
@@ -533,108 +533,108 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function geodir_get_posttype_info($post_type = '')
535 535
 {
536
-    $post_types = array();
537
-    $post_types = get_option('geodir_post_types');
538
-    $post_types = stripslashes_deep($post_types);
539
-    if (!empty($post_types) && $post_type != '') {
540
-        return $post_types[$post_type];
541
-    } else
542
-        return false;
536
+	$post_types = array();
537
+	$post_types = get_option('geodir_post_types');
538
+	$post_types = stripslashes_deep($post_types);
539
+	if (!empty($post_types) && $post_type != '') {
540
+		return $post_types[$post_type];
541
+	} else
542
+		return false;
543 543
 }
544 544
 
545 545
 if (!function_exists('geodir_get_taxonomies')) {
546
-    /**
547
-     * Get all custom taxonomies.
548
-     *
549
-     * @since 1.0.0
550
-     * @package GeoDirectory
551
-     * @param string $post_type The post type.
552
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
-     * @return array|bool Taxonomies on success. false on failure.
554
-     */
555
-    function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false)
556
-    {
546
+	/**
547
+	 * Get all custom taxonomies.
548
+	 *
549
+	 * @since 1.0.0
550
+	 * @package GeoDirectory
551
+	 * @param string $post_type The post type.
552
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
553
+	 * @return array|bool Taxonomies on success. false on failure.
554
+	 */
555
+	function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false)
556
+	{
557 557
 
558
-        $taxonomies = array();
559
-        $gd_taxonomies = array();
558
+		$taxonomies = array();
559
+		$gd_taxonomies = array();
560 560
 
561
-        if ($taxonomies = get_option('geodir_taxonomies')) {
561
+		if ($taxonomies = get_option('geodir_taxonomies')) {
562 562
 
563 563
 
564
-            $gd_taxonomies = array_keys($taxonomies);
564
+			$gd_taxonomies = array_keys($taxonomies);
565 565
 
566 566
 
567
-            if ($post_type != '')
568
-                $gd_taxonomies = array();
567
+			if ($post_type != '')
568
+				$gd_taxonomies = array();
569 569
 
570
-            $i = 0;
571
-            foreach ($taxonomies as $taxonomy => $args) {
570
+			$i = 0;
571
+			foreach ($taxonomies as $taxonomy => $args) {
572 572
 
573
-                if ($post_type != '' && $args['object_type'] == $post_type)
574
-                    $gd_taxonomies[] = $taxonomy;
573
+				if ($post_type != '' && $args['object_type'] == $post_type)
574
+					$gd_taxonomies[] = $taxonomy;
575 575
 
576
-                if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
578
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
579
-                }
576
+				if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
+					if (array_search($taxonomy, $gd_taxonomies) !== false)
578
+						unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
579
+				}
580 580
 
581
-            }
581
+			}
582 582
 
583
-            $gd_taxonomies = array_values($gd_taxonomies);
584
-        }
585
-
586
-        /**
587
-         * Filter the taxonomies.
588
-         *
589
-         * @since 1.0.0
590
-         * @param array $gd_taxonomies The taxonomy array.
591
-         */
592
-        $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
593
-
594
-        if (!empty($taxonomies)) {
595
-            return $taxonomies;
596
-        } else {
597
-            return false;
598
-        }
599
-    }
583
+			$gd_taxonomies = array_values($gd_taxonomies);
584
+		}
585
+
586
+		/**
587
+		 * Filter the taxonomies.
588
+		 *
589
+		 * @since 1.0.0
590
+		 * @param array $gd_taxonomies The taxonomy array.
591
+		 */
592
+		$taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies);
593
+
594
+		if (!empty($taxonomies)) {
595
+			return $taxonomies;
596
+		} else {
597
+			return false;
598
+		}
599
+	}
600 600
 }
601 601
 
602 602
 if (!function_exists(' geodir_get_categories_dl')) {
603
-    /**
604
-     * Get categories dropdown HTML.
605
-     *
606
-     * @since 1.0.0
607
-     * @package GeoDirectory
608
-     * @param string $post_type The post type.
609
-     * @param string $selected The selected value.
610
-     * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
611
-     * @param bool $echo Prints the HTML when set to true. Default: true.
612
-     * @return void|string Dropdown HTML.
613
-     */
614
-    function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
615
-    {
616
-
617
-        $html = '';
618
-        $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
619
-
620
-        $categories = get_terms($taxonomies);
621
-
622
-        $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
623
-
624
-        foreach ($categories as $category_obj) {
625
-            $select_opt = '';
626
-            if ($selected == $category_obj->term_id) {
627
-                $select_opt = 'selected="selected"';
628
-            }
629
-            $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
630
-                . geodir_utf8_ucfirst($category_obj->name) . '</option>';
631
-        }
632
-
633
-        if ($echo)
634
-            echo $html;
635
-        else
636
-            return $html;
637
-    }
603
+	/**
604
+	 * Get categories dropdown HTML.
605
+	 *
606
+	 * @since 1.0.0
607
+	 * @package GeoDirectory
608
+	 * @param string $post_type The post type.
609
+	 * @param string $selected The selected value.
610
+	 * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false.
611
+	 * @param bool $echo Prints the HTML when set to true. Default: true.
612
+	 * @return void|string Dropdown HTML.
613
+	 */
614
+	function  geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true)
615
+	{
616
+
617
+		$html = '';
618
+		$taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies);
619
+
620
+		$categories = get_terms($taxonomies);
621
+
622
+		$html .= '<option value="0">' . __('All', 'geodirectory') . '</option>';
623
+
624
+		foreach ($categories as $category_obj) {
625
+			$select_opt = '';
626
+			if ($selected == $category_obj->term_id) {
627
+				$select_opt = 'selected="selected"';
628
+			}
629
+			$html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">'
630
+				. geodir_utf8_ucfirst($category_obj->name) . '</option>';
631
+		}
632
+
633
+		if ($echo)
634
+			echo $html;
635
+		else
636
+			return $html;
637
+	}
638 638
 }
639 639
 
640 640
 
@@ -649,28 +649,28 @@  discard block
 block discarded – undo
649 649
 function geodir_get_listing_slug($object_type = '')
650 650
 {
651 651
 
652
-    $listing_slug = '';
652
+	$listing_slug = '';
653 653
 
654
-    $post_types = get_option('geodir_post_types');
655
-    $taxonomies = get_option('geodir_taxonomies');
654
+	$post_types = get_option('geodir_post_types');
655
+	$taxonomies = get_option('geodir_taxonomies');
656 656
 
657 657
 
658
-    if ($object_type != '') {
659
-        if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
658
+	if ($object_type != '') {
659
+		if (!empty($post_types) && array_key_exists($object_type, $post_types)) {
660 660
 
661
-            $object_info = $post_types[$object_type];
662
-            $listing_slug = $object_info['listing_slug'];
663
-        } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
664
-            $object_info = $taxonomies[$object_type];
665
-            $listing_slug = $object_info['listing_slug'];
666
-        }
661
+			$object_info = $post_types[$object_type];
662
+			$listing_slug = $object_info['listing_slug'];
663
+		} elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) {
664
+			$object_info = $taxonomies[$object_type];
665
+			$listing_slug = $object_info['listing_slug'];
666
+		}
667 667
 
668
-    }
668
+	}
669 669
 
670
-    if (!empty($listing_slug))
671
-        return $listing_slug;
672
-    else
673
-        return false;
670
+	if (!empty($listing_slug))
671
+		return $listing_slug;
672
+	else
673
+		return false;
674 674
 }
675 675
 
676 676
 
@@ -685,212 +685,212 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function geodir_get_taxonomy_posttype($taxonomy = '')
687 687
 {
688
-    global $wp_query;
689
-
690
-    $post_type = array();
691
-    $taxonomies = array();
692
-
693
-    if (!empty($taxonomy)) {
694
-        $taxonomies[] = $taxonomy;
695
-    } elseif (isset($wp_query->tax_query->queries)) {
696
-        $tax_arr = $wp_query->tax_query->queries;
697
-        //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
698
-        if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
699
-        $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
700
-    }
701
-
702
-    if (!empty($taxonomies)) {
703
-        foreach (geodir_get_posttypes() as $pt) {
704
-            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
-            if (array_intersect($taxonomies, $object_taxonomies))
706
-                $post_type[] = $pt;
707
-        }
708
-    }
709
-
710
-    if (!empty($post_type))
711
-        return $post_type[0];
712
-    else
713
-        return false;
688
+	global $wp_query;
689
+
690
+	$post_type = array();
691
+	$taxonomies = array();
692
+
693
+	if (!empty($taxonomy)) {
694
+		$taxonomies[] = $taxonomy;
695
+	} elseif (isset($wp_query->tax_query->queries)) {
696
+		$tax_arr = $wp_query->tax_query->queries;
697
+		//if tax query has 'relation' set then it will break wp_list_pluck so we remove it
698
+		if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);}
699
+		$taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
700
+	}
701
+
702
+	if (!empty($taxonomies)) {
703
+		foreach (geodir_get_posttypes() as $pt) {
704
+			$object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
+			if (array_intersect($taxonomies, $object_taxonomies))
706
+				$post_type[] = $pt;
707
+		}
708
+	}
709
+
710
+	if (!empty($post_type))
711
+		return $post_type[0];
712
+	else
713
+		return false;
714 714
 }
715 715
 
716 716
 if (!function_exists('geodir_custom_taxonomy_walker')) {
717
-    /**
718
-     * Custom taxonomy walker function.
719
-     *
720
-     * @since 1.0.0
721
-     * @package GeoDirectory
722
-     * @param string $cat_taxonomy The taxonomy name.
723
-     * @param int $cat_parent The parent term ID.
724
-     * @param bool $hide_empty Hide empty taxonomies? Default: false.
725
-     * @param int $pading CSS padding in pixels.
726
-     * @return string|void taxonomy HTML.
727
-     */
728
-    function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
729
-    {
730
-        global $cat_display, $post_cat, $exclude_cats;
731
-
732
-        $search_terms = trim($post_cat, ",");
733
-
734
-        $search_terms = explode(",", $search_terms);
735
-
736
-        $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
737
-
738
-        $display = '';
739
-        $onchange = '';
740
-        $term_check = '';
741
-        $main_list_class = '';
742
-        $out = '';
743
-        //If there are terms, start displaying
744
-        if (count($cat_terms) > 0) {
745
-            //Displaying as a list
746
-            $p = $pading * 20;
747
-            $pading++;
748
-
749
-
750
-            if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
751
-                if ($cat_parent == 0) {
752
-                    $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
753
-                    $main_list_class = 'class="main_list_selecter"';
754
-                } else {
755
-                    //$display = 'display:none';
756
-                    $list_class = 'sub_list gd-sub-cats-list';
757
-                }
758
-            }
717
+	/**
718
+	 * Custom taxonomy walker function.
719
+	 *
720
+	 * @since 1.0.0
721
+	 * @package GeoDirectory
722
+	 * @param string $cat_taxonomy The taxonomy name.
723
+	 * @param int $cat_parent The parent term ID.
724
+	 * @param bool $hide_empty Hide empty taxonomies? Default: false.
725
+	 * @param int $pading CSS padding in pixels.
726
+	 * @return string|void taxonomy HTML.
727
+	 */
728
+	function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0)
729
+	{
730
+		global $cat_display, $post_cat, $exclude_cats;
731
+
732
+		$search_terms = trim($post_cat, ",");
733
+
734
+		$search_terms = explode(",", $search_terms);
735
+
736
+		$cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats));
737
+
738
+		$display = '';
739
+		$onchange = '';
740
+		$term_check = '';
741
+		$main_list_class = '';
742
+		$out = '';
743
+		//If there are terms, start displaying
744
+		if (count($cat_terms) > 0) {
745
+			//Displaying as a list
746
+			$p = $pading * 20;
747
+			$pading++;
748
+
749
+
750
+			if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) {
751
+				if ($cat_parent == 0) {
752
+					$list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display;
753
+					$main_list_class = 'class="main_list_selecter"';
754
+				} else {
755
+					//$display = 'display:none';
756
+					$list_class = 'sub_list gd-sub-cats-list';
757
+				}
758
+			}
759 759
 
760
-            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
761
-                $p = 0;
762
-                $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
763
-            }
760
+			if ($cat_display == 'checkbox' || $cat_display == 'radio') {
761
+				$p = 0;
762
+				$out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">';
763
+			}
764 764
 
765
-            foreach ($cat_terms as $cat_term) {
765
+			foreach ($cat_terms as $cat_term) {
766 766
 
767
-                $checked = '';
767
+				$checked = '';
768 768
 
769
-                if (in_array($cat_term->term_id, $search_terms)) {
770
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
771
-                        $checked = 'selected="selected"';
772
-                    else
773
-                        $checked = 'checked="checked"';
774
-                }
769
+				if (in_array($cat_term->term_id, $search_terms)) {
770
+					if ($cat_display == 'select' || $cat_display == 'multiselect')
771
+						$checked = 'selected="selected"';
772
+					else
773
+						$checked = 'checked="checked"';
774
+				}
775 775
 
776
-                if ($cat_display == 'radio')
777
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
776
+				if ($cat_display == 'radio')
777
+					$out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
+				elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
+					$out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
780 780
 
781
-                else {
782
-                    $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783
-                }
781
+				else {
782
+					$out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783
+				}
784 784
 
785
-                // Call recurson to print sub cats
786
-                $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
785
+				// Call recurson to print sub cats
786
+				$out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading);
787 787
 
788
-            }
788
+			}
789 789
 
790
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
-                $out .= '</div>';
790
+			if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
+				$out .= '</div>';
792 792
 
793
-            return $out;
794
-        }
795
-        return;
796
-    }
793
+			return $out;
794
+		}
795
+		return;
796
+	}
797 797
 }
798 798
 
799 799
 if (!function_exists('geodir_custom_taxonomy_walker2')) {
800
-    /**
801
-     * Custom taxonomy walker function.
802
-     *
803
-     * @since 1.0.0
804
-     * @package GeoDirectory
805
-     * @global object $post WordPress Post object.
806
-     * @global object $gd_session GeoDirectory Session object.
807
-     * @param string $cat_taxonomy The taxonomy name.
808
-     * @param string $cat_limit Number of categories to display.
809
-     */
810
-    function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
811
-    {
812
-        $post_category = '';
813
-        $post_category_str = '';
814
-        global $exclude_cats, $gd_session;
815
-
816
-        $cat_exclude = '';
817
-        if (is_array($exclude_cats) && !empty($exclude_cats))
818
-            $cat_exclude = serialize($exclude_cats);
819
-
820
-        if (isset($_REQUEST['backandedit'])) {
821
-            $post = (object)$gd_session->get('listing');
822
-
823
-            if (!is_array($post->post_category[$cat_taxonomy]))
824
-                $post_category = $post->post_category[$cat_taxonomy];
825
-
826
-            $post_categories = $post->post_category_str;
827
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
-                $post_category_str = $post_categories[$cat_taxonomy];
829
-
830
-        } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831
-            global $post;
832
-
833
-            $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
834
-            if (empty($post_category) && isset($post->{$cat_taxonomy})) {
835
-                $post_category = $post->{$cat_taxonomy};
836
-            }
800
+	/**
801
+	 * Custom taxonomy walker function.
802
+	 *
803
+	 * @since 1.0.0
804
+	 * @package GeoDirectory
805
+	 * @global object $post WordPress Post object.
806
+	 * @global object $gd_session GeoDirectory Session object.
807
+	 * @param string $cat_taxonomy The taxonomy name.
808
+	 * @param string $cat_limit Number of categories to display.
809
+	 */
810
+	function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '')
811
+	{
812
+		$post_category = '';
813
+		$post_category_str = '';
814
+		global $exclude_cats, $gd_session;
815
+
816
+		$cat_exclude = '';
817
+		if (is_array($exclude_cats) && !empty($exclude_cats))
818
+			$cat_exclude = serialize($exclude_cats);
819
+
820
+		if (isset($_REQUEST['backandedit'])) {
821
+			$post = (object)$gd_session->get('listing');
822
+
823
+			if (!is_array($post->post_category[$cat_taxonomy]))
824
+				$post_category = $post->post_category[$cat_taxonomy];
825
+
826
+			$post_categories = $post->post_category_str;
827
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
+				$post_category_str = $post_categories[$cat_taxonomy];
829
+
830
+		} elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831
+			global $post;
832
+
833
+			$post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true);
834
+			if (empty($post_category) && isset($post->{$cat_taxonomy})) {
835
+				$post_category = $post->{$cat_taxonomy};
836
+			}
837 837
 
838
-            $post_categories = get_post_meta($post->ID, 'post_categories', true);
838
+			$post_categories = get_post_meta($post->ID, 'post_categories', true);
839 839
 
840
-            if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
841
-                foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
842
-                    if (is_numeric($cat_part)) {
843
-                        $cat_part_arr[] = $cat_part;
844
-                    }
845
-                }
846
-                if (is_array($cat_part_arr)) {
847
-                    $post_category = implode(',', $cat_part_arr);
848
-                }
849
-            }
840
+			if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) {
841
+				foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) {
842
+					if (is_numeric($cat_part)) {
843
+						$cat_part_arr[] = $cat_part;
844
+					}
845
+				}
846
+				if (is_array($cat_part_arr)) {
847
+					$post_category = implode(',', $cat_part_arr);
848
+				}
849
+			}
850 850
 
851
-            if (!empty($post_category)) {
852
-                $cat1 = array_filter(explode(',', $post_category));
853
-                $post_category = ',' . implode(',', $cat1) . ',';
851
+			if (!empty($post_category)) {
852
+				$cat1 = array_filter(explode(',', $post_category));
853
+				$post_category = ',' . implode(',', $cat1) . ',';
854 854
 
855
-            }
855
+			}
856 856
 
857
-            if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
857
+			if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) {
858 858
 
859
-                $post_category_upd = explode(',', $post_category);
860
-                $post_category_change = '';
861
-                foreach ($post_category_upd as $cat) {
859
+				$post_category_upd = explode(',', $post_category);
860
+				$post_category_change = '';
861
+				foreach ($post_category_upd as $cat) {
862 862
 
863
-                    if (!in_array($cat, $exclude_cats) && $cat != '') {
864
-                        $post_category_change .= ',' . $cat;
865
-                    }
866
-                }
867
-                $post_category = $post_category_change;
868
-            }
863
+					if (!in_array($cat, $exclude_cats) && $cat != '') {
864
+						$post_category_change .= ',' . $cat;
865
+					}
866
+				}
867
+				$post_category = $post_category_change;
868
+			}
869 869
 
870 870
 
871
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
872
-                $post_category_str = $post_categories[$cat_taxonomy];
873
-            }
874
-        }
871
+			if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
872
+				$post_category_str = $post_categories[$cat_taxonomy];
873
+			}
874
+		}
875 875
 
876
-        echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
876
+		echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']"  />';
877 877
 
878
-        echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
878
+		echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']"  />';
879 879
 
880
-        echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
880
+		echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']"  />';
881 881
 
882 882
 
883
-        ?>
883
+		?>
884 884
         <div class="cat_sublist">
885 885
             <?php
886 886
 
887
-            $post_id = isset($post->ID) ? $post->ID : '';
887
+			$post_id = isset($post->ID) ? $post->ID : '';
888 888
 
889
-            if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
889
+			if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) {
890 890
 
891
-                geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
892
-            }
893
-            ?>
891
+				geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories);
892
+			}
893
+			?>
894 894
         </div>
895 895
         <script type="text/javascript">
896 896
 
@@ -1013,22 +1013,22 @@  discard block
 block discarded – undo
1013 1013
 
1014 1014
         </script>
1015 1015
         <?php
1016
-        if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017
-            $post_cat_str = $post_categories[$cat_taxonomy];
1018
-            $post_cat_array = explode("#", $post_cat_str);
1019
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
-                $style = "display:none;";
1021
-        }
1022
-        ?>
1016
+		if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017
+			$post_cat_str = $post_categories[$cat_taxonomy];
1018
+			$post_cat_array = explode("#", $post_cat_str);
1019
+			if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
+				$style = "display:none;";
1021
+		}
1022
+		?>
1023 1023
         <div class="main_cat_list" style=" <?php if (isset($style)) {
1024
-            echo $style;
1025
-        }?> ">
1024
+			echo $style;
1025
+		}?> ">
1026 1026
             <?php geodir_get_catlist($cat_taxonomy, 0);  // print main categories list
1027
-            ?>
1027
+			?>
1028 1028
         </div>
1029 1029
     <?php
1030 1030
 
1031
-    }
1031
+	}
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1045,23 +1045,23 @@  discard block
 block discarded – undo
1045 1045
  */
1046 1046
 function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '')
1047 1047
 {
1048
-    global $exclude_cats;
1048
+	global $exclude_cats;
1049 1049
 
1050
-    if ($exclude != '') {
1051
-        $exclude_cats = maybe_unserialize(base64_decode($exclude));
1050
+	if ($exclude != '') {
1051
+		$exclude_cats = maybe_unserialize(base64_decode($exclude));
1052 1052
 
1053
-        if(is_array( $exclude_cats)){
1054
-            $exclude_cats = array_map( 'intval', $exclude_cats );
1055
-        }else{
1056
-            $exclude_cats = intval($exclude_cats);
1057
-        }
1053
+		if(is_array( $exclude_cats)){
1054
+			$exclude_cats = array_map( 'intval', $exclude_cats );
1055
+		}else{
1056
+			$exclude_cats = intval($exclude_cats);
1057
+		}
1058 1058
 
1059
-    }
1059
+	}
1060 1060
 
1061
-    if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1062
-        (!is_array($exclude_cats) || empty($exclude_cats))
1063
-    ) {
1064
-        ?>
1061
+	if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) ||
1062
+		(!is_array($exclude_cats) || empty($exclude_cats))
1063
+	) {
1064
+		?>
1065 1065
 
1066 1066
         <?php $main_cat = get_term($parrent, $request_taxonomy); ?>
1067 1067
 
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
             <br/>
1092 1092
             <?php
1093
-            $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1094
-            if (!empty($cat_terms)) { ?>
1093
+			$cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats));
1094
+			if (!empty($cat_terms)) { ?>
1095 1095
                 <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span>
1096 1096
                 <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?>
1097 1097
             <?php } ?>
@@ -1113,53 +1113,53 @@  discard block
 block discarded – undo
1113 1113
 function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories)
1114 1114
 {
1115 1115
 
1116
-    if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1117
-        $post_cat_str = $post_categories[$request_taxonomy];
1118
-        $post_cat_array = explode("#", $post_cat_str);
1119
-        if (is_array($post_cat_array)) {
1120
-            $post_cat_array = array_unique( $post_cat_array );
1116
+	if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) {
1117
+		$post_cat_str = $post_categories[$request_taxonomy];
1118
+		$post_cat_array = explode("#", $post_cat_str);
1119
+		if (is_array($post_cat_array)) {
1120
+			$post_cat_array = array_unique( $post_cat_array );
1121 1121
 
1122 1122
 			foreach ($post_cat_array as $post_cat_html) {
1123 1123
 
1124
-                $post_cat_info = explode(":", $post_cat_html);
1125
-                $post_maincat_str = $post_cat_info[0];
1124
+				$post_cat_info = explode(":", $post_cat_html);
1125
+				$post_maincat_str = $post_cat_info[0];
1126 1126
 
1127
-                if (!empty($post_maincat_str)) {
1128
-                    $post_maincat_info = explode(",", $post_maincat_str);
1129
-                    $post_maincat_id = $post_maincat_info[0];
1130
-                    ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1131
-                    (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1132
-                }
1133
-                $post_sub_catid = '';
1134
-                if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1135
-                    $post_sub_catid = (int)$post_cat_info[1];
1136
-                }
1127
+				if (!empty($post_maincat_str)) {
1128
+					$post_maincat_info = explode(",", $post_maincat_str);
1129
+					$post_maincat_id = $post_maincat_info[0];
1130
+					($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1131
+					(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1132
+				}
1133
+				$post_sub_catid = '';
1134
+				if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1135
+					$post_sub_catid = (int)$post_cat_info[1];
1136
+				}
1137 1137
 
1138
-                geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1138
+				geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1139 1139
 
1140
-            }
1141
-        } else {
1140
+			}
1141
+		} else {
1142 1142
 
1143
-            $post_cat_info = explode(":", $post_cat_str);
1144
-            $post_maincat_str = $post_cat_info[0];
1143
+			$post_cat_info = explode(":", $post_cat_str);
1144
+			$post_maincat_str = $post_cat_info[0];
1145 1145
 
1146
-            $post_sub_catid = '';
1146
+			$post_sub_catid = '';
1147 1147
 
1148
-            if (!empty($post_maincat_str)) {
1149
-                $post_maincat_info = explode(",", $post_maincat_str);
1150
-                $post_maincat_id = $post_maincat_info[0];
1151
-                ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1152
-                (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1153
-            }
1148
+			if (!empty($post_maincat_str)) {
1149
+				$post_maincat_info = explode(",", $post_maincat_str);
1150
+				$post_maincat_id = $post_maincat_info[0];
1151
+				($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false;
1152
+				(end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false;
1153
+			}
1154 1154
 
1155
-            if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1156
-                $post_sub_catid = (int)$post_cat_info[1];
1157
-            }
1155
+			if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) {
1156
+				$post_sub_catid = (int)$post_cat_info[1];
1157
+			}
1158 1158
 
1159
-            geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1159
+			geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default);
1160 1160
 
1161
-        }
1162
-    }
1161
+		}
1162
+	}
1163 1163
 }
1164 1164
 
1165 1165
 /**
@@ -1173,35 +1173,35 @@  discard block
 block discarded – undo
1173 1173
  */
1174 1174
 function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false)
1175 1175
 {
1176
-    global $exclude_cats;
1176
+	global $exclude_cats;
1177 1177
 
1178
-    $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1178
+	$cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats));
1179 1179
 
1180
-    if (!empty($cat_terms)) {
1181
-        $onchange = '';
1182
-        $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1180
+	if (!empty($cat_terms)) {
1181
+		$onchange = '';
1182
+		$onchange = ' onchange="show_subcatlist(this.value, this)" ';
1183 1183
 
1184
-        $option_selected = '';
1185
-        if (!$selected)
1186
-            $option_slected = ' selected="selected" ';
1184
+		$option_selected = '';
1185
+		if (!$selected)
1186
+			$option_slected = ' selected="selected" ';
1187 1187
 
1188
-        echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1188
+		echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1189 1189
 
1190
-        echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1190
+		echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>';
1191 1191
 
1192
-        foreach ($cat_terms as $cat_term) {
1193
-            $option_selected = '';
1194
-            if ($selected == $cat_term->term_id)
1195
-                $option_selected = ' selected="selected" ';
1192
+		foreach ($cat_terms as $cat_term) {
1193
+			$option_selected = '';
1194
+			if ($selected == $cat_term->term_id)
1195
+				$option_selected = ' selected="selected" ';
1196 1196
 
1197
-            // Count child terms
1198
-            $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1199
-            $has_child = !empty( $child_terms ) ? 't' : 'f';
1197
+			// Count child terms
1198
+			$child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
1199
+			$has_child = !empty( $child_terms ) ? 't' : 'f';
1200 1200
 
1201
-            echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1202
-        }
1203
-        echo '</select>';
1204
-    }
1201
+			echo '<option  ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>';
1202
+		}
1203
+		echo '</select>';
1204
+	}
1205 1205
 }
1206 1206
 
1207 1207
 /**
@@ -1217,28 +1217,28 @@  discard block
 block discarded – undo
1217 1217
  */
1218 1218
 function geodir_custom_update_messages($messages)
1219 1219
 {
1220
-    global $post, $post_ID;
1221
-
1222
-    $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1223
-
1224
-    foreach ($post_types as $post_type => $post_object) {
1225
-
1226
-        $messages[$post_type] = array(
1227
-            0 => '', // Unused. Messages start at index 1.
1228
-            1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1229
-            2 => __('Custom field updated.', 'geodirectory'),
1230
-            3 => __('Custom field deleted.', 'geodirectory'),
1231
-            4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1232
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1233
-            6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1234
-            7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1235
-            8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1236
-            9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1237
-            10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1238
-        );
1239
-    }
1240
-
1241
-    return $messages;
1220
+	global $post, $post_ID;
1221
+
1222
+	$post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects');
1223
+
1224
+	foreach ($post_types as $post_type => $post_object) {
1225
+
1226
+		$messages[$post_type] = array(
1227
+			0 => '', // Unused. Messages start at index 1.
1228
+			1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1229
+			2 => __('Custom field updated.', 'geodirectory'),
1230
+			3 => __('Custom field deleted.', 'geodirectory'),
1231
+			4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name),
1232
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false,
1233
+			6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1234
+			7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name),
1235
+			8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1236
+			9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name),
1237
+			10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name),
1238
+		);
1239
+	}
1240
+
1241
+	return $messages;
1242 1242
 }
1243 1243
 
1244 1244
 
@@ -1253,182 +1253,182 @@  discard block
 block discarded – undo
1253 1253
 function geodir_register_defaults()
1254 1254
 {
1255 1255
 
1256
-    global $wpdb;
1257
-
1258
-    $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259
-
1260
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
-        $listing_slug = 'places';
1262
-
1263
-    /**
1264
-     * Taxonomies
1265
-     **/
1266
-    //if ( ! taxonomy_exists('gd_place_tags') )
1267
-    {
1268
-
1269
-        $gd_placetags = array();
1270
-        $gd_placetags['object_type'] = 'gd_place';
1271
-        $gd_placetags['listing_slug'] = $listing_slug . '/tags';
1272
-        $gd_placetags['args'] = array(
1273
-            'public' => true,
1274
-            'hierarchical' => false,
1275
-            'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1276
-            'query_var' => true,
1277
-
1278
-            'labels' => array(
1279
-                'name' => __('Place Tags', 'geodirectory'),
1280
-                'singular_name' => __('Place Tag', 'geodirectory'),
1281
-                'search_items' => __('Search Place Tags', 'geodirectory'),
1282
-                'popular_items' => __('Popular Place Tags', 'geodirectory'),
1283
-                'all_items' => __('All Place Tags', 'geodirectory'),
1284
-                'edit_item' => __('Edit Place Tag', 'geodirectory'),
1285
-                'update_item' => __('Update Place Tag', 'geodirectory'),
1286
-                'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1287
-                'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1288
-                'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1289
-                'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1290
-                'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1291
-            ),
1292
-        );
1293
-
1294
-
1295
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1296
-        $geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1297
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1298
-
1299
-
1300
-        // Update post types and delete tmp options
1301
-        flush_rewrite_rules();
1302
-
1303
-    }
1304
-
1305
-    //if ( ! taxonomy_exists('gd_placecategory') )
1306
-    {
1307
-
1308
-        $gd_placecategory = array();
1309
-        $gd_placecategory['object_type'] = 'gd_place';
1310
-        $gd_placecategory['listing_slug'] = $listing_slug;
1311
-        $gd_placecategory['args'] = array(
1312
-            'public' => true,
1313
-            'hierarchical' => true,
1314
-            'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1315
-            'query_var' => true,
1316
-            'labels' => array(
1317
-                'name' => __('Place Categories', 'geodirectory'),
1318
-                'singular_name' => __('Place Category', 'geodirectory'),
1319
-                'search_items' => __('Search Place Categories', 'geodirectory'),
1320
-                'popular_items' => __('Popular Place Categories', 'geodirectory'),
1321
-                'all_items' => __('All Place Categories', 'geodirectory'),
1322
-                'edit_item' => __('Edit Place Category', 'geodirectory'),
1323
-                'update_item' => __('Update Place Category', 'geodirectory'),
1324
-                'add_new_item' => __('Add New Place Category', 'geodirectory'),
1325
-                'new_item_name' => __('New Place Category', 'geodirectory'),
1326
-                'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1327
-            ),
1328
-        );
1329
-
1330
-
1331
-        $geodir_taxonomies = get_option('geodir_taxonomies');
1332
-        $geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1333
-        update_option('geodir_taxonomies', $geodir_taxonomies);
1334
-
1335
-
1336
-        flush_rewrite_rules();
1337
-    }
1338
-
1339
-    /**
1340
-     * Post Types
1341
-     **/
1342
-
1343
-    //if ( ! post_type_exists('gd_place') )
1344
-    {
1345
-
1346
-        $labels = array(
1347
-            'name' => __('Places', 'geodirectory'),
1348
-            'singular_name' => __('Place', 'geodirectory'),
1349
-            'add_new' => __('Add New', 'geodirectory'),
1350
-            'add_new_item' => __('Add New Place', 'geodirectory'),
1351
-            'edit_item' => __('Edit Place', 'geodirectory'),
1352
-            'new_item' => __('New Place', 'geodirectory'),
1353
-            'view_item' => __('View Place', 'geodirectory'),
1354
-            'search_items' => __('Search Places', 'geodirectory'),
1355
-            'not_found' => __('No Place Found', 'geodirectory'),
1356
-            'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1357
-
1358
-        $place_default = array(
1359
-            'labels' => $labels,
1360
-            'can_export' => true,
1361
-            'capability_type' => 'post',
1362
-            'description' => 'Place post type.',
1363
-            'has_archive' => $listing_slug,
1364
-            'hierarchical' => false,
1365
-            'map_meta_cap' => true,
1366
-            'menu_icon' => $menu_icon,
1367
-            'public' => true,
1368
-            'query_var' => true,
1369
-            'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1370
-            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1371
-            'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1372
-
1373
-        //Update custom post types
1374
-        $geodir_post_types = get_option('geodir_post_types');
1375
-        $geodir_post_types['gd_place'] = $place_default;
1376
-        update_option('geodir_post_types', $geodir_post_types);
1377
-
1378
-        // Update post types and delete tmp options
1379
-        flush_rewrite_rules();
1380
-    }
1381
-
1382
-
1383
-    geodir_register_taxonomies();
1384
-    geodir_register_post_types();
1385
-
1386
-    //die;
1256
+	global $wpdb;
1257
+
1258
+	$menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259
+
1260
+	if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
+		$listing_slug = 'places';
1262
+
1263
+	/**
1264
+	 * Taxonomies
1265
+	 **/
1266
+	//if ( ! taxonomy_exists('gd_place_tags') )
1267
+	{
1268
+
1269
+		$gd_placetags = array();
1270
+		$gd_placetags['object_type'] = 'gd_place';
1271
+		$gd_placetags['listing_slug'] = $listing_slug . '/tags';
1272
+		$gd_placetags['args'] = array(
1273
+			'public' => true,
1274
+			'hierarchical' => false,
1275
+			'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true),
1276
+			'query_var' => true,
1277
+
1278
+			'labels' => array(
1279
+				'name' => __('Place Tags', 'geodirectory'),
1280
+				'singular_name' => __('Place Tag', 'geodirectory'),
1281
+				'search_items' => __('Search Place Tags', 'geodirectory'),
1282
+				'popular_items' => __('Popular Place Tags', 'geodirectory'),
1283
+				'all_items' => __('All Place Tags', 'geodirectory'),
1284
+				'edit_item' => __('Edit Place Tag', 'geodirectory'),
1285
+				'update_item' => __('Update Place Tag', 'geodirectory'),
1286
+				'add_new_item' => __('Add New Place Tag', 'geodirectory'),
1287
+				'new_item_name' => __('New Place Tag Name', 'geodirectory'),
1288
+				'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'),
1289
+				'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'),
1290
+				'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'),
1291
+			),
1292
+		);
1293
+
1294
+
1295
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1296
+		$geodir_taxonomies['gd_place_tags'] = $gd_placetags;
1297
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1298
+
1299
+
1300
+		// Update post types and delete tmp options
1301
+		flush_rewrite_rules();
1302
+
1303
+	}
1304
+
1305
+	//if ( ! taxonomy_exists('gd_placecategory') )
1306
+	{
1307
+
1308
+		$gd_placecategory = array();
1309
+		$gd_placecategory['object_type'] = 'gd_place';
1310
+		$gd_placecategory['listing_slug'] = $listing_slug;
1311
+		$gd_placecategory['args'] = array(
1312
+			'public' => true,
1313
+			'hierarchical' => true,
1314
+			'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true),
1315
+			'query_var' => true,
1316
+			'labels' => array(
1317
+				'name' => __('Place Categories', 'geodirectory'),
1318
+				'singular_name' => __('Place Category', 'geodirectory'),
1319
+				'search_items' => __('Search Place Categories', 'geodirectory'),
1320
+				'popular_items' => __('Popular Place Categories', 'geodirectory'),
1321
+				'all_items' => __('All Place Categories', 'geodirectory'),
1322
+				'edit_item' => __('Edit Place Category', 'geodirectory'),
1323
+				'update_item' => __('Update Place Category', 'geodirectory'),
1324
+				'add_new_item' => __('Add New Place Category', 'geodirectory'),
1325
+				'new_item_name' => __('New Place Category', 'geodirectory'),
1326
+				'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'),
1327
+			),
1328
+		);
1329
+
1330
+
1331
+		$geodir_taxonomies = get_option('geodir_taxonomies');
1332
+		$geodir_taxonomies['gd_placecategory'] = $gd_placecategory;
1333
+		update_option('geodir_taxonomies', $geodir_taxonomies);
1334
+
1335
+
1336
+		flush_rewrite_rules();
1337
+	}
1338
+
1339
+	/**
1340
+	 * Post Types
1341
+	 **/
1342
+
1343
+	//if ( ! post_type_exists('gd_place') )
1344
+	{
1345
+
1346
+		$labels = array(
1347
+			'name' => __('Places', 'geodirectory'),
1348
+			'singular_name' => __('Place', 'geodirectory'),
1349
+			'add_new' => __('Add New', 'geodirectory'),
1350
+			'add_new_item' => __('Add New Place', 'geodirectory'),
1351
+			'edit_item' => __('Edit Place', 'geodirectory'),
1352
+			'new_item' => __('New Place', 'geodirectory'),
1353
+			'view_item' => __('View Place', 'geodirectory'),
1354
+			'search_items' => __('Search Places', 'geodirectory'),
1355
+			'not_found' => __('No Place Found', 'geodirectory'),
1356
+			'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory'));
1357
+
1358
+		$place_default = array(
1359
+			'labels' => $labels,
1360
+			'can_export' => true,
1361
+			'capability_type' => 'post',
1362
+			'description' => 'Place post type.',
1363
+			'has_archive' => $listing_slug,
1364
+			'hierarchical' => false,
1365
+			'map_meta_cap' => true,
1366
+			'menu_icon' => $menu_icon,
1367
+			'public' => true,
1368
+			'query_var' => true,
1369
+			'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true),
1370
+			'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/),
1371
+			'taxonomies' => array('gd_placecategory', 'gd_place_tags'));
1372
+
1373
+		//Update custom post types
1374
+		$geodir_post_types = get_option('geodir_post_types');
1375
+		$geodir_post_types['gd_place'] = $place_default;
1376
+		update_option('geodir_post_types', $geodir_post_types);
1377
+
1378
+		// Update post types and delete tmp options
1379
+		flush_rewrite_rules();
1380
+	}
1381
+
1382
+
1383
+	geodir_register_taxonomies();
1384
+	geodir_register_post_types();
1385
+
1386
+	//die;
1387 1387
 
1388 1388
 }
1389 1389
 
1390 1390
 $gd_wpml_get_languages = "";
1391 1391
 function gd_wpml_get_lang_from_url($url) {
1392
-    global $sitepress, $gd_wpml_get_languages;
1392
+	global $sitepress, $gd_wpml_get_languages;
1393 1393
     
1394
-    if (geodir_is_wpml()) {
1395
-        return $sitepress->get_language_from_url($url);
1396
-    }
1394
+	if (geodir_is_wpml()) {
1395
+		return $sitepress->get_language_from_url($url);
1396
+	}
1397 1397
     
1398
-    if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1399
-        return $_REQUEST['lang'];
1400
-    }
1398
+	if (isset($_REQUEST['lang']) && $_REQUEST['lang']) {
1399
+		return $_REQUEST['lang'];
1400
+	}
1401 1401
 
1402
-    $url = str_replace(array("http://","https://"),"",$url);
1402
+	$url = str_replace(array("http://","https://"),"",$url);
1403 1403
 
1404
-    // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1405
-    $site_url = str_replace(array("http://","https://"),"",site_url());
1404
+	// site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang.
1405
+	$site_url = str_replace(array("http://","https://"),"",site_url());
1406 1406
 
1407
-    $url = str_replace($site_url,"",$url);
1407
+	$url = str_replace($site_url,"",$url);
1408 1408
 
1409
-    $segments = explode('/', trim($url, '/'));
1409
+	$segments = explode('/', trim($url, '/'));
1410 1410
 
1411
-    if ($gd_wpml_get_languages) {
1412
-        $langs = $gd_wpml_get_languages;
1413
-    } else {
1414
-        $gd_wpml_get_languages = $sitepress->get_active_languages();
1415
-    }
1411
+	if ($gd_wpml_get_languages) {
1412
+		$langs = $gd_wpml_get_languages;
1413
+	} else {
1414
+		$gd_wpml_get_languages = $sitepress->get_active_languages();
1415
+	}
1416 1416
 
1417
-    if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1418
-        return $segments[0];
1419
-    }
1417
+	if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) {
1418
+		return $segments[0];
1419
+	}
1420 1420
 
1421
-    return false;
1421
+	return false;
1422 1422
 }
1423 1423
 
1424 1424
 function gd_wpml_slug_translation_turned_on($post_type) {
1425 1425
 
1426
-    global $sitepress;
1427
-    $settings = $sitepress->get_settings();
1428
-    return isset($settings['posts_slug_translation']['types'][$post_type])
1429
-    && $settings['posts_slug_translation']['types'][$post_type]
1430
-    && isset($settings['posts_slug_translation']['on'])
1431
-    && $settings['posts_slug_translation']['on'];
1426
+	global $sitepress;
1427
+	$settings = $sitepress->get_settings();
1428
+	return isset($settings['posts_slug_translation']['types'][$post_type])
1429
+	&& $settings['posts_slug_translation']['types'][$post_type]
1430
+	&& isset($settings['posts_slug_translation']['on'])
1431
+	&& $settings['posts_slug_translation']['on'];
1432 1432
 }
1433 1433
 
1434 1434
 
@@ -1455,158 +1455,158 @@  discard block
 block discarded – undo
1455 1455
  */
1456 1456
 function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample)
1457 1457
 {
1458
-    //echo $post_link."<br />".$sample ;
1458
+	//echo $post_link."<br />".$sample ;
1459 1459
 
1460 1460
 
1461
-    global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1462
-    if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1463
-    } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1464
-        return $post_link;
1465
-    } else {
1466
-        $orig_post = $post;
1467
-        $post = $post_obj;
1468
-    }
1461
+	global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache;
1462
+	if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) {
1463
+	} elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') {
1464
+		return $post_link;
1465
+	} else {
1466
+		$orig_post = $post;
1467
+		$post = $post_obj;
1468
+	}
1469 1469
 
1470
-    if (in_array($post->post_type, geodir_get_posttypes())) {
1470
+	if (in_array($post->post_type, geodir_get_posttypes())) {
1471 1471
 
1472
-        // if we dont have a GD post then try to grab it
1473
-        if(!isset($post->default_category)){
1474
-            $gd_post = geodir_get_post_info($post->ID);
1475
-            if(!empty($gd_post)){
1476
-                $post = $gd_post;
1477
-            }
1478
-        }
1472
+		// if we dont have a GD post then try to grab it
1473
+		if(!isset($post->default_category)){
1474
+			$gd_post = geodir_get_post_info($post->ID);
1475
+			if(!empty($gd_post)){
1476
+				$post = $gd_post;
1477
+			}
1478
+		}
1479 1479
 
1480 1480
 
1481
-        $post_types = get_option('geodir_post_types');
1482
-        $slug = $post_types[$post->post_type]['rewrite']['slug'];
1481
+		$post_types = get_option('geodir_post_types');
1482
+		$slug = $post_types[$post->post_type]['rewrite']['slug'];
1483 1483
 
1484
-        // Alter the CPT slug if WPML is set to do so
1485
-        if(function_exists('icl_object_id')){
1486
-            if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1484
+		// Alter the CPT slug if WPML is set to do so
1485
+		if(function_exists('icl_object_id')){
1486
+			if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) {
1487 1487
 
1488
-                $org_slug = $slug;
1489
-                $slug = apply_filters( 'wpml_translate_single_string',
1490
-                    $slug,
1491
-                    'WordPress',
1492
-                    'URL slug: ' . $slug,
1493
-                    $language_code);
1488
+				$org_slug = $slug;
1489
+				$slug = apply_filters( 'wpml_translate_single_string',
1490
+					$slug,
1491
+					'WordPress',
1492
+					'URL slug: ' . $slug,
1493
+					$language_code);
1494 1494
 
1495
-                if(!$slug){$slug = $org_slug;}
1495
+				if(!$slug){$slug = $org_slug;}
1496 1496
 
1497
-            }
1498
-        }
1497
+			}
1498
+		}
1499 1499
 
1500
-        if (function_exists('geodir_location_geo_home_link')) {
1501
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1502
-        }
1500
+		if (function_exists('geodir_location_geo_home_link')) {
1501
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
1502
+		}
1503 1503
         
1504
-        // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1505
-        $site_url = trailingslashit(get_bloginfo('url'));
1504
+		// Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz.
1505
+		$site_url = trailingslashit(get_bloginfo('url'));
1506 1506
         
1507
-        if (function_exists('geodir_location_geo_home_link')) {
1508
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1509
-        }
1510
-
1511
-        $fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1512
-        if ($fix_url) {
1513
-            $post_link = str_replace($site_url, '', $post_link);
1514
-        }
1515
-
1516
-        $post_link = trailingslashit(
1517
-            preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1518
-        );
1519
-
1520
-        if ($fix_url) {
1521
-            $post_link = $site_url . $post_link;
1522
-        }
1523
-
1524
-        if (isset($comment_post_cache[$post->ID])) {
1525
-            $post = $comment_post_cache[$post->ID];
1526
-        }
1527
-        if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1528
-            $post_id = $post->ID;
1529
-            if (isset($orig_post)) {
1530
-                $post = $orig_post;
1531
-            }
1532
-            return $gd_permalink_cache[$post_id];
1533
-        }
1507
+		if (function_exists('geodir_location_geo_home_link')) {
1508
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
1509
+		}
1534 1510
 
1535
-        if (!isset($post->post_locations)) {
1536
-            $post_type = $post->post_type;
1537
-            $ID = $post->ID;
1538
-            $post2 = $wpdb->get_row(
1539
-                $wpdb->prepare(
1540
-                    "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1541
-                    array($post->ID)
1542
-                )
1543
-            );
1511
+		$fix_url = strpos($post_link, $site_url) === 0 ? true : false;
1512
+		if ($fix_url) {
1513
+			$post_link = str_replace($site_url, '', $post_link);
1514
+		}
1544 1515
 
1545
-            $post = (object)array_merge((array)$post, (array)$post2);
1516
+		$post_link = trailingslashit(
1517
+			preg_replace(  "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 )
1518
+		);
1546 1519
 
1547
-            $comment_post_cache[$post->ID] = $post;
1548
-        }
1520
+		if ($fix_url) {
1521
+			$post_link = $site_url . $post_link;
1522
+		}
1549 1523
 
1524
+		if (isset($comment_post_cache[$post->ID])) {
1525
+			$post = $comment_post_cache[$post->ID];
1526
+		}
1527
+		if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) {
1528
+			$post_id = $post->ID;
1529
+			if (isset($orig_post)) {
1530
+				$post = $orig_post;
1531
+			}
1532
+			return $gd_permalink_cache[$post_id];
1533
+		}
1550 1534
 
1535
+		if (!isset($post->post_locations)) {
1536
+			$post_type = $post->post_type;
1537
+			$ID = $post->ID;
1538
+			$post2 = $wpdb->get_row(
1539
+				$wpdb->prepare(
1540
+					"SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1541
+					array($post->ID)
1542
+				)
1543
+			);
1551 1544
 
1552
-        if (false !== strpos($post_link, '%gd_taxonomy%')) {
1545
+			$post = (object)array_merge((array)$post, (array)$post2);
1553 1546
 
1554
-            if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1555
-                $location_request = '';
1547
+			$comment_post_cache[$post->ID] = $post;
1548
+		}
1556 1549
 
1557 1550
 
1558
-                if (!empty($post->post_locations)) {
1559
-                    $geodir_arr_locations = explode(',', $post->post_locations);
1560
-                    if (count($geodir_arr_locations) == 3) {
1561
-                        $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1562
-                        $post->city_slug = str_replace(']', '', $post->city_slug);
1563
-                        $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1564
-                        $post->region_slug = str_replace(']', '', $post->region_slug);
1565
-                        $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566
-                        $post->country_slug = str_replace(']', '', $post->country_slug);
1567 1551
 
1568
-                        $post_location = (object)array('country_slug' => $post->country_slug,
1569
-                            'region_slug' => $post->region_slug,
1570
-                            'city_slug' => $post->city_slug
1571
-                        );
1552
+		if (false !== strpos($post_link, '%gd_taxonomy%')) {
1572 1553
 
1573
-                    } else
1574
-                        $post_location = geodir_get_location();
1554
+			if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) {
1555
+				$location_request = '';
1575 1556
 
1576 1557
 
1577
-                } else {
1558
+				if (!empty($post->post_locations)) {
1559
+					$geodir_arr_locations = explode(',', $post->post_locations);
1560
+					if (count($geodir_arr_locations) == 3) {
1561
+						$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1562
+						$post->city_slug = str_replace(']', '', $post->city_slug);
1563
+						$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1564
+						$post->region_slug = str_replace(']', '', $post->region_slug);
1565
+						$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1566
+						$post->country_slug = str_replace(']', '', $post->country_slug);
1578 1567
 
1579
-                    $post_location_sql = $wpdb->get_results(
1580
-                        $wpdb->prepare(
1581
-                            "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1582
-                            array($post->ID)
1583
-                        )
1584
-                    );
1585
-
1586
-                    if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1587
-
1588
-                        $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1589
-                        if (count($geodir_arr_locations) == 3) {
1590
-                            $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1591
-                            $post->city_slug = str_replace(']', '', $post->city_slug);
1592
-                            $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1593
-                            $post->region_slug = str_replace(']', '', $post->region_slug);
1594
-                            $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595
-                            $post->country_slug = str_replace(']', '', $post->country_slug);
1596
-
1597
-                            $post_location = (object)array('country_slug' => $post->country_slug,
1598
-                                'region_slug' => $post->region_slug,
1599
-                                'city_slug' => $post->city_slug
1600
-                            );
1568
+						$post_location = (object)array('country_slug' => $post->country_slug,
1569
+							'region_slug' => $post->region_slug,
1570
+							'city_slug' => $post->city_slug
1571
+						);
1572
+
1573
+					} else
1574
+						$post_location = geodir_get_location();
1601 1575
 
1602
-                        }
1603
-                    } else
1604
-                        $post_location = geodir_get_location();
1605
-                }
1606 1576
 
1577
+				} else {
1607 1578
 
1608
-                if (!empty($post_location)) {
1609
-                    $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1579
+					$post_location_sql = $wpdb->get_results(
1580
+						$wpdb->prepare(
1581
+							"SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ",
1582
+							array($post->ID)
1583
+						)
1584
+					);
1585
+
1586
+					if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) {
1587
+
1588
+						$geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations);
1589
+						if (count($geodir_arr_locations) == 3) {
1590
+							$post->city_slug = str_replace('[', '', $geodir_arr_locations[0]);
1591
+							$post->city_slug = str_replace(']', '', $post->city_slug);
1592
+							$post->region_slug = str_replace('[', '', $geodir_arr_locations[1]);
1593
+							$post->region_slug = str_replace(']', '', $post->region_slug);
1594
+							$post->country_slug = str_replace('[', '', $geodir_arr_locations[2]);
1595
+							$post->country_slug = str_replace(']', '', $post->country_slug);
1596
+
1597
+							$post_location = (object)array('country_slug' => $post->country_slug,
1598
+								'region_slug' => $post->region_slug,
1599
+								'city_slug' => $post->city_slug
1600
+							);
1601
+
1602
+						}
1603
+					} else
1604
+						$post_location = geodir_get_location();
1605
+				}
1606
+
1607
+
1608
+				if (!empty($post_location)) {
1609
+					$country_slug = isset($post_location->country_slug) ? $post_location->country_slug : '';
1610 1610
 					$region_slug = isset($post_location->region_slug) ? $post_location->region_slug : '';
1611 1611
 					$city_slug = isset($post_location->city_slug) ? $post_location->city_slug : '';
1612 1612
 					
@@ -1624,89 +1624,89 @@  discard block
 block discarded – undo
1624 1624
 					$location_slug[] = $city_slug;
1625 1625
 					
1626 1626
 					$location_request .= implode('/', $location_slug) . '/';
1627
-                }
1628
-            }
1627
+				}
1628
+			}
1629 1629
 
1630
-            if (get_option('geodir_add_categories_url')) {
1630
+			if (get_option('geodir_add_categories_url')) {
1631 1631
 
1632
-                $term_request = '';
1633
-                $taxonomies = geodir_get_taxonomies($post->post_type);
1632
+				$term_request = '';
1633
+				$taxonomies = geodir_get_taxonomies($post->post_type);
1634 1634
 
1635
-                $taxonomies = end($taxonomies);
1635
+				$taxonomies = end($taxonomies);
1636 1636
 
1637
-                if (!empty($post->default_category)) {
1638
-                    $post_terms = $post->default_category;
1639
-                } else {
1640
-                    $post_terms = '';
1641
-
1642
-                    if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643
-                        $post_terms = absint($_POST['post_default_category']);
1644
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1645
-                        $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646
-                        $post_terms = absint($post_terms[0]);
1647
-                    }elseif (isset($post->{$taxonomies})) {
1648
-                        $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649
-                        $post_terms = $post_terms[0];
1650
-                    }
1637
+				if (!empty($post->default_category)) {
1638
+					$post_terms = $post->default_category;
1639
+				} else {
1640
+					$post_terms = '';
1641
+
1642
+					if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643
+						$post_terms = absint($_POST['post_default_category']);
1644
+					}elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1645
+						$post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646
+						$post_terms = absint($post_terms[0]);
1647
+					}elseif (isset($post->{$taxonomies})) {
1648
+						$post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649
+						$post_terms = $post_terms[0];
1650
+					}
1651 1651
 
1652
-                    if (!$post_terms)
1653
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1652
+					if (!$post_terms)
1653
+						$post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1654 1654
 
1655
-                    if (!$post_terms) {
1656
-                        $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1655
+					if (!$post_terms) {
1656
+						$post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
1657 1657
 
1658
-                        if ($post_terms) {
1659
-                            $post_terms = explode(",", trim($post_terms, ","));
1660
-                            $post_terms = $post_terms[0];
1661
-                        }
1662
-                    }
1663
-                }
1658
+						if ($post_terms) {
1659
+							$post_terms = explode(",", trim($post_terms, ","));
1660
+							$post_terms = $post_terms[0];
1661
+						}
1662
+					}
1663
+				}
1664 1664
 
1665
-                $term = get_term_by('id', $post_terms, $taxonomies);
1665
+				$term = get_term_by('id', $post_terms, $taxonomies);
1666 1666
 
1667
-                if (!empty($term))
1668
-                    $term_request = $term->slug;
1669
-                //$term_request = $term->slug.'/';
1670
-            }
1667
+				if (!empty($term))
1668
+					$term_request = $term->slug;
1669
+				//$term_request = $term->slug.'/';
1670
+			}
1671 1671
 
1672
-            $request_term = '';
1673
-            $listingurl_separator = '';
1674
-            //$detailurl_separator = get_option('geodir_detailurl_separator');
1675
-            $detailurl_separator = '';
1676
-            if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1677
-                $request_term = $location_request;
1678
-                //$listingurl_separator = get_option('geodir_listingurl_separator');
1679
-                //$request_term .= $listingurl_separator.'/'.$term_request;
1680
-                $request_term .= $term_request;
1672
+			$request_term = '';
1673
+			$listingurl_separator = '';
1674
+			//$detailurl_separator = get_option('geodir_detailurl_separator');
1675
+			$detailurl_separator = '';
1676
+			if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') {
1677
+				$request_term = $location_request;
1678
+				//$listingurl_separator = get_option('geodir_listingurl_separator');
1679
+				//$request_term .= $listingurl_separator.'/'.$term_request;
1680
+				$request_term .= $term_request;
1681 1681
 
1682
-            } else {
1683
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1682
+			} else {
1683
+				if (isset($location_request) && $location_request != '') $request_term = $location_request;
1684 1684
 
1685
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1686
-            }
1687
-            $request_term = trim($request_term, '/');
1685
+				if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1686
+			}
1687
+			$request_term = trim($request_term, '/');
1688 1688
             
1689
-            // Fix with WPML the location terms added twice when CPT slug is translated.
1690
-            if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1691
-                $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692
-            }
1689
+			// Fix with WPML the location terms added twice when CPT slug is translated.
1690
+			if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) {
1691
+				$post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692
+			}
1693 1693
             
1694
-            if (!empty($request_term))
1695
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
-            else
1697
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1698
-            //echo $post_link ;
1699
-        }
1700
-        // temp cache the permalink
1701
-        if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1702
-            $gd_permalink_cache[$post->ID] = $post_link;
1703
-        }
1704
-    }
1705
-    if (isset($orig_post)) {
1706
-        $post = $orig_post;
1707
-    }
1708
-
1709
-    return $post_link;
1694
+			if (!empty($request_term))
1695
+				$post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
+			else
1697
+				$post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1698
+			//echo $post_link ;
1699
+		}
1700
+		// temp cache the permalink
1701
+		if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) {
1702
+			$gd_permalink_cache[$post->ID] = $post_link;
1703
+		}
1704
+	}
1705
+	if (isset($orig_post)) {
1706
+		$post = $orig_post;
1707
+	}
1708
+
1709
+	return $post_link;
1710 1710
 }
1711 1711
 
1712 1712
 /**
@@ -1722,99 +1722,99 @@  discard block
 block discarded – undo
1722 1722
  * @return string The term link.
1723 1723
  */
1724 1724
 function geodir_term_link($termlink, $term, $taxonomy) {
1725
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
1725
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
1726 1726
 
1727
-    if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1728
-        global $geodir_add_location_url, $gd_session;
1729
-        $include_location = false;
1730
-        $request_term = array();
1731
-        $add_location_url = get_option('geodir_add_location_url');
1732
-        $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1727
+	if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) {
1728
+		global $geodir_add_location_url, $gd_session;
1729
+		$include_location = false;
1730
+		$request_term = array();
1731
+		$add_location_url = get_option('geodir_add_location_url');
1732
+		$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
1733 1733
 
1734
-        $listing_slug = geodir_get_listing_slug($taxonomy);
1734
+		$listing_slug = geodir_get_listing_slug($taxonomy);
1735 1735
 
1736
-        if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1737
-            if ($geodir_add_location_url && $add_location_url) {
1738
-                $include_location = true;
1739
-            }
1740
-        } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1741
-            $include_location = true;
1742
-        } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1743
-            $include_location = true;
1744
-        }
1745
-
1746
-        if ($include_location) {
1747
-            global $post;
1736
+		if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') {
1737
+			if ($geodir_add_location_url && $add_location_url) {
1738
+				$include_location = true;
1739
+			}
1740
+		} elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) {
1741
+			$include_location = true;
1742
+		} elseif ($add_location_url && $location_manager && geodir_is_page('detail')) {
1743
+			$include_location = true;
1744
+		}
1745
+
1746
+		if ($include_location) {
1747
+			global $post;
1748 1748
             
1749
-            $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1749
+			$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
1750 1750
             
1751
-            if (geodir_is_page('detail') && isset($post->country_slug)) {
1752
-                $location_terms = array(
1753
-                    'gd_country' => $post->country_slug,
1754
-                    'gd_region' => $post->region_slug,
1755
-                    'gd_city' => $post->city_slug
1756
-                );
1751
+			if (geodir_is_page('detail') && isset($post->country_slug)) {
1752
+				$location_terms = array(
1753
+					'gd_country' => $post->country_slug,
1754
+					'gd_region' => $post->region_slug,
1755
+					'gd_city' => $post->city_slug
1756
+				);
1757 1757
                 
1758
-                if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1759
-                    $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1760
-                }
1761
-            } else {
1762
-                $location_terms = geodir_get_current_location_terms('query_vars');
1763
-            }
1758
+				if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
1759
+					$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
1760
+				}
1761
+			} else {
1762
+				$location_terms = geodir_get_current_location_terms('query_vars');
1763
+			}
1764 1764
 
1765
-            $geodir_show_location_url = get_option('geodir_show_location_url');
1766
-            $location_terms = geodir_remove_location_terms($location_terms);
1765
+			$geodir_show_location_url = get_option('geodir_show_location_url');
1766
+			$location_terms = geodir_remove_location_terms($location_terms);
1767 1767
 
1768
-            if (!empty($location_terms)) {
1769
-                $url_separator = '';
1768
+			if (!empty($location_terms)) {
1769
+				$url_separator = '';
1770 1770
 
1771
-                if (get_option('permalink_structure') != '') {
1772
-                    $old_listing_slug = '/' . $listing_slug . '/';
1773
-                    $request_term = implode("/", $location_terms);
1774
-                    $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1771
+				if (get_option('permalink_structure') != '') {
1772
+					$old_listing_slug = '/' . $listing_slug . '/';
1773
+					$request_term = implode("/", $location_terms);
1774
+					$new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/';
1775 1775
 
1776
-                    $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1777
-                } else {
1778
-                    $termlink = geodir_getlink($termlink, $request_term);
1779
-                }
1780
-            }
1781
-        }
1776
+					$termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug));
1777
+				} else {
1778
+					$termlink = geodir_getlink($termlink, $request_term);
1779
+				}
1780
+			}
1781
+		}
1782 1782
 
1783
-        // Alter the CPT slug is WPML is set to do so
1784
-        /* we can replace this with the below function
1783
+		// Alter the CPT slug is WPML is set to do so
1784
+		/* we can replace this with the below function
1785 1785
         if(function_exists('icl_object_id')){
1786 1786
             global $sitepress;
1787 1787
             $post_type = str_replace("category","",$taxonomy);
1788 1788
             $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type);
1789 1789
         }*/
1790 1790
 
1791
-        // Alter the CPT slug if WPML is set to do so
1792
-        if (function_exists('icl_object_id')) {
1793
-            $post_types = get_option('geodir_post_types');
1794
-            $post_type = str_replace("category","",$taxonomy);
1795
-            $post_type = str_replace("_tags","",$post_type);
1796
-            $slug = $post_types[$post_type]['rewrite']['slug'];
1797
-            if (gd_wpml_slug_translation_turned_on($post_type)) {
1798
-                global $sitepress;
1799
-                $default_lang = $sitepress->get_default_language();
1800
-                $language_code = gd_wpml_get_lang_from_url($termlink);
1801
-                if (!$language_code ) {
1802
-                    $language_code  = $default_lang;
1803
-                }
1791
+		// Alter the CPT slug if WPML is set to do so
1792
+		if (function_exists('icl_object_id')) {
1793
+			$post_types = get_option('geodir_post_types');
1794
+			$post_type = str_replace("category","",$taxonomy);
1795
+			$post_type = str_replace("_tags","",$post_type);
1796
+			$slug = $post_types[$post_type]['rewrite']['slug'];
1797
+			if (gd_wpml_slug_translation_turned_on($post_type)) {
1798
+				global $sitepress;
1799
+				$default_lang = $sitepress->get_default_language();
1800
+				$language_code = gd_wpml_get_lang_from_url($termlink);
1801
+				if (!$language_code ) {
1802
+					$language_code  = $default_lang;
1803
+				}
1804 1804
 
1805
-                $org_slug = $slug;
1806
-                $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1805
+				$org_slug = $slug;
1806
+				$slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code);
1807 1807
 
1808
-                if (!$slug) {
1809
-                    $slug = $org_slug;
1810
-                }
1808
+				if (!$slug) {
1809
+					$slug = $org_slug;
1810
+				}
1811 1811
 
1812
-                $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1813
-            }
1814
-        }
1815
-    }
1812
+				$termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug  ,$termlink, 1));
1813
+			}
1814
+		}
1815
+	}
1816 1816
     
1817
-    return $termlink;
1817
+	return $termlink;
1818 1818
 }
1819 1819
 
1820 1820
 /**
@@ -1840,14 +1840,14 @@  discard block
 block discarded – undo
1840 1840
 	if (in_array($post_type, geodir_get_posttypes())) {
1841 1841
 		if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) {
1842 1842
 			if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) {
1843
-                $location_terms = array(
1844
-                    'gd_country' => $post->country_slug,
1845
-                    'gd_region' => $post->region_slug,
1846
-                    'gd_city' => $post->city_slug
1847
-                );
1848
-            } else {
1849
-                $location_terms = geodir_get_current_location_terms('query_vars');
1850
-            }
1843
+				$location_terms = array(
1844
+					'gd_country' => $post->country_slug,
1845
+					'gd_region' => $post->region_slug,
1846
+					'gd_city' => $post->city_slug
1847
+				);
1848
+			} else {
1849
+				$location_terms = geodir_get_current_location_terms('query_vars');
1850
+			}
1851 1851
 			
1852 1852
 			$location_terms = geodir_remove_location_terms($location_terms);
1853 1853
 			
@@ -1879,17 +1879,17 @@  discard block
 block discarded – undo
1879 1879
  * @return void|string Label.
1880 1880
  */
1881 1881
 function get_post_type_singular_label($post_type, $echo = false, $translate = false) {
1882
-    $obj_post_type = get_post_type_object($post_type);
1883
-    if (!is_object($obj_post_type)) {
1884
-        return;
1885
-    }
1882
+	$obj_post_type = get_post_type_object($post_type);
1883
+	if (!is_object($obj_post_type)) {
1884
+		return;
1885
+	}
1886 1886
     
1887
-    $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1887
+	$label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1888 1888
     
1889
-    if ($echo)
1890
-        echo $label;
1891
-    else
1892
-        return $label;
1889
+	if ($echo)
1890
+		echo $label;
1891
+	else
1892
+		return $label;
1893 1893
 }
1894 1894
 
1895 1895
 /**
@@ -1904,19 +1904,19 @@  discard block
 block discarded – undo
1904 1904
  * @return void|string Label.
1905 1905
  */
1906 1906
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1907
-    $all_postypes = geodir_get_posttypes();
1907
+	$all_postypes = geodir_get_posttypes();
1908 1908
 
1909
-    if (!in_array($post_type, $all_postypes))
1910
-        return false;
1909
+	if (!in_array($post_type, $all_postypes))
1910
+		return false;
1911 1911
 
1912
-    $obj_post_type = get_post_type_object($post_type);
1912
+	$obj_post_type = get_post_type_object($post_type);
1913 1913
     
1914
-    $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1914
+	$label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1915 1915
     
1916
-    if ($echo)
1917
-        echo $label;
1918
-    else
1919
-        return $label;
1916
+	if ($echo)
1917
+		echo $label;
1918
+	else
1919
+		return $label;
1920 1920
 }
1921 1921
 
1922 1922
 /**
@@ -1934,51 +1934,51 @@  discard block
 block discarded – undo
1934 1934
  */
1935 1935
 function geodir_term_exists($term, $taxonomy = '', $parent = 0)
1936 1936
 {
1937
-    global $wpdb;
1938
-
1939
-    $select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1940
-    $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941
-
1942
-    if (is_int($term)) {
1943
-        if (0 == $term)
1944
-            return 0;
1945
-        $where = 't.term_id = %d';
1946
-        if (!empty($taxonomy))
1947
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
-        else
1949
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1950
-    }
1937
+	global $wpdb;
1938
+
1939
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
1940
+	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941
+
1942
+	if (is_int($term)) {
1943
+		if (0 == $term)
1944
+			return 0;
1945
+		$where = 't.term_id = %d';
1946
+		if (!empty($taxonomy))
1947
+			return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
+		else
1949
+			return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1950
+	}
1951 1951
 
1952
-    $term = trim(wp_unslash($term));
1952
+	$term = trim(wp_unslash($term));
1953 1953
 
1954
-    if ('' === $slug = sanitize_title($term))
1955
-        return 0;
1954
+	if ('' === $slug = sanitize_title($term))
1955
+		return 0;
1956 1956
 
1957
-    $where = 't.slug = %s';
1957
+	$where = 't.slug = %s';
1958 1958
 
1959
-    $where_fields = array($slug);
1960
-    if (!empty($taxonomy)) {
1961
-        $parent = (int)$parent;
1962
-        if ($parent > 0) {
1963
-            $where_fields[] = $parent;
1964
-            $else_where_fields[] = $parent;
1965
-            $where .= ' AND tt.parent = %d';
1959
+	$where_fields = array($slug);
1960
+	if (!empty($taxonomy)) {
1961
+		$parent = (int)$parent;
1962
+		if ($parent > 0) {
1963
+			$where_fields[] = $parent;
1964
+			$else_where_fields[] = $parent;
1965
+			$where .= ' AND tt.parent = %d';
1966 1966
 
1967
-        }
1967
+		}
1968 1968
 
1969
-        $where_fields[] = $taxonomy;
1969
+		$where_fields[] = $taxonomy;
1970 1970
 
1971 1971
 
1972
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
-            return $result;
1972
+		if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
+			return $result;
1974 1974
 
1975
-        return false;
1976
-    }
1975
+		return false;
1976
+	}
1977 1977
 
1978
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
-        return $result;
1978
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
+		return $result;
1980 1980
 
1981
-    return false;
1981
+	return false;
1982 1982
 }
1983 1983
 
1984 1984
 /**
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
 function geodir_get_term_icon_rebuild()
1991 1991
 {
1992 1992
 
1993
-    update_option('gd_term_icons', '');
1993
+	update_option('gd_term_icons', '');
1994 1994
 
1995 1995
 }
1996 1996
 
@@ -2008,61 +2008,61 @@  discard block
 block discarded – undo
2008 2008
  */
2009 2009
 function geodir_get_term_icon($term_id = false, $rebuild = false)
2010 2010
 {
2011
-    global $wpdb;
2012
-    if (!$rebuild) {
2013
-        $terms_icons = get_option('gd_term_icons');
2014
-    } else {
2015
-        $terms_icons = array();
2016
-    }
2017
-
2018
-    if (empty($terms_icons)) {
2019
-        $terms_icons = array();
2020
-        $default_icon_url = get_option('geodir_default_marker_icon');
2021
-        $taxonomy = geodir_get_taxonomies();
2022
-        $post_types = geodir_get_posttypes();
2023
-        $tax_arr = array();
2024
-        foreach ($post_types as $post_type) {
2025
-            $tax_arr[] = "'" . $post_type . "category'";
2026
-        }
2027
-        $tax_c = implode(',', $tax_arr);
2028
-        $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2029
-        //$terms = get_terms( $taxonomy );
2030
-
2031
-        if($terms) {
2032
-            foreach ($terms as $term) {
2033
-                $post_type = str_replace("category", "", $term->taxonomy);
2034
-                $a_terms[$post_type][] = $term;
2011
+	global $wpdb;
2012
+	if (!$rebuild) {
2013
+		$terms_icons = get_option('gd_term_icons');
2014
+	} else {
2015
+		$terms_icons = array();
2016
+	}
2035 2017
 
2036
-            }
2037
-        }
2018
+	if (empty($terms_icons)) {
2019
+		$terms_icons = array();
2020
+		$default_icon_url = get_option('geodir_default_marker_icon');
2021
+		$taxonomy = geodir_get_taxonomies();
2022
+		$post_types = geodir_get_posttypes();
2023
+		$tax_arr = array();
2024
+		foreach ($post_types as $post_type) {
2025
+			$tax_arr[] = "'" . $post_type . "category'";
2026
+		}
2027
+		$tax_c = implode(',', $tax_arr);
2028
+		$terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)");
2029
+		//$terms = get_terms( $taxonomy );
2038 2030
 
2039
-        if($a_terms) {
2040
-            foreach ($a_terms as $pt => $t2) {
2031
+		if($terms) {
2032
+			foreach ($terms as $term) {
2033
+				$post_type = str_replace("category", "", $term->taxonomy);
2034
+				$a_terms[$post_type][] = $term;
2041 2035
 
2042
-                foreach ($t2 as $term) {
2043
-                    $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2044
-                    if ($term_icon) {
2045
-                        $term_icon_url = $term_icon["src"];
2046
-                    } else {
2047
-                        $term_icon_url = $default_icon_url;
2048
-                    }
2049
-                    $terms_icons[$term->term_id] = $term_icon_url;
2050
-                }
2051
-            }
2052
-        }
2036
+			}
2037
+		}
2053 2038
 
2054
-        update_option('gd_term_icons', $terms_icons);
2055
-    }
2039
+		if($a_terms) {
2040
+			foreach ($a_terms as $pt => $t2) {
2056 2041
 
2057
-    if ($term_id && isset($terms_icons[$term_id])) {
2058
-        return $terms_icons[$term_id];
2059
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2060
-        return get_option('geodir_default_marker_icon');
2061
-    }
2042
+				foreach ($t2 as $term) {
2043
+					$term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2044
+					if ($term_icon) {
2045
+						$term_icon_url = $term_icon["src"];
2046
+					} else {
2047
+						$term_icon_url = $default_icon_url;
2048
+					}
2049
+					$terms_icons[$term->term_id] = $term_icon_url;
2050
+				}
2051
+			}
2052
+		}
2053
+
2054
+		update_option('gd_term_icons', $terms_icons);
2055
+	}
2062 2056
 
2063
-    if (is_ssl()) {
2064
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2065
-    }
2057
+	if ($term_id && isset($terms_icons[$term_id])) {
2058
+		return $terms_icons[$term_id];
2059
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2060
+		return get_option('geodir_default_marker_icon');
2061
+	}
2062
+
2063
+	if (is_ssl()) {
2064
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2065
+	}
2066 2066
 
2067
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2067
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2068 2068
 }
2069 2069
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +170 added lines, -122 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
     if (get_option('geodir_show_listing_nav')) {
40 40
 
41 41
         $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
42
+        if (geodir_is_page('listing')) {
43
+                    $menu_class = 'current-menu-item';
44
+        }
44 45
 
45 46
 
46 47
         //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
                     if (in_array($post_type, $show_post_type_main_nav)) {
53 54
                         if (get_post_type_archive_link($post_type)) {
54 55
                             $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
56
+                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
57
+                                                            $menu_class = 'current-menu-item';
58
+                            }
57 59
                             /**
58 60
                              * Filter the menu li class.
59 61
                              *
@@ -130,8 +132,9 @@  discard block
 block discarded – undo
130 132
                             if (get_post_type_archive_link($post_type)) {
131 133
 
132 134
                                 $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
135
+                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
136
+                                                                    $menu_class = 'current-menu-item';
137
+                                }
135 138
 
136 139
                                 $items .= '<li class="' . $sub_li_class . '">
137 140
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
@@ -159,8 +162,9 @@  discard block
 block discarded – undo
159 162
     if (get_option('geodir_show_addlisting_nav')) {
160 163
 
161 164
         $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
165
+        if (geodir_is_page('add-listing')) {
166
+                    $menu_class = 'current-menu-item';
167
+        }
164 168
 
165 169
         //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166 170
         $post_types = geodir_get_posttypes('object');
@@ -176,8 +180,9 @@  discard block
 block discarded – undo
176 180
                                 if (geodir_get_addlisting_link($post_type)) {
177 181
 
178 182
                                     $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
183
+                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
184
+                                                                            $menu_class = 'current-menu-item';
185
+                                    }
181 186
                                     /**
182 187
                                      * Filter the menu li class.
183 188
                                      *
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
                                     if (geodir_get_addlisting_link($post_type)) {
262 267
 
263 268
                                         $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
269
+                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
270
+                                                                                    $menu_class = 'current-menu-item';
271
+                                        }
266 272
                                         /**
267 273
                                          * Filter the menu li class.
268 274
                                          *
@@ -319,8 +325,9 @@  discard block
 block discarded – undo
319 325
     }
320 326
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 327
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
328
+    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) {
329
+            $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
330
+    }
324 331
 
325 332
     return $menu;
326 333
 
@@ -407,17 +414,20 @@  discard block
 block discarded – undo
407 414
     $geodir_post_type = get_query_var('post_type');
408 415
 
409 416
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
417
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
418
+                    $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
419
+        } elseif (isset($_REQUEST['listing_type'])) {
420
+                    $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
421
+        }
414 422
     }
415 423
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
424
+    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) {
425
+            $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
426
+    }
418 427
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
428
+    if (is_tax()) {
429
+            $geodir_post_type = geodir_get_taxonomy_posttype();
430
+    }
421 431
 
422 432
     // Retrive post type for map marker html ajax request on preview page.
423 433
     if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
@@ -431,8 +441,9 @@  discard block
 block discarded – undo
431 441
     $all_postypes = geodir_get_posttypes();
432 442
     $all_postypes = stripslashes_deep($all_postypes);
433 443
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
444
+    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) {
445
+            $geodir_post_type = '';
446
+    }
436 447
 
437 448
     if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438 449
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
@@ -517,11 +528,12 @@  discard block
 block discarded – undo
517 528
         endswitch;
518 529
     }
519 530
 
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
524
-}
531
+    if (!empty($post_types)) {
532
+            return $post_types;
533
+    } else {
534
+            return array();
535
+    }
536
+    }
525 537
 
526 538
 /**
527 539
  * Get Custom Post Type info.
@@ -538,9 +550,10 @@  discard block
 block discarded – undo
538 550
     $post_types = stripslashes_deep($post_types);
539 551
     if (!empty($post_types) && $post_type != '') {
540 552
         return $post_types[$post_type];
541
-    } else
542
-        return false;
543
-}
553
+    } else {
554
+            return false;
555
+    }
556
+    }
544 557
 
545 558
 if (!function_exists('geodir_get_taxonomies')) {
546 559
     /**
@@ -564,18 +577,21 @@  discard block
 block discarded – undo
564 577
             $gd_taxonomies = array_keys($taxonomies);
565 578
 
566 579
 
567
-            if ($post_type != '')
568
-                $gd_taxonomies = array();
580
+            if ($post_type != '') {
581
+                            $gd_taxonomies = array();
582
+            }
569 583
 
570 584
             $i = 0;
571 585
             foreach ($taxonomies as $taxonomy => $args) {
572 586
 
573
-                if ($post_type != '' && $args['object_type'] == $post_type)
574
-                    $gd_taxonomies[] = $taxonomy;
587
+                if ($post_type != '' && $args['object_type'] == $post_type) {
588
+                                    $gd_taxonomies[] = $taxonomy;
589
+                }
575 590
 
576 591
                 if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
578
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
592
+                    if (array_search($taxonomy, $gd_taxonomies) !== false) {
593
+                                            unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
594
+                    }
579 595
                 }
580 596
 
581 597
             }
@@ -630,10 +646,11 @@  discard block
 block discarded – undo
630 646
                 . geodir_utf8_ucfirst($category_obj->name) . '</option>';
631 647
         }
632 648
 
633
-        if ($echo)
634
-            echo $html;
635
-        else
636
-            return $html;
649
+        if ($echo) {
650
+                    echo $html;
651
+        } else {
652
+                    return $html;
653
+        }
637 654
     }
638 655
 }
639 656
 
@@ -667,11 +684,12 @@  discard block
 block discarded – undo
667 684
 
668 685
     }
669 686
 
670
-    if (!empty($listing_slug))
671
-        return $listing_slug;
672
-    else
673
-        return false;
674
-}
687
+    if (!empty($listing_slug)) {
688
+            return $listing_slug;
689
+    } else {
690
+            return false;
691
+    }
692
+    }
675 693
 
676 694
 
677 695
 /**
@@ -702,16 +720,18 @@  discard block
 block discarded – undo
702 720
     if (!empty($taxonomies)) {
703 721
         foreach (geodir_get_posttypes() as $pt) {
704 722
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
-            if (array_intersect($taxonomies, $object_taxonomies))
706
-                $post_type[] = $pt;
723
+            if (array_intersect($taxonomies, $object_taxonomies)) {
724
+                            $post_type[] = $pt;
725
+            }
707 726
         }
708 727
     }
709 728
 
710
-    if (!empty($post_type))
711
-        return $post_type[0];
712
-    else
713
-        return false;
714
-}
729
+    if (!empty($post_type)) {
730
+            return $post_type[0];
731
+    } else {
732
+            return false;
733
+    }
734
+    }
715 735
 
716 736
 if (!function_exists('geodir_custom_taxonomy_walker')) {
717 737
     /**
@@ -767,18 +787,18 @@  discard block
 block discarded – undo
767 787
                 $checked = '';
768 788
 
769 789
                 if (in_array($cat_term->term_id, $search_terms)) {
770
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
771
-                        $checked = 'selected="selected"';
772
-                    else
773
-                        $checked = 'checked="checked"';
790
+                    if ($cat_display == 'select' || $cat_display == 'multiselect') {
791
+                                            $checked = 'selected="selected"';
792
+                    } else {
793
+                                            $checked = 'checked="checked"';
794
+                    }
774 795
                 }
775 796
 
776
-                if ($cat_display == 'radio')
777
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
780
-
781
-                else {
797
+                if ($cat_display == 'radio') {
798
+                                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
799
+                } elseif ($cat_display == 'select' || $cat_display == 'multiselect') {
800
+                                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
801
+                } else {
782 802
                     $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783 803
                 }
784 804
 
@@ -787,8 +807,9 @@  discard block
 block discarded – undo
787 807
 
788 808
             }
789 809
 
790
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
-                $out .= '</div>';
810
+            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
811
+                            $out .= '</div>';
812
+            }
792 813
 
793 814
             return $out;
794 815
         }
@@ -814,18 +835,21 @@  discard block
 block discarded – undo
814 835
         global $exclude_cats, $gd_session;
815 836
 
816 837
         $cat_exclude = '';
817
-        if (is_array($exclude_cats) && !empty($exclude_cats))
818
-            $cat_exclude = serialize($exclude_cats);
838
+        if (is_array($exclude_cats) && !empty($exclude_cats)) {
839
+                    $cat_exclude = serialize($exclude_cats);
840
+        }
819 841
 
820 842
         if (isset($_REQUEST['backandedit'])) {
821 843
             $post = (object)$gd_session->get('listing');
822 844
 
823
-            if (!is_array($post->post_category[$cat_taxonomy]))
824
-                $post_category = $post->post_category[$cat_taxonomy];
845
+            if (!is_array($post->post_category[$cat_taxonomy])) {
846
+                            $post_category = $post->post_category[$cat_taxonomy];
847
+            }
825 848
 
826 849
             $post_categories = $post->post_category_str;
827
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
-                $post_category_str = $post_categories[$cat_taxonomy];
850
+            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
851
+                            $post_category_str = $post_categories[$cat_taxonomy];
852
+            }
829 853
 
830 854
         } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831 855
             global $post;
@@ -1016,8 +1040,9 @@  discard block
 block discarded – undo
1016 1040
         if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017 1041
             $post_cat_str = $post_categories[$cat_taxonomy];
1018 1042
             $post_cat_array = explode("#", $post_cat_str);
1019
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
-                $style = "display:none;";
1043
+            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) {
1044
+                            $style = "display:none;";
1045
+            }
1021 1046
         }
1022 1047
         ?>
1023 1048
         <div class="main_cat_list" style=" <?php if (isset($style)) {
@@ -1052,7 +1077,7 @@  discard block
 block discarded – undo
1052 1077
 
1053 1078
         if(is_array( $exclude_cats)){
1054 1079
             $exclude_cats = array_map( 'intval', $exclude_cats );
1055
-        }else{
1080
+        } else{
1056 1081
             $exclude_cats = intval($exclude_cats);
1057 1082
         }
1058 1083
 
@@ -1082,7 +1107,10 @@  discard block
 block discarded – undo
1082 1107
 
1083 1108
             <div class="post_default_category">
1084 1109
                 <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1085
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1110
+                       onchange="update_listing_cat()" <?php if ($default) {
1111
+	echo ' checked="checked" ';
1112
+}
1113
+?>   />
1086 1114
         <span> 
1087 1115
         <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1088 1116
         </span>
@@ -1182,8 +1210,9 @@  discard block
 block discarded – undo
1182 1210
         $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1183 1211
 
1184 1212
         $option_selected = '';
1185
-        if (!$selected)
1186
-            $option_slected = ' selected="selected" ';
1213
+        if (!$selected) {
1214
+                    $option_slected = ' selected="selected" ';
1215
+        }
1187 1216
 
1188 1217
         echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1189 1218
 
@@ -1191,8 +1220,9 @@  discard block
 block discarded – undo
1191 1220
 
1192 1221
         foreach ($cat_terms as $cat_term) {
1193 1222
             $option_selected = '';
1194
-            if ($selected == $cat_term->term_id)
1195
-                $option_selected = ' selected="selected" ';
1223
+            if ($selected == $cat_term->term_id) {
1224
+                            $option_selected = ' selected="selected" ';
1225
+            }
1196 1226
 
1197 1227
             // Count child terms
1198 1228
             $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
@@ -1257,8 +1287,9 @@  discard block
 block discarded – undo
1257 1287
 
1258 1288
     $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259 1289
 
1260
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
-        $listing_slug = 'places';
1290
+    if (!$listing_slug = get_option('geodir_listing_prefix')) {
1291
+            $listing_slug = 'places';
1292
+    }
1262 1293
 
1263 1294
     /**
1264 1295
      * Taxonomies
@@ -1570,8 +1601,9 @@  discard block
 block discarded – undo
1570 1601
                             'city_slug' => $post->city_slug
1571 1602
                         );
1572 1603
 
1573
-                    } else
1574
-                        $post_location = geodir_get_location();
1604
+                    } else {
1605
+                                            $post_location = geodir_get_location();
1606
+                    }
1575 1607
 
1576 1608
 
1577 1609
                 } else {
@@ -1600,8 +1632,9 @@  discard block
 block discarded – undo
1600 1632
                             );
1601 1633
 
1602 1634
                         }
1603
-                    } else
1604
-                        $post_location = geodir_get_location();
1635
+                    } else {
1636
+                                            $post_location = geodir_get_location();
1637
+                    }
1605 1638
                 }
1606 1639
 
1607 1640
 
@@ -1641,16 +1674,17 @@  discard block
 block discarded – undo
1641 1674
 
1642 1675
                     if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643 1676
                         $post_terms = absint($_POST['post_default_category']);
1644
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1677
+                    } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
1645 1678
                         $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646 1679
                         $post_terms = absint($post_terms[0]);
1647
-                    }elseif (isset($post->{$taxonomies})) {
1680
+                    } elseif (isset($post->{$taxonomies})) {
1648 1681
                         $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649 1682
                         $post_terms = $post_terms[0];
1650 1683
                     }
1651 1684
 
1652
-                    if (!$post_terms)
1653
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1685
+                    if (!$post_terms) {
1686
+                                            $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1687
+                    }
1654 1688
 
1655 1689
                     if (!$post_terms) {
1656 1690
                         $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
@@ -1664,8 +1698,9 @@  discard block
 block discarded – undo
1664 1698
 
1665 1699
                 $term = get_term_by('id', $post_terms, $taxonomies);
1666 1700
 
1667
-                if (!empty($term))
1668
-                    $term_request = $term->slug;
1701
+                if (!empty($term)) {
1702
+                                    $term_request = $term->slug;
1703
+                }
1669 1704
                 //$term_request = $term->slug.'/';
1670 1705
             }
1671 1706
 
@@ -1680,9 +1715,13 @@  discard block
 block discarded – undo
1680 1715
                 $request_term .= $term_request;
1681 1716
 
1682 1717
             } else {
1683
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1718
+                if (isset($location_request) && $location_request != '') {
1719
+                	$request_term = $location_request;
1720
+                }
1684 1721
 
1685
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1722
+                if (isset($term_request) && $term_request != '') {
1723
+                	$request_term .= $term_request;
1724
+                }
1686 1725
             }
1687 1726
             $request_term = trim($request_term, '/');
1688 1727
             
@@ -1691,10 +1730,11 @@  discard block
 block discarded – undo
1691 1730
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692 1731
             }
1693 1732
             
1694
-            if (!empty($request_term))
1695
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
-            else
1697
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1733
+            if (!empty($request_term)) {
1734
+                            $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1735
+            } else {
1736
+                            $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1737
+            }
1698 1738
             //echo $post_link ;
1699 1739
         }
1700 1740
         // temp cache the permalink
@@ -1886,11 +1926,12 @@  discard block
 block discarded – undo
1886 1926
     
1887 1927
     $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1888 1928
     
1889
-    if ($echo)
1890
-        echo $label;
1891
-    else
1892
-        return $label;
1893
-}
1929
+    if ($echo) {
1930
+            echo $label;
1931
+    } else {
1932
+            return $label;
1933
+    }
1934
+    }
1894 1935
 
1895 1936
 /**
1896 1937
  * Print or Get post type plural label.
@@ -1906,18 +1947,20 @@  discard block
 block discarded – undo
1906 1947
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1907 1948
     $all_postypes = geodir_get_posttypes();
1908 1949
 
1909
-    if (!in_array($post_type, $all_postypes))
1910
-        return false;
1950
+    if (!in_array($post_type, $all_postypes)) {
1951
+            return false;
1952
+    }
1911 1953
 
1912 1954
     $obj_post_type = get_post_type_object($post_type);
1913 1955
     
1914 1956
     $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1915 1957
     
1916
-    if ($echo)
1917
-        echo $label;
1918
-    else
1919
-        return $label;
1920
-}
1958
+    if ($echo) {
1959
+            echo $label;
1960
+    } else {
1961
+            return $label;
1962
+    }
1963
+    }
1921 1964
 
1922 1965
 /**
1923 1966
  * Checks whether a term exists or not.
@@ -1940,19 +1983,22 @@  discard block
 block discarded – undo
1940 1983
     $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941 1984
 
1942 1985
     if (is_int($term)) {
1943
-        if (0 == $term)
1944
-            return 0;
1986
+        if (0 == $term) {
1987
+                    return 0;
1988
+        }
1945 1989
         $where = 't.term_id = %d';
1946
-        if (!empty($taxonomy))
1947
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
-        else
1949
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1990
+        if (!empty($taxonomy)) {
1991
+                    return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1992
+        } else {
1993
+                    return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1994
+        }
1950 1995
     }
1951 1996
 
1952 1997
     $term = trim(wp_unslash($term));
1953 1998
 
1954
-    if ('' === $slug = sanitize_title($term))
1955
-        return 0;
1999
+    if ('' === $slug = sanitize_title($term)) {
2000
+            return 0;
2001
+    }
1956 2002
 
1957 2003
     $where = 't.slug = %s';
1958 2004
 
@@ -1969,14 +2015,16 @@  discard block
 block discarded – undo
1969 2015
         $where_fields[] = $taxonomy;
1970 2016
 
1971 2017
 
1972
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
-            return $result;
2018
+        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) {
2019
+                    return $result;
2020
+        }
1974 2021
 
1975 2022
         return false;
1976 2023
     }
1977 2024
 
1978
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
-        return $result;
2025
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) {
2026
+            return $result;
2027
+    }
1980 2028
 
1981 2029
     return false;
1982 2030
 }
Please login to merge, or discard this patch.
geodirectory-functions/post_functions.php 1 patch
Indentation   +2245 added lines, -2245 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
+						}
407 403
 
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
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.
410 407
 
411
-                            $date_format = str_replace($search, $replace, $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
412 410
 
413
-                            $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
411
+							$date_format = str_replace($search, $replace, $date_format);
414 412
 
415
-                        }else{
416
-                            $post_htmlvar_value = $request_info[$name];
417
-                        }
413
+							$post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
418 414
 
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
-                    }
415
+						}else{
416
+							$post_htmlvar_value = $request_info[$name];
417
+						}
422 418
 
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
-            }
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
+
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
-    {
926
-
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
+	{
927 926
 
928
-        global $wpdb, $plugin_prefix, $current_user;
929 927
 
930
-        $post_type = get_post_type($post_id);
928
+		global $wpdb, $plugin_prefix, $current_user;
931 929
 
932
-        $table = $plugin_prefix . $post_type . '_detail';
930
+		$post_type = get_post_type($post_id);
933 931
 
934
-        $post_images = geodir_get_images($post_id);
932
+		$table = $plugin_prefix . $post_type . '_detail';
935 933
 
936
-        $wpdb->query(
937
-            $wpdb->prepare(
938
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
939
-                array($post_id)
940
-            )
941
-        );
934
+		$post_images = geodir_get_images($post_id);
942 935
 
943
-        $invalid_files = $post_images;
944
-        $valid_file_ids = array();
945
-        $valid_files_condition = '';
946
-        $geodir_uploaddir = '';
936
+		$wpdb->query(
937
+			$wpdb->prepare(
938
+				"UPDATE " . $table . " SET featured_image = '' where post_id =%d",
939
+				array($post_id)
940
+			)
941
+		);
947 942
 
948
-        $remove_files = array();
943
+		$invalid_files = $post_images;
944
+		$valid_file_ids = array();
945
+		$valid_files_condition = '';
946
+		$geodir_uploaddir = '';
949 947
 
950
-        if (!empty($post_image)) {
948
+		$remove_files = array();
951 949
 
952
-            $uploads = wp_upload_dir();
953
-            $uploads_dir = $uploads['path'];
950
+		if (!empty($post_image)) {
954 951
 
955
-            $geodir_uploadpath = $uploads['path'];
956
-            $geodir_uploadurl = $uploads['url'];
957
-            $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
952
+			$uploads = wp_upload_dir();
953
+			$uploads_dir = $uploads['path'];
958 954
 
959
-            $invalid_files = array();
960
-            $postcurr_images = array();
955
+			$geodir_uploadpath = $uploads['path'];
956
+			$geodir_uploadurl = $uploads['url'];
957
+			$sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
961 958
 
962
-            for ($m = 0; $m < count($post_image); $m++) {
963
-                $menu_order = $m + 1;
959
+			$invalid_files = array();
960
+			$postcurr_images = array();
964 961
 
965
-                $file_path = '';
966
-                /* --------- start ------- */
962
+			for ($m = 0; $m < count($post_image); $m++) {
963
+				$menu_order = $m + 1;
967 964
 
968
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
965
+				$file_path = '';
966
+				/* --------- start ------- */
969 967
 
970
-                $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
968
+				$split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
971 969
 
970
+				$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
972 971
 
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 972
 
975
-                    /* --------- end ------- */
976
-                    $curr_img_url = $post_image[$m];
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)))) {
977 974
 
978
-                    $image_name_arr = explode('/', $curr_img_url);
975
+					/* --------- end ------- */
976
+					$curr_img_url = $post_image[$m];
979 977
 
980
-                    $count_image_name_arr = count($image_name_arr) - 2;
978
+					$image_name_arr = explode('/', $curr_img_url);
981 979
 
982
-                    $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
980
+					$count_image_name_arr = count($image_name_arr) - 2;
983 981
 
984
-                    $curr_img_dir = $image_name_arr[$count_image_name_arr];
982
+					$count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
985 983
 
986
-                    $filename = end($image_name_arr);
987
-                    if (strpos($filename, '?') !== false) {
988
-                        list($filename) = explode('?', $filename);
989
-                    }
984
+					$curr_img_dir = $image_name_arr[$count_image_name_arr];
990 985
 
991
-                    $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
992
-                    $curr_img_dir = str_replace($filename, "", $curr_img_dir);
986
+					$filename = end($image_name_arr);
987
+					if (strpos($filename, '?') !== false) {
988
+						list($filename) = explode('?', $filename);
989
+					}
993 990
 
994
-                    $img_name_arr = explode('.', $filename);
991
+					$curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
992
+					$curr_img_dir = str_replace($filename, "", $curr_img_dir);
995 993
 
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);
994
+					$img_name_arr = explode('.', $filename);
1006 995
 
1007
-                    $arr_file_type = wp_check_filetype($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);
1008 1006
 
1009
-                    $uploaded_file_type = $arr_file_type['type'];
1007
+					$arr_file_type = wp_check_filetype($filename);
1010 1008
 
1011
-                    // Set an array containing a list of acceptable formats
1012
-                    $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1009
+					$uploaded_file_type = $arr_file_type['type'];
1013 1010
 
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
-                        }
1011
+					// Set an array containing a list of acceptable formats
1012
+					$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1019 1013
 
1020
-                        if (!is_dir($geodir_uploadpath)) {
1021
-                            mkdir($geodir_uploadpath);
1022
-                        }
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
+						}
1023 1019
 
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
-                        }
1020
+						if (!is_dir($geodir_uploadpath)) {
1021
+							mkdir($geodir_uploadpath);
1022
+						}
1029 1023
 
1030
-                        if ($dummy || $external_img) {
1031
-                            $uploaded_file = array();
1032
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
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
+						}
1033 1029
 
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;
1030
+						if ($dummy || $external_img) {
1031
+							$uploaded_file = array();
1032
+							$uploaded = (array)fetch_remote_file($curr_img_url);
1043 1033
 
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
-                            }
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;
1051 1043
 
1052
-                            $uploaded_file = '';
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
+							}
1053 1051
 
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
-                            }
1052
+							$uploaded_file = '';
1061 1053
 
1062
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
-                                unlink($img_path);
1064
-                        }
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
+							}
1065 1061
 
1066
-                        if (!empty($uploaded_file)) {
1067
-                            if (!isset($file_path) || !$file_path) {
1068
-                                $file_path = $sub_dir . '/' . $new_name;
1069
-                            }
1062
+							if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
+								unlink($img_path);
1064
+						}
1070 1065
 
1071
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1066
+						if (!empty($uploaded_file)) {
1067
+							if (!isset($file_path) || !$file_path) {
1068
+								$file_path = $sub_dir . '/' . $new_name;
1069
+							}
1072 1070
 
1073
-                            if ($menu_order == 1) {
1071
+							$postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1074 1072
 
1075
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1073
+							if ($menu_order == 1) {
1076 1074
 
1077
-                            }
1075
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1078 1076
 
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;
1077
+							}
1088 1078
 
1089
-                            $attachment_set = '';
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;
1090 1088
 
1091
-                            foreach ($attachment as $key => $val) {
1092
-                                if ($val != '')
1093
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1094
-                            }
1089
+							$attachment_set = '';
1095 1090
 
1096
-                            $attachment_set = trim($attachment_set, ", ");
1091
+							foreach ($attachment as $key => $val) {
1092
+								if ($val != '')
1093
+									$attachment_set .= $key . " = '" . $val . "', ";
1094
+							}
1097 1095
 
1098
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1096
+							$attachment_set = trim($attachment_set, ", ");
1097
+
1098
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1099 1099
 
1100
-                            $valid_file_ids[] = $wpdb->insert_id;
1101
-                        }
1100
+							$valid_file_ids[] = $wpdb->insert_id;
1101
+						}
1102 1102
 
1103
-                    }
1103
+					}
1104 1104
 
1105 1105
 
1106
-                } else {
1107
-                    $valid_file_ids[] = $find_image;
1106
+				} else {
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
-                    $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,117 +1210,117 @@  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;
1285
+		global $wpdb, $plugin_prefix, $post;
1286 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
-        }
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 1292
 
1293
-        if (!in_array($post_type, geodir_get_posttypes())) {
1294
-            return false;// if not a GD CPT return;
1295
-        }
1293
+		if (!in_array($post_type, geodir_get_posttypes())) {
1294
+			return false;// if not a GD CPT return;
1295
+		}
1296 1296
 
1297
-        $table = $plugin_prefix . $post_type . '_detail';
1297
+		$table = $plugin_prefix . $post_type . '_detail';
1298 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
-        }
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 1306
 
1307
-        if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1308
-            $img_arr = array();
1307
+		if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1308
+			$img_arr = array();
1309 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
-            }
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
+			}
1315 1315
 
1316
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1317
-            $uploads_baseurl = $uploads['baseurl'];
1318
-            $uploads_path = $uploads['path'];
1316
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1317
+			$uploads_baseurl = $uploads['baseurl'];
1318
+			$uploads_path = $uploads['path'];
1319 1319
 
1320
-            $file_name = $file_info['basename'];
1320
+			$file_name = $file_info['basename'];
1321 1321
 
1322
-            $uploads_url = $uploads_baseurl . $sub_dir;
1323
-            /*
1322
+			$uploads_url = $uploads_baseurl . $sub_dir;
1323
+			/*
1324 1324
              * Allows the filter of image src for such things as CDN change.
1325 1325
              *
1326 1326
              * @since 1.5.7
@@ -1329,158 +1329,158 @@  discard block
 block discarded – undo
1329 1329
              * @param string $uploads_url The server upload directory url.
1330 1330
              * @param string $uploads_baseurl The uploads dir base url.
1331 1331
              */
1332
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1333
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1334
-            $width = 0;
1335
-            $height = 0;
1336
-            if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1337
-                $imagesize = getimagesize($img_arr['path']);
1338
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1339
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1340
-            }
1341
-            $img_arr['width'] = $width;
1342
-            $img_arr['height'] = $height;
1343
-            $img_arr['title'] = '';
1344
-        } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1345
-            foreach ($post_images as $image) {
1346
-                return $image;
1347
-            }
1348
-        } else if ($no_image) {
1349
-            $img_arr = array();
1350
-
1351
-            $default_img = '';
1352
-            if (isset($post->default_category) && $post->default_category) {
1353
-                $default_cat = $post->default_category;
1354
-            } else {
1355
-                $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1356
-            }
1357
-
1358
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1359
-                $default_img = $default_catimg['src'];
1360
-            elseif ($no_image) {
1361
-                $default_img = get_option('geodir_listing_no_img');
1362
-            }
1363
-
1364
-            if (!empty($default_img)) {
1365
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1366
-                $uploads_baseurl = $uploads['baseurl'];
1367
-                $uploads_path = $uploads['path'];
1368
-
1369
-                $img_arr = array();
1370
-
1371
-                $file_info = pathinfo($default_img);
1372
-
1373
-                $file_name = $file_info['basename'];
1374
-
1375
-                $img_arr['src'] = $default_img;
1376
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1377
-
1378
-                $width = 0;
1379
-                $height = 0;
1380
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1381
-                    $imagesize = getimagesize($img_arr['path']);
1382
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1383
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1384
-                }
1385
-                $img_arr['width'] = $width;
1386
-                $img_arr['height'] = $height;
1387
-
1388
-                $img_arr['title'] = ''; // add the title to the array
1389
-            }
1390
-        }
1391
-
1392
-        if (!empty($img_arr))
1393
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1394
-        else
1395
-            return false;
1396
-    }
1332
+			$img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1333
+			$img_arr['path'] = $uploads_path . '/' . $file_name;
1334
+			$width = 0;
1335
+			$height = 0;
1336
+			if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1337
+				$imagesize = getimagesize($img_arr['path']);
1338
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1339
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1340
+			}
1341
+			$img_arr['width'] = $width;
1342
+			$img_arr['height'] = $height;
1343
+			$img_arr['title'] = '';
1344
+		} elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1345
+			foreach ($post_images as $image) {
1346
+				return $image;
1347
+			}
1348
+		} else if ($no_image) {
1349
+			$img_arr = array();
1350
+
1351
+			$default_img = '';
1352
+			if (isset($post->default_category) && $post->default_category) {
1353
+				$default_cat = $post->default_category;
1354
+			} else {
1355
+				$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1356
+			}
1357
+
1358
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1359
+				$default_img = $default_catimg['src'];
1360
+			elseif ($no_image) {
1361
+				$default_img = get_option('geodir_listing_no_img');
1362
+			}
1363
+
1364
+			if (!empty($default_img)) {
1365
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1366
+				$uploads_baseurl = $uploads['baseurl'];
1367
+				$uploads_path = $uploads['path'];
1368
+
1369
+				$img_arr = array();
1370
+
1371
+				$file_info = pathinfo($default_img);
1372
+
1373
+				$file_name = $file_info['basename'];
1374
+
1375
+				$img_arr['src'] = $default_img;
1376
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1377
+
1378
+				$width = 0;
1379
+				$height = 0;
1380
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1381
+					$imagesize = getimagesize($img_arr['path']);
1382
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1383
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1384
+				}
1385
+				$img_arr['width'] = $width;
1386
+				$img_arr['height'] = $height;
1387
+
1388
+				$img_arr['title'] = ''; // add the title to the array
1389
+			}
1390
+		}
1391
+
1392
+		if (!empty($img_arr))
1393
+			return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1394
+		else
1395
+			return false;
1396
+	}
1397 1397
 }
1398 1398
 
1399 1399
 if (!function_exists('geodir_show_featured_image')) {
1400
-    /**
1401
-     * Gets the post featured image.
1402
-     *
1403
-     * @since 1.0.0
1404
-     * @package GeoDirectory
1405
-     * @param int|string $post_id The post ID.
1406
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1407
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1408
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1409
-     * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1410
-     * @return bool|string Returns image html.
1411
-     */
1412
-    function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1413
-    {
1414
-        $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1415
-
1416
-        $html = geodir_show_image($image, $size, $no_image, false);
1417
-
1418
-        if (!empty($html) && $echo) {
1419
-            echo $html;
1420
-        } elseif (!empty($html)) {
1421
-            return $html;
1422
-        } else
1423
-            return false;
1424
-    }
1400
+	/**
1401
+	 * Gets the post featured image.
1402
+	 *
1403
+	 * @since 1.0.0
1404
+	 * @package GeoDirectory
1405
+	 * @param int|string $post_id The post ID.
1406
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1407
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1408
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1409
+	 * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1410
+	 * @return bool|string Returns image html.
1411
+	 */
1412
+	function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1413
+	{
1414
+		$image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1415
+
1416
+		$html = geodir_show_image($image, $size, $no_image, false);
1417
+
1418
+		if (!empty($html) && $echo) {
1419
+			echo $html;
1420
+		} elseif (!empty($html)) {
1421
+			return $html;
1422
+		} else
1423
+			return false;
1424
+	}
1425 1425
 }
1426 1426
 
1427 1427
 if (!function_exists('geodir_get_images')) {
1428
-    /**
1429
-     * Gets the post images.
1430
-     *
1431
-     * @since 1.0.0
1432
-     * @package GeoDirectory
1433
-     * @global object $wpdb WordPress Database object.
1434
-     * @param int $post_id The post ID.
1435
-     * @param string $img_size Optional. Thumbnail size.
1436
-     * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1437
-     * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1438
-     * @param int|string $limit Optional. Number of images.
1439
-     * @return array|bool Returns images as an array. Each item is an object.
1440
-     */
1441
-    function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1442
-    {
1443
-        global $wpdb;
1444
-        if ($limit) {
1445
-            $limit_q = " LIMIT $limit ";
1446
-        } else {
1447
-            $limit_q = '';
1448
-        }
1449
-        $not_featured = '';
1450
-        $sub_dir = '';
1451
-        if (!$add_featured)
1452
-            $not_featured = " AND is_featured = 0 ";
1453
-
1454
-        $arrImages = $wpdb->get_results(
1455
-            $wpdb->prepare(
1456
-                "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 ",
1457
-                array('%image%', $post_id)
1458
-            )
1459
-        );
1460
-
1461
-        $counter = 0;
1462
-        $return_arr = array();
1463
-
1464
-        if (!empty($arrImages)) {
1465
-            foreach ($arrImages as $attechment) {
1466
-
1467
-                $img_arr = array();
1468
-                $img_arr['id'] = $attechment->ID;
1469
-                $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1470
-
1471
-                $file_info = pathinfo($attechment->file);
1472
-
1473
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1474
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1475
-
1476
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1477
-                $uploads_baseurl = $uploads['baseurl'];
1478
-                $uploads_path = $uploads['path'];
1479
-
1480
-                $file_name = $file_info['basename'];
1481
-
1482
-                $uploads_url = $uploads_baseurl . $sub_dir;
1483
-                /*
1428
+	/**
1429
+	 * Gets the post images.
1430
+	 *
1431
+	 * @since 1.0.0
1432
+	 * @package GeoDirectory
1433
+	 * @global object $wpdb WordPress Database object.
1434
+	 * @param int $post_id The post ID.
1435
+	 * @param string $img_size Optional. Thumbnail size.
1436
+	 * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1437
+	 * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1438
+	 * @param int|string $limit Optional. Number of images.
1439
+	 * @return array|bool Returns images as an array. Each item is an object.
1440
+	 */
1441
+	function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1442
+	{
1443
+		global $wpdb;
1444
+		if ($limit) {
1445
+			$limit_q = " LIMIT $limit ";
1446
+		} else {
1447
+			$limit_q = '';
1448
+		}
1449
+		$not_featured = '';
1450
+		$sub_dir = '';
1451
+		if (!$add_featured)
1452
+			$not_featured = " AND is_featured = 0 ";
1453
+
1454
+		$arrImages = $wpdb->get_results(
1455
+			$wpdb->prepare(
1456
+				"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 ",
1457
+				array('%image%', $post_id)
1458
+			)
1459
+		);
1460
+
1461
+		$counter = 0;
1462
+		$return_arr = array();
1463
+
1464
+		if (!empty($arrImages)) {
1465
+			foreach ($arrImages as $attechment) {
1466
+
1467
+				$img_arr = array();
1468
+				$img_arr['id'] = $attechment->ID;
1469
+				$img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1470
+
1471
+				$file_info = pathinfo($attechment->file);
1472
+
1473
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1474
+					$sub_dir = stripslashes_deep($file_info['dirname']);
1475
+
1476
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1477
+				$uploads_baseurl = $uploads['baseurl'];
1478
+				$uploads_path = $uploads['path'];
1479
+
1480
+				$file_name = $file_info['basename'];
1481
+
1482
+				$uploads_url = $uploads_baseurl . $sub_dir;
1483
+				/*
1484 1484
                 * Allows the filter of image src for such things as CDN change.
1485 1485
                 *
1486 1486
                 * @since 1.5.7
@@ -1489,520 +1489,520 @@  discard block
 block discarded – undo
1489 1489
                 * @param string $uploads_url The server upload directory url.
1490 1490
                 * @param string $uploads_baseurl The uploads dir base url.
1491 1491
                 */
1492
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1493
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1494
-                $width = 0;
1495
-                $height = 0;
1496
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1497
-                    $imagesize = getimagesize($img_arr['path']);
1498
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1499
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1500
-                }
1501
-                $img_arr['width'] = $width;
1502
-                $img_arr['height'] = $height;
1503
-
1504
-                $img_arr['file'] = $file_name; // add the title to the array
1505
-                $img_arr['title'] = $attechment->title; // add the title to the array
1506
-                $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1507
-                $img_arr['content'] = $attechment->content; // add the description to the array
1508
-                $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1509
-
1510
-                $return_arr[] = (object)$img_arr;
1511
-
1512
-                $counter++;
1513
-            }
1514
-            return (object)$return_arr;
1515
-        } else if ($no_images) {
1516
-            $default_img = '';
1517
-            $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1518
-            $post_type = get_post_type($post_id);
1519
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1520
-                $default_img = $default_catimg['src'];
1521
-            elseif ($no_images) {
1522
-                $default_img = get_option('geodir_listing_no_img');
1523
-            }
1524
-
1525
-            if (!empty($default_img)) {
1526
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1492
+				$img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1493
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1494
+				$width = 0;
1495
+				$height = 0;
1496
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1497
+					$imagesize = getimagesize($img_arr['path']);
1498
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1499
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1500
+				}
1501
+				$img_arr['width'] = $width;
1502
+				$img_arr['height'] = $height;
1503
+
1504
+				$img_arr['file'] = $file_name; // add the title to the array
1505
+				$img_arr['title'] = $attechment->title; // add the title to the array
1506
+				$img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1507
+				$img_arr['content'] = $attechment->content; // add the description to the array
1508
+				$img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1509
+
1510
+				$return_arr[] = (object)$img_arr;
1511
+
1512
+				$counter++;
1513
+			}
1514
+			return (object)$return_arr;
1515
+		} else if ($no_images) {
1516
+			$default_img = '';
1517
+			$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1518
+			$post_type = get_post_type($post_id);
1519
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1520
+				$default_img = $default_catimg['src'];
1521
+			elseif ($no_images) {
1522
+				$default_img = get_option('geodir_listing_no_img');
1523
+			}
1524
+
1525
+			if (!empty($default_img)) {
1526
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1527 1527
                 
1528
-                $image_path = $default_img;
1529
-                if (!path_is_absolute($image_path)) {
1530
-                    $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1531
-                }
1532
-
1533
-                $file_info = pathinfo($default_img);
1534
-                $file_name = $file_info['basename'];
1535
-
1536
-                $width = '';
1537
-                $height = '';
1538
-                if (is_file($image_path) && file_exists($image_path)) {
1539
-                    $imagesize = getimagesize($image_path);
1540
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1541
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1542
-                }
1528
+				$image_path = $default_img;
1529
+				if (!path_is_absolute($image_path)) {
1530
+					$image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1531
+				}
1532
+
1533
+				$file_info = pathinfo($default_img);
1534
+				$file_name = $file_info['basename'];
1535
+
1536
+				$width = '';
1537
+				$height = '';
1538
+				if (is_file($image_path) && file_exists($image_path)) {
1539
+					$imagesize = getimagesize($image_path);
1540
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1541
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1542
+				}
1543 1543
                 
1544
-                $img_arr = array();
1545
-                $img_arr['src'] = $default_img;
1546
-                $img_arr['path'] = $image_path;
1547
-                $img_arr['width'] = $width;
1548
-                $img_arr['height'] = $height;
1549
-                $img_arr['file'] = $file_name; // add the title to the array
1550
-                $img_arr['title'] = $file_info['filename']; // add the title to the array
1551
-                $img_arr['content'] = $file_info['filename']; // add the description to the array
1552
-
1553
-                $return_arr[] = (object)$img_arr;
1554
-
1555
-                return $return_arr;
1556
-            } else
1557
-                return false;
1558
-        }
1559
-    }
1544
+				$img_arr = array();
1545
+				$img_arr['src'] = $default_img;
1546
+				$img_arr['path'] = $image_path;
1547
+				$img_arr['width'] = $width;
1548
+				$img_arr['height'] = $height;
1549
+				$img_arr['file'] = $file_name; // add the title to the array
1550
+				$img_arr['title'] = $file_info['filename']; // add the title to the array
1551
+				$img_arr['content'] = $file_info['filename']; // add the description to the array
1552
+
1553
+				$return_arr[] = (object)$img_arr;
1554
+
1555
+				return $return_arr;
1556
+			} else
1557
+				return false;
1558
+		}
1559
+	}
1560 1560
 }
1561 1561
 
1562 1562
 if (!function_exists('geodir_show_image')) {
1563
-    /**
1564
-     * Show image using image details.
1565
-     *
1566
-     * @since 1.0.0
1567
-     * @package GeoDirectory
1568
-     * @param array|object $request Image info either as an array or object.
1569
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1570
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1571
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1572
-     * @return bool|string Returns image html.
1573
-     */
1574
-    function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1575
-    {
1576
-        $image = new stdClass();
1577
-
1578
-        $html = '';
1579
-        if (!empty($request)) {
1580
-            if (!is_object($request)){
1581
-                $request = (object)$request;
1582
-            }
1583
-
1584
-            if (isset($request->src) && !isset($request->path)) {
1585
-                $request->path = $request->src;
1586
-            }
1587
-
1588
-            /*
1563
+	/**
1564
+	 * Show image using image details.
1565
+	 *
1566
+	 * @since 1.0.0
1567
+	 * @package GeoDirectory
1568
+	 * @param array|object $request Image info either as an array or object.
1569
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1570
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1571
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1572
+	 * @return bool|string Returns image html.
1573
+	 */
1574
+	function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1575
+	{
1576
+		$image = new stdClass();
1577
+
1578
+		$html = '';
1579
+		if (!empty($request)) {
1580
+			if (!is_object($request)){
1581
+				$request = (object)$request;
1582
+			}
1583
+
1584
+			if (isset($request->src) && !isset($request->path)) {
1585
+				$request->path = $request->src;
1586
+			}
1587
+
1588
+			/*
1589 1589
              * getimagesize() works faster from path than url so we try and get path if we can.
1590 1590
              */
1591
-            $upload_dir = wp_upload_dir();
1592
-            $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1593
-            $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1594
-            if (strpos($img_no_http, $upload_no_http) !== false) {
1595
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1596
-            }
1591
+			$upload_dir = wp_upload_dir();
1592
+			$img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1593
+			$upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1594
+			if (strpos($img_no_http, $upload_no_http) !== false) {
1595
+				$request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1596
+			}
1597 1597
             
1598
-            $width = 0;
1599
-            $height = 0;
1600
-            if (is_file($request->path) && file_exists($request->path)) {
1601
-                $imagesize = getimagesize($request->path);
1602
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1603
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1604
-            }
1605
-
1606
-            $image->src = $request->src;
1607
-            $image->width = $width;
1608
-            $image->height = $height;
1609
-
1610
-            $max_size = (object)geodir_get_imagesize($size);
1611
-
1612
-            if (!is_wp_error($max_size)) {
1613
-                if ($image->width) {
1614
-                    if ($image->height >= $image->width) {
1615
-                        $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1616
-                    } else if ($image->width < ($max_size->h)) {
1617
-                        $width_per = round((($image->width / $max_size->w) * 100), 2);
1618
-                    } else
1619
-                        $width_per = 100;
1620
-                }
1621
-
1622
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1623
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1624
-                } else {
1625
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1626
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1627
-                    }else{
1628
-                        //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1629
-                        //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1630
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1631
-
1632
-                    }
1633
-
1634
-                }
1635
-            }
1636
-        }
1637
-
1638
-        if (!empty($html) && $echo) {
1639
-            echo $html;
1640
-        } elseif (!empty($html)) {
1641
-            return $html;
1642
-        } else
1643
-            return false;
1644
-    }
1645
-}
1598
+			$width = 0;
1599
+			$height = 0;
1600
+			if (is_file($request->path) && file_exists($request->path)) {
1601
+				$imagesize = getimagesize($request->path);
1602
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1603
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1604
+			}
1646 1605
 
1647
-if (!function_exists('geodir_set_post_terms')) {
1648
-    /**
1649
-     * Set post Categories.
1650
-     *
1651
-     * @since 1.0.0
1652
-     * @package GeoDirectory
1653
-     * @global object $wpdb WordPress Database object.
1654
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1655
-     * @param int $post_id The post ID.
1656
-     * @param array $terms An array of term objects.
1657
-     * @param array $tt_ids An array of term taxonomy IDs.
1658
-     * @param string $taxonomy Taxonomy slug.
1659
-     */
1660
-    function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1661
-    {
1662
-        global $wpdb, $plugin_prefix;
1606
+			$image->src = $request->src;
1607
+			$image->width = $width;
1608
+			$image->height = $height;
1609
+
1610
+			$max_size = (object)geodir_get_imagesize($size);
1611
+
1612
+			if (!is_wp_error($max_size)) {
1613
+				if ($image->width) {
1614
+					if ($image->height >= $image->width) {
1615
+						$width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1616
+					} else if ($image->width < ($max_size->h)) {
1617
+						$width_per = round((($image->width / $max_size->w) * 100), 2);
1618
+					} else
1619
+						$width_per = 100;
1620
+				}
1663 1621
 
1664
-        $post_type = get_post_type($post_id);
1622
+				if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1623
+					$html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1624
+				} else {
1625
+					if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1626
+						$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1627
+					}else{
1628
+						//$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1629
+						//$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1630
+						$html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1665 1631
 
1666
-        $table = $plugin_prefix . $post_type . '_detail';
1632
+					}
1667 1633
 
1668
-        if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1634
+				}
1635
+			}
1636
+		}
1637
+
1638
+		if (!empty($html) && $echo) {
1639
+			echo $html;
1640
+		} elseif (!empty($html)) {
1641
+			return $html;
1642
+		} else
1643
+			return false;
1644
+	}
1645
+}
1669 1646
 
1670
-            if ($taxonomy == $post_type . '_tags') {
1671
-                if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1672
-                    geodir_save_post_meta($post_id, 'post_tags', $terms);
1673
-                }
1674
-            } elseif ($taxonomy == $post_type . 'category') {
1675
-                $srcharr = array('"', '\\');
1676
-                $replarr = array("&quot;", '');
1647
+if (!function_exists('geodir_set_post_terms')) {
1648
+	/**
1649
+	 * Set post Categories.
1650
+	 *
1651
+	 * @since 1.0.0
1652
+	 * @package GeoDirectory
1653
+	 * @global object $wpdb WordPress Database object.
1654
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1655
+	 * @param int $post_id The post ID.
1656
+	 * @param array $terms An array of term objects.
1657
+	 * @param array $tt_ids An array of term taxonomy IDs.
1658
+	 * @param string $taxonomy Taxonomy slug.
1659
+	 */
1660
+	function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1661
+	{
1662
+		global $wpdb, $plugin_prefix;
1663
+
1664
+		$post_type = get_post_type($post_id);
1665
+
1666
+		$table = $plugin_prefix . $post_type . '_detail';
1667
+
1668
+		if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1669
+
1670
+			if ($taxonomy == $post_type . '_tags') {
1671
+				if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1672
+					geodir_save_post_meta($post_id, 'post_tags', $terms);
1673
+				}
1674
+			} elseif ($taxonomy == $post_type . 'category') {
1675
+				$srcharr = array('"', '\\');
1676
+				$replarr = array("&quot;", '');
1677 1677
 
1678
-                $post_obj = get_post($post_id);
1678
+				$post_obj = get_post($post_id);
1679 1679
 
1680
-                $cat_ids = array('0');
1681
-                if (is_array($tt_ids))
1682
-                    $cat_ids = $tt_ids;
1680
+				$cat_ids = array('0');
1681
+				if (is_array($tt_ids))
1682
+					$cat_ids = $tt_ids;
1683 1683
 
1684 1684
 
1685
-                if (!empty($cat_ids)) {
1686
-                    $cat_ids_array = $cat_ids;
1687
-                    $cat_ids_length = count($cat_ids_array);
1688
-                    $cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1689
-                    $format = implode(',', $cat_ids_format);
1685
+				if (!empty($cat_ids)) {
1686
+					$cat_ids_array = $cat_ids;
1687
+					$cat_ids_length = count($cat_ids_array);
1688
+					$cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1689
+					$format = implode(',', $cat_ids_format);
1690 1690
 
1691
-                    $cat_ids_array_del = $cat_ids_array;
1692
-                    $cat_ids_array_del[] = $post_id;
1691
+					$cat_ids_array_del = $cat_ids_array;
1692
+					$cat_ids_array_del[] = $post_id;
1693 1693
 
1694
-                    $wpdb->get_var(
1695
-                        $wpdb->prepare(
1696
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1697
-                            $cat_ids_array_del
1698
-                        )
1699
-                    );
1694
+					$wpdb->get_var(
1695
+						$wpdb->prepare(
1696
+							"DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1697
+							$cat_ids_array_del
1698
+						)
1699
+					);
1700 1700
 
1701 1701
 
1702
-                    $post_term = $wpdb->get_col(
1703
-                        $wpdb->prepare(
1704
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1705
-                            $cat_ids_array
1706
-                        )
1707
-                    );
1702
+					$post_term = $wpdb->get_col(
1703
+						$wpdb->prepare(
1704
+							"SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1705
+							$cat_ids_array
1706
+						)
1707
+					);
1708 1708
 
1709
-                }
1709
+				}
1710 1710
 
1711
-                $post_marker_json = '';
1711
+				$post_marker_json = '';
1712 1712
 
1713
-                if (!empty($post_term)):
1713
+				if (!empty($post_term)):
1714 1714
 
1715
-                    foreach ($post_term as $cat_id):
1715
+					foreach ($post_term as $cat_id):
1716 1716
 
1717
-                        $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1718
-                        $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1717
+						$term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1718
+						$term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1719 1719
 
1720
-                        $post_title = $post_obj->title;
1721
-                        $title = str_replace($srcharr, $replarr, $post_title);
1720
+						$post_title = $post_obj->title;
1721
+						$title = str_replace($srcharr, $replarr, $post_title);
1722 1722
 
1723
-                        $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1724
-                        $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1723
+						$lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1724
+						$lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1725 1725
 
1726
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1727
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1726
+						$timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1727
+						$timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1728 1728
 
1729
-                        $json = '{';
1730
-                        $json .= '"id":"' . $post_id . '",';
1731
-                        $json .= '"lat_pos": "' . $lat . '",';
1732
-                        $json .= '"long_pos": "' . $lng . '",';
1733
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1734
-                        $json .= '"icon":"' . $term_icon . '",';
1735
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1736
-                        $json .= '}';
1729
+						$json = '{';
1730
+						$json .= '"id":"' . $post_id . '",';
1731
+						$json .= '"lat_pos": "' . $lat . '",';
1732
+						$json .= '"long_pos": "' . $lng . '",';
1733
+						$json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1734
+						$json .= '"icon":"' . $term_icon . '",';
1735
+						$json .= '"group":"catgroup' . $cat_id . '"';
1736
+						$json .= '}';
1737 1737
 
1738 1738
 
1739
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1740
-                            $post_marker_json = $json;
1739
+						if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1740
+							$post_marker_json = $json;
1741 1741
 
1742 1742
 
1743
-                        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)))) {
1743
+						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)))) {
1744 1744
 
1745
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1745
+							$json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1746 1746
 										post_title = %s,
1747 1747
 										json = %s
1748 1748
 										WHERE post_id = %d AND cat_id = %d ",
1749
-                                array($post_title, $json, $post_id, $cat_id));
1749
+								array($post_title, $json, $post_id, $cat_id));
1750 1750
 
1751
-                        } else {
1751
+						} else {
1752 1752
 
1753
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1753
+							$json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1754 1754
 										post_id = %d,
1755 1755
 										post_title = %s,
1756 1756
 										cat_id = %d,
1757 1757
 										json = %s",
1758
-                                array($post_id, $post_title, $cat_id, $json));
1758
+								array($post_id, $post_title, $cat_id, $json));
1759 1759
 
1760
-                        }
1760
+						}
1761 1761
 
1762
-                        $wpdb->query($json_query);
1762
+						$wpdb->query($json_query);
1763 1763
 
1764
-                    endforeach;
1764
+					endforeach;
1765 1765
 
1766
-                endif;
1766
+				endif;
1767 1767
 
1768
-                if (!empty($post_term) && is_array($post_term)) {
1769
-                    $categories = implode(',', $post_term);
1768
+				if (!empty($post_term) && is_array($post_term)) {
1769
+					$categories = implode(',', $post_term);
1770 1770
 
1771
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1771
+					if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1772 1772
 
1773
-                    if (empty($post_marker_json))
1774
-                        $post_marker_json = isset($json) ? $json : '';
1773
+					if (empty($post_marker_json))
1774
+						$post_marker_json = isset($json) ? $json : '';
1775 1775
 
1776
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1776
+					if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1777 1777
 
1778
-                        $wpdb->query(
1779
-                            $wpdb->prepare(
1780
-                                "UPDATE " . $table . " SET
1778
+						$wpdb->query(
1779
+							$wpdb->prepare(
1780
+								"UPDATE " . $table . " SET
1781 1781
 								" . $taxonomy . " = %s,
1782 1782
 								marker_json = %s
1783 1783
 								where post_id = %d",
1784
-                                array($categories, $post_marker_json, $post_id)
1785
-                            )
1786
-                        );
1784
+								array($categories, $post_marker_json, $post_id)
1785
+							)
1786
+						);
1787 1787
 
1788
-                        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1788
+						if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1789 1789
 
1790
-                            $categories = trim($categories, ',');
1790
+							$categories = trim($categories, ',');
1791 1791
 
1792
-                            if ($categories) {
1792
+							if ($categories) {
1793 1793
 
1794
-                                $categories = explode(',', $categories);
1794
+								$categories = explode(',', $categories);
1795 1795
 
1796
-                                $default_category = geodir_get_post_meta($post_id, 'default_category', true);
1796
+								$default_category = geodir_get_post_meta($post_id, 'default_category', true);
1797 1797
 
1798
-                                if (!in_array($default_category, $categories)) {
1798
+								if (!in_array($default_category, $categories)) {
1799 1799
 
1800
-                                    $wpdb->query(
1801
-                                        $wpdb->prepare(
1802
-                                            "UPDATE " . $table . " SET
1800
+									$wpdb->query(
1801
+										$wpdb->prepare(
1802
+											"UPDATE " . $table . " SET
1803 1803
 											default_category = %s
1804 1804
 											where post_id = %d",
1805
-                                            array($categories[0], $post_id)
1806
-                                        )
1807
-                                    );
1805
+											array($categories[0], $post_id)
1806
+										)
1807
+									);
1808 1808
 
1809
-                                    $default_category = $categories[0];
1809
+									$default_category = $categories[0];
1810 1810
 
1811
-                                }
1811
+								}
1812 1812
 
1813
-                                if ($default_category == '')
1814
-                                    $default_category = $categories[0];
1813
+								if ($default_category == '')
1814
+									$default_category = $categories[0];
1815 1815
 
1816
-                                geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1816
+								geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1817 1817
 
1818
-                            }
1818
+							}
1819 1819
 
1820
-                        }
1820
+						}
1821 1821
 
1822 1822
 
1823
-                    } else {
1823
+					} else {
1824 1824
 
1825
-                        $wpdb->query(
1826
-                            $wpdb->prepare(
1827
-                                "INSERT INTO " . $table . " SET
1825
+						$wpdb->query(
1826
+							$wpdb->prepare(
1827
+								"INSERT INTO " . $table . " SET
1828 1828
 								post_id = %d,
1829 1829
 								" . $taxonomy . " = %s,
1830 1830
 								marker_json = %s ",
1831 1831
 
1832
-                                array($post_id, $categories, $post_marker_json)
1833
-                            )
1834
-                        );
1835
-                    }
1836
-                }
1837
-            }
1838
-        }
1839
-    }
1832
+								array($post_id, $categories, $post_marker_json)
1833
+							)
1834
+						);
1835
+					}
1836
+				}
1837
+			}
1838
+		}
1839
+	}
1840 1840
 }
1841 1841
 
1842 1842
 if (!function_exists('geodir_get_infowindow_html')) {
1843
-    /**
1844
-     * Set post Map Marker info html.
1845
-     *
1846
-     * @since 1.0.0
1847
-     * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1848
-     * @since 1.6.16 Changes for disable review stars for certain post type.
1849
-     * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info.
1850
-     * @package GeoDirectory
1851
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
1852
-     * @global object $gd_session GeoDirectory Session object.
1853
-     * @param object $postinfo_obj The post details object.
1854
-     * @param string $post_preview Is this a post preview?.
1855
-     * @global object $post WordPress Post object.
1856
-     * @return mixed|string|void
1857
-     */
1858
-    function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
1859
-        global $preview, $post, $gd_session;
1860
-        $srcharr = array("'", "/", "-", '"', '\\');
1861
-        $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1862
-
1863
-        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1864
-            $ID = '';
1865
-            $plink = '';
1866
-
1867
-            if (isset($postinfo_obj->pid)) {
1868
-                $ID = $postinfo_obj->pid;
1869
-                $plink = get_permalink($ID);
1870
-            }
1871
-
1872
-            $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1873
-            $lat = $postinfo_obj->post_latitude;
1874
-            $lng = $postinfo_obj->post_longitude;
1875
-        } else {
1876
-            $ID = $postinfo_obj->post_id;
1877
-            $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1878
-            $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1879
-            $plink = get_permalink($ID);
1880
-            $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1881
-            $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1882
-        }
1843
+	/**
1844
+	 * Set post Map Marker info html.
1845
+	 *
1846
+	 * @since 1.0.0
1847
+	 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1848
+	 * @since 1.6.16 Changes for disable review stars for certain post type.
1849
+	 * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info.
1850
+	 * @package GeoDirectory
1851
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
1852
+	 * @global object $gd_session GeoDirectory Session object.
1853
+	 * @param object $postinfo_obj The post details object.
1854
+	 * @param string $post_preview Is this a post preview?.
1855
+	 * @global object $post WordPress Post object.
1856
+	 * @return mixed|string|void
1857
+	 */
1858
+	function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
1859
+		global $preview, $post, $gd_session;
1860
+		$srcharr = array("'", "/", "-", '"', '\\');
1861
+		$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1862
+
1863
+		if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1864
+			$ID = '';
1865
+			$plink = '';
1866
+
1867
+			if (isset($postinfo_obj->pid)) {
1868
+				$ID = $postinfo_obj->pid;
1869
+				$plink = get_permalink($ID);
1870
+			}
1871
+
1872
+			$title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1873
+			$lat = $postinfo_obj->post_latitude;
1874
+			$lng = $postinfo_obj->post_longitude;
1875
+		} else {
1876
+			$ID = $postinfo_obj->post_id;
1877
+			$title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1878
+			$title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1879
+			$plink = get_permalink($ID);
1880
+			$lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1881
+			$lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1882
+		}
1883 1883
         
1884
-        // Some theme overwrites global gd listing $post
1885
-        if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
1886
-            $post = geodir_get_post_info($ID);
1887
-        }
1884
+		// Some theme overwrites global gd listing $post
1885
+		if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
1886
+			$post = geodir_get_post_info($ID);
1887
+		}
1888 1888
         
1889
-        $post_type = $ID ? get_post_type($ID) : '';
1890
-
1891
-        // filter field as per price package
1892
-        global $geodir_addon_list;
1893
-        if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1894
-            $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1895
-            $field_name = 'geodir_contact';
1896
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1897
-                $contact = '';
1898
-            }
1899
-
1900
-            $field_name = 'geodir_timing';
1901
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1902
-                $timing = '';
1903
-            }
1904
-        }
1905
-
1906
-        if ($lat && $lng) {
1907
-            ob_start(); ?>
1889
+		$post_type = $ID ? get_post_type($ID) : '';
1890
+
1891
+		// filter field as per price package
1892
+		global $geodir_addon_list;
1893
+		if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1894
+			$package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1895
+			$field_name = 'geodir_contact';
1896
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1897
+				$contact = '';
1898
+			}
1899
+
1900
+			$field_name = 'geodir_timing';
1901
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1902
+				$timing = '';
1903
+			}
1904
+		}
1905
+
1906
+		if ($lat && $lng) {
1907
+			ob_start(); ?>
1908 1908
             <div class="gd-bubble" style="">
1909 1909
                 <div class="gd-bubble-inside">
1910 1910
                     <?php
1911
-                    $comment_count = '';
1912
-                    $rating_star = '';
1913
-                    if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1914
-                        $rating_star = '';
1915
-                        $comment_count = geodir_get_review_count_total($ID);
1916
-
1917
-                        if (!$preview) {
1918
-                            $post_avgratings = geodir_get_post_rating($ID);
1919
-
1920
-                            $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1921
-
1922
-                            /**
1923
-                             * Filter to change rating stars
1924
-                             *
1925
-                             * You can use this filter to change Rating stars.
1926
-                             *
1927
-                             * @since 1.0.0
1928
-                             * @package GeoDirectory
1929
-                             * @param string $rating_star Rating stars.
1930
-                             * @param float $post_avgratings Average ratings of the post.
1931
-                             * @param int $ID The post ID.
1932
-                             */
1933
-                            $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1934
-                        }
1935
-                    }
1936
-                    ?>
1911
+					$comment_count = '';
1912
+					$rating_star = '';
1913
+					if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1914
+						$rating_star = '';
1915
+						$comment_count = geodir_get_review_count_total($ID);
1916
+
1917
+						if (!$preview) {
1918
+							$post_avgratings = geodir_get_post_rating($ID);
1919
+
1920
+							$rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1921
+
1922
+							/**
1923
+							 * Filter to change rating stars
1924
+							 *
1925
+							 * You can use this filter to change Rating stars.
1926
+							 *
1927
+							 * @since 1.0.0
1928
+							 * @package GeoDirectory
1929
+							 * @param string $rating_star Rating stars.
1930
+							 * @param float $post_avgratings Average ratings of the post.
1931
+							 * @param int $ID The post ID.
1932
+							 */
1933
+							$rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1934
+						}
1935
+					}
1936
+					?>
1937 1937
                     <div class="geodir-bubble_desc">
1938 1938
                         <h4>
1939 1939
                             <a href="<?php if ($plink != '') {
1940
-                                echo $plink;
1941
-                            } else {
1942
-                                echo 'javascript:void(0);';
1943
-                            } ?>"><?php echo $title; ?></a>
1940
+								echo $plink;
1941
+							} else {
1942
+								echo 'javascript:void(0);';
1943
+							} ?>"><?php echo $title; ?></a>
1944 1944
                         </h4>
1945 1945
                         <?php
1946
-                        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1947
-                            $post_images = array();
1948
-                            if (!empty($postinfo_obj->post_images)) {
1949
-                                $post_images = explode(",", $postinfo_obj->post_images);
1950
-                            }
1951
-
1952
-                            if (!empty($post_images)) {
1953
-                                ?>
1946
+						if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1947
+							$post_images = array();
1948
+							if (!empty($postinfo_obj->post_images)) {
1949
+								$post_images = explode(",", $postinfo_obj->post_images);
1950
+							}
1951
+
1952
+							if (!empty($post_images)) {
1953
+								?>
1954 1954
                                 <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
1955
-                                        echo $plink;
1956
-                                    } else {
1957
-                                        echo 'javascript:void(0);';
1958
-                                    } ?>"><img alt="bubble image" style="max-height:50px;"
1955
+										echo $plink;
1956
+									} else {
1957
+										echo 'javascript:void(0);';
1958
+									} ?>"><img alt="bubble image" style="max-height:50px;"
1959 1959
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1960 1960
                             <?php
1961
-                            }else{
1962
-                                echo '<div class="geodir-bubble_image"></div>';
1963
-                            }
1964
-                        } else {
1965
-                            if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1966
-                                ?>
1961
+							}else{
1962
+								echo '<div class="geodir-bubble_image"></div>';
1963
+							}
1964
+						} else {
1965
+							if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1966
+								?>
1967 1967
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1968 1968
                             <?php
1969
-                            }else{
1970
-                                echo '<div class="geodir-bubble_image"></div>';
1971
-                            }
1972
-                        }
1973
-                        ?>
1969
+							}else{
1970
+								echo '<div class="geodir-bubble_image"></div>';
1971
+							}
1972
+						}
1973
+						?>
1974 1974
                         <div class="geodir-bubble-meta-side">
1975 1975
                             <?php
1976
-                            /**
1977
-                             * Fires before the meta info in the map info window.
1978
-                             *
1979
-                             * This can be used to add more info to the map info window before the normal meta info.
1980
-                             *
1981
-                             * @since 1.5.4
1982
-                             * @param int $ID The post id.
1983
-                             * @param object $postinfo_obj The posts info as an object.
1984
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1985
-                             */
1986
-                            do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1987
-
1988
-                            echo geodir_show_listing_info('mapbubble');
1989
-
1990
-                            /**
1991
-                             * Fires after the meta info in the map info window.
1992
-                             *
1993
-                             * This can be used to add more info to the map info window after the normal meta info.
1994
-                             *
1995
-                             * @since 1.4.2
1996
-                             * @param object $postinfo_obj The posts info as an object.
1997
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1998
-                             */
1999
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2000
-                            ?>
1976
+							/**
1977
+							 * Fires before the meta info in the map info window.
1978
+							 *
1979
+							 * This can be used to add more info to the map info window before the normal meta info.
1980
+							 *
1981
+							 * @since 1.5.4
1982
+							 * @param int $ID The post id.
1983
+							 * @param object $postinfo_obj The posts info as an object.
1984
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1985
+							 */
1986
+							do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1987
+
1988
+							echo geodir_show_listing_info('mapbubble');
1989
+
1990
+							/**
1991
+							 * Fires after the meta info in the map info window.
1992
+							 *
1993
+							 * This can be used to add more info to the map info window after the normal meta info.
1994
+							 *
1995
+							 * @since 1.4.2
1996
+							 * @param object $postinfo_obj The posts info as an object.
1997
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1998
+							 */
1999
+							do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2000
+							?>
2001 2001
                         </div>
2002 2002
                         <?php
2003
-                        if ($ID) {
2004
-                            $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2005
-                            ?>
2003
+						if ($ID) {
2004
+							$post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2005
+							?>
2006 2006
                             <div class="geodir-bubble-meta-fade"></div>
2007 2007
                             <div class="geodir-bubble-meta-bottom">
2008 2008
                                 <?php if ($rating_star != '') { ?>
@@ -2018,69 +2018,69 @@  discard block
 block discarded – undo
2018 2018
                 </div>
2019 2019
             </div>
2020 2020
             <?php
2021
-            $html = ob_get_clean();
2022
-            /**
2023
-             * Filter to change infowindow html
2024
-             *
2025
-             * You can use this filter to change infowindow html.
2026
-             *
2027
-             * @since 1.0.0
2028
-             * @package GeoDirectory
2029
-             * @param string $html Infowindow html.
2030
-             * @param object $postinfo_obj The Post object.
2031
-             * @param bool|string $post_preview Is this a post preview?
2032
-             */
2033
-            $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2034
-            return $html;
2035
-        }
2036
-    }
2021
+			$html = ob_get_clean();
2022
+			/**
2023
+			 * Filter to change infowindow html
2024
+			 *
2025
+			 * You can use this filter to change infowindow html.
2026
+			 *
2027
+			 * @since 1.0.0
2028
+			 * @package GeoDirectory
2029
+			 * @param string $html Infowindow html.
2030
+			 * @param object $postinfo_obj The Post object.
2031
+			 * @param bool|string $post_preview Is this a post preview?
2032
+			 */
2033
+			$html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2034
+			return $html;
2035
+		}
2036
+	}
2037 2037
 }
2038 2038
 
2039 2039
 
2040 2040
 if (!function_exists('geodir_new_post_default_status')) {
2041
-    /**
2042
-     * Default post status for new posts.
2043
-     *
2044
-     * @since 1.0.0
2045
-     * @package GeoDirectory
2046
-     * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2047
-     */
2048
-    function geodir_new_post_default_status()
2049
-    {
2050
-        if (get_option('geodir_new_post_default_status'))
2051
-            return get_option('geodir_new_post_default_status');
2052
-        else
2053
-            return 'publish';
2054
-
2055
-    }
2041
+	/**
2042
+	 * Default post status for new posts.
2043
+	 *
2044
+	 * @since 1.0.0
2045
+	 * @package GeoDirectory
2046
+	 * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2047
+	 */
2048
+	function geodir_new_post_default_status()
2049
+	{
2050
+		if (get_option('geodir_new_post_default_status'))
2051
+			return get_option('geodir_new_post_default_status');
2052
+		else
2053
+			return 'publish';
2054
+
2055
+	}
2056 2056
 }
2057 2057
 
2058 2058
 if (!function_exists('geodir_change_post_status')) {
2059
-    /**
2060
-     * Change post status of a post.
2061
-     *
2062
-     * @global object $wpdb WordPress Database object.
2063
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2064
-     * @param int|string $post_id The post ID.
2065
-     * @param string $status New post status. Ex: draft, publish etc.
2066
-     */
2067
-    function geodir_change_post_status($post_id = '', $status = '')
2068
-    {
2069
-        global $wpdb, $plugin_prefix;
2070
-
2071
-        $post_type = get_post_type($post_id);
2072
-
2073
-        $table = $plugin_prefix . $post_type . '_detail';
2074
-
2075
-        $wpdb->query(
2076
-            $wpdb->prepare(
2077
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2078
-                array($status, $post_id)
2079
-            )
2080
-        );
2081
-
2082
-
2083
-    }
2059
+	/**
2060
+	 * Change post status of a post.
2061
+	 *
2062
+	 * @global object $wpdb WordPress Database object.
2063
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2064
+	 * @param int|string $post_id The post ID.
2065
+	 * @param string $status New post status. Ex: draft, publish etc.
2066
+	 */
2067
+	function geodir_change_post_status($post_id = '', $status = '')
2068
+	{
2069
+		global $wpdb, $plugin_prefix;
2070
+
2071
+		$post_type = get_post_type($post_id);
2072
+
2073
+		$table = $plugin_prefix . $post_type . '_detail';
2074
+
2075
+		$wpdb->query(
2076
+			$wpdb->prepare(
2077
+				"UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2078
+				array($status, $post_id)
2079
+			)
2080
+		);
2081
+
2082
+
2083
+	}
2084 2084
 }
2085 2085
 
2086 2086
 /**
@@ -2094,13 +2094,13 @@  discard block
 block discarded – undo
2094 2094
  */
2095 2095
 function geodir_set_post_status($pid, $status)
2096 2096
 {
2097
-    if ($pid) {
2098
-        global $wpdb;
2099
-        $my_post = array();
2100
-        $my_post['post_status'] = $status;
2101
-        $my_post['ID'] = $pid;
2102
-        $last_postid = wp_update_post($my_post);
2103
-    }
2097
+	if ($pid) {
2098
+		global $wpdb;
2099
+		$my_post = array();
2100
+		$my_post['post_status'] = $status;
2101
+		$my_post['ID'] = $pid;
2102
+		$last_postid = wp_update_post($my_post);
2103
+	}
2104 2104
 }
2105 2105
 
2106 2106
 
@@ -2116,384 +2116,384 @@  discard block
 block discarded – undo
2116 2116
  */
2117 2117
 function geodir_update_poststatus($new_status, $old_status, $post)
2118 2118
 {
2119
-    global $wpdb;
2119
+	global $wpdb;
2120 2120
 
2121
-    $geodir_posttypes = geodir_get_posttypes();
2121
+	$geodir_posttypes = geodir_get_posttypes();
2122 2122
 
2123
-    if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2123
+	if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2124 2124
 
2125
-        geodir_change_post_status($post->ID, $new_status);
2126
-    }
2125
+		geodir_change_post_status($post->ID, $new_status);
2126
+	}
2127 2127
 }
2128 2128
 
2129 2129
 
2130 2130
 if (!function_exists('geodir_update_listing_info')) {
2131
-    /**
2132
-     * Update post info.
2133
-     *
2134
-     * @since 1.0.0
2135
-     * @package GeoDirectory
2136
-     * @global object $wpdb WordPress Database object.
2137
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2138
-     * @param int $updatingpost The updating post ID.
2139
-     * @param int $temppost The temporary post ID.
2140
-     * @todo fix post_id variable
2141
-     */
2142
-    function geodir_update_listing_info($updatingpost, $temppost)
2143
-    {
2144
-
2145
-        global $wpdb, $plugin_prefix;
2146
-
2147
-        $post_type = get_post_type($post_id);
2148
-
2149
-        $table = $plugin_prefix . $post_type . '_detail';
2150
-
2151
-        $wpdb->query(
2152
-            $wpdb->prepare(
2153
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2154
-                array($updatingpost, $temppost)
2155
-            )
2156
-        );
2157
-
2158
-        $wpdb->query(
2159
-            $wpdb->prepare(
2160
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2161
-                array($updatingpost, $temppost)
2162
-            )
2163
-        );
2164
-
2165
-        /* Update Attachments*/
2166
-
2167
-        $wpdb->query(
2168
-            $wpdb->prepare(
2169
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2170
-                array($updatingpost, $temppost)
2171
-            )
2172
-        );
2173
-
2174
-    }
2131
+	/**
2132
+	 * Update post info.
2133
+	 *
2134
+	 * @since 1.0.0
2135
+	 * @package GeoDirectory
2136
+	 * @global object $wpdb WordPress Database object.
2137
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2138
+	 * @param int $updatingpost The updating post ID.
2139
+	 * @param int $temppost The temporary post ID.
2140
+	 * @todo fix post_id variable
2141
+	 */
2142
+	function geodir_update_listing_info($updatingpost, $temppost)
2143
+	{
2144
+
2145
+		global $wpdb, $plugin_prefix;
2146
+
2147
+		$post_type = get_post_type($post_id);
2148
+
2149
+		$table = $plugin_prefix . $post_type . '_detail';
2150
+
2151
+		$wpdb->query(
2152
+			$wpdb->prepare(
2153
+				"UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2154
+				array($updatingpost, $temppost)
2155
+			)
2156
+		);
2157
+
2158
+		$wpdb->query(
2159
+			$wpdb->prepare(
2160
+				"UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2161
+				array($updatingpost, $temppost)
2162
+			)
2163
+		);
2164
+
2165
+		/* Update Attachments*/
2166
+
2167
+		$wpdb->query(
2168
+			$wpdb->prepare(
2169
+				"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2170
+				array($updatingpost, $temppost)
2171
+			)
2172
+		);
2173
+
2174
+	}
2175 2175
 }
2176 2176
 
2177 2177
 
2178 2178
 if (!function_exists('geodir_delete_listing_info')) {
2179
-    /**
2180
-     * Delete Listing info from details table for the given post id.
2181
-     *
2182
-     * @since 1.0.0
2183
-     * @package GeoDirectory
2184
-     * @global object $wpdb WordPress Database object.
2185
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2186
-     * @param int $deleted_postid The post ID.
2187
-     * @param bool $force Optional. Do you want to force delete it? Default: false.
2188
-     * @return bool|void
2189
-     */
2190
-    function geodir_delete_listing_info($deleted_postid, $force = false)
2191
-    {
2192
-        global $wpdb, $plugin_prefix;
2193
-
2194
-        // check for multisite deletions
2195
-        if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2196
-        } else {
2197
-            return;
2198
-        }
2199
-
2200
-        $post_type = get_post_type($deleted_postid);
2201
-
2202
-        $all_postypes = geodir_get_posttypes();
2203
-
2204
-        if (!in_array($post_type, $all_postypes))
2205
-            return false;
2206
-
2207
-        $table = $plugin_prefix . $post_type . '_detail';
2208
-
2209
-        /* Delete custom post meta*/
2210
-        $wpdb->query(
2211
-            $wpdb->prepare(
2212
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2213
-                array($deleted_postid)
2214
-            )
2215
-        );
2216
-
2217
-        /* Delete post map icons*/
2218
-
2219
-        $wpdb->query(
2220
-            $wpdb->prepare(
2221
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2222
-                array($deleted_postid)
2223
-            )
2224
-        );
2225
-
2226
-        /* Delete Attachments*/
2227
-        $postcurr_images = geodir_get_images($deleted_postid);
2228
-
2229
-        $wpdb->query(
2230
-            $wpdb->prepare(
2231
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2232
-                array($deleted_postid)
2233
-            )
2234
-        );
2235
-        geodir_remove_attachments($postcurr_images);
2236
-
2237
-    }
2179
+	/**
2180
+	 * Delete Listing info from details table for the given post id.
2181
+	 *
2182
+	 * @since 1.0.0
2183
+	 * @package GeoDirectory
2184
+	 * @global object $wpdb WordPress Database object.
2185
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2186
+	 * @param int $deleted_postid The post ID.
2187
+	 * @param bool $force Optional. Do you want to force delete it? Default: false.
2188
+	 * @return bool|void
2189
+	 */
2190
+	function geodir_delete_listing_info($deleted_postid, $force = false)
2191
+	{
2192
+		global $wpdb, $plugin_prefix;
2193
+
2194
+		// check for multisite deletions
2195
+		if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2196
+		} else {
2197
+			return;
2198
+		}
2199
+
2200
+		$post_type = get_post_type($deleted_postid);
2201
+
2202
+		$all_postypes = geodir_get_posttypes();
2203
+
2204
+		if (!in_array($post_type, $all_postypes))
2205
+			return false;
2206
+
2207
+		$table = $plugin_prefix . $post_type . '_detail';
2208
+
2209
+		/* Delete custom post meta*/
2210
+		$wpdb->query(
2211
+			$wpdb->prepare(
2212
+				"DELETE FROM " . $table . " WHERE `post_id` = %d",
2213
+				array($deleted_postid)
2214
+			)
2215
+		);
2216
+
2217
+		/* Delete post map icons*/
2218
+
2219
+		$wpdb->query(
2220
+			$wpdb->prepare(
2221
+				"DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2222
+				array($deleted_postid)
2223
+			)
2224
+		);
2225
+
2226
+		/* Delete Attachments*/
2227
+		$postcurr_images = geodir_get_images($deleted_postid);
2228
+
2229
+		$wpdb->query(
2230
+			$wpdb->prepare(
2231
+				"DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2232
+				array($deleted_postid)
2233
+			)
2234
+		);
2235
+		geodir_remove_attachments($postcurr_images);
2236
+
2237
+	}
2238 2238
 }
2239 2239
 
2240 2240
 
2241 2241
 if (!function_exists('geodir_add_to_favorite')) {
2242
-    /**
2243
-     * This function would add listing to favorite listing.
2244
-     *
2245
-     * @since 1.0.0
2246
-     * @package GeoDirectory
2247
-     * @global object $current_user Current user object.
2248
-     * @param int $post_id The post ID.
2249
-     */
2250
-    function geodir_add_to_favorite($post_id)
2251
-    {
2252
-
2253
-        global $current_user;
2254
-
2255
-        /**
2256
-         * Filter to modify "Unfavorite" text
2257
-         *
2258
-         * You can use this filter to rename "Unfavorite" text to something else.
2259
-         *
2260
-         * @since 1.0.0
2261
-         * @package GeoDirectory
2262
-         */
2263
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2264
-
2265
-        /**
2266
-         * Filter to modify "Remove from Favorites" text
2267
-         *
2268
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2269
-         *
2270
-         * @since 1.0.0
2271
-         * @package GeoDirectory
2272
-         */
2273
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2274
-
2275
-        /**
2276
-         * Filter to modify "fa fa-heart" icon
2277
-         *
2278
-         * You can use this filter to change "fa fa-heart" icon to something else.
2279
-         *
2280
-         * @since 1.0.0
2281
-         * @package GeoDirectory
2282
-         */
2283
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2284
-
2285
-        $user_meta_data = array();
2286
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2287
-
2288
-        if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2289
-            $user_meta_data[] = $post_id;
2290
-        }
2291
-
2292
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2293
-
2294
-        /**
2295
-         * Called before adding the post from favourites.
2296
-         *
2297
-         * @since 1.0.0
2298
-         * @package GeoDirectory
2299
-         * @param int $post_id The post ID.
2300
-         */
2301
-        do_action('geodir_before_add_from_favorite', $post_id);
2302
-
2303
-        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>';
2242
+	/**
2243
+	 * This function would add listing to favorite listing.
2244
+	 *
2245
+	 * @since 1.0.0
2246
+	 * @package GeoDirectory
2247
+	 * @global object $current_user Current user object.
2248
+	 * @param int $post_id The post ID.
2249
+	 */
2250
+	function geodir_add_to_favorite($post_id)
2251
+	{
2252
+
2253
+		global $current_user;
2254
+
2255
+		/**
2256
+		 * Filter to modify "Unfavorite" text
2257
+		 *
2258
+		 * You can use this filter to rename "Unfavorite" text to something else.
2259
+		 *
2260
+		 * @since 1.0.0
2261
+		 * @package GeoDirectory
2262
+		 */
2263
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2264
+
2265
+		/**
2266
+		 * Filter to modify "Remove from Favorites" text
2267
+		 *
2268
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2269
+		 *
2270
+		 * @since 1.0.0
2271
+		 * @package GeoDirectory
2272
+		 */
2273
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2274
+
2275
+		/**
2276
+		 * Filter to modify "fa fa-heart" icon
2277
+		 *
2278
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2279
+		 *
2280
+		 * @since 1.0.0
2281
+		 * @package GeoDirectory
2282
+		 */
2283
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2284
+
2285
+		$user_meta_data = array();
2286
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2287
+
2288
+		if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2289
+			$user_meta_data[] = $post_id;
2290
+		}
2291
+
2292
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2293
+
2294
+		/**
2295
+		 * Called before adding the post from favourites.
2296
+		 *
2297
+		 * @since 1.0.0
2298
+		 * @package GeoDirectory
2299
+		 * @param int $post_id The post ID.
2300
+		 */
2301
+		do_action('geodir_before_add_from_favorite', $post_id);
2302
+
2303
+		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>';
2304
+
2305
+		/**
2306
+		 * Called after adding the post from favourites.
2307
+		 *
2308
+		 * @since 1.0.0
2309
+		 * @package GeoDirectory
2310
+		 * @param int $post_id The post ID.
2311
+		 */
2312
+		do_action('geodir_after_add_from_favorite', $post_id);
2304 2313
 
2305
-        /**
2306
-         * Called after adding the post from favourites.
2307
-         *
2308
-         * @since 1.0.0
2309
-         * @package GeoDirectory
2310
-         * @param int $post_id The post ID.
2311
-         */
2312
-        do_action('geodir_after_add_from_favorite', $post_id);
2313
-
2314
-    }
2314
+	}
2315 2315
 }
2316 2316
 
2317 2317
 if (!function_exists('geodir_remove_from_favorite')) {
2318
-    /**
2319
-     * This function would remove the favourited property earlier.
2320
-     *
2321
-     * @since 1.0.0
2322
-     * @package GeoDirectory
2323
-     * @global object $current_user Current user object.
2324
-     * @param int $post_id The post ID.
2325
-     */
2326
-    function geodir_remove_from_favorite($post_id)
2327
-    {
2328
-        global $current_user;
2329
-
2330
-        /**
2331
-         * Filter to modify "Add to Favorites" text
2332
-         *
2333
-         * You can use this filter to rename "Add to Favorites" text to something else.
2334
-         *
2335
-         * @since 1.0.0
2336
-         * @package GeoDirectory
2337
-         */
2338
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2339
-
2340
-        /**
2341
-         * Filter to modify "Favourite" text
2342
-         *
2343
-         * You can use this filter to rename "Favourite" text to something else.
2344
-         *
2345
-         * @since 1.0.0
2346
-         * @package GeoDirectory
2347
-         */
2348
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2349
-
2350
-        /**
2351
-         * Filter to modify "fa fa-heart" icon
2352
-         *
2353
-         * You can use this filter to change "fa fa-heart" icon to something else.
2354
-         *
2355
-         * @since 1.0.0
2356
-         * @package GeoDirectory
2357
-         */
2358
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2359
-
2360
-        $user_meta_data = array();
2361
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2362
-
2363
-        if (!empty($user_meta_data)) {
2318
+	/**
2319
+	 * This function would remove the favourited property earlier.
2320
+	 *
2321
+	 * @since 1.0.0
2322
+	 * @package GeoDirectory
2323
+	 * @global object $current_user Current user object.
2324
+	 * @param int $post_id The post ID.
2325
+	 */
2326
+	function geodir_remove_from_favorite($post_id)
2327
+	{
2328
+		global $current_user;
2329
+
2330
+		/**
2331
+		 * Filter to modify "Add to Favorites" text
2332
+		 *
2333
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2334
+		 *
2335
+		 * @since 1.0.0
2336
+		 * @package GeoDirectory
2337
+		 */
2338
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2339
+
2340
+		/**
2341
+		 * Filter to modify "Favourite" text
2342
+		 *
2343
+		 * You can use this filter to rename "Favourite" text to something else.
2344
+		 *
2345
+		 * @since 1.0.0
2346
+		 * @package GeoDirectory
2347
+		 */
2348
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2349
+
2350
+		/**
2351
+		 * Filter to modify "fa fa-heart" icon
2352
+		 *
2353
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2354
+		 *
2355
+		 * @since 1.0.0
2356
+		 * @package GeoDirectory
2357
+		 */
2358
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2359
+
2360
+		$user_meta_data = array();
2361
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2362
+
2363
+		if (!empty($user_meta_data)) {
2364
+
2365
+			if (($key = array_search($post_id, $user_meta_data)) !== false) {
2366
+				unset($user_meta_data[$key]);
2367
+			}
2364 2368
 
2365
-            if (($key = array_search($post_id, $user_meta_data)) !== false) {
2366
-                unset($user_meta_data[$key]);
2367
-            }
2369
+		}
2368 2370
 
2369
-        }
2371
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2370 2372
 
2371
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2373
+		/**
2374
+		 * Called before removing the post from favourites.
2375
+		 *
2376
+		 * @since 1.0.0
2377
+		 * @package GeoDirectory
2378
+		 * @param int $post_id The post ID.
2379
+		 */
2380
+		do_action('geodir_before_remove_from_favorite', $post_id);
2372 2381
 
2373
-        /**
2374
-         * Called before removing the post from favourites.
2375
-         *
2376
-         * @since 1.0.0
2377
-         * @package GeoDirectory
2378
-         * @param int $post_id The post ID.
2379
-         */
2380
-        do_action('geodir_before_remove_from_favorite', $post_id);
2382
+		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 2383
 
2382
-        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>';
2384
+		/**
2385
+		 * Called after removing the post from favourites.
2386
+		 *
2387
+		 * @since 1.0.0
2388
+		 * @package GeoDirectory
2389
+		 * @param int $post_id The post ID.
2390
+		 */
2391
+		do_action('geodir_after_remove_from_favorite', $post_id);
2383 2392
 
2384
-        /**
2385
-         * Called after removing the post from favourites.
2386
-         *
2387
-         * @since 1.0.0
2388
-         * @package GeoDirectory
2389
-         * @param int $post_id The post ID.
2390
-         */
2391
-        do_action('geodir_after_remove_from_favorite', $post_id);
2392
-
2393
-    }
2393
+	}
2394 2394
 }
2395 2395
 
2396 2396
 if (!function_exists('geodir_favourite_html')) {
2397
-    /**
2398
-     * This function would display the html content for add to favorite or remove from favorite.
2399
-     *
2400
-     * @since 1.0.0
2401
-     * @package GeoDirectory
2402
-     * @global object $current_user Current user object.
2403
-     * @global object $post The current post object.
2404
-     * @param int $user_id The user ID.
2405
-     * @param int $post_id The post ID.
2406
-     */
2407
-    function geodir_favourite_html($user_id, $post_id)
2408
-    {
2409
-
2410
-        global $current_user, $post;
2411
-
2412
-        /**
2413
-         * Filter to modify "Add to Favorites" text
2414
-         *
2415
-         * You can use this filter to rename "Add to Favorites" text to something else.
2416
-         *
2417
-         * @since 1.0.0
2418
-         * @package GeoDirectory
2419
-         */
2420
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2421
-
2422
-        /**
2423
-         * Filter to modify "Favourite" text
2424
-         *
2425
-         * You can use this filter to rename "Favourite" text to something else.
2426
-         *
2427
-         * @since 1.0.0
2428
-         * @package GeoDirectory
2429
-         */
2430
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2431
-
2432
-        /**
2433
-         * Filter to modify "Unfavorite" text
2434
-         *
2435
-         * You can use this filter to rename "Unfavorite" text to something else.
2436
-         *
2437
-         * @since 1.0.0
2438
-         * @package GeoDirectory
2439
-         */
2440
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2441
-
2442
-        /**
2443
-         * Filter to modify "Remove from Favorites" text
2444
-         *
2445
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2446
-         *
2447
-         * @since 1.0.0
2448
-         * @package GeoDirectory
2449
-         */
2450
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2451
-
2452
-        /**
2453
-         * Filter to modify "fa fa-heart" icon
2454
-         *
2455
-         * You can use this filter to change "fa fa-heart" icon to something else.
2456
-         *
2457
-         * @since 1.0.0
2458
-         * @package GeoDirectory
2459
-         */
2460
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2461
-
2462
-        /**
2463
-         * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2464
-         *
2465
-         * You can use this filter to change "fa fa-heart" icon to something else.
2466
-         *
2467
-         * @since 1.0.0
2468
-         * @package GeoDirectory
2469
-         */
2470
-        $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2471
-
2472
-        $user_meta_data = '';
2473
-        if (isset($current_user->data->ID))
2474
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2475
-
2476
-        if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2477
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2397
+	/**
2398
+	 * This function would display the html content for add to favorite or remove from favorite.
2399
+	 *
2400
+	 * @since 1.0.0
2401
+	 * @package GeoDirectory
2402
+	 * @global object $current_user Current user object.
2403
+	 * @global object $post The current post object.
2404
+	 * @param int $user_id The user ID.
2405
+	 * @param int $post_id The post ID.
2406
+	 */
2407
+	function geodir_favourite_html($user_id, $post_id)
2408
+	{
2409
+
2410
+		global $current_user, $post;
2411
+
2412
+		/**
2413
+		 * Filter to modify "Add to Favorites" text
2414
+		 *
2415
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2416
+		 *
2417
+		 * @since 1.0.0
2418
+		 * @package GeoDirectory
2419
+		 */
2420
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2421
+
2422
+		/**
2423
+		 * Filter to modify "Favourite" text
2424
+		 *
2425
+		 * You can use this filter to rename "Favourite" text to something else.
2426
+		 *
2427
+		 * @since 1.0.0
2428
+		 * @package GeoDirectory
2429
+		 */
2430
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2431
+
2432
+		/**
2433
+		 * Filter to modify "Unfavorite" text
2434
+		 *
2435
+		 * You can use this filter to rename "Unfavorite" text to something else.
2436
+		 *
2437
+		 * @since 1.0.0
2438
+		 * @package GeoDirectory
2439
+		 */
2440
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2441
+
2442
+		/**
2443
+		 * Filter to modify "Remove from Favorites" text
2444
+		 *
2445
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2446
+		 *
2447
+		 * @since 1.0.0
2448
+		 * @package GeoDirectory
2449
+		 */
2450
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2451
+
2452
+		/**
2453
+		 * Filter to modify "fa fa-heart" icon
2454
+		 *
2455
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2456
+		 *
2457
+		 * @since 1.0.0
2458
+		 * @package GeoDirectory
2459
+		 */
2460
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2461
+
2462
+		/**
2463
+		 * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2464
+		 *
2465
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2466
+		 *
2467
+		 * @since 1.0.0
2468
+		 * @package GeoDirectory
2469
+		 */
2470
+		$unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2471
+
2472
+		$user_meta_data = '';
2473
+		if (isset($current_user->data->ID))
2474
+			$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2475
+
2476
+		if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2477
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2478 2478
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2479 2479
                 onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2480 2480
                 title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2481 2481
             </a>   </span><?php
2482 2482
 
2483
-        } else {
2483
+		} else {
2484 2484
 
2485
-            if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2486
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2487
-            } else
2488
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2485
+			if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2486
+				$script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2487
+			} else
2488
+				$script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2489 2489
 
2490
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2490
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2491 2491
                                                                                         href="javascript:void(0);"
2492 2492
                                                                                         onclick="<?php echo $script_text;?>"
2493 2493
                                                                                         title="<?php echo $add_favourite_text;?>"><i
2494 2494
                     class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2495 2495
         <?php }
2496
-    }
2496
+	}
2497 2497
 }
2498 2498
 
2499 2499
 
@@ -2510,54 +2510,54 @@  discard block
 block discarded – undo
2510 2510
 function geodir_get_cat_postcount($term = array())
2511 2511
 {
2512 2512
 
2513
-    if (!empty($term)) {
2513
+	if (!empty($term)) {
2514 2514
 
2515
-        global $wpdb, $plugin_prefix;
2515
+		global $wpdb, $plugin_prefix;
2516 2516
 
2517
-        $where = '';
2518
-        $join = '';
2519
-        if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2520
-            $taxonomy_obj = get_taxonomy($term->taxonomy);
2517
+		$where = '';
2518
+		$join = '';
2519
+		if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2520
+			$taxonomy_obj = get_taxonomy($term->taxonomy);
2521 2521
 
2522
-            $post_type = $taxonomy_obj->object_type[0];
2522
+			$post_type = $taxonomy_obj->object_type[0];
2523 2523
 
2524
-            $table = $plugin_prefix . $post_type . '_detail';
2524
+			$table = $plugin_prefix . $post_type . '_detail';
2525 2525
 
2526
-            /**
2527
-             * Filter to modify the 'join' query
2528
-             *
2529
-             * @since 1.0.0
2530
-             * @package GeoDirectory
2531
-             * @param object|array $term category / term object that need to be processed.
2532
-             * @param string $join The join query.
2533
-             */
2534
-            $join = apply_filters('geodir_cat_post_count_join', $join, $term);
2526
+			/**
2527
+			 * Filter to modify the 'join' query
2528
+			 *
2529
+			 * @since 1.0.0
2530
+			 * @package GeoDirectory
2531
+			 * @param object|array $term category / term object that need to be processed.
2532
+			 * @param string $join The join query.
2533
+			 */
2534
+			$join = apply_filters('geodir_cat_post_count_join', $join, $term);
2535 2535
 
2536
-            /**
2537
-             * Filter to modify the 'where' query
2538
-             *
2539
-             * @since 1.0.0
2540
-             * @package GeoDirectory
2541
-             * @param object|array $term category / term object that need to be processed.
2542
-             * @param string $where The where query.
2543
-             */
2544
-            $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2536
+			/**
2537
+			 * Filter to modify the 'where' query
2538
+			 *
2539
+			 * @since 1.0.0
2540
+			 * @package GeoDirectory
2541
+			 * @param object|array $term category / term object that need to be processed.
2542
+			 * @param string $where The where query.
2543
+			 */
2544
+			$where = apply_filters('geodir_cat_post_count_where', $where, $term);
2545 2545
 
2546
-            $count_query = "SELECT count(post_id) FROM
2546
+			$count_query = "SELECT count(post_id) FROM
2547 2547
 							" . $table . " as pd " . $join . "
2548 2548
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2549 2549
 
2550
-            $cat_post_count = $wpdb->get_var($count_query);
2551
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2552
-                $cat_post_count = 0;
2550
+			$cat_post_count = $wpdb->get_var($count_query);
2551
+			if (empty($cat_post_count) || is_wp_error($cat_post_count))
2552
+				$cat_post_count = 0;
2553 2553
 
2554
-            return $cat_post_count;
2554
+			return $cat_post_count;
2555 2555
 
2556
-        } else
2556
+		} else
2557 2557
 
2558
-            return $term->count;
2559
-    }
2560
-    return false;
2558
+			return $term->count;
2559
+	}
2560
+	return false;
2561 2561
 
2562 2562
 }
2563 2563
 
@@ -2570,17 +2570,17 @@  discard block
 block discarded – undo
2570 2570
  */
2571 2571
 function geodir_allow_post_type_frontend()
2572 2572
 {
2573
-    $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2573
+	$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2574 2574
 
2575
-    if (!is_admin() && isset($_REQUEST['listing_type'])
2576
-        && !empty($geodir_allow_posttype_frontend)
2577
-        && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2578
-    ) {
2575
+	if (!is_admin() && isset($_REQUEST['listing_type'])
2576
+		&& !empty($geodir_allow_posttype_frontend)
2577
+		&& !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2578
+	) {
2579 2579
 
2580
-        wp_redirect(home_url());
2581
-        exit;
2580
+		wp_redirect(home_url());
2581
+		exit;
2582 2582
 
2583
-    }
2583
+	}
2584 2584
 
2585 2585
 }
2586 2586
 
@@ -2597,20 +2597,20 @@  discard block
 block discarded – undo
2597 2597
  */
2598 2598
 function geodir_excerpt_length($length)
2599 2599
 {
2600
-    global $wp_query, $geodir_is_widget_listing;
2600
+	global $wp_query, $geodir_is_widget_listing;
2601 2601
 	if ($geodir_is_widget_listing) {
2602 2602
 		return $length;
2603 2603
 	}
2604 2604
 	
2605
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2606
-        $length = get_option('geodir_desc_word_limit');
2607
-    elseif (get_query_var('excerpt_length'))
2608
-        $length = get_query_var('excerpt_length');
2605
+	if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2606
+		$length = get_option('geodir_desc_word_limit');
2607
+	elseif (get_query_var('excerpt_length'))
2608
+		$length = get_query_var('excerpt_length');
2609 2609
 
2610
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2611
-        $length = get_option('geodir_author_desc_word_limit');
2610
+	if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2611
+		$length = get_option('geodir_author_desc_word_limit');
2612 2612
 
2613
-    return $length;
2613
+	return $length;
2614 2614
 }
2615 2615
 
2616 2616
 /**
@@ -2625,13 +2625,13 @@  discard block
 block discarded – undo
2625 2625
  */
2626 2626
 function geodir_excerpt_more($more)
2627 2627
 {
2628
-    global $post;
2629
-    $all_postypes = geodir_get_posttypes();
2630
-    if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2631
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2632
-    }
2628
+	global $post;
2629
+	$all_postypes = geodir_get_posttypes();
2630
+	if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2631
+		return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2632
+	}
2633 2633
 
2634
-    return $more;
2634
+	return $more;
2635 2635
 }
2636 2636
 
2637 2637
 
@@ -2648,63 +2648,63 @@  discard block
 block discarded – undo
2648 2648
  */
2649 2649
 function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
2650 2650
 {
2651
-    global $plugin_prefix, $wpdb;
2651
+	global $plugin_prefix, $wpdb;
2652 2652
 
2653
-    $gd_taxonomies = geodir_get_taxonomies();
2653
+	$gd_taxonomies = geodir_get_taxonomies();
2654 2654
 
2655
-    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2655
+	if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2656 2656
 
2657
-        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2658
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2657
+		$geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2658
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
2659 2659
 
2660
-        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2661
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2660
+		$path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2661
+		$term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2662 2662
 
2663
-        $posts = $wpdb->get_results(
2664
-            $wpdb->prepare(
2665
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2666
-                array($term_id, $taxonomy)
2667
-            )
2668
-        );
2663
+		$posts = $wpdb->get_results(
2664
+			$wpdb->prepare(
2665
+				"SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2666
+				array($term_id, $taxonomy)
2667
+			)
2668
+		);
2669 2669
 
2670
-        if (!empty($posts)):
2671
-            foreach ($posts as $post_obj) {
2670
+		if (!empty($posts)):
2671
+			foreach ($posts as $post_obj) {
2672 2672
 
2673
-                $lat = $post_obj->post_latitude;
2674
-                $lng = $post_obj->post_longitude;
2673
+				$lat = $post_obj->post_latitude;
2674
+				$lng = $post_obj->post_longitude;
2675 2675
 
2676
-                $json = '{';
2677
-                $json .= '"id":"' . $post_obj->post_id . '",';
2678
-                $json .= '"lat_pos": "' . $lat . '",';
2679
-                $json .= '"long_pos": "' . $lng . '",';
2680
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2681
-                $json .= '"icon":"' . $term_icon . '",';
2682
-                $json .= '"group":"catgroup' . $term_id . '"';
2683
-                $json .= '}';
2676
+				$json = '{';
2677
+				$json .= '"id":"' . $post_obj->post_id . '",';
2678
+				$json .= '"lat_pos": "' . $lat . '",';
2679
+				$json .= '"long_pos": "' . $lng . '",';
2680
+				$json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2681
+				$json .= '"icon":"' . $term_icon . '",';
2682
+				$json .= '"group":"catgroup' . $term_id . '"';
2683
+				$json .= '}';
2684 2684
 
2685
-                if ($post_obj->default_category == $term_id) {
2685
+				if ($post_obj->default_category == $term_id) {
2686 2686
 
2687
-                    $wpdb->query(
2688
-                        $wpdb->prepare(
2689
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2690
-                            array($json, $post_obj->post_id)
2691
-                        )
2692
-                    );
2693
-                }
2687
+					$wpdb->query(
2688
+						$wpdb->prepare(
2689
+							"UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2690
+							array($json, $post_obj->post_id)
2691
+						)
2692
+					);
2693
+				}
2694 2694
 
2695
-                $wpdb->query(
2696
-                    $wpdb->prepare(
2697
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2698
-                        array($json, $post_obj->post_id, $term_id)
2699
-                    )
2700
-                );
2695
+				$wpdb->query(
2696
+					$wpdb->prepare(
2697
+						"UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2698
+						array($json, $post_obj->post_id, $term_id)
2699
+					)
2700
+				);
2701 2701
 
2702
-            }
2702
+			}
2703 2703
 
2704 2704
 
2705
-        endif;
2705
+		endif;
2706 2706
 
2707
-    }
2707
+	}
2708 2708
 
2709 2709
 }
2710 2710
 
@@ -2718,14 +2718,14 @@  discard block
 block discarded – undo
2718 2718
  */
2719 2719
 function geodir_get_listing_author($listing_id = '')
2720 2720
 {
2721
-    if ($listing_id == '') {
2722
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2723
-            $listing_id = $_REQUEST['pid'];
2724
-        }
2725
-    }
2726
-    $listing = get_post(strip_tags($listing_id));
2727
-    $listing_author_id = $listing->post_author;
2728
-    return $listing_author_id;
2721
+	if ($listing_id == '') {
2722
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2723
+			$listing_id = $_REQUEST['pid'];
2724
+		}
2725
+	}
2726
+	$listing = get_post(strip_tags($listing_id));
2727
+	$listing_author_id = $listing->post_author;
2728
+	return $listing_author_id;
2729 2729
 }
2730 2730
 
2731 2731
 
@@ -2740,11 +2740,11 @@  discard block
 block discarded – undo
2740 2740
  */
2741 2741
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2742 2742
 {
2743
-    $listing_author_id = geodir_get_listing_author($listing_id);
2744
-    if ($listing_author_id == $user_id)
2745
-        return true;
2746
-    else
2747
-        return false;
2743
+	$listing_author_id = geodir_get_listing_author($listing_id);
2744
+	if ($listing_author_id == $user_id)
2745
+		return true;
2746
+	else
2747
+		return false;
2748 2748
 
2749 2749
 }
2750 2750
 
@@ -2760,17 +2760,17 @@  discard block
 block discarded – undo
2760 2760
  */
2761 2761
 function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true)
2762 2762
 {
2763
-    global $current_user;
2764
-    if ($exclude_admin) {
2765
-        foreach ($current_user->caps as $key => $caps) {
2766
-            if (geodir_strtolower($key) == 'administrator') {
2767
-                return true;
2768
-                break;
2769
-            }
2770
-        }
2771
-    }
2772
-
2773
-    return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2763
+	global $current_user;
2764
+	if ($exclude_admin) {
2765
+		foreach ($current_user->caps as $key => $caps) {
2766
+			if (geodir_strtolower($key) == 'administrator') {
2767
+				return true;
2768
+				break;
2769
+			}
2770
+		}
2771
+	}
2772
+
2773
+	return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2774 2774
 }
2775 2775
 
2776 2776
 
@@ -2786,17 +2786,17 @@  discard block
 block discarded – undo
2786 2786
 function geodir_only_supportable_attachments_remove($file)
2787 2787
 {
2788 2788
 
2789
-    global $wpdb;
2789
+	global $wpdb;
2790 2790
 
2791
-    $matches = array();
2791
+	$matches = array();
2792 2792
 
2793
-    $pattern = '/-\d+x\d+\./';
2794
-    preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2793
+	$pattern = '/-\d+x\d+\./';
2794
+	preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2795 2795
 
2796
-    if (empty($matches))
2797
-        return '';
2798
-    else
2799
-        return $file;
2796
+	if (empty($matches))
2797
+		return '';
2798
+	else
2799
+		return $file;
2800 2800
 
2801 2801
 }
2802 2802
 
@@ -2813,78 +2813,78 @@  discard block
 block discarded – undo
2813 2813
 function geodir_set_wp_featured_image($post_id)
2814 2814
 {
2815 2815
 
2816
-    global $wpdb, $plugin_prefix;
2817
-    $uploads = wp_upload_dir();
2816
+	global $wpdb, $plugin_prefix;
2817
+	$uploads = wp_upload_dir();
2818 2818
 //	print_r($uploads ) ;
2819
-    $post_first_image = $wpdb->get_results(
2820
-        $wpdb->prepare(
2821
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2822
-        )
2823
-    );
2824
-
2825
-    $old_attachment_name = '';
2826
-    $post_thumbnail_id = '';
2827
-    if (has_post_thumbnail($post_id)) {
2819
+	$post_first_image = $wpdb->get_results(
2820
+		$wpdb->prepare(
2821
+			"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2822
+		)
2823
+	);
2828 2824
 
2829
-        if (has_post_thumbnail($post_id)) {
2825
+	$old_attachment_name = '';
2826
+	$post_thumbnail_id = '';
2827
+	if (has_post_thumbnail($post_id)) {
2830 2828
 
2831
-            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2829
+		if (has_post_thumbnail($post_id)) {
2832 2830
 
2833
-            $old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2831
+			$post_thumbnail_id = get_post_thumbnail_id($post_id);
2834 2832
 
2835
-        }
2836
-    }
2833
+			$old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2837 2834
 
2838
-    if (!empty($post_first_image)) {
2835
+		}
2836
+	}
2839 2837
 
2840
-        $post_type = get_post_type($post_id);
2838
+	if (!empty($post_first_image)) {
2841 2839
 
2842
-        $table_name = $plugin_prefix . $post_type . '_detail';
2840
+		$post_type = get_post_type($post_id);
2843 2841
 
2844
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2842
+		$table_name = $plugin_prefix . $post_type . '_detail';
2845 2843
 
2846
-        $new_attachment_name = basename($post_first_image[0]->file);
2844
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2847 2845
 
2848
-        if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2846
+		$new_attachment_name = basename($post_first_image[0]->file);
2849 2847
 
2850
-            if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2848
+		if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2851 2849
 
2852
-                add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2850
+			if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2853 2851
 
2854
-                wp_delete_attachment($post_thumbnail_id);
2852
+				add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2855 2853
 
2856
-            }
2857
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2854
+				wp_delete_attachment($post_thumbnail_id);
2858 2855
 
2859
-            $attachment = array(
2860
-                'post_mime_type' => $post_first_image[0]->mime_type,
2861
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2862
-                'post_parent' => $post_id,
2863
-                'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2864
-                'post_content' => ''
2865
-            );
2856
+			}
2857
+			$filename = $uploads['basedir'] . $post_first_image[0]->file;
2858
+
2859
+			$attachment = array(
2860
+				'post_mime_type' => $post_first_image[0]->mime_type,
2861
+				'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2862
+				'post_parent' => $post_id,
2863
+				'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2864
+				'post_content' => ''
2865
+			);
2866 2866
 
2867 2867
 
2868
-            $id = wp_insert_attachment($attachment, $filename, $post_id);
2868
+			$id = wp_insert_attachment($attachment, $filename, $post_id);
2869 2869
 
2870
-            if (!is_wp_error($id)) {
2870
+			if (!is_wp_error($id)) {
2871 2871
 
2872
-                set_post_thumbnail($post_id, $id);
2872
+				set_post_thumbnail($post_id, $id);
2873 2873
 
2874
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2875
-                wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2874
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
2875
+				wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2876 2876
 
2877
-            }
2877
+			}
2878 2878
 
2879
-        }
2879
+		}
2880 2880
 
2881
-    } else {
2882
-        //set_post_thumbnail($post_id,-1);
2881
+	} else {
2882
+		//set_post_thumbnail($post_id,-1);
2883 2883
 
2884
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2885
-            wp_delete_attachment($post_thumbnail_id);
2884
+		if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2885
+			wp_delete_attachment($post_thumbnail_id);
2886 2886
 
2887
-    }
2887
+	}
2888 2888
 }
2889 2889
 
2890 2890
 
@@ -2899,53 +2899,53 @@  discard block
 block discarded – undo
2899 2899
  */
2900 2900
 function gd_copy_original_translation()
2901 2901
 {
2902
-    if (function_exists('icl_object_id')) {
2903
-        global $wpdb, $table_prefix, $plugin_prefix;
2904
-        $post_id = absint($_POST['post_id']);
2905
-        $upload_dir = wp_upload_dir();
2906
-        $post_type = get_post_type($_POST['post_id']);
2907
-        $table = $plugin_prefix . $post_type . '_detail';
2908
-
2909
-        $post_arr = $wpdb->get_results($wpdb->prepare(
2910
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2911
-            array($post_id)
2912
-        )
2913
-            , ARRAY_A);
2914
-
2915
-        $arrImages = $wpdb->get_results(
2916
-            $wpdb->prepare(
2917
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2918
-                array('%image%', $post_id)
2919
-            )
2920
-        );
2921
-        if ($arrImages) {
2922
-            $image_arr = array();
2923
-            foreach ($arrImages as $img) {
2924
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2925
-            }
2926
-            $comma_separated = implode(",", $image_arr);
2927
-            $post_arr[0]['post_images'] = $comma_separated;
2928
-        }
2929
-
2930
-
2931
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2932
-        $cat_arr = array_filter(explode(",", $cats));
2933
-        $trans_cat = array();
2934
-        foreach ($cat_arr as $cat) {
2935
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2936
-        }
2937
-
2938
-
2939
-        $post_arr[0]['categories'] = array_filter($trans_cat);
2902
+	if (function_exists('icl_object_id')) {
2903
+		global $wpdb, $table_prefix, $plugin_prefix;
2904
+		$post_id = absint($_POST['post_id']);
2905
+		$upload_dir = wp_upload_dir();
2906
+		$post_type = get_post_type($_POST['post_id']);
2907
+		$table = $plugin_prefix . $post_type . '_detail';
2908
+
2909
+		$post_arr = $wpdb->get_results($wpdb->prepare(
2910
+			"SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2911
+			array($post_id)
2912
+		)
2913
+			, ARRAY_A);
2914
+
2915
+		$arrImages = $wpdb->get_results(
2916
+			$wpdb->prepare(
2917
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2918
+				array('%image%', $post_id)
2919
+			)
2920
+		);
2921
+		if ($arrImages) {
2922
+			$image_arr = array();
2923
+			foreach ($arrImages as $img) {
2924
+				$image_arr[] = $upload_dir['baseurl'] . $img->file;
2925
+			}
2926
+			$comma_separated = implode(",", $image_arr);
2927
+			$post_arr[0]['post_images'] = $comma_separated;
2928
+		}
2929
+
2930
+
2931
+		$cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2932
+		$cat_arr = array_filter(explode(",", $cats));
2933
+		$trans_cat = array();
2934
+		foreach ($cat_arr as $cat) {
2935
+			$trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2936
+		}
2937
+
2938
+
2939
+		$post_arr[0]['categories'] = array_filter($trans_cat);
2940 2940
 //print_r($image_arr);
2941
-        //print_r($arrImages);
2942
-        //echo $_REQUEST['lang'];
2941
+		//print_r($arrImages);
2942
+		//echo $_REQUEST['lang'];
2943 2943
 //print_r($post_arr);
2944 2944
 //print_r($trans_cat);
2945
-        echo json_encode($post_arr[0]);
2945
+		echo json_encode($post_arr[0]);
2946 2946
 
2947
-    }
2948
-    die();
2947
+	}
2948
+	die();
2949 2949
 }
2950 2950
 
2951 2951
 
@@ -2965,54 +2965,54 @@  discard block
 block discarded – undo
2965 2965
 function geodir_get_custom_fields_type($listing_type = '')
2966 2966
 {
2967 2967
 
2968
-    global $wpdb;
2968
+	global $wpdb;
2969 2969
 
2970
-    if ($listing_type == '')
2971
-        $listing_type = 'gd_place';
2970
+	if ($listing_type == '')
2971
+		$listing_type = 'gd_place';
2972 2972
 
2973
-    $fields_info = array();
2973
+	$fields_info = array();
2974 2974
 
2975
-    $get_data = $wpdb->get_results(
2976
-        $wpdb->prepare(
2977
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2978
-            array($listing_type)
2979
-        )
2980
-    );
2975
+	$get_data = $wpdb->get_results(
2976
+		$wpdb->prepare(
2977
+			"SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2978
+			array($listing_type)
2979
+		)
2980
+	);
2981 2981
 
2982
-    if (!empty($get_data)) {
2982
+	if (!empty($get_data)) {
2983 2983
 
2984
-        foreach ($get_data as $data) {
2984
+		foreach ($get_data as $data) {
2985 2985
 
2986
-            if ($data->field_type == 'address') {
2986
+			if ($data->field_type == 'address') {
2987 2987
 
2988
-                $extra_fields = unserialize($data->extra_fields);
2988
+				$extra_fields = unserialize($data->extra_fields);
2989 2989
 
2990
-                $prefix = $data->htmlvar_name . '_';
2990
+				$prefix = $data->htmlvar_name . '_';
2991 2991
 
2992
-                $fields_info[$prefix . 'address'] = $data->field_type;
2992
+				$fields_info[$prefix . 'address'] = $data->field_type;
2993 2993
 
2994
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2995
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
2994
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2995
+					$fields_info[$prefix . 'zip'] = $data->field_type;
2996 2996
 
2997
-            } else {
2997
+			} else {
2998 2998
 
2999
-                $fields_info[$data->htmlvar_name] = $data->field_type;
2999
+				$fields_info[$data->htmlvar_name] = $data->field_type;
3000 3000
 
3001
-            }
3001
+			}
3002 3002
 
3003
-        }
3003
+		}
3004 3004
 
3005
-    }
3005
+	}
3006 3006
 
3007
-    /**
3008
-     * Filter to modify custom fields info using listing post type.
3009
-     *
3010
-     * @since 1.0.0
3011
-     * @package GeoDirectory
3012
-     * @return array $fields_info Custom fields info.
3013
-     * @param string $listing_type The listing post type.
3014
-     */
3015
-    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3007
+	/**
3008
+	 * Filter to modify custom fields info using listing post type.
3009
+	 *
3010
+	 * @since 1.0.0
3011
+	 * @package GeoDirectory
3012
+	 * @return array $fields_info Custom fields info.
3013
+	 * @param string $listing_type The listing post type.
3014
+	 */
3015
+	return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3016 3016
 }
3017 3017
 
3018 3018
 
@@ -3027,58 +3027,58 @@  discard block
 block discarded – undo
3027 3027
  */
3028 3028
 function geodir_function_post_updated($post_ID, $post_after, $post_before)
3029 3029
 {
3030
-    $post_type = get_post_type($post_ID);
3030
+	$post_type = get_post_type($post_ID);
3031 3031
 
3032
-    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3033
-        // send notification to client when post moves from draft to publish
3034
-        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')) {
3035
-            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3036
-            $post_author_data = get_userdata($post_author_id);
3032
+	if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3033
+		// send notification to client when post moves from draft to publish
3034
+		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')) {
3035
+			$post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3036
+			$post_author_data = get_userdata($post_author_id);
3037 3037
 
3038
-            $to_name = geodir_get_client_name($post_author_id);
3038
+			$to_name = geodir_get_client_name($post_author_id);
3039 3039
 
3040
-            $from_email = geodir_get_site_email_id();
3041
-            $from_name = get_site_emailName();
3042
-            $to_email = $post_author_data->user_email;
3040
+			$from_email = geodir_get_site_email_id();
3041
+			$from_name = get_site_emailName();
3042
+			$to_email = $post_author_data->user_email;
3043 3043
 
3044
-            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3045
-                $to_email = $post_author_data->user_email;
3046
-            }
3044
+			if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3045
+				$to_email = $post_author_data->user_email;
3046
+			}
3047 3047
 
3048
-            $message_type = 'listing_published';
3048
+			$message_type = 'listing_published';
3049 3049
 
3050
-            if (get_option('geodir_post_published_email_subject') == '') {
3051
-                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3052
-            }
3050
+			if (get_option('geodir_post_published_email_subject') == '') {
3051
+				update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3052
+			}
3053 3053
 
3054
-            if (get_option('geodir_post_published_email_content') == '') {
3055
-                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'));
3056
-            }
3054
+			if (get_option('geodir_post_published_email_content') == '') {
3055
+				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'));
3056
+			}
3057 3057
 
3058
-            /**
3059
-             * Called before sending the email when listing gets published.
3060
-             *
3061
-             * @since 1.0.0
3062
-             * @package GeoDirectory
3063
-             * @param object $post_after The post object after update.
3064
-             * @param object $post_before The post object before update.
3065
-             */
3066
-            do_action('geodir_before_listing_published_email', $post_after, $post_before);
3067
-            if (is_email($to_email)) {
3068
-                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3069
-            }
3058
+			/**
3059
+			 * Called before sending the email when listing gets published.
3060
+			 *
3061
+			 * @since 1.0.0
3062
+			 * @package GeoDirectory
3063
+			 * @param object $post_after The post object after update.
3064
+			 * @param object $post_before The post object before update.
3065
+			 */
3066
+			do_action('geodir_before_listing_published_email', $post_after, $post_before);
3067
+			if (is_email($to_email)) {
3068
+				geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3069
+			}
3070 3070
 
3071
-            /**
3072
-             * Called after sending the email when listing gets published.
3073
-             *
3074
-             * @since 1.0.0
3075
-             * @package GeoDirectory
3076
-             * @param object $post_after The post object after update.
3077
-             * @param object $post_before The post object before update.
3078
-             */
3079
-            do_action('geodir_after_listing_published_email', $post_after, $post_before);
3080
-        }
3081
-    }
3071
+			/**
3072
+			 * Called after sending the email when listing gets published.
3073
+			 *
3074
+			 * @since 1.0.0
3075
+			 * @package GeoDirectory
3076
+			 * @param object $post_after The post object after update.
3077
+			 * @param object $post_before The post object before update.
3078
+			 */
3079
+			do_action('geodir_after_listing_published_email', $post_after, $post_before);
3080
+		}
3081
+	}
3082 3082
 }
3083 3083
 
3084 3084
 add_action('wp_head', 'geodir_fb_like_thumbnail');
@@ -3092,14 +3092,14 @@  discard block
 block discarded – undo
3092 3092
  */
3093 3093
 function geodir_fb_like_thumbnail(){
3094 3094
 
3095
-    // return if not a single post
3096
-    if(!is_single()){return;}
3095
+	// return if not a single post
3096
+	if(!is_single()){return;}
3097 3097
 
3098
-    global $post;
3099
-    if(isset($post->featured_image) && $post->featured_image){
3100
-        $upload_dir = wp_upload_dir();
3101
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3102
-        echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3098
+	global $post;
3099
+	if(isset($post->featured_image) && $post->featured_image){
3100
+		$upload_dir = wp_upload_dir();
3101
+		$thumb = $upload_dir['baseurl'].$post->featured_image;
3102
+		echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3103 3103
 
3104
-    }
3104
+	}
3105 3105
 }
3106 3106
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-admin/admin_functions.php 2 patches
Indentation   +2906 added lines, -2906 removed lines patch added patch discarded remove patch
@@ -13,125 +13,125 @@  discard block
 block discarded – undo
13 13
  * @package GeoDirectory
14 14
  */
15 15
 function geodir_deactivation() {
16
-    // Update installed variable
17
-    update_option("geodir_installed", 0);
16
+	// Update installed variable
17
+	update_option("geodir_installed", 0);
18 18
 
19
-    // Remove rewrite rules and then recreate rewrite rules.
20
-    flush_rewrite_rules();
19
+	// Remove rewrite rules and then recreate rewrite rules.
20
+	flush_rewrite_rules();
21 21
 }
22 22
 
23 23
 if (!function_exists('geodir_admin_styles')) {
24
-    /**
25
-     * Enqueue Admin Styles.
26
-     *
27
-     * @since 1.0.0
28
-     * @package GeoDirectory
29
-     */
30
-    function geodir_admin_styles() {
31
-        wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
32
-        wp_enqueue_style('geodirectory-admin-css');
24
+	/**
25
+	 * Enqueue Admin Styles.
26
+	 *
27
+	 * @since 1.0.0
28
+	 * @package GeoDirectory
29
+	 */
30
+	function geodir_admin_styles() {
31
+		wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
32
+		wp_enqueue_style('geodirectory-admin-css');
33 33
 
34
-        wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
35
-        wp_enqueue_style('geodirectory-frontend-style');
34
+		wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
35
+		wp_enqueue_style('geodirectory-frontend-style');
36 36
 
37
-        wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
38
-        wp_enqueue_style('geodir-chosen-style');
37
+		wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
38
+		wp_enqueue_style('geodir-chosen-style');
39 39
 
40
-        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
41
-        wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
40
+		wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
41
+		wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
42 42
 
43
-        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
44
-        wp_enqueue_style('geodirectory-jquery-ui-css');
43
+		wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
44
+		wp_enqueue_style('geodirectory-jquery-ui-css');
45 45
 
46
-        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
47
-        wp_enqueue_style('geodirectory-custom-fields-css');
46
+		wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
47
+		wp_enqueue_style('geodirectory-custom-fields-css');
48 48
 
49
-        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
50
-        wp_enqueue_style('geodirectory-pluplodar-css');
49
+		wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
50
+		wp_enqueue_style('geodirectory-pluplodar-css');
51 51
 
52
-        wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
53
-        wp_enqueue_style('geodir-rating-style');
52
+		wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
53
+		wp_enqueue_style('geodir-rating-style');
54 54
 
55
-        wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
56
-        wp_enqueue_style('geodir-rtl-style');
57
-    }
55
+		wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
56
+		wp_enqueue_style('geodir-rtl-style');
57
+	}
58 58
 }
59 59
 
60 60
 if (!function_exists('geodir_admin_styles_req')) {
61
-    /**
62
-     * Loads stylesheets from CDN.
63
-     *
64
-     * @since 1.0.0
65
-     * @package GeoDirectory
66
-     */
67
-    function geodir_admin_styles_req()
68
-    {
61
+	/**
62
+	 * Loads stylesheets from CDN.
63
+	 *
64
+	 * @since 1.0.0
65
+	 * @package GeoDirectory
66
+	 */
67
+	function geodir_admin_styles_req()
68
+	{
69 69
 
70
-        wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
71
-        wp_enqueue_style('font-awesome');
70
+		wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
71
+		wp_enqueue_style('font-awesome');
72 72
 
73
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
74
-        wp_enqueue_script('geodirectory-admin');
73
+		wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
74
+		wp_enqueue_script('geodirectory-admin');
75 75
 
76
-    }
76
+	}
77 77
 }
78 78
 
79 79
 if (!function_exists('geodir_admin_scripts')) {
80
-    /**
81
-     * Enqueue Admin Scripts.
82
-     *
83
-     * @since 1.0.0
84
-     * @package GeoDirectory
85
-     */
86
-    function geodir_admin_scripts()
87
-    {
88
-        $geodir_map_name = geodir_map_name();
80
+	/**
81
+	 * Enqueue Admin Scripts.
82
+	 *
83
+	 * @since 1.0.0
84
+	 * @package GeoDirectory
85
+	 */
86
+	function geodir_admin_scripts()
87
+	{
88
+		$geodir_map_name = geodir_map_name();
89 89
         
90
-        wp_enqueue_script('jquery');
90
+		wp_enqueue_script('jquery');
91 91
 
92
-        wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
92
+		wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
93 93
 
94
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
95
-        wp_enqueue_script('chosen');
94
+		wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
95
+		wp_enqueue_script('chosen');
96 96
 
97
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
98
-        wp_enqueue_script('geodirectory-choose-ajax');
97
+		wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
98
+		wp_enqueue_script('geodirectory-choose-ajax');
99 99
 
100
-        if (isset($_REQUEST['listing_type'])) {
101
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
102
-        }
100
+		if (isset($_REQUEST['listing_type'])) {
101
+			wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
102
+		}
103 103
 
104
-        wp_enqueue_script('geodirectory-custom-fields-script');
105
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
104
+		wp_enqueue_script('geodirectory-custom-fields-script');
105
+		$plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
106 106
 
107
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
107
+		wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
108 108
 
109
-        if (in_array($geodir_map_name, array('auto', 'google'))) {
110
-            $map_lang = "&language=" . geodir_get_map_default_language();
111
-            $map_key = "&key=" . geodir_get_map_api_key();
112
-            /** This filter is documented in geodirectory_template_tags.php */
113
-            $map_extra = apply_filters('geodir_googlemap_script_extra', '');
114
-            wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
115
-        }
109
+		if (in_array($geodir_map_name, array('auto', 'google'))) {
110
+			$map_lang = "&language=" . geodir_get_map_default_language();
111
+			$map_key = "&key=" . geodir_get_map_api_key();
112
+			/** This filter is documented in geodirectory_template_tags.php */
113
+			$map_extra = apply_filters('geodir_googlemap_script_extra', '');
114
+			wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
115
+		}
116 116
         
117
-        if ($geodir_map_name == 'osm') {
118
-            // Leaflet OpenStreetMap
119
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
120
-            wp_enqueue_style('geodirectory-leaflet-style');
117
+		if ($geodir_map_name == 'osm') {
118
+			// Leaflet OpenStreetMap
119
+			wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
120
+			wp_enqueue_style('geodirectory-leaflet-style');
121 121
                 
122
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
123
-            wp_enqueue_script('geodirectory-leaflet-script');
122
+			wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
123
+			wp_enqueue_script('geodirectory-leaflet-script');
124 124
             
125
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
126
-            wp_enqueue_script('geodirectory-leaflet-geo-script');
127
-        }
128
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
125
+			wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
126
+			wp_enqueue_script('geodirectory-leaflet-geo-script');
127
+		}
128
+		wp_enqueue_script( 'jquery-ui-autocomplete' );
129 129
         
130
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
131
-        wp_enqueue_script('geodirectory-goMap-script');
130
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
131
+		wp_enqueue_script('geodirectory-goMap-script');
132 132
 
133
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
134
-        wp_enqueue_script('geodirectory-goMap-script');
133
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
134
+		wp_enqueue_script('geodirectory-goMap-script');
135 135
 
136 136
 		// font awesome rating script
137 137
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
@@ -142,167 +142,167 @@  discard block
 block discarded – undo
142 142
 			wp_enqueue_script('geodir-jRating-js');
143 143
 		}
144 144
 
145
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
146
-        wp_enqueue_script('geodir-on-document-load');
147
-
148
-
149
-        // SCRIPT FOR UPLOAD
150
-        wp_enqueue_script('plupload-all');
151
-        wp_enqueue_script('jquery-ui-sortable');
152
-
153
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
154
-        wp_enqueue_script('geodirectory-plupload-script');
155
-
156
-        // SCRIPT FOR UPLOAD END
157
-
158
-
159
-        // place js config array for plupload
160
-        $plupload_init = array(
161
-            'runtimes' => 'html5,silverlight,flash,html4',
162
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
163
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
164
-            'drop_element' => 'dropbox', // will be adjusted per uploader
165
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
166
-            'multiple_queues' => true,
167
-            'max_file_size' => geodir_max_upload_size(),
168
-            'url' => admin_url('admin-ajax.php'),
169
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
170
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
171
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
172
-            'multipart' => true,
173
-            'urlstream_upload' => true,
174
-            'multi_selection' => false, // will be added per uploader
175
-            // additional post data to send to our ajax hook
176
-            'multipart_params' => array(
177
-                '_ajax_nonce' => "", // will be added per uploader
178
-                'action' => 'plupload_action', // the ajax action name
179
-                'imgid' => 0 // will be added per uploader
180
-            )
181
-        );
182
-        $base_plupload_config = json_encode($plupload_init);
183
-
184
-
185
-        $thumb_img_arr = array();
186
-
187
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
188
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
189
-
190
-        $totImg = '';
191
-        $image_limit = '';
192
-        if (!empty($thumb_img_arr)) {
193
-            $totImg = count($thumb_img_arr);
194
-        }
145
+		wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
146
+		wp_enqueue_script('geodir-on-document-load');
147
+
148
+
149
+		// SCRIPT FOR UPLOAD
150
+		wp_enqueue_script('plupload-all');
151
+		wp_enqueue_script('jquery-ui-sortable');
152
+
153
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
154
+		wp_enqueue_script('geodirectory-plupload-script');
155
+
156
+		// SCRIPT FOR UPLOAD END
157
+
158
+
159
+		// place js config array for plupload
160
+		$plupload_init = array(
161
+			'runtimes' => 'html5,silverlight,flash,html4',
162
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
163
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
164
+			'drop_element' => 'dropbox', // will be adjusted per uploader
165
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
166
+			'multiple_queues' => true,
167
+			'max_file_size' => geodir_max_upload_size(),
168
+			'url' => admin_url('admin-ajax.php'),
169
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
170
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
171
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
172
+			'multipart' => true,
173
+			'urlstream_upload' => true,
174
+			'multi_selection' => false, // will be added per uploader
175
+			// additional post data to send to our ajax hook
176
+			'multipart_params' => array(
177
+				'_ajax_nonce' => "", // will be added per uploader
178
+				'action' => 'plupload_action', // the ajax action name
179
+				'imgid' => 0 // will be added per uploader
180
+			)
181
+		);
182
+		$base_plupload_config = json_encode($plupload_init);
183
+
184
+
185
+		$thumb_img_arr = array();
186
+
187
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
188
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
189
+
190
+		$totImg = '';
191
+		$image_limit = '';
192
+		if (!empty($thumb_img_arr)) {
193
+			$totImg = count($thumb_img_arr);
194
+		}
195 195
 
196
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
197
-            'totalImg' => $totImg,
198
-            'image_limit' => $image_limit,
199
-            'upload_img_size' => geodir_max_upload_size());
196
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
197
+			'totalImg' => $totImg,
198
+			'image_limit' => $image_limit,
199
+			'upload_img_size' => geodir_max_upload_size());
200 200
 
201
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
201
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
202 202
 
203
-        $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
204
-        wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
203
+		$ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
204
+		wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
205 205
 
206 206
 
207
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
208
-        wp_enqueue_script('geodirectory-admin-script');
207
+		wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
208
+		wp_enqueue_script('geodirectory-admin-script');
209 209
 
210
-        wp_enqueue_style('farbtastic');
211
-        wp_enqueue_script('farbtastic');
210
+		wp_enqueue_style('farbtastic');
211
+		wp_enqueue_script('farbtastic');
212 212
 
213
-        $screen = get_current_screen();
214
-        if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
215
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
216
-        }
213
+		$screen = get_current_screen();
214
+		if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
215
+			wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
216
+		}
217 217
 
218
-        $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
219
-        wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
218
+		$ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
219
+		wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
220 220
 
221
-    }
221
+	}
222 222
 }
223 223
 
224 224
 if (!function_exists('geodir_admin_menu')) {
225
-    /**
226
-     * Admin Menus
227
-     *
228
-     * Sets up the admin menus in wordpress.
229
-     *
230
-     * @since 1.0.0
231
-     * @package GeoDirectory
232
-     * @global array $menu Menu array.
233
-     * @global object $geodirectory GeoDirectory plugin object.
234
-     */
235
-    function geodir_admin_menu()
236
-    {
237
-        global $menu, $geodirectory;
225
+	/**
226
+	 * Admin Menus
227
+	 *
228
+	 * Sets up the admin menus in wordpress.
229
+	 *
230
+	 * @since 1.0.0
231
+	 * @package GeoDirectory
232
+	 * @global array $menu Menu array.
233
+	 * @global object $geodirectory GeoDirectory plugin object.
234
+	 */
235
+	function geodir_admin_menu()
236
+	{
237
+		global $menu, $geodirectory;
238 238
 
239
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
239
+		if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
240 240
 
241
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
241
+		add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
242 242
 
243 243
 
244
-    }
244
+	}
245 245
 }
246 246
 
247 247
 if (!function_exists('geodir_admin_menu_order')) {
248
-    /**
249
-     * Order admin menus.
250
-     *
251
-     * @since 1.0.0
252
-     * @package GeoDirectory
253
-     * @param array $menu_order Menu order array.
254
-     * @return array Modified menu order array.
255
-     */
256
-    function geodir_admin_menu_order($menu_order)
257
-    {
258
-
259
-        // Initialize our custom order array
260
-        $geodir_menu_order = array();
261
-
262
-        // Get the index of our custom separator
263
-        $geodir_separator = array_search('separator-geodirectory', $menu_order);
264
-
265
-        // Get index of posttype menu
266
-        $post_types = geodir_get_posttypes();
267
-
268
-        // Loop through menu order and do some rearranging
269
-        foreach ($menu_order as $index => $item) :
270
-
271
-            if ((('geodirectory') == $item)) :
272
-                $geodir_menu_order[] = 'separator-geodirectory';
273
-                if (!empty($post_types)) {
274
-                    foreach ($post_types as $post_type) {
275
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
276
-                    }
277
-                }
278
-                $geodir_menu_order[] = $item;
248
+	/**
249
+	 * Order admin menus.
250
+	 *
251
+	 * @since 1.0.0
252
+	 * @package GeoDirectory
253
+	 * @param array $menu_order Menu order array.
254
+	 * @return array Modified menu order array.
255
+	 */
256
+	function geodir_admin_menu_order($menu_order)
257
+	{
279 258
 
280
-                unset($menu_order[$geodir_separator]);
281
-            //unset( $menu_order[$geodir_places] );
282
-            elseif (!in_array($item, array('separator-geodirectory'))) :
283
-                $geodir_menu_order[] = $item;
284
-            endif;
259
+		// Initialize our custom order array
260
+		$geodir_menu_order = array();
285 261
 
286
-        endforeach;
262
+		// Get the index of our custom separator
263
+		$geodir_separator = array_search('separator-geodirectory', $menu_order);
287 264
 
288
-        // Return order
289
-        return $geodir_menu_order;
290
-    }
265
+		// Get index of posttype menu
266
+		$post_types = geodir_get_posttypes();
267
+
268
+		// Loop through menu order and do some rearranging
269
+		foreach ($menu_order as $index => $item) :
270
+
271
+			if ((('geodirectory') == $item)) :
272
+				$geodir_menu_order[] = 'separator-geodirectory';
273
+				if (!empty($post_types)) {
274
+					foreach ($post_types as $post_type) {
275
+						$geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
276
+					}
277
+				}
278
+				$geodir_menu_order[] = $item;
279
+
280
+				unset($menu_order[$geodir_separator]);
281
+			//unset( $menu_order[$geodir_places] );
282
+			elseif (!in_array($item, array('separator-geodirectory'))) :
283
+				$geodir_menu_order[] = $item;
284
+			endif;
285
+
286
+		endforeach;
287
+
288
+		// Return order
289
+		return $geodir_menu_order;
290
+	}
291 291
 }
292 292
 
293 293
 if (!function_exists('geodir_admin_custom_menu_order')) {
294
-    /**
295
-     * Enables custom menu order.
296
-     *
297
-     * @since 1.0.0
298
-     * @package GeoDirectory
299
-     * @return bool
300
-     */
301
-    function geodir_admin_custom_menu_order()
302
-    {
303
-        if (!current_user_can('manage_options')) return false;
304
-        return true;
305
-    }
294
+	/**
295
+	 * Enables custom menu order.
296
+	 *
297
+	 * @since 1.0.0
298
+	 * @package GeoDirectory
299
+	 * @return bool
300
+	 */
301
+	function geodir_admin_custom_menu_order()
302
+	{
303
+		if (!current_user_can('manage_options')) return false;
304
+		return true;
305
+	}
306 306
 }
307 307
 
308 308
 /**
@@ -313,51 +313,51 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function geodir_before_admin_panel()
315 315
 {
316
-    if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
317
-        echo '<div id="message" class="updated fade">
316
+	if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
317
+		echo '<div id="message" class="updated fade">
318 318
                         <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
319 319
                         <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
320 320
                 </div>';
321 321
 
322
-    }
322
+	}
323 323
 
324
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
325
-        switch ($_REQUEST['msg']) {
326
-            case 'success':
327
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
328
-                flush_rewrite_rules(false);
324
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
325
+		switch ($_REQUEST['msg']) {
326
+			case 'success':
327
+				echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
328
+				flush_rewrite_rules(false);
329 329
 
330
-                break;
330
+				break;
331 331
 			case 'fail':
332 332
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
333 333
 				
334 334
 				if ($gderr == 21)
335
-			    	echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
335
+					echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
336 336
 				else
337 337
 					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
338
-                break;
339
-        }
340
-    }
338
+				break;
339
+		}
340
+	}
341 341
 
342
-    $geodir_load_map = get_option('geodir_load_map');
343
-    $need_map_key = false;
344
-    if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
345
-        $need_map_key = true;
346
-    }
342
+	$geodir_load_map = get_option('geodir_load_map');
343
+	$need_map_key = false;
344
+	if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
345
+		$need_map_key = true;
346
+	}
347 347
 
348
-    if (!geodir_get_map_api_key() && $need_map_key) {
349
-        echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
350
-    }
348
+	if (!geodir_get_map_api_key() && $need_map_key) {
349
+		echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
350
+	}
351 351
 
352
-    if (!geodir_is_default_location_set()) {
353
-        echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
352
+	if (!geodir_is_default_location_set()) {
353
+		echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
354 354
 
355
-    }
355
+	}
356 356
 
357
-    if (!function_exists('curl_init')) {
358
-        echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
357
+	if (!function_exists('curl_init')) {
358
+		echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
359 359
 
360
-    }
360
+	}
361 361
 
362 362
 
363 363
 
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
  */
375 375
 function geodir_handle_option_form_submit($current_tab)
376 376
 {
377
-    global $geodir_settings;
378
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
379
-        /**
380
-         * Contains settings array for current tab.
381
-         *
382
-         * @since 1.0.0
383
-         * @package GeoDirectory
384
-         */
385
-        include_once('option-pages/' . $current_tab . '_array.php');
386
-    }
387
-    if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
388
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
377
+	global $geodir_settings;
378
+	if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
379
+		/**
380
+		 * Contains settings array for current tab.
381
+		 *
382
+		 * @since 1.0.0
383
+		 * @package GeoDirectory
384
+		 */
385
+		include_once('option-pages/' . $current_tab . '_array.php');
386
+	}
387
+	if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
388
+		if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
+		if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
390 390
 		
391 391
 		/**
392 392
 		 * Fires before updating geodirectory admin settings.
@@ -398,38 +398,38 @@  discard block
 block discarded – undo
398 398
 		 */
399 399
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
400 400
 		
401
-        if (!empty($geodir_settings[$current_tab]))
402
-            geodir_update_options($geodir_settings[$current_tab]);
401
+		if (!empty($geodir_settings[$current_tab]))
402
+			geodir_update_options($geodir_settings[$current_tab]);
403 403
 
404
-        /**
405
-         * Called after GeoDirectory options settings are updated.
406
-         *
407
-         * @since 1.0.0
408
-         * @param array $geodir_settings The array of GeoDirectory settings.
409
-         * @see 'geodir_before_update_options'
410
-         */
411
-        do_action('geodir_update_options', $geodir_settings);
404
+		/**
405
+		 * Called after GeoDirectory options settings are updated.
406
+		 *
407
+		 * @since 1.0.0
408
+		 * @param array $geodir_settings The array of GeoDirectory settings.
409
+		 * @see 'geodir_before_update_options'
410
+		 */
411
+		do_action('geodir_update_options', $geodir_settings);
412 412
 
413
-        /**
414
-         * Called after GeoDirectory options settings are updated.
415
-         *
416
-         * Provides tab specific settings.
417
-         *
418
-         * @since 1.0.0
419
-         * @param string $current_tab The current settings tab name.
420
-         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
421
-         */
422
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
413
+		/**
414
+		 * Called after GeoDirectory options settings are updated.
415
+		 *
416
+		 * Provides tab specific settings.
417
+		 *
418
+		 * @since 1.0.0
419
+		 * @param string $current_tab The current settings tab name.
420
+		 * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
421
+		 */
422
+		do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
423 423
 
424
-        flush_rewrite_rules(false);
424
+		flush_rewrite_rules(false);
425 425
 
426
-        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
426
+		$current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
427 427
 
428
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
428
+		$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
429 429
 
430
-        wp_redirect($redirect_url);
431
-        exit();
432
-    endif;
430
+		wp_redirect($redirect_url);
431
+		exit();
432
+	endif;
433 433
 
434 434
 
435 435
 }
@@ -447,144 +447,144 @@  discard block
 block discarded – undo
447 447
  * @return bool Returns true if saved.
448 448
  */
449 449
 function geodir_update_options($options, $dummy = false) {
450
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
450
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
451 451
 
452
-    foreach ($options as $value) {
453
-        if ($dummy && isset($value['std']))
454
-            $_POST[$value['id']] = $value['std'];
452
+	foreach ($options as $value) {
453
+		if ($dummy && isset($value['std']))
454
+			$_POST[$value['id']] = $value['std'];
455 455
 
456 456
 
457
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
457
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
458 458
 
459
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
460
-                update_option($value['id'], $_POST[$value['id']]);
461
-            } else {
462
-                update_option($value['id'], 0);
463
-            }
459
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
460
+				update_option($value['id'], $_POST[$value['id']]);
461
+			} else {
462
+				update_option($value['id'], 0);
463
+			}
464 464
 
465
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
465
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
466 466
 
467
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
468
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
469
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
470
-                if (isset($_POST[$value['id'] . '_crop'])) :
471
-                    update_option($value['id'] . '_crop', 1);
472
-                else :
473
-                    update_option($value['id'] . '_crop', 0);
474
-                endif;
475
-            } else {
476
-                update_option($value['id'] . '_width', $value['std']);
477
-                update_option($value['id'] . '_height', $value['std']);
478
-                update_option($value['id'] . '_crop', 1);
479
-            }
467
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
468
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
469
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
470
+				if (isset($_POST[$value['id'] . '_crop'])) :
471
+					update_option($value['id'] . '_crop', 1);
472
+				else :
473
+					update_option($value['id'] . '_crop', 0);
474
+				endif;
475
+			} else {
476
+				update_option($value['id'] . '_width', $value['std']);
477
+				update_option($value['id'] . '_height', $value['std']);
478
+				update_option($value['id'] . '_crop', 1);
479
+			}
480 480
 
481
-        elseif (isset($value['type']) && $value['type'] == 'map') :
482
-            $post_types = array();
483
-            $categories = array();
481
+		elseif (isset($value['type']) && $value['type'] == 'map') :
482
+			$post_types = array();
483
+			$categories = array();
484 484
 
485
-            if (!empty($_POST['home_map_post_types'])) :
486
-                foreach ($_POST['home_map_post_types'] as $post_type) :
487
-                    $post_types[] = $post_type;
488
-                endforeach;
489
-            endif;
485
+			if (!empty($_POST['home_map_post_types'])) :
486
+				foreach ($_POST['home_map_post_types'] as $post_type) :
487
+					$post_types[] = $post_type;
488
+				endforeach;
489
+			endif;
490 490
 
491
-            update_option('geodir_exclude_post_type_on_map', $post_types);
491
+			update_option('geodir_exclude_post_type_on_map', $post_types);
492 492
 
493
-            if (!empty($_POST['post_category'])) :
494
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
495
-                    $categories[$texonomy] = array();
496
-                    foreach ($cat_arr as $category) :
497
-                        $categories[$texonomy][] = $category;
498
-                    endforeach;
499
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
500
-                endforeach;
501
-            endif;
502
-            update_option('geodir_exclude_cat_on_map', $categories);
503
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
504
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
493
+			if (!empty($_POST['post_category'])) :
494
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
495
+					$categories[$texonomy] = array();
496
+					foreach ($cat_arr as $category) :
497
+						$categories[$texonomy][] = $category;
498
+					endforeach;
499
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
500
+				endforeach;
501
+			endif;
502
+			update_option('geodir_exclude_cat_on_map', $categories);
503
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
504
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
505 505
 
506 506
 
507
-            if (!empty($_POST['geodir_default_map_language'])):
508
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
509
-            endif;
507
+			if (!empty($_POST['geodir_default_map_language'])):
508
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
509
+			endif;
510 510
 
511 511
 
512
-            if (!empty($_POST['geodir_default_map_search_pt'])):
513
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
514
-            endif;
512
+			if (!empty($_POST['geodir_default_map_search_pt'])):
513
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
514
+			endif;
515 515
 
516 516
 
517
-        elseif (isset($value['type']) && $value['type'] == 'file') :
517
+		elseif (isset($value['type']) && $value['type'] == 'file') :
518 518
 
519 519
 
520
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
520
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
521 521
 
522
-                if (get_option($value['id'])) {
523
-                    $image_name_arr = explode('/', get_option($value['id']));
524
-                    $noimg_name = end($image_name_arr);
525
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
526
-                    if (file_exists($img_path))
527
-                        unlink($img_path);
528
-                }
522
+				if (get_option($value['id'])) {
523
+					$image_name_arr = explode('/', get_option($value['id']));
524
+					$noimg_name = end($image_name_arr);
525
+					$img_path = $uploads['path'] . '/' . $noimg_name;
526
+					if (file_exists($img_path))
527
+						unlink($img_path);
528
+				}
529 529
 
530
-                update_option($value['id'], '');
531
-            }
530
+				update_option($value['id'], '');
531
+			}
532 532
 
533
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
534
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
535
-
536
-            if (!empty($filename)):
537
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
538
-                $uplaods = array();
539
-
540
-                foreach ($uploadedfile as $key => $uplaod):
541
-                    if ($key == 'name'):
542
-                        $uplaods[$key] = $filename;
543
-                    else :
544
-                        $uplaods[$key] = $uplaod;
545
-                    endif;
546
-                endforeach;
547
-
548
-                $uploads = wp_upload_dir();
549
-
550
-                if (get_option($value['id'])) {
551
-                    $image_name_arr = explode('/', get_option($value['id']));
552
-                    $noimg_name = end($image_name_arr);
553
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
554
-                    if (file_exists($img_path))
555
-                        unlink($img_path);
556
-                }
533
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
534
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
535
+
536
+			if (!empty($filename)):
537
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
538
+				$uplaods = array();
539
+
540
+				foreach ($uploadedfile as $key => $uplaod):
541
+					if ($key == 'name'):
542
+						$uplaods[$key] = $filename;
543
+					else :
544
+						$uplaods[$key] = $uplaod;
545
+					endif;
546
+				endforeach;
547
+
548
+				$uploads = wp_upload_dir();
549
+
550
+				if (get_option($value['id'])) {
551
+					$image_name_arr = explode('/', get_option($value['id']));
552
+					$noimg_name = end($image_name_arr);
553
+					$img_path = $uploads['path'] . '/' . $noimg_name;
554
+					if (file_exists($img_path))
555
+						unlink($img_path);
556
+				}
557 557
 
558
-                $upload_overrides = array('test_form' => false);
559
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
558
+				$upload_overrides = array('test_form' => false);
559
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
560 560
 
561
-                update_option($value['id'], $movefile['url']);
561
+				update_option($value['id'], $movefile['url']);
562 562
 
563
-            endif;
563
+			endif;
564 564
 
565
-            if (!get_option($value['id']) && isset($value['value'])):
566
-                update_option($value['id'], $value['value']);
567
-            endif;
565
+			if (!get_option($value['id']) && isset($value['value'])):
566
+				update_option($value['id'], $value['value']);
567
+			endif;
568 568
 
569 569
 
570
-        else :
571
-            // same menu setting per theme.
572
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
573
-                $theme = wp_get_theme();
574
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
575
-            }
570
+		else :
571
+			// same menu setting per theme.
572
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
573
+				$theme = wp_get_theme();
574
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
575
+			}
576 576
 
577
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
578
-                update_option($value['id'], $_POST[$value['id']]);
579
-            } else {
580
-                delete_option($value['id']);
581
-            }
577
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
578
+				update_option($value['id'], $_POST[$value['id']]);
579
+			} else {
580
+				delete_option($value['id']);
581
+			}
582 582
 
583
-        endif;
584
-    }
585
-    if ($dummy)
586
-        $_POST = array();
587
-    return true;
583
+		endif;
584
+	}
585
+	if ($dummy)
586
+		$_POST = array();
587
+	return true;
588 588
 
589 589
 }
590 590
 
@@ -633,33 +633,33 @@  discard block
 block discarded – undo
633 633
 function places_custom_fields_tab($tabs)
634 634
 {
635 635
 
636
-    $geodir_post_types = get_option('geodir_post_types');
636
+	$geodir_post_types = get_option('geodir_post_types');
637 637
 
638
-    if (!empty($geodir_post_types)) {
638
+	if (!empty($geodir_post_types)) {
639 639
 
640
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
640
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
641 641
 
642
-            $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory');
642
+			$listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory');
643 643
 
644
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
645
-                'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
646
-                'subtabs' => array(
647
-                    array('subtab' => 'custom_fields',
648
-                        'label' => __('Custom Fields', 'geodirectory'),
649
-                        'request' => array('listing_type' => $geodir_post_type)),
650
-                    array('subtab' => 'sorting_options',
651
-                        'label' => __('Sorting Options', 'geodirectory'),
652
-                        'request' => array('listing_type' => $geodir_post_type)),
653
-                ),
654
-                'tab_index' => 9,
655
-                'request' => array('listing_type' => $geodir_post_type)
656
-            );
644
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
645
+				'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
646
+				'subtabs' => array(
647
+					array('subtab' => 'custom_fields',
648
+						'label' => __('Custom Fields', 'geodirectory'),
649
+						'request' => array('listing_type' => $geodir_post_type)),
650
+					array('subtab' => 'sorting_options',
651
+						'label' => __('Sorting Options', 'geodirectory'),
652
+						'request' => array('listing_type' => $geodir_post_type)),
653
+				),
654
+				'tab_index' => 9,
655
+				'request' => array('listing_type' => $geodir_post_type)
656
+			);
657 657
 
658
-        endforeach;
658
+		endforeach;
659 659
 
660
-    }
660
+	}
661 661
 
662
-    return $tabs;
662
+	return $tabs;
663 663
 }
664 664
 
665 665
 
@@ -675,9 +675,9 @@  discard block
 block discarded – undo
675 675
  */
676 676
 function geodir_tools_setting_tab($tabs)
677 677
 {
678
-    wp_enqueue_script( 'jquery-ui-progressbar' );
679
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
680
-    return $tabs;
678
+	wp_enqueue_script( 'jquery-ui-progressbar' );
679
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
680
+	return $tabs;
681 681
 }
682 682
 
683 683
 /**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
  */
693 693
 function geodir_compatibility_setting_tab($tabs)
694 694
 {
695
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
696
-    return $tabs;
695
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
696
+	return $tabs;
697 697
 }
698 698
 
699 699
 
@@ -709,144 +709,144 @@  discard block
 block discarded – undo
709 709
  */
710 710
 function geodir_extend_geodirectory_setting_tab($tabs)
711 711
 {
712
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
713
-    return $tabs;
712
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
713
+	return $tabs;
714 714
 }
715 715
 
716 716
 
717 717
 if (!function_exists('geodir_edit_post_columns')) {
718
-    /**
719
-     * Modify admin post listing page columns.
720
-     *
721
-     * @since 1.0.0
722
-     * @package GeoDirectory
723
-     * @param array $columns The column array.
724
-     * @return array Altered column array.
725
-     */
726
-    function geodir_edit_post_columns($columns)
727
-    {
728
-
729
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
730
-            'categorys' => __('Categories', 'geodirectory'));
731
-
732
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
733
-        {
734
-            $offset = 0; // should we prepend $array with $data?
735
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
736
-        }
718
+	/**
719
+	 * Modify admin post listing page columns.
720
+	 *
721
+	 * @since 1.0.0
722
+	 * @package GeoDirectory
723
+	 * @param array $columns The column array.
724
+	 * @return array Altered column array.
725
+	 */
726
+	function geodir_edit_post_columns($columns)
727
+	{
737 728
 
738
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
729
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
730
+			'categorys' => __('Categories', 'geodirectory'));
739 731
 
740
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
732
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
733
+		{
734
+			$offset = 0; // should we prepend $array with $data?
735
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
736
+		}
741 737
 
742
-        return $columns;
743
-    }
738
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
739
+
740
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
741
+
742
+		return $columns;
743
+	}
744 744
 }
745 745
 
746 746
 
747 747
 if (!function_exists('geodir_manage_post_columns')) {
748
-    /**
749
-     * Adds content to our custom post listing page columns.
750
-     *
751
-     * @since 1.0.0
752
-     * @package GeoDirectory
753
-     * @global object $wpdb WordPress Database object.
754
-     * @global object $post WordPress Post object.
755
-     * @param string $column The column name.
756
-     * @param int $post_id The post ID.
757
-     */
758
-    function geodir_manage_post_columns($column, $post_id)
759
-    {
760
-        global $post, $wpdb;
761
-
762
-        switch ($column):
763
-            /* If displaying the 'city' column. */
764
-            case 'location' :
765
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
766
-                $location = geodir_get_location($location_id);
767
-                /* If no city is found, output a default message. */
768
-                if (empty($location)) {
769
-                    _e('Unknown', 'geodirectory');
770
-                } else {
771
-                    /* If there is a city id, append 'city name' to the text string. */
772
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
773
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
774
-                }
775
-                break;
776
-
777
-            /* If displaying the 'expire' column. */
778
-            case 'expire' :
779
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
780
-                $d1 = $expire_date; // get expire_date
781
-                $d2 = date('Y-m-d'); // get current date
782
-                $state = __('days left', 'geodirectory');
783
-                $date_diff_text = '';
784
-                $expire_class = 'expire_left';
785
-                if ($expire_date != 'Never') {
786
-                    if (strtotime($d1) < strtotime($d2)) {
787
-                        $state = __('days overdue', 'geodirectory');
788
-                        $expire_class = 'expire_over';
789
-                    }
790
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
791
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
792
-                }
793
-                /* If no expire_date is found, output a default message. */
794
-                if (empty($expire_date))
795
-                    echo __('Unknown', 'geodirectory');
796
-                /* If there is a expire_date, append 'days left' to the text string. */
797
-                else
798
-                    echo $expire_date . $date_diff_text;
799
-                break;
800
-
801
-            /* If displaying the 'categorys' column. */
802
-            case 'categorys' :
803
-
804
-                /* Get the categorys for the post. */
805
-
806
-
807
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
808
-
809
-                /* If terms were found. */
810
-                if (!empty($terms)) {
811
-                    $out = array();
812
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
813
-                    foreach ($terms as $term) {
814
-                        if (!strstr($term->taxonomy, 'tag')) {
815
-                            $out[] = sprintf('<a href="%s">%s</a>',
816
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
817
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
818
-                            );
819
-                        }
820
-                    }
821
-                    /* Join the terms, separating them with a comma. */
822
-                    echo(join(', ', $out));
823
-                } /* If no terms were found, output a default message. */
824
-                else {
825
-                    _e('No Categories', 'geodirectory');
826
-                }
827
-                break;
748
+	/**
749
+	 * Adds content to our custom post listing page columns.
750
+	 *
751
+	 * @since 1.0.0
752
+	 * @package GeoDirectory
753
+	 * @global object $wpdb WordPress Database object.
754
+	 * @global object $post WordPress Post object.
755
+	 * @param string $column The column name.
756
+	 * @param int $post_id The post ID.
757
+	 */
758
+	function geodir_manage_post_columns($column, $post_id)
759
+	{
760
+		global $post, $wpdb;
761
+
762
+		switch ($column):
763
+			/* If displaying the 'city' column. */
764
+			case 'location' :
765
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
766
+				$location = geodir_get_location($location_id);
767
+				/* If no city is found, output a default message. */
768
+				if (empty($location)) {
769
+					_e('Unknown', 'geodirectory');
770
+				} else {
771
+					/* If there is a city id, append 'city name' to the text string. */
772
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
773
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
774
+				}
775
+				break;
776
+
777
+			/* If displaying the 'expire' column. */
778
+			case 'expire' :
779
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
780
+				$d1 = $expire_date; // get expire_date
781
+				$d2 = date('Y-m-d'); // get current date
782
+				$state = __('days left', 'geodirectory');
783
+				$date_diff_text = '';
784
+				$expire_class = 'expire_left';
785
+				if ($expire_date != 'Never') {
786
+					if (strtotime($d1) < strtotime($d2)) {
787
+						$state = __('days overdue', 'geodirectory');
788
+						$expire_class = 'expire_over';
789
+					}
790
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
791
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
792
+				}
793
+				/* If no expire_date is found, output a default message. */
794
+				if (empty($expire_date))
795
+					echo __('Unknown', 'geodirectory');
796
+				/* If there is a expire_date, append 'days left' to the text string. */
797
+				else
798
+					echo $expire_date . $date_diff_text;
799
+				break;
828 800
 
829
-        endswitch;
830
-    }
801
+			/* If displaying the 'categorys' column. */
802
+			case 'categorys' :
803
+
804
+				/* Get the categorys for the post. */
805
+
806
+
807
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
808
+
809
+				/* If terms were found. */
810
+				if (!empty($terms)) {
811
+					$out = array();
812
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
813
+					foreach ($terms as $term) {
814
+						if (!strstr($term->taxonomy, 'tag')) {
815
+							$out[] = sprintf('<a href="%s">%s</a>',
816
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
817
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
818
+							);
819
+						}
820
+					}
821
+					/* Join the terms, separating them with a comma. */
822
+					echo(join(', ', $out));
823
+				} /* If no terms were found, output a default message. */
824
+				else {
825
+					_e('No Categories', 'geodirectory');
826
+				}
827
+				break;
828
+
829
+		endswitch;
830
+	}
831 831
 }
832 832
 
833 833
 
834 834
 if (!function_exists('geodir_post_sortable_columns')) {
835
-    /**
836
-     * Makes admin post listing page columns sortable.
837
-     *
838
-     * @since 1.0.0
839
-     * @package GeoDirectory
840
-     * @param array $columns The column array.
841
-     * @return array Altered column array.
842
-     */
843
-    function geodir_post_sortable_columns($columns)
844
-    {
845
-
846
-        $columns['expire'] = 'expire';
847
-
848
-        return $columns;
849
-    }
835
+	/**
836
+	 * Makes admin post listing page columns sortable.
837
+	 *
838
+	 * @since 1.0.0
839
+	 * @package GeoDirectory
840
+	 * @param array $columns The column array.
841
+	 * @return array Altered column array.
842
+	 */
843
+	function geodir_post_sortable_columns($columns)
844
+	{
845
+
846
+		$columns['expire'] = 'expire';
847
+
848
+		return $columns;
849
+	}
850 850
 }
851 851
 
852 852
 /**
@@ -860,32 +860,32 @@  discard block
 block discarded – undo
860 860
  * @param int $post_id The post ID.
861 861
  */
862 862
 function geodir_post_information_save($post_id, $post) {
863
-    global $wpdb, $current_user;
863
+	global $wpdb, $current_user;
864 864
 
865
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
866
-        return;
867
-    }
865
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
866
+		return;
867
+	}
868 868
 
869
-    $geodir_posttypes = geodir_get_posttypes();
869
+	$geodir_posttypes = geodir_get_posttypes();
870 870
 
871
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
872
-        return;
871
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
872
+		return;
873 873
 
874
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
875
-        if (isset($_REQUEST['_status']))
876
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
874
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
875
+		if (isset($_REQUEST['_status']))
876
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
877 877
 
878
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
879
-            return;
878
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
879
+			return;
880 880
 
881
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
882
-            return;
881
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
882
+			return;
883 883
 
884
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
885
-            return;
884
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
885
+			return;
886 886
 
887
-        geodir_save_listing($_REQUEST);
888
-    }
887
+		geodir_save_listing($_REQUEST);
888
+	}
889 889
 }
890 890
 
891 891
 /**
@@ -901,102 +901,102 @@  discard block
 block discarded – undo
901 901
  */
902 902
 function geodir_admin_fields($options)
903 903
 {
904
-    global $geodirectory;
905
-
906
-    $first_title = true;
907
-    $tab_id = '';
908
-    $i = 0;
909
-    foreach ($options as $value) :
910
-        if (!isset($value['name'])) $value['name'] = '';
911
-        if (!isset($value['class'])) $value['class'] = '';
912
-        if (!isset($value['css'])) $value['css'] = '';
913
-        if (!isset($value['std'])) $value['std'] = '';
914
-        $desc = '';
915
-        switch ($value['type']) :
916
-            case 'dummy_installer':
917
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
918
-                geodir_autoinstall_admin_header($post_type);
919
-                break;
920
-            case 'title':
921
-
922
-                if ($i == 0) {
923
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
924
-                    echo '<div class="inner_content_tab_main">';
925
-                }
904
+	global $geodirectory;
905
+
906
+	$first_title = true;
907
+	$tab_id = '';
908
+	$i = 0;
909
+	foreach ($options as $value) :
910
+		if (!isset($value['name'])) $value['name'] = '';
911
+		if (!isset($value['class'])) $value['class'] = '';
912
+		if (!isset($value['css'])) $value['css'] = '';
913
+		if (!isset($value['std'])) $value['std'] = '';
914
+		$desc = '';
915
+		switch ($value['type']) :
916
+			case 'dummy_installer':
917
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
918
+				geodir_autoinstall_admin_header($post_type);
919
+				break;
920
+			case 'title':
921
+
922
+				if ($i == 0) {
923
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
924
+					echo '<div class="inner_content_tab_main">';
925
+				}
926 926
 
927
-                $i++;
927
+				$i++;
928 928
 
929
-                if (isset($value['id']) && $value['id'])
930
-                    $tab_id = $value['id'];
929
+				if (isset($value['id']) && $value['id'])
930
+					$tab_id = $value['id'];
931 931
 
932
-                if (isset($value['desc']) && $value['desc'])
933
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
932
+				if (isset($value['desc']) && $value['desc'])
933
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
934 934
 
935
-                if (isset($value['name']) && $value['name']) {
936
-                    if ($first_title === true) {
937
-                        $first_title = false;
938
-                    } else {
939
-                        echo '</div>';
940
-                    }
941
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
935
+				if (isset($value['name']) && $value['name']) {
936
+					if ($first_title === true) {
937
+						$first_title = false;
938
+					} else {
939
+						echo '</div>';
940
+					}
941
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
942 942
 
943
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
944
-                }
943
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
944
+				}
945 945
 
946
-                /**
947
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
948
-                 *
949
-                 * The action is called dynamically geodir_settings_$value['id'].
950
-                 *
951
-                 * @since 1.0.0
952
-                 */
953
-                do_action('geodir_settings_' . sanitize_title($value['id']));
954
-                break;
955
-
956
-            case 'no_tabs':
957
-
958
-                echo '<div class="inner_content_tab_main">';
959
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
960
-
961
-                break;
962
-
963
-            case 'sectionstart':
964
-                if (isset($value['desc']) && $value['desc'])
965
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
966
-                if (isset($value['name']) && $value['name'])
967
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
968
-                /**
969
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
970
-                 *
971
-                 * The action is called dynamically geodir_settings_$value['id']_start.
972
-                 *
973
-                 * @since 1.0.0
974
-                 */
975
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
976
-                echo '<table class="form-table">' . "\n\n";
977
-
978
-                break;
979
-            case 'sectionend':
980
-                /**
981
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
982
-                 *
983
-                 * The action is called dynamically geodir_settings_$value['id']_end.
984
-                 *
985
-                 * @since 1.0.0
986
-                 */
987
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
988
-                echo '</table>';
989
-                /**
990
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
991
-                 *
992
-                 * The action is called dynamically geodir_settings_$value['id']_end.
993
-                 *
994
-                 * @since 1.0.0
995
-                 */
996
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
997
-                break;
998
-            case 'text':
999
-                ?>
946
+				/**
947
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
948
+				 *
949
+				 * The action is called dynamically geodir_settings_$value['id'].
950
+				 *
951
+				 * @since 1.0.0
952
+				 */
953
+				do_action('geodir_settings_' . sanitize_title($value['id']));
954
+				break;
955
+
956
+			case 'no_tabs':
957
+
958
+				echo '<div class="inner_content_tab_main">';
959
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
960
+
961
+				break;
962
+
963
+			case 'sectionstart':
964
+				if (isset($value['desc']) && $value['desc'])
965
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
966
+				if (isset($value['name']) && $value['name'])
967
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
968
+				/**
969
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
970
+				 *
971
+				 * The action is called dynamically geodir_settings_$value['id']_start.
972
+				 *
973
+				 * @since 1.0.0
974
+				 */
975
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
976
+				echo '<table class="form-table">' . "\n\n";
977
+
978
+				break;
979
+			case 'sectionend':
980
+				/**
981
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
982
+				 *
983
+				 * The action is called dynamically geodir_settings_$value['id']_end.
984
+				 *
985
+				 * @since 1.0.0
986
+				 */
987
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
988
+				echo '</table>';
989
+				/**
990
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
991
+				 *
992
+				 * The action is called dynamically geodir_settings_$value['id']_end.
993
+				 *
994
+				 * @since 1.0.0
995
+				 */
996
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
997
+				break;
998
+			case 'text':
999
+				?>
1000 1000
                 <tr valign="top">
1001 1001
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1002 1002
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1005,15 +1005,15 @@  discard block
 block discarded – undo
1005 1005
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1006 1006
                                            style=" <?php echo esc_attr($value['css']); ?>"
1007 1007
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1008
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1009
-                                           } else {
1010
-                                               echo esc_attr($value['std']);
1011
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1008
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1009
+										   } else {
1010
+											   echo esc_attr($value['std']);
1011
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1012 1012
                 </tr><?php
1013
-                break;
1013
+				break;
1014 1014
 
1015
-            case 'map-key':
1016
-                ?>
1015
+			case 'map-key':
1016
+				?>
1017 1017
                 <tr valign="top">
1018 1018
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1019 1019
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1022,17 +1022,17 @@  discard block
 block discarded – undo
1022 1022
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1023 1023
                                            style=" <?php echo esc_attr($value['css']); ?>"
1024 1024
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1025
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1026
-                                           } else {
1027
-                                               echo esc_attr($value['std']);
1028
-                                           } ?>"/>
1025
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1026
+										   } else {
1027
+											   echo esc_attr($value['std']);
1028
+										   } ?>"/>
1029 1029
                     <a href='https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]&TB_iframe=true&width=600&height=400' class="thickbox button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','geodirectory');?>" ><?php _e('Generate API Key','geodirectory');?></a>
1030 1030
                     <span class="description"><?php echo $value['desc']; ?></span></td>
1031 1031
                 </tr><?php
1032
-                break;
1032
+				break;
1033 1033
 
1034
-            case 'password':
1035
-                ?>
1034
+			case 'password':
1035
+				?>
1036 1036
                 <tr valign="top">
1037 1037
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1038 1038
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1041,42 +1041,42 @@  discard block
 block discarded – undo
1041 1041
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1042 1042
                                            style="<?php echo esc_attr($value['css']); ?>"
1043 1043
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1044
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1045
-                                           } else {
1046
-                                               echo esc_attr($value['std']);
1047
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1044
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1045
+										   } else {
1046
+											   echo esc_attr($value['std']);
1047
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1048 1048
                 </tr><?php
1049
-                break;
1049
+				break;
1050 1050
 
1051
-            case 'html_content':
1052
-                ?>
1051
+			case 'html_content':
1052
+				?>
1053 1053
                 <tr valign="top">
1054 1054
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1055 1055
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1056 1056
                 </tr><?php
1057
-                break;
1057
+				break;
1058 1058
 
1059
-            case 'color' :
1060
-                ?>
1059
+			case 'color' :
1060
+				?>
1061 1061
                 <tr valign="top">
1062 1062
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1063 1063
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1064 1064
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1065 1065
                                            style="<?php echo esc_attr($value['css']); ?>"
1066 1066
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1067
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1068
-                                           } else {
1069
-                                               echo esc_attr($value['std']);
1070
-                                           } ?>" class="colorpick"/> <span
1067
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1068
+										   } else {
1069
+											   echo esc_attr($value['std']);
1070
+										   } ?>" class="colorpick"/> <span
1071 1071
                         class="description"><?php echo $value['desc']; ?></span>
1072 1072
 
1073 1073
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1074 1074
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1075 1075
                 </td>
1076 1076
                 </tr><?php
1077
-                break;
1078
-            case 'image_width' :
1079
-                ?>
1077
+				break;
1078
+			case 'image_width' :
1079
+				?>
1080 1080
                 <tr valign="top">
1081 1081
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1082 1082
                 <td class="forminp">
@@ -1098,11 +1098,11 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1100 1100
                 </tr><?php
1101
-                break;
1102
-            case 'select':
1103
-                $option_value = get_option($value['id']);
1104
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1105
-                ?>
1101
+				break;
1102
+			case 'select':
1103
+				$option_value = get_option($value['id']);
1104
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1105
+				?>
1106 1106
                 <tr valign="top">
1107 1107
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1108 1108
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1111,33 +1111,33 @@  discard block
 block discarded – undo
1111 1111
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1112 1112
                                             option-ajaxchosen="false">
1113 1113
                         <?php
1114
-                        foreach ($value['options'] as $key => $val) {
1115
-                            $geodir_select_value = '';
1116
-                            if ($option_value != '') {
1117
-                                if ($option_value != '' && $option_value == $key)
1118
-                                    $geodir_select_value = ' selected="selected" ';
1119
-                            } else {
1120
-                                if ($value['std'] == $key)
1121
-                                    $geodir_select_value = ' selected="selected" ';
1122
-                            }
1123
-                            ?>
1114
+						foreach ($value['options'] as $key => $val) {
1115
+							$geodir_select_value = '';
1116
+							if ($option_value != '') {
1117
+								if ($option_value != '' && $option_value == $key)
1118
+									$geodir_select_value = ' selected="selected" ';
1119
+							} else {
1120
+								if ($value['std'] == $key)
1121
+									$geodir_select_value = ' selected="selected" ';
1122
+							}
1123
+							?>
1124 1124
                             <option
1125 1125
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo geodir_utf8_ucfirst($val) ?></option>
1126 1126
                         <?php
1127
-                        }
1128
-                        ?>
1127
+						}
1128
+						?>
1129 1129
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1130 1130
                 </td>
1131 1131
                 </tr><?php
1132
-                break;
1132
+				break;
1133 1133
 
1134
-            case 'multiselect':
1135
-                $option_values = get_option($value['id']);
1136
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1137
-                   $option_values = $value['std'];
1138
-                }
1139
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1140
-                ?>
1134
+			case 'multiselect':
1135
+				$option_values = get_option($value['id']);
1136
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1137
+				   $option_values = $value['std'];
1138
+				}
1139
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1140
+				?>
1141 1141
                 <tr valign="top">
1142 1142
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1143 1143
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1147,26 +1147,26 @@  discard block
 block discarded – undo
1147 1147
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1148 1148
                                             option-ajaxchosen="false">
1149 1149
                         <?php
1150
-                        foreach ($value['options'] as $key => $val) {
1151
-                            if (strpos($key, 'optgroup_start-') === 0) {
1152
-                                ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php
1153
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1154
-                                ?></optgroup><?php
1155
-                            } else {
1156
-                                ?>
1150
+						foreach ($value['options'] as $key => $val) {
1151
+							if (strpos($key, 'optgroup_start-') === 0) {
1152
+								?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php
1153
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1154
+								?></optgroup><?php
1155
+							} else {
1156
+								?>
1157 1157
                                 <option value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>>
1158 1158
                                     <?php echo geodir_utf8_ucfirst($val) ?>
1159 1159
                                 </option>
1160 1160
                             <?php
1161
-                            }
1162
-                        }
1163
-                        ?>
1161
+							}
1162
+						}
1163
+						?>
1164 1164
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1165 1165
                 </td>
1166 1166
                 </tr><?php
1167
-                break;
1168
-            case 'file':
1169
-                ?>
1167
+				break;
1168
+			case 'file':
1169
+				?>
1170 1170
                 <tr valign="top">
1171 1171
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1172 1172
                 <td class="forminp">
@@ -1186,87 +1186,87 @@  discard block
 block discarded – undo
1186 1186
                     <?php } ?>
1187 1187
                 </td>
1188 1188
                 </tr><?php
1189
-                break;
1190
-            case 'map_default_settings' :
1191
-                ?>
1189
+				break;
1190
+			case 'map_default_settings' :
1191
+				?>
1192 1192
 
1193 1193
                 <tr valign="top">
1194 1194
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1195 1195
                     <td width="60%">
1196 1196
                         <select name="geodir_default_map_language" style="width:60%">
1197 1197
                             <?php
1198
-                            $arr_map_langages = array(
1199
-                                'ar' => __('ARABIC', 'geodirectory'),
1200
-                                'eu' => __('BASQUE', 'geodirectory'),
1201
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1202
-                                'bn' => __('BENGALI', 'geodirectory'),
1203
-                                'ca' => __('CATALAN', 'geodirectory'),
1204
-                                'cs' => __('CZECH', 'geodirectory'),
1205
-                                'da' => __('DANISH', 'geodirectory'),
1206
-                                'de' => __('GERMAN', 'geodirectory'),
1207
-                                'el' => __('GREEK', 'geodirectory'),
1208
-                                'en' => __('ENGLISH', 'geodirectory'),
1209
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1210
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1211
-                                'es' => __('SPANISH', 'geodirectory'),
1212
-                                'eu' => __('BASQUE', 'geodirectory'),
1213
-                                'fa' => __('FARSI', 'geodirectory'),
1214
-                                'fi' => __('FINNISH', 'geodirectory'),
1215
-                                'fil' => __('FILIPINO', 'geodirectory'),
1216
-                                'fr' => __('FRENCH', 'geodirectory'),
1217
-                                'gl' => __('GALICIAN', 'geodirectory'),
1218
-                                'gu' => __('GUJARATI', 'geodirectory'),
1219
-                                'hi' => __('HINDI', 'geodirectory'),
1220
-                                'hr' => __('CROATIAN', 'geodirectory'),
1221
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1222
-                                'id' => __('INDONESIAN', 'geodirectory'),
1223
-                                'it' => __('ITALIAN', 'geodirectory'),
1224
-                                'iw' => __('HEBREW', 'geodirectory'),
1225
-                                'ja' => __('JAPANESE', 'geodirectory'),
1226
-                                'kn' => __('KANNADA', 'geodirectory'),
1227
-                                'ko' => __('KOREAN', 'geodirectory'),
1228
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1229
-                                'lv' => __('LATVIAN', 'geodirectory'),
1230
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1231
-                                'mr' => __('MARATHI', 'geodirectory'),
1232
-                                'nl' => __('DUTCH', 'geodirectory'),
1233
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1234
-                                'pl' => __('POLISH', 'geodirectory'),
1235
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1236
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1237
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1238
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1239
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1240
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1241
-                                'sk' => __('SLOVAK', 'geodirectory'),
1242
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1243
-                                'sr' => __('SERBIAN', 'geodirectory'),
1244
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1245
-                                'tl' => __('TAGALOG', 'geodirectory'),
1246
-                                'ta' => __('TAMIL', 'geodirectory'),
1247
-                                'te' => __('TELUGU', 'geodirectory'),
1248
-                                'th' => __('THAI', 'geodirectory'),
1249
-                                'tr' => __('TURKISH', 'geodirectory'),
1250
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1251
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1252
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1253
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1254
-                            );
1255
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1256
-                            if (empty($geodir_default_map_language))
1257
-                                $geodir_default_map_language = 'en';
1258
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
1259
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1260
-                                    $geodir_default_language_selected = "selected='selected'";
1261
-                                else
1262
-                                    $geodir_default_language_selected = '';
1263
-
1264
-                                ?>
1198
+							$arr_map_langages = array(
1199
+								'ar' => __('ARABIC', 'geodirectory'),
1200
+								'eu' => __('BASQUE', 'geodirectory'),
1201
+								'bg' => __('BULGARIAN', 'geodirectory'),
1202
+								'bn' => __('BENGALI', 'geodirectory'),
1203
+								'ca' => __('CATALAN', 'geodirectory'),
1204
+								'cs' => __('CZECH', 'geodirectory'),
1205
+								'da' => __('DANISH', 'geodirectory'),
1206
+								'de' => __('GERMAN', 'geodirectory'),
1207
+								'el' => __('GREEK', 'geodirectory'),
1208
+								'en' => __('ENGLISH', 'geodirectory'),
1209
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1210
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1211
+								'es' => __('SPANISH', 'geodirectory'),
1212
+								'eu' => __('BASQUE', 'geodirectory'),
1213
+								'fa' => __('FARSI', 'geodirectory'),
1214
+								'fi' => __('FINNISH', 'geodirectory'),
1215
+								'fil' => __('FILIPINO', 'geodirectory'),
1216
+								'fr' => __('FRENCH', 'geodirectory'),
1217
+								'gl' => __('GALICIAN', 'geodirectory'),
1218
+								'gu' => __('GUJARATI', 'geodirectory'),
1219
+								'hi' => __('HINDI', 'geodirectory'),
1220
+								'hr' => __('CROATIAN', 'geodirectory'),
1221
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1222
+								'id' => __('INDONESIAN', 'geodirectory'),
1223
+								'it' => __('ITALIAN', 'geodirectory'),
1224
+								'iw' => __('HEBREW', 'geodirectory'),
1225
+								'ja' => __('JAPANESE', 'geodirectory'),
1226
+								'kn' => __('KANNADA', 'geodirectory'),
1227
+								'ko' => __('KOREAN', 'geodirectory'),
1228
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1229
+								'lv' => __('LATVIAN', 'geodirectory'),
1230
+								'ml' => __('MALAYALAM', 'geodirectory'),
1231
+								'mr' => __('MARATHI', 'geodirectory'),
1232
+								'nl' => __('DUTCH', 'geodirectory'),
1233
+								'no' => __('NORWEGIAN', 'geodirectory'),
1234
+								'pl' => __('POLISH', 'geodirectory'),
1235
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1236
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1237
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1238
+								'ro' => __('ROMANIAN', 'geodirectory'),
1239
+								'ru' => __('RUSSIAN', 'geodirectory'),
1240
+								'ru' => __('RUSSIAN', 'geodirectory'),
1241
+								'sk' => __('SLOVAK', 'geodirectory'),
1242
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1243
+								'sr' => __('SERBIAN', 'geodirectory'),
1244
+								'sv' => __('	SWEDISH', 'geodirectory'),
1245
+								'tl' => __('TAGALOG', 'geodirectory'),
1246
+								'ta' => __('TAMIL', 'geodirectory'),
1247
+								'te' => __('TELUGU', 'geodirectory'),
1248
+								'th' => __('THAI', 'geodirectory'),
1249
+								'tr' => __('TURKISH', 'geodirectory'),
1250
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1251
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1252
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1253
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1254
+							);
1255
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1256
+							if (empty($geodir_default_map_language))
1257
+								$geodir_default_map_language = 'en';
1258
+							foreach ($arr_map_langages as $language_key => $language_txt) {
1259
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1260
+									$geodir_default_language_selected = "selected='selected'";
1261
+								else
1262
+									$geodir_default_language_selected = '';
1263
+
1264
+								?>
1265 1265
                                 <option
1266 1266
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1267 1267
 
1268 1268
                             <?php }
1269
-                            ?>
1269
+							?>
1270 1270
                         </select>
1271 1271
                     </td>
1272 1272
                 </tr>
@@ -1277,46 +1277,46 @@  discard block
 block discarded – undo
1277 1277
                     <td width="60%">
1278 1278
                         <select name="geodir_default_map_search_pt" style="width:60%">
1279 1279
                             <?php
1280
-                            $post_types = geodir_get_posttypes('array');
1281
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1282
-                            if (empty($geodir_default_map_search_pt))
1283
-                                $geodir_default_map_search_pt = 'gd_place';
1284
-                            if (is_array($post_types)) {
1285
-                                foreach ($post_types as $key => $post_types_obj) {
1286
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1287
-                                        $geodir_search_pt_selected = "selected='selected'";
1288
-                                    else
1289
-                                        $geodir_search_pt_selected = '';
1290
-
1291
-                                    ?>
1280
+							$post_types = geodir_get_posttypes('array');
1281
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1282
+							if (empty($geodir_default_map_search_pt))
1283
+								$geodir_default_map_search_pt = 'gd_place';
1284
+							if (is_array($post_types)) {
1285
+								foreach ($post_types as $key => $post_types_obj) {
1286
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1287
+										$geodir_search_pt_selected = "selected='selected'";
1288
+									else
1289
+										$geodir_search_pt_selected = '';
1290
+
1291
+									?>
1292 1292
                                     <option
1293 1293
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo __($post_types_obj['labels']['singular_name'], 'geodirectory'); ?></option>
1294 1294
 
1295 1295
                                 <?php }
1296 1296
 
1297
-                            }
1297
+							}
1298 1298
 
1299
-                            ?>
1299
+							?>
1300 1300
                         </select>
1301 1301
                     </td>
1302 1302
                 </tr>
1303 1303
 
1304 1304
                 <?php
1305
-                break;
1305
+				break;
1306 1306
 
1307
-            case 'map':
1308
-                ?>
1307
+			case 'map':
1308
+				?>
1309 1309
                 <tr valign="top">
1310 1310
                     <td class="forminp">
1311 1311
                         <?php
1312
-                        global $post_cat, $cat_display;
1313
-                        $post_types = geodir_get_posttypes('object');
1314
-                        $cat_display = 'checkbox';
1315
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1316
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1317
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1318
-                        $count = 1;
1319
-                        ?>
1312
+						global $post_cat, $cat_display;
1313
+						$post_types = geodir_get_posttypes('object');
1314
+						$cat_display = 'checkbox';
1315
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1316
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1317
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1318
+						$count = 1;
1319
+						?>
1320 1320
                         <table width="70%" class="widefat">
1321 1321
                             <thead>
1322 1322
                             <tr>
@@ -1325,18 +1325,18 @@  discard block
 block discarded – undo
1325 1325
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1326 1326
                             </tr>
1327 1327
                             <?php
1328
-                            $gd_categs = $gd_cats;
1329
-                            foreach ($post_types as $key => $post_types_obj) :
1330
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1331
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1332
-                                if ($gd_cats_upgrade) {
1333
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1334
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1335
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1336
-                                }
1337
-                                $post_cat = implode(',', $gd_cats);
1338
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1339
-                                ?>
1328
+							$gd_categs = $gd_cats;
1329
+							foreach ($post_types as $key => $post_types_obj) :
1330
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1331
+								$gd_taxonomy = geodir_get_taxonomies($key);
1332
+								if ($gd_cats_upgrade) {
1333
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1334
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1335
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1336
+								}
1337
+								$post_cat = implode(',', $gd_cats);
1338
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1339
+								?>
1340 1340
                                 <tr>
1341 1341
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1342 1342
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1357,19 +1357,19 @@  discard block
 block discarded – undo
1357 1357
                     </td>
1358 1358
                 </tr>
1359 1359
                 <?php
1360
-                break;
1360
+				break;
1361 1361
 
1362
-            case 'checkbox' :
1362
+			case 'checkbox' :
1363 1363
 
1364
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1365
-                    ?>
1364
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1365
+					?>
1366 1366
                     <tr valign="top">
1367 1367
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1368 1368
                     <td class="forminp">
1369 1369
                 <?php
1370
-                endif;
1370
+				endif;
1371 1371
 
1372
-                ?>
1372
+				?>
1373 1373
                 <fieldset>
1374 1374
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1375 1375
                     <label for="<?php echo $value['id'] ?>">
@@ -1379,49 +1379,49 @@  discard block
 block discarded – undo
1379 1379
                 </fieldset>
1380 1380
                 <?php
1381 1381
 
1382
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1383
-                    ?>
1382
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1383
+					?>
1384 1384
                     </td>
1385 1385
                     </tr>
1386 1386
                 <?php
1387
-                endif;
1387
+				endif;
1388 1388
 
1389
-                break;
1389
+				break;
1390 1390
 
1391
-            case 'radio' :
1391
+			case 'radio' :
1392 1392
 
1393
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1394
-                    ?>
1393
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1394
+					?>
1395 1395
                     <tr valign="top">
1396 1396
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1397 1397
                     <td class="forminp">
1398 1398
                 <?php
1399
-                endif;
1399
+				endif;
1400 1400
 
1401
-                ?>
1401
+				?>
1402 1402
                 <fieldset>
1403 1403
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1404 1404
                     <label for="<?php echo $value['id'];?>">
1405 1405
                         <input name="<?php echo esc_attr($value['id']); ?>"
1406 1406
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1407 1407
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1408
-                            echo 'checked="checked"';
1409
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1408
+							echo 'checked="checked"';
1409
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1410 1410
                         <?php echo $value['desc']; ?></label><br>
1411 1411
                 </fieldset>
1412 1412
                 <?php
1413 1413
 
1414
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1415
-                    ?>
1414
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1415
+					?>
1416 1416
                     </td>
1417 1417
                     </tr>
1418 1418
                 <?php
1419
-                endif;
1419
+				endif;
1420 1420
 
1421
-                break;
1421
+				break;
1422 1422
 
1423
-            case 'textarea':
1424
-                ?>
1423
+			case 'textarea':
1424
+				?>
1425 1425
                 <tr valign="top">
1426 1426
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1427 1427
                 <td class="forminp">
@@ -1434,30 +1434,30 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
                 </td>
1436 1436
                 </tr><?php
1437
-                break;
1437
+				break;
1438 1438
 
1439
-            case 'editor':
1440
-                ?>
1439
+			case 'editor':
1440
+				?>
1441 1441
                 <tr valign="top">
1442 1442
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1443 1443
                 <td class="forminp"><?php
1444
-                    if (get_option($value['id']))
1445
-                        $content = stripslashes(get_option($value['id']));
1446
-                    else
1447
-                        $content = $value['std'];
1444
+					if (get_option($value['id']))
1445
+						$content = stripslashes(get_option($value['id']));
1446
+					else
1447
+						$content = $value['std'];
1448 1448
 
1449
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1449
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1450 1450
 
1451
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1451
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1452 1452
 
1453
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1453
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1454 1454
 
1455 1455
                 </td>
1456 1456
                 </tr><?php
1457
-                break;
1457
+				break;
1458 1458
 
1459
-            case 'single_select_page' :
1460
-                // WPML
1459
+			case 'single_select_page' :
1460
+				// WPML
1461 1461
 				$switch_lang = false;
1462 1462
 				$disabled = '';
1463 1463
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1475,18 +1475,18 @@  discard block
 block discarded – undo
1475 1475
 				//
1476 1476
 				$page_setting = (int)get_option($value['id']);
1477 1477
 
1478
-                $args = array('name' => $value['id'],
1479
-                    'id' => $value['id'],
1480
-                    'sort_column' => 'menu_order',
1481
-                    'sort_order' => 'ASC',
1482
-                    'show_option_none' => ' ',
1483
-                    'class' => $value['class'],
1484
-                    'echo' => false,
1485
-                    'selected' => $page_setting);
1478
+				$args = array('name' => $value['id'],
1479
+					'id' => $value['id'],
1480
+					'sort_column' => 'menu_order',
1481
+					'sort_order' => 'ASC',
1482
+					'show_option_none' => ' ',
1483
+					'class' => $value['class'],
1484
+					'echo' => false,
1485
+					'selected' => $page_setting);
1486 1486
 
1487
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1487
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1488 1488
 
1489
-                ?>
1489
+				?>
1490 1490
                 <tr valign="top" class="single_select_page">
1491 1491
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1492 1492
                 <td class="forminp">
@@ -1497,17 +1497,17 @@  discard block
 block discarded – undo
1497 1497
 				if ($switch_lang) {
1498 1498
 					$sitepress->switch_lang($switch_lang, true);
1499 1499
 				}
1500
-                break;
1501
-            case 'single_select_country' :
1502
-                $country_setting = (string)get_option($value['id']);
1503
-                if (strstr($country_setting, ':')) :
1504
-                    $country = current(explode(':', $country_setting));
1505
-                    $state = end(explode(':', $country_setting));
1506
-                else :
1507
-                    $country = $country_setting;
1508
-                    $state = '*';
1509
-                endif;
1510
-                ?>
1500
+				break;
1501
+			case 'single_select_country' :
1502
+				$country_setting = (string)get_option($value['id']);
1503
+				if (strstr($country_setting, ':')) :
1504
+					$country = current(explode(':', $country_setting));
1505
+					$state = end(explode(':', $country_setting));
1506
+				else :
1507
+					$country = $country_setting;
1508
+					$state = '*';
1509
+				endif;
1510
+				?>
1511 1511
                 <tr valign="top">
1512 1512
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1513 1513
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1518,12 +1518,12 @@  discard block
 block discarded – undo
1518 1518
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1519 1519
                 </td>
1520 1520
                 </tr><?php
1521
-                break;
1522
-            case 'multi_select_countries' :
1523
-                $countries = $geodirectory->countries->countries;
1524
-                asort($countries);
1525
-                $selections = (array)get_option($value['id']);
1526
-                ?>
1521
+				break;
1522
+			case 'multi_select_countries' :
1523
+				$countries = $geodirectory->countries->countries;
1524
+				asort($countries);
1525
+				$selections = (array)get_option($value['id']);
1526
+				?>
1527 1527
                 <tr valign="top">
1528 1528
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1529 1529
                 <td class="forminp">
@@ -1531,21 +1531,21 @@  discard block
 block discarded – undo
1531 1531
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1532 1532
                             title="Country" class="chosen_select">
1533 1533
                         <?php
1534
-                        if ($countries) foreach ($countries as $key => $val) :
1535
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1536
-                        endforeach;
1537
-                        ?>
1534
+						if ($countries) foreach ($countries as $key => $val) :
1535
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1536
+						endforeach;
1537
+						?>
1538 1538
                     </select>
1539 1539
                 </td>
1540 1540
                 </tr>
1541 1541
 
1542 1542
                 <?php
1543 1543
 
1544
-                break;
1544
+				break;
1545 1545
 
1546
-            case 'google_analytics' :
1547
-                $selections = (array)get_option($value['id']);
1548
-                    ?>
1546
+			case 'google_analytics' :
1547
+				$selections = (array)get_option($value['id']);
1548
+					?>
1549 1549
                     <tr valign="top">
1550 1550
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1551 1551
                         <td class="forminp">
@@ -1553,62 +1553,62 @@  discard block
 block discarded – undo
1553 1553
 
1554 1554
                             <?php
1555 1555
 
1556
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1557
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1558
-                            $state = "&state=123";//any string
1559
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1560
-                            $response_type = "&response_type=code";
1561
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1562
-                            $access_type = "&access_type=offline";
1563
-                            $approval_prompt = "&approval_prompt=force";
1556
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1557
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1558
+							$state = "&state=123";//any string
1559
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1560
+							$response_type = "&response_type=code";
1561
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1562
+							$access_type = "&access_type=offline";
1563
+							$approval_prompt = "&approval_prompt=force";
1564 1564
 
1565
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1565
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1566 1566
 
1567 1567
 
1568
-                            if (get_option('geodir_ga_auth_token')) {
1569
-                                ?>
1568
+							if (get_option('geodir_ga_auth_token')) {
1569
+								?>
1570 1570
                                 <span class="button-primary"
1571 1571
                                       onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
1572 1572
                                 <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1573 1573
                             <?php
1574
-                                global $gd_ga_errors;
1575
-                                if(!empty($gd_ga_errors)){
1576
-                                    print_r($gd_ga_errors);
1577
-                                }
1578
-                            } else {
1579
-                                ?>
1574
+								global $gd_ga_errors;
1575
+								if(!empty($gd_ga_errors)){
1576
+									print_r($gd_ga_errors);
1577
+								}
1578
+							} else {
1579
+								?>
1580 1580
                                 <span class="button-primary"
1581 1581
                                       onclick="window.open('<?php echo  geodir_ga_activation_url();?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Authorize', 'geodirectory');?></span>
1582 1582
                             <?php
1583
-                            }
1584
-                            ?>
1583
+							}
1584
+							?>
1585 1585
                         </td>
1586 1586
                     </tr>
1587 1587
 
1588 1588
                 <?php
1589 1589
 
1590 1590
 
1591
-                break;
1591
+				break;
1592 1592
 
1593
-            case 'field_seperator' :
1593
+			case 'field_seperator' :
1594 1594
 
1595
-                ?>
1595
+				?>
1596 1596
                 <tr valign="top">
1597 1597
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1598 1598
                 </tr>
1599 1599
                 <?php
1600 1600
 
1601
-                break;
1601
+				break;
1602 1602
 
1603
-        endswitch;
1603
+		endswitch;
1604 1604
 
1605
-    endforeach;
1605
+	endforeach;
1606 1606
 
1607
-    if ($first_title === false) {
1608
-        echo "</div>";
1609
-    }
1607
+	if ($first_title === false) {
1608
+		echo "</div>";
1609
+	}
1610 1610
 
1611
-    ?>
1611
+	?>
1612 1612
 
1613 1613
     <script type="text/javascript">
1614 1614
 
@@ -1668,33 +1668,33 @@  discard block
 block discarded – undo
1668 1668
  */
1669 1669
 function geodir_post_info_setting()
1670 1670
 {
1671
-    global $post, $post_id;
1672
-
1673
-    $post_type = get_post_type();
1674
-
1675
-    $package_info = array();
1676
-
1677
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1678
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1679
-    echo '<div id="geodir_wrapper">';
1680
-    /**
1681
-     * Called before the GD custom fields are output in the wp-admin area.
1682
-     *
1683
-     * @since 1.0.0
1684
-     * @see 'geodir_after_default_field_in_meta_box'
1685
-     */
1686
-    do_action('geodir_before_default_field_in_meta_box');
1687
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
1688
-    // to display all fields in one information box
1689
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
1690
-    /**
1691
-     * Called after the GD custom fields are output in the wp-admin area.
1692
-     *
1693
-     * @since 1.0.0
1694
-     * @see 'geodir_before_default_field_in_meta_box'
1695
-     */
1696
-    do_action('geodir_after_default_field_in_meta_box');
1697
-    echo '</div>';
1671
+	global $post, $post_id;
1672
+
1673
+	$post_type = get_post_type();
1674
+
1675
+	$package_info = array();
1676
+
1677
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1678
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1679
+	echo '<div id="geodir_wrapper">';
1680
+	/**
1681
+	 * Called before the GD custom fields are output in the wp-admin area.
1682
+	 *
1683
+	 * @since 1.0.0
1684
+	 * @see 'geodir_after_default_field_in_meta_box'
1685
+	 */
1686
+	do_action('geodir_before_default_field_in_meta_box');
1687
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
1688
+	// to display all fields in one information box
1689
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
1690
+	/**
1691
+	 * Called after the GD custom fields are output in the wp-admin area.
1692
+	 *
1693
+	 * @since 1.0.0
1694
+	 * @see 'geodir_before_default_field_in_meta_box'
1695
+	 */
1696
+	do_action('geodir_after_default_field_in_meta_box');
1697
+	echo '</div>';
1698 1698
 }
1699 1699
 
1700 1700
 /**
@@ -1707,18 +1707,18 @@  discard block
 block discarded – undo
1707 1707
  */
1708 1708
 function geodir_post_addinfo_setting()
1709 1709
 {
1710
-    global $post, $post_id;
1710
+	global $post, $post_id;
1711 1711
 
1712
-    $post_type = get_post_type();
1712
+	$post_type = get_post_type();
1713 1713
 
1714
-    $package_info = array();
1714
+	$package_info = array();
1715 1715
 
1716
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1716
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1717 1717
 
1718
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
1719
-    echo '<div id="geodir_wrapper">';
1720
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
1721
-    echo '</div>';
1718
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
1719
+	echo '<div id="geodir_wrapper">';
1720
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
1721
+	echo '</div>';
1722 1722
 
1723 1723
 }
1724 1724
 
@@ -1732,60 +1732,60 @@  discard block
 block discarded – undo
1732 1732
  */
1733 1733
 function geodir_post_attachments()
1734 1734
 {
1735
-    global $post, $post_id;
1735
+	global $post, $post_id;
1736 1736
 
1737
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
1737
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
1738 1738
 
1739
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
1740
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
1741
-        geodir_show_featured_image($post_id, 'thumbnail');
1742
-    }
1739
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
1740
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
1741
+		geodir_show_featured_image($post_id, 'thumbnail');
1742
+	}
1743 1743
 
1744
-    $image_limit = 0;
1744
+	$image_limit = 0;
1745 1745
 
1746
-    ?>
1746
+	?>
1747 1747
 
1748 1748
 
1749 1749
     <h5 class="form_title">
1750 1750
         <?php if ($image_limit != 0 && $image_limit == 1) {
1751
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
1752
-        } ?>
1751
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
1752
+		} ?>
1753 1753
         <?php if ($image_limit != 0 && $image_limit > 1) {
1754
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
1755
-        } ?>
1754
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
1755
+		} ?>
1756 1756
         <?php if ($image_limit == 0) {
1757
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
1758
-        } ?>
1757
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
1758
+		} ?>
1759 1759
     </h5>
1760 1760
 
1761 1761
 
1762 1762
     <?php
1763 1763
 
1764
-    $curImages = geodir_get_images($post_id);
1765
-    $place_img_array = array();
1764
+	$curImages = geodir_get_images($post_id);
1765
+	$place_img_array = array();
1766 1766
 
1767
-    if (!empty($curImages)):
1768
-        foreach ($curImages as $p_img):
1769
-            $place_img_array[] = $p_img->src;
1770
-        endforeach;
1771
-    endif;
1767
+	if (!empty($curImages)):
1768
+		foreach ($curImages as $p_img):
1769
+			$place_img_array[] = $p_img->src;
1770
+		endforeach;
1771
+	endif;
1772 1772
 
1773
-    if (!empty($place_img_array))
1774
-        $curImages = implode(',', $place_img_array);
1773
+	if (!empty($place_img_array))
1774
+		$curImages = implode(',', $place_img_array);
1775 1775
 
1776 1776
 
1777
-    // adjust values here
1778
-    $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
1777
+	// adjust values here
1778
+	$id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
1779 1779
 
1780
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
1780
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
1781 1781
 
1782
-    $multiple = true; // allow multiple files upload
1782
+	$multiple = true; // allow multiple files upload
1783 1783
 
1784
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
1784
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
1785 1785
 
1786
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
1786
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
1787 1787
 
1788
-    ?>
1788
+	?>
1789 1789
 
1790 1790
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
1791 1791
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -1827,13 +1827,13 @@  discard block
 block discarded – undo
1827 1827
  */
1828 1828
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
1829 1829
 {
1830
-    $post_type = get_post_type($post_ID);
1830
+	$post_type = get_post_type($post_ID);
1831 1831
 
1832
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1833
-        if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
1834
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
1835
-        }
1836
-    }
1832
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1833
+		if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
1834
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
1835
+		}
1836
+	}
1837 1837
 }
1838 1838
 
1839 1839
 /**
@@ -1848,39 +1848,39 @@  discard block
 block discarded – undo
1848 1848
  */
1849 1849
 function geodir_notification_add_bcc_option($settings)
1850 1850
 {
1851
-    if (!empty($settings)) {
1852
-        $new_settings = array();
1853
-        foreach ($settings as $setting) {
1854
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
1855
-                $geodir_bcc_listing_published_yes = array(
1856
-                    'name' => __('Listing published', 'geodirectory'),
1857
-                    'desc' => __('Yes', 'geodirectory'),
1858
-                    'id' => 'geodir_bcc_listing_published',
1859
-                    'std' => 'yes',
1860
-                    'type' => 'radio',
1861
-                    'value' => '1',
1862
-                    'radiogroup' => 'start'
1863
-                );
1864
-
1865
-                $geodir_bcc_listing_published_no = array(
1866
-                    'name' => __('Listing published', 'geodirectory'),
1867
-                    'desc' => __('No', 'geodirectory'),
1868
-                    'id' => 'geodir_bcc_listing_published',
1869
-                    'std' => 'yes',
1870
-                    'type' => 'radio',
1871
-                    'value' => '0',
1872
-                    'radiogroup' => 'end'
1873
-                );
1874
-
1875
-                $new_settings[] = $geodir_bcc_listing_published_yes;
1876
-                $new_settings[] = $geodir_bcc_listing_published_no;
1877
-            }
1878
-            $new_settings[] = $setting;
1879
-        }
1880
-        $settings = $new_settings;
1881
-    }
1851
+	if (!empty($settings)) {
1852
+		$new_settings = array();
1853
+		foreach ($settings as $setting) {
1854
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
1855
+				$geodir_bcc_listing_published_yes = array(
1856
+					'name' => __('Listing published', 'geodirectory'),
1857
+					'desc' => __('Yes', 'geodirectory'),
1858
+					'id' => 'geodir_bcc_listing_published',
1859
+					'std' => 'yes',
1860
+					'type' => 'radio',
1861
+					'value' => '1',
1862
+					'radiogroup' => 'start'
1863
+				);
1864
+
1865
+				$geodir_bcc_listing_published_no = array(
1866
+					'name' => __('Listing published', 'geodirectory'),
1867
+					'desc' => __('No', 'geodirectory'),
1868
+					'id' => 'geodir_bcc_listing_published',
1869
+					'std' => 'yes',
1870
+					'type' => 'radio',
1871
+					'value' => '0',
1872
+					'radiogroup' => 'end'
1873
+				);
1874
+
1875
+				$new_settings[] = $geodir_bcc_listing_published_yes;
1876
+				$new_settings[] = $geodir_bcc_listing_published_no;
1877
+			}
1878
+			$new_settings[] = $setting;
1879
+		}
1880
+		$settings = $new_settings;
1881
+	}
1882 1882
 
1883
-    return $settings;
1883
+	return $settings;
1884 1884
 }
1885 1885
 
1886 1886
 
@@ -1895,19 +1895,19 @@  discard block
 block discarded – undo
1895 1895
  */
1896 1896
 function get_gd_theme_compat_callback()
1897 1897
 {
1898
-    global $wpdb;
1899
-    $themes = get_option('gd_theme_compats');
1900
-
1901
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
1902
-        if (isset($_POST['export'])) {
1903
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
1904
-        } else {
1905
-            echo json_encode($themes[$_POST['theme']]);
1906
-        }
1898
+	global $wpdb;
1899
+	$themes = get_option('gd_theme_compats');
1907 1900
 
1908
-    }
1901
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
1902
+		if (isset($_POST['export'])) {
1903
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
1904
+		} else {
1905
+			echo json_encode($themes[$_POST['theme']]);
1906
+		}
1907
+
1908
+	}
1909 1909
 
1910
-    die();
1910
+	die();
1911 1911
 }
1912 1912
 
1913 1913
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -1921,20 +1921,20 @@  discard block
 block discarded – undo
1921 1921
  */
1922 1922
 function get_gd_theme_compat_import_callback()
1923 1923
 {
1924
-    global $wpdb;
1925
-    $themes = get_option('gd_theme_compats');
1926
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
1927
-        $json = json_decode(stripslashes($_POST['theme']), true);
1928
-        if (!empty($json) && is_array($json)) {
1929
-            $key = sanitize_text_field(key($json));
1930
-            $themes[$key] = $json[$key];
1931
-            update_option('gd_theme_compats', $themes);
1932
-            echo $key;
1933
-            die();
1934
-        }
1935
-    }
1936
-    echo '0';
1937
-    die();
1924
+	global $wpdb;
1925
+	$themes = get_option('gd_theme_compats');
1926
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
1927
+		$json = json_decode(stripslashes($_POST['theme']), true);
1928
+		if (!empty($json) && is_array($json)) {
1929
+			$key = sanitize_text_field(key($json));
1930
+			$themes[$key] = $json[$key];
1931
+			update_option('gd_theme_compats', $themes);
1932
+			echo $key;
1933
+			die();
1934
+		}
1935
+	}
1936
+	echo '0';
1937
+	die();
1938 1938
 }
1939 1939
 
1940 1940
 
@@ -1947,39 +1947,39 @@  discard block
 block discarded – undo
1947 1947
  */
1948 1948
 function gd_set_theme_compat()
1949 1949
 {
1950
-    global $wpdb;
1951
-    $theme = wp_get_theme();
1950
+	global $wpdb;
1951
+	$theme = wp_get_theme();
1952 1952
 
1953
-    if ($theme->parent()) {
1954
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
1955
-    } else {
1956
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
1957
-    }
1953
+	if ($theme->parent()) {
1954
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
1955
+	} else {
1956
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
1957
+	}
1958 1958
 
1959
-    $theme_compats = get_option('gd_theme_compats');
1960
-    $current_compat = get_option('gd_theme_compat');
1961
-    $current_compat = str_replace("_custom", "", $current_compat);
1959
+	$theme_compats = get_option('gd_theme_compats');
1960
+	$current_compat = get_option('gd_theme_compat');
1961
+	$current_compat = str_replace("_custom", "", $current_compat);
1962 1962
  
1963
-    if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
1964
-        return;
1965
-    }// if already running correct compat then bail
1963
+	if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
1964
+		return;
1965
+	}// if already running correct compat then bail
1966 1966
 
1967
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
1968
-        update_option('gd_theme_compat', $theme_name);
1969
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
1967
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
1968
+		update_option('gd_theme_compat', $theme_name);
1969
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
1970 1970
 
1971
-        // if there are default options to set then set them
1972
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
1971
+		// if there are default options to set then set them
1972
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
1973 1973
 
1974
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
1975
-                update_option($key, $val);
1976
-            }
1977
-        }
1974
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
1975
+				update_option($key, $val);
1976
+			}
1977
+		}
1978 1978
 
1979
-    } else {
1980
-        update_option('gd_theme_compat', '');
1981
-        update_option('theme_compatibility_setting', '');
1982
-    }
1979
+	} else {
1980
+		update_option('gd_theme_compat', '');
1981
+		update_option('theme_compatibility_setting', '');
1982
+	}
1983 1983
 
1984 1984
 
1985 1985
 }
@@ -1994,9 +1994,9 @@  discard block
 block discarded – undo
1994 1994
  */
1995 1995
 function gd_check_avada_compat()
1996 1996
 {
1997
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
1998
-        add_action('admin_notices', 'gd_avada_compat_warning');
1999
-    }
1997
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
1998
+		add_action('admin_notices', 'gd_avada_compat_warning');
1999
+	}
2000 2000
 }
2001 2001
 
2002 2002
 
@@ -2009,22 +2009,22 @@  discard block
 block discarded – undo
2009 2009
 function gd_avada_compat_warning()
2010 2010
 {
2011 2011
 
2012
-    /*
2012
+	/*
2013 2013
     $msg_type = error
2014 2014
     $msg_type = updated fade
2015 2015
     $msg_type = update-nag
2016 2016
     */
2017 2017
 
2018
-    $plugin = 'avada-nag';
2019
-    $timestamp = 'avada-nag1234';
2020
-    $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2021
-    echo '<div id="' . $timestamp . '"  class="error">';
2022
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2023
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2024
-    echo "<p>$message</p>";
2025
-    echo "</div>";
2018
+	$plugin = 'avada-nag';
2019
+	$timestamp = 'avada-nag1234';
2020
+	$message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2021
+	echo '<div id="' . $timestamp . '"  class="error">';
2022
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2023
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2024
+	echo "<p>$message</p>";
2025
+	echo "</div>";
2026 2026
 
2027
-    ?>
2027
+	?>
2028 2028
     <script>
2029 2029
         function gdRemoveANotification($plugin, $timestamp) {
2030 2030
 
@@ -2092,10 +2092,10 @@  discard block
 block discarded – undo
2092 2092
  */
2093 2093
 function geodir_avada_remove_notification()
2094 2094
 {
2095
-    update_option('avada_nag', TRUE);
2095
+	update_option('avada_nag', TRUE);
2096 2096
 
2097
-    // Always die in functions echoing ajax content
2098
-    die();
2097
+	// Always die in functions echoing ajax content
2098
+	die();
2099 2099
 }
2100 2100
 
2101 2101
 
@@ -2117,11 +2117,11 @@  discard block
 block discarded – undo
2117 2117
 	global $post, $typenow, $current_screen;
2118 2118
 	
2119 2119
 	$post_type = NULL;
2120
-    if (isset($_REQUEST['post_type']))
2120
+	if (isset($_REQUEST['post_type']))
2121 2121
 		$post_type = sanitize_key($_REQUEST['post_type']);
2122
-    elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2122
+	elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2123 2123
 		$post_type = get_post_type($_REQUEST['post']);
2124
-    elseif ($post && isset($post->post_type))
2124
+	elseif ($post && isset($post->post_type))
2125 2125
 		$post_type = $post->post_type;
2126 2126
 	elseif ($typenow)
2127 2127
 		$post_type = $typenow;
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 		// Don't allow same slug url for listing and location
2156 2156
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2157 2157
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2158
-        	wp_redirect($redirect_url);
2158
+			wp_redirect($redirect_url);
2159 2159
 			exit;
2160 2160
 		}
2161 2161
 		
@@ -2185,10 +2185,10 @@  discard block
 block discarded – undo
2185 2185
  * @package GeoDirectory
2186 2186
  */
2187 2187
 function geodir_hide_admin_preview_button() {
2188
-    global $post_type;
2189
-    $post_types = geodir_get_posttypes();
2190
-    if(in_array($post_type, $post_types))
2191
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2188
+	global $post_type;
2189
+	$post_types = geodir_get_posttypes();
2190
+	if(in_array($post_type, $post_types))
2191
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2192 2192
 }
2193 2193
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2194 2194
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2203,7 +2203,7 @@  discard block
 block discarded – undo
2203 2203
  */
2204 2204
 function geodir_import_export_tab( $tabs ) {
2205 2205
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2206
-    return $tabs;
2206
+	return $tabs;
2207 2207
 }
2208 2208
 
2209 2209
 /**
@@ -2218,26 +2218,26 @@  discard block
 block discarded – undo
2218 2218
 function geodir_import_export_page() {
2219 2219
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2220 2220
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2221
-    /**
2222
-     * Filter sample category data csv file url.
2223
-     *
2224
-     * @since 1.0.0
2225
-     * @package GeoDirectory
2226
-     *
2227
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2228
-     */
2221
+	/**
2222
+	 * Filter sample category data csv file url.
2223
+	 *
2224
+	 * @since 1.0.0
2225
+	 * @package GeoDirectory
2226
+	 *
2227
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2228
+	 */
2229 2229
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2230 2230
 	
2231 2231
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2232
-    /**
2233
-     * Filter sample post data csv file url.
2234
-     *
2235
-     * @since 1.0.0
2236
-     * @package GeoDirectory
2237
-     *
2238
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2239
-     */
2240
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2232
+	/**
2233
+	 * Filter sample post data csv file url.
2234
+	 *
2235
+	 * @since 1.0.0
2236
+	 * @package GeoDirectory
2237
+	 *
2238
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2239
+	 */
2240
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2241 2241
 	
2242 2242
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2243 2243
 	
@@ -2260,14 +2260,14 @@  discard block
 block discarded – undo
2260 2260
 	$gd_chunksize_options[100000] = 100000;
2261 2261
 	 
2262 2262
 	 /**
2263
-     * Filter max entries per export csv file.
2264
-     *
2265
-     * @since 1.5.6
2266
-     * @package GeoDirectory
2267
-     *
2268
-     * @param string $gd_chunksize_options Entries options.
2269
-     */
2270
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2263
+	  * Filter max entries per export csv file.
2264
+	  *
2265
+	  * @since 1.5.6
2266
+	  * @package GeoDirectory
2267
+	  *
2268
+	  * @param string $gd_chunksize_options Entries options.
2269
+	  */
2270
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2271 2271
 	
2272 2272
 	$gd_chunksize_option = '';
2273 2273
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2284,12 +2284,12 @@  discard block
 block discarded – undo
2284 2284
   <div class="gd-content-heading">
2285 2285
 
2286 2286
   <?php
2287
-    ini_set('max_execution_time', 999999);
2288
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2289
-    ini_restore('max_execution_time');
2287
+	ini_set('max_execution_time', 999999);
2288
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2289
+	ini_restore('max_execution_time');
2290 2290
 
2291
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2292
-        ?>
2291
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2292
+		?>
2293 2293
 	<div id="gd_ie_reqs" class="metabox-holder">
2294 2294
       <div class="meta-box-sortables ui-sortable">
2295 2295
         <div class="postbox">
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
 						 * Called just after the sample CSV download link.
2465 2465
 						 *
2466 2466
 						 * @since 1.0.0
2467
-                         * @package GeoDirectory
2467
+						 * @package GeoDirectory
2468 2468
 						 */
2469 2469
 						do_action('geodir_sample_cats_csv_download_link');
2470 2470
 						?>
@@ -2549,11 +2549,11 @@  discard block
 block discarded – undo
2549 2549
 	 *
2550 2550
 	 * Called after the last setting on the GD > Import & Export page.
2551 2551
 	 * @since 1.4.6
2552
-     * @package GeoDirectory
2552
+	 * @package GeoDirectory
2553 2553
 	 *
2554 2554
 	 * @param array $gd_posttypes GD post types.
2555
-     * @param array $gd_chunksize_options File chunk size options.
2556
-     * @param string $nonce Wordpress security token for GD import & export.
2555
+	 * @param array $gd_chunksize_options File chunk size options.
2556
+	 * @param string $nonce Wordpress security token for GD import & export.
2557 2557
 	 */
2558 2558
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2559 2559
 	?>
@@ -3240,44 +3240,44 @@  discard block
 block discarded – undo
3240 3240
 function geodir_init_filesystem()
3241 3241
 {
3242 3242
 
3243
-    if(!function_exists('get_filesystem_method')){
3244
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3245
-    }
3246
-    $access_type = get_filesystem_method();
3247
-    if ($access_type === 'direct') {
3248
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3249
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3250
-
3251
-        /* initialize the API */
3252
-        if (!WP_Filesystem($creds)) {
3253
-            /* any problems and we exit */
3254
-            //return '@@@3';
3255
-            return false;
3256
-        }
3243
+	if(!function_exists('get_filesystem_method')){
3244
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3245
+	}
3246
+	$access_type = get_filesystem_method();
3247
+	if ($access_type === 'direct') {
3248
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3249
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3250
+
3251
+		/* initialize the API */
3252
+		if (!WP_Filesystem($creds)) {
3253
+			/* any problems and we exit */
3254
+			//return '@@@3';
3255
+			return false;
3256
+		}
3257 3257
 
3258
-        global $wp_filesystem;
3259
-        return $wp_filesystem;
3260
-        /* do our file manipulations below */
3261
-    } elseif (defined('FTP_USER')) {
3262
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3258
+		global $wp_filesystem;
3259
+		return $wp_filesystem;
3260
+		/* do our file manipulations below */
3261
+	} elseif (defined('FTP_USER')) {
3262
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3263
+
3264
+		/* initialize the API */
3265
+		if (!WP_Filesystem($creds)) {
3266
+			/* any problems and we exit */
3267
+			//return '@@@33';
3268
+			return false;
3269
+		}
3263 3270
 
3264
-        /* initialize the API */
3265
-        if (!WP_Filesystem($creds)) {
3266
-            /* any problems and we exit */
3267
-            //return '@@@33';
3268
-            return false;
3269
-        }
3271
+		global $wp_filesystem;
3272
+		//return '@@@1';
3273
+		return $wp_filesystem;
3270 3274
 
3271
-        global $wp_filesystem;
3272
-        //return '@@@1';
3273
-        return $wp_filesystem;
3274
-
3275
-    } else {
3276
-        //return '@@@2';
3277
-        /* don't have direct write access. Prompt user with our notice */
3278
-        add_action('admin_notice', 'geodir_filesystem_notice');
3279
-        return false;
3280
-    }
3275
+	} else {
3276
+		//return '@@@2';
3277
+		/* don't have direct write access. Prompt user with our notice */
3278
+		add_action('admin_notice', 'geodir_filesystem_notice');
3279
+		return false;
3280
+	}
3281 3281
 
3282 3282
 }
3283 3283
 
@@ -3295,10 +3295,10 @@  discard block
 block discarded – undo
3295 3295
  */
3296 3296
 function geodir_filesystem_notice()
3297 3297
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3298
-    $access_type = get_filesystem_method();
3299
-    if ($access_type === 'direct') {
3300
-    } elseif (!defined('FTP_USER')) {
3301
-        ?>
3298
+	$access_type = get_filesystem_method();
3299
+	if ($access_type === 'direct') {
3300
+	} elseif (!defined('FTP_USER')) {
3301
+		?>
3302 3302
         <div class="error">
3303 3303
             <p><?php _e('GeoDirectory does not have access to your filesystem, thing like import/export will not work. Please define your details in wp-config.php as explained here', 'geodirectory'); ?>
3304 3304
                 <a target="_blank" href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants</a>
@@ -3325,1267 +3325,1267 @@  discard block
 block discarded – undo
3325 3325
  * @return string Json data.
3326 3326
  */
3327 3327
 function geodir_ajax_import_export() {
3328
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3328
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3329 3329
     
3330
-    error_reporting(0);
3330
+	error_reporting(0);
3331 3331
 
3332
-    $xstart = microtime(true);
3332
+	$xstart = microtime(true);
3333 3333
 
3334
-    // try to set higher limits for import
3335
-    $max_input_time = ini_get('max_input_time');
3336
-    $max_execution_time = ini_get('max_execution_time');
3337
-    $memory_limit= ini_get('memory_limit');
3334
+	// try to set higher limits for import
3335
+	$max_input_time = ini_get('max_input_time');
3336
+	$max_execution_time = ini_get('max_execution_time');
3337
+	$memory_limit= ini_get('memory_limit');
3338 3338
 
3339
-    if(!$max_input_time || $max_input_time<3000){
3340
-        ini_set('max_input_time', 3000);
3341
-    }
3339
+	if(!$max_input_time || $max_input_time<3000){
3340
+		ini_set('max_input_time', 3000);
3341
+	}
3342 3342
 
3343
-    if(!$max_execution_time || $max_execution_time<3000){
3344
-        ini_set('max_execution_time', 3000);
3345
-    }
3343
+	if(!$max_execution_time || $max_execution_time<3000){
3344
+		ini_set('max_execution_time', 3000);
3345
+	}
3346 3346
 
3347
-    if($memory_limit && str_replace('M','',$memory_limit)){
3348
-        if(str_replace('M','',$memory_limit)<256){
3349
-            ini_set('memory_limit', '256M');
3350
-        }
3351
-    }
3347
+	if($memory_limit && str_replace('M','',$memory_limit)){
3348
+		if(str_replace('M','',$memory_limit)<256){
3349
+			ini_set('memory_limit', '256M');
3350
+		}
3351
+	}
3352 3352
 
3353
-    $json = array();
3353
+	$json = array();
3354 3354
 
3355
-    if ( !current_user_can( 'manage_options' ) ) {
3356
-        wp_send_json( $json );
3357
-    }
3355
+	if ( !current_user_can( 'manage_options' ) ) {
3356
+		wp_send_json( $json );
3357
+	}
3358 3358
 
3359
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3360
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3361
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3359
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3360
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3361
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3362 3362
 
3363
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3364
-        wp_send_json( $json );
3365
-    }
3363
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3364
+		wp_send_json( $json );
3365
+	}
3366 3366
 
3367
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3368
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3369
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3370
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3367
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3368
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3369
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3370
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3371 3371
 
3372
-    $wp_filesystem = geodir_init_filesystem();
3373
-    if (!$wp_filesystem) {
3374
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3375
-        wp_send_json( $json );
3376
-    }
3372
+	$wp_filesystem = geodir_init_filesystem();
3373
+	if (!$wp_filesystem) {
3374
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3375
+		wp_send_json( $json );
3376
+	}
3377 3377
 
3378
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3379
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3380
-        wp_send_json( $json );
3381
-    }
3378
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3379
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3380
+		wp_send_json( $json );
3381
+	}
3382 3382
 
3383
-    $csv_file_dir = geodir_path_import_export( false );
3384
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3385
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3386
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3387
-            wp_send_json( $json );
3388
-        }
3389
-    }
3383
+	$csv_file_dir = geodir_path_import_export( false );
3384
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3385
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3386
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3387
+			wp_send_json( $json );
3388
+		}
3389
+	}
3390 3390
     
3391
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3392
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3393
-
3394
-    switch ( $task ) {
3395
-        case 'export_posts': {
3396
-            // WPML
3397
-            $is_wpml = geodir_is_wpml();
3398
-            if ($is_wpml) {
3399
-                global $sitepress;
3400
-                $active_lang = ICL_LANGUAGE_CODE;
3391
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3392
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3393
+
3394
+	switch ( $task ) {
3395
+		case 'export_posts': {
3396
+			// WPML
3397
+			$is_wpml = geodir_is_wpml();
3398
+			if ($is_wpml) {
3399
+				global $sitepress;
3400
+				$active_lang = ICL_LANGUAGE_CODE;
3401 3401
                 
3402
-                $sitepress->switch_lang('all', true);
3403
-            }
3404
-            // WPML
3405
-            if ( $post_type == 'gd_event' ) {
3406
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3407
-            }
3408
-            $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3402
+				$sitepress->switch_lang('all', true);
3403
+			}
3404
+			// WPML
3405
+			if ( $post_type == 'gd_event' ) {
3406
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3407
+			}
3408
+			$filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3409 3409
             
3410
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3411
-            if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3412
-                $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3413
-            }
3414
-            $posts_count = geodir_get_posts_count( $post_type );
3415
-            $file_url_base = geodir_path_import_export() . '/';
3416
-            $file_url = $file_url_base . $file_name . '.csv';
3417
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3418
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3410
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3411
+			if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3412
+				$file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3413
+			}
3414
+			$posts_count = geodir_get_posts_count( $post_type );
3415
+			$file_url_base = geodir_path_import_export() . '/';
3416
+			$file_url = $file_url_base . $file_name . '.csv';
3417
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3418
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3419 3419
             
3420
-            $chunk_file_paths = array();
3420
+			$chunk_file_paths = array();
3421 3421
 
3422
-            if ( isset( $_REQUEST['_c'] ) ) {
3423
-                $json['total'] = $posts_count;
3424
-                // WPML
3425
-                if ($is_wpml) {
3426
-                    $sitepress->switch_lang($active_lang, true);
3427
-                }
3428
-                // WPML
3429
-                wp_send_json( $json );
3430
-                gd_die();
3431
-            } else if ( isset( $_REQUEST['_st'] ) ) {
3432
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3433
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3434
-                $percentage = min( $percentage, 100 );
3422
+			if ( isset( $_REQUEST['_c'] ) ) {
3423
+				$json['total'] = $posts_count;
3424
+				// WPML
3425
+				if ($is_wpml) {
3426
+					$sitepress->switch_lang($active_lang, true);
3427
+				}
3428
+				// WPML
3429
+				wp_send_json( $json );
3430
+				gd_die();
3431
+			} else if ( isset( $_REQUEST['_st'] ) ) {
3432
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3433
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3434
+				$percentage = min( $percentage, 100 );
3435 3435
                 
3436
-                $json['percentage'] = $percentage;
3437
-                // WPML
3438
-                if ($is_wpml) {
3439
-                    $sitepress->switch_lang($active_lang, true);
3440
-                }
3441
-                // WPML
3442
-                wp_send_json( $json );
3443
-                gd_die();
3444
-            } else {
3445
-                if ( !$posts_count > 0 ) {
3446
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3447
-                } else {
3448
-                    $total_posts = $posts_count;
3449
-                    if ($chunk_per_page > $total_posts) {
3450
-                        $chunk_per_page = $total_posts;
3451
-                    }
3452
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3436
+				$json['percentage'] = $percentage;
3437
+				// WPML
3438
+				if ($is_wpml) {
3439
+					$sitepress->switch_lang($active_lang, true);
3440
+				}
3441
+				// WPML
3442
+				wp_send_json( $json );
3443
+				gd_die();
3444
+			} else {
3445
+				if ( !$posts_count > 0 ) {
3446
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3447
+				} else {
3448
+					$total_posts = $posts_count;
3449
+					if ($chunk_per_page > $total_posts) {
3450
+						$chunk_per_page = $total_posts;
3451
+					}
3452
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3453 3453
                     
3454
-                    $j = $chunk_page_no;
3455
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3454
+					$j = $chunk_page_no;
3455
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3456 3456
                     
3457
-                    $per_page = 500;
3458
-                    if ($per_page > $chunk_per_page) {
3459
-                        $per_page = $chunk_per_page;
3460
-                    }
3461
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3457
+					$per_page = 500;
3458
+					if ($per_page > $chunk_per_page) {
3459
+						$per_page = $chunk_per_page;
3460
+					}
3461
+					$total_pages = ceil( $chunk_per_page / $per_page );
3462 3462
                     
3463
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3464
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3463
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3464
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3465 3465
                         
3466
-                        $clear = $i == 0 ? true : false;
3467
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3468
-                    }
3466
+						$clear = $i == 0 ? true : false;
3467
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3468
+					}
3469 3469
                         
3470
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3471
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3472
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3473
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3474
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3470
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3471
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3472
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3473
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3474
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3475 3475
                         
3476
-                        $file_url = $file_url_base . $chunk_file_name;
3477
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3478
-                    }
3476
+						$file_url = $file_url_base . $chunk_file_name;
3477
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3478
+					}
3479 3479
                     
3480
-                    if ( !empty($chunk_file_paths) ) {
3481
-                        $json['total'] = $posts_count;
3482
-                        $json['files'] = $chunk_file_paths;
3483
-                    } else {
3484
-                        if ($j > 1) {
3485
-                            $json['total'] = $posts_count;
3486
-                            $json['files'] = array();
3487
-                        } else {
3488
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3489
-                        }
3490
-                    }
3491
-                }
3492
-                // WPML
3493
-                if ($is_wpml) {
3494
-                    $sitepress->switch_lang($active_lang, true);
3495
-                }
3496
-                // WPML
3497
-                wp_send_json( $json );
3498
-            }
3499
-        }
3500
-        break;
3501
-        case 'export_cats': {
3502
-            // WPML
3503
-            $is_wpml = geodir_is_wpml();
3504
-            if ($is_wpml) {
3505
-                global $sitepress;
3506
-                $active_lang = ICL_LANGUAGE_CODE;
3480
+					if ( !empty($chunk_file_paths) ) {
3481
+						$json['total'] = $posts_count;
3482
+						$json['files'] = $chunk_file_paths;
3483
+					} else {
3484
+						if ($j > 1) {
3485
+							$json['total'] = $posts_count;
3486
+							$json['files'] = array();
3487
+						} else {
3488
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3489
+						}
3490
+					}
3491
+				}
3492
+				// WPML
3493
+				if ($is_wpml) {
3494
+					$sitepress->switch_lang($active_lang, true);
3495
+				}
3496
+				// WPML
3497
+				wp_send_json( $json );
3498
+			}
3499
+		}
3500
+		break;
3501
+		case 'export_cats': {
3502
+			// WPML
3503
+			$is_wpml = geodir_is_wpml();
3504
+			if ($is_wpml) {
3505
+				global $sitepress;
3506
+				$active_lang = ICL_LANGUAGE_CODE;
3507 3507
                 
3508
-                $sitepress->switch_lang('all', true);
3509
-            }
3510
-            // WPML
3511
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3508
+				$sitepress->switch_lang('all', true);
3509
+			}
3510
+			// WPML
3511
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3512 3512
             
3513
-            $terms_count = geodir_get_terms_count( $post_type );
3514
-            $file_url_base = geodir_path_import_export() . '/';
3515
-            $file_url = $file_url_base . $file_name . '.csv';
3516
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3517
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3513
+			$terms_count = geodir_get_terms_count( $post_type );
3514
+			$file_url_base = geodir_path_import_export() . '/';
3515
+			$file_url = $file_url_base . $file_name . '.csv';
3516
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3517
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3518 3518
             
3519
-            $chunk_file_paths = array();
3519
+			$chunk_file_paths = array();
3520 3520
             
3521
-            if ( isset( $_REQUEST['_st'] ) ) {
3522
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3523
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3524
-                $percentage = min( $percentage, 100 );
3521
+			if ( isset( $_REQUEST['_st'] ) ) {
3522
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3523
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3524
+				$percentage = min( $percentage, 100 );
3525 3525
                 
3526
-                $json['percentage'] = $percentage;
3527
-                // WPML
3528
-                if ($is_wpml) {
3529
-                    $sitepress->switch_lang($active_lang, true);
3530
-                }
3531
-                // WPML
3532
-                wp_send_json( $json );
3533
-            } else {
3534
-                if ( !$terms_count > 0 ) {
3535
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3536
-                } else {
3537
-                    $total_terms = $terms_count;
3538
-                    if ($chunk_per_page > $terms_count) {
3539
-                        $chunk_per_page = $terms_count;
3540
-                    }
3541
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3526
+				$json['percentage'] = $percentage;
3527
+				// WPML
3528
+				if ($is_wpml) {
3529
+					$sitepress->switch_lang($active_lang, true);
3530
+				}
3531
+				// WPML
3532
+				wp_send_json( $json );
3533
+			} else {
3534
+				if ( !$terms_count > 0 ) {
3535
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3536
+				} else {
3537
+					$total_terms = $terms_count;
3538
+					if ($chunk_per_page > $terms_count) {
3539
+						$chunk_per_page = $terms_count;
3540
+					}
3541
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3542 3542
                     
3543
-                    $j = $chunk_page_no;
3544
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3543
+					$j = $chunk_page_no;
3544
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3545 3545
                     
3546
-                    $per_page = 500;
3547
-                    if ($per_page > $chunk_per_page) {
3548
-                        $per_page = $chunk_per_page;
3549
-                    }
3550
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3546
+					$per_page = 500;
3547
+					if ($per_page > $chunk_per_page) {
3548
+						$per_page = $chunk_per_page;
3549
+					}
3550
+					$total_pages = ceil( $chunk_per_page / $per_page );
3551 3551
                     
3552
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3553
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3552
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3553
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3554 3554
                         
3555
-                        $clear = $i == 0 ? true : false;
3556
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3557
-                    }
3555
+						$clear = $i == 0 ? true : false;
3556
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3557
+					}
3558 3558
                     
3559
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3560
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3561
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3562
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3563
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3559
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3560
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3561
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3562
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3563
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3564 3564
                         
3565
-                        $file_url = $file_url_base . $chunk_file_name;
3566
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3567
-                    }
3565
+						$file_url = $file_url_base . $chunk_file_name;
3566
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3567
+					}
3568 3568
                     
3569
-                    if ( !empty($chunk_file_paths) ) {
3570
-                        $json['total'] = $terms_count;
3571
-                        $json['files'] = $chunk_file_paths;
3572
-                    } else {
3573
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3574
-                    }
3575
-                }
3576
-                // WPML
3577
-                if ($is_wpml) {
3578
-                    $sitepress->switch_lang($active_lang, true);
3579
-                }
3580
-                // WPML
3581
-                wp_send_json( $json );
3582
-            }
3583
-        }
3584
-        break;
3585
-        case 'export_locations': {
3586
-            $file_url_base = geodir_path_import_export() . '/';
3587
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3588
-            $file_url = $file_url_base . $file_name . '.csv';
3589
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3590
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3569
+					if ( !empty($chunk_file_paths) ) {
3570
+						$json['total'] = $terms_count;
3571
+						$json['files'] = $chunk_file_paths;
3572
+					} else {
3573
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3574
+					}
3575
+				}
3576
+				// WPML
3577
+				if ($is_wpml) {
3578
+					$sitepress->switch_lang($active_lang, true);
3579
+				}
3580
+				// WPML
3581
+				wp_send_json( $json );
3582
+			}
3583
+		}
3584
+		break;
3585
+		case 'export_locations': {
3586
+			$file_url_base = geodir_path_import_export() . '/';
3587
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3588
+			$file_url = $file_url_base . $file_name . '.csv';
3589
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3590
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3591 3591
             
3592
-            $items_count = (int)geodir_location_imex_count_locations();
3592
+			$items_count = (int)geodir_location_imex_count_locations();
3593 3593
             
3594
-            if ( isset( $_REQUEST['_st'] ) ) {
3595
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3596
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3597
-                $percentage = min( $percentage, 100 );
3594
+			if ( isset( $_REQUEST['_st'] ) ) {
3595
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3596
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3597
+				$percentage = min( $percentage, 100 );
3598 3598
                 
3599
-                $json['percentage'] = $percentage;
3600
-                wp_send_json( $json );
3601
-            } else {
3602
-                $chunk_file_paths = array();
3599
+				$json['percentage'] = $percentage;
3600
+				wp_send_json( $json );
3601
+			} else {
3602
+				$chunk_file_paths = array();
3603 3603
                 
3604
-                if ( !$items_count > 0 ) {
3605
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3606
-                } else {
3607
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3608
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3604
+				if ( !$items_count > 0 ) {
3605
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3606
+				} else {
3607
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3608
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3609 3609
                     
3610
-                    $j = $chunk_page_no;
3611
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3610
+					$j = $chunk_page_no;
3611
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3612 3612
                     
3613
-                    $per_page = 500;
3614
-                    $per_page = min( $per_page, $chunk_per_page );
3615
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3613
+					$per_page = 500;
3614
+					$per_page = min( $per_page, $chunk_per_page );
3615
+					$total_pages = ceil( $chunk_per_page / $per_page );
3616 3616
                     
3617
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3618
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3617
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3618
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3619 3619
                         
3620
-                        $clear = $i == 0 ? true : false;
3621
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3622
-                    }
3620
+						$clear = $i == 0 ? true : false;
3621
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3622
+					}
3623 3623
                     
3624
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3625
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3626
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3627
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3628
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3624
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3625
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3626
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3627
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3628
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3629 3629
                         
3630
-                        $file_url = $file_url_base . $chunk_file_name;
3631
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3632
-                    }
3630
+						$file_url = $file_url_base . $chunk_file_name;
3631
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3632
+					}
3633 3633
                     
3634
-                    if ( !empty($chunk_file_paths) ) {
3635
-                        $json['total'] = $items_count;
3636
-                        $json['files'] = $chunk_file_paths;
3637
-                    } else {
3638
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3639
-                    }
3640
-                }
3641
-                wp_send_json( $json );
3642
-            }
3643
-        }
3644
-        break;
3645
-        case 'export_hoods': {
3646
-            $file_url_base = geodir_path_import_export() . '/';
3647
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3648
-            $file_url = $file_url_base . $file_name . '.csv';
3649
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3650
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3634
+					if ( !empty($chunk_file_paths) ) {
3635
+						$json['total'] = $items_count;
3636
+						$json['files'] = $chunk_file_paths;
3637
+					} else {
3638
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3639
+					}
3640
+				}
3641
+				wp_send_json( $json );
3642
+			}
3643
+		}
3644
+		break;
3645
+		case 'export_hoods': {
3646
+			$file_url_base = geodir_path_import_export() . '/';
3647
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3648
+			$file_url = $file_url_base . $file_name . '.csv';
3649
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3650
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3651 3651
             
3652
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3652
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3653 3653
             
3654
-            if ( isset( $_REQUEST['_st'] ) ) {
3655
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3656
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3657
-                $percentage = min( $percentage, 100 );
3654
+			if ( isset( $_REQUEST['_st'] ) ) {
3655
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3656
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3657
+				$percentage = min( $percentage, 100 );
3658 3658
                 
3659
-                $json['percentage'] = $percentage;
3660
-                wp_send_json( $json );
3661
-            } else {
3662
-                $chunk_file_paths = array();
3659
+				$json['percentage'] = $percentage;
3660
+				wp_send_json( $json );
3661
+			} else {
3662
+				$chunk_file_paths = array();
3663 3663
                 
3664
-                if ( !$items_count > 0 ) {
3665
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3666
-                } else {
3667
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3668
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3664
+				if ( !$items_count > 0 ) {
3665
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3666
+				} else {
3667
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3668
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3669 3669
                     
3670
-                    $j = $chunk_page_no;
3671
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3670
+					$j = $chunk_page_no;
3671
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3672 3672
                     
3673
-                    $per_page = 500;
3674
-                    $per_page = min( $per_page, $chunk_per_page );
3675
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3673
+					$per_page = 500;
3674
+					$per_page = min( $per_page, $chunk_per_page );
3675
+					$total_pages = ceil( $chunk_per_page / $per_page );
3676 3676
                     
3677
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3678
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3677
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3678
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3679 3679
                         
3680
-                        $clear = $i == 0 ? true : false;
3681
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3682
-                    }
3680
+						$clear = $i == 0 ? true : false;
3681
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3682
+					}
3683 3683
                     
3684
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3685
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3686
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3687
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3688
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3684
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3685
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3686
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3687
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3688
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3689 3689
                         
3690
-                        $file_url = $file_url_base . $chunk_file_name;
3691
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3692
-                    }
3690
+						$file_url = $file_url_base . $chunk_file_name;
3691
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3692
+					}
3693 3693
                     
3694
-                    if ( !empty($chunk_file_paths) ) {
3695
-                        $json['total'] = $items_count;
3696
-                        $json['files'] = $chunk_file_paths;
3697
-                    } else {
3698
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3699
-                    }
3700
-                }
3701
-                wp_send_json( $json );
3702
-            }
3703
-        }
3704
-        break;
3705
-        case 'prepare_import':
3706
-        case 'import_cat':
3707
-        case 'import_post':
3708
-        case 'import_loc':
3709
-        case 'import_hood': {
3710
-            // WPML
3711
-            $is_wpml = geodir_is_wpml();
3712
-            if ($is_wpml) {
3713
-                global $sitepress;
3714
-                $active_lang = ICL_LANGUAGE_CODE;
3715
-            }
3716
-            // WPML
3694
+					if ( !empty($chunk_file_paths) ) {
3695
+						$json['total'] = $items_count;
3696
+						$json['files'] = $chunk_file_paths;
3697
+					} else {
3698
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3699
+					}
3700
+				}
3701
+				wp_send_json( $json );
3702
+			}
3703
+		}
3704
+		break;
3705
+		case 'prepare_import':
3706
+		case 'import_cat':
3707
+		case 'import_post':
3708
+		case 'import_loc':
3709
+		case 'import_hood': {
3710
+			// WPML
3711
+			$is_wpml = geodir_is_wpml();
3712
+			if ($is_wpml) {
3713
+				global $sitepress;
3714
+				$active_lang = ICL_LANGUAGE_CODE;
3715
+			}
3716
+			// WPML
3717 3717
             
3718
-            ini_set( 'auto_detect_line_endings', true );
3718
+			ini_set( 'auto_detect_line_endings', true );
3719 3719
             
3720
-            $uploads = wp_upload_dir();
3721
-            $uploads_dir = $uploads['path'];
3722
-            $uploads_subdir = $uploads['subdir'];
3720
+			$uploads = wp_upload_dir();
3721
+			$uploads_dir = $uploads['path'];
3722
+			$uploads_subdir = $uploads['subdir'];
3723 3723
             
3724
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3725
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3724
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3725
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3726 3726
             
3727
-            $csv_file_arr = explode( '/', $csv_file );
3728
-            $csv_filename = end( $csv_file_arr );
3729
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3727
+			$csv_file_arr = explode( '/', $csv_file );
3728
+			$csv_filename = end( $csv_file_arr );
3729
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3730 3730
             
3731
-            $json['file'] = $csv_file;
3732
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3733
-            $file = array();
3731
+			$json['file'] = $csv_file;
3732
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3733
+			$file = array();
3734 3734
 
3735
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3736
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3735
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3736
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3737 3737
                 
3738
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
3739
-                    $json['error'] = NULL;
3740
-                    $json['rows'] = 0;
3738
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
3739
+					$json['error'] = NULL;
3740
+					$json['rows'] = 0;
3741 3741
                     
3742
-                    $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
3743
-                    setlocale(LC_ALL, 'en_US.UTF-8');
3744
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
3745
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
3746
-                            if ( !empty( $data ) ) {
3747
-                                $file[] = $data;
3748
-                            }
3749
-                        }
3750
-                        fclose($handle);
3751
-                    }
3752
-                    setlocale(LC_ALL, $lc_all);
3742
+					$lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
3743
+					setlocale(LC_ALL, 'en_US.UTF-8');
3744
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
3745
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
3746
+							if ( !empty( $data ) ) {
3747
+								$file[] = $data;
3748
+							}
3749
+						}
3750
+						fclose($handle);
3751
+					}
3752
+					setlocale(LC_ALL, $lc_all);
3753 3753
 
3754
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
3754
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
3755 3755
                     
3756
-                    if (!$json['rows'] > 0) {
3757
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
3758
-                    }
3759
-                } else {
3760
-                    wp_send_json( $json );
3761
-                }
3762
-            } else {
3763
-                wp_send_json( $json );
3764
-            }
3756
+					if (!$json['rows'] > 0) {
3757
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
3758
+					}
3759
+				} else {
3760
+					wp_send_json( $json );
3761
+				}
3762
+			} else {
3763
+				wp_send_json( $json );
3764
+			}
3765 3765
             
3766
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
3767
-                wp_send_json( $json );
3768
-            }
3766
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
3767
+				wp_send_json( $json );
3768
+			}
3769 3769
             
3770
-            $total = $json['rows'];
3771
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
3772
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
3770
+			$total = $json['rows'];
3771
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
3772
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
3773 3773
             
3774
-            $count = $limit;
3774
+			$count = $limit;
3775 3775
             
3776
-            if ($count < $total) {
3777
-                $count = $processed + $count;
3778
-                if ($count > $total) {
3779
-                    $count = $total;
3780
-                }
3781
-            } else {
3782
-                $count = $total;
3783
-            }
3776
+			if ($count < $total) {
3777
+				$count = $processed + $count;
3778
+				if ($count > $total) {
3779
+					$count = $total;
3780
+				}
3781
+			} else {
3782
+				$count = $total;
3783
+			}
3784 3784
             
3785
-            $created = 0;
3786
-            $updated = 0;
3787
-            $skipped = 0;
3788
-            $invalid = 0;
3789
-            $invalid_addr = 0;
3790
-            $images = 0;
3785
+			$created = 0;
3786
+			$updated = 0;
3787
+			$skipped = 0;
3788
+			$invalid = 0;
3789
+			$invalid_addr = 0;
3790
+			$images = 0;
3791 3791
             
3792
-            $gd_post_info = array();
3793
-            $countpost = 0;
3792
+			$gd_post_info = array();
3793
+			$countpost = 0;
3794 3794
             
3795
-            $post_types = geodir_get_posttypes();
3795
+			$post_types = geodir_get_posttypes();
3796 3796
 
3797
-            if ( $task == 'import_cat' ) {
3798
-                if (!empty($file)) {
3799
-                    $columns = isset($file[0]) ? $file[0] : NULL;
3797
+			if ( $task == 'import_cat' ) {
3798
+				if (!empty($file)) {
3799
+					$columns = isset($file[0]) ? $file[0] : NULL;
3800 3800
                     
3801
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
3802
-                        $json['error'] = CSV_INVAILD_FILE;
3803
-                        wp_send_json( $json );
3804
-                        exit;
3805
-                    }
3801
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
3802
+						$json['error'] = CSV_INVAILD_FILE;
3803
+						wp_send_json( $json );
3804
+						exit;
3805
+					}
3806 3806
                     
3807
-                    $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
3807
+					$gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
3808 3808
                     
3809
-                    for ($i = 1; $i <= $limit; $i++) {
3810
-                        $index = $processed + $i;
3809
+					for ($i = 1; $i <= $limit; $i++) {
3810
+						$index = $processed + $i;
3811 3811
                         
3812
-                        if (isset($file[$index])) {
3813
-                            $row = $file[$index];
3814
-                            $row = array_map( 'trim', $row );
3815
-                            //$row = array_map( 'utf8_encode', $row );
3812
+						if (isset($file[$index])) {
3813
+							$row = $file[$index];
3814
+							$row = array_map( 'trim', $row );
3815
+							//$row = array_map( 'utf8_encode', $row );
3816 3816
                             
3817
-                            $cat_id = '';
3818
-                            $cat_name = '';
3819
-                            $cat_slug = '';
3820
-                            $cat_posttype = '';
3821
-                            $cat_parent = '';
3822
-                            $cat_description = '';
3823
-                            $cat_schema = '';
3824
-                            $cat_top_description = '';
3825
-                            $cat_image = '';
3826
-                            $cat_icon = '';
3827
-                            $cat_language = '';
3828
-                            $cat_id_original = '';
3817
+							$cat_id = '';
3818
+							$cat_name = '';
3819
+							$cat_slug = '';
3820
+							$cat_posttype = '';
3821
+							$cat_parent = '';
3822
+							$cat_description = '';
3823
+							$cat_schema = '';
3824
+							$cat_top_description = '';
3825
+							$cat_image = '';
3826
+							$cat_icon = '';
3827
+							$cat_language = '';
3828
+							$cat_id_original = '';
3829 3829
                             
3830
-                            $c = 0;
3831
-                            foreach ($columns as $column ) {
3832
-                                if ( $column == 'cat_id' ) {
3833
-                                    $cat_id = (int)$row[$c];
3834
-                                } else if ( $column == 'cat_name' ) {
3835
-                                    $cat_name = $row[$c];
3836
-                                } else if ( $column == 'cat_slug' ) {
3837
-                                    $cat_slug = $row[$c];
3838
-                                } else if ( $column == 'cat_posttype' ) {
3839
-                                    $cat_posttype = $row[$c];
3840
-                                } else if ( $column == 'cat_parent' ) {
3841
-                                    $cat_parent = trim($row[$c]);
3842
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
3843
-                                    $cat_schema = $row[$c];
3844
-                                } else if ( $column == 'cat_description' ) {
3845
-                                    $cat_description = $row[$c];
3846
-                                } else if ( $column == 'cat_top_description' ) {
3847
-                                    $cat_top_description = $row[$c];
3848
-                                } else if ( $column == 'cat_image' ) {
3849
-                                    $cat_image = $row[$c];
3850
-                                } else if ( $column == 'cat_icon' ) {
3851
-                                    $cat_icon = $row[$c];
3852
-                                }
3853
-                                // WPML
3854
-                                if ( $is_wpml ) {
3855
-                                    if ( $column == 'cat_language' ) {
3856
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
3857
-                                    } else if ( $column == 'cat_id_original' ) {
3858
-                                        $cat_id_original = (int)$row[$c];
3859
-                                    }
3860
-                                }
3861
-                                // WPML
3862
-                                $c++;
3863
-                            }
3830
+							$c = 0;
3831
+							foreach ($columns as $column ) {
3832
+								if ( $column == 'cat_id' ) {
3833
+									$cat_id = (int)$row[$c];
3834
+								} else if ( $column == 'cat_name' ) {
3835
+									$cat_name = $row[$c];
3836
+								} else if ( $column == 'cat_slug' ) {
3837
+									$cat_slug = $row[$c];
3838
+								} else if ( $column == 'cat_posttype' ) {
3839
+									$cat_posttype = $row[$c];
3840
+								} else if ( $column == 'cat_parent' ) {
3841
+									$cat_parent = trim($row[$c]);
3842
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
3843
+									$cat_schema = $row[$c];
3844
+								} else if ( $column == 'cat_description' ) {
3845
+									$cat_description = $row[$c];
3846
+								} else if ( $column == 'cat_top_description' ) {
3847
+									$cat_top_description = $row[$c];
3848
+								} else if ( $column == 'cat_image' ) {
3849
+									$cat_image = $row[$c];
3850
+								} else if ( $column == 'cat_icon' ) {
3851
+									$cat_icon = $row[$c];
3852
+								}
3853
+								// WPML
3854
+								if ( $is_wpml ) {
3855
+									if ( $column == 'cat_language' ) {
3856
+										$cat_language = geodir_strtolower( trim( $row[$c] ) );
3857
+									} else if ( $column == 'cat_id_original' ) {
3858
+										$cat_id_original = (int)$row[$c];
3859
+									}
3860
+								}
3861
+								// WPML
3862
+								$c++;
3863
+							}
3864 3864
                             
3865
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
3866
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
3865
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
3866
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
3867 3867
                                 
3868
-                                $invalid++;
3869
-                                continue;
3870
-                            }
3868
+								$invalid++;
3869
+								continue;
3870
+							}
3871 3871
                             
3872
-                            // WPML
3873
-                            if ($is_wpml && $cat_language != '') {
3874
-                                $sitepress->switch_lang($cat_language, true);
3875
-                            }
3876
-                            // WPML
3872
+							// WPML
3873
+							if ($is_wpml && $cat_language != '') {
3874
+								$sitepress->switch_lang($cat_language, true);
3875
+							}
3876
+							// WPML
3877 3877
                                                         
3878
-                            $term_data = array();
3879
-                            $term_data['name'] = $cat_name;
3880
-                            $term_data['slug'] = $cat_slug;
3881
-                            $term_data['description'] = $cat_description;
3882
-                            $term_data['cat_schema'] = $cat_schema;
3883
-                            $term_data['top_description'] = $cat_top_description;
3884
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
3885
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
3878
+							$term_data = array();
3879
+							$term_data['name'] = $cat_name;
3880
+							$term_data['slug'] = $cat_slug;
3881
+							$term_data['description'] = $cat_description;
3882
+							$term_data['cat_schema'] = $cat_schema;
3883
+							$term_data['top_description'] = $cat_top_description;
3884
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
3885
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
3886 3886
                             
3887
-                            //$term_data = array_map( 'utf8_encode', $term_data );
3887
+							//$term_data = array_map( 'utf8_encode', $term_data );
3888 3888
                             
3889
-                            $taxonomy = $cat_posttype . 'category';
3889
+							$taxonomy = $cat_posttype . 'category';
3890 3890
                             
3891
-                            $term_data['taxonomy'] = $taxonomy;
3891
+							$term_data['taxonomy'] = $taxonomy;
3892 3892
 
3893
-                            $term_parent_id = 0;
3894
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
3895
-                                $term_parent = '';
3893
+							$term_parent_id = 0;
3894
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
3895
+								$term_parent = '';
3896 3896
                                 
3897
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
3898
-                                    //
3899
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
3900
-                                    //
3901
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
3902
-                                    //
3903
-                                } else {
3904
-                                    $term_parent_data = array();
3905
-                                    $term_parent_data['name'] = $cat_parent;
3906
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
3907
-                                    $term_parent_data['taxonomy'] = $taxonomy;
3897
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
3898
+									//
3899
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
3900
+									//
3901
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
3902
+									//
3903
+								} else {
3904
+									$term_parent_data = array();
3905
+									$term_parent_data['name'] = $cat_parent;
3906
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
3907
+									$term_parent_data['taxonomy'] = $taxonomy;
3908 3908
                                     
3909
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
3910
-                                }
3909
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
3910
+								}
3911 3911
                                 
3912
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
3913
-                                    $term_parent_id = (int)$term_parent->term_id;
3914
-                                }
3915
-                            }
3916
-                            $term_data['parent'] = (int)$term_parent_id;
3912
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
3913
+									$term_parent_id = (int)$term_parent->term_id;
3914
+								}
3915
+							}
3916
+							$term_data['parent'] = (int)$term_parent_id;
3917 3917
 
3918
-                            $term_id = NULL;
3919
-                            if ( $import_choice == 'update' ) {
3920
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3921
-                                    $term_data['term_id'] = $term['term_id'];
3918
+							$term_id = NULL;
3919
+							if ( $import_choice == 'update' ) {
3920
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3921
+									$term_data['term_id'] = $term['term_id'];
3922 3922
                                     
3923
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3924
-                                        $updated++;
3925
-                                    } else {
3926
-                                        $invalid++;
3927
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3928
-                                    }
3929
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3930
-                                    $term_data['term_id'] = $term['term_id'];
3923
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3924
+										$updated++;
3925
+									} else {
3926
+										$invalid++;
3927
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3928
+									}
3929
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3930
+									$term_data['term_id'] = $term['term_id'];
3931 3931
                                     
3932
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3933
-                                        $updated++;
3934
-                                    } else {
3935
-                                        $invalid++;
3936
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3937
-                                    }
3938
-                                } else {
3939
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3940
-                                        $created++;
3941
-                                    } else {
3942
-                                        $invalid++;
3943
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3944
-                                    }
3945
-                                }
3946
-                            } else if ( $import_choice == 'skip' ) {
3947
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3948
-                                    $skipped++;
3949
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3950
-                                    $skipped++;
3951
-                                } else {
3952
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3953
-                                        $created++;
3954
-                                    } else {
3955
-                                        $invalid++;
3956
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3957
-                                    }
3958
-                                }
3959
-                            } else {
3960
-                                $invalid++;
3961
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3962
-                            }
3932
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3933
+										$updated++;
3934
+									} else {
3935
+										$invalid++;
3936
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3937
+									}
3938
+								} else {
3939
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3940
+										$created++;
3941
+									} else {
3942
+										$invalid++;
3943
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3944
+									}
3945
+								}
3946
+							} else if ( $import_choice == 'skip' ) {
3947
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3948
+									$skipped++;
3949
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3950
+									$skipped++;
3951
+								} else {
3952
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3953
+										$created++;
3954
+									} else {
3955
+										$invalid++;
3956
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3957
+									}
3958
+								}
3959
+							} else {
3960
+								$invalid++;
3961
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3962
+							}
3963 3963
                             
3964
-                            if ( $term_id ) {
3965
-                                // WPML
3966
-                                if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
3967
-                                    $wpml_element_type = 'tax_' . $taxonomy;
3968
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
3969
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
3970
-
3971
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
3964
+							if ( $term_id ) {
3965
+								// WPML
3966
+								if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
3967
+									$wpml_element_type = 'tax_' . $taxonomy;
3968
+									$source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
3969
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
3970
+
3971
+									$trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
3972 3972
                                     
3973
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
3974
-                                }
3975
-                                // WPML
3973
+									$sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
3974
+								}
3975
+								// WPML
3976 3976
                                 
3977
-                                if ( isset( $term_data['top_description'] ) ) {
3978
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
3979
-                                }
3977
+								if ( isset( $term_data['top_description'] ) ) {
3978
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
3979
+								}
3980 3980
                                 
3981
-                                if ( isset( $term_data['cat_schema'] ) ) {
3982
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
3983
-                                }
3981
+								if ( isset( $term_data['cat_schema'] ) ) {
3982
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
3983
+								}
3984 3984
             
3985
-                                $attachment = false;
3986
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
3987
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
3988
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
3985
+								$attachment = false;
3986
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
3987
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
3988
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
3989 3989
                                     
3990
-                                    if ( basename($cat_image) != $term_data['image'] ) {
3991
-                                        $attachment = true;
3992
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
3993
-                                    }
3994
-                                }
3990
+									if ( basename($cat_image) != $term_data['image'] ) {
3991
+										$attachment = true;
3992
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
3993
+									}
3994
+								}
3995 3995
                                 
3996
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
3997
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
3998
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
3999
-
4000
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4001
-                                        $attachment = true;
4002
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4003
-                                    }
4004
-                                }
3996
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
3997
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
3998
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
3999
+
4000
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4001
+										$attachment = true;
4002
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4003
+									}
4004
+								}
4005 4005
                                 
4006
-                                if ( $attachment ) {
4007
-                                    $images++;
4008
-                                }
4009
-                            }
4006
+								if ( $attachment ) {
4007
+									$images++;
4008
+								}
4009
+							}
4010 4010
                             
4011
-                            // WPML
4012
-                            if ($is_wpml && $cat_language != '') {
4013
-                                $sitepress->switch_lang($active_lang, true);
4014
-                            }
4015
-                            // WPML
4016
-                        }
4017
-                    }
4018
-                }
4011
+							// WPML
4012
+							if ($is_wpml && $cat_language != '') {
4013
+								$sitepress->switch_lang($active_lang, true);
4014
+							}
4015
+							// WPML
4016
+						}
4017
+					}
4018
+				}
4019 4019
                 
4020
-                $json = array();
4021
-                $json['processed'] = $limit;
4022
-                $json['created'] = $created;
4023
-                $json['updated'] = $updated;
4024
-                $json['skipped'] = $skipped;
4025
-                $json['invalid'] = $invalid;
4026
-                $json['images'] = $images;
4020
+				$json = array();
4021
+				$json['processed'] = $limit;
4022
+				$json['created'] = $created;
4023
+				$json['updated'] = $updated;
4024
+				$json['skipped'] = $skipped;
4025
+				$json['invalid'] = $invalid;
4026
+				$json['images'] = $images;
4027 4027
                 
4028
-                wp_send_json( $json );
4029
-                exit;
4030
-            } else if ( $task == 'import_post' ) {
4031
-                $xtimings['###1'] = microtime(true)-$xstart;
4032
-                //run some stuff to make the import quicker
4033
-                wp_defer_term_counting( true );
4034
-                wp_defer_comment_counting( true );
4035
-                $wpdb->query( 'SET autocommit = 0;' );
4028
+				wp_send_json( $json );
4029
+				exit;
4030
+			} else if ( $task == 'import_post' ) {
4031
+				$xtimings['###1'] = microtime(true)-$xstart;
4032
+				//run some stuff to make the import quicker
4033
+				wp_defer_term_counting( true );
4034
+				wp_defer_comment_counting( true );
4035
+				$wpdb->query( 'SET autocommit = 0;' );
4036 4036
 //
4037 4037
 //                remove_all_actions('publish_post');
4038 4038
 //                remove_all_actions('transition_post_status');
4039 4039
 //                remove_all_actions('publish_future_post');
4040 4040
 
4041
-                if (!empty($file)) {
4042
-                    $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4043
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4044
-                    $default_status = 'publish';
4045
-                    $current_date = date_i18n( 'Y-m-d', time() );
4041
+				if (!empty($file)) {
4042
+					$is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4043
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4044
+					$default_status = 'publish';
4045
+					$current_date = date_i18n( 'Y-m-d', time() );
4046 4046
                     
4047
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4047
+					$columns = isset($file[0]) ? $file[0] : NULL;
4048 4048
                     
4049
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4050
-                        $json['error'] = CSV_INVAILD_FILE;
4051
-                        wp_send_json( $json );
4052
-                        exit;
4053
-                    }
4054
-                    $xtimings['###2'] = microtime(true)-$xstart;
4055
-                    $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4056
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4057
-                    $processed_actual = 0;
4058
-                    for ($i = 1; $i <= $limit; $i++) {
4059
-                        $index = $processed + $i;
4060
-                        $gd_post = array();
4049
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4050
+						$json['error'] = CSV_INVAILD_FILE;
4051
+						wp_send_json( $json );
4052
+						exit;
4053
+					}
4054
+					$xtimings['###2'] = microtime(true)-$xstart;
4055
+					$gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4056
+					$wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4057
+					$processed_actual = 0;
4058
+					for ($i = 1; $i <= $limit; $i++) {
4059
+						$index = $processed + $i;
4060
+						$gd_post = array();
4061 4061
                         
4062
-                        if (isset($file[$index])) {
4063
-                            $processed_actual++;
4064
-                            $row = $file[$index];
4065
-                            $row = array_map( 'trim', $row );
4066
-                            //$row = array_map( 'utf8_encode', $row );
4067
-                            $row = array_map( 'addslashes_gpc', $row );
4062
+						if (isset($file[$index])) {
4063
+							$processed_actual++;
4064
+							$row = $file[$index];
4065
+							$row = array_map( 'trim', $row );
4066
+							//$row = array_map( 'utf8_encode', $row );
4067
+							$row = array_map( 'addslashes_gpc', $row );
4068 4068
                             
4069
-                            $post_id = '';
4070
-                            $post_title = '';
4071
-                            $post_date = '';
4072
-                            $post_author = '';
4073
-                            $post_content = '';
4074
-                            $post_category_arr = array();
4075
-                            $default_category = '';
4076
-                            $post_tags = array();
4077
-                            $post_type = '';
4078
-                            $post_status = '';
4079
-                            $geodir_video = '';
4080
-                            $post_address = '';
4081
-                            $post_city = '';
4082
-                            $post_region = '';
4083
-                            $post_country = '';
4084
-                            $post_zip = '';
4085
-                            $post_latitude = '';
4086
-                            $post_longitude = '';
4087
-                            $post_neighbourhood = '';
4088
-                            $neighbourhood_latitude = '';
4089
-                            $neighbourhood_longitude = '';
4090
-                            $geodir_timing = '';
4091
-                            $geodir_contact = '';
4092
-                            $geodir_email = '';
4093
-                            $geodir_website = '';
4094
-                            $geodir_twitter = '';
4095
-                            $geodir_facebook = '';
4096
-                            $geodir_twitter = '';
4097
-                            $post_images = array();
4069
+							$post_id = '';
4070
+							$post_title = '';
4071
+							$post_date = '';
4072
+							$post_author = '';
4073
+							$post_content = '';
4074
+							$post_category_arr = array();
4075
+							$default_category = '';
4076
+							$post_tags = array();
4077
+							$post_type = '';
4078
+							$post_status = '';
4079
+							$geodir_video = '';
4080
+							$post_address = '';
4081
+							$post_city = '';
4082
+							$post_region = '';
4083
+							$post_country = '';
4084
+							$post_zip = '';
4085
+							$post_latitude = '';
4086
+							$post_longitude = '';
4087
+							$post_neighbourhood = '';
4088
+							$neighbourhood_latitude = '';
4089
+							$neighbourhood_longitude = '';
4090
+							$geodir_timing = '';
4091
+							$geodir_contact = '';
4092
+							$geodir_email = '';
4093
+							$geodir_website = '';
4094
+							$geodir_twitter = '';
4095
+							$geodir_facebook = '';
4096
+							$geodir_twitter = '';
4097
+							$post_images = array();
4098 4098
                             
4099
-                            $expire_date = 'Never';
4099
+							$expire_date = 'Never';
4100 4100
                             
4101
-                            $language = '';
4102
-                            $original_post_id = '';
4101
+							$language = '';
4102
+							$original_post_id = '';
4103 4103
                             
4104
-                            $c = 0;
4105
-                            foreach ($columns as $column ) {
4106
-                                $gd_post[$column] = $row[$c];
4104
+							$c = 0;
4105
+							foreach ($columns as $column ) {
4106
+								$gd_post[$column] = $row[$c];
4107 4107
                                 
4108
-                                if ( $column == 'post_id' ) {
4109
-                                    $post_id = $row[$c];
4110
-                                } else if ( $column == 'post_title' ) {
4111
-                                    $post_title = sanitize_text_field($row[$c]);
4112
-                                } else if ( $column == 'post_author' ) {
4113
-                                    $post_author = $row[$c];
4114
-                                } else if ( $column == 'post_date' ) {
4115
-                                    $post_date = $row[$c];
4116
-                                } else if ( $column == 'post_content' ) {
4117
-                                    $post_content = $row[$c];
4118
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4119
-                                    $post_category_arr = explode( ',', $row[$c] );
4120
-                                } else if ( $column == 'default_category' ) {
4121
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4122
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4123
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4124
-                                } else if ( $column == 'post_type' ) {
4125
-                                    $post_type = $row[$c];
4126
-                                } else if ( $column == 'post_status' ) {
4127
-                                    $post_status = sanitize_key( $row[$c] );
4128
-                                } else if ( $column == 'is_featured' ) {
4129
-                                    $is_featured = (int)$row[$c];
4130
-                                } else if ( $column == 'geodir_video' ) {
4131
-                                    $geodir_video = $row[$c];
4132
-                                } else if ( $column == 'post_address' ) {
4133
-                                    $post_address = sanitize_text_field($row[$c]);
4134
-                                } else if ( $column == 'post_city' ) {
4135
-                                    $post_city = sanitize_text_field($row[$c]);
4136
-                                } else if ( $column == 'post_region' ) {
4137
-                                    $post_region = sanitize_text_field($row[$c]);
4138
-                                } else if ( $column == 'post_country' ) {
4139
-                                    $post_country = sanitize_text_field($row[$c]);
4140
-                                } else if ( $column == 'post_zip' ) {
4141
-                                    $post_zip = sanitize_text_field($row[$c]);
4142
-                                } else if ( $column == 'post_latitude' ) {
4143
-                                    $post_latitude = sanitize_text_field($row[$c]);
4144
-                                } else if ( $column == 'post_longitude' ) {
4145
-                                    $post_longitude = sanitize_text_field($row[$c]);
4146
-                                } else if ( $column == 'post_neighbourhood' ) {
4147
-                                    $post_neighbourhood = sanitize_text_field($row[$c]);
4148
-                                    unset($gd_post[$column]);
4149
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4150
-                                    $neighbourhood_latitude = sanitize_text_field($row[$c]);
4151
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4152
-                                    $neighbourhood_longitude = sanitize_text_field($row[$c]);
4153
-                                } else if ( $column == 'geodir_timing' ) {
4154
-                                    $geodir_timing = sanitize_text_field($row[$c]);
4155
-                                } else if ( $column == 'geodir_contact' ) {
4156
-                                    $geodir_contact = sanitize_text_field($row[$c]);
4157
-                                } else if ( $column == 'geodir_email' ) {
4158
-                                    $geodir_email = sanitize_email($row[$c]);
4159
-                                } else if ( $column == 'geodir_website' ) {
4160
-                                    $geodir_website = sanitize_text_field($row[$c]);
4161
-                                } else if ( $column == 'geodir_twitter' ) {
4162
-                                    $geodir_twitter = sanitize_text_field($row[$c]);
4163
-                                } else if ( $column == 'geodir_facebook' ) {
4164
-                                    $geodir_facebook = sanitize_text_field($row[$c]);
4165
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4166
-                                    $post_images[] = $row[$c];
4167
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4168
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4169
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4170
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4171
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4172
-                                }
4173
-                                // WPML
4174
-                                if ($is_wpml) {
4175
-                                    if ($column == 'language') {
4176
-                                        $language = geodir_strtolower(trim($row[$c]));
4177
-                                    } else if ($column == 'original_post_id') {
4178
-                                        $original_post_id = (int)$row[$c];
4179
-                                    }
4180
-                                }
4181
-                                // WPML
4182
-                                $c++;
4183
-                            }
4184
-                            // listing claimed or not
4185
-                            if ($is_claim_active && isset($gd_post['claimed'])) {
4186
-                                $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4187
-                            }
4108
+								if ( $column == 'post_id' ) {
4109
+									$post_id = $row[$c];
4110
+								} else if ( $column == 'post_title' ) {
4111
+									$post_title = sanitize_text_field($row[$c]);
4112
+								} else if ( $column == 'post_author' ) {
4113
+									$post_author = $row[$c];
4114
+								} else if ( $column == 'post_date' ) {
4115
+									$post_date = $row[$c];
4116
+								} else if ( $column == 'post_content' ) {
4117
+									$post_content = $row[$c];
4118
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4119
+									$post_category_arr = explode( ',', $row[$c] );
4120
+								} else if ( $column == 'default_category' ) {
4121
+									$default_category = wp_kses_normalize_entities($row[$c]);
4122
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4123
+									$post_tags = explode( ',', sanitize_text_field($row[$c]) );
4124
+								} else if ( $column == 'post_type' ) {
4125
+									$post_type = $row[$c];
4126
+								} else if ( $column == 'post_status' ) {
4127
+									$post_status = sanitize_key( $row[$c] );
4128
+								} else if ( $column == 'is_featured' ) {
4129
+									$is_featured = (int)$row[$c];
4130
+								} else if ( $column == 'geodir_video' ) {
4131
+									$geodir_video = $row[$c];
4132
+								} else if ( $column == 'post_address' ) {
4133
+									$post_address = sanitize_text_field($row[$c]);
4134
+								} else if ( $column == 'post_city' ) {
4135
+									$post_city = sanitize_text_field($row[$c]);
4136
+								} else if ( $column == 'post_region' ) {
4137
+									$post_region = sanitize_text_field($row[$c]);
4138
+								} else if ( $column == 'post_country' ) {
4139
+									$post_country = sanitize_text_field($row[$c]);
4140
+								} else if ( $column == 'post_zip' ) {
4141
+									$post_zip = sanitize_text_field($row[$c]);
4142
+								} else if ( $column == 'post_latitude' ) {
4143
+									$post_latitude = sanitize_text_field($row[$c]);
4144
+								} else if ( $column == 'post_longitude' ) {
4145
+									$post_longitude = sanitize_text_field($row[$c]);
4146
+								} else if ( $column == 'post_neighbourhood' ) {
4147
+									$post_neighbourhood = sanitize_text_field($row[$c]);
4148
+									unset($gd_post[$column]);
4149
+								} else if ( $column == 'neighbourhood_latitude' ) {
4150
+									$neighbourhood_latitude = sanitize_text_field($row[$c]);
4151
+								} else if ( $column == 'neighbourhood_longitude' ) {
4152
+									$neighbourhood_longitude = sanitize_text_field($row[$c]);
4153
+								} else if ( $column == 'geodir_timing' ) {
4154
+									$geodir_timing = sanitize_text_field($row[$c]);
4155
+								} else if ( $column == 'geodir_contact' ) {
4156
+									$geodir_contact = sanitize_text_field($row[$c]);
4157
+								} else if ( $column == 'geodir_email' ) {
4158
+									$geodir_email = sanitize_email($row[$c]);
4159
+								} else if ( $column == 'geodir_website' ) {
4160
+									$geodir_website = sanitize_text_field($row[$c]);
4161
+								} else if ( $column == 'geodir_twitter' ) {
4162
+									$geodir_twitter = sanitize_text_field($row[$c]);
4163
+								} else if ( $column == 'geodir_facebook' ) {
4164
+									$geodir_facebook = sanitize_text_field($row[$c]);
4165
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4166
+									$post_images[] = $row[$c];
4167
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4168
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4169
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4170
+									$row[$c] = str_replace('/', '-', $row[$c]);
4171
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4172
+								}
4173
+								// WPML
4174
+								if ($is_wpml) {
4175
+									if ($column == 'language') {
4176
+										$language = geodir_strtolower(trim($row[$c]));
4177
+									} else if ($column == 'original_post_id') {
4178
+										$original_post_id = (int)$row[$c];
4179
+									}
4180
+								}
4181
+								// WPML
4182
+								$c++;
4183
+							}
4184
+							// listing claimed or not
4185
+							if ($is_claim_active && isset($gd_post['claimed'])) {
4186
+								$gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4187
+							}
4188 4188
                             
4189
-                            // WPML
4190
-                            if ($is_wpml && $language != '') {
4191
-                                $sitepress->switch_lang($language, true);
4192
-                            }
4193
-                            // WPML
4189
+							// WPML
4190
+							if ($is_wpml && $language != '') {
4191
+								$sitepress->switch_lang($language, true);
4192
+							}
4193
+							// WPML
4194 4194
 
4195
-                            $gd_post['IMAGE'] = $post_images;
4195
+							$gd_post['IMAGE'] = $post_images;
4196 4196
                             
4197
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4198
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4197
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4198
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4199 4199
                                                                                                                 
4200
-                            $valid = true;
4200
+							$valid = true;
4201 4201
                             
4202
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4203
-                                $invalid++;
4204
-                                $valid = false;
4205
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4206
-                            }
4207
-                            $xtimings['###3'] = microtime(true)-$xstart;
4208
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4209
-                            if ( $location_allowed ) {
4210
-                                $location_result = geodir_get_default_location();
4211
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4212
-                                    $invalid_addr++;
4213
-                                    $valid = false;
4214
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4215
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4216
-                                    if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4217
-                                        $invalid_addr++;
4218
-                                        $valid = false;
4219
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4220
-                                    } else {
4221
-                                        if (!$location_manager) {
4222
-                                            $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4223
-                                        }
4224
-                                    }
4225
-                                }
4226
-                            }
4227
-                            $xtimings['###4']   = microtime(true)-$xstart;
4228
-                            if ( !$valid ) {
4229
-                                continue;
4230
-                            }
4202
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4203
+								$invalid++;
4204
+								$valid = false;
4205
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4206
+							}
4207
+							$xtimings['###3'] = microtime(true)-$xstart;
4208
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4209
+							if ( $location_allowed ) {
4210
+								$location_result = geodir_get_default_location();
4211
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4212
+									$invalid_addr++;
4213
+									$valid = false;
4214
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4215
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4216
+									if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4217
+										$invalid_addr++;
4218
+										$valid = false;
4219
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4220
+									} else {
4221
+										if (!$location_manager) {
4222
+											$gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4223
+										}
4224
+									}
4225
+								}
4226
+							}
4227
+							$xtimings['###4']   = microtime(true)-$xstart;
4228
+							if ( !$valid ) {
4229
+								continue;
4230
+							}
4231 4231
 
4232
-                            $cat_taxonomy = $post_type . 'category';
4233
-                            $tags_taxonomy = $post_type . '_tags';
4232
+							$cat_taxonomy = $post_type . 'category';
4233
+							$tags_taxonomy = $post_type . '_tags';
4234 4234
                             
4235
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4236
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4237
-                            }
4235
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4236
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4237
+							}
4238 4238
 
4239
-                            $post_category = array();
4240
-                            $default_category_id = NULL;
4241
-                            if ( !empty( $post_category_arr ) ) {
4242
-                                foreach ( $post_category_arr as $value ) {
4243
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4239
+							$post_category = array();
4240
+							$default_category_id = NULL;
4241
+							if ( !empty( $post_category_arr ) ) {
4242
+								foreach ( $post_category_arr as $value ) {
4243
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4244 4244
                                     
4245
-                                    if ( $category_name != '' ) {
4246
-                                        $term_category = array();
4245
+									if ( $category_name != '' ) {
4246
+										$term_category = array();
4247 4247
                                         
4248
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4249
-                                            $term_category = $term;
4250
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4251
-                                            $term_category = $term;
4252
-                                        } else {
4253
-                                            $term_data = array();
4254
-                                            $term_data['name'] = $category_name;
4255
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4248
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4249
+											$term_category = $term;
4250
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4251
+											$term_category = $term;
4252
+										} else {
4253
+											$term_data = array();
4254
+											$term_data['name'] = $category_name;
4255
+											$term_data['taxonomy'] = $cat_taxonomy;
4256 4256
                                             
4257
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4258
-                                            if ( $term_id ) {
4259
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4260
-                                            }
4261
-                                        }
4257
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4258
+											if ( $term_id ) {
4259
+												$term_category = get_term( $term_id, $cat_taxonomy );
4260
+											}
4261
+										}
4262 4262
                                         
4263
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4264
-                                            $post_category[] = intval($term_category->term_id);
4263
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4264
+											$post_category[] = intval($term_category->term_id);
4265 4265
                                             
4266
-                                            if ($category_name == $default_category) {
4267
-                                                $default_category_id = intval($term_category->term_id);
4268
-                                            }
4269
-                                        }
4270
-                                    }
4271
-                                }
4272
-                            }
4273
-                            $xtimings['###5'] = microtime(true)-$xstart;
4274
-                            $save_post = array();
4275
-                            $save_post['post_title'] = $post_title;
4276
-                            if (!empty($post_date)) {
4277
-                                $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format.
4266
+											if ($category_name == $default_category) {
4267
+												$default_category_id = intval($term_category->term_id);
4268
+											}
4269
+										}
4270
+									}
4271
+								}
4272
+							}
4273
+							$xtimings['###5'] = microtime(true)-$xstart;
4274
+							$save_post = array();
4275
+							$save_post['post_title'] = $post_title;
4276
+							if (!empty($post_date)) {
4277
+								$post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format.
4278 4278
                                 
4279
-                                $save_post['post_date'] = $post_date;
4280
-                                $save_post['post_date_gmt'] = get_gmt_from_date( $post_date );
4281
-                            }
4282
-                            $save_post['post_content'] = $post_content;
4283
-                            $save_post['post_type'] = $post_type;
4284
-                            $save_post['post_author'] = $post_author;
4285
-                            $save_post['post_status'] = $post_status;
4286
-                            $save_post['post_category'] = $post_category;
4287
-                            $save_post['post_tags'] = $post_tags;
4288
-
4289
-                            $saved_post_id = NULL;
4290
-                            if ( $import_choice == 'update' ) {
4291
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4279
+								$save_post['post_date'] = $post_date;
4280
+								$save_post['post_date_gmt'] = get_gmt_from_date( $post_date );
4281
+							}
4282
+							$save_post['post_content'] = $post_content;
4283
+							$save_post['post_type'] = $post_type;
4284
+							$save_post['post_author'] = $post_author;
4285
+							$save_post['post_status'] = $post_status;
4286
+							$save_post['post_category'] = $post_category;
4287
+							$save_post['post_tags'] = $post_tags;
4288
+
4289
+							$saved_post_id = NULL;
4290
+							if ( $import_choice == 'update' ) {
4291
+								$gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4292 4292
                                 
4293
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4294
-                                    $save_post['ID'] = $post_id;
4293
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4294
+									$save_post['ID'] = $post_id;
4295 4295
                                     
4296
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4297
-                                        if ( is_wp_error( $saved_post_id ) ) {
4298
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4299
-                                            $saved_post_id = 0;
4300
-                                        } else {
4301
-                                            $saved_post_id = $post_id;
4302
-                                            $updated++;
4303
-                                        }
4304
-                                    }
4305
-                                } else {
4306
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4307
-                                        if ( is_wp_error( $saved_post_id ) ) {
4308
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4309
-                                            $saved_post_id = 0;
4310
-                                        } else {
4311
-                                            $created++;
4312
-                                        }
4313
-                                    }
4314
-                                }
4296
+									if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4297
+										if ( is_wp_error( $saved_post_id ) ) {
4298
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4299
+											$saved_post_id = 0;
4300
+										} else {
4301
+											$saved_post_id = $post_id;
4302
+											$updated++;
4303
+										}
4304
+									}
4305
+								} else {
4306
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4307
+										if ( is_wp_error( $saved_post_id ) ) {
4308
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4309
+											$saved_post_id = 0;
4310
+										} else {
4311
+											$created++;
4312
+										}
4313
+									}
4314
+								}
4315 4315
                                 
4316
-                                if ( !$saved_post_id > 0 ) {
4317
-                                    $invalid++;
4318
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4319
-                                }
4320
-                            } else if ( $import_choice == 'skip' ) {
4321
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4322
-                                    $skipped++;	
4323
-                                } else {
4324
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4325
-                                        if ( is_wp_error( $saved_post_id ) ) {
4326
-                                            $invalid++;
4316
+								if ( !$saved_post_id > 0 ) {
4317
+									$invalid++;
4318
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4319
+								}
4320
+							} else if ( $import_choice == 'skip' ) {
4321
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4322
+									$skipped++;	
4323
+								} else {
4324
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4325
+										if ( is_wp_error( $saved_post_id ) ) {
4326
+											$invalid++;
4327 4327
                                             
4328
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4329
-                                            $saved_post_id = 0;
4330
-                                        } else {
4331
-                                            $created++;
4332
-                                        }
4333
-                                    } else {
4334
-                                        $invalid++;
4328
+											geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4329
+											$saved_post_id = 0;
4330
+										} else {
4331
+											$created++;
4332
+										}
4333
+									} else {
4334
+										$invalid++;
4335 4335
                                         
4336
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4337
-                                    }
4338
-                                }
4339
-                            } else {
4340
-                                $invalid++;
4336
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4337
+									}
4338
+								}
4339
+							} else {
4340
+								$invalid++;
4341 4341
                                 
4342
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4343
-                            }
4344
-                            $xtimings['###6'] = microtime(true)-$xstart;
4345
-                            if ( (int)$saved_post_id > 0 ) {
4346
-                                // WPML
4347
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4348
-                                    $wpml_post_type = 'post_' . $post_type;
4349
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4350
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4351
-
4352
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4342
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4343
+							}
4344
+							$xtimings['###6'] = microtime(true)-$xstart;
4345
+							if ( (int)$saved_post_id > 0 ) {
4346
+								// WPML
4347
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4348
+									$wpml_post_type = 'post_' . $post_type;
4349
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4350
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4351
+
4352
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4353 4353
                                     
4354
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4355
-                                }
4356
-                                // WPML
4357
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4354
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4355
+								}
4356
+								// WPML
4357
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4358 4358
                                 
4359
-                                $gd_post['post_id'] = $saved_post_id;
4360
-                                $gd_post['ID'] = $saved_post_id;
4361
-                                $gd_post['post_tags'] = $post_tags;
4362
-                                $gd_post['post_title'] = $post_title;
4363
-                                $gd_post['post_status'] = $post_status;
4364
-                                $gd_post['submit_time'] = time();
4365
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4359
+								$gd_post['post_id'] = $saved_post_id;
4360
+								$gd_post['ID'] = $saved_post_id;
4361
+								$gd_post['post_tags'] = $post_tags;
4362
+								$gd_post['post_title'] = $post_title;
4363
+								$gd_post['post_status'] = $post_status;
4364
+								$gd_post['submit_time'] = time();
4365
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4366 4366
                                                     
4367
-                                // post location
4368
-                                $post_location_id = 0;
4369
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4370
-                                    $gd_post['post_neighbourhood'] = '';
4367
+								// post location
4368
+								$post_location_id = 0;
4369
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4370
+									$gd_post['post_neighbourhood'] = '';
4371 4371
                                     
4372
-                                    $post_location_info = array(
4373
-                                                                'city' => $post_city,
4374
-                                                                'region' => $post_region,
4375
-                                                                'country' => $post_country,
4376
-                                                                'geo_lat' => $post_latitude,
4377
-                                                                'geo_lng' => $post_longitude
4378
-                                                            );
4379
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4380
-                                        $post_location_id = $location_id;
4381
-                                    }
4372
+									$post_location_info = array(
4373
+																'city' => $post_city,
4374
+																'region' => $post_region,
4375
+																'country' => $post_country,
4376
+																'geo_lat' => $post_latitude,
4377
+																'geo_lng' => $post_longitude
4378
+															);
4379
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4380
+										$post_location_id = $location_id;
4381
+									}
4382 4382
                                     
4383
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4384
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4383
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4384
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4385 4385
 
4386
-                                        $hood_data = array();
4387
-                                        $hood_data['hood_location_id'] = $post_location_id;
4388
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4386
+										$hood_data = array();
4387
+										$hood_data['hood_location_id'] = $post_location_id;
4388
+										$hood_data['hood_name'] = $post_neighbourhood;
4389 4389
                                         
4390
-                                        if (!empty($neighbourhood_info)) {
4391
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4392
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4390
+										if (!empty($neighbourhood_info)) {
4391
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4392
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4393 4393
                                             
4394
-                                            if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4395
-                                                $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4396
-                                                $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4397
-                                            }
4398
-                                        }
4394
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4395
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4396
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4397
+											}
4398
+										}
4399 4399
                                         
4400
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4401
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4402
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4403
-                                        }
4400
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4401
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4402
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4403
+										}
4404 4404
                                         
4405
-                                        $hood_data['hood_latitude'] = $post_latitude;
4406
-                                        $hood_data['hood_longitude'] = $post_longitude;
4407
-
4408
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4409
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4410
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4411
-                                        }
4412
-                                    }
4413
-                                }
4414
-                                $gd_post['post_location_id'] = $post_location_id;
4405
+										$hood_data['hood_latitude'] = $post_latitude;
4406
+										$hood_data['hood_longitude'] = $post_longitude;
4407
+
4408
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4409
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4410
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4411
+										}
4412
+									}
4413
+								}
4414
+								$gd_post['post_location_id'] = $post_location_id;
4415 4415
                                 
4416
-                                // post package info
4417
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4418
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4419
-                                    $package_id = $gd_post_info->package_id;
4420
-                                }
4416
+								// post package info
4417
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4418
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4419
+									$package_id = $gd_post_info->package_id;
4420
+								}
4421 4421
                                 
4422
-                                $package_info = array();
4423
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4424
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4422
+								$package_info = array();
4423
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4424
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4425 4425
                                     
4426
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4427
-                                        $package_info = array();
4428
-                                    }
4429
-                                }
4426
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4427
+										$package_info = array();
4428
+									}
4429
+								}
4430 4430
                                 
4431
-                                if (empty($package_info)) {
4432
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4433
-                                }
4431
+								if (empty($package_info)) {
4432
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4433
+								}
4434 4434
                                  
4435
-                                if (!empty($package_info))	 {
4436
-                                    $package_id = $package_info['pid'];
4435
+								if (!empty($package_info))	 {
4436
+									$package_id = $package_info['pid'];
4437 4437
                                     
4438
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4439
-                                        $gd_post['expire_date'] = $expire_date;
4440
-                                    } else {
4441
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4442
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4443
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4444
-                                        } else {
4445
-                                            $gd_post['expire_date'] = 'Never';
4446
-                                        }
4447
-                                    }
4438
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4439
+										$gd_post['expire_date'] = $expire_date;
4440
+									} else {
4441
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4442
+											$gd_post['alive_days'] = (int)$package_info['days'];
4443
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4444
+										} else {
4445
+											$gd_post['expire_date'] = 'Never';
4446
+										}
4447
+									}
4448 4448
                                     
4449
-                                    $gd_post['package_id'] = $package_id;
4450
-                                }
4449
+									$gd_post['package_id'] = $package_id;
4450
+								}
4451 4451
 
4452
-                                $table = $plugin_prefix . $post_type . '_detail';
4452
+								$table = $plugin_prefix . $post_type . '_detail';
4453 4453
                                 
4454
-                                if ($post_type == 'gd_event') {
4455
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4456
-                                }
4454
+								if ($post_type == 'gd_event') {
4455
+									$gd_post = geodir_imex_process_event_data($gd_post);
4456
+								}
4457 4457
                                 
4458
-                                if (isset($gd_post['post_id'])) {
4459
-                                    unset($gd_post['post_id']);
4460
-                                }
4458
+								if (isset($gd_post['post_id'])) {
4459
+									unset($gd_post['post_id']);
4460
+								}
4461 4461
 
4462
-                                // Export franchise fields
4463
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4464
-                                if ($is_franchise_active) {
4465
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4466
-                                        $gd_franchise_lock = array();
4462
+								// Export franchise fields
4463
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4464
+								if ($is_franchise_active) {
4465
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4466
+										$gd_franchise_lock = array();
4467 4467
                                         
4468
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4469
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4470
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4471
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4472
-                                        }
4468
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4469
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4470
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4471
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4472
+										}
4473 4473
                                         
4474
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4475
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4476
-                                    } else {
4477
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4478
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4479
-                                        }
4480
-                                    }
4481
-                                }
4474
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4475
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4476
+									} else {
4477
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4478
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4479
+										}
4480
+									}
4481
+								}
4482 4482
                                 
4483
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4484
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4485
-                                    if ($default_category_id) {
4486
-                                        $save_post['post_default_category'] = $default_category_id;
4487
-                                        $gd_post['default_category'] = $default_category_id;
4488
-                                    }
4489
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4490
-                                }
4491
-                                $xtimings['###7'] = microtime(true)-$xstart;
4492
-                                // Save post info
4493
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4494
-                                $xtimings['###8'] = microtime(true)-$xstart;
4495
-                                // post taxonomies
4496
-                                if ( !empty( $save_post['post_category'] ) ) {
4497
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4483
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4484
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4485
+									if ($default_category_id) {
4486
+										$save_post['post_default_category'] = $default_category_id;
4487
+										$gd_post['default_category'] = $default_category_id;
4488
+									}
4489
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4490
+								}
4491
+								$xtimings['###7'] = microtime(true)-$xstart;
4492
+								// Save post info
4493
+								geodir_save_post_info( $saved_post_id, $gd_post );
4494
+								$xtimings['###8'] = microtime(true)-$xstart;
4495
+								// post taxonomies
4496
+								if ( !empty( $save_post['post_category'] ) ) {
4497
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4498 4498
                                     
4499
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4500
-                                    if ($default_category_id) {
4501
-                                        $post_default_category = $default_category_id;
4502
-                                    }
4503
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4504
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4505
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4499
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4500
+									if ($default_category_id) {
4501
+										$post_default_category = $default_category_id;
4502
+									}
4503
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4504
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4505
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4506 4506
                                     
4507
-                                    if ($post_category_str != '' && $post_default_category) {
4508
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4509
-                                    }
4507
+									if ($post_category_str != '' && $post_default_category) {
4508
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4509
+									}
4510 4510
                                     
4511
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4511
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4512 4512
                                     
4513
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4514
-                                }
4515
-                                $xtimings['###8.1'] = microtime(true)-$xstart;
4516
-                                if ( !empty( $save_post['post_tags'] ) ) {
4517
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4518
-                                }
4519
-                                $xtimings['###9'] = microtime(true)-$xstart;
4520
-                                // Post images
4521
-                                if ( !empty( $post_images ) ) {
4522
-                                    $post_images = array_unique($post_images);
4513
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4514
+								}
4515
+								$xtimings['###8.1'] = microtime(true)-$xstart;
4516
+								if ( !empty( $save_post['post_tags'] ) ) {
4517
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4518
+								}
4519
+								$xtimings['###9'] = microtime(true)-$xstart;
4520
+								// Post images
4521
+								if ( !empty( $post_images ) ) {
4522
+									$post_images = array_unique($post_images);
4523 4523
                                     
4524
-                                    $old_post_images_arr = array();
4525
-                                    $saved_post_images_arr = array();
4524
+									$old_post_images_arr = array();
4525
+									$saved_post_images_arr = array();
4526 4526
                                     
4527
-                                    $order = 1;
4527
+									$order = 1;
4528 4528
                                     
4529
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4530
-                                    $xtimings['###9.1'] = microtime(true)-$xstart;
4531
-                                    if (!empty($old_post_images)) {
4532
-                                        foreach( $old_post_images as $old_post_image ) {
4533
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4534
-                                                $old_post_images_arr[] = $old_post_image->file;
4535
-                                            }
4536
-                                        }
4537
-                                    }
4529
+									$old_post_images = geodir_get_images( $saved_post_id );
4530
+									$xtimings['###9.1'] = microtime(true)-$xstart;
4531
+									if (!empty($old_post_images)) {
4532
+										foreach( $old_post_images as $old_post_image ) {
4533
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4534
+												$old_post_images_arr[] = $old_post_image->file;
4535
+											}
4536
+										}
4537
+									}
4538 4538
 
4539
-                                    foreach ( $post_images as $post_image ) {
4540
-                                        $image_name = basename( $post_image );
4541
-                                        $saved_post_images_arr[] = $image_name;
4539
+									foreach ( $post_images as $post_image ) {
4540
+										$image_name = basename( $post_image );
4541
+										$saved_post_images_arr[] = $image_name;
4542 4542
                                         
4543
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4544
-                                            continue; // Skip if image already exists.
4545
-                                        }
4543
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4544
+											continue; // Skip if image already exists.
4545
+										}
4546 4546
                                         
4547
-                                        $image_name_parts = explode( '.', $image_name );
4548
-                                        array_pop( $image_name_parts );
4549
-                                        $proper_image_name = implode( '.', $image_name_parts );
4550
-                                        $xtimings['###9.2'] = microtime(true)-$xstart;
4551
-                                        $arr_file_type = wp_check_filetype( $image_name );
4552
-                                        $xtimings['###9.3'] = microtime(true)-$xstart;
4553
-                                        if ( !empty( $arr_file_type ) ) {
4554
-                                            $uploaded_file_type = $arr_file_type['type'];
4547
+										$image_name_parts = explode( '.', $image_name );
4548
+										array_pop( $image_name_parts );
4549
+										$proper_image_name = implode( '.', $image_name_parts );
4550
+										$xtimings['###9.2'] = microtime(true)-$xstart;
4551
+										$arr_file_type = wp_check_filetype( $image_name );
4552
+										$xtimings['###9.3'] = microtime(true)-$xstart;
4553
+										if ( !empty( $arr_file_type ) ) {
4554
+											$uploaded_file_type = $arr_file_type['type'];
4555 4555
                                             
4556
-                                            $attachment = array();
4557
-                                            $attachment['post_id'] = $saved_post_id;
4558
-                                            $attachment['title'] = $proper_image_name;
4559
-                                            $attachment['content'] = '';
4560
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4561
-                                            $attachment['mime_type'] = $uploaded_file_type;
4562
-                                            $attachment['menu_order'] = $order;
4563
-                                            $attachment['is_featured'] = 0;
4564
-
4565
-                                            $attachment_set = '';
4566
-                                            foreach ( $attachment as $key => $val ) {
4567
-                                                if ( $val != '' ) {
4568
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4569
-                                                }
4570
-                                            }
4571
-                                            $attachment_set = trim( $attachment_set, ", " );
4556
+											$attachment = array();
4557
+											$attachment['post_id'] = $saved_post_id;
4558
+											$attachment['title'] = $proper_image_name;
4559
+											$attachment['content'] = '';
4560
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4561
+											$attachment['mime_type'] = $uploaded_file_type;
4562
+											$attachment['menu_order'] = $order;
4563
+											$attachment['is_featured'] = 0;
4564
+
4565
+											$attachment_set = '';
4566
+											foreach ( $attachment as $key => $val ) {
4567
+												if ( $val != '' ) {
4568
+													$attachment_set .= $key . " = '" . $val . "', ";
4569
+												}
4570
+											}
4571
+											$attachment_set = trim( $attachment_set, ", " );
4572 4572
                                                                                         
4573
-                                            // Add new attachment
4574
-                                            $xtimings['###9.4'] = microtime(true)-$xstart;
4575
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4576
-                                            $xtimings['###9.5'] = microtime(true)-$xstart;
4577
-                                            $order++;
4578
-                                        }
4579
-                                    }
4580
-
4581
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4582
-                                    // Remove previous attachment
4583
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4584
-                                    $xtimings['###9.6'] = microtime(true)-$xstart;
4585
-                                    if ( !empty( $saved_post_images_arr ) ) {
4586
-                                        geodir_set_wp_featured_image($saved_post_id);
4587
-                                        $xtimings['###9.7'] = microtime(true)-$xstart;
4588
-                                        /*
4573
+											// Add new attachment
4574
+											$xtimings['###9.4'] = microtime(true)-$xstart;
4575
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4576
+											$xtimings['###9.5'] = microtime(true)-$xstart;
4577
+											$order++;
4578
+										}
4579
+									}
4580
+
4581
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4582
+									// Remove previous attachment
4583
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4584
+									$xtimings['###9.6'] = microtime(true)-$xstart;
4585
+									if ( !empty( $saved_post_images_arr ) ) {
4586
+										geodir_set_wp_featured_image($saved_post_id);
4587
+										$xtimings['###9.7'] = microtime(true)-$xstart;
4588
+										/*
4589 4589
                                         $menu_order = 1;
4590 4590
                                         
4591 4591
                                         foreach ( $saved_post_images_arr as $img_name ) {
@@ -4598,288 +4598,288 @@  discard block
 block discarded – undo
4598 4598
                                             }
4599 4599
                                             $menu_order++;
4600 4600
                                         }*/
4601
-                                    }
4601
+									}
4602 4602
                                     
4603
-                                    if ( $order > 1 ) {
4604
-                                        $images++;
4605
-                                    }
4606
-                                }
4607
-                                $xtimings['###10'] = microtime(true)-$xstart;
4608
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4609
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4610
-                                $xtimings['###11'] = microtime(true)-$xstart;
4611
-                                if (isset($is_featured)) {
4612
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4613
-                                }
4614
-                                if (isset($gd_post['alive_days'])) {
4615
-                                    geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']);
4616
-                                }
4617
-                                if (isset($gd_post['expire_date'])) {
4618
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4619
-                                }
4620
-                                $xtimings['###12'] = microtime(true)-$xstart;
4621
-                            }
4603
+									if ( $order > 1 ) {
4604
+										$images++;
4605
+									}
4606
+								}
4607
+								$xtimings['###10'] = microtime(true)-$xstart;
4608
+								/** This action is documented in geodirectory-functions/post-functions.php */
4609
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4610
+								$xtimings['###11'] = microtime(true)-$xstart;
4611
+								if (isset($is_featured)) {
4612
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4613
+								}
4614
+								if (isset($gd_post['alive_days'])) {
4615
+									geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']);
4616
+								}
4617
+								if (isset($gd_post['expire_date'])) {
4618
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4619
+								}
4620
+								$xtimings['###12'] = microtime(true)-$xstart;
4621
+							}
4622 4622
                             
4623
-                            // WPML
4624
-                            if ($is_wpml && $language != '') {
4625
-                                $sitepress->switch_lang($active_lang, true);
4626
-                            }
4627
-                            // WPML
4628
-                        }
4629
-                    }
4630
-                }
4623
+							// WPML
4624
+							if ($is_wpml && $language != '') {
4625
+								$sitepress->switch_lang($active_lang, true);
4626
+							}
4627
+							// WPML
4628
+						}
4629
+					}
4630
+				}
4631 4631
 
4632
-                //undo some stuff to make the import quicker
4633
-                wp_defer_term_counting( false );
4634
-                wp_defer_comment_counting( false );
4635
-                $wpdb->query( 'COMMIT;' );
4636
-                $wpdb->query( 'SET autocommit = 1;' );
4637
-                $xtimings['###13'] = microtime(true)-$xstart;
4638
-                $json = array();
4639
-                $json['processed'] = $processed_actual;
4640
-                $json['created'] = $created;
4641
-                $json['updated'] = $updated;
4642
-                $json['skipped'] = $skipped;
4643
-                $json['invalid'] = $invalid;
4644
-                $json['invalid_addr'] = $invalid_addr;
4645
-                $json['images'] = $images;
4646
-                $json['timing'] = microtime(true)-$xstart;
4647
-                $json['timings'] = $xtimings;
4632
+				//undo some stuff to make the import quicker
4633
+				wp_defer_term_counting( false );
4634
+				wp_defer_comment_counting( false );
4635
+				$wpdb->query( 'COMMIT;' );
4636
+				$wpdb->query( 'SET autocommit = 1;' );
4637
+				$xtimings['###13'] = microtime(true)-$xstart;
4638
+				$json = array();
4639
+				$json['processed'] = $processed_actual;
4640
+				$json['created'] = $created;
4641
+				$json['updated'] = $updated;
4642
+				$json['skipped'] = $skipped;
4643
+				$json['invalid'] = $invalid;
4644
+				$json['invalid_addr'] = $invalid_addr;
4645
+				$json['images'] = $images;
4646
+				$json['timing'] = microtime(true)-$xstart;
4647
+				$json['timings'] = $xtimings;
4648 4648
                 
4649 4649
 
4650
-                wp_send_json( $json );
4651
-                exit;
4652
-            } else if ( $task == 'import_loc' ) {
4653
-                global $gd_post_types;
4654
-                $gd_post_types = $post_types;
4650
+				wp_send_json( $json );
4651
+				exit;
4652
+			} else if ( $task == 'import_loc' ) {
4653
+				global $gd_post_types;
4654
+				$gd_post_types = $post_types;
4655 4655
                 
4656
-                if (!empty($file)) {
4657
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4656
+				if (!empty($file)) {
4657
+					$columns = isset($file[0]) ? $file[0] : NULL;
4658 4658
                     
4659
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4660
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4661
-                        wp_send_json( $json );
4662
-                    }
4659
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4660
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4661
+						wp_send_json( $json );
4662
+					}
4663 4663
                     
4664
-                    $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4665
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4666
-                    for ($i = 1; $i <= $limit; $i++) {
4667
-                        $index = $processed + $i;
4664
+					$gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4665
+					$gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4666
+					for ($i = 1; $i <= $limit; $i++) {
4667
+						$index = $processed + $i;
4668 4668
                         
4669
-                        if (isset($file[$index])) {
4670
-                            $row = $file[$index];
4671
-                            $row = array_map( 'trim', $row );
4672
-                            $data = array();
4669
+						if (isset($file[$index])) {
4670
+							$row = $file[$index];
4671
+							$row = array_map( 'trim', $row );
4672
+							$data = array();
4673 4673
                             
4674
-                            foreach ($columns as $c => $column ) {
4675
-                                if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
4676
-                                    $data[$column] = $row[$c];
4677
-                                }
4678
-                            }
4674
+							foreach ($columns as $c => $column ) {
4675
+								if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
4676
+									$data[$column] = $row[$c];
4677
+								}
4678
+							}
4679 4679
 
4680
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4681
-                                $invalid++;
4682
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4683
-                                continue;
4684
-                            }
4680
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4681
+								$invalid++;
4682
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4683
+								continue;
4684
+							}
4685 4685
                             
4686
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4686
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4687 4687
                             
4688
-                            if ( $import_choice == 'update' ) {
4689
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4690
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4691
-                                        $updated++;
4692
-                                    } else {
4693
-                                        $invalid++;
4694
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4695
-                                    }
4696
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4697
-                                    $data['location_id'] = (int)$location->location_id;
4688
+							if ( $import_choice == 'update' ) {
4689
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4690
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4691
+										$updated++;
4692
+									} else {
4693
+										$invalid++;
4694
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4695
+									}
4696
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4697
+									$data['location_id'] = (int)$location->location_id;
4698 4698
                                     
4699
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4700
-                                        $data['location_id'] = (int)$location->location_id;
4701
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4702
-                                        $data['location_id'] = (int)$location->location_id;
4703
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4704
-                                        $data['location_id'] = (int)$location->location_id;
4705
-                                    }
4699
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4700
+										$data['location_id'] = (int)$location->location_id;
4701
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4702
+										$data['location_id'] = (int)$location->location_id;
4703
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4704
+										$data['location_id'] = (int)$location->location_id;
4705
+									}
4706 4706
                                     
4707
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4708
-                                        $updated++;
4709
-                                    } else {
4710
-                                        $invalid++;
4711
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4712
-                                    }
4713
-                                } else {
4714
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4715
-                                        $created++;
4716
-                                    } else {
4717
-                                        $invalid++;
4718
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4719
-                                    }
4720
-                                }
4721
-                            } elseif ( $import_choice == 'skip' ) {
4722
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4723
-                                    $skipped++;
4724
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4725
-                                    $skipped++;
4726
-                                } else {
4727
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4728
-                                        $created++;
4729
-                                    } else {
4730
-                                        $invalid++;
4731
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4732
-                                    }
4733
-                                }
4734
-                            } else {
4735
-                                $invalid++;
4736
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4737
-                            }
4738
-                        }
4739
-                    }
4740
-                }
4707
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4708
+										$updated++;
4709
+									} else {
4710
+										$invalid++;
4711
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4712
+									}
4713
+								} else {
4714
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4715
+										$created++;
4716
+									} else {
4717
+										$invalid++;
4718
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4719
+									}
4720
+								}
4721
+							} elseif ( $import_choice == 'skip' ) {
4722
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4723
+									$skipped++;
4724
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4725
+									$skipped++;
4726
+								} else {
4727
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4728
+										$created++;
4729
+									} else {
4730
+										$invalid++;
4731
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4732
+									}
4733
+								}
4734
+							} else {
4735
+								$invalid++;
4736
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4737
+							}
4738
+						}
4739
+					}
4740
+				}
4741 4741
                 
4742
-                $json = array();
4743
-                $json['processed'] = $limit;
4744
-                $json['created'] = $created;
4745
-                $json['updated'] = $updated;
4746
-                $json['skipped'] = $skipped;
4747
-                $json['invalid'] = $invalid;
4748
-                $json['images'] = $images;
4742
+				$json = array();
4743
+				$json['processed'] = $limit;
4744
+				$json['created'] = $created;
4745
+				$json['updated'] = $updated;
4746
+				$json['skipped'] = $skipped;
4747
+				$json['invalid'] = $invalid;
4748
+				$json['images'] = $images;
4749 4749
                 
4750
-                wp_send_json( $json );
4751
-            } else if ( $task == 'import_hood' ) {               
4752
-                if (!empty($file)) {
4753
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4750
+				wp_send_json( $json );
4751
+			} else if ( $task == 'import_hood' ) {               
4752
+				if (!empty($file)) {
4753
+					$columns = isset($file[0]) ? $file[0] : NULL;
4754 4754
                     
4755
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4756
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4757
-                        wp_send_json( $json );
4758
-                    }
4755
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4756
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4757
+						wp_send_json( $json );
4758
+					}
4759 4759
                     
4760
-                    $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4761
-                    $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
4762
-                    for ($i = 1; $i <= $limit; $i++) {
4763
-                        $index = $processed + $i;
4760
+					$gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4761
+					$gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
4762
+					for ($i = 1; $i <= $limit; $i++) {
4763
+						$index = $processed + $i;
4764 4764
                         
4765
-                        if (isset($file[$index])) {
4766
-                            $row = $file[$index];
4767
-                            $row = array_map( 'trim', $row );
4768
-                            $data = array();
4765
+						if (isset($file[$index])) {
4766
+							$row = $file[$index];
4767
+							$row = array_map( 'trim', $row );
4768
+							$data = array();
4769 4769
                             
4770
-                            foreach ($columns as $c => $column) {
4771
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
4772
-                                    $data[$column] = sanitize_text_field($row[$c]);
4773
-                                }
4774
-                            }
4770
+							foreach ($columns as $c => $column) {
4771
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
4772
+									$data[$column] = sanitize_text_field($row[$c]);
4773
+								}
4774
+							}
4775 4775
 
4776
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4777
-                                $invalid++;
4778
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4779
-                                continue;
4780
-                            }
4776
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4777
+								$invalid++;
4778
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4779
+								continue;
4780
+							}
4781 4781
                             
4782
-                            $location_info = array();
4783
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4784
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4785
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4786
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4787
-                            }
4782
+							$location_info = array();
4783
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4784
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4785
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4786
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4787
+							}
4788 4788
 
4789
-                            if (empty($location_info)) {
4790
-                                $invalid++;
4791
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4792
-                                continue;
4793
-                            }
4789
+							if (empty($location_info)) {
4790
+								$invalid++;
4791
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4792
+								continue;
4793
+							}
4794 4794
                             
4795
-                            $location_id = $location_info->location_id;
4795
+							$location_id = $location_info->location_id;
4796 4796
 
4797
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
4797
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
4798 4798
                             
4799
-                            $hood_data = array();
4800
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
4801
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
4802
-                            $hood_data['hood_latitude'] = $data['latitude'];
4803
-                            $hood_data['hood_longitude'] = $data['longitude'];
4804
-                            $hood_data['hood_location_id'] = $location_id;
4799
+							$hood_data = array();
4800
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
4801
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
4802
+							$hood_data['hood_latitude'] = $data['latitude'];
4803
+							$hood_data['hood_longitude'] = $data['longitude'];
4804
+							$hood_data['hood_location_id'] = $location_id;
4805 4805
                                     
4806
-                            if ( $import_choice == 'update' ) {
4807
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4808
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4806
+							if ( $import_choice == 'update' ) {
4807
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4808
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4809 4809
                                     
4810
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4811
-                                        $updated++;
4812
-                                    } else {
4813
-                                        $invalid++;
4814
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4815
-                                    }
4816
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4817
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4810
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4811
+										$updated++;
4812
+									} else {
4813
+										$invalid++;
4814
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4815
+									}
4816
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4817
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4818 4818
                                     
4819
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4820
-                                        $updated++;
4821
-                                    } else {
4822
-                                        $invalid++;
4823
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4824
-                                    }
4825
-                                } else {
4826
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4827
-                                        $created++;
4828
-                                    } else {
4829
-                                        $invalid++;
4830
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4831
-                                    }
4832
-                                }
4833
-                            } elseif ( $import_choice == 'skip' ) {
4834
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4835
-                                    $skipped++;
4836
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4837
-                                    $skipped++;
4838
-                                } else {
4819
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4820
+										$updated++;
4821
+									} else {
4822
+										$invalid++;
4823
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4824
+									}
4825
+								} else {
4826
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4827
+										$created++;
4828
+									} else {
4829
+										$invalid++;
4830
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4831
+									}
4832
+								}
4833
+							} elseif ( $import_choice == 'skip' ) {
4834
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4835
+									$skipped++;
4836
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4837
+									$skipped++;
4838
+								} else {
4839 4839
                                     
4840
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4841
-                                        $created++;
4842
-                                    } else {
4843
-                                        $invalid++;
4844
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4845
-                                    }
4846
-                                }
4847
-                            } else {
4848
-                                $invalid++;
4849
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4850
-                            }
4851
-                        }
4852
-                    }
4853
-                }
4840
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4841
+										$created++;
4842
+									} else {
4843
+										$invalid++;
4844
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4845
+									}
4846
+								}
4847
+							} else {
4848
+								$invalid++;
4849
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4850
+							}
4851
+						}
4852
+					}
4853
+				}
4854 4854
                 
4855
-                $json = array();
4856
-                $json['processed'] = $limit;
4857
-                $json['created'] = $created;
4858
-                $json['updated'] = $updated;
4859
-                $json['skipped'] = $skipped;
4860
-                $json['invalid'] = $invalid;
4861
-                $json['images'] = $images;
4855
+				$json = array();
4856
+				$json['processed'] = $limit;
4857
+				$json['created'] = $created;
4858
+				$json['updated'] = $updated;
4859
+				$json['skipped'] = $skipped;
4860
+				$json['invalid'] = $invalid;
4861
+				$json['images'] = $images;
4862 4862
                 
4863
-                wp_send_json( $json );
4864
-            }
4865
-        }
4866
-        break;
4867
-        case 'import_finish':{
4868
-            /**
4869
-             * Run an action when an import finishes.
4870
-             *
4871
-             * This action can be used to fire functions after an import ends.
4872
-             *
4873
-             * @since 1.5.3
4874
-             * @package GeoDirectory
4875
-             */
4876
-            do_action('geodir_import_finished');
4877
-        }
4878
-        break;
4863
+				wp_send_json( $json );
4864
+			}
4865
+		}
4866
+		break;
4867
+		case 'import_finish':{
4868
+			/**
4869
+			 * Run an action when an import finishes.
4870
+			 *
4871
+			 * This action can be used to fire functions after an import ends.
4872
+			 *
4873
+			 * @since 1.5.3
4874
+			 * @package GeoDirectory
4875
+			 */
4876
+			do_action('geodir_import_finished');
4877
+		}
4878
+		break;
4879 4879
 
4880
-    }
4881
-    echo '0';
4882
-    gd_die();
4880
+	}
4881
+	echo '0';
4882
+	gd_die();
4883 4883
 }
4884 4884
 
4885 4885
 /**
@@ -4923,12 +4923,12 @@  discard block
 block discarded – undo
4923 4923
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
4924 4924
 	}
4925 4925
 	
4926
-    if( !empty( $term ) ) {
4926
+	if( !empty( $term ) ) {
4927 4927
 		$result = wp_insert_term( $term, $taxonomy, $args );
4928
-        if( !is_wp_error( $result ) ) {
4929
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4930
-        }
4931
-    }
4928
+		if( !is_wp_error( $result ) ) {
4929
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4930
+		}
4931
+	}
4932 4932
 	
4933 4933
 	return false;
4934 4934
 }
@@ -4974,16 +4974,16 @@  discard block
 block discarded – undo
4974 4974
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
4975 4975
 		
4976 4976
 		if( !is_wp_error( $result ) ) {
4977
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4978
-        }
4977
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4978
+		}
4979 4979
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4980 4980
 		$term_data['term_id'] = $term_info['term_id'];
4981 4981
 		
4982 4982
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
4983 4983
 		
4984 4984
 		if( !is_wp_error( $result ) ) {
4985
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4986
-        }
4985
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4986
+		}
4987 4987
 	} else {
4988 4988
 		return geodir_imex_insert_term( $taxonomy, $term_data );
4989 4989
 	}
@@ -5005,47 +5005,47 @@  discard block
 block discarded – undo
5005 5005
  * @return int Posts count.
5006 5006
  */
5007 5007
 function geodir_get_posts_count( $post_type ) {
5008
-    global $wpdb, $plugin_prefix;
5008
+	global $wpdb, $plugin_prefix;
5009 5009
 
5010
-    if ( !post_type_exists( $post_type ) ) {
5011
-        return 0;
5012
-    }
5010
+	if ( !post_type_exists( $post_type ) ) {
5011
+		return 0;
5012
+	}
5013 5013
         
5014
-    $table = $plugin_prefix . $post_type . '_detail';
5014
+	$table = $plugin_prefix . $post_type . '_detail';
5015 5015
 
5016
-    // Skip listing with statuses trash, auto-draft etc...
5017
-    $skip_statuses = geodir_imex_export_skip_statuses();
5018
-    $where_statuses = '';
5019
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5020
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5021
-    }
5016
+	// Skip listing with statuses trash, auto-draft etc...
5017
+	$skip_statuses = geodir_imex_export_skip_statuses();
5018
+	$where_statuses = '';
5019
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5020
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5021
+	}
5022 5022
     
5023
-    /**
5024
-     * Filter the SQL where clause part to filter posts count in import/export.
5025
-     *
5026
-     * @since 1.6.4
5027
-     * @package GeoDirectory
5028
-     *
5029
-     * @param string $where SQL where clause part.
5030
-     */
5031
-    $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5032
-
5033
-    $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5034
-
5035
-    $posts_count = (int)$wpdb->get_var( $query );
5023
+	/**
5024
+	 * Filter the SQL where clause part to filter posts count in import/export.
5025
+	 *
5026
+	 * @since 1.6.4
5027
+	 * @package GeoDirectory
5028
+	 *
5029
+	 * @param string $where SQL where clause part.
5030
+	 */
5031
+	$where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5032
+
5033
+	$query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5034
+
5035
+	$posts_count = (int)$wpdb->get_var( $query );
5036 5036
     
5037
-    /**
5038
-     * Modify returned post counts for the current post type.
5039
-     *
5040
-     * @since 1.4.6
5041
-     * @package GeoDirectory
5042
-     *
5043
-     * @param int $posts_count Post counts.
5044
-     * @param string $post_type Post type.
5045
-     */
5046
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5047
-
5048
-    return $posts_count;
5037
+	/**
5038
+	 * Modify returned post counts for the current post type.
5039
+	 *
5040
+	 * @since 1.4.6
5041
+	 * @package GeoDirectory
5042
+	 *
5043
+	 * @param int $posts_count Post counts.
5044
+	 * @param string $post_type Post type.
5045
+	 */
5046
+	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5047
+
5048
+	return $posts_count;
5049 5049
 }
5050 5050
 
5051 5051
 /**
@@ -5074,10 +5074,10 @@  discard block
 block discarded – undo
5074 5074
 	
5075 5075
 	if ( !empty( $posts ) ) {
5076 5076
 		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5077
-        $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5078
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5079
-        $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5080
-        $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
5077
+		$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5078
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5079
+		$neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5080
+		$is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
5081 5081
 		
5082 5082
 		$csv_row = array();
5083 5083
 		$csv_row[] = 'post_id';
@@ -5109,7 +5109,7 @@  discard block
 block discarded – undo
5109 5109
 		}
5110 5110
 		$csv_row[] = 'post_status';
5111 5111
 		$csv_row[] = 'is_featured';
5112
-        // Export claim listing field
5112
+		// Export claim listing field
5113 5113
 		if ($is_claim_active) {
5114 5114
 			$csv_row[] = 'claimed';
5115 5115
 		}
@@ -5118,7 +5118,7 @@  discard block
 block discarded – undo
5118 5118
 			$csv_row[] = 'alive_days';
5119 5119
 			$csv_row[] = 'expire_date';
5120 5120
 		}
5121
-        $csv_row[] = 'post_date';
5121
+		$csv_row[] = 'post_date';
5122 5122
 		$csv_row[] = 'post_address';
5123 5123
 		$csv_row[] = 'post_city';
5124 5124
 		$csv_row[] = 'post_region';
@@ -5126,11 +5126,11 @@  discard block
 block discarded – undo
5126 5126
 		$csv_row[] = 'post_zip';
5127 5127
 		$csv_row[] = 'post_latitude';
5128 5128
 		$csv_row[] = 'post_longitude';
5129
-        if ($neighbourhood_active) {
5130
-            $csv_row[] = 'post_neighbourhood';
5131
-            $csv_row[] = 'neighbourhood_latitude';
5132
-            $csv_row[] = 'neighbourhood_longitude';
5133
-        }
5129
+		if ($neighbourhood_active) {
5130
+			$csv_row[] = 'post_neighbourhood';
5131
+			$csv_row[] = 'neighbourhood_latitude';
5132
+			$csv_row[] = 'neighbourhood_longitude';
5133
+		}
5134 5134
 		$csv_row[] = 'geodir_timing';
5135 5135
 		$csv_row[] = 'geodir_contact';
5136 5136
 		$csv_row[] = 'geodir_email';
@@ -5162,21 +5162,21 @@  discard block
 block discarded – undo
5162 5162
 			$csv_row[] = 'franchise';
5163 5163
 		}
5164 5164
         
5165
-        /**
5166
-         * Filter columns field names of gd export listings csv.
5167
-         *
5168
-         * @since 1.6.5
5169
-         * @package GeoDirectory
5170
-         *
5171
-         * @param array $csv_row Column names being exported in csv.
5172
-         * @param string $post_type The post type.
5173
-         */
5174
-        $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
5165
+		/**
5166
+		 * Filter columns field names of gd export listings csv.
5167
+		 *
5168
+		 * @since 1.6.5
5169
+		 * @package GeoDirectory
5170
+		 *
5171
+		 * @param array $csv_row Column names being exported in csv.
5172
+		 * @param string $post_type The post type.
5173
+		 */
5174
+		$csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
5175 5175
 		
5176 5176
 		$csv_rows[] = $csv_row;
5177 5177
 
5178 5178
 		$images_count = 5;
5179
-        $xx=0;
5179
+		$xx=0;
5180 5180
 		foreach ( $posts as $post ) {$xx++;
5181 5181
 			$post_id = $post['ID'];
5182 5182
 			
@@ -5307,15 +5307,15 @@  discard block
 block discarded – undo
5307 5307
 			}
5308 5308
 			$csv_row[] = $post_info['post_status']; // post_status
5309 5309
 			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5310
-            if ($is_claim_active) {
5311
-                $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5312
-            }
5310
+			if ($is_claim_active) {
5311
+				$csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5312
+			}
5313 5313
 			if ($is_payment_plugin) {
5314 5314
 				$csv_row[] = (int)$post_info['package_id']; // package_id
5315 5315
 				$csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days
5316 5316
 				$csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
5317 5317
 			}
5318
-            $csv_row[] = $post_info['post_date']; // post_date
5318
+			$csv_row[] = $post_info['post_date']; // post_date
5319 5319
 			$csv_row[] = stripslashes($post_info['post_address']); // post_address
5320 5320
 			$csv_row[] = stripslashes($post_info['post_city']); // post_city
5321 5321
 			$csv_row[] = stripslashes($post_info['post_region']); // post_region
@@ -5323,21 +5323,21 @@  discard block
 block discarded – undo
5323 5323
 			$csv_row[] = stripslashes($post_info['post_zip']); // post_zip
5324 5324
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5325 5325
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5326
-            if ($neighbourhood_active) {
5327
-                $post_neighbourhood = '';
5328
-                $neighbourhood_latitude = '';
5329
-                $neighbourhood_longitude = '';
5330
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5331
-                    if (!empty($hood_info)) {
5332
-                        $post_neighbourhood = $hood_info->hood_name;
5333
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5334
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5335
-                    }
5336
-                }
5337
-                $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood
5338
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5339
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5340
-            }
5326
+			if ($neighbourhood_active) {
5327
+				$post_neighbourhood = '';
5328
+				$neighbourhood_latitude = '';
5329
+				$neighbourhood_longitude = '';
5330
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5331
+					if (!empty($hood_info)) {
5332
+						$post_neighbourhood = $hood_info->hood_name;
5333
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5334
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5335
+					}
5336
+				}
5337
+				$csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood
5338
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5339
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5340
+			}
5341 5341
 			$csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing
5342 5342
 			$csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact
5343 5343
 			$csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email
@@ -5377,16 +5377,16 @@  discard block
 block discarded – undo
5377 5377
 				$csv_row[] = (int)$franchise; // franchise id
5378 5378
 			}
5379 5379
             
5380
-            /**
5381
-             * Filter columns values of gd export listings csv file
5382
-             *
5383
-             * @since 1.6.5
5384
-             * @package GeoDirectory
5385
-             *
5386
-             * @param array $csv_row Field values being exported in csv.
5387
-             * @param array $post_info The post info.
5388
-             */
5389
-            $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5380
+			/**
5381
+			 * Filter columns values of gd export listings csv file
5382
+			 *
5383
+			 * @since 1.6.5
5384
+			 * @package GeoDirectory
5385
+			 *
5386
+			 * @param array $csv_row Field values being exported in csv.
5387
+			 * @param array $post_info The post info.
5388
+			 */
5389
+			$csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5390 5390
 			
5391 5391
 			for ( $c = 0; $c < $images_count; $c++ ) {
5392 5392
 				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
@@ -5419,64 +5419,64 @@  discard block
 block discarded – undo
5419 5419
  * @return array Array of posts data.
5420 5420
  */
5421 5421
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5422
-    global $wpdb, $plugin_prefix;
5422
+	global $wpdb, $plugin_prefix;
5423 5423
 
5424
-    if ( ! post_type_exists( $post_type ) )
5425
-        return new stdClass;
5424
+	if ( ! post_type_exists( $post_type ) )
5425
+		return new stdClass;
5426 5426
         
5427
-    $table = $plugin_prefix . $post_type . '_detail';
5427
+	$table = $plugin_prefix . $post_type . '_detail';
5428 5428
 
5429
-    $limit = '';
5430
-    if ( $per_page > 0 && $page_no > 0 ) {
5431
-        $offset = ( $page_no - 1 ) * $per_page;
5429
+	$limit = '';
5430
+	if ( $per_page > 0 && $page_no > 0 ) {
5431
+		$offset = ( $page_no - 1 ) * $per_page;
5432 5432
         
5433
-        if ( $offset > 0 ) {
5434
-            $limit = " LIMIT " . $offset . "," . $per_page;
5435
-        } else {
5436
-            $limit = " LIMIT " . $per_page;
5437
-        }
5438
-    }
5433
+		if ( $offset > 0 ) {
5434
+			$limit = " LIMIT " . $offset . "," . $per_page;
5435
+		} else {
5436
+			$limit = " LIMIT " . $per_page;
5437
+		}
5438
+	}
5439 5439
 
5440
-    // Skip listing with statuses trash, auto-draft etc...
5441
-    $skip_statuses = geodir_imex_export_skip_statuses();
5442
-    $where_statuses = '';
5443
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5444
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5445
-    }
5440
+	// Skip listing with statuses trash, auto-draft etc...
5441
+	$skip_statuses = geodir_imex_export_skip_statuses();
5442
+	$where_statuses = '';
5443
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5444
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5445
+	}
5446 5446
     
5447
-    /**
5448
-     * Filter the SQL where clause part to filter posts in import/export.
5449
-     *
5450
-     * @since 1.6.4
5451
-     * @package GeoDirectory
5452
-     *
5453
-     * @param string $where SQL where clause part.
5454
-     */
5455
-    $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5456
-
5457
-    $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5458
-    /**
5459
-     * Modify returned posts SQL query for the current post type.
5460
-     *
5461
-     * @since 1.4.6
5462
-     * @package GeoDirectory
5463
-     *
5464
-     * @param int $query The SQL query.
5465
-     * @param string $post_type Post type.
5466
-     */
5467
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5468
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5469
-
5470
-    /**
5471
-     * Modify returned post results for the current post type.
5472
-     *
5473
-     * @since 1.4.6
5474
-     * @package GeoDirectory
5475
-     *
5476
-     * @param object $results An object containing all post ids.
5477
-     * @param string $post_type Post type.
5478
-     */
5479
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5447
+	/**
5448
+	 * Filter the SQL where clause part to filter posts in import/export.
5449
+	 *
5450
+	 * @since 1.6.4
5451
+	 * @package GeoDirectory
5452
+	 *
5453
+	 * @param string $where SQL where clause part.
5454
+	 */
5455
+	$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5456
+
5457
+	$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5458
+	/**
5459
+	 * Modify returned posts SQL query for the current post type.
5460
+	 *
5461
+	 * @since 1.4.6
5462
+	 * @package GeoDirectory
5463
+	 *
5464
+	 * @param int $query The SQL query.
5465
+	 * @param string $post_type Post type.
5466
+	 */
5467
+	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5468
+	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5469
+
5470
+	/**
5471
+	 * Modify returned post results for the current post type.
5472
+	 *
5473
+	 * @since 1.4.6
5474
+	 * @package GeoDirectory
5475
+	 *
5476
+	 * @param object $results An object containing all post ids.
5477
+	 * @param string $post_type Post type.
5478
+	 */
5479
+	return apply_filters( 'geodir_export_posts', $results, $post_type );
5480 5480
 }
5481 5481
 
5482 5482
 /**
@@ -5495,26 +5495,26 @@  discard block
 block discarded – undo
5495 5495
  * @return string The SQL query.
5496 5496
  */
5497 5497
 function geodir_imex_get_events_query( $query, $post_type ) {
5498
-    if ( $post_type == 'gd_event' ) {
5499
-        global $wpdb, $plugin_prefix;
5498
+	if ( $post_type == 'gd_event' ) {
5499
+		global $wpdb, $plugin_prefix;
5500 5500
         
5501
-        $table = $plugin_prefix . $post_type . '_detail';
5502
-        $schedule_table = EVENT_SCHEDULE;
5501
+		$table = $plugin_prefix . $post_type . '_detail';
5502
+		$schedule_table = EVENT_SCHEDULE;
5503 5503
         
5504
-        // Skip listing with statuses trash, auto-draft etc...
5505
-        $skip_statuses = geodir_imex_export_skip_statuses();
5506
-        $where_statuses = '';
5507
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5508
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5509
-        }
5504
+		// Skip listing with statuses trash, auto-draft etc...
5505
+		$skip_statuses = geodir_imex_export_skip_statuses();
5506
+		$where_statuses = '';
5507
+		if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5508
+			$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5509
+		}
5510 5510
         
5511
-        /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5512
-        $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5511
+		/** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5512
+		$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5513 5513
 
5514
-        $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5515
-    }
5514
+		$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5515
+	}
5516 5516
 
5517
-    return $query;
5517
+	return $query;
5518 5518
 }
5519 5519
 
5520 5520
 /**
@@ -5536,36 +5536,36 @@  discard block
 block discarded – undo
5536 5536
  * @return int Total terms count.
5537 5537
  */
5538 5538
 function geodir_get_terms_count( $post_type ) {
5539
-    $args = array( 'hide_empty' => 0 );
5539
+	$args = array( 'hide_empty' => 0 );
5540 5540
 
5541
-    remove_all_filters( 'get_terms' );
5541
+	remove_all_filters( 'get_terms' );
5542 5542
 
5543
-    $taxonomy = $post_type . 'category';
5543
+	$taxonomy = $post_type . 'category';
5544 5544
 
5545
-    // WPML
5546
-    $is_wpml = geodir_is_wpml();
5547
-    $active_lang = 'all';
5548
-    if ( $is_wpml ) {
5549
-        global $sitepress;
5550
-        $active_lang = $sitepress->get_current_language();
5545
+	// WPML
5546
+	$is_wpml = geodir_is_wpml();
5547
+	$active_lang = 'all';
5548
+	if ( $is_wpml ) {
5549
+		global $sitepress;
5550
+		$active_lang = $sitepress->get_current_language();
5551 5551
         
5552
-        if ( $active_lang != 'all' ) {
5553
-            $sitepress->switch_lang( 'all', true );
5554
-        }
5555
-    }
5556
-    // WPML
5552
+		if ( $active_lang != 'all' ) {
5553
+			$sitepress->switch_lang( 'all', true );
5554
+		}
5555
+	}
5556
+	// WPML
5557 5557
             
5558
-    $count_terms = wp_count_terms( $taxonomy, $args );
5558
+	$count_terms = wp_count_terms( $taxonomy, $args );
5559 5559
 
5560
-    // WPML
5561
-    if ( $is_wpml && $active_lang !== 'all' ) {
5562
-        global $sitepress;
5563
-        $sitepress->switch_lang( $active_lang, true );
5564
-    }
5565
-    // WPML
5566
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5560
+	// WPML
5561
+	if ( $is_wpml && $active_lang !== 'all' ) {
5562
+		global $sitepress;
5563
+		$sitepress->switch_lang( $active_lang, true );
5564
+	}
5565
+	// WPML
5566
+	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5567 5567
      
5568
-    return $count_terms;
5568
+	return $count_terms;
5569 5569
 }
5570 5570
 
5571 5571
 /**
@@ -5604,11 +5604,11 @@  discard block
 block discarded – undo
5604 5604
 		$csv_row[] = 'cat_posttype';
5605 5605
 		$csv_row[] = 'cat_parent';
5606 5606
 		$csv_row[] = 'cat_schema';
5607
-        // WPML
5607
+		// WPML
5608 5608
 		$is_wpml = geodir_is_wpml();
5609 5609
 		if ($is_wpml) {
5610 5610
 			$csv_row[] = 'cat_language';
5611
-            $csv_row[] = 'cat_id_original';
5611
+			$csv_row[] = 'cat_id_original';
5612 5612
 		}
5613 5613
 		// WPML
5614 5614
 		$csv_row[] = 'cat_description';
@@ -5638,10 +5638,10 @@  discard block
 block discarded – undo
5638 5638
 			$csv_row[] = $post_type;
5639 5639
 			$csv_row[] = $cat_parent;
5640 5640
 			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5641
-            // WPML
5641
+			// WPML
5642 5642
 			if ($is_wpml) {
5643 5643
 				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5644
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5644
+				$csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5645 5645
 			}
5646 5646
 			// WPML
5647 5647
 			$csv_row[] = $term->description;
@@ -6059,43 +6059,43 @@  discard block
 block discarded – undo
6059 6059
  * @param string $status Post status.
6060 6060
  */
6061 6061
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6062
-    global $wpdb, $current_user;
6063
-
6064
-    $option_value = get_option($option);
6065
-
6066
-    if ($option_value > 0) :
6067
-        if (get_post($option_value)) :
6068
-            // Page exists
6069
-            return;
6070
-        endif;
6071
-    endif;
6072
-
6073
-    $page_found = $wpdb->get_var(
6074
-        $wpdb->prepare(
6075
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6076
-            array($slug)
6077
-        )
6078
-    );
6079
-
6080
-    if ($page_found) :
6081
-        // Page exists
6082
-        if (!$option_value) update_option($option, $page_found);
6083
-        return;
6084
-    endif;
6085
-
6086
-    $page_data = array(
6087
-        'post_status' => $status,
6088
-        'post_type' => 'page',
6089
-        'post_author' => $current_user->ID,
6090
-        'post_name' => $slug,
6091
-        'post_title' => $page_title,
6092
-        'post_content' => $page_content,
6093
-        'post_parent' => $post_parent,
6094
-        'comment_status' => 'closed'
6095
-    );
6096
-    $page_id = wp_insert_post($page_data);
6097
-
6098
-    add_option($option, $page_id);
6062
+	global $wpdb, $current_user;
6063
+
6064
+	$option_value = get_option($option);
6065
+
6066
+	if ($option_value > 0) :
6067
+		if (get_post($option_value)) :
6068
+			// Page exists
6069
+			return;
6070
+		endif;
6071
+	endif;
6072
+
6073
+	$page_found = $wpdb->get_var(
6074
+		$wpdb->prepare(
6075
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6076
+			array($slug)
6077
+		)
6078
+	);
6079
+
6080
+	if ($page_found) :
6081
+		// Page exists
6082
+		if (!$option_value) update_option($option, $page_found);
6083
+		return;
6084
+	endif;
6085
+
6086
+	$page_data = array(
6087
+		'post_status' => $status,
6088
+		'post_type' => 'page',
6089
+		'post_author' => $current_user->ID,
6090
+		'post_name' => $slug,
6091
+		'post_title' => $page_title,
6092
+		'post_content' => $page_content,
6093
+		'post_parent' => $post_parent,
6094
+		'comment_status' => 'closed'
6095
+	);
6096
+	$page_id = wp_insert_post($page_data);
6097
+
6098
+	add_option($option, $page_id);
6099 6099
 
6100 6100
 }
6101 6101
 
@@ -6126,9 +6126,9 @@  discard block
 block discarded – undo
6126 6126
  * @package GeoDirectory
6127 6127
  */
6128 6128
 function geodir_admin_upgrade_notice() {
6129
-    $class = "error";
6130
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6131
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6129
+	$class = "error";
6130
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6131
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6132 6132
 }
6133 6133
 
6134 6134
 /**
@@ -6141,18 +6141,18 @@  discard block
 block discarded – undo
6141 6141
  */
6142 6142
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6143 6143
 {
6144
-    // readme contents
6145
-    $args = array(
6146
-        'timeout'     => 15,
6147
-        'redirection' => 5
6148
-    );
6149
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6150
-    $data       = wp_remote_get( $url, $args );
6144
+	// readme contents
6145
+	$args = array(
6146
+		'timeout'     => 15,
6147
+		'redirection' => 5
6148
+	);
6149
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6150
+	$data       = wp_remote_get( $url, $args );
6151 6151
 
6152
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6152
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6153 6153
 
6154
-        geodir_in_plugin_update_message($data['body']);
6155
-    }
6154
+		geodir_in_plugin_update_message($data['body']);
6155
+	}
6156 6156
 }
6157 6157
 
6158 6158
 
@@ -6160,28 +6160,28 @@  discard block
 block discarded – undo
6160 6160
 * @param string $content http response body
6161 6161
 */
6162 6162
 function geodir_in_plugin_update_message($content) {
6163
-    // Output Upgrade Notice
6164
-    $matches        = null;
6165
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6166
-    $upgrade_notice = '';
6167
-    if ( preg_match( $regexp, $content, $matches ) ) {
6168
-        if(empty($matches)){return;}
6169
-
6170
-        $version = trim( $matches[1] );
6171
-        if($version && $version>GEODIRECTORY_VERSION){
6172
-
6173
-
6174
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6175
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6176
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6177
-            foreach ( $notices as $index => $line ) {
6178
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6179
-            }
6180
-            $upgrade_notice .= '</div> ';
6181
-        }
6182
-        }
6183
-    }
6184
-    echo $upgrade_notice;
6163
+	// Output Upgrade Notice
6164
+	$matches        = null;
6165
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6166
+	$upgrade_notice = '';
6167
+	if ( preg_match( $regexp, $content, $matches ) ) {
6168
+		if(empty($matches)){return;}
6169
+
6170
+		$version = trim( $matches[1] );
6171
+		if($version && $version>GEODIRECTORY_VERSION){
6172
+
6173
+
6174
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6175
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6176
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6177
+			foreach ( $notices as $index => $line ) {
6178
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6179
+			}
6180
+			$upgrade_notice .= '</div> ';
6181
+		}
6182
+		}
6183
+	}
6184
+	echo $upgrade_notice;
6185 6185
 }
6186 6186
 
6187 6187
 /**
@@ -6214,19 +6214,19 @@  discard block
 block discarded – undo
6214 6214
  * @param array Listing statuses to be skipped.
6215 6215
  */
6216 6216
 function geodir_imex_export_skip_statuses() {
6217
-    $statuses = array( 'trash', 'auto-draft' );
6217
+	$statuses = array( 'trash', 'auto-draft' );
6218 6218
     
6219
-    /**
6220
-     * Filter the statuses to skip during GD export listings.
6221
-     *
6222
-     * @since 1.6.0
6223
-     * @package GeoDirectory
6224
-     *
6225
-     * @param array $statuses Listing statuses to be skipped.
6226
-     */
6227
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6219
+	/**
6220
+	 * Filter the statuses to skip during GD export listings.
6221
+	 *
6222
+	 * @since 1.6.0
6223
+	 * @package GeoDirectory
6224
+	 *
6225
+	 * @param array $statuses Listing statuses to be skipped.
6226
+	 */
6227
+	$statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6228 6228
      
6229
-    return $statuses;
6229
+	return $statuses;
6230 6230
 }
6231 6231
 
6232 6232
 /**
@@ -6242,42 +6242,42 @@  discard block
 block discarded – undo
6242 6242
  * @global string $typenow Current post type.
6243 6243
  */
6244 6244
 function geodir_admin_dequeue_scripts() {
6245
-    global $typenow;
6245
+	global $typenow;
6246 6246
     
6247
-    // EDD
6248
-    if (wp_script_is('jquery-chosen', 'enqueued')) {
6249
-        wp_dequeue_script('jquery-chosen');
6250
-    }
6247
+	// EDD
6248
+	if (wp_script_is('jquery-chosen', 'enqueued')) {
6249
+		wp_dequeue_script('jquery-chosen');
6250
+	}
6251 6251
     
6252
-    // Ultimate Addons for Visual Composer
6253
-    if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6254
-        wp_dequeue_script('ultimate-vc-backend-script');
6255
-    }
6252
+	// Ultimate Addons for Visual Composer
6253
+	if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6254
+		wp_dequeue_script('ultimate-vc-backend-script');
6255
+	}
6256 6256
     
6257
-    // VC editor conflicts
6258
-    if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
6259
-        wp_dequeue_script('dfd_vc_damin_scripts');
6260
-    }
6257
+	// VC editor conflicts
6258
+	if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
6259
+		wp_dequeue_script('dfd_vc_damin_scripts');
6260
+	}
6261 6261
     
6262
-    // Ultimate chosen
6263
-    if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
6264
-        wp_dequeue_script('ultimate-chosen-script');
6265
-    }
6262
+	// Ultimate chosen
6263
+	if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
6264
+		wp_dequeue_script('ultimate-chosen-script');
6265
+	}
6266 6266
     
6267
-    // Crum composer choosen
6268
-    if (wp_script_is('crum-composer-choosen', 'enqueued')) {
6269
-        wp_dequeue_script('crum-composer-choosen');
6270
-    }
6267
+	// Crum composer choosen
6268
+	if (wp_script_is('crum-composer-choosen', 'enqueued')) {
6269
+		wp_dequeue_script('crum-composer-choosen');
6270
+	}
6271 6271
     
6272
-    // Fix conflict Fusion Builder jquery chosen with GD jquery chosen.
6273
-    if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
6274
-        wp_dequeue_script('fusion_builder_chosen_js');
6275
-    }
6272
+	// Fix conflict Fusion Builder jquery chosen with GD jquery chosen.
6273
+	if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
6274
+		wp_dequeue_script('fusion_builder_chosen_js');
6275
+	}
6276 6276
     
6277
-    // Fix conflicts timepicker & setting date value.
6278
-    if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
6279
-        wp_dequeue_script('acf-timepicker');
6280
-    }
6277
+	// Fix conflicts timepicker & setting date value.
6278
+	if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
6279
+		wp_dequeue_script('acf-timepicker');
6280
+	}
6281 6281
 }
6282 6282
 
6283 6283
 /**
@@ -6293,48 +6293,48 @@  discard block
 block discarded – undo
6293 6293
  * @return string SQL where clause part.
6294 6294
  */
6295 6295
 function geodir_imex_get_filter_where($where = '', $post_type = '') {
6296
-    global $wpdb;
6296
+	global $wpdb;
6297 6297
     
6298
-    $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6298
+	$filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6299 6299
     
6300
-    if ( !empty( $filters ) ) {
6301
-        foreach ( $filters as $field => $value ) {
6302
-            switch ($field) {
6303
-                case 'start_date':
6304
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6305
-                break;
6306
-                case 'end_date':
6307
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6308
-                break;
6309
-            }
6310
-        }
6311
-    }
6300
+	if ( !empty( $filters ) ) {
6301
+		foreach ( $filters as $field => $value ) {
6302
+			switch ($field) {
6303
+				case 'start_date':
6304
+					$where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6305
+				break;
6306
+				case 'end_date':
6307
+					$where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6308
+				break;
6309
+			}
6310
+		}
6311
+	}
6312 6312
     
6313
-    return $where;
6313
+	return $where;
6314 6314
 }
6315 6315
 add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2);
6316 6316
 add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
6317 6317
 
6318 6318
 
6319 6319
 function geodir_fix_for_primer_theme(){
6320
-    if(!defined( 'PRIMER_VERSION' )){return;}
6321
-    global $pagenow;
6320
+	if(!defined( 'PRIMER_VERSION' )){return;}
6321
+	global $pagenow;
6322 6322
 
6323
-    if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) )  ){
6323
+	if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) )  ){
6324 6324
 
6325
-        $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] );
6325
+		$post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] );
6326 6326
 
6327
-        $post_types = geodir_get_posttypes();
6328
-        if ($post_type && in_array($post_type, $post_types) ) {
6329
-            global $primer_customizer_layouts;
6330
-            remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10);
6331
-        }
6332
-    }
6327
+		$post_types = geodir_get_posttypes();
6328
+		if ($post_type && in_array($post_type, $post_types) ) {
6329
+			global $primer_customizer_layouts;
6330
+			remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10);
6331
+		}
6332
+	}
6333 6333
 
6334 6334
 }
6335 6335
 
6336 6336
 if(is_admin()){
6337
-    add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);  
6337
+	add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);  
6338 6338
 }
6339 6339
 
6340 6340
 
@@ -6467,96 +6467,96 @@  discard block
 block discarded – undo
6467 6467
 
6468 6468
 function geodir_ga_activation_url() {
6469 6469
 
6470
-    return add_query_arg( array(
6471
-        'next'          => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
6472
-        'scope'         => GEODIR_GA_SCOPE,
6473
-        'response_type' => 'code',
6474
-        'redirect_uri'  => GEODIR_GA_REDIRECT,
6475
-        'client_id'     => GEODIR_GA_CLIENTID,
6476
-    ), 'https://accounts.google.com/o/oauth2/auth' );
6470
+	return add_query_arg( array(
6471
+		'next'          => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
6472
+		'scope'         => GEODIR_GA_SCOPE,
6473
+		'response_type' => 'code',
6474
+		'redirect_uri'  => GEODIR_GA_REDIRECT,
6475
+		'client_id'     => GEODIR_GA_CLIENTID,
6476
+	), 'https://accounts.google.com/o/oauth2/auth' );
6477 6477
 
6478
-    return $url;
6478
+	return $url;
6479 6479
 }
6480 6480
 
6481 6481
 function geodir_gd_accounts(){
6482
-    $accounts = array();
6483
-    $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true );
6484
-    if($useAuth){
6485
-        try {
6486
-            $accounts = geodir_ga_get_analytics_accounts();
6487
-        } catch (Exception $e) {
6488
-            geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) );
6489
-        }
6482
+	$accounts = array();
6483
+	$useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true );
6484
+	if($useAuth){
6485
+		try {
6486
+			$accounts = geodir_ga_get_analytics_accounts();
6487
+		} catch (Exception $e) {
6488
+			geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) );
6489
+		}
6490 6490
         
6491
-        if(is_array($accounts)){
6492
-            $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
6493
-        }elseif(get_option('geodir_ga_account_id')){
6494
-            $accounts = array();
6495
-            $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
6496
-        }
6497
-    }
6498
-    return $accounts;
6491
+		if(is_array($accounts)){
6492
+			$accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
6493
+		}elseif(get_option('geodir_ga_account_id')){
6494
+			$accounts = array();
6495
+			$accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
6496
+		}
6497
+	}
6498
+	return $accounts;
6499 6499
 }
6500 6500
 
6501 6501
 function geodir_ga_get_analytics_accounts()
6502 6502
 {
6503
-    global $gd_ga_errors;
6504
-    $accounts = array();
6503
+	global $gd_ga_errors;
6504
+	$accounts = array();
6505 6505
 
6506
-    if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
6506
+	if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
6507 6507
 
6508 6508
 
6509
-    if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
6510
-      return get_option('geodir_gd_uids');
6511
-    }
6509
+	if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
6510
+	  return get_option('geodir_gd_uids');
6511
+	}
6512 6512
 
6513
-    # Create a new Gdata call
6514
-    if ( trim(get_option('geodir_ga_auth_code')) != '' )
6515
-        $stats = new GDGoogleAnalyticsStats();
6516
-    else
6517
-        return false;
6513
+	# Create a new Gdata call
6514
+	if ( trim(get_option('geodir_ga_auth_code')) != '' )
6515
+		$stats = new GDGoogleAnalyticsStats();
6516
+	else
6517
+		return false;
6518 6518
 
6519
-    # Check if Google sucessfully logged in
6520
-    if ( ! $stats->checkLogin() )
6521
-        return false;
6519
+	# Check if Google sucessfully logged in
6520
+	if ( ! $stats->checkLogin() )
6521
+		return false;
6522 6522
 
6523
-    # Get a list of accounts
6524
-    try {
6525
-        $accounts = $stats->getAllProfiles();
6526
-    } catch (Exception $e) {
6527
-        $gd_ga_errors[] = $e->getMessage();
6528
-        return false;
6529
-    }
6523
+	# Get a list of accounts
6524
+	try {
6525
+		$accounts = $stats->getAllProfiles();
6526
+	} catch (Exception $e) {
6527
+		$gd_ga_errors[] = $e->getMessage();
6528
+		return false;
6529
+	}
6530 6530
 
6531 6531
 
6532
-    natcasesort ($accounts);
6532
+	natcasesort ($accounts);
6533 6533
 
6534
-    # Return the account array if there are accounts
6535
-    if ( count($accounts) > 0 ){
6536
-        update_option('geodir_gd_uids',$accounts);
6537
-        return $accounts;
6538
-    }
6539
-    else
6540
-        return false;
6534
+	# Return the account array if there are accounts
6535
+	if ( count($accounts) > 0 ){
6536
+		update_option('geodir_gd_uids',$accounts);
6537
+		return $accounts;
6538
+	}
6539
+	else
6540
+		return false;
6541 6541
 }
6542 6542
 
6543 6543
 add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' );
6544 6544
 function geodir_ga_deauthorize(){
6545 6545
 
6546
-    if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
6546
+	if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
6547 6547
 
6548
-        die( 'Security check' );
6548
+		die( 'Security check' );
6549 6549
 
6550
-    } else {
6551
-        update_option('geodir_ga_auth_token','');
6552
-        update_option('geodir_ga_auth_code','');
6553
-        update_option('geodir_gd_uids','');
6550
+	} else {
6551
+		update_option('geodir_ga_auth_token','');
6552
+		update_option('geodir_ga_auth_code','');
6553
+		update_option('geodir_gd_uids','');
6554 6554
 
6555 6555
 
6556
-        echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
6557
-    }
6556
+		echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
6557
+	}
6558 6558
 
6559
-    die();
6559
+	die();
6560 6560
 }
6561 6561
 
6562 6562
 
@@ -6567,12 +6567,12 @@  discard block
 block discarded – undo
6567 6567
  * @package GeoDirectory
6568 6568
  */
6569 6569
 function geodir_post_type_setting_fun() {
6570
-    $post_type_arr = array();
6570
+	$post_type_arr = array();
6571 6571
 
6572
-    $post_types = geodir_get_posttypes('object');
6572
+	$post_types = geodir_get_posttypes('object');
6573 6573
 
6574
-    foreach ($post_types as $key => $post_types_obj) {
6575
-        $post_type_arr[$key] = $post_types_obj->labels->singular_name;
6576
-    }
6577
-    return $post_type_arr;
6574
+	foreach ($post_types as $key => $post_types_obj) {
6575
+		$post_type_arr[$key] = $post_types_obj->labels->singular_name;
6576
+	}
6577
+	return $post_type_arr;
6578 6578
 }
6579 6579
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +935 added lines, -935 removed lines patch added patch discarded remove patch
@@ -28,31 +28,31 @@  discard block
 block discarded – undo
28 28
      * @package GeoDirectory
29 29
      */
30 30
     function geodir_admin_styles() {
31
-        wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
31
+        wp_register_style('geodirectory-admin-css', geodir_plugin_url().'/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
32 32
         wp_enqueue_style('geodirectory-admin-css');
33 33
 
34
-        wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
34
+        wp_register_style('geodirectory-frontend-style', geodir_plugin_url().'/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
35 35
         wp_enqueue_style('geodirectory-frontend-style');
36 36
 
37
-        wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
37
+        wp_register_style('geodir-chosen-style', geodir_plugin_url().'/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
38 38
         wp_enqueue_style('geodir-chosen-style');
39 39
 
40
-        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
40
+        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url().'/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
41 41
         wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
42 42
 
43
-        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
43
+        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url().'/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
44 44
         wp_enqueue_style('geodirectory-jquery-ui-css');
45 45
 
46
-        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
46
+        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url().'/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
47 47
         wp_enqueue_style('geodirectory-custom-fields-css');
48 48
 
49
-        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
49
+        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url().'/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
50 50
         wp_enqueue_style('geodirectory-pluplodar-css');
51 51
 
52
-        wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
52
+        wp_register_style('geodir-rating-style', geodir_plugin_url().'/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
53 53
         wp_enqueue_style('geodir-rating-style');
54 54
 
55
-        wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
55
+        wp_register_style('geodir-rtl-style', geodir_plugin_url().'/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
56 56
         wp_enqueue_style('geodir-rtl-style');
57 57
     }
58 58
 }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
71 71
         wp_enqueue_style('font-awesome');
72 72
 
73
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
73
+        wp_register_script('geodirectory-admin', geodir_plugin_url().'/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
74 74
         wp_enqueue_script('geodirectory-admin');
75 75
 
76 76
     }
@@ -89,60 +89,60 @@  discard block
 block discarded – undo
89 89
         
90 90
         wp_enqueue_script('jquery');
91 91
 
92
-        wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
92
+        wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
93 93
 
94
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
94
+        wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
95 95
         wp_enqueue_script('chosen');
96 96
 
97
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
97
+        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url().'/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
98 98
         wp_enqueue_script('geodirectory-choose-ajax');
99 99
 
100 100
         if (isset($_REQUEST['listing_type'])) {
101
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
101
+            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url().'/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
102 102
         }
103 103
 
104 104
         wp_enqueue_script('geodirectory-custom-fields-script');
105
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
105
+        $plugin_path = geodir_plugin_url().'/geodirectory-functions/cat-meta-functions';
106 106
 
107
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
107
+        wp_enqueue_script('tax-meta-clss', $plugin_path.'/js/tax-meta-clss.js', array('jquery'), null, true);
108 108
 
109 109
         if (in_array($geodir_map_name, array('auto', 'google'))) {
110
-            $map_lang = "&language=" . geodir_get_map_default_language();
111
-            $map_key = "&key=" . geodir_get_map_api_key();
110
+            $map_lang = "&language=".geodir_get_map_default_language();
111
+            $map_key = "&key=".geodir_get_map_api_key();
112 112
             /** This filter is documented in geodirectory_template_tags.php */
113 113
             $map_extra = apply_filters('geodir_googlemap_script_extra', '');
114
-            wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
114
+            wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?'.$map_lang.$map_key.$map_extra, '', NULL);
115 115
         }
116 116
         
117 117
         if ($geodir_map_name == 'osm') {
118 118
             // Leaflet OpenStreetMap
119
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
119
+            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
120 120
             wp_enqueue_style('geodirectory-leaflet-style');
121 121
                 
122
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
122
+            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
123 123
             wp_enqueue_script('geodirectory-leaflet-script');
124 124
             
125
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
125
+            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
126 126
             wp_enqueue_script('geodirectory-leaflet-geo-script');
127 127
         }
128
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
128
+        wp_enqueue_script('jquery-ui-autocomplete');
129 129
         
130
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
130
+        wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
131 131
         wp_enqueue_script('geodirectory-goMap-script');
132 132
 
133
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
133
+        wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
134 134
         wp_enqueue_script('geodirectory-goMap-script');
135 135
 
136 136
 		// font awesome rating script
137 137
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
138
-			wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
138
+			wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
139 139
 			wp_enqueue_script('geodir-barrating-js');
140 140
 		} else { // default rating script
141
-			wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
141
+			wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
142 142
 			wp_enqueue_script('geodir-jRating-js');
143 143
 		}
144 144
 
145
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
145
+        wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
146 146
         wp_enqueue_script('geodir-on-document-load');
147 147
 
148 148
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         wp_enqueue_script('plupload-all');
151 151
         wp_enqueue_script('jquery-ui-sortable');
152 152
 
153
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
153
+        wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
154 154
         wp_enqueue_script('geodirectory-plupload-script');
155 155
 
156 156
         // SCRIPT FOR UPLOAD END
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
205 205
 
206 206
 
207
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
207
+        wp_register_script('geodirectory-admin-script', geodir_plugin_url().'/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
208 208
         wp_enqueue_script('geodirectory-admin-script');
209 209
 
210 210
         wp_enqueue_style('farbtastic');
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 
213 213
         $screen = get_current_screen();
214 214
         if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
215
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
215
+            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation_admin.js');
216 216
         }
217 217
 
218
-        $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
218
+        $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl').'?geodir_ajax=true')));
219 219
         wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
220 220
 
221 221
     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
         if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
240 240
 
241
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
241
+        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url().'/geodirectory-assets/images/favicon.ico', '55.1984');
242 242
 
243 243
 
244 244
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                 $geodir_menu_order[] = 'separator-geodirectory';
273 273
                 if (!empty($post_types)) {
274 274
                     foreach ($post_types as $post_type) {
275
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
275
+                        $geodir_menu_order[] = 'edit.php?post_type='.$post_type;
276 276
                     }
277 277
                 }
278 278
                 $geodir_menu_order[] = $item;
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 {
316 316
     if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
317 317
         echo '<div id="message" class="updated fade">
318
-                        <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
319
-                        <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
318
+                        <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory').' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">'.__('Support us by leaving a rating!', 'geodirectory').'</a></p>
319
+                        <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory').'</strong></p>
320 320
                 </div>';
321 321
 
322 322
     }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
     if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
325 325
         switch ($_REQUEST['msg']) {
326 326
             case 'success':
327
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
327
+                echo '<div id="message" class="updated fade"><p><strong>'.__('Your settings have been saved.', 'geodirectory').'</strong></p></div>';
328 328
                 flush_rewrite_rules(false);
329 329
 
330 330
                 break;
@@ -332,30 +332,30 @@  discard block
 block discarded – undo
332 332
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
333 333
 				
334 334
 				if ($gderr == 21)
335
-			    	echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
335
+			    	echo '<div id="message" class="error fade"><p><strong>'.__('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory').'</strong></p></div>';
336 336
 				else
337
-					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
337
+					echo '<div id="message" class="error fade"><p><strong>'.__('Error: Your settings have not been saved, please try again.', 'geodirectory').'</strong></p></div>';
338 338
                 break;
339 339
         }
340 340
     }
341 341
 
342 342
     $geodir_load_map = get_option('geodir_load_map');
343 343
     $need_map_key = false;
344
-    if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
344
+    if ($geodir_load_map == '' || $geodir_load_map == 'google' || $geodir_load_map == 'auto') {
345 345
         $need_map_key = true;
346 346
     }
347 347
 
348 348
     if (!geodir_get_map_api_key() && $need_map_key) {
349
-        echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
349
+        echo '<div class="error"><p><strong>'.sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings').'\'>', '</a>').'</strong></p></div>';
350 350
     }
351 351
 
352 352
     if (!geodir_is_default_location_set()) {
353
-        echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
353
+        echo '<div class="updated fade"><p><strong>'.sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=default_location_settings').'\'>', '</a>').'</strong></p></div>';
354 354
 
355 355
     }
356 356
 
357 357
     if (!function_exists('curl_init')) {
358
-        echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
358
+        echo '<div class="error"><p><strong>'.__('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory').'</strong></p></div>';
359 359
 
360 360
     }
361 361
 
@@ -375,18 +375,18 @@  discard block
 block discarded – undo
375 375
 function geodir_handle_option_form_submit($current_tab)
376 376
 {
377 377
     global $geodir_settings;
378
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
378
+    if (file_exists(dirname(__FILE__).'/option-pages/'.$current_tab.'_array.php')) {
379 379
         /**
380 380
          * Contains settings array for current tab.
381 381
          *
382 382
          * @since 1.0.0
383 383
          * @package GeoDirectory
384 384
          */
385
-        include_once('option-pages/' . $current_tab . '_array.php');
385
+        include_once('option-pages/'.$current_tab.'_array.php');
386 386
     }
387 387
     if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
388 388
         if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
+        if (!wp_verify_nonce($_REQUEST['_wpnonce-'.$current_tab], 'geodir-settings-'.$current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
390 390
 		
391 391
 		/**
392 392
 		 * Fires before updating geodirectory admin settings.
@@ -419,13 +419,13 @@  discard block
 block discarded – undo
419 419
          * @param string $current_tab The current settings tab name.
420 420
          * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
421 421
          */
422
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
422
+        do_action('geodir_update_options_'.$current_tab, $geodir_settings[$current_tab]);
423 423
 
424 424
         flush_rewrite_rules(false);
425 425
 
426 426
         $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
427 427
 
428
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
428
+        $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$_REQUEST['active_tab'].'&msg=success');
429 429
 
430 430
         wp_redirect($redirect_url);
431 431
         exit();
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
 
465 465
         elseif (isset($value['type']) && $value['type'] == 'image_width') :
466 466
 
467
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
468
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
469
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
470
-                if (isset($_POST[$value['id'] . '_crop'])) :
471
-                    update_option($value['id'] . '_crop', 1);
467
+            if (isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
468
+                update_option($value['id'].'_width', $_POST[$value['id'].'_width']);
469
+                update_option($value['id'].'_height', $_POST[$value['id'].'_height']);
470
+                if (isset($_POST[$value['id'].'_crop'])) :
471
+                    update_option($value['id'].'_crop', 1);
472 472
                 else :
473
-                    update_option($value['id'] . '_crop', 0);
473
+                    update_option($value['id'].'_crop', 0);
474 474
                 endif;
475 475
             } else {
476
-                update_option($value['id'] . '_width', $value['std']);
477
-                update_option($value['id'] . '_height', $value['std']);
478
-                update_option($value['id'] . '_crop', 1);
476
+                update_option($value['id'].'_width', $value['std']);
477
+                update_option($value['id'].'_height', $value['std']);
478
+                update_option($value['id'].'_crop', 1);
479 479
             }
480 480
 
481 481
         elseif (isset($value['type']) && $value['type'] == 'map') :
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
         elseif (isset($value['type']) && $value['type'] == 'file') :
518 518
 
519 519
 
520
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
520
+            if (isset($_POST[$value['id'].'_remove']) && $_POST[$value['id'].'_remove']) {// if remove is set then remove the file
521 521
 
522 522
                 if (get_option($value['id'])) {
523 523
                     $image_name_arr = explode('/', get_option($value['id']));
524 524
                     $noimg_name = end($image_name_arr);
525
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
525
+                    $img_path = $uploads['path'].'/'.$noimg_name;
526 526
                     if (file_exists($img_path))
527 527
                         unlink($img_path);
528 528
                 }
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                 if (get_option($value['id'])) {
551 551
                     $image_name_arr = explode('/', get_option($value['id']));
552 552
                     $noimg_name = end($image_name_arr);
553
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
553
+                    $img_path = $uploads['path'].'/'.$noimg_name;
554 554
                     if (file_exists($img_path))
555 555
                         unlink($img_path);
556 556
                 }
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
             // same menu setting per theme.
572 572
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
573 573
                 $theme = wp_get_theme();
574
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
574
+                update_option('geodir_theme_location_nav_'.$theme->name, $_POST[$value['id']]);
575 575
             }
576 576
 
577 577
             if (isset($value['id']) && isset($_POST[$value['id']])) {
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 
642 642
             $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory');
643 643
 
644
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
644
+            $tabs[$geodir_post_type.'_fields_settings'] = array(
645 645
                 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
646 646
                 'subtabs' => array(
647 647
                     array('subtab' => 'custom_fields',
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
  */
676 676
 function geodir_tools_setting_tab($tabs)
677 677
 {
678
-    wp_enqueue_script( 'jquery-ui-progressbar' );
678
+    wp_enqueue_script('jquery-ui-progressbar');
679 679
     $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
680 680
     return $tabs;
681 681
 }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
  */
710 710
 function geodir_extend_geodirectory_setting_tab($tabs)
711 711
 {
712
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
712
+    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory').' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
713 713
     return $tabs;
714 714
 }
715 715
 
@@ -769,8 +769,8 @@  discard block
 block discarded – undo
769 769
                     _e('Unknown', 'geodirectory');
770 770
                 } else {
771 771
                     /* If there is a city id, append 'city name' to the text string. */
772
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
773
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
772
+                    $add_location_id = $location_id > 0 ? ' ('.$location_id.')' : '';
773
+                    echo(__($location->country, 'geodirectory').'-'.$location->region.'-'.$location->city.$add_location_id);
774 774
                 }
775 775
                 break;
776 776
 
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
                         $expire_class = 'expire_over';
789 789
                     }
790 790
                     $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
791
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
791
+                    $date_diff_text = '<br /><span class="'.$expire_class.'">('.$date_diff.' '.$state.')</span>';
792 792
                 }
793 793
                 /* If no expire_date is found, output a default message. */
794 794
                 if (empty($expire_date))
795 795
                     echo __('Unknown', 'geodirectory');
796 796
                 /* If there is a expire_date, append 'days left' to the text string. */
797 797
                 else
798
-                    echo $expire_date . $date_diff_text;
798
+                    echo $expire_date.$date_diff_text;
799 799
                 break;
800 800
 
801 801
             /* If displaying the 'categorys' column. */
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 function geodir_post_information_save($post_id, $post) {
863 863
     global $wpdb, $current_user;
864 864
 
865
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
865
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
866 866
         return;
867 867
     }
868 868
 
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                     $tab_id = $value['id'];
931 931
 
932 932
                 if (isset($value['desc']) && $value['desc'])
933
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
933
+                    $desc = '<span style=" text-transform:none;">:- '.$value['desc'].'</span>';
934 934
 
935 935
                 if (isset($value['name']) && $value['name']) {
936 936
                     if ($first_title === true) {
@@ -938,9 +938,9 @@  discard block
 block discarded – undo
938 938
                     } else {
939 939
                         echo '</div>';
940 940
                     }
941
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
941
+                    echo '<dd id="'.trim($tab_id).'" class="geodir_option_tabs" ><a href="javascript:void(0);">'.$value['name'].'</a></dd>';
942 942
 
943
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
943
+                    echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
944 944
                 }
945 945
 
946 946
                 /**
@@ -950,21 +950,21 @@  discard block
 block discarded – undo
950 950
                  *
951 951
                  * @since 1.0.0
952 952
                  */
953
-                do_action('geodir_settings_' . sanitize_title($value['id']));
953
+                do_action('geodir_settings_'.sanitize_title($value['id']));
954 954
                 break;
955 955
 
956 956
             case 'no_tabs':
957 957
 
958 958
                 echo '<div class="inner_content_tab_main">';
959
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
959
+                echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
960 960
 
961 961
                 break;
962 962
 
963 963
             case 'sectionstart':
964 964
                 if (isset($value['desc']) && $value['desc'])
965
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
965
+                    $desc = '<span style=" text-transform:none;"> - '.$value['desc'].'</span>';
966 966
                 if (isset($value['name']) && $value['name'])
967
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
967
+                    echo '<h3>'.$value['name'].$desc.'</h3>';
968 968
                 /**
969 969
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
970 970
                  *
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
                  *
973 973
                  * @since 1.0.0
974 974
                  */
975
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
976
-                echo '<table class="form-table">' . "\n\n";
975
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_start');
976
+                echo '<table class="form-table">'."\n\n";
977 977
 
978 978
                 break;
979 979
             case 'sectionend':
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
                  *
985 985
                  * @since 1.0.0
986 986
                  */
987
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
987
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_end');
988 988
                 echo '</table>';
989 989
                 /**
990 990
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
                  *
994 994
                  * @since 1.0.0
995 995
                  */
996
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
996
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_after');
997 997
                 break;
998 998
             case 'text':
999 999
                 ?>
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1003 1003
                                            id="<?php echo esc_attr($value['id']); ?>"
1004 1004
                                            type="<?php echo esc_attr($value['type']); ?>"
1005
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1005
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1006 1006
                                            style=" <?php echo esc_attr($value['css']); ?>"
1007 1007
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1008 1008
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1020 1020
                                            id="<?php echo esc_attr($value['id']); ?>"
1021 1021
                                            type="<?php echo esc_attr($value['type']); ?>"
1022
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1022
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1023 1023
                                            style=" <?php echo esc_attr($value['css']); ?>"
1024 1024
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1025 1025
                                                echo esc_attr(stripslashes(get_option($value['id'])));
1026 1026
                                            } else {
1027 1027
                                                echo esc_attr($value['std']);
1028 1028
                                            } ?>"/>
1029
-                    <a href='https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]&TB_iframe=true&width=600&height=400' class="thickbox button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','geodirectory');?>" ><?php _e('Generate API Key','geodirectory');?></a>
1029
+                    <a href='https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]&TB_iframe=true&width=600&height=400' class="thickbox button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )', 'geodirectory'); ?>" ><?php _e('Generate API Key', 'geodirectory'); ?></a>
1030 1030
                     <span class="description"><?php echo $value['desc']; ?></span></td>
1031 1031
                 </tr><?php
1032 1032
                 break;
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1039 1039
                                            id="<?php echo esc_attr($value['id']); ?>"
1040 1040
                                            type="<?php echo esc_attr($value['type']); ?>"
1041
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1041
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1042 1042
                                            style="<?php echo esc_attr($value['css']); ?>"
1043 1043
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1044 1044
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1084,17 +1084,17 @@  discard block
 block discarded – undo
1084 1084
                     <?php _e('Width', 'geodirectory'); ?> <input
1085 1085
                         name="<?php echo esc_attr($value['id']); ?>_width"
1086 1086
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
1087
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1087
+                        value="<?php if ($size = get_option($value['id'].'_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1088 1088
 
1089 1089
                     <?php _e('Height', 'geodirectory'); ?> <input
1090 1090
                         name="<?php echo esc_attr($value['id']); ?>_height"
1091 1091
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
1092
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1092
+                        value="<?php if ($size = get_option($value['id'].'_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1093 1093
 
1094 1094
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1095 1095
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1096 1096
                             id="<?php echo esc_attr($value['id']); ?>_crop"
1097
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
1097
+                            type="checkbox" <?php if (get_option($value['id'].'_crop') != '') checked(get_option($value['id'].'_crop'), 1); else checked(1); ?> /></label>
1098 1098
 
1099 1099
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1100 1100
                 </tr><?php
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
                                             id="<?php echo esc_attr($value['id']); ?>"
1145 1145
                                             style="<?php echo esc_attr($value['css']); ?>"
1146 1146
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1147
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1147
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>"
1148 1148
                                             option-ajaxchosen="false">
1149 1149
                         <?php
1150 1150
                         foreach ($value['options'] as $key => $val) {
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
                                 ?></optgroup><?php
1155 1155
                             } else {
1156 1156
                                 ?>
1157
-                                <option value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>>
1157
+                                <option value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>>
1158 1158
                                     <?php echo geodir_utf8_ucfirst($val) ?>
1159 1159
                                 </option>
1160 1160
                             <?php
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
                 ?>
1192 1192
 
1193 1193
                 <tr valign="top">
1194
-                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1194
+                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
1195 1195
                     <td width="60%">
1196 1196
                         <select name="geodir_default_map_language" style="width:60%">
1197 1197
                             <?php
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 
1274 1274
                 <tr valign="top">
1275 1275
                     <th class="titledesc"
1276
-                        width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
1276
+                        width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
1277 1277
                     <td width="60%">
1278 1278
                         <select name="geodir_default_map_search_pt" style="width:60%">
1279 1279
                             <?php
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
                         $cat_display = 'checkbox';
1315 1315
                         $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1316 1316
                         $gd_cats = get_option('geodir_exclude_cat_on_map');
1317
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1317
+                        $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
1318 1318
                         $count = 1;
1319 1319
                         ?>
1320 1320
                         <table width="70%" class="widefat">
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
                                                                                            name="home_map_post_types[]"
1344 1344
                                                                                            id="<?php echo esc_attr($value['id']); ?>"
1345 1345
                                                                                            value="<?php echo $key; ?>"
1346
-                                                                                           class="map_post_type" <?php echo $checked;?> />
1346
+                                                                                           class="map_post_type" <?php echo $checked; ?> />
1347 1347
                                         <?php echo __($post_types_obj->labels->singular_name, 'geodirectory'); ?></td>
1348 1348
                                     <td width="40%">
1349 1349
                                         <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
@@ -1401,12 +1401,12 @@  discard block
 block discarded – undo
1401 1401
                 ?>
1402 1402
                 <fieldset>
1403 1403
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1404
-                    <label for="<?php echo $value['id'];?>">
1404
+                    <label for="<?php echo $value['id']; ?>">
1405 1405
                         <input name="<?php echo esc_attr($value['id']); ?>"
1406
-                               id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1406
+                               id="<?php echo esc_attr($value['id'].$value['value']); ?>" type="radio"
1407 1407
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1408 1408
                             echo 'checked="checked"';
1409
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1409
+                        }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
1410 1410
                         <?php echo $value['desc']; ?></label><br>
1411 1411
                 </fieldset>
1412 1412
                 <?php
@@ -1426,9 +1426,9 @@  discard block
 block discarded – undo
1426 1426
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1427 1427
                 <td class="forminp">
1428 1428
                     <textarea
1429
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1429
+                        <?php if (isset($value['args'])) echo $value['args'].' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1430 1430
                         id="<?php echo esc_attr($value['id']); ?>"
1431
-                        <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1431
+                        <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1432 1432
                         style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea($value['std']); ?></textarea><span
1433 1433
                         class="description"><?php echo $value['desc'] ?></span>
1434 1434
 
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
 					}
1474 1474
 				}
1475 1475
 				//
1476
-				$page_setting = (int)get_option($value['id']);
1476
+				$page_setting = (int) get_option($value['id']);
1477 1477
 
1478 1478
                 $args = array('name' => $value['id'],
1479 1479
                     'id' => $value['id'],
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
                 <tr valign="top" class="single_select_page">
1491 1491
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1492 1492
                 <td class="forminp">
1493
-                    <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' " . $disabled . " id=", wp_dropdown_pages($args)); ?>
1493
+                    <?php echo str_replace(' id=', " data-placeholder='".__('Select a page...', 'geodirectory')."' style='".$value['css']."' class='".$value['class']."' ".$disabled." id=", wp_dropdown_pages($args)); ?>
1494 1494
                     <span class="description"><?php echo $value['desc'] ?></span>
1495 1495
                 </td>
1496 1496
                 </tr><?php
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
 				}
1500 1500
                 break;
1501 1501
             case 'single_select_country' :
1502
-                $country_setting = (string)get_option($value['id']);
1502
+                $country_setting = (string) get_option($value['id']);
1503 1503
                 if (strstr($country_setting, ':')) :
1504 1504
                     $country = current(explode(':', $country_setting));
1505 1505
                     $state = end(explode(':', $country_setting));
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
             case 'multi_select_countries' :
1523 1523
                 $countries = $geodirectory->countries->countries;
1524 1524
                 asort($countries);
1525
-                $selections = (array)get_option($value['id']);
1525
+                $selections = (array) get_option($value['id']);
1526 1526
                 ?>
1527 1527
                 <tr valign="top">
1528 1528
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
                             title="Country" class="chosen_select">
1533 1533
                         <?php
1534 1534
                         if ($countries) foreach ($countries as $key => $val) :
1535
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1535
+                            echo '<option value="'.$key.'" '.selected(in_array($key, $selections), true, false).'>'.$val.'</option>';
1536 1536
                         endforeach;
1537 1537
                         ?>
1538 1538
                     </select>
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
                 break;
1545 1545
 
1546 1546
             case 'google_analytics' :
1547
-                $selections = (array)get_option($value['id']);
1547
+                $selections = (array) get_option($value['id']);
1548 1548
                     ?>
1549 1549
                     <tr valign="top">
1550 1550
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1555,30 +1555,30 @@  discard block
 block discarded – undo
1555 1555
 
1556 1556
                             $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1557 1557
                             $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1558
-                            $state = "&state=123";//any string
1559
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1558
+                            $state = "&state=123"; //any string
1559
+                            $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
1560 1560
                             $response_type = "&response_type=code";
1561 1561
                             $client_id = "&client_id=".get_option('geodir_ga_client_id');
1562 1562
                             $access_type = "&access_type=offline";
1563 1563
                             $approval_prompt = "&approval_prompt=force";
1564 1564
 
1565
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1565
+                            $auth_url = $oAuthURL.$scope.$state.$redirect_uri.$response_type.$client_id.$access_type.$approval_prompt;
1566 1566
 
1567 1567
 
1568 1568
                             if (get_option('geodir_ga_auth_token')) {
1569 1569
                                 ?>
1570 1570
                                 <span class="button-primary"
1571
-                                      onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
1571
+                                      onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize'); ?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
1572 1572
                                 <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1573 1573
                             <?php
1574 1574
                                 global $gd_ga_errors;
1575
-                                if(!empty($gd_ga_errors)){
1575
+                                if (!empty($gd_ga_errors)) {
1576 1576
                                     print_r($gd_ga_errors);
1577 1577
                                 }
1578 1578
                             } else {
1579 1579
                                 ?>
1580 1580
                                 <span class="button-primary"
1581
-                                      onclick="window.open('<?php echo  geodir_ga_activation_url();?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Authorize', 'geodirectory');?></span>
1581
+                                      onclick="window.open('<?php echo  geodir_ga_activation_url(); ?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Authorize', 'geodirectory'); ?></span>
1582 1582
                             <?php
1583 1583
                             }
1584 1584
                             ?>
@@ -1649,9 +1649,9 @@  discard block
 block discarded – undo
1649 1649
 
1650 1650
             <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
1651 1651
             jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
1652
-            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
1652
+            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
1653 1653
             jQuery('.gd-content-heading').hide();
1654
-            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
1654
+            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
1655 1655
             <?php } ?>
1656 1656
         });
1657 1657
     </script>
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
     wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
1738 1738
 
1739 1739
     if (geodir_get_featured_image($post_id, 'thumbnail')) {
1740
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
1740
+        echo '<h4>'.__('Featured Image', 'geodirectory').'</h4>';
1741 1741
         geodir_show_featured_image($post_id, 'thumbnail');
1742 1742
     }
1743 1743
 
@@ -1748,13 +1748,13 @@  discard block
 block discarded – undo
1748 1748
 
1749 1749
     <h5 class="form_title">
1750 1750
         <?php if ($image_limit != 0 && $image_limit == 1) {
1751
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
1751
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
1752 1752
         } ?>
1753 1753
         <?php if ($image_limit != 0 && $image_limit > 1) {
1754
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
1754
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
1755 1755
         } ?>
1756 1756
         <?php if ($image_limit == 0) {
1757
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
1757
+            echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
1758 1758
         } ?>
1759 1759
     </h5>
1760 1760
 
@@ -1793,10 +1793,10 @@  discard block
 block discarded – undo
1793 1793
         <div
1794 1794
             class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
1795 1795
             id="<?php echo $id; ?>plupload-upload-ui">
1796
-            <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
1796
+            <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
1797 1797
             <input id="<?php echo $id; ?>plupload-browse-button" type="button"
1798 1798
                    value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
1799
-            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
1799
+            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span>
1800 1800
             <?php if ($width && $height): ?>
1801 1801
                 <span class="plupload-resize"></span>
1802 1802
                 <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span>
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
              id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
1809 1809
         </div>
1810 1810
         <span
1811
-            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
1811
+            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory'); ?></span>
1812 1812
         <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
1813 1813
     </div>
1814 1814
 
@@ -2018,9 +2018,9 @@  discard block
 block discarded – undo
2018 2018
     $plugin = 'avada-nag';
2019 2019
     $timestamp = 'avada-nag1234';
2020 2020
     $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2021
-    echo '<div id="' . $timestamp . '"  class="error">';
2022
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2023
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2021
+    echo '<div id="'.$timestamp.'"  class="error">';
2022
+    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\''.$plugin.'\',\''.$timestamp.'\');" ><i class="fa fa-times"></i></span>';
2023
+    echo "<img class='gd-icon-noti' src='".plugin_dir_url('')."geodirectory/geodirectory-assets/images/favicon.ico' > ";
2024 2024
     echo "<p>$message</p>";
2025 2025
     echo "</div>";
2026 2026
 
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
 		
2155 2155
 		// Don't allow same slug url for listing and location
2156 2156
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2157
-			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2157
+			$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab.'&msg=fail&gderr=21');
2158 2158
         	wp_redirect($redirect_url);
2159 2159
 			exit;
2160 2160
 		}
@@ -2166,7 +2166,7 @@  discard block
 block discarded – undo
2166 2166
 			$default_language = $sitepress->get_default_language();
2167 2167
 			
2168 2168
 			if ($current_language != 'all' && $current_language != $default_language) {
2169
-				$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
2169
+				$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab);
2170 2170
 				wp_redirect($redirect_url);
2171 2171
 				exit;
2172 2172
 			}
@@ -2187,11 +2187,11 @@  discard block
 block discarded – undo
2187 2187
 function geodir_hide_admin_preview_button() {
2188 2188
     global $post_type;
2189 2189
     $post_types = geodir_get_posttypes();
2190
-    if(in_array($post_type, $post_types))
2190
+    if (in_array($post_type, $post_types))
2191 2191
         echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2192 2192
 }
2193
-add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2194
-add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2193
+add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
2194
+add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
2195 2195
 
2196 2196
 /**
2197 2197
  * Add the tab in left sidebar menu fro import & export page.
@@ -2201,8 +2201,8 @@  discard block
 block discarded – undo
2201 2201
  *
2202 2202
  * @return array Array of tab data.
2203 2203
  */
2204
-function geodir_import_export_tab( $tabs ) {
2205
-	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2204
+function geodir_import_export_tab($tabs) {
2205
+	$tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
2206 2206
     return $tabs;
2207 2207
 }
2208 2208
 
@@ -2216,8 +2216,8 @@  discard block
 block discarded – undo
2216 2216
  * @return string Html content.
2217 2217
  */
2218 2218
 function geodir_import_export_page() {
2219
-	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2220
-	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2219
+	$nonce = wp_create_nonce('geodir_import_export_nonce');
2220
+	$gd_cats_sample_csv = geodir_plugin_url().'/geodirectory-assets/gd_sample_categories.csv';
2221 2221
     /**
2222 2222
      * Filter sample category data csv file url.
2223 2223
      *
@@ -2226,9 +2226,9 @@  discard block
 block discarded – undo
2226 2226
      *
2227 2227
      * @param string $gd_cats_sample_csv Sample category data csv file url.
2228 2228
      */
2229
-	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2229
+	$gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
2230 2230
 	
2231
-	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2231
+	$gd_posts_sample_csv = geodir_plugin_url().'/geodirectory-assets/place_listing.csv';
2232 2232
     /**
2233 2233
      * Filter sample post data csv file url.
2234 2234
      *
@@ -2237,15 +2237,15 @@  discard block
 block discarded – undo
2237 2237
      *
2238 2238
      * @param string $gd_posts_sample_csv Sample post data csv file url.
2239 2239
      */
2240
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2240
+    $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
2241 2241
 	
2242
-	$gd_posttypes = geodir_get_posttypes( 'array' );
2242
+	$gd_posttypes = geodir_get_posttypes('array');
2243 2243
 	
2244 2244
 	$gd_posttypes_option = '';
2245
-	foreach ( $gd_posttypes as $gd_posttype => $row ) {
2246
-		$gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>';
2245
+	foreach ($gd_posttypes as $gd_posttype => $row) {
2246
+		$gd_posttypes_option .= '<option value="'.$gd_posttype.'" data-cats="'.(int) geodir_get_terms_count($gd_posttype).'" data-posts="'.(int) geodir_get_posts_count($gd_posttype).'">'.__($row['labels']['name'], 'geodirectory').'</option>';
2247 2247
 	}
2248
-	wp_enqueue_script( 'jquery-ui-progressbar' );
2248
+	wp_enqueue_script('jquery-ui-progressbar');
2249 2249
 	
2250 2250
 	$gd_chunksize_options = array();
2251 2251
 	$gd_chunksize_options[100] = 100;
@@ -2267,50 +2267,50 @@  discard block
 block discarded – undo
2267 2267
      *
2268 2268
      * @param string $gd_chunksize_options Entries options.
2269 2269
      */
2270
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2270
+    $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
2271 2271
 	
2272 2272
 	$gd_chunksize_option = '';
2273 2273
 	foreach ($gd_chunksize_options as $value => $title) {
2274
-		$gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>';
2274
+		$gd_chunksize_option .= '<option value="'.$value.'" '.selected($value, 5000, false).'>'.$title.'</option>';
2275 2275
 	}
2276 2276
 	
2277 2277
 	$uploads = wp_upload_dir();
2278
-	$upload_dir = wp_sprintf( CSV_TRANSFER_IMG_FOLDER, str_replace( ABSPATH, '', $uploads['path'] ) );
2278
+	$upload_dir = wp_sprintf(CSV_TRANSFER_IMG_FOLDER, str_replace(ABSPATH, '', $uploads['path']));
2279 2279
 ?>
2280 2280
 </form>
2281 2281
 <div class="inner_content_tab_main gd-import-export">
2282
-  <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3>
2283
-  <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span>
2282
+  <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
2283
+  <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
2284 2284
   <div class="gd-content-heading">
2285 2285
 
2286 2286
   <?php
2287 2287
     ini_set('max_execution_time', 999999);
2288
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2288
+    $ini_max_execution_time_check = @ini_get('max_execution_time');
2289 2289
     ini_restore('max_execution_time');
2290 2290
 
2291
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2291
+    if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
2292 2292
         ?>
2293 2293
 	<div id="gd_ie_reqs" class="metabox-holder">
2294 2294
       <div class="meta-box-sortables ui-sortable">
2295 2295
         <div class="postbox">
2296
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3>
2296
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
2297 2297
           <div class="inside">
2298
-            <span class="description"><?php echo __( 'Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory' );?></span>
2298
+            <span class="description"><?php echo __('Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory'); ?></span>
2299 2299
 			<table class="form-table">
2300 2300
 				<thead>
2301 2301
 				  <tr>
2302
-				  	<th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th>
2302
+				  	<th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
2303 2303
 				  </tr>
2304 2304
 				</thead>
2305 2305
 				<tbody>
2306 2306
 				  <tr>
2307
-				  	<td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td>
2307
+				  	<td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
2308 2308
 				  </tr>
2309 2309
 				  <tr>
2310
-				  	<td>max_execution_time</td><td><?php  echo @ini_get( 'max_execution_time' );?></td><td>3000</td>
2310
+				  	<td>max_execution_time</td><td><?php  echo @ini_get('max_execution_time'); ?></td><td>3000</td>
2311 2311
 				  </tr>
2312 2312
 				  <tr>
2313
-				  	<td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td>
2313
+				  	<td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
2314 2314
 				  </tr>
2315 2315
 				</tbody>
2316 2316
 		    </table>
@@ -2322,21 +2322,21 @@  discard block
 block discarded – undo
2322 2322
 	<div id="gd_ie_imposts" class="metabox-holder">
2323 2323
       <div class="meta-box-sortables ui-sortable">
2324 2324
         <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox">
2325
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Listings: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2326
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3>
2325
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Listings: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2326
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
2327 2327
           <div class="inside">
2328 2328
             <table class="form-table">
2329 2329
 				<tbody>
2330 2330
 				  <tr>
2331 2331
 					<td class="gd-imex-box">
2332 2332
 						<div class="gd-im-choices">
2333
-						<p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e( 'Update listing if post with post_id already exists.', 'geodirectory' );?></label></p>
2334
-						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e( 'Ignore listing if post with post_id already exists.', 'geodirectory' );?></label></p>
2333
+						<p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e('Update listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
2334
+						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e('Ignore listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
2335 2335
 						</div>
2336 2336
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui">
2337 2337
 							<input type="text" readonly="readonly" name="gd_im_post_file" class="gd-imex-file gd_im_post_file" id="gd_im_post" onclick="jQuery('#gd_im_postplupload-browse-button').trigger('click');" />
2338
-							<input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
2339
-						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" />
2338
+							<input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
2339
+						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" />
2340 2340
 						<input type="hidden" id="gd_im_post_allowed_types" data-exts=".csv" value="csv" />
2341 2341
 							<?php
2342 2342
 							/**
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
 							 */
2347 2347
 							do_action('geodir_sample_csv_download_link');
2348 2348
 							?>
2349
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span>
2349
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
2350 2350
 							<div class="filelist"></div>
2351 2351
 						</div>
2352 2352
 						<span id="gd_im_postupload-error" style="display:none"></span>
@@ -2364,7 +2364,7 @@  discard block
 block discarded – undo
2364 2364
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2365 2365
 						</div>
2366 2366
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2367
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2367
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2368 2368
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2369 2369
 									id="gd-import-perc">0%</font> )
2370 2370
 								<div class="gd-fileprogress"></div>
@@ -2376,10 +2376,10 @@  discard block
 block discarded – undo
2376 2376
                     	<div class="gd-imex-btns" style="display:none;">
2377 2377
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2378 2378
                         	<input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2379
-                        	<input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2380
-                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
2379
+                        	<input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2380
+                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
2381 2381
 							<div id="gd_process_data" style="display:none">
2382
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2382
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2383 2383
 							</div>
2384 2384
 						</div>
2385 2385
 					</td>
@@ -2393,30 +2393,30 @@  discard block
 block discarded – undo
2393 2393
 	<div id="gd_ie_excategs" class="metabox-holder">
2394 2394
 	  <div class="meta-box-sortables ui-sortable">
2395 2395
 		<div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox">
2396
-		  <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - Listings: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2397
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3>
2396
+		  <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - Listings: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2397
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
2398 2398
 		  <div class="inside">
2399 2399
 			<table class="form-table">
2400 2400
 			  <tbody>
2401 2401
 				<tr>
2402 2402
 				  <td class="fld"><label for="gd_post_type">
2403
-					<?php _e( 'Post Type:', 'geodirectory' );?>
2403
+					<?php _e('Post Type:', 'geodirectory'); ?>
2404 2404
 					</label></td>
2405 2405
 				  <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px">
2406
-					  <?php echo $gd_posttypes_option;?>
2406
+					  <?php echo $gd_posttypes_option; ?>
2407 2407
 					</select></td>
2408 2408
 				</tr>
2409 2409
 				<tr>
2410
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2411
-					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td>
2410
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2411
+					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
2412 2412
 				</tr>
2413 2413
                 <tr class="gd-imex-dates">
2414
-					<td class="fld"><label><?php _e( 'Published Date:', 'geodirectory' );?></label></td>
2415
-					<td><label><span class="label-responsive"><?php _e( 'Start date:', 'geodirectory' );?></span><input type="text" id="gd_imex_start_date" name="gd_imex[start_date]" data-type="date" /></label><label><span class="label-responsive"><?php _e( 'End date:', 'geodirectory' );?></span><input type="text" id="gd_imex_end_date" name="gd_imex[end_date]" data-type="date" /></label></td>
2414
+					<td class="fld"><label><?php _e('Published Date:', 'geodirectory'); ?></label></td>
2415
+					<td><label><span class="label-responsive"><?php _e('Start date:', 'geodirectory'); ?></span><input type="text" id="gd_imex_start_date" name="gd_imex[start_date]" data-type="date" /></label><label><span class="label-responsive"><?php _e('End date:', 'geodirectory'); ?></span><input type="text" id="gd_imex_end_date" name="gd_imex[end_date]" data-type="date" /></label></td>
2416 2416
 				</tr>
2417 2417
 				<tr>
2418 2418
 				  <td class="fld" style="vertical-align:top"><label>
2419
-					<?php _e( 'Progress:', 'geodirectory' );?>
2419
+					<?php _e('Progress:', 'geodirectory'); ?>
2420 2420
 					</label></td>
2421 2421
 				  <td><div id='gd_progressbar_box'>
2422 2422
 					  <div id="gd_progressbar" class="gd_progressbar">
@@ -2424,13 +2424,13 @@  discard block
 block discarded – undo
2424 2424
 					  </div>
2425 2425
 					</div>
2426 2426
 					<p style="display:inline-block">
2427
-					  <?php _e( 'Elapsed Time:', 'geodirectory' );?>
2427
+					  <?php _e('Elapsed Time:', 'geodirectory'); ?>
2428 2428
 					</p>
2429 2429
 					  
2430 2430
 					<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2431 2431
 				</tr>
2432 2432
 				<tr class="gd-ie-actions">
2433
-				  <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
2433
+				  <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
2434 2434
 				  </td>
2435 2435
 				  <td id="gd_ie_ex_files" class="gd-ie-files"></td>
2436 2436
 				</tr>
@@ -2443,21 +2443,21 @@  discard block
 block discarded – undo
2443 2443
 	<div id="gd_ie_imcategs" class="metabox-holder">
2444 2444
       <div class="meta-box-sortables ui-sortable">
2445 2445
         <div id="gd_ie_imcats" class="postbox gd-hndle-pbox">
2446
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2447
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3>
2446
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2447
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
2448 2448
           <div class="inside">
2449 2449
             <table class="form-table">
2450 2450
 				<tbody>
2451 2451
 				  <tr>
2452 2452
 					<td class="gd-imex-box">
2453 2453
 						<div class="gd-im-choices">
2454
-						<p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e( 'Update item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p>
2455
-						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e( 'Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p>
2454
+						<p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e('Update item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
2455
+						<p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e('Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
2456 2456
 						</div>
2457 2457
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui">
2458 2458
 							<input type="text" readonly="readonly" name="gd_im_cat_file" class="gd-imex-file gd_im_cat_file" id="gd_im_cat" onclick="jQuery('#gd_im_catplupload-browse-button').trigger('click');" />
2459
-							<input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
2460
-						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" />
2459
+							<input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
2460
+						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" />
2461 2461
 						<input type="hidden" id="gd_im_cat_allowed_types" data-exts=".csv" value="csv" />
2462 2462
 						<?php
2463 2463
 						/**
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 						 */
2469 2469
 						do_action('geodir_sample_cats_csv_download_link');
2470 2470
 						?>
2471
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span>
2471
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
2472 2472
 							<div class="filelist"></div>
2473 2473
 						</div>
2474 2474
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2486 2486
 						</div>
2487 2487
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2488
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2488
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2489 2489
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2490 2490
 									id="gd-import-perc">0%</font> )
2491 2491
 								<div class="gd-fileprogress"></div>
@@ -2497,10 +2497,10 @@  discard block
 block discarded – undo
2497 2497
                     	<div class="gd-imex-btns" style="display:none;">
2498 2498
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2499 2499
                         	<input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2500
-                        	<input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2501
-                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
2500
+                        	<input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
2501
+                        	<input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
2502 2502
 							<div id="gd_process_data" style="display:none">
2503
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2503
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2504 2504
 							</div>
2505 2505
 						</div>
2506 2506
 					</td>
@@ -2514,26 +2514,26 @@  discard block
 block discarded – undo
2514 2514
 	<div id="gd_ie_excategs" class="metabox-holder">
2515 2515
       <div class="meta-box-sortables ui-sortable">
2516 2516
         <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox">
2517
-          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2518
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3>
2517
+          <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
2518
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
2519 2519
           <div class="inside">
2520 2520
             <table class="form-table">
2521 2521
 				<tbody>
2522 2522
 				  <tr>
2523
-					<td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td>
2524
-					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td>
2523
+					<td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
2524
+					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td>
2525 2525
 				  </tr>
2526 2526
 				   <tr>
2527
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2528
-					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td>
2527
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2528
+					<td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
2529 2529
 				  </tr>
2530 2530
 				  <tr>
2531
-					<td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td>
2532
-					<td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e( 'Elapsed Time:', 'geodirectory' );?></p>&nbsp;&nbsp;<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2531
+					<td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
2532
+					<td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e('Elapsed Time:', 'geodirectory'); ?></p>&nbsp;&nbsp;<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2533 2533
 				  </tr>
2534 2534
 				  <tr class="gd-ie-actions">
2535 2535
 					<td style="vertical-align:top">
2536
-						<input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2536
+						<input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2537 2537
 					</td>
2538 2538
 					<td id="gd_ie_ex_files" class="gd-ie-files"></td>
2539 2539
 				  </tr>
@@ -2555,7 +2555,7 @@  discard block
 block discarded – undo
2555 2555
      * @param array $gd_chunksize_options File chunk size options.
2556 2556
      * @param string $nonce Wordpress security token for GD import & export.
2557 2557
 	 */
2558
-	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2558
+	do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
2559 2559
 	?>
2560 2560
   </div>
2561 2561
 </div>
@@ -2574,7 +2574,7 @@  discard block
 block discarded – undo
2574 2574
         jQuery.ajax({
2575 2575
             url: ajaxurl,
2576 2576
             type: "POST",
2577
-            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>',
2577
+            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>',
2578 2578
             dataType: 'json',
2579 2579
             cache: false,
2580 2580
             success: function(data) {
@@ -2626,7 +2626,7 @@  discard block
 block discarded – undo
2626 2626
 
2627 2627
         jQuery(cont).find('.filelist .file').remove();
2628 2628
         
2629
-        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
2629
+        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
2630 2630
         jQuery('#gd-import-msg', cont).show();
2631 2631
         
2632 2632
         return false;
@@ -2685,7 +2685,7 @@  discard block
 block discarded – undo
2685 2685
     jQuery.ajax({
2686 2686
         url: ajaxurl,
2687 2687
         type: "POST",
2688
-        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>',
2688
+        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>',
2689 2689
         dataType : 'json',
2690 2690
         cache: false,
2691 2691
         success: function (data) {
@@ -2874,27 +2874,27 @@  discard block
 block discarded – undo
2874 2874
 
2875 2875
     var gdMsg = '<p></p>';
2876 2876
     if ( processed > 0 ) {
2877
-        var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>';
2877
+        var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
2878 2878
         msgParse = msgParse.replace("%s", processed);
2879 2879
         gdMsg += msgParse;
2880 2880
     }
2881 2881
 
2882 2882
     if ( updated > 0 ) {
2883
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>';
2883
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
2884 2884
         msgParse = msgParse.replace("%s", updated);
2885 2885
         msgParse = msgParse.replace("%d", processed);
2886 2886
         gdMsg += msgParse;
2887 2887
     }
2888 2888
 
2889 2889
     if ( created > 0 ) {
2890
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>';
2890
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
2891 2891
         msgParse = msgParse.replace("%s", created);
2892 2892
         msgParse = msgParse.replace("%d", processed);
2893 2893
         gdMsg += msgParse;
2894 2894
     }
2895 2895
 
2896 2896
     if ( skipped > 0 ) {
2897
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>';
2897
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
2898 2898
         msgParse = msgParse.replace("%s", skipped);
2899 2899
         msgParse = msgParse.replace("%d", processed);
2900 2900
         gdMsg += msgParse;
@@ -2904,17 +2904,17 @@  discard block
 block discarded – undo
2904 2904
         if (type=='loc') {
2905 2905
             invalid_addr = invalid;
2906 2906
         }
2907
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ), '%s', '%d' ) );?></p>';
2907
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'), '%s', '%d')); ?></p>';
2908 2908
         msgParse = msgParse.replace("%s", invalid_addr);
2909 2909
         msgParse = msgParse.replace("%d", total);
2910 2910
         gdMsg += msgParse;
2911 2911
     }
2912 2912
 
2913 2913
     if (invalid > 0 && type!='loc') {
2914
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory' ), '%s', '%d' ) );?></p>';
2914
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory'), '%s', '%d')); ?></p>';
2915 2915
         
2916 2916
         if (type=='hood') {
2917
-            msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ), '%s', '%d' ) );?></p>';
2917
+            msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory'), '%s', '%d')); ?></p>';
2918 2918
         }
2919 2919
         msgParse = msgParse.replace("%s", invalid);
2920 2920
         msgParse = msgParse.replace("%d", total);
@@ -2922,7 +2922,7 @@  discard block
 block discarded – undo
2922 2922
     }
2923 2923
 
2924 2924
     if (images > 0) {
2925
-        gdMsg += '<p><?php echo addslashes( $upload_dir );?></p>';
2925
+        gdMsg += '<p><?php echo addslashes($upload_dir); ?></p>';
2926 2926
     }
2927 2927
     gdMsg += '<p></p>';
2928 2928
     jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -3086,9 +3086,9 @@  discard block
 block discarded – undo
3086 3086
             if (typeof filters !== 'undefined' && filters && doFilter) {
3087 3087
                 getTotal = true;
3088 3088
                 attach += '&_c=1';
3089
-                gd_progressbar(el, 0, '<i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Preparing...', 'geodirectory' ) );?>');
3089
+                gd_progressbar(el, 0, '<i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Preparing...', 'geodirectory')); ?>');
3090 3090
             } else {
3091
-                gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3091
+                gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3092 3092
             }
3093 3093
             jQuery(el).find('#gd_timer').text('00:00:01');
3094 3094
             jQuery('#gd_ie_ex_files', el).html('');
@@ -3097,7 +3097,7 @@  discard block
 block discarded – undo
3097 3097
         jQuery.ajax({
3098 3098
             url: ajaxurl,
3099 3099
             type: "POST",
3100
-            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page + attach,
3100
+            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page + attach,
3101 3101
             dataType : 'json',
3102 3102
             cache: false,
3103 3103
             beforeSend: function (jqXHR, settings) {},
@@ -3122,11 +3122,11 @@  discard block
 block discarded – undo
3122 3122
                         } else {
3123 3123
                             if (pages < page || pages == page) {
3124 3124
                                 window.clearInterval(timer_posts);
3125
-                                gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3125
+                                gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3126 3126
                             } else {
3127 3127
                                 var percentage = Math.round(((page * chunk_size) / total_posts) * 100);
3128 3128
                                 percentage = percentage > 100 ? 100 : percentage;
3129
-                                gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3129
+                                gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3130 3130
                             }
3131 3131
                             if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3132 3132
                                 var obj_files = data.files;
@@ -3157,7 +3157,7 @@  discard block
 block discarded – undo
3157 3157
 
3158 3158
     function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
3159 3159
         if (page < 2) {
3160
-            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3160
+            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3161 3161
             jQuery(el).find('#gd_timer').text('00:00:01');
3162 3162
             jQuery('#gd_ie_ex_files', el).html('');
3163 3163
         }
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
         jQuery.ajax({
3166 3166
             url: ajaxurl,
3167 3167
             type: "POST",
3168
-            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3168
+            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3169 3169
             dataType : 'json',
3170 3170
             cache: false,
3171 3171
             beforeSend: function (jqXHR, settings) {},
@@ -3179,11 +3179,11 @@  discard block
 block discarded – undo
3179 3179
                     } else {
3180 3180
                         if (pages < page || pages == page) {
3181 3181
                             window.clearInterval(timer_cats);
3182
-                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3182
+                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3183 3183
                         } else {
3184 3184
                             var percentage = Math.round(((page * chunk_size) / total_cats) * 100);
3185 3185
                             percentage = percentage > 100 ? 100 : percentage;
3186
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
3186
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
3187 3187
                         }
3188 3188
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3189 3189
                             var obj_files = data.files;
@@ -3240,13 +3240,13 @@  discard block
 block discarded – undo
3240 3240
 function geodir_init_filesystem()
3241 3241
 {
3242 3242
 
3243
-    if(!function_exists('get_filesystem_method')){
3243
+    if (!function_exists('get_filesystem_method')) {
3244 3244
         require_once(ABSPATH."/wp-admin/includes/file.php");
3245 3245
     }
3246 3246
     $access_type = get_filesystem_method();
3247 3247
     if ($access_type === 'direct') {
3248 3248
         /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3249
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3249
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3250 3250
 
3251 3251
         /* initialize the API */
3252 3252
         if (!WP_Filesystem($creds)) {
@@ -3259,7 +3259,7 @@  discard block
 block discarded – undo
3259 3259
         return $wp_filesystem;
3260 3260
         /* do our file manipulations below */
3261 3261
     } elseif (defined('FTP_USER')) {
3262
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3262
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3263 3263
 
3264 3264
         /* initialize the API */
3265 3265
         if (!WP_Filesystem($creds)) {
@@ -3294,7 +3294,7 @@  discard block
 block discarded – undo
3294 3294
  * @package GeoDirectory
3295 3295
  */
3296 3296
 function geodir_filesystem_notice()
3297
-{   if ( defined( 'DOING_AJAX' ) ){return;}
3297
+{   if (defined('DOING_AJAX')) {return; }
3298 3298
     $access_type = get_filesystem_method();
3299 3299
     if ($access_type === 'direct') {
3300 3300
     } elseif (!defined('FTP_USER')) {
@@ -3334,64 +3334,64 @@  discard block
 block discarded – undo
3334 3334
     // try to set higher limits for import
3335 3335
     $max_input_time = ini_get('max_input_time');
3336 3336
     $max_execution_time = ini_get('max_execution_time');
3337
-    $memory_limit= ini_get('memory_limit');
3337
+    $memory_limit = ini_get('memory_limit');
3338 3338
 
3339
-    if(!$max_input_time || $max_input_time<3000){
3339
+    if (!$max_input_time || $max_input_time < 3000) {
3340 3340
         ini_set('max_input_time', 3000);
3341 3341
     }
3342 3342
 
3343
-    if(!$max_execution_time || $max_execution_time<3000){
3343
+    if (!$max_execution_time || $max_execution_time < 3000) {
3344 3344
         ini_set('max_execution_time', 3000);
3345 3345
     }
3346 3346
 
3347
-    if($memory_limit && str_replace('M','',$memory_limit)){
3348
-        if(str_replace('M','',$memory_limit)<256){
3347
+    if ($memory_limit && str_replace('M', '', $memory_limit)) {
3348
+        if (str_replace('M', '', $memory_limit) < 256) {
3349 3349
             ini_set('memory_limit', '256M');
3350 3350
         }
3351 3351
     }
3352 3352
 
3353 3353
     $json = array();
3354 3354
 
3355
-    if ( !current_user_can( 'manage_options' ) ) {
3356
-        wp_send_json( $json );
3355
+    if (!current_user_can('manage_options')) {
3356
+        wp_send_json($json);
3357 3357
     }
3358 3358
 
3359
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3360
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3361
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3359
+    $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL;
3360
+    $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL;
3361
+    $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false;
3362 3362
 
3363
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3364
-        wp_send_json( $json );
3363
+    if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
3364
+        wp_send_json($json);
3365 3365
     }
3366 3366
 
3367
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3368
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3367
+    $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL;
3368
+    $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL;
3369 3369
     $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3370
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3370
+    $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1;
3371 3371
 
3372 3372
     $wp_filesystem = geodir_init_filesystem();
3373 3373
     if (!$wp_filesystem) {
3374
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3375
-        wp_send_json( $json );
3374
+        $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
3375
+        wp_send_json($json);
3376 3376
     }
3377 3377
 
3378 3378
     if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3379
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3380
-        wp_send_json( $json );
3379
+        $json['error'] = __('Filesystem ERROR: '.$wp_filesystem->errors->get_error_message(), 'geodirectory');
3380
+        wp_send_json($json);
3381 3381
     }
3382 3382
 
3383
-    $csv_file_dir = geodir_path_import_export( false );
3384
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3385
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3386
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3387
-            wp_send_json( $json );
3383
+    $csv_file_dir = geodir_path_import_export(false);
3384
+    if (!$wp_filesystem->is_dir($csv_file_dir)) {
3385
+        if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
3386
+            $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
3387
+            wp_send_json($json);
3388 3388
         }
3389 3389
     }
3390 3390
     
3391 3391
     $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3392 3392
     $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3393 3393
 
3394
-    switch ( $task ) {
3394
+    switch ($task) {
3395 3395
         case 'export_posts': {
3396 3396
             // WPML
3397 3397
             $is_wpml = geodir_is_wpml();
@@ -3402,36 +3402,36 @@  discard block
 block discarded – undo
3402 3402
                 $sitepress->switch_lang('all', true);
3403 3403
             }
3404 3404
             // WPML
3405
-            if ( $post_type == 'gd_event' ) {
3406
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3405
+            if ($post_type == 'gd_event') {
3406
+                add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
3407 3407
             }
3408
-            $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3408
+            $filters = !empty($_REQUEST['gd_imex']) && is_array($_REQUEST['gd_imex']) ? $_REQUEST['gd_imex'] : NULL;
3409 3409
             
3410
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3411
-            if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3412
-                $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3410
+            $file_name = $post_type.'_'.date('dmyHi');
3411
+            if ($filters && isset($filters['start_date']) && isset($filters['end_date'])) {
3412
+                $file_name = $post_type.'_'.date_i18n('dmy', strtotime($filters['start_date'])).'_'.date_i18n('dmy', strtotime($filters['end_date']));
3413 3413
             }
3414
-            $posts_count = geodir_get_posts_count( $post_type );
3415
-            $file_url_base = geodir_path_import_export() . '/';
3416
-            $file_url = $file_url_base . $file_name . '.csv';
3417
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3418
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3414
+            $posts_count = geodir_get_posts_count($post_type);
3415
+            $file_url_base = geodir_path_import_export().'/';
3416
+            $file_url = $file_url_base.$file_name.'.csv';
3417
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3418
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'_'.$nonce.'.csv';
3419 3419
             
3420 3420
             $chunk_file_paths = array();
3421 3421
 
3422
-            if ( isset( $_REQUEST['_c'] ) ) {
3422
+            if (isset($_REQUEST['_c'])) {
3423 3423
                 $json['total'] = $posts_count;
3424 3424
                 // WPML
3425 3425
                 if ($is_wpml) {
3426 3426
                     $sitepress->switch_lang($active_lang, true);
3427 3427
                 }
3428 3428
                 // WPML
3429
-                wp_send_json( $json );
3429
+                wp_send_json($json);
3430 3430
                 gd_die();
3431
-            } else if ( isset( $_REQUEST['_st'] ) ) {
3432
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3433
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3434
-                $percentage = min( $percentage, 100 );
3431
+            } else if (isset($_REQUEST['_st'])) {
3432
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3433
+                $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0;
3434
+                $percentage = min($percentage, 100);
3435 3435
                 
3436 3436
                 $json['percentage'] = $percentage;
3437 3437
                 // WPML
@@ -3439,45 +3439,45 @@  discard block
 block discarded – undo
3439 3439
                     $sitepress->switch_lang($active_lang, true);
3440 3440
                 }
3441 3441
                 // WPML
3442
-                wp_send_json( $json );
3442
+                wp_send_json($json);
3443 3443
                 gd_die();
3444 3444
             } else {
3445
-                if ( !$posts_count > 0 ) {
3446
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3445
+                if (!$posts_count > 0) {
3446
+                    $json['error'] = __('No records to export.', 'geodirectory');
3447 3447
                 } else {
3448 3448
                     $total_posts = $posts_count;
3449 3449
                     if ($chunk_per_page > $total_posts) {
3450 3450
                         $chunk_per_page = $total_posts;
3451 3451
                     }
3452
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3452
+                    $chunk_total_pages = ceil($total_posts / $chunk_per_page);
3453 3453
                     
3454 3454
                     $j = $chunk_page_no;
3455
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3455
+                    $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j);
3456 3456
                     
3457 3457
                     $per_page = 500;
3458 3458
                     if ($per_page > $chunk_per_page) {
3459 3459
                         $per_page = $chunk_per_page;
3460 3460
                     }
3461
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3461
+                    $total_pages = ceil($chunk_per_page / $per_page);
3462 3462
                     
3463
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3464
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3463
+                    for ($i = 0; $i <= $total_pages; $i++) {
3464
+                        $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page);
3465 3465
                         
3466 3466
                         $clear = $i == 0 ? true : false;
3467
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3467
+                        geodir_save_csv_data($file_path_temp, $save_posts, $clear);
3468 3468
                     }
3469 3469
                         
3470
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3471
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3472
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3473
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3474
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3470
+                    if ($wp_filesystem->exists($file_path_temp)) {
3471
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3472
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3473
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3474
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3475 3475
                         
3476
-                        $file_url = $file_url_base . $chunk_file_name;
3477
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3476
+                        $file_url = $file_url_base.$chunk_file_name;
3477
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3478 3478
                     }
3479 3479
                     
3480
-                    if ( !empty($chunk_file_paths) ) {
3480
+                    if (!empty($chunk_file_paths)) {
3481 3481
                         $json['total'] = $posts_count;
3482 3482
                         $json['files'] = $chunk_file_paths;
3483 3483
                     } else {
@@ -3485,7 +3485,7 @@  discard block
 block discarded – undo
3485 3485
                             $json['total'] = $posts_count;
3486 3486
                             $json['files'] = array();
3487 3487
                         } else {
3488
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3488
+                            $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3489 3489
                         }
3490 3490
                     }
3491 3491
                 }
@@ -3494,7 +3494,7 @@  discard block
 block discarded – undo
3494 3494
                     $sitepress->switch_lang($active_lang, true);
3495 3495
                 }
3496 3496
                 // WPML
3497
-                wp_send_json( $json );
3497
+                wp_send_json($json);
3498 3498
             }
3499 3499
         }
3500 3500
         break;
@@ -3508,20 +3508,20 @@  discard block
 block discarded – undo
3508 3508
                 $sitepress->switch_lang('all', true);
3509 3509
             }
3510 3510
             // WPML
3511
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3511
+            $file_name = $post_type.'category_'.date('dmyHi');
3512 3512
             
3513
-            $terms_count = geodir_get_terms_count( $post_type );
3514
-            $file_url_base = geodir_path_import_export() . '/';
3515
-            $file_url = $file_url_base . $file_name . '.csv';
3516
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3517
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3513
+            $terms_count = geodir_get_terms_count($post_type);
3514
+            $file_url_base = geodir_path_import_export().'/';
3515
+            $file_url = $file_url_base.$file_name.'.csv';
3516
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3517
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'category_'.$nonce.'.csv';
3518 3518
             
3519 3519
             $chunk_file_paths = array();
3520 3520
             
3521
-            if ( isset( $_REQUEST['_st'] ) ) {
3522
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3523
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3524
-                $percentage = min( $percentage, 100 );
3521
+            if (isset($_REQUEST['_st'])) {
3522
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3523
+                $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0;
3524
+                $percentage = min($percentage, 100);
3525 3525
                 
3526 3526
                 $json['percentage'] = $percentage;
3527 3527
                 // WPML
@@ -3529,48 +3529,48 @@  discard block
 block discarded – undo
3529 3529
                     $sitepress->switch_lang($active_lang, true);
3530 3530
                 }
3531 3531
                 // WPML
3532
-                wp_send_json( $json );
3532
+                wp_send_json($json);
3533 3533
             } else {
3534
-                if ( !$terms_count > 0 ) {
3535
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3534
+                if (!$terms_count > 0) {
3535
+                    $json['error'] = __('No records to export.', 'geodirectory');
3536 3536
                 } else {
3537 3537
                     $total_terms = $terms_count;
3538 3538
                     if ($chunk_per_page > $terms_count) {
3539 3539
                         $chunk_per_page = $terms_count;
3540 3540
                     }
3541
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3541
+                    $chunk_total_pages = ceil($total_terms / $chunk_per_page);
3542 3542
                     
3543 3543
                     $j = $chunk_page_no;
3544
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3544
+                    $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j);
3545 3545
                     
3546 3546
                     $per_page = 500;
3547 3547
                     if ($per_page > $chunk_per_page) {
3548 3548
                         $per_page = $chunk_per_page;
3549 3549
                     }
3550
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3550
+                    $total_pages = ceil($chunk_per_page / $per_page);
3551 3551
                     
3552
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3553
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3552
+                    for ($i = 0; $i <= $total_pages; $i++) {
3553
+                        $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page);
3554 3554
                         
3555 3555
                         $clear = $i == 0 ? true : false;
3556
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3556
+                        geodir_save_csv_data($file_path_temp, $save_terms, $clear);
3557 3557
                     }
3558 3558
                     
3559
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3560
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3561
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3562
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3563
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3559
+                    if ($wp_filesystem->exists($file_path_temp)) {
3560
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3561
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3562
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3563
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3564 3564
                         
3565
-                        $file_url = $file_url_base . $chunk_file_name;
3566
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3565
+                        $file_url = $file_url_base.$chunk_file_name;
3566
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3567 3567
                     }
3568 3568
                     
3569
-                    if ( !empty($chunk_file_paths) ) {
3569
+                    if (!empty($chunk_file_paths)) {
3570 3570
                         $json['total'] = $terms_count;
3571 3571
                         $json['files'] = $chunk_file_paths;
3572 3572
                     } else {
3573
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3573
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3574 3574
                     }
3575 3575
                 }
3576 3576
                 // WPML
@@ -3578,127 +3578,127 @@  discard block
 block discarded – undo
3578 3578
                     $sitepress->switch_lang($active_lang, true);
3579 3579
                 }
3580 3580
                 // WPML
3581
-                wp_send_json( $json );
3581
+                wp_send_json($json);
3582 3582
             }
3583 3583
         }
3584 3584
         break;
3585 3585
         case 'export_locations': {
3586
-            $file_url_base = geodir_path_import_export() . '/';
3587
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3588
-            $file_url = $file_url_base . $file_name . '.csv';
3589
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3590
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3586
+            $file_url_base = geodir_path_import_export().'/';
3587
+            $file_name = 'gd_locations_'.date('dmyHi');
3588
+            $file_url = $file_url_base.$file_name.'.csv';
3589
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3590
+            $file_path_temp = $csv_file_dir.'/gd_locations_'.$nonce.'.csv';
3591 3591
             
3592
-            $items_count = (int)geodir_location_imex_count_locations();
3592
+            $items_count = (int) geodir_location_imex_count_locations();
3593 3593
             
3594
-            if ( isset( $_REQUEST['_st'] ) ) {
3595
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3596
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3597
-                $percentage = min( $percentage, 100 );
3594
+            if (isset($_REQUEST['_st'])) {
3595
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3596
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3597
+                $percentage = min($percentage, 100);
3598 3598
                 
3599 3599
                 $json['percentage'] = $percentage;
3600
-                wp_send_json( $json );
3600
+                wp_send_json($json);
3601 3601
             } else {
3602 3602
                 $chunk_file_paths = array();
3603 3603
                 
3604
-                if ( !$items_count > 0 ) {
3605
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3604
+                if (!$items_count > 0) {
3605
+                    $json['error'] = __('No records to export.', 'geodirectory');
3606 3606
                 } else {
3607
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3608
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3607
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3608
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3609 3609
                     
3610 3610
                     $j = $chunk_page_no;
3611
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3611
+                    $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j);
3612 3612
                     
3613 3613
                     $per_page = 500;
3614
-                    $per_page = min( $per_page, $chunk_per_page );
3615
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3614
+                    $per_page = min($per_page, $chunk_per_page);
3615
+                    $total_pages = ceil($chunk_per_page / $per_page);
3616 3616
                     
3617
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3618
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3617
+                    for ($i = 0; $i <= $total_pages; $i++) {
3618
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3619 3619
                         
3620 3620
                         $clear = $i == 0 ? true : false;
3621
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3621
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3622 3622
                     }
3623 3623
                     
3624
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3625
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3626
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3627
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3628
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3624
+                    if ($wp_filesystem->exists($file_path_temp)) {
3625
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3626
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3627
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3628
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3629 3629
                         
3630
-                        $file_url = $file_url_base . $chunk_file_name;
3631
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3630
+                        $file_url = $file_url_base.$chunk_file_name;
3631
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3632 3632
                     }
3633 3633
                     
3634
-                    if ( !empty($chunk_file_paths) ) {
3634
+                    if (!empty($chunk_file_paths)) {
3635 3635
                         $json['total'] = $items_count;
3636 3636
                         $json['files'] = $chunk_file_paths;
3637 3637
                     } else {
3638
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3638
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3639 3639
                     }
3640 3640
                 }
3641
-                wp_send_json( $json );
3641
+                wp_send_json($json);
3642 3642
             }
3643 3643
         }
3644 3644
         break;
3645 3645
         case 'export_hoods': {
3646
-            $file_url_base = geodir_path_import_export() . '/';
3647
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3648
-            $file_url = $file_url_base . $file_name . '.csv';
3649
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3650
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3646
+            $file_url_base = geodir_path_import_export().'/';
3647
+            $file_name = 'gd_neighbourhoods_'.date('dmyHi');
3648
+            $file_url = $file_url_base.$file_name.'.csv';
3649
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3650
+            $file_path_temp = $csv_file_dir.'/gd_neighbourhoods_'.$nonce.'.csv';
3651 3651
             
3652
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3652
+            $items_count = (int) geodir_location_imex_count_neighbourhoods();
3653 3653
             
3654
-            if ( isset( $_REQUEST['_st'] ) ) {
3655
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3656
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3657
-                $percentage = min( $percentage, 100 );
3654
+            if (isset($_REQUEST['_st'])) {
3655
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3656
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3657
+                $percentage = min($percentage, 100);
3658 3658
                 
3659 3659
                 $json['percentage'] = $percentage;
3660
-                wp_send_json( $json );
3660
+                wp_send_json($json);
3661 3661
             } else {
3662 3662
                 $chunk_file_paths = array();
3663 3663
                 
3664
-                if ( !$items_count > 0 ) {
3665
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3664
+                if (!$items_count > 0) {
3665
+                    $json['error'] = __('No records to export.', 'geodirectory');
3666 3666
                 } else {
3667
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3668
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3667
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3668
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3669 3669
                     
3670 3670
                     $j = $chunk_page_no;
3671
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3671
+                    $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j);
3672 3672
                     
3673 3673
                     $per_page = 500;
3674
-                    $per_page = min( $per_page, $chunk_per_page );
3675
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3674
+                    $per_page = min($per_page, $chunk_per_page);
3675
+                    $total_pages = ceil($chunk_per_page / $per_page);
3676 3676
                     
3677
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3678
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3677
+                    for ($i = 0; $i <= $total_pages; $i++) {
3678
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3679 3679
                         
3680 3680
                         $clear = $i == 0 ? true : false;
3681
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3681
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3682 3682
                     }
3683 3683
                     
3684
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3685
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3686
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3687
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3688
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3684
+                    if ($wp_filesystem->exists($file_path_temp)) {
3685
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3686
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3687
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3688
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3689 3689
                         
3690
-                        $file_url = $file_url_base . $chunk_file_name;
3691
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3690
+                        $file_url = $file_url_base.$chunk_file_name;
3691
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3692 3692
                     }
3693 3693
                     
3694
-                    if ( !empty($chunk_file_paths) ) {
3694
+                    if (!empty($chunk_file_paths)) {
3695 3695
                         $json['total'] = $items_count;
3696 3696
                         $json['files'] = $chunk_file_paths;
3697 3697
                     } else {
3698
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3698
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3699 3699
                     }
3700 3700
                 }
3701
-                wp_send_json( $json );
3701
+                wp_send_json($json);
3702 3702
             }
3703 3703
         }
3704 3704
         break;
@@ -3715,25 +3715,25 @@  discard block
 block discarded – undo
3715 3715
             }
3716 3716
             // WPML
3717 3717
             
3718
-            ini_set( 'auto_detect_line_endings', true );
3718
+            ini_set('auto_detect_line_endings', true);
3719 3719
             
3720 3720
             $uploads = wp_upload_dir();
3721 3721
             $uploads_dir = $uploads['path'];
3722 3722
             $uploads_subdir = $uploads['subdir'];
3723 3723
             
3724
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3725
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3724
+            $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL;
3725
+            $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip';
3726 3726
             
3727
-            $csv_file_arr = explode( '/', $csv_file );
3728
-            $csv_filename = end( $csv_file_arr );
3729
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3727
+            $csv_file_arr = explode('/', $csv_file);
3728
+            $csv_filename = end($csv_file_arr);
3729
+            $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$csv_filename;
3730 3730
             
3731 3731
             $json['file'] = $csv_file;
3732
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3732
+            $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
3733 3733
             $file = array();
3734 3734
 
3735
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3736
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3735
+            if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
3736
+                $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename);
3737 3737
                 
3738 3738
                 if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
3739 3739
                     $json['error'] = NULL;
@@ -3741,9 +3741,9 @@  discard block
 block discarded – undo
3741 3741
                     
3742 3742
                     $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
3743 3743
                     setlocale(LC_ALL, 'en_US.UTF-8');
3744
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
3745
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
3746
-                            if ( !empty( $data ) ) {
3744
+                    if (($handle = fopen($target_path, "r")) !== FALSE) {
3745
+                        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
3746
+                            if (!empty($data)) {
3747 3747
                                 $file[] = $data;
3748 3748
                             }
3749 3749
                         }
@@ -3757,19 +3757,19 @@  discard block
 block discarded – undo
3757 3757
                         $json['error'] = __('No data found in csv file.', 'geodirectory');
3758 3758
                     }
3759 3759
                 } else {
3760
-                    wp_send_json( $json );
3760
+                    wp_send_json($json);
3761 3761
                 }
3762 3762
             } else {
3763
-                wp_send_json( $json );
3763
+                wp_send_json($json);
3764 3764
             }
3765 3765
             
3766
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
3767
-                wp_send_json( $json );
3766
+            if ($task == 'prepare_import' || !empty($json['error'])) {
3767
+                wp_send_json($json);
3768 3768
             }
3769 3769
             
3770 3770
             $total = $json['rows'];
3771
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
3772
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
3771
+            $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1;
3772
+            $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0;
3773 3773
             
3774 3774
             $count = $limit;
3775 3775
             
@@ -3794,13 +3794,13 @@  discard block
 block discarded – undo
3794 3794
             
3795 3795
             $post_types = geodir_get_posttypes();
3796 3796
 
3797
-            if ( $task == 'import_cat' ) {
3797
+            if ($task == 'import_cat') {
3798 3798
                 if (!empty($file)) {
3799 3799
                     $columns = isset($file[0]) ? $file[0] : NULL;
3800 3800
                     
3801 3801
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
3802 3802
                         $json['error'] = CSV_INVAILD_FILE;
3803
-                        wp_send_json( $json );
3803
+                        wp_send_json($json);
3804 3804
                         exit;
3805 3805
                     }
3806 3806
                     
@@ -3811,7 +3811,7 @@  discard block
 block discarded – undo
3811 3811
                         
3812 3812
                         if (isset($file[$index])) {
3813 3813
                             $row = $file[$index];
3814
-                            $row = array_map( 'trim', $row );
3814
+                            $row = array_map('trim', $row);
3815 3815
                             //$row = array_map( 'utf8_encode', $row );
3816 3816
                             
3817 3817
                             $cat_id = '';
@@ -3828,42 +3828,42 @@  discard block
 block discarded – undo
3828 3828
                             $cat_id_original = '';
3829 3829
                             
3830 3830
                             $c = 0;
3831
-                            foreach ($columns as $column ) {
3832
-                                if ( $column == 'cat_id' ) {
3833
-                                    $cat_id = (int)$row[$c];
3834
-                                } else if ( $column == 'cat_name' ) {
3831
+                            foreach ($columns as $column) {
3832
+                                if ($column == 'cat_id') {
3833
+                                    $cat_id = (int) $row[$c];
3834
+                                } else if ($column == 'cat_name') {
3835 3835
                                     $cat_name = $row[$c];
3836
-                                } else if ( $column == 'cat_slug' ) {
3836
+                                } else if ($column == 'cat_slug') {
3837 3837
                                     $cat_slug = $row[$c];
3838
-                                } else if ( $column == 'cat_posttype' ) {
3838
+                                } else if ($column == 'cat_posttype') {
3839 3839
                                     $cat_posttype = $row[$c];
3840
-                                } else if ( $column == 'cat_parent' ) {
3840
+                                } else if ($column == 'cat_parent') {
3841 3841
                                     $cat_parent = trim($row[$c]);
3842
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
3842
+                                } else if ($column == 'cat_schema' && $row[$c] != '') {
3843 3843
                                     $cat_schema = $row[$c];
3844
-                                } else if ( $column == 'cat_description' ) {
3844
+                                } else if ($column == 'cat_description') {
3845 3845
                                     $cat_description = $row[$c];
3846
-                                } else if ( $column == 'cat_top_description' ) {
3846
+                                } else if ($column == 'cat_top_description') {
3847 3847
                                     $cat_top_description = $row[$c];
3848
-                                } else if ( $column == 'cat_image' ) {
3848
+                                } else if ($column == 'cat_image') {
3849 3849
                                     $cat_image = $row[$c];
3850
-                                } else if ( $column == 'cat_icon' ) {
3850
+                                } else if ($column == 'cat_icon') {
3851 3851
                                     $cat_icon = $row[$c];
3852 3852
                                 }
3853 3853
                                 // WPML
3854
-                                if ( $is_wpml ) {
3855
-                                    if ( $column == 'cat_language' ) {
3856
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
3857
-                                    } else if ( $column == 'cat_id_original' ) {
3858
-                                        $cat_id_original = (int)$row[$c];
3854
+                                if ($is_wpml) {
3855
+                                    if ($column == 'cat_language') {
3856
+                                        $cat_language = geodir_strtolower(trim($row[$c]));
3857
+                                    } else if ($column == 'cat_id_original') {
3858
+                                        $cat_id_original = (int) $row[$c];
3859 3859
                                     }
3860 3860
                                 }
3861 3861
                                 // WPML
3862 3862
                                 $c++;
3863 3863
                             }
3864 3864
                             
3865
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
3866
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
3865
+                            if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
3866
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
3867 3867
                                 
3868 3868
                                 $invalid++;
3869 3869
                                 continue;
@@ -3881,24 +3881,24 @@  discard block
 block discarded – undo
3881 3881
                             $term_data['description'] = $cat_description;
3882 3882
                             $term_data['cat_schema'] = $cat_schema;
3883 3883
                             $term_data['top_description'] = $cat_top_description;
3884
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
3885
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
3884
+                            $term_data['image'] = $cat_image != '' ? basename($cat_image) : '';
3885
+                            $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : '';
3886 3886
                             
3887 3887
                             //$term_data = array_map( 'utf8_encode', $term_data );
3888 3888
                             
3889
-                            $taxonomy = $cat_posttype . 'category';
3889
+                            $taxonomy = $cat_posttype.'category';
3890 3890
                             
3891 3891
                             $term_data['taxonomy'] = $taxonomy;
3892 3892
 
3893 3893
                             $term_parent_id = 0;
3894
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
3894
+                            if ($cat_parent != "" || (int) $cat_parent > 0) {
3895 3895
                                 $term_parent = '';
3896 3896
                                 
3897
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
3897
+                                if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
3898 3898
                                     //
3899
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
3899
+                                } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
3900 3900
                                     //
3901
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
3901
+                                } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
3902 3902
                                     //
3903 3903
                                 } else {
3904 3904
                                     $term_parent_data = array();
@@ -3906,104 +3906,104 @@  discard block
 block discarded – undo
3906 3906
                                     //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
3907 3907
                                     $term_parent_data['taxonomy'] = $taxonomy;
3908 3908
                                     
3909
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
3909
+                                    $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data);
3910 3910
                                 }
3911 3911
                                 
3912
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
3913
-                                    $term_parent_id = (int)$term_parent->term_id;
3912
+                                if (!empty($term_parent) && !is_wp_error($term_parent)) {
3913
+                                    $term_parent_id = (int) $term_parent->term_id;
3914 3914
                                 }
3915 3915
                             }
3916
-                            $term_data['parent'] = (int)$term_parent_id;
3916
+                            $term_data['parent'] = (int) $term_parent_id;
3917 3917
 
3918 3918
                             $term_id = NULL;
3919
-                            if ( $import_choice == 'update' ) {
3920
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3919
+                            if ($import_choice == 'update') {
3920
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
3921 3921
                                     $term_data['term_id'] = $term['term_id'];
3922 3922
                                     
3923
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3923
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
3924 3924
                                         $updated++;
3925 3925
                                     } else {
3926 3926
                                         $invalid++;
3927
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3927
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
3928 3928
                                     }
3929
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3929
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
3930 3930
                                     $term_data['term_id'] = $term['term_id'];
3931 3931
                                     
3932
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3932
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
3933 3933
                                         $updated++;
3934 3934
                                     } else {
3935 3935
                                         $invalid++;
3936
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3936
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
3937 3937
                                     }
3938 3938
                                 } else {
3939
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3939
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
3940 3940
                                         $created++;
3941 3941
                                     } else {
3942 3942
                                         $invalid++;
3943
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3943
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
3944 3944
                                     }
3945 3945
                                 }
3946
-                            } else if ( $import_choice == 'skip' ) {
3947
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3946
+                            } else if ($import_choice == 'skip') {
3947
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
3948 3948
                                     $skipped++;
3949
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3949
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
3950 3950
                                     $skipped++;
3951 3951
                                 } else {
3952
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3952
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
3953 3953
                                         $created++;
3954 3954
                                     } else {
3955 3955
                                         $invalid++;
3956
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3956
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
3957 3957
                                     }
3958 3958
                                 }
3959 3959
                             } else {
3960 3960
                                 $invalid++;
3961
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3961
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
3962 3962
                             }
3963 3963
                             
3964
-                            if ( $term_id ) {
3964
+                            if ($term_id) {
3965 3965
                                 // WPML
3966 3966
                                 if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
3967
-                                    $wpml_element_type = 'tax_' . $taxonomy;
3968
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
3967
+                                    $wpml_element_type = 'tax_'.$taxonomy;
3968
+                                    $source_language = geodir_get_language_for_element($cat_id_original, $wpml_element_type);
3969 3969
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
3970 3970
 
3971
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
3971
+                                    $trid = $sitepress->get_element_trid($cat_id_original, $wpml_element_type);
3972 3972
                                     
3973
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
3973
+                                    $sitepress->set_element_language_details($term_id, $wpml_element_type, $trid, $cat_language, $source_language);
3974 3974
                                 }
3975 3975
                                 // WPML
3976 3976
                                 
3977
-                                if ( isset( $term_data['top_description'] ) ) {
3978
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
3977
+                                if (isset($term_data['top_description'])) {
3978
+                                    update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype);
3979 3979
                                 }
3980 3980
                                 
3981
-                                if ( isset( $term_data['cat_schema'] ) ) {
3982
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
3981
+                                if (isset($term_data['cat_schema'])) {
3982
+                                    update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype);
3983 3983
                                 }
3984 3984
             
3985 3985
                                 $attachment = false;
3986
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
3987
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
3988
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
3986
+                                if (isset($term_data['image']) && $term_data['image'] != '') {
3987
+                                    $cat_image = geodir_get_default_catimage($term_id, $cat_posttype);
3988
+                                    $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : '';
3989 3989
                                     
3990
-                                    if ( basename($cat_image) != $term_data['image'] ) {
3990
+                                    if (basename($cat_image) != $term_data['image']) {
3991 3991
                                         $attachment = true;
3992
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
3992
+                                        update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'].'/'.$term_data['image']), $cat_posttype);
3993 3993
                                     }
3994 3994
                                 }
3995 3995
                                 
3996
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
3997
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
3998
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
3996
+                                if (isset($term_data['icon']) && $term_data['icon'] != '') {
3997
+                                    $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype);
3998
+                                    $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
3999 3999
 
4000
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4000
+                                    if (basename($cat_icon) != $term_data['icon']) {
4001 4001
                                         $attachment = true;
4002
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4002
+                                        update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'].'/'.$term_data['icon']), $cat_posttype);
4003 4003
                                     }
4004 4004
                                 }
4005 4005
                                 
4006
-                                if ( $attachment ) {
4006
+                                if ($attachment) {
4007 4007
                                     $images++;
4008 4008
                                 }
4009 4009
                             }
@@ -4025,35 +4025,35 @@  discard block
 block discarded – undo
4025 4025
                 $json['invalid'] = $invalid;
4026 4026
                 $json['images'] = $images;
4027 4027
                 
4028
-                wp_send_json( $json );
4028
+                wp_send_json($json);
4029 4029
                 exit;
4030
-            } else if ( $task == 'import_post' ) {
4031
-                $xtimings['###1'] = microtime(true)-$xstart;
4030
+            } else if ($task == 'import_post') {
4031
+                $xtimings['###1'] = microtime(true) - $xstart;
4032 4032
                 //run some stuff to make the import quicker
4033
-                wp_defer_term_counting( true );
4034
-                wp_defer_comment_counting( true );
4035
-                $wpdb->query( 'SET autocommit = 0;' );
4033
+                wp_defer_term_counting(true);
4034
+                wp_defer_comment_counting(true);
4035
+                $wpdb->query('SET autocommit = 0;');
4036 4036
 //
4037 4037
 //                remove_all_actions('publish_post');
4038 4038
 //                remove_all_actions('transition_post_status');
4039 4039
 //                remove_all_actions('publish_future_post');
4040 4040
 
4041 4041
                 if (!empty($file)) {
4042
-                    $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4042
+                    $is_claim_active = is_plugin_active('geodir_claim_listing/geodir_claim_listing.php') && get_option('geodir_claim_enable') === 'yes' ? true : false;
4043 4043
                     $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4044 4044
                     $default_status = 'publish';
4045
-                    $current_date = date_i18n( 'Y-m-d', time() );
4045
+                    $current_date = date_i18n('Y-m-d', time());
4046 4046
                     
4047 4047
                     $columns = isset($file[0]) ? $file[0] : NULL;
4048 4048
                     
4049 4049
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4050 4050
                         $json['error'] = CSV_INVAILD_FILE;
4051
-                        wp_send_json( $json );
4051
+                        wp_send_json($json);
4052 4052
                         exit;
4053 4053
                     }
4054
-                    $xtimings['###2'] = microtime(true)-$xstart;
4054
+                    $xtimings['###2'] = microtime(true) - $xstart;
4055 4055
                     $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4056
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4056
+                    $wp_chars_error = __('(check & remove if any invalid characters used in data)', 'geodirectory');
4057 4057
                     $processed_actual = 0;
4058 4058
                     for ($i = 1; $i <= $limit; $i++) {
4059 4059
                         $index = $processed + $i;
@@ -4062,9 +4062,9 @@  discard block
 block discarded – undo
4062 4062
                         if (isset($file[$index])) {
4063 4063
                             $processed_actual++;
4064 4064
                             $row = $file[$index];
4065
-                            $row = array_map( 'trim', $row );
4065
+                            $row = array_map('trim', $row);
4066 4066
                             //$row = array_map( 'utf8_encode', $row );
4067
-                            $row = array_map( 'addslashes_gpc', $row );
4067
+                            $row = array_map('addslashes_gpc', $row);
4068 4068
                             
4069 4069
                             $post_id = '';
4070 4070
                             $post_title = '';
@@ -4102,80 +4102,80 @@  discard block
 block discarded – undo
4102 4102
                             $original_post_id = '';
4103 4103
                             
4104 4104
                             $c = 0;
4105
-                            foreach ($columns as $column ) {
4105
+                            foreach ($columns as $column) {
4106 4106
                                 $gd_post[$column] = $row[$c];
4107 4107
                                 
4108
-                                if ( $column == 'post_id' ) {
4108
+                                if ($column == 'post_id') {
4109 4109
                                     $post_id = $row[$c];
4110
-                                } else if ( $column == 'post_title' ) {
4110
+                                } else if ($column == 'post_title') {
4111 4111
                                     $post_title = sanitize_text_field($row[$c]);
4112
-                                } else if ( $column == 'post_author' ) {
4112
+                                } else if ($column == 'post_author') {
4113 4113
                                     $post_author = $row[$c];
4114
-                                } else if ( $column == 'post_date' ) {
4114
+                                } else if ($column == 'post_date') {
4115 4115
                                     $post_date = $row[$c];
4116
-                                } else if ( $column == 'post_content' ) {
4116
+                                } else if ($column == 'post_content') {
4117 4117
                                     $post_content = $row[$c];
4118
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4119
-                                    $post_category_arr = explode( ',', $row[$c] );
4120
-                                } else if ( $column == 'default_category' ) {
4118
+                                } else if ($column == 'post_category' && $row[$c] != '') {
4119
+                                    $post_category_arr = explode(',', $row[$c]);
4120
+                                } else if ($column == 'default_category') {
4121 4121
                                     $default_category = wp_kses_normalize_entities($row[$c]);
4122
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4123
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4124
-                                } else if ( $column == 'post_type' ) {
4122
+                                } else if ($column == 'post_tags' && $row[$c] != '') {
4123
+                                    $post_tags = explode(',', sanitize_text_field($row[$c]));
4124
+                                } else if ($column == 'post_type') {
4125 4125
                                     $post_type = $row[$c];
4126
-                                } else if ( $column == 'post_status' ) {
4127
-                                    $post_status = sanitize_key( $row[$c] );
4128
-                                } else if ( $column == 'is_featured' ) {
4129
-                                    $is_featured = (int)$row[$c];
4130
-                                } else if ( $column == 'geodir_video' ) {
4126
+                                } else if ($column == 'post_status') {
4127
+                                    $post_status = sanitize_key($row[$c]);
4128
+                                } else if ($column == 'is_featured') {
4129
+                                    $is_featured = (int) $row[$c];
4130
+                                } else if ($column == 'geodir_video') {
4131 4131
                                     $geodir_video = $row[$c];
4132
-                                } else if ( $column == 'post_address' ) {
4132
+                                } else if ($column == 'post_address') {
4133 4133
                                     $post_address = sanitize_text_field($row[$c]);
4134
-                                } else if ( $column == 'post_city' ) {
4134
+                                } else if ($column == 'post_city') {
4135 4135
                                     $post_city = sanitize_text_field($row[$c]);
4136
-                                } else if ( $column == 'post_region' ) {
4136
+                                } else if ($column == 'post_region') {
4137 4137
                                     $post_region = sanitize_text_field($row[$c]);
4138
-                                } else if ( $column == 'post_country' ) {
4138
+                                } else if ($column == 'post_country') {
4139 4139
                                     $post_country = sanitize_text_field($row[$c]);
4140
-                                } else if ( $column == 'post_zip' ) {
4140
+                                } else if ($column == 'post_zip') {
4141 4141
                                     $post_zip = sanitize_text_field($row[$c]);
4142
-                                } else if ( $column == 'post_latitude' ) {
4142
+                                } else if ($column == 'post_latitude') {
4143 4143
                                     $post_latitude = sanitize_text_field($row[$c]);
4144
-                                } else if ( $column == 'post_longitude' ) {
4144
+                                } else if ($column == 'post_longitude') {
4145 4145
                                     $post_longitude = sanitize_text_field($row[$c]);
4146
-                                } else if ( $column == 'post_neighbourhood' ) {
4146
+                                } else if ($column == 'post_neighbourhood') {
4147 4147
                                     $post_neighbourhood = sanitize_text_field($row[$c]);
4148 4148
                                     unset($gd_post[$column]);
4149
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4149
+                                } else if ($column == 'neighbourhood_latitude') {
4150 4150
                                     $neighbourhood_latitude = sanitize_text_field($row[$c]);
4151
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4151
+                                } else if ($column == 'neighbourhood_longitude') {
4152 4152
                                     $neighbourhood_longitude = sanitize_text_field($row[$c]);
4153
-                                } else if ( $column == 'geodir_timing' ) {
4153
+                                } else if ($column == 'geodir_timing') {
4154 4154
                                     $geodir_timing = sanitize_text_field($row[$c]);
4155
-                                } else if ( $column == 'geodir_contact' ) {
4155
+                                } else if ($column == 'geodir_contact') {
4156 4156
                                     $geodir_contact = sanitize_text_field($row[$c]);
4157
-                                } else if ( $column == 'geodir_email' ) {
4157
+                                } else if ($column == 'geodir_email') {
4158 4158
                                     $geodir_email = sanitize_email($row[$c]);
4159
-                                } else if ( $column == 'geodir_website' ) {
4159
+                                } else if ($column == 'geodir_website') {
4160 4160
                                     $geodir_website = sanitize_text_field($row[$c]);
4161
-                                } else if ( $column == 'geodir_twitter' ) {
4161
+                                } else if ($column == 'geodir_twitter') {
4162 4162
                                     $geodir_twitter = sanitize_text_field($row[$c]);
4163
-                                } else if ( $column == 'geodir_facebook' ) {
4163
+                                } else if ($column == 'geodir_facebook') {
4164 4164
                                     $geodir_facebook = sanitize_text_field($row[$c]);
4165
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4165
+                                } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
4166 4166
                                     $post_images[] = $row[$c];
4167
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4168
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4169
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4167
+                                } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
4168
+                                    $expire_date = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $row[$c].' days'));
4169
+                                } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
4170 4170
                                     $row[$c] = str_replace('/', '-', $row[$c]);
4171
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4171
+                                    $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
4172 4172
                                 }
4173 4173
                                 // WPML
4174 4174
                                 if ($is_wpml) {
4175 4175
                                     if ($column == 'language') {
4176 4176
                                         $language = geodir_strtolower(trim($row[$c]));
4177 4177
                                     } else if ($column == 'original_post_id') {
4178
-                                        $original_post_id = (int)$row[$c];
4178
+                                        $original_post_id = (int) $row[$c];
4179 4179
                                     }
4180 4180
                                 }
4181 4181
                                 // WPML
@@ -4183,7 +4183,7 @@  discard block
 block discarded – undo
4183 4183
                             }
4184 4184
                             // listing claimed or not
4185 4185
                             if ($is_claim_active && isset($gd_post['claimed'])) {
4186
-                                $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4186
+                                $gd_post['claimed'] = (int) $gd_post['claimed'] == 1 ? 1 : 0;
4187 4187
                             }
4188 4188
                             
4189 4189
                             // WPML
@@ -4194,43 +4194,43 @@  discard block
 block discarded – undo
4194 4194
 
4195 4195
                             $gd_post['IMAGE'] = $post_images;
4196 4196
                             
4197
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4198
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4197
+                            $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
4198
+                            $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
4199 4199
                                                                                                                 
4200 4200
                             $valid = true;
4201 4201
                             
4202
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4202
+                            if ($post_title == '' || !in_array($post_type, $post_types)) {
4203 4203
                                 $invalid++;
4204 4204
                                 $valid = false;
4205
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4205
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4206 4206
                             }
4207
-                            $xtimings['###3'] = microtime(true)-$xstart;
4208
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4209
-                            if ( $location_allowed ) {
4207
+                            $xtimings['###3'] = microtime(true) - $xstart;
4208
+                            $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
4209
+                            if ($location_allowed) {
4210 4210
                                 $location_result = geodir_get_default_location();
4211
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4211
+                                if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
4212 4212
                                     $invalid_addr++;
4213 4213
                                     $valid = false;
4214
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4215
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4216
-                                    if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4214
+                                    geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'));
4215
+                                } else if (!empty($location_result) && $location_result->location_id == 0) {
4216
+                                    if ((geodir_strtolower($post_city) != geodir_strtolower($location_result->city)) || (geodir_strtolower($post_region) != geodir_strtolower($location_result->region)) || (geodir_strtolower($post_country) != geodir_strtolower($location_result->country))) {
4217 4217
                                         $invalid_addr++;
4218 4218
                                         $valid = false;
4219
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4219
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'));
4220 4220
                                     } else {
4221 4221
                                         if (!$location_manager) {
4222
-                                            $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4222
+                                            $gd_post['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // Set the default location when location manager not activated.
4223 4223
                                         }
4224 4224
                                     }
4225 4225
                                 }
4226 4226
                             }
4227
-                            $xtimings['###4']   = microtime(true)-$xstart;
4228
-                            if ( !$valid ) {
4227
+                            $xtimings['###4'] = microtime(true) - $xstart;
4228
+                            if (!$valid) {
4229 4229
                                 continue;
4230 4230
                             }
4231 4231
 
4232
-                            $cat_taxonomy = $post_type . 'category';
4233
-                            $tags_taxonomy = $post_type . '_tags';
4232
+                            $cat_taxonomy = $post_type.'category';
4233
+                            $tags_taxonomy = $post_type.'_tags';
4234 4234
                             
4235 4235
                             if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4236 4236
                                 $post_category_arr = array_merge(array($default_category), $post_category_arr);
@@ -4238,29 +4238,29 @@  discard block
 block discarded – undo
4238 4238
 
4239 4239
                             $post_category = array();
4240 4240
                             $default_category_id = NULL;
4241
-                            if ( !empty( $post_category_arr ) ) {
4242
-                                foreach ( $post_category_arr as $value ) {
4243
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4241
+                            if (!empty($post_category_arr)) {
4242
+                                foreach ($post_category_arr as $value) {
4243
+                                    $category_name = wp_kses_normalize_entities(trim($value));
4244 4244
                                     
4245
-                                    if ( $category_name != '' ) {
4245
+                                    if ($category_name != '') {
4246 4246
                                         $term_category = array();
4247 4247
                                         
4248
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4248
+                                        if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
4249 4249
                                             $term_category = $term;
4250
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4250
+                                        } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
4251 4251
                                             $term_category = $term;
4252 4252
                                         } else {
4253 4253
                                             $term_data = array();
4254 4254
                                             $term_data['name'] = $category_name;
4255 4255
                                             $term_data['taxonomy'] = $cat_taxonomy;
4256 4256
                                             
4257
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4258
-                                            if ( $term_id ) {
4259
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4257
+                                            $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data);
4258
+                                            if ($term_id) {
4259
+                                                $term_category = get_term($term_id, $cat_taxonomy);
4260 4260
                                             }
4261 4261
                                         }
4262 4262
                                         
4263
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4263
+                                        if (!empty($term_category) && !is_wp_error($term_category)) {
4264 4264
                                             $post_category[] = intval($term_category->term_id);
4265 4265
                                             
4266 4266
                                             if ($category_name == $default_category) {
@@ -4270,14 +4270,14 @@  discard block
 block discarded – undo
4270 4270
                                     }
4271 4271
                                 }
4272 4272
                             }
4273
-                            $xtimings['###5'] = microtime(true)-$xstart;
4273
+                            $xtimings['###5'] = microtime(true) - $xstart;
4274 4274
                             $save_post = array();
4275 4275
                             $save_post['post_title'] = $post_title;
4276 4276
                             if (!empty($post_date)) {
4277
-                                $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format.
4277
+                                $post_date = geodir_date($post_date, 'Y-m-d H:i:s'); // convert to mysql date format.
4278 4278
                                 
4279 4279
                                 $save_post['post_date'] = $post_date;
4280
-                                $save_post['post_date_gmt'] = get_gmt_from_date( $post_date );
4280
+                                $save_post['post_date_gmt'] = get_gmt_from_date($post_date);
4281 4281
                             }
4282 4282
                             $save_post['post_content'] = $post_content;
4283 4283
                             $save_post['post_type'] = $post_type;
@@ -4287,15 +4287,15 @@  discard block
 block discarded – undo
4287 4287
                             $save_post['post_tags'] = $post_tags;
4288 4288
 
4289 4289
                             $saved_post_id = NULL;
4290
-                            if ( $import_choice == 'update' ) {
4291
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4290
+                            if ($import_choice == 'update') {
4291
+                                $gd_wp_error = __('Unable to add listing, please check the listing data.', 'geodirectory');
4292 4292
                                 
4293
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4293
+                                if ($post_id > 0 && get_post($post_id)) {
4294 4294
                                     $save_post['ID'] = $post_id;
4295 4295
                                     
4296
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4297
-                                        if ( is_wp_error( $saved_post_id ) ) {
4298
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4296
+                                    if ($saved_post_id = wp_update_post($save_post, true)) {
4297
+                                        if (is_wp_error($saved_post_id)) {
4298
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4299 4299
                                             $saved_post_id = 0;
4300 4300
                                         } else {
4301 4301
                                             $saved_post_id = $post_id;
@@ -4303,9 +4303,9 @@  discard block
 block discarded – undo
4303 4303
                                         }
4304 4304
                                     }
4305 4305
                                 } else {
4306
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4307
-                                        if ( is_wp_error( $saved_post_id ) ) {
4308
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4306
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4307
+                                        if (is_wp_error($saved_post_id)) {
4308
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4309 4309
                                             $saved_post_id = 0;
4310 4310
                                         } else {
4311 4311
                                             $created++;
@@ -4313,19 +4313,19 @@  discard block
 block discarded – undo
4313 4313
                                     }
4314 4314
                                 }
4315 4315
                                 
4316
-                                if ( !$saved_post_id > 0 ) {
4316
+                                if (!$saved_post_id > 0) {
4317 4317
                                     $invalid++;
4318
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4318
+                                    geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_wp_error);
4319 4319
                                 }
4320
-                            } else if ( $import_choice == 'skip' ) {
4321
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4320
+                            } else if ($import_choice == 'skip') {
4321
+                                if ($post_id > 0 && get_post($post_id)) {
4322 4322
                                     $skipped++;	
4323 4323
                                 } else {
4324
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4325
-                                        if ( is_wp_error( $saved_post_id ) ) {
4324
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4325
+                                        if (is_wp_error($saved_post_id)) {
4326 4326
                                             $invalid++;
4327 4327
                                             
4328
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4328
+                                            geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$saved_post_id->get_error_message().' '.$wp_chars_error);
4329 4329
                                             $saved_post_id = 0;
4330 4330
                                         } else {
4331 4331
                                             $created++;
@@ -4333,28 +4333,28 @@  discard block
 block discarded – undo
4333 4333
                                     } else {
4334 4334
                                         $invalid++;
4335 4335
                                         
4336
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4336
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4337 4337
                                     }
4338 4338
                                 }
4339 4339
                             } else {
4340 4340
                                 $invalid++;
4341 4341
                                 
4342
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4342
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4343 4343
                             }
4344
-                            $xtimings['###6'] = microtime(true)-$xstart;
4345
-                            if ( (int)$saved_post_id > 0 ) {
4344
+                            $xtimings['###6'] = microtime(true) - $xstart;
4345
+                            if ((int) $saved_post_id > 0) {
4346 4346
                                 // WPML
4347 4347
                                 if ($is_wpml && $original_post_id > 0 && $language != '') {
4348
-                                    $wpml_post_type = 'post_' . $post_type;
4349
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4348
+                                    $wpml_post_type = 'post_'.$post_type;
4349
+                                    $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type);
4350 4350
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4351 4351
 
4352
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4352
+                                    $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type);
4353 4353
                                     
4354
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4354
+                                    $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language);
4355 4355
                                 }
4356 4356
                                 // WPML
4357
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4357
+                                $gd_post_info = geodir_get_post_info($saved_post_id);
4358 4358
                                 
4359 4359
                                 $gd_post['post_id'] = $saved_post_id;
4360 4360
                                 $gd_post['ID'] = $saved_post_id;
@@ -4366,7 +4366,7 @@  discard block
 block discarded – undo
4366 4366
                                                     
4367 4367
                                 // post location
4368 4368
                                 $post_location_id = 0;
4369
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4369
+                                if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
4370 4370
                                     $gd_post['post_neighbourhood'] = '';
4371 4371
                                     
4372 4372
                                     $post_location_info = array(
@@ -4376,7 +4376,7 @@  discard block
 block discarded – undo
4376 4376
                                                                 'geo_lat' => $post_latitude,
4377 4377
                                                                 'geo_lng' => $post_longitude
4378 4378
                                                             );
4379
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4379
+                                    if ($location_id = (int) geodir_add_new_location($post_location_info)) {
4380 4380
                                         $post_location_id = $location_id;
4381 4381
                                     }
4382 4382
                                     
@@ -4414,14 +4414,14 @@  discard block
 block discarded – undo
4414 4414
                                 $gd_post['post_location_id'] = $post_location_id;
4415 4415
                                 
4416 4416
                                 // post package info
4417
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4417
+                                $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0;
4418 4418
                                 if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4419 4419
                                     $package_id = $gd_post_info->package_id;
4420 4420
                                 }
4421 4421
                                 
4422 4422
                                 $package_info = array();
4423 4423
                                 if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4424
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4424
+                                    $package_info = (array) geodir_get_package_info_by_id($package_id);
4425 4425
                                     
4426 4426
                                     if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4427 4427
                                         $package_info = array();
@@ -4429,18 +4429,18 @@  discard block
 block discarded – undo
4429 4429
                                 }
4430 4430
                                 
4431 4431
                                 if (empty($package_info)) {
4432
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4432
+                                    $package_info = (array) geodir_post_package_info(array(), '', $post_type);
4433 4433
                                 }
4434 4434
                                  
4435
-                                if (!empty($package_info))	 {
4435
+                                if (!empty($package_info)) {
4436 4436
                                     $package_id = $package_info['pid'];
4437 4437
                                     
4438 4438
                                     if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4439 4439
                                         $gd_post['expire_date'] = $expire_date;
4440 4440
                                     } else {
4441
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4442
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4443
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4441
+                                        if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
4442
+                                            $gd_post['alive_days'] = (int) $package_info['days'];
4443
+                                            $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $package_info['days'].' days'));
4444 4444
                                         } else {
4445 4445
                                             $gd_post['expire_date'] = 'Never';
4446 4446
                                         }
@@ -4449,7 +4449,7 @@  discard block
 block discarded – undo
4449 4449
                                     $gd_post['package_id'] = $package_id;
4450 4450
                                 }
4451 4451
 
4452
-                                $table = $plugin_prefix . $post_type . '_detail';
4452
+                                $table = $plugin_prefix.$post_type.'_detail';
4453 4453
                                 
4454 4454
                                 if ($post_type == 'gd_event') {
4455 4455
                                     $gd_post = geodir_imex_process_event_data($gd_post);
@@ -4460,65 +4460,65 @@  discard block
 block discarded – undo
4460 4460
                                 }
4461 4461
 
4462 4462
                                 // Export franchise fields
4463
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4463
+                                $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
4464 4464
                                 if ($is_franchise_active) {
4465
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4465
+                                    if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
4466 4466
                                         $gd_franchise_lock = array();
4467 4467
                                         
4468
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4469
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4470
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4471
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4468
+                                        if (isset($gd_post['gd_franchise_lock'])) {
4469
+                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
4470
+                                            $gd_franchise_lock = trim($gd_franchise_lock);
4471
+                                            $gd_franchise_lock = explode(",", $gd_franchise_lock);
4472 4472
                                         }
4473 4473
                                         
4474
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4475
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4474
+                                        update_post_meta($saved_post_id, 'gd_is_franchise', 1);
4475
+                                        update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock);
4476 4476
                                     } else {
4477
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4478
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4477
+                                        if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
4478
+                                            geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']);
4479 4479
                                         }
4480 4480
                                     }
4481 4481
                                 }
4482 4482
                                 
4483 4483
                                 if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4484
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4484
+                                    $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
4485 4485
                                     if ($default_category_id) {
4486 4486
                                         $save_post['post_default_category'] = $default_category_id;
4487 4487
                                         $gd_post['default_category'] = $default_category_id;
4488 4488
                                     }
4489 4489
                                     $gd_post[$cat_taxonomy] = $save_post['post_category'];
4490 4490
                                 }
4491
-                                $xtimings['###7'] = microtime(true)-$xstart;
4491
+                                $xtimings['###7'] = microtime(true) - $xstart;
4492 4492
                                 // Save post info
4493
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4494
-                                $xtimings['###8'] = microtime(true)-$xstart;
4493
+                                geodir_save_post_info($saved_post_id, $gd_post);
4494
+                                $xtimings['###8'] = microtime(true) - $xstart;
4495 4495
                                 // post taxonomies
4496
-                                if ( !empty( $save_post['post_category'] ) ) {
4497
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4496
+                                if (!empty($save_post['post_category'])) {
4497
+                                    wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy);
4498 4498
                                     
4499
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4499
+                                    $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : '';
4500 4500
                                     if ($default_category_id) {
4501 4501
                                         $post_default_category = $default_category_id;
4502 4502
                                     }
4503 4503
                                     $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4504 4504
                                     $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4505
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4505
+                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']).',y:' : '';
4506 4506
                                     
4507 4507
                                     if ($post_category_str != '' && $post_default_category) {
4508
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4508
+                                        $post_category_str = str_replace($post_default_category.',y:', $post_default_category.',y,d:', $post_category_str);
4509 4509
                                     }
4510 4510
                                     
4511 4511
                                     $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4512 4512
                                     
4513
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4513
+                                    geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str);
4514 4514
                                 }
4515
-                                $xtimings['###8.1'] = microtime(true)-$xstart;
4516
-                                if ( !empty( $save_post['post_tags'] ) ) {
4517
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4515
+                                $xtimings['###8.1'] = microtime(true) - $xstart;
4516
+                                if (!empty($save_post['post_tags'])) {
4517
+                                    wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy);
4518 4518
                                 }
4519
-                                $xtimings['###9'] = microtime(true)-$xstart;
4519
+                                $xtimings['###9'] = microtime(true) - $xstart;
4520 4520
                                 // Post images
4521
-                                if ( !empty( $post_images ) ) {
4521
+                                if (!empty($post_images)) {
4522 4522
                                     $post_images = array_unique($post_images);
4523 4523
                                     
4524 4524
                                     $old_post_images_arr = array();
@@ -4526,65 +4526,65 @@  discard block
 block discarded – undo
4526 4526
                                     
4527 4527
                                     $order = 1;
4528 4528
                                     
4529
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4530
-                                    $xtimings['###9.1'] = microtime(true)-$xstart;
4529
+                                    $old_post_images = geodir_get_images($saved_post_id);
4530
+                                    $xtimings['###9.1'] = microtime(true) - $xstart;
4531 4531
                                     if (!empty($old_post_images)) {
4532
-                                        foreach( $old_post_images as $old_post_image ) {
4532
+                                        foreach ($old_post_images as $old_post_image) {
4533 4533
                                             if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4534 4534
                                                 $old_post_images_arr[] = $old_post_image->file;
4535 4535
                                             }
4536 4536
                                         }
4537 4537
                                     }
4538 4538
 
4539
-                                    foreach ( $post_images as $post_image ) {
4540
-                                        $image_name = basename( $post_image );
4539
+                                    foreach ($post_images as $post_image) {
4540
+                                        $image_name = basename($post_image);
4541 4541
                                         $saved_post_images_arr[] = $image_name;
4542 4542
                                         
4543
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4543
+                                        if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
4544 4544
                                             continue; // Skip if image already exists.
4545 4545
                                         }
4546 4546
                                         
4547
-                                        $image_name_parts = explode( '.', $image_name );
4548
-                                        array_pop( $image_name_parts );
4549
-                                        $proper_image_name = implode( '.', $image_name_parts );
4550
-                                        $xtimings['###9.2'] = microtime(true)-$xstart;
4551
-                                        $arr_file_type = wp_check_filetype( $image_name );
4552
-                                        $xtimings['###9.3'] = microtime(true)-$xstart;
4553
-                                        if ( !empty( $arr_file_type ) ) {
4547
+                                        $image_name_parts = explode('.', $image_name);
4548
+                                        array_pop($image_name_parts);
4549
+                                        $proper_image_name = implode('.', $image_name_parts);
4550
+                                        $xtimings['###9.2'] = microtime(true) - $xstart;
4551
+                                        $arr_file_type = wp_check_filetype($image_name);
4552
+                                        $xtimings['###9.3'] = microtime(true) - $xstart;
4553
+                                        if (!empty($arr_file_type)) {
4554 4554
                                             $uploaded_file_type = $arr_file_type['type'];
4555 4555
                                             
4556 4556
                                             $attachment = array();
4557 4557
                                             $attachment['post_id'] = $saved_post_id;
4558 4558
                                             $attachment['title'] = $proper_image_name;
4559 4559
                                             $attachment['content'] = '';
4560
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4560
+                                            $attachment['file'] = $uploads_subdir.'/'.$image_name;
4561 4561
                                             $attachment['mime_type'] = $uploaded_file_type;
4562 4562
                                             $attachment['menu_order'] = $order;
4563 4563
                                             $attachment['is_featured'] = 0;
4564 4564
 
4565 4565
                                             $attachment_set = '';
4566
-                                            foreach ( $attachment as $key => $val ) {
4567
-                                                if ( $val != '' ) {
4568
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4566
+                                            foreach ($attachment as $key => $val) {
4567
+                                                if ($val != '') {
4568
+                                                    $attachment_set .= $key." = '".$val."', ";
4569 4569
                                                 }
4570 4570
                                             }
4571
-                                            $attachment_set = trim( $attachment_set, ", " );
4571
+                                            $attachment_set = trim($attachment_set, ", ");
4572 4572
                                                                                         
4573 4573
                                             // Add new attachment
4574
-                                            $xtimings['###9.4'] = microtime(true)-$xstart;
4575
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4576
-                                            $xtimings['###9.5'] = microtime(true)-$xstart;
4574
+                                            $xtimings['###9.4'] = microtime(true) - $xstart;
4575
+                                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
4576
+                                            $xtimings['###9.5'] = microtime(true) - $xstart;
4577 4577
                                             $order++;
4578 4578
                                         }
4579 4579
                                     }
4580 4580
 
4581
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4581
+                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/".implode("' AND file NOT LIKE '%/", $saved_post_images_arr)."' )" : '';
4582 4582
                                     // Remove previous attachment
4583
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4584
-                                    $xtimings['###9.6'] = microtime(true)-$xstart;
4585
-                                    if ( !empty( $saved_post_images_arr ) ) {
4583
+                                    $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = ".(int) $saved_post_id." ".$saved_post_images_sql);
4584
+                                    $xtimings['###9.6'] = microtime(true) - $xstart;
4585
+                                    if (!empty($saved_post_images_arr)) {
4586 4586
                                         geodir_set_wp_featured_image($saved_post_id);
4587
-                                        $xtimings['###9.7'] = microtime(true)-$xstart;
4587
+                                        $xtimings['###9.7'] = microtime(true) - $xstart;
4588 4588
                                         /*
4589 4589
                                         $menu_order = 1;
4590 4590
                                         
@@ -4600,14 +4600,14 @@  discard block
 block discarded – undo
4600 4600
                                         }*/
4601 4601
                                     }
4602 4602
                                     
4603
-                                    if ( $order > 1 ) {
4603
+                                    if ($order > 1) {
4604 4604
                                         $images++;
4605 4605
                                     }
4606 4606
                                 }
4607
-                                $xtimings['###10'] = microtime(true)-$xstart;
4607
+                                $xtimings['###10'] = microtime(true) - $xstart;
4608 4608
                                 /** This action is documented in geodirectory-functions/post-functions.php */
4609
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4610
-                                $xtimings['###11'] = microtime(true)-$xstart;
4609
+                                do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
4610
+                                $xtimings['###11'] = microtime(true) - $xstart;
4611 4611
                                 if (isset($is_featured)) {
4612 4612
                                     geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4613 4613
                                 }
@@ -4617,7 +4617,7 @@  discard block
 block discarded – undo
4617 4617
                                 if (isset($gd_post['expire_date'])) {
4618 4618
                                     geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4619 4619
                                 }
4620
-                                $xtimings['###12'] = microtime(true)-$xstart;
4620
+                                $xtimings['###12'] = microtime(true) - $xstart;
4621 4621
                             }
4622 4622
                             
4623 4623
                             // WPML
@@ -4630,11 +4630,11 @@  discard block
 block discarded – undo
4630 4630
                 }
4631 4631
 
4632 4632
                 //undo some stuff to make the import quicker
4633
-                wp_defer_term_counting( false );
4634
-                wp_defer_comment_counting( false );
4635
-                $wpdb->query( 'COMMIT;' );
4636
-                $wpdb->query( 'SET autocommit = 1;' );
4637
-                $xtimings['###13'] = microtime(true)-$xstart;
4633
+                wp_defer_term_counting(false);
4634
+                wp_defer_comment_counting(false);
4635
+                $wpdb->query('COMMIT;');
4636
+                $wpdb->query('SET autocommit = 1;');
4637
+                $xtimings['###13'] = microtime(true) - $xstart;
4638 4638
                 $json = array();
4639 4639
                 $json['processed'] = $processed_actual;
4640 4640
                 $json['created'] = $created;
@@ -4643,13 +4643,13 @@  discard block
 block discarded – undo
4643 4643
                 $json['invalid'] = $invalid;
4644 4644
                 $json['invalid_addr'] = $invalid_addr;
4645 4645
                 $json['images'] = $images;
4646
-                $json['timing'] = microtime(true)-$xstart;
4646
+                $json['timing'] = microtime(true) - $xstart;
4647 4647
                 $json['timings'] = $xtimings;
4648 4648
                 
4649 4649
 
4650
-                wp_send_json( $json );
4650
+                wp_send_json($json);
4651 4651
                 exit;
4652
-            } else if ( $task == 'import_loc' ) {
4652
+            } else if ($task == 'import_loc') {
4653 4653
                 global $gd_post_types;
4654 4654
                 $gd_post_types = $post_types;
4655 4655
                 
@@ -4658,82 +4658,82 @@  discard block
 block discarded – undo
4658 4658
                     
4659 4659
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4660 4660
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4661
-                        wp_send_json( $json );
4661
+                        wp_send_json($json);
4662 4662
                     }
4663 4663
                     
4664 4664
                     $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4665
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4665
+                    $gd_error_location = __('Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory');
4666 4666
                     for ($i = 1; $i <= $limit; $i++) {
4667 4667
                         $index = $processed + $i;
4668 4668
                         
4669 4669
                         if (isset($file[$index])) {
4670 4670
                             $row = $file[$index];
4671
-                            $row = array_map( 'trim', $row );
4671
+                            $row = array_map('trim', $row);
4672 4672
                             $data = array();
4673 4673
                             
4674
-                            foreach ($columns as $c => $column ) {
4674
+                            foreach ($columns as $c => $column) {
4675 4675
                                 if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
4676 4676
                                     $data[$column] = $row[$c];
4677 4677
                                 }
4678 4678
                             }
4679 4679
 
4680
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4680
+                            if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
4681 4681
                                 $invalid++;
4682
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4682
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4683 4683
                                 continue;
4684 4684
                             }
4685 4685
                             
4686 4686
                             $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4687 4687
                             
4688
-                            if ( $import_choice == 'update' ) {
4689
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4690
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4688
+                            if ($import_choice == 'update') {
4689
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4690
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4691 4691
                                         $updated++;
4692 4692
                                     } else {
4693 4693
                                         $invalid++;
4694
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4694
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4695 4695
                                     }
4696
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4697
-                                    $data['location_id'] = (int)$location->location_id;
4696
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4697
+                                    $data['location_id'] = (int) $location->location_id;
4698 4698
                                     
4699
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4700
-                                        $data['location_id'] = (int)$location->location_id;
4701
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4702
-                                        $data['location_id'] = (int)$location->location_id;
4703
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4704
-                                        $data['location_id'] = (int)$location->location_id;
4699
+                                    if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
4700
+                                        $data['location_id'] = (int) $location->location_id;
4701
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
4702
+                                        $data['location_id'] = (int) $location->location_id;
4703
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
4704
+                                        $data['location_id'] = (int) $location->location_id;
4705 4705
                                     }
4706 4706
                                     
4707
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4707
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4708 4708
                                         $updated++;
4709 4709
                                     } else {
4710 4710
                                         $invalid++;
4711
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4711
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4712 4712
                                     }
4713 4713
                                 } else {
4714
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4714
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4715 4715
                                         $created++;
4716 4716
                                     } else {
4717 4717
                                         $invalid++;
4718
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4718
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4719 4719
                                     }
4720 4720
                                 }
4721
-                            } elseif ( $import_choice == 'skip' ) {
4722
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4721
+                            } elseif ($import_choice == 'skip') {
4722
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4723 4723
                                     $skipped++;
4724
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4724
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4725 4725
                                     $skipped++;
4726 4726
                                 } else {
4727
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4727
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4728 4728
                                         $created++;
4729 4729
                                     } else {
4730 4730
                                         $invalid++;
4731
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4731
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4732 4732
                                     }
4733 4733
                                 }
4734 4734
                             } else {
4735 4735
                                 $invalid++;
4736
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4736
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4737 4737
                             }
4738 4738
                         }
4739 4739
                     }
@@ -4747,24 +4747,24 @@  discard block
 block discarded – undo
4747 4747
                 $json['invalid'] = $invalid;
4748 4748
                 $json['images'] = $images;
4749 4749
                 
4750
-                wp_send_json( $json );
4751
-            } else if ( $task == 'import_hood' ) {               
4750
+                wp_send_json($json);
4751
+            } else if ($task == 'import_hood') {               
4752 4752
                 if (!empty($file)) {
4753 4753
                     $columns = isset($file[0]) ? $file[0] : NULL;
4754 4754
                     
4755 4755
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4756 4756
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4757
-                        wp_send_json( $json );
4757
+                        wp_send_json($json);
4758 4758
                     }
4759 4759
                     
4760 4760
                     $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4761
-                    $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
4761
+                    $gd_error_hood = __('Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory');
4762 4762
                     for ($i = 1; $i <= $limit; $i++) {
4763 4763
                         $index = $processed + $i;
4764 4764
                         
4765 4765
                         if (isset($file[$index])) {
4766 4766
                             $row = $file[$index];
4767
-                            $row = array_map( 'trim', $row );
4767
+                            $row = array_map('trim', $row);
4768 4768
                             $data = array();
4769 4769
                             
4770 4770
                             foreach ($columns as $c => $column) {
@@ -4775,20 +4775,20 @@  discard block
 block discarded – undo
4775 4775
 
4776 4776
                             if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4777 4777
                                 $invalid++;
4778
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4778
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4779 4779
                                 continue;
4780 4780
                             }
4781 4781
                             
4782 4782
                             $location_info = array();
4783
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4784
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4783
+                            if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
4784
+                                $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
4785 4785
                             } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4786 4786
                                 $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4787 4787
                             }
4788 4788
 
4789 4789
                             if (empty($location_info)) {
4790 4790
                                 $invalid++;
4791
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4791
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4792 4792
                                 continue;
4793 4793
                             }
4794 4794
                             
@@ -4803,35 +4803,35 @@  discard block
 block discarded – undo
4803 4803
                             $hood_data['hood_longitude'] = $data['longitude'];
4804 4804
                             $hood_data['hood_location_id'] = $location_id;
4805 4805
                                     
4806
-                            if ( $import_choice == 'update' ) {
4807
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4808
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4806
+                            if ($import_choice == 'update') {
4807
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
4808
+                                    $hood_data['hood_id'] = (int) $data['neighbourhood_id'];
4809 4809
                                     
4810 4810
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4811 4811
                                         $updated++;
4812 4812
                                     } else {
4813 4813
                                         $invalid++;
4814
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4814
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4815 4815
                                     }
4816 4816
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4817
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4817
+                                    $hood_data['hood_id'] = (int) $neighbourhood->hood_id;
4818 4818
                                     
4819 4819
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4820 4820
                                         $updated++;
4821 4821
                                     } else {
4822 4822
                                         $invalid++;
4823
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4823
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4824 4824
                                     }
4825 4825
                                 } else {
4826 4826
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4827 4827
                                         $created++;
4828 4828
                                     } else {
4829 4829
                                         $invalid++;
4830
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4830
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4831 4831
                                     }
4832 4832
                                 }
4833
-                            } elseif ( $import_choice == 'skip' ) {
4834
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4833
+                            } elseif ($import_choice == 'skip') {
4834
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
4835 4835
                                     $skipped++;
4836 4836
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4837 4837
                                     $skipped++;
@@ -4841,12 +4841,12 @@  discard block
 block discarded – undo
4841 4841
                                         $created++;
4842 4842
                                     } else {
4843 4843
                                         $invalid++;
4844
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4844
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4845 4845
                                     }
4846 4846
                                 }
4847 4847
                             } else {
4848 4848
                                 $invalid++;
4849
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4849
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
4850 4850
                             }
4851 4851
                         }
4852 4852
                     }
@@ -4860,7 +4860,7 @@  discard block
 block discarded – undo
4860 4860
                 $json['invalid'] = $invalid;
4861 4861
                 $json['images'] = $images;
4862 4862
                 
4863
-                wp_send_json( $json );
4863
+                wp_send_json($json);
4864 4864
             }
4865 4865
         }
4866 4866
         break;
@@ -4904,29 +4904,29 @@  discard block
 block discarded – undo
4904 4904
  * }
4905 4905
  * @return int|bool Term id when success, false when fail.
4906 4906
  */
4907
-function geodir_imex_insert_term( $taxonomy, $term_data ) {
4908
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
4907
+function geodir_imex_insert_term($taxonomy, $term_data) {
4908
+	if (empty($taxonomy) || empty($term_data)) {
4909 4909
 		return false;
4910 4910
 	}
4911 4911
 	
4912
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
4912
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
4913 4913
 	$args = array();
4914
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
4915
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
4916
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
4914
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
4915
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
4916
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
4917 4917
 	
4918
-	if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
4919
-		$term_args = array_merge( $term_data, $args );
4920
-		$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
4921
-		$term_args = wp_parse_args( $term_args, $defaults );
4922
-		$term_args = sanitize_term( $term_args, $taxonomy, 'db' );
4923
-		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
4918
+	if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
4919
+		$term_args = array_merge($term_data, $args);
4920
+		$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
4921
+		$term_args = wp_parse_args($term_args, $defaults);
4922
+		$term_args = sanitize_term($term_args, $taxonomy, 'db');
4923
+		$args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args);
4924 4924
 	}
4925 4925
 	
4926
-    if( !empty( $term ) ) {
4927
-		$result = wp_insert_term( $term, $taxonomy, $args );
4928
-        if( !is_wp_error( $result ) ) {
4929
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4926
+    if (!empty($term)) {
4927
+		$result = wp_insert_term($term, $taxonomy, $args);
4928
+        if (!is_wp_error($result)) {
4929
+            return isset($result['term_id']) ? $result['term_id'] : 0;
4930 4930
         }
4931 4931
     }
4932 4932
 	
@@ -4956,36 +4956,36 @@  discard block
 block discarded – undo
4956 4956
  * }
4957 4957
  * @return int|bool Term id when success, false when fail.
4958 4958
  */
4959
-function geodir_imex_update_term( $taxonomy, $term_data ) {
4960
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
4959
+function geodir_imex_update_term($taxonomy, $term_data) {
4960
+	if (empty($taxonomy) || empty($term_data)) {
4961 4961
 		return false;
4962 4962
 	}
4963 4963
 	
4964
-	$term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0;
4964
+	$term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0;
4965 4965
 	
4966 4966
 	$args = array();
4967
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
4968
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
4969
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
4967
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
4968
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
4969
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
4970 4970
 	
4971
-	if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
4971
+	if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
4972 4972
 		$term_data['term_id'] = $term_info['term_id'];
4973 4973
 		
4974
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
4974
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
4975 4975
 		
4976
-		if( !is_wp_error( $result ) ) {
4977
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4976
+		if (!is_wp_error($result)) {
4977
+            return isset($result['term_id']) ? $result['term_id'] : 0;
4978 4978
         }
4979
-	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4979
+	} else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
4980 4980
 		$term_data['term_id'] = $term_info['term_id'];
4981 4981
 		
4982
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
4982
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
4983 4983
 		
4984
-		if( !is_wp_error( $result ) ) {
4985
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4984
+		if (!is_wp_error($result)) {
4985
+            return isset($result['term_id']) ? $result['term_id'] : 0;
4986 4986
         }
4987 4987
 	} else {
4988
-		return geodir_imex_insert_term( $taxonomy, $term_data );
4988
+		return geodir_imex_insert_term($taxonomy, $term_data);
4989 4989
 	}
4990 4990
 	
4991 4991
 	return false;
@@ -5004,20 +5004,20 @@  discard block
 block discarded – undo
5004 5004
  * @param string $post_type Post type.
5005 5005
  * @return int Posts count.
5006 5006
  */
5007
-function geodir_get_posts_count( $post_type ) {
5007
+function geodir_get_posts_count($post_type) {
5008 5008
     global $wpdb, $plugin_prefix;
5009 5009
 
5010
-    if ( !post_type_exists( $post_type ) ) {
5010
+    if (!post_type_exists($post_type)) {
5011 5011
         return 0;
5012 5012
     }
5013 5013
         
5014
-    $table = $plugin_prefix . $post_type . '_detail';
5014
+    $table = $plugin_prefix.$post_type.'_detail';
5015 5015
 
5016 5016
     // Skip listing with statuses trash, auto-draft etc...
5017 5017
     $skip_statuses = geodir_imex_export_skip_statuses();
5018 5018
     $where_statuses = '';
5019
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5020
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5019
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5020
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5021 5021
     }
5022 5022
     
5023 5023
     /**
@@ -5028,11 +5028,11 @@  discard block
 block discarded – undo
5028 5028
      *
5029 5029
      * @param string $where SQL where clause part.
5030 5030
      */
5031
-    $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5031
+    $where_statuses = apply_filters('geodir_get_posts_count', $where_statuses, $post_type);
5032 5032
 
5033
-    $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5033
+    $query = $wpdb->prepare("SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ".$where_statuses, $post_type);
5034 5034
 
5035
-    $posts_count = (int)$wpdb->get_var( $query );
5035
+    $posts_count = (int) $wpdb->get_var($query);
5036 5036
     
5037 5037
     /**
5038 5038
      * Modify returned post counts for the current post type.
@@ -5043,7 +5043,7 @@  discard block
 block discarded – undo
5043 5043
      * @param int $posts_count Post counts.
5044 5044
      * @param string $post_type Post type.
5045 5045
      */
5046
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5046
+    $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
5047 5047
 
5048 5048
     return $posts_count;
5049 5049
 }
@@ -5065,19 +5065,19 @@  discard block
 block discarded – undo
5065 5065
  * @param int $page_no Page number. Default 0.
5066 5066
  * @return array Array of posts data.
5067 5067
  */
5068
-function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {	
5068
+function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {	
5069 5069
 	global $wp_filesystem;
5070 5070
 
5071
-	$posts = geodir_get_export_posts( $post_type, $per_page, $page_no );
5071
+	$posts = geodir_get_export_posts($post_type, $per_page, $page_no);
5072 5072
 
5073 5073
 	$csv_rows = array();
5074 5074
 	
5075
-	if ( !empty( $posts ) ) {
5076
-		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5075
+	if (!empty($posts)) {
5076
+		$is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
5077 5077
         $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5078
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5078
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
5079 5079
         $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5080
-        $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
5080
+        $is_claim_active = is_plugin_active('geodir_claim_listing/geodir_claim_listing.php') && get_option('geodir_claim_enable') === 'yes' ? true : false;
5081 5081
 		
5082 5082
 		$csv_row = array();
5083 5083
 		$csv_row[] = 'post_id';
@@ -5088,7 +5088,7 @@  discard block
 block discarded – undo
5088 5088
 		$csv_row[] = 'default_category';
5089 5089
 		$csv_row[] = 'post_tags';
5090 5090
 		$csv_row[] = 'post_type';
5091
-		if ( $post_type == 'gd_event' ) {
5091
+		if ($post_type == 'gd_event') {
5092 5092
 			$csv_row[] = 'event_date';
5093 5093
 			$csv_row[] = 'event_enddate';
5094 5094
 			$csv_row[] = 'starttime';
@@ -5147,15 +5147,15 @@  discard block
 block discarded – undo
5147 5147
 		}
5148 5148
 		// WPML
5149 5149
 
5150
-		$custom_fields = geodir_imex_get_custom_fields( $post_type );
5151
-		if ( !empty( $custom_fields ) ) {
5152
-			foreach ( $custom_fields as $custom_field ) {
5150
+		$custom_fields = geodir_imex_get_custom_fields($post_type);
5151
+		if (!empty($custom_fields)) {
5152
+			foreach ($custom_fields as $custom_field) {
5153 5153
 				$csv_row[] = $custom_field->htmlvar_name;
5154 5154
 			}
5155 5155
 		}
5156 5156
 
5157 5157
 		// Export franchise fields
5158
-		$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5158
+		$is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5159 5159
 		if ($is_franchise_active) {
5160 5160
 			$csv_row[] = 'gd_is_franchise';
5161 5161
 			$csv_row[] = 'gd_franchise_lock';
@@ -5176,28 +5176,28 @@  discard block
 block discarded – undo
5176 5176
 		$csv_rows[] = $csv_row;
5177 5177
 
5178 5178
 		$images_count = 5;
5179
-        $xx=0;
5180
-		foreach ( $posts as $post ) {$xx++;
5179
+        $xx = 0;
5180
+		foreach ($posts as $post) {$xx++;
5181 5181
 			$post_id = $post['ID'];
5182 5182
 			
5183
-			$gd_post_info = geodir_get_post_info( $post_id );
5184
-			$post_info = (array)$gd_post_info;
5183
+			$gd_post_info = geodir_get_post_info($post_id);
5184
+			$post_info = (array) $gd_post_info;
5185 5185
 			
5186
-			$taxonomy_category = $post_type . 'category';
5187
-			$taxonomy_tags = $post_type . '_tags';
5186
+			$taxonomy_category = $post_type.'category';
5187
+			$taxonomy_tags = $post_type.'_tags';
5188 5188
 			
5189 5189
 			$post_category = '';
5190 5190
 			$default_category_id = $gd_post_info->default_category;
5191 5191
 			$default_category = '';
5192 5192
 			$post_tags = '';
5193
-			$terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) );
5193
+			$terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
5194 5194
 			
5195
-			if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
5195
+			if (!empty($terms) && !is_wp_error($terms)) {
5196 5196
 				$post_category = array();
5197 5197
 				$post_tags = array();
5198 5198
 			
5199
-				foreach ( $terms as $term ) {
5200
-					if ( $term->taxonomy == $taxonomy_category ) {
5199
+				foreach ($terms as $term) {
5200
+					if ($term->taxonomy == $taxonomy_category) {
5201 5201
 						$post_category[] = $term->name;
5202 5202
 						
5203 5203
 						if ($default_category_id == $term->term_id) {
@@ -5205,7 +5205,7 @@  discard block
 block discarded – undo
5205 5205
 						}
5206 5206
 					}
5207 5207
 					
5208
-					if ( $term->taxonomy == $taxonomy_tags ) {
5208
+					if ($term->taxonomy == $taxonomy_tags) {
5209 5209
 						$post_tags[] = $term->name;
5210 5210
 					}
5211 5211
 				}
@@ -5213,47 +5213,47 @@  discard block
 block discarded – undo
5213 5213
 				if (empty($default_category) && !empty($post_category)) {
5214 5214
 					$default_category = $post_category[0]; // Set first one as default category.
5215 5215
 				}
5216
-				$post_category = !empty( $post_category ) ? implode( ',', $post_category ) : '';
5217
-				$post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : '';
5216
+				$post_category = !empty($post_category) ? implode(',', $post_category) : '';
5217
+				$post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
5218 5218
 			}
5219 5219
 
5220 5220
 			// Franchise data
5221
-			if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
5221
+			if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
5222 5222
 				$franchise_id = $post_info['franchise'];
5223 5223
 				$gd_franchise_info = geodir_get_post_info($franchise_id);
5224 5224
 
5225 5225
 				if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
5226
-					$franchise_info = (array)$gd_franchise_info;
5226
+					$franchise_info = (array) $gd_franchise_info;
5227 5227
 					$locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
5228 5228
 					
5229 5229
 					if (!empty($locked_fields)) {
5230
-						foreach( $locked_fields as $locked_field) {
5230
+						foreach ($locked_fields as $locked_field) {
5231 5231
 							if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
5232 5232
 								$post_info[$locked_field] = $franchise_info[$locked_field];
5233 5233
 							}
5234 5234
 							
5235 5235
 							if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
5236
-								$franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) );
5236
+								$franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
5237 5237
 			
5238
-								if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
5238
+								if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
5239 5239
 									$franchise_post_category = array();
5240 5240
 									$franchise_post_tags = array();
5241 5241
 								
5242
-									foreach ( $franchise_terms as $franchise_term ) {
5243
-										if ( $franchise_term->taxonomy == $taxonomy_category ) {
5242
+									foreach ($franchise_terms as $franchise_term) {
5243
+										if ($franchise_term->taxonomy == $taxonomy_category) {
5244 5244
 											$franchise_post_category[] = $franchise_term->name;
5245 5245
 										}
5246 5246
 										
5247
-										if ( $franchise_term->taxonomy == $taxonomy_tags ) {
5247
+										if ($franchise_term->taxonomy == $taxonomy_tags) {
5248 5248
 											$franchise_post_tags[] = $franchise_term->name;
5249 5249
 										}
5250 5250
 									}
5251 5251
 									
5252 5252
 									if (in_array($taxonomy_category, $locked_fields)) {
5253
-										$post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : '';
5253
+										$post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
5254 5254
 									}
5255 5255
 									if (in_array('post_tags', $locked_fields)) {
5256
-										$post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : '';
5256
+										$post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
5257 5257
 									}
5258 5258
 								}
5259 5259
 							}
@@ -5262,18 +5262,18 @@  discard block
 block discarded – undo
5262 5262
 				}
5263 5263
 			}
5264 5264
 						
5265
-			$post_images = geodir_get_images( $post_id );
5265
+			$post_images = geodir_get_images($post_id);
5266 5266
 			$current_images = array();
5267
-			if ( !empty( $post_images ) ) {
5268
-				foreach ( $post_images as $post_image ) {
5269
-					$post_image = (array)$post_image;
5270
-					$image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : '';
5271
-					if ( $image ) {
5267
+			if (!empty($post_images)) {
5268
+				foreach ($post_images as $post_image) {
5269
+					$post_image = (array) $post_image;
5270
+					$image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
5271
+					if ($image) {
5272 5272
 						$current_images[] = $image;
5273 5273
 					}
5274 5274
 				}
5275 5275
 				
5276
-				$images_count = max( $images_count, count( $current_images ) );
5276
+				$images_count = max($images_count, count($current_images));
5277 5277
 			}
5278 5278
 
5279 5279
 			$csv_row = array();
@@ -5285,7 +5285,7 @@  discard block
 block discarded – undo
5285 5285
 			$csv_row[] = $default_category; // default_category
5286 5286
 			$csv_row[] = $post_tags; // post_tags
5287 5287
 			$csv_row[] = $post_type; // post_type
5288
-			if ( $post_type == 'gd_event' ) {
5288
+			if ($post_type == 'gd_event') {
5289 5289
 				$event_data = geodir_imex_get_event_data($post, $gd_post_info);
5290 5290
 				$csv_row[] = $event_data['event_date']; // event_date
5291 5291
 				$csv_row[] = $event_data['event_enddate']; // enddate
@@ -5306,12 +5306,12 @@  discard block
 block discarded – undo
5306 5306
 				$csv_row[] = $event_data['recurring_end_date']; // repeat_end
5307 5307
 			}
5308 5308
 			$csv_row[] = $post_info['post_status']; // post_status
5309
-			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5309
+			$csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5310 5310
             if ($is_claim_active) {
5311
-                $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5311
+                $csv_row[] = !empty($post_info['claimed']) && (int) $post_info['claimed'] == 1 ? 1 : ''; // claimed
5312 5312
             }
5313 5313
 			if ($is_payment_plugin) {
5314
-				$csv_row[] = (int)$post_info['package_id']; // package_id
5314
+				$csv_row[] = (int) $post_info['package_id']; // package_id
5315 5315
 				$csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days
5316 5316
 				$csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
5317 5317
 			}
@@ -5348,14 +5348,14 @@  discard block
 block discarded – undo
5348 5348
 			$csv_row[] = stripslashes($post_info['geodir_special_offers']); // geodir_special_offers
5349 5349
 			// WPML
5350 5350
 			if ($is_wpml) {
5351
-				$csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type );
5352
-				$csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type );
5351
+				$csv_row[] = geodir_get_language_for_element($post_id, 'post_'.$post_type);
5352
+				$csv_row[] = geodir_imex_original_post_id($post_id, 'post_'.$post_type);
5353 5353
 			}
5354 5354
 			// WPML
5355 5355
 			
5356
-			if ( !empty( $custom_fields ) ) {
5357
-				foreach ( $custom_fields as $custom_field ) {
5358
-					$csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : '';
5356
+			if (!empty($custom_fields)) {
5357
+				foreach ($custom_fields as $custom_field) {
5358
+					$csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
5359 5359
 				}
5360 5360
 			}
5361 5361
 			
@@ -5366,15 +5366,15 @@  discard block
 block discarded – undo
5366 5366
 				$franchise = '';
5367 5367
 					
5368 5368
 				if (geodir_franchise_pkg_is_active($gd_post_info)) {
5369
-					$gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true );
5370
-					$locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : '';
5369
+					$gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
5370
+					$locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
5371 5371
 					$locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
5372
-					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id
5372
+					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id
5373 5373
 				}
5374 5374
 				
5375
-				$csv_row[] = (int)$gd_is_franchise; // gd_is_franchise
5375
+				$csv_row[] = (int) $gd_is_franchise; // gd_is_franchise
5376 5376
 				$csv_row[] = $locaked_fields; // gd_franchise_lock fields
5377
-				$csv_row[] = (int)$franchise; // franchise id
5377
+				$csv_row[] = (int) $franchise; // franchise id
5378 5378
 			}
5379 5379
             
5380 5380
             /**
@@ -5388,15 +5388,15 @@  discard block
 block discarded – undo
5388 5388
              */
5389 5389
             $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5390 5390
 			
5391
-			for ( $c = 0; $c < $images_count; $c++ ) {
5392
-				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
5391
+			for ($c = 0; $c < $images_count; $c++) {
5392
+				$csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE
5393 5393
 			}
5394 5394
 			
5395 5395
 			$csv_rows[] = $csv_row;
5396 5396
 
5397 5397
 		}
5398 5398
 
5399
-		for ( $c = 0; $c < $images_count; $c++ ) {
5399
+		for ($c = 0; $c < $images_count; $c++) {
5400 5400
 			$csv_rows[0][] = 'IMAGE';
5401 5401
 		}
5402 5402
 	}
@@ -5418,30 +5418,30 @@  discard block
 block discarded – undo
5418 5418
  * @param int $page_no Page number. Default 0.
5419 5419
  * @return array Array of posts data.
5420 5420
  */
5421
-function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5421
+function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
5422 5422
     global $wpdb, $plugin_prefix;
5423 5423
 
5424
-    if ( ! post_type_exists( $post_type ) )
5424
+    if (!post_type_exists($post_type))
5425 5425
         return new stdClass;
5426 5426
         
5427
-    $table = $plugin_prefix . $post_type . '_detail';
5427
+    $table = $plugin_prefix.$post_type.'_detail';
5428 5428
 
5429 5429
     $limit = '';
5430
-    if ( $per_page > 0 && $page_no > 0 ) {
5431
-        $offset = ( $page_no - 1 ) * $per_page;
5430
+    if ($per_page > 0 && $page_no > 0) {
5431
+        $offset = ($page_no - 1) * $per_page;
5432 5432
         
5433
-        if ( $offset > 0 ) {
5434
-            $limit = " LIMIT " . $offset . "," . $per_page;
5433
+        if ($offset > 0) {
5434
+            $limit = " LIMIT ".$offset.",".$per_page;
5435 5435
         } else {
5436
-            $limit = " LIMIT " . $per_page;
5436
+            $limit = " LIMIT ".$per_page;
5437 5437
         }
5438 5438
     }
5439 5439
 
5440 5440
     // Skip listing with statuses trash, auto-draft etc...
5441 5441
     $skip_statuses = geodir_imex_export_skip_statuses();
5442 5442
     $where_statuses = '';
5443
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5444
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5443
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5444
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5445 5445
     }
5446 5446
     
5447 5447
     /**
@@ -5452,9 +5452,9 @@  discard block
 block discarded – undo
5452 5452
      *
5453 5453
      * @param string $where SQL where clause part.
5454 5454
      */
5455
-    $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5455
+    $where_statuses = apply_filters('geodir_get_export_posts', $where_statuses, $post_type);
5456 5456
 
5457
-    $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5457
+    $query = $wpdb->prepare("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ".$where_statuses." ORDER BY {$wpdb->posts}.ID ASC".$limit, $post_type);
5458 5458
     /**
5459 5459
      * Modify returned posts SQL query for the current post type.
5460 5460
      *
@@ -5464,8 +5464,8 @@  discard block
 block discarded – undo
5464 5464
      * @param int $query The SQL query.
5465 5465
      * @param string $post_type Post type.
5466 5466
      */
5467
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5468
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5467
+    $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
5468
+    $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A);
5469 5469
 
5470 5470
     /**
5471 5471
      * Modify returned post results for the current post type.
@@ -5476,7 +5476,7 @@  discard block
 block discarded – undo
5476 5476
      * @param object $results An object containing all post ids.
5477 5477
      * @param string $post_type Post type.
5478 5478
      */
5479
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5479
+    return apply_filters('geodir_export_posts', $results, $post_type);
5480 5480
 }
5481 5481
 
5482 5482
 /**
@@ -5494,24 +5494,24 @@  discard block
 block discarded – undo
5494 5494
  * @param string $post_type Post type.
5495 5495
  * @return string The SQL query.
5496 5496
  */
5497
-function geodir_imex_get_events_query( $query, $post_type ) {
5498
-    if ( $post_type == 'gd_event' ) {
5497
+function geodir_imex_get_events_query($query, $post_type) {
5498
+    if ($post_type == 'gd_event') {
5499 5499
         global $wpdb, $plugin_prefix;
5500 5500
         
5501
-        $table = $plugin_prefix . $post_type . '_detail';
5501
+        $table = $plugin_prefix.$post_type.'_detail';
5502 5502
         $schedule_table = EVENT_SCHEDULE;
5503 5503
         
5504 5504
         // Skip listing with statuses trash, auto-draft etc...
5505 5505
         $skip_statuses = geodir_imex_export_skip_statuses();
5506 5506
         $where_statuses = '';
5507
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5508
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5507
+        if (!empty($skip_statuses) && is_array($skip_statuses)) {
5508
+            $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5509 5509
         }
5510 5510
         
5511 5511
         /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5512
-        $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5512
+        $where_statuses = apply_filters('geodir_get_export_posts', $where_statuses, $post_type);
5513 5513
 
5514
-        $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5514
+        $query = $wpdb->prepare("SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s ".$where_statuses." GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type);
5515 5515
     }
5516 5516
 
5517 5517
     return $query;
@@ -5535,35 +5535,35 @@  discard block
 block discarded – undo
5535 5535
  * @param  string $post_type Post type.
5536 5536
  * @return int Total terms count.
5537 5537
  */
5538
-function geodir_get_terms_count( $post_type ) {
5539
-    $args = array( 'hide_empty' => 0 );
5538
+function geodir_get_terms_count($post_type) {
5539
+    $args = array('hide_empty' => 0);
5540 5540
 
5541
-    remove_all_filters( 'get_terms' );
5541
+    remove_all_filters('get_terms');
5542 5542
 
5543
-    $taxonomy = $post_type . 'category';
5543
+    $taxonomy = $post_type.'category';
5544 5544
 
5545 5545
     // WPML
5546 5546
     $is_wpml = geodir_is_wpml();
5547 5547
     $active_lang = 'all';
5548
-    if ( $is_wpml ) {
5548
+    if ($is_wpml) {
5549 5549
         global $sitepress;
5550 5550
         $active_lang = $sitepress->get_current_language();
5551 5551
         
5552
-        if ( $active_lang != 'all' ) {
5553
-            $sitepress->switch_lang( 'all', true );
5552
+        if ($active_lang != 'all') {
5553
+            $sitepress->switch_lang('all', true);
5554 5554
         }
5555 5555
     }
5556 5556
     // WPML
5557 5557
             
5558
-    $count_terms = wp_count_terms( $taxonomy, $args );
5558
+    $count_terms = wp_count_terms($taxonomy, $args);
5559 5559
 
5560 5560
     // WPML
5561
-    if ( $is_wpml && $active_lang !== 'all' ) {
5561
+    if ($is_wpml && $active_lang !== 'all') {
5562 5562
         global $sitepress;
5563
-        $sitepress->switch_lang( $active_lang, true );
5563
+        $sitepress->switch_lang($active_lang, true);
5564 5564
     }
5565 5565
     // WPML
5566
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5566
+    $count_terms = !is_wp_error($count_terms) ? $count_terms : 0;
5567 5567
      
5568 5568
     return $count_terms;
5569 5569
 }
@@ -5580,23 +5580,23 @@  discard block
 block discarded – undo
5580 5580
  * @param int $page_no Page number. Default 0.
5581 5581
  * @return array Array of terms data.
5582 5582
  */
5583
-function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
5584
-	$args = array( 'hide_empty' => 0, 'orderby' => 'id' );
5583
+function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
5584
+	$args = array('hide_empty' => 0, 'orderby' => 'id');
5585 5585
 	
5586
-	remove_all_filters( 'get_terms' );
5586
+	remove_all_filters('get_terms');
5587 5587
 	
5588
-	$taxonomy = $post_type . 'category';
5588
+	$taxonomy = $post_type.'category';
5589 5589
 	
5590
-	if ( $per_page > 0 && $page_no > 0 ) {
5591
-		$args['offset'] = ( $page_no - 1 ) * $per_page;
5590
+	if ($per_page > 0 && $page_no > 0) {
5591
+		$args['offset'] = ($page_no - 1) * $per_page;
5592 5592
 		$args['number'] = $per_page;
5593 5593
 	}
5594 5594
 	
5595
-	$terms = get_terms( $taxonomy, $args );
5595
+	$terms = get_terms($taxonomy, $args);
5596 5596
 
5597 5597
 	$csv_rows = array();
5598 5598
 	
5599
-	if ( !empty( $terms ) ) {
5599
+	if (!empty($terms)) {
5600 5600
 		$csv_row = array();
5601 5601
 		$csv_row[] = 'cat_id';
5602 5602
 		$csv_row[] = 'cat_name';
@@ -5618,16 +5618,16 @@  discard block
 block discarded – undo
5618 5618
 		
5619 5619
 		$csv_rows[] = $csv_row;
5620 5620
 		
5621
-		foreach ( $terms as $term ) {
5622
-			$cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type );
5623
-			$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5621
+		foreach ($terms as $term) {
5622
+			$cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type);
5623
+			$cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
5624 5624
 			
5625
-			$cat_image = geodir_get_default_catimage( $term->term_id, $post_type );
5626
-			$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; 
5625
+			$cat_image = geodir_get_default_catimage($term->term_id, $post_type);
5626
+			$cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; 
5627 5627
 			
5628 5628
 			$cat_parent = '';
5629
-			if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
5630
-				$parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy );
5629
+			if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
5630
+				$parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
5631 5631
 				$cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : '';
5632 5632
 			}
5633 5633
 			
@@ -5637,15 +5637,15 @@  discard block
 block discarded – undo
5637 5637
 			$csv_row[] = $term->slug;
5638 5638
 			$csv_row[] = $post_type;
5639 5639
 			$csv_row[] = $cat_parent;
5640
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5640
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type);
5641 5641
             // WPML
5642 5642
 			if ($is_wpml) {
5643
-				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5644
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5643
+				$csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_'.$taxonomy);
5644
+                $csv_row[] = geodir_imex_original_post_id($term->term_id, 'tax_'.$taxonomy);
5645 5645
 			}
5646 5646
 			// WPML
5647 5647
 			$csv_row[] = $term->description;
5648
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type );
5648
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type);
5649 5649
 			$csv_row[] = $cat_image;
5650 5650
 			$csv_row[] = $cat_icon;
5651 5651
 			
@@ -5664,10 +5664,10 @@  discard block
 block discarded – undo
5664 5664
  * @param  bool $relative True for relative path & False for absolute path.
5665 5665
  * @return string Path to the cache directory.
5666 5666
  */
5667
-function geodir_path_import_export( $relative = true ) {
5667
+function geodir_path_import_export($relative = true) {
5668 5668
 	$upload_dir = wp_upload_dir();
5669 5669
 	
5670
-	return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache';
5670
+	return $relative ? $upload_dir['baseurl'].'/cache' : $upload_dir['basedir'].'/cache';
5671 5671
 }
5672 5672
 
5673 5673
 /**
@@ -5683,8 +5683,8 @@  discard block
 block discarded – undo
5683 5683
  * @param  bool $clear If true then it overwrite data otherwise add rows at the end of file.
5684 5684
  * @return bool true if success otherwise false.
5685 5685
  */
5686
-function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
5687
-	if ( empty( $csv_data ) ) {
5686
+function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
5687
+	if (empty($csv_data)) {
5688 5688
 		return false;
5689 5689
 	}
5690 5690
 	
@@ -5692,17 +5692,17 @@  discard block
 block discarded – undo
5692 5692
 	
5693 5693
 	$mode = $clear ? 'w+' : 'a+';
5694 5694
 	
5695
-	if ( function_exists( 'fputcsv' ) ) {
5696
-		$file = fopen( $file_path, $mode );
5697
-		foreach( $csv_data as $csv_row ) {
5695
+	if (function_exists('fputcsv')) {
5696
+		$file = fopen($file_path, $mode);
5697
+		foreach ($csv_data as $csv_row) {
5698 5698
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5699
-			$write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' );
5699
+			$write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"');
5700 5700
 		}
5701
-		fclose( $file );
5701
+		fclose($file);
5702 5702
 	} else {
5703
-		foreach( $csv_data as $csv_row ) {
5703
+		foreach ($csv_data as $csv_row) {
5704 5704
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5705
-			$wp_filesystem->put_contents( $file_path, $csv_row );
5705
+			$wp_filesystem->put_contents($file_path, $csv_row);
5706 5706
 		}
5707 5707
 	}
5708 5708
 		
@@ -5720,14 +5720,14 @@  discard block
 block discarded – undo
5720 5720
  * @param  string $file Full path to file.
5721 5721
  * @return int No of file rows.
5722 5722
  */
5723
-function geodir_import_export_line_count( $file ) {
5723
+function geodir_import_export_line_count($file) {
5724 5724
 	global $wp_filesystem;
5725 5725
 	
5726
-	if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
5727
-		$contents = $wp_filesystem->get_contents_array( $file );
5726
+	if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
5727
+		$contents = $wp_filesystem->get_contents_array($file);
5728 5728
 		
5729
-		if ( !empty( $contents ) && is_array( $contents ) ) {
5730
-			return count( $contents ) - 1;
5729
+		if (!empty($contents) && is_array($contents)) {
5730
+			return count($contents) - 1;
5731 5731
 		}
5732 5732
 	}
5733 5733
 	
@@ -5744,11 +5744,11 @@  discard block
 block discarded – undo
5744 5744
  * @param string $post_type The post type.
5745 5745
  * @return object Queried object.
5746 5746
  */
5747
-function geodir_imex_get_custom_fields( $post_type ) {
5747
+function geodir_imex_get_custom_fields($post_type) {
5748 5748
 	global $wpdb;
5749 5749
 	 
5750
-	$sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
5751
-	$rows = $wpdb->get_results( $sql );
5750
+	$sql = $wpdb->prepare("SELECT htmlvar_name FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array($post_type));
5751
+	$rows = $wpdb->get_results($sql);
5752 5752
 	 
5753 5753
 	return $rows;
5754 5754
 }
@@ -5764,10 +5764,10 @@  discard block
 block discarded – undo
5764 5764
  * @return array Event data array.
5765 5765
  */
5766 5766
 function geodir_imex_get_event_data($post, $gd_post_info) {
5767
-	$event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : '';
5767
+	$event_date = isset($post['event_date']) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($post['event_date'])) : '';
5768 5768
 	$event_enddate = $event_date;
5769
-	$starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : '';
5770
-	$endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : '';
5769
+	$starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
5770
+	$endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
5771 5771
 	
5772 5772
 	$is_recurring_event = '';
5773 5773
 	$event_duration_days = '';
@@ -5784,15 +5784,15 @@  discard block
 block discarded – undo
5784 5784
 		
5785 5785
 	$recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array();
5786 5786
 	if (!empty($recurring_data)) {
5787
-		$event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date;
5788
-		$event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date;
5789
-		$starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime;
5790
-		$endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime;
5787
+		$event_date = isset($recurring_data['event_start']) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_start'])) : $event_date;
5788
+		$event_enddate = isset($recurring_data['event_end']) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_end'])) : $event_date;
5789
+		$starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
5790
+		$endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
5791 5791
 		$is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : '';
5792 5792
 		$different_times = !empty($recurring_data['different_times']) ? true : false;
5793 5793
 	
5794
-		$recurring_pkg = geodir_event_recurring_pkg( $gd_post_info );
5795
-		$is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true;
5794
+		$recurring_pkg = geodir_event_recurring_pkg($gd_post_info);
5795
+		$is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true;
5796 5796
 			
5797 5797
 		if ($recurring_pkg && $is_recurring) {
5798 5798
 			$recurring_dates = $event_date;
@@ -5802,13 +5802,13 @@  discard block
 block discarded – undo
5802 5802
 			$recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
5803 5803
 			
5804 5804
 			if (!empty($recurring_data['event_recurring_dates'])) {
5805
-				$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
5805
+				$event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
5806 5806
 				
5807 5807
 				if (!empty($event_recurring_dates)) {
5808 5808
 					$recurring_dates = array();
5809 5809
 					
5810 5810
 					foreach ($event_recurring_dates as $date) {
5811
-						$recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) );
5811
+						$recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
5812 5812
 					}
5813 5813
 					
5814 5814
 					$recurring_dates = implode(",", $recurring_dates);
@@ -5824,7 +5824,7 @@  discard block
 block discarded – undo
5824 5824
 						$times = array();
5825 5825
 						
5826 5826
 						foreach ($recurring_data['starttimes'] as $time) {
5827
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
5827
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
5828 5828
 						}
5829 5829
 						
5830 5830
 						$event_starttimes = implode(",", $times);
@@ -5834,7 +5834,7 @@  discard block
 block discarded – undo
5834 5834
 						$times = array();
5835 5835
 						
5836 5836
 						foreach ($recurring_data['endtimes'] as $time) {
5837
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
5837
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
5838 5838
 						}
5839 5839
 						
5840 5840
 						$event_endtimes = implode(",", $times);
@@ -5846,8 +5846,8 @@  discard block
 block discarded – undo
5846 5846
 					}
5847 5847
 				}
5848 5848
 			} else {
5849
-				$event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1;
5850
-				$recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
5849
+				$event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1;
5850
+				$recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
5851 5851
 				
5852 5852
 				if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
5853 5853
 					$week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@@ -5863,11 +5863,11 @@  discard block
 block discarded – undo
5863 5863
 				}
5864 5864
 				
5865 5865
 				$recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
5866
-				if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
5867
-					$recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : '';
5866
+				if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
5867
+					$recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['repeat_end'])) : '';
5868 5868
 					$max_recurring_count = empty($recurring_end_date) ? 1 : '';
5869 5869
 				} else {
5870
-					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1);
5870
+					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1);
5871 5871
 				}
5872 5872
 			}
5873 5873
 		}
@@ -5931,9 +5931,9 @@  discard block
 block discarded – undo
5931 5931
  * @return array Event data array.
5932 5932
  */
5933 5933
 function geodir_imex_process_event_data($gd_post) {
5934
-	$recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post );
5934
+	$recurring_pkg = geodir_event_recurring_pkg((object) $gd_post);
5935 5935
 
5936
-	$is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true;
5936
+	$is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true;
5937 5937
 	$event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_date($gd_post['event_date'], 'Y-m-d') : '';
5938 5938
 	$event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_date($gd_post['event_enddate'], 'Y-m-d') : $event_date;
5939 5939
 	$all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false;
@@ -5980,17 +5980,17 @@  discard block
 block discarded – undo
5980 5980
 				$event_recurring_dates = implode(",", $event_recurring_dates);
5981 5981
 			}
5982 5982
 		} else {
5983
-			$duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1;
5984
-			$repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1;
5985
-			$max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1;
5986
-			$repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_date($gd_post['recurring_end_date'], 'Y-m-d') : '';
5983
+			$duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1;
5984
+			$repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1;
5985
+			$max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1;
5986
+			$repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_date($gd_post['recurring_end_date'], 'Y-m-d') : '';
5987 5987
 			
5988 5988
 			$repeat_end_type = $repeat_end != '' ? 1 : 0;
5989 5989
 			$max_repeat = $repeat_end != '' ? '' : $max_repeat;
5990 5990
 			
5991 5991
 			$week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
5992 5992
 			
5993
-			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
5993
+			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
5994 5994
 			$repeat_days = array();
5995 5995
 			if (!empty($a_repeat_days)) {
5996 5996
 				foreach ($a_repeat_days as $repeat_day) {
@@ -6008,7 +6008,7 @@  discard block
 block discarded – undo
6008 6008
 			$repeat_weeks = array();
6009 6009
 			if (!empty($a_repeat_weeks)) {
6010 6010
 				foreach ($a_repeat_weeks as $repeat_week) {
6011
-					$repeat_weeks[] = (int)$repeat_week;
6011
+					$repeat_weeks[] = (int) $repeat_week;
6012 6012
 				}
6013 6013
 				
6014 6014
 				$repeat_weeks = array_unique($repeat_weeks);
@@ -6072,7 +6072,7 @@  discard block
 block discarded – undo
6072 6072
 
6073 6073
     $page_found = $wpdb->get_var(
6074 6074
         $wpdb->prepare(
6075
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6075
+            "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
6076 6076
             array($slug)
6077 6077
         )
6078 6078
     );
@@ -6127,7 +6127,7 @@  discard block
 block discarded – undo
6127 6127
  */
6128 6128
 function geodir_admin_upgrade_notice() {
6129 6129
     $class = "error";
6130
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6130
+    $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
6131 6131
     echo"<div class=\"$class\"> <p>$message</p></div>";
6132 6132
 }
6133 6133
 
@@ -6139,7 +6139,7 @@  discard block
 block discarded – undo
6139 6139
  * @param (object) $r
6140 6140
  * @return (string) $output
6141 6141
  */
6142
-function geodire_admin_upgrade_notice( $plugin_data, $r )
6142
+function geodire_admin_upgrade_notice($plugin_data, $r)
6143 6143
 {
6144 6144
     // readme contents
6145 6145
     $args = array(
@@ -6147,7 +6147,7 @@  discard block
 block discarded – undo
6147 6147
         'redirection' => 5
6148 6148
     );
6149 6149
     $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6150
-    $data       = wp_remote_get( $url, $args );
6150
+    $data = wp_remote_get($url, $args);
6151 6151
 
6152 6152
     if (!is_wp_error($data) && $data['response']['code'] == 200) {
6153 6153
 
@@ -6162,20 +6162,20 @@  discard block
 block discarded – undo
6162 6162
 function geodir_in_plugin_update_message($content) {
6163 6163
     // Output Upgrade Notice
6164 6164
     $matches        = null;
6165
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6165
+    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote(GEODIRECTORY_VERSION).'\s*=|$)~Uis';
6166 6166
     $upgrade_notice = '';
6167
-    if ( preg_match( $regexp, $content, $matches ) ) {
6168
-        if(empty($matches)){return;}
6167
+    if (preg_match($regexp, $content, $matches)) {
6168
+        if (empty($matches)) {return; }
6169 6169
 
6170
-        $version = trim( $matches[1] );
6171
-        if($version && $version>GEODIRECTORY_VERSION){
6170
+        $version = trim($matches[1]);
6171
+        if ($version && $version > GEODIRECTORY_VERSION) {
6172 6172
 
6173 6173
 
6174
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6175
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6174
+        $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
6175
+        if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
6176 6176
             $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6177
-            foreach ( $notices as $index => $line ) {
6178
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6177
+            foreach ($notices as $index => $line) {
6178
+                $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
6179 6179
             }
6180 6180
             $upgrade_notice .= '</div> ';
6181 6181
         }
@@ -6199,7 +6199,7 @@  discard block
 block discarded – undo
6199 6199
 		$default_language = $sitepress->get_default_language();
6200 6200
 		if ($current_language != 'all' && $current_language != $default_language) {
6201 6201
 	?>
6202
-	<div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
6202
+	<div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory'); ?></strong></p></div>
6203 6203
 	<?php
6204 6204
 		}
6205 6205
 	}
@@ -6214,7 +6214,7 @@  discard block
 block discarded – undo
6214 6214
  * @param array Listing statuses to be skipped.
6215 6215
  */
6216 6216
 function geodir_imex_export_skip_statuses() {
6217
-    $statuses = array( 'trash', 'auto-draft' );
6217
+    $statuses = array('trash', 'auto-draft');
6218 6218
     
6219 6219
     /**
6220 6220
      * Filter the statuses to skip during GD export listings.
@@ -6224,7 +6224,7 @@  discard block
 block discarded – undo
6224 6224
      *
6225 6225
      * @param array $statuses Listing statuses to be skipped.
6226 6226
      */
6227
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6227
+    $statuses = apply_filters('geodir_imex_export_skip_statuses', $statuses);
6228 6228
      
6229 6229
     return $statuses;
6230 6230
 }
@@ -6295,16 +6295,16 @@  discard block
 block discarded – undo
6295 6295
 function geodir_imex_get_filter_where($where = '', $post_type = '') {
6296 6296
     global $wpdb;
6297 6297
     
6298
-    $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6298
+    $filters = !empty($_REQUEST['gd_imex']) && is_array($_REQUEST['gd_imex']) ? $_REQUEST['gd_imex'] : NULL;
6299 6299
     
6300
-    if ( !empty( $filters ) ) {
6301
-        foreach ( $filters as $field => $value ) {
6300
+    if (!empty($filters)) {
6301
+        foreach ($filters as $field => $value) {
6302 6302
             switch ($field) {
6303 6303
                 case 'start_date':
6304
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6304
+                    $where .= " AND `".$wpdb->posts."`.`post_date` >= '".sanitize_text_field($value)." 00:00:00'";
6305 6305
                 break;
6306 6306
                 case 'end_date':
6307
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6307
+                    $where .= " AND `".$wpdb->posts."`.`post_date` <= '".sanitize_text_field($value)." 23:59:59'";
6308 6308
                 break;
6309 6309
             }
6310 6310
         }
@@ -6316,25 +6316,25 @@  discard block
 block discarded – undo
6316 6316
 add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
6317 6317
 
6318 6318
 
6319
-function geodir_fix_for_primer_theme(){
6320
-    if(!defined( 'PRIMER_VERSION' )){return;}
6319
+function geodir_fix_for_primer_theme() {
6320
+    if (!defined('PRIMER_VERSION')) {return; }
6321 6321
     global $pagenow;
6322 6322
 
6323
-    if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) )  ){
6323
+    if (('post.php' === $pagenow || 'post-new.php' === $pagenow) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']))) {
6324 6324
 
6325
-        $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] );
6325
+        $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type($_GET['post']);
6326 6326
 
6327 6327
         $post_types = geodir_get_posttypes();
6328
-        if ($post_type && in_array($post_type, $post_types) ) {
6328
+        if ($post_type && in_array($post_type, $post_types)) {
6329 6329
             global $primer_customizer_layouts;
6330
-            remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10);
6330
+            remove_action('add_meta_boxes', array($primer_customizer_layouts, 'add_meta_box'), 10);
6331 6331
         }
6332 6332
     }
6333 6333
 
6334 6334
 }
6335 6335
 
6336
-if(is_admin()){
6337
-    add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);  
6336
+if (is_admin()) {
6337
+    add_action('add_meta_boxes', 'geodir_fix_for_primer_theme', 0);  
6338 6338
 }
6339 6339
 
6340 6340
 
@@ -6467,32 +6467,32 @@  discard block
 block discarded – undo
6467 6467
 
6468 6468
 function geodir_ga_activation_url() {
6469 6469
 
6470
-    return add_query_arg( array(
6470
+    return add_query_arg(array(
6471 6471
         'next'          => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
6472 6472
         'scope'         => GEODIR_GA_SCOPE,
6473 6473
         'response_type' => 'code',
6474 6474
         'redirect_uri'  => GEODIR_GA_REDIRECT,
6475 6475
         'client_id'     => GEODIR_GA_CLIENTID,
6476
-    ), 'https://accounts.google.com/o/oauth2/auth' );
6476
+    ), 'https://accounts.google.com/o/oauth2/auth');
6477 6477
 
6478 6478
     return $url;
6479 6479
 }
6480 6480
 
6481
-function geodir_gd_accounts(){
6481
+function geodir_gd_accounts() {
6482 6482
     $accounts = array();
6483
-    $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true );
6484
-    if($useAuth){
6483
+    $useAuth = (get_option('geodir_ga_auth_code') == '' ? false : true);
6484
+    if ($useAuth) {
6485 6485
         try {
6486 6486
             $accounts = geodir_ga_get_analytics_accounts();
6487 6487
         } catch (Exception $e) {
6488
-            geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) );
6488
+            geodir_error_log(wp_sprintf(__('GD Google Analytics API Error(%s) : %s', 'geodirectory'), $e->getCode(), $e->getMessage()));
6489 6489
         }
6490 6490
         
6491
-        if(is_array($accounts)){
6492
-            $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
6493
-        }elseif(get_option('geodir_ga_account_id')){
6491
+        if (is_array($accounts)) {
6492
+            $accounts = array_merge(array(__('Select Account', 'geodirectory')), $accounts);
6493
+        }elseif (get_option('geodir_ga_account_id')) {
6494 6494
             $accounts = array();
6495
-            $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
6495
+            $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required', 'geodirectory').' ('.get_option('geodir_ga_account_id').')';
6496 6496
         }
6497 6497
     }
6498 6498
     return $accounts;
@@ -6503,21 +6503,21 @@  discard block
 block discarded – undo
6503 6503
     global $gd_ga_errors;
6504 6504
     $accounts = array();
6505 6505
 
6506
-    if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
6506
+    if (get_option('geodir_ga_auth_token') === false) {update_option('geodir_ga_auth_token', ''); }
6507 6507
 
6508 6508
 
6509
-    if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
6509
+    if (get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])) {
6510 6510
       return get_option('geodir_gd_uids');
6511 6511
     }
6512 6512
 
6513 6513
     # Create a new Gdata call
6514
-    if ( trim(get_option('geodir_ga_auth_code')) != '' )
6514
+    if (trim(get_option('geodir_ga_auth_code')) != '')
6515 6515
         $stats = new GDGoogleAnalyticsStats();
6516 6516
     else
6517 6517
         return false;
6518 6518
 
6519 6519
     # Check if Google sucessfully logged in
6520
-    if ( ! $stats->checkLogin() )
6520
+    if (!$stats->checkLogin())
6521 6521
         return false;
6522 6522
 
6523 6523
     # Get a list of accounts
@@ -6529,28 +6529,28 @@  discard block
 block discarded – undo
6529 6529
     }
6530 6530
 
6531 6531
 
6532
-    natcasesort ($accounts);
6532
+    natcasesort($accounts);
6533 6533
 
6534 6534
     # Return the account array if there are accounts
6535
-    if ( count($accounts) > 0 ){
6536
-        update_option('geodir_gd_uids',$accounts);
6535
+    if (count($accounts) > 0) {
6536
+        update_option('geodir_gd_uids', $accounts);
6537 6537
         return $accounts;
6538 6538
     }
6539 6539
     else
6540 6540
         return false;
6541 6541
 }
6542 6542
 
6543
-add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' );
6544
-function geodir_ga_deauthorize(){
6543
+add_action('wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize');
6544
+function geodir_ga_deauthorize() {
6545 6545
 
6546
-    if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
6546
+    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'gd_ga_deauthorize')) {
6547 6547
 
6548
-        die( 'Security check' );
6548
+        die('Security check');
6549 6549
 
6550 6550
     } else {
6551
-        update_option('geodir_ga_auth_token','');
6552
-        update_option('geodir_ga_auth_code','');
6553
-        update_option('geodir_gd_uids','');
6551
+        update_option('geodir_ga_auth_token', '');
6552
+        update_option('geodir_ga_auth_code', '');
6553
+        update_option('geodir_gd_uids', '');
6554 6554
 
6555 6555
 
6556 6556
         echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
Please login to merge, or discard this patch.