Test Failed
Pull Request — master (#380)
by Kiran
17:21
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.