Test Failed
Push — master ( 33c2aa...380661 )
by Stiofan
04:39
created
geodirectory-admin/admin_dummy_data_functions.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -19,151 +19,151 @@  discard block
 block discarded – undo
19 19
  * @global string $dummy_image_path The dummy image path.
20 20
  */
21 21
 function geodir_dummy_data_taxonomies($post_type,$category_array) {
22
-    global $wpdb, $dummy_image_path;
22
+	global $wpdb, $dummy_image_path;
23 23
 
24 24
 
25 25
 
26
-    $last_catid = '';
26
+	$last_catid = '';
27 27
 
28
-    $uploads = wp_upload_dir(); // Array of key => value pairs
28
+	$uploads = wp_upload_dir(); // Array of key => value pairs
29 29
 
30
-    for ($i = 0; $i < count($category_array); $i++) {
31
-        $parent_catid = 0;
32
-        if (is_array($category_array[$i])) {
33
-            $cat_name_arr = $category_array[$i];
34
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
35
-                $catname = $cat_name_arr[$j];
30
+	for ($i = 0; $i < count($category_array); $i++) {
31
+		$parent_catid = 0;
32
+		if (is_array($category_array[$i])) {
33
+			$cat_name_arr = $category_array[$i];
34
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
35
+				$catname = $cat_name_arr[$j];
36 36
 
37
-                if (!term_exists($catname, $post_type.'category')) {
38
-                    $last_catid = wp_insert_term($catname, $post_type.'category', $args = array('parent' => $parent_catid));
37
+				if (!term_exists($catname, $post_type.'category')) {
38
+					$last_catid = wp_insert_term($catname, $post_type.'category', $args = array('parent' => $parent_catid));
39 39
 
40
-                    if ($j == 0) {
41
-                        $parent_catid = $last_catid;
42
-                    }
40
+					if ($j == 0) {
41
+						$parent_catid = $last_catid;
42
+					}
43 43
 
44 44
 
45
-                    if (geodir_dummy_folder_exists())
46
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
47
-                    else
48
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
45
+					if (geodir_dummy_folder_exists())
46
+						$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
47
+					else
48
+						$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
49 49
 
50
-                    $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
50
+					$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
51 51
 
52
-                    $catname = str_replace(' ', '_', $catname);
53
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
52
+					$catname = str_replace(' ', '_', $catname);
53
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
54 54
 
55
-                    if (empty($uploaded['error'])) {
56
-                        $new_path = $uploaded['file'];
57
-                        $new_url = $uploaded['url'];
58
-                    }
55
+					if (empty($uploaded['error'])) {
56
+						$new_path = $uploaded['file'];
57
+						$new_url = $uploaded['url'];
58
+					}
59 59
 
60
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
61
-
62
-                    $attachment = array(
63
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
64
-                        'post_mime_type' => $wp_filetype['type'],
65
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
66
-                        'post_content' => '',
67
-                        'post_status' => 'inherit'
68
-                    );
69
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
70
-
71
-                    // you must first include the image.php file
72
-                    // for the function wp_generate_attachment_metadata() to work
73
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
74
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
75
-                    wp_update_attachment_metadata($attach_id, $attach_data);
76
-
77
-                    if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) {
78
-                        geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), $post_type);
79
-                    }
80
-                }
81
-            }
60
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
82 61
 
83
-        } else {
84
-            $catname = $category_array[$i];
62
+					$attachment = array(
63
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
64
+						'post_mime_type' => $wp_filetype['type'],
65
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
66
+						'post_content' => '',
67
+						'post_status' => 'inherit'
68
+					);
69
+					$attach_id = wp_insert_attachment($attachment, $new_path);
85 70
 
86
-            if (!term_exists($catname, $post_type.'category')) {
87
-                $last_catid = wp_insert_term($catname, $post_type.'category');
71
+					// you must first include the image.php file
72
+					// for the function wp_generate_attachment_metadata() to work
73
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
74
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
75
+					wp_update_attachment_metadata($attach_id, $attach_data);
88 76
 
89
-                if (geodir_dummy_folder_exists())
90
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
91
-                else
92
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
77
+					if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) {
78
+						geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), $post_type);
79
+					}
80
+				}
81
+			}
93 82
 
94
-                $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
83
+		} else {
84
+			$catname = $category_array[$i];
95 85
 
96
-                $catname = str_replace(' ', '_', $catname);
97
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
86
+			if (!term_exists($catname, $post_type.'category')) {
87
+				$last_catid = wp_insert_term($catname, $post_type.'category');
98 88
 
99
-                if (empty($uploaded['error'])) {
100
-                    $new_path = $uploaded['file'];
101
-                    $new_url = $uploaded['url'];
102
-                }
89
+				if (geodir_dummy_folder_exists())
90
+					$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
91
+				else
92
+					$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
103 93
 
104
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
94
+				$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
105 95
 
106
-                $attachment = array(
107
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
108
-                    'post_mime_type' => $wp_filetype['type'],
109
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
110
-                    'post_content' => '',
111
-                    'post_status' => 'inherit'
112
-                );
96
+				$catname = str_replace(' ', '_', $catname);
97
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
113 98
 
114
-                $attach_id = wp_insert_attachment($attachment, $new_path);
99
+				if (empty($uploaded['error'])) {
100
+					$new_path = $uploaded['file'];
101
+					$new_url = $uploaded['url'];
102
+				}
115 103
 
104
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
116 105
 
117
-                // you must first include the image.php file
118
-                // for the function wp_generate_attachment_metadata() to work
119
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
120
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
121
-                wp_update_attachment_metadata($attach_id, $attach_data);
106
+				$attachment = array(
107
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
108
+					'post_mime_type' => $wp_filetype['type'],
109
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
110
+					'post_content' => '',
111
+					'post_status' => 'inherit'
112
+				);
113
+
114
+				$attach_id = wp_insert_attachment($attachment, $new_path);
122 115
 
123
-                if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) {
124
-                    geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), $post_type);
125
-                }
126
-            }
127
-        }
128 116
 
129
-    }
117
+				// you must first include the image.php file
118
+				// for the function wp_generate_attachment_metadata() to work
119
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
120
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
121
+				wp_update_attachment_metadata($attach_id, $attach_data);
122
+
123
+				if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) {
124
+					geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), $post_type);
125
+				}
126
+			}
127
+		}
128
+
129
+	}
130 130
 }
131 131
 
132 132
 
133 133
 function geodir_dummy_data_types(){
134
-    $data =  array(
135
-        'standard_places' => array(
136
-            'name'=>__('Default','geodirectory'),
137
-            'count'=> 30
138
-        ),
139
-        'property_sale' => array(
140
-            'name'=>__('Property for sale','geodirectory'),
141
-            'count'=> 10
142
-        ),
143
-        'property_rent' => array(
144
-            'name'=>__('Property for rent','geodirectory'),
145
-            'count'=> 10
146
-        )
147
-    );
148
-
149
-    return apply_filters('geodir_dummy_data_types',$data );
134
+	$data =  array(
135
+		'standard_places' => array(
136
+			'name'=>__('Default','geodirectory'),
137
+			'count'=> 30
138
+		),
139
+		'property_sale' => array(
140
+			'name'=>__('Property for sale','geodirectory'),
141
+			'count'=> 10
142
+		),
143
+		'property_rent' => array(
144
+			'name'=>__('Property for rent','geodirectory'),
145
+			'count'=> 10
146
+		)
147
+	);
148
+
149
+	return apply_filters('geodir_dummy_data_types',$data );
150 150
 }
151 151
 
152 152
 
153 153
 function geodir_create_dummy_fields($fields)
154 154
 {
155 155
     
156
-    /**
157
-     * Filter the array of default custom fields DB table data.
158
-     *
159
-     * @since 1.0.0
160
-     * @param string $fields The default custom fields as an array.
161
-     */
162
-    $fields = apply_filters('geodir_before_dummy_custom_fields_saved', $fields);
163
-    foreach ($fields as $field_index => $field) {
164
-        geodir_custom_field_save($field);
165
-
166
-    }
156
+	/**
157
+	 * Filter the array of default custom fields DB table data.
158
+	 *
159
+	 * @since 1.0.0
160
+	 * @param string $fields The default custom fields as an array.
161
+	 */
162
+	$fields = apply_filters('geodir_before_dummy_custom_fields_saved', $fields);
163
+	foreach ($fields as $field_index => $field) {
164
+		geodir_custom_field_save($field);
165
+
166
+	}
167 167
 }
168 168
 
169 169
 /**
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function geodir_delete_dummy_posts($post_type,$data_type)
178 178
 {
179
-    global $wpdb, $plugin_prefix;
179
+	global $wpdb, $plugin_prefix;
180 180
 
181 181
 
182
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . $post_type."_detail WHERE post_dummy='1'");
182
+	$post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . $post_type."_detail WHERE post_dummy='1'");
183 183
 
184 184
 
185
-    foreach ($post_ids as $post_ids_obj) {
186
-        wp_delete_post($post_ids_obj->post_id);
187
-    }
185
+	foreach ($post_ids as $post_ids_obj) {
186
+		wp_delete_post($post_ids_obj->post_id);
187
+	}
188 188
 
189
-    //double check posts are deleted
190
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . $post_type. "_detail WHERE post_dummy='1'");
189
+	//double check posts are deleted
190
+	$wpdb->get_results("DELETE FROM " . $plugin_prefix . $post_type. "_detail WHERE post_dummy='1'");
191 191
 
192
-    update_option($post_type.'_dummy_data_type','');
192
+	update_option($post_type.'_dummy_data_type','');
193 193
 }
194 194
 
195 195
 /**
@@ -203,78 +203,78 @@  discard block
 block discarded – undo
203 203
 function geodir_insert_dummy_posts($post_type,$data_type,$item_index)
204 204
 {
205 205
 
206
-    ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
207
-    $data_types = geodir_dummy_data_types();
208
-
209
-    $total_count = 0;
210
-    global $dummy_post_index;
211
-    $dummy_post_index = $item_index;
212
-    foreach( $data_types as $key=>$val){
213
-        if($key==$data_type){
214
-            $total_count = $val['count'];
215
-            if($key=='standard_places'){
216
-                /**
217
-                 * Contains dummy post content.
218
-                 *
219
-                 * @since 1.0.0
220
-                 * @package GeoDirectory
221
-                 */
222
-                include_once( 'dummy-data/standard_places.php' );
223
-            }elseif($key=='property_sale'){
224
-                /**
225
-                 * Contains dummy property for sale post content.
226
-                 *
227
-                 * @since 1.6.11
228
-                 * @package GeoDirectory
229
-                 */
230
-                include_once( 'dummy-data/property_sale.php' );
231
-            }elseif($key=='property_rent'){
232
-                /**
233
-                 * Contains dummy property for sale post content.
234
-                 *
235
-                 * @since 1.6.11
236
-                 * @package GeoDirectory
237
-                 */
238
-                include_once( 'dummy-data/property_rent.php' );
239
-            }
240
-
241
-        }
242
-
243
-        do_action('geodir_insert_dummy_data_loop',$post_type,$data_type,$item_index);
244
-    }
245
-
246
-
247
-
248
-    // delete image cache on last entry
249
-    if($total_count == $item_index){
250
-        delete_transient( 'cached_dummy_images' );
251
-        flush_rewrite_rules();
252
-    }
206
+	ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
207
+	$data_types = geodir_dummy_data_types();
208
+
209
+	$total_count = 0;
210
+	global $dummy_post_index;
211
+	$dummy_post_index = $item_index;
212
+	foreach( $data_types as $key=>$val){
213
+		if($key==$data_type){
214
+			$total_count = $val['count'];
215
+			if($key=='standard_places'){
216
+				/**
217
+				 * Contains dummy post content.
218
+				 *
219
+				 * @since 1.0.0
220
+				 * @package GeoDirectory
221
+				 */
222
+				include_once( 'dummy-data/standard_places.php' );
223
+			}elseif($key=='property_sale'){
224
+				/**
225
+				 * Contains dummy property for sale post content.
226
+				 *
227
+				 * @since 1.6.11
228
+				 * @package GeoDirectory
229
+				 */
230
+				include_once( 'dummy-data/property_sale.php' );
231
+			}elseif($key=='property_rent'){
232
+				/**
233
+				 * Contains dummy property for sale post content.
234
+				 *
235
+				 * @since 1.6.11
236
+				 * @package GeoDirectory
237
+				 */
238
+				include_once( 'dummy-data/property_rent.php' );
239
+			}
240
+
241
+		}
242
+
243
+		do_action('geodir_insert_dummy_data_loop',$post_type,$data_type,$item_index);
244
+	}
245
+
246
+
247
+
248
+	// delete image cache on last entry
249
+	if($total_count == $item_index){
250
+		delete_transient( 'cached_dummy_images' );
251
+		flush_rewrite_rules();
252
+	}
253 253
 
254 254
 
255 255
 }
256 256
 
257 257
 
258 258
 if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
259
-    /**
260
-     * GeoDirectory dummy data installation.
261
-     *
262
-     * @since 1.0.0
263
-     * @package GeoDirectory
264
-     * @global object $wpdb WordPress Database object.
265
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
266
-     * @param string $post_type The post type.
267
-     */
268
-    function geodir_autoinstall_admin_header($post_type = 'gd_place')
269
-    {
270
-
271
-        global $wpdb, $plugin_prefix;
272
-
273
-        if (!geodir_is_default_location_set()) {
274
-            echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
275
-        } else {
276
-
277
-            ?>
259
+	/**
260
+	 * GeoDirectory dummy data installation.
261
+	 *
262
+	 * @since 1.0.0
263
+	 * @package GeoDirectory
264
+	 * @global object $wpdb WordPress Database object.
265
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
266
+	 * @param string $post_type The post type.
267
+	 */
268
+	function geodir_autoinstall_admin_header($post_type = 'gd_place')
269
+	{
270
+
271
+		global $wpdb, $plugin_prefix;
272
+
273
+		if (!geodir_is_default_location_set()) {
274
+			echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
275
+		} else {
276
+
277
+			?>
278 278
             <span class="gd-dummy-hint"><small><?php _e('*Hint*: Installing our Advanced Search addon FIRST will add extra search fields to non-default data types.','geodirectory');?></small></span>
279 279
             <table class="form-table gd-dummy-table">
280 280
                 <tbody>
@@ -286,78 +286,78 @@  discard block
 block discarded – undo
286 286
 
287 287
                 <?php
288 288
 
289
-                $cpts = geodir_get_posttypes('array');
289
+				$cpts = geodir_get_posttypes('array');
290 290
 
291
-                $data_types = geodir_dummy_data_types();
291
+				$data_types = geodir_dummy_data_types();
292 292
 
293
-                $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
293
+				$nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
294 294
 
295
-                foreach($cpts as $post_type=>$cpt){
295
+				foreach($cpts as $post_type=>$cpt){
296 296
 
297
-                    $data_types_for = apply_filters('geodir_dummy_date_types_for',$data_types,$post_type);
297
+					$data_types_for = apply_filters('geodir_dummy_date_types_for',$data_types,$post_type);
298 298
 
299 299
 
300
-                    $set_dt = get_option($post_type.'_dummy_data_type');
300
+					$set_dt = get_option($post_type.'_dummy_data_type');
301 301
 
302
-                    $count = 30;
302
+					$count = 30;
303 303
 
304
-                    geodir_add_column_if_not_exist($plugin_prefix . $post_type. "_detail", 'post_dummy', "enum( '1', '0' ) NULL DEFAULT '0'");
304
+					geodir_add_column_if_not_exist($plugin_prefix . $post_type. "_detail", 'post_dummy', "enum( '1', '0' ) NULL DEFAULT '0'");
305 305
 
306
-                    $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
306
+					$post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
307 307
 
308
-                    echo "<tr>";
309
-                    echo "<td><strong>".$cpt['labels']['name']."</strong></td>";
308
+					echo "<tr>";
309
+					echo "<td><strong>".$cpt['labels']['name']."</strong></td>";
310 310
 
311 311
 
312
-                    $select_disabled = $post_counts > 0 ? 'disabled' : '';
313
-                    echo "<td>";
314
-                    echo "<select id='".$post_type."_data_type' onchange='geodir_dummy_set_count(this,\"$post_type\");' $select_disabled>";
312
+					$select_disabled = $post_counts > 0 ? 'disabled' : '';
313
+					echo "<td>";
314
+					echo "<select id='".$post_type."_data_type' onchange='geodir_dummy_set_count(this,\"$post_type\");' $select_disabled>";
315 315
 
316
-                    foreach($data_types_for as $key=>$val){
317
-                        $selected = ($key==$set_dt) ? "selected='selected'" : '';
318
-                        if($selected || count($data_types_for)==1){$count = $val['count'];}
319
-                        echo "<option $selected value='$key' data-count='".$val['count']."'>".$val['name']."</option>";
320
-                    }
321
-                    echo "</select>";
322
-
323
-                    $select_display = $post_counts > 0 ? 'display:none;' : '';
324
-                    echo "<select id='".$post_type."_data_type_count' style='$select_display' >";
325
-                    $x = 1;
326
-                    while($x <= $count){
327
-                        $selected = ($x==$count) ? "selected='selected'" : '';
328
-                        echo "<option $selected value='$x'>".$x."</option>";
329
-                        $x++;
330
-                    }
331
-                    echo "</select>";
332
-                    echo "</td>";
316
+					foreach($data_types_for as $key=>$val){
317
+						$selected = ($key==$set_dt) ? "selected='selected'" : '';
318
+						if($selected || count($data_types_for)==1){$count = $val['count'];}
319
+						echo "<option $selected value='$key' data-count='".$val['count']."'>".$val['name']."</option>";
320
+					}
321
+					echo "</select>";
333 322
 
323
+					$select_display = $post_counts > 0 ? 'display:none;' : '';
324
+					echo "<select id='".$post_type."_data_type_count' style='$select_display' >";
325
+					$x = 1;
326
+					while($x <= $count){
327
+						$selected = ($x==$count) ? "selected='selected'" : '';
328
+						echo "<option $selected value='$x'>".$x."</option>";
329
+						$x++;
330
+					}
331
+					echo "</select>";
332
+					echo "</td>";
334 333
 
335 334
 
336 335
 
337 336
 
338
-                    if($post_counts > 0){
339
-                        echo '<td><input type="button" value="'.__('Remove data','geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>';
340
-                    }else{
341
-                        echo '<td><input type="button" value="'.__('Insert data','geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>';
342
-                    }
343 337
 
344
-                    echo "</tr>";
345
-                    //print_r($cpt);
346
-                }
338
+					if($post_counts > 0){
339
+						echo '<td><input type="button" value="'.__('Remove data','geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>';
340
+					}else{
341
+						echo '<td><input type="button" value="'.__('Insert data','geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>';
342
+					}
343
+
344
+					echo "</tr>";
345
+					//print_r($cpt);
346
+				}
347 347
 
348
-                ?>
348
+				?>
349 349
                 </tbody>
350 350
             </table>
351 351
             <?php
352 352
 
353 353
 
354
-            $default_location = geodir_get_default_location();
355
-            $city = isset($default_location->city) ? $default_location->city : '';
356
-            $region = isset($default_location->region) ? $default_location->region : '';
357
-            $country = isset($default_location->country) ? $default_location->country : '';
358
-            $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
359
-            $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
360
-            ?>
354
+			$default_location = geodir_get_default_location();
355
+			$city = isset($default_location->city) ? $default_location->city : '';
356
+			$region = isset($default_location->region) ? $default_location->region : '';
357
+			$country = isset($default_location->country) ? $default_location->country : '';
358
+			$city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
359
+			$city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
360
+			?>
361 361
             <script type="text/javascript">
362 362
 
363 363
                 function geodir_dummy_set_count(data,cpt){
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                 }
534 534
             </script>
535 535
             <?php
536
-        }
537
-    }
536
+		}
537
+	}
538 538
 }
539 539
 
Please login to merge, or discard this patch.
geodirectory-admin/admin_functions.php 1 patch
Indentation   +2908 added lines, -2908 removed lines patch added patch discarded remove patch
@@ -13,125 +13,125 @@  discard block
 block discarded – undo
13 13
  * @package GeoDirectory
14 14
  */
15 15
 function geodir_deactivation() {
16
-    // Update installed variable
17
-    update_option("geodir_installed", 0);
16
+	// Update installed variable
17
+	update_option("geodir_installed", 0);
18 18
 
19
-    // Remove rewrite rules and then recreate rewrite rules.
20
-    flush_rewrite_rules();
19
+	// Remove rewrite rules and then recreate rewrite rules.
20
+	flush_rewrite_rules();
21 21
 }
22 22
 
23 23
 if (!function_exists('geodir_admin_styles')) {
24
-    /**
25
-     * Enqueue Admin Styles.
26
-     *
27
-     * @since 1.0.0
28
-     * @package GeoDirectory
29
-     */
30
-    function geodir_admin_styles() {
31
-        wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
32
-        wp_enqueue_style('geodirectory-admin-css');
24
+	/**
25
+	 * Enqueue Admin Styles.
26
+	 *
27
+	 * @since 1.0.0
28
+	 * @package GeoDirectory
29
+	 */
30
+	function geodir_admin_styles() {
31
+		wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
32
+		wp_enqueue_style('geodirectory-admin-css');
33 33
 
34
-        wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
35
-        wp_enqueue_style('geodirectory-frontend-style');
34
+		wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
35
+		wp_enqueue_style('geodirectory-frontend-style');
36 36
 
37
-        wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
38
-        wp_enqueue_style('geodir-chosen-style');
37
+		wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
38
+		wp_enqueue_style('geodir-chosen-style');
39 39
 
40
-        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
41
-        wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
40
+		wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
41
+		wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
42 42
 
43
-        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
44
-        wp_enqueue_style('geodirectory-jquery-ui-css');
43
+		wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
44
+		wp_enqueue_style('geodirectory-jquery-ui-css');
45 45
 
46
-        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
47
-        wp_enqueue_style('geodirectory-custom-fields-css');
46
+		wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
47
+		wp_enqueue_style('geodirectory-custom-fields-css');
48 48
 
49
-        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
50
-        wp_enqueue_style('geodirectory-pluplodar-css');
49
+		wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
50
+		wp_enqueue_style('geodirectory-pluplodar-css');
51 51
 
52
-        wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
53
-        wp_enqueue_style('geodir-rating-style');
52
+		wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
53
+		wp_enqueue_style('geodir-rating-style');
54 54
 
55
-        wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
56
-        wp_enqueue_style('geodir-rtl-style');
57
-    }
55
+		wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
56
+		wp_enqueue_style('geodir-rtl-style');
57
+	}
58 58
 }
59 59
 
60 60
 if (!function_exists('geodir_admin_styles_req')) {
61
-    /**
62
-     * Loads stylesheets from CDN.
63
-     *
64
-     * @since 1.0.0
65
-     * @package GeoDirectory
66
-     */
67
-    function geodir_admin_styles_req()
68
-    {
61
+	/**
62
+	 * Loads stylesheets from CDN.
63
+	 *
64
+	 * @since 1.0.0
65
+	 * @package GeoDirectory
66
+	 */
67
+	function geodir_admin_styles_req()
68
+	{
69 69
 
70
-        wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
71
-        wp_enqueue_style('font-awesome');
70
+		wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
71
+		wp_enqueue_style('font-awesome');
72 72
 
73
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
74
-        wp_enqueue_script('geodirectory-admin');
73
+		wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
74
+		wp_enqueue_script('geodirectory-admin');
75 75
 
76
-    }
76
+	}
77 77
 }
78 78
 
79 79
 if (!function_exists('geodir_admin_scripts')) {
80
-    /**
81
-     * Enqueue Admin Scripts.
82
-     *
83
-     * @since 1.0.0
84
-     * @package GeoDirectory
85
-     */
86
-    function geodir_admin_scripts()
87
-    {
88
-        $geodir_map_name = geodir_map_name();
80
+	/**
81
+	 * Enqueue Admin Scripts.
82
+	 *
83
+	 * @since 1.0.0
84
+	 * @package GeoDirectory
85
+	 */
86
+	function geodir_admin_scripts()
87
+	{
88
+		$geodir_map_name = geodir_map_name();
89 89
         
90
-        wp_enqueue_script('jquery');
90
+		wp_enqueue_script('jquery');
91 91
 
92
-        wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
92
+		wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
93 93
 
94
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
95
-        wp_enqueue_script('chosen');
94
+		wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
95
+		wp_enqueue_script('chosen');
96 96
 
97
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
98
-        wp_enqueue_script('geodirectory-choose-ajax');
97
+		wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
98
+		wp_enqueue_script('geodirectory-choose-ajax');
99 99
 
100
-        if (isset($_REQUEST['listing_type'])) {
101
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
102
-        }
100
+		if (isset($_REQUEST['listing_type'])) {
101
+			wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
102
+		}
103 103
 
104
-        wp_enqueue_script('geodirectory-custom-fields-script');
105
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
104
+		wp_enqueue_script('geodirectory-custom-fields-script');
105
+		$plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
106 106
 
107
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
107
+		wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
108 108
 
109
-        if (in_array($geodir_map_name, array('auto', 'google'))) {
110
-            $map_lang = "&language=" . geodir_get_map_default_language();
111
-            $map_key = "&key=" . geodir_get_map_api_key();
112
-            /** This filter is documented in geodirectory_template_tags.php */
113
-            $map_extra = apply_filters('geodir_googlemap_script_extra', '');
114
-            wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
115
-        }
109
+		if (in_array($geodir_map_name, array('auto', 'google'))) {
110
+			$map_lang = "&language=" . geodir_get_map_default_language();
111
+			$map_key = "&key=" . geodir_get_map_api_key();
112
+			/** This filter is documented in geodirectory_template_tags.php */
113
+			$map_extra = apply_filters('geodir_googlemap_script_extra', '');
114
+			wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
115
+		}
116 116
         
117
-        if ($geodir_map_name == 'osm') {
118
-            // Leaflet OpenStreetMap
119
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
120
-            wp_enqueue_style('geodirectory-leaflet-style');
117
+		if ($geodir_map_name == 'osm') {
118
+			// Leaflet OpenStreetMap
119
+			wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
120
+			wp_enqueue_style('geodirectory-leaflet-style');
121 121
                 
122
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
123
-            wp_enqueue_script('geodirectory-leaflet-script');
122
+			wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
123
+			wp_enqueue_script('geodirectory-leaflet-script');
124 124
             
125
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
126
-            wp_enqueue_script('geodirectory-leaflet-geo-script');
127
-        }
128
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
125
+			wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
126
+			wp_enqueue_script('geodirectory-leaflet-geo-script');
127
+		}
128
+		wp_enqueue_script( 'jquery-ui-autocomplete' );
129 129
         
130
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
131
-        wp_enqueue_script('geodirectory-goMap-script');
130
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
131
+		wp_enqueue_script('geodirectory-goMap-script');
132 132
 
133
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
134
-        wp_enqueue_script('geodirectory-goMap-script');
133
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
134
+		wp_enqueue_script('geodirectory-goMap-script');
135 135
 
136 136
 		// font awesome rating script
137 137
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
@@ -142,167 +142,167 @@  discard block
 block discarded – undo
142 142
 			wp_enqueue_script('geodir-jRating-js');
143 143
 		}
144 144
 
145
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
146
-        wp_enqueue_script('geodir-on-document-load');
147
-
148
-
149
-        // SCRIPT FOR UPLOAD
150
-        wp_enqueue_script('plupload-all');
151
-        wp_enqueue_script('jquery-ui-sortable');
152
-
153
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
154
-        wp_enqueue_script('geodirectory-plupload-script');
155
-
156
-        // SCRIPT FOR UPLOAD END
157
-
158
-
159
-        // place js config array for plupload
160
-        $plupload_init = array(
161
-            'runtimes' => 'html5,silverlight,flash,html4',
162
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
163
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
164
-            'drop_element' => 'dropbox', // will be adjusted per uploader
165
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
166
-            'multiple_queues' => true,
167
-            'max_file_size' => geodir_max_upload_size(),
168
-            'url' => admin_url('admin-ajax.php'),
169
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
170
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
171
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
172
-            'multipart' => true,
173
-            'urlstream_upload' => true,
174
-            'multi_selection' => false, // will be added per uploader
175
-            // additional post data to send to our ajax hook
176
-            'multipart_params' => array(
177
-                '_ajax_nonce' => "", // will be added per uploader
178
-                'action' => 'plupload_action', // the ajax action name
179
-                'imgid' => 0 // will be added per uploader
180
-            )
181
-        );
182
-        $base_plupload_config = json_encode($plupload_init);
183
-
184
-
185
-        $thumb_img_arr = array();
186
-
187
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
188
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
189
-
190
-        $totImg = '';
191
-        $image_limit = '';
192
-        if (!empty($thumb_img_arr)) {
193
-            $totImg = count($thumb_img_arr);
194
-        }
145
+		wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
146
+		wp_enqueue_script('geodir-on-document-load');
147
+
148
+
149
+		// SCRIPT FOR UPLOAD
150
+		wp_enqueue_script('plupload-all');
151
+		wp_enqueue_script('jquery-ui-sortable');
152
+
153
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
154
+		wp_enqueue_script('geodirectory-plupload-script');
155
+
156
+		// SCRIPT FOR UPLOAD END
157
+
158
+
159
+		// place js config array for plupload
160
+		$plupload_init = array(
161
+			'runtimes' => 'html5,silverlight,flash,html4',
162
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
163
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
164
+			'drop_element' => 'dropbox', // will be adjusted per uploader
165
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
166
+			'multiple_queues' => true,
167
+			'max_file_size' => geodir_max_upload_size(),
168
+			'url' => admin_url('admin-ajax.php'),
169
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
170
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
171
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
172
+			'multipart' => true,
173
+			'urlstream_upload' => true,
174
+			'multi_selection' => false, // will be added per uploader
175
+			// additional post data to send to our ajax hook
176
+			'multipart_params' => array(
177
+				'_ajax_nonce' => "", // will be added per uploader
178
+				'action' => 'plupload_action', // the ajax action name
179
+				'imgid' => 0 // will be added per uploader
180
+			)
181
+		);
182
+		$base_plupload_config = json_encode($plupload_init);
183
+
184
+
185
+		$thumb_img_arr = array();
186
+
187
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
188
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
189
+
190
+		$totImg = '';
191
+		$image_limit = '';
192
+		if (!empty($thumb_img_arr)) {
193
+			$totImg = count($thumb_img_arr);
194
+		}
195 195
 
196
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
197
-            'totalImg' => $totImg,
198
-            'image_limit' => $image_limit,
199
-            'upload_img_size' => geodir_max_upload_size());
196
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
197
+			'totalImg' => $totImg,
198
+			'image_limit' => $image_limit,
199
+			'upload_img_size' => geodir_max_upload_size());
200 200
 
201
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
201
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
202 202
 
203
-        $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
204
-        wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
203
+		$ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
204
+		wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
205 205
 
206 206
 
207
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
208
-        wp_enqueue_script('geodirectory-admin-script');
207
+		wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
208
+		wp_enqueue_script('geodirectory-admin-script');
209 209
 
210
-        wp_enqueue_style('farbtastic');
211
-        wp_enqueue_script('farbtastic');
210
+		wp_enqueue_style('farbtastic');
211
+		wp_enqueue_script('farbtastic');
212 212
 
213
-        $screen = get_current_screen();
214
-        if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
215
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
216
-        }
213
+		$screen = get_current_screen();
214
+		if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
215
+			wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
216
+		}
217 217
 
218
-        $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
219
-        wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
218
+		$ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
219
+		wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
220 220
 
221
-    }
221
+	}
222 222
 }
223 223
 
224 224
 if (!function_exists('geodir_admin_menu')) {
225
-    /**
226
-     * Admin Menus
227
-     *
228
-     * Sets up the admin menus in wordpress.
229
-     *
230
-     * @since 1.0.0
231
-     * @package GeoDirectory
232
-     * @global array $menu Menu array.
233
-     * @global object $geodirectory GeoDirectory plugin object.
234
-     */
235
-    function geodir_admin_menu()
236
-    {
237
-        global $menu, $geodirectory;
225
+	/**
226
+	 * Admin Menus
227
+	 *
228
+	 * Sets up the admin menus in wordpress.
229
+	 *
230
+	 * @since 1.0.0
231
+	 * @package GeoDirectory
232
+	 * @global array $menu Menu array.
233
+	 * @global object $geodirectory GeoDirectory plugin object.
234
+	 */
235
+	function geodir_admin_menu()
236
+	{
237
+		global $menu, $geodirectory;
238 238
 
239
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
239
+		if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
240 240
 
241
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
241
+		add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
242 242
 
243 243
 
244
-    }
244
+	}
245 245
 }
246 246
 
247 247
 if (!function_exists('geodir_admin_menu_order')) {
248
-    /**
249
-     * Order admin menus.
250
-     *
251
-     * @since 1.0.0
252
-     * @package GeoDirectory
253
-     * @param array $menu_order Menu order array.
254
-     * @return array Modified menu order array.
255
-     */
256
-    function geodir_admin_menu_order($menu_order)
257
-    {
258
-
259
-        // Initialize our custom order array
260
-        $geodir_menu_order = array();
261
-
262
-        // Get the index of our custom separator
263
-        $geodir_separator = array_search('separator-geodirectory', $menu_order);
264
-
265
-        // Get index of posttype menu
266
-        $post_types = geodir_get_posttypes();
267
-
268
-        // Loop through menu order and do some rearranging
269
-        foreach ($menu_order as $index => $item) :
270
-
271
-            if ((('geodirectory') == $item)) :
272
-                $geodir_menu_order[] = 'separator-geodirectory';
273
-                if (!empty($post_types)) {
274
-                    foreach ($post_types as $post_type) {
275
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
276
-                    }
277
-                }
278
-                $geodir_menu_order[] = $item;
248
+	/**
249
+	 * Order admin menus.
250
+	 *
251
+	 * @since 1.0.0
252
+	 * @package GeoDirectory
253
+	 * @param array $menu_order Menu order array.
254
+	 * @return array Modified menu order array.
255
+	 */
256
+	function geodir_admin_menu_order($menu_order)
257
+	{
279 258
 
280
-                unset($menu_order[$geodir_separator]);
281
-            //unset( $menu_order[$geodir_places] );
282
-            elseif (!in_array($item, array('separator-geodirectory'))) :
283
-                $geodir_menu_order[] = $item;
284
-            endif;
259
+		// Initialize our custom order array
260
+		$geodir_menu_order = array();
285 261
 
286
-        endforeach;
262
+		// Get the index of our custom separator
263
+		$geodir_separator = array_search('separator-geodirectory', $menu_order);
287 264
 
288
-        // Return order
289
-        return $geodir_menu_order;
290
-    }
265
+		// Get index of posttype menu
266
+		$post_types = geodir_get_posttypes();
267
+
268
+		// Loop through menu order and do some rearranging
269
+		foreach ($menu_order as $index => $item) :
270
+
271
+			if ((('geodirectory') == $item)) :
272
+				$geodir_menu_order[] = 'separator-geodirectory';
273
+				if (!empty($post_types)) {
274
+					foreach ($post_types as $post_type) {
275
+						$geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
276
+					}
277
+				}
278
+				$geodir_menu_order[] = $item;
279
+
280
+				unset($menu_order[$geodir_separator]);
281
+			//unset( $menu_order[$geodir_places] );
282
+			elseif (!in_array($item, array('separator-geodirectory'))) :
283
+				$geodir_menu_order[] = $item;
284
+			endif;
285
+
286
+		endforeach;
287
+
288
+		// Return order
289
+		return $geodir_menu_order;
290
+	}
291 291
 }
292 292
 
293 293
 if (!function_exists('geodir_admin_custom_menu_order')) {
294
-    /**
295
-     * Enables custom menu order.
296
-     *
297
-     * @since 1.0.0
298
-     * @package GeoDirectory
299
-     * @return bool
300
-     */
301
-    function geodir_admin_custom_menu_order()
302
-    {
303
-        if (!current_user_can('manage_options')) return false;
304
-        return true;
305
-    }
294
+	/**
295
+	 * Enables custom menu order.
296
+	 *
297
+	 * @since 1.0.0
298
+	 * @package GeoDirectory
299
+	 * @return bool
300
+	 */
301
+	function geodir_admin_custom_menu_order()
302
+	{
303
+		if (!current_user_can('manage_options')) return false;
304
+		return true;
305
+	}
306 306
 }
307 307
 
308 308
 /**
@@ -313,51 +313,51 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function geodir_before_admin_panel()
315 315
 {
316
-    if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
317
-        echo '<div id="message" class="updated fade">
316
+	if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
317
+		echo '<div id="message" class="updated fade">
318 318
                         <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
319 319
                         <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
320 320
                 </div>';
321 321
 
322
-    }
322
+	}
323 323
 
324
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
325
-        switch ($_REQUEST['msg']) {
326
-            case 'success':
327
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
328
-                flush_rewrite_rules(false);
324
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
325
+		switch ($_REQUEST['msg']) {
326
+			case 'success':
327
+				echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
328
+				flush_rewrite_rules(false);
329 329
 
330
-                break;
330
+				break;
331 331
 			case 'fail':
332 332
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
333 333
 				
334 334
 				if ($gderr == 21)
335
-			    	echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
335
+					echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
336 336
 				else
337 337
 					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
338
-                break;
339
-        }
340
-    }
338
+				break;
339
+		}
340
+	}
341 341
 
342
-    $geodir_load_map = get_option('geodir_load_map');
343
-    $need_map_key = false;
344
-    if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
345
-        $need_map_key = true;
346
-    }
342
+	$geodir_load_map = get_option('geodir_load_map');
343
+	$need_map_key = false;
344
+	if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
345
+		$need_map_key = true;
346
+	}
347 347
 
348
-    if (!geodir_get_map_api_key() && $need_map_key) {
349
-        echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
350
-    }
348
+	if (!geodir_get_map_api_key() && $need_map_key) {
349
+		echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
350
+	}
351 351
 
352
-    if (!geodir_is_default_location_set()) {
353
-        echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
352
+	if (!geodir_is_default_location_set()) {
353
+		echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
354 354
 
355
-    }
355
+	}
356 356
 
357
-    if (!function_exists('curl_init')) {
358
-        echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
357
+	if (!function_exists('curl_init')) {
358
+		echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
359 359
 
360
-    }
360
+	}
361 361
 
362 362
 
363 363
 
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
  */
375 375
 function geodir_handle_option_form_submit($current_tab)
376 376
 {
377
-    global $geodir_settings;
378
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
379
-        /**
380
-         * Contains settings array for current tab.
381
-         *
382
-         * @since 1.0.0
383
-         * @package GeoDirectory
384
-         */
385
-        include_once('option-pages/' . $current_tab . '_array.php');
386
-    }
387
-    if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
388
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
377
+	global $geodir_settings;
378
+	if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
379
+		/**
380
+		 * Contains settings array for current tab.
381
+		 *
382
+		 * @since 1.0.0
383
+		 * @package GeoDirectory
384
+		 */
385
+		include_once('option-pages/' . $current_tab . '_array.php');
386
+	}
387
+	if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
388
+		if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
389
+		if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
390 390
 		
391 391
 		/**
392 392
 		 * Fires before updating geodirectory admin settings.
@@ -398,38 +398,38 @@  discard block
 block discarded – undo
398 398
 		 */
399 399
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
400 400
 		
401
-        if (!empty($geodir_settings[$current_tab]))
402
-            geodir_update_options($geodir_settings[$current_tab]);
401
+		if (!empty($geodir_settings[$current_tab]))
402
+			geodir_update_options($geodir_settings[$current_tab]);
403 403
 
404
-        /**
405
-         * Called after GeoDirectory options settings are updated.
406
-         *
407
-         * @since 1.0.0
408
-         * @param array $geodir_settings The array of GeoDirectory settings.
409
-         * @see 'geodir_before_update_options'
410
-         */
411
-        do_action('geodir_update_options', $geodir_settings);
404
+		/**
405
+		 * Called after GeoDirectory options settings are updated.
406
+		 *
407
+		 * @since 1.0.0
408
+		 * @param array $geodir_settings The array of GeoDirectory settings.
409
+		 * @see 'geodir_before_update_options'
410
+		 */
411
+		do_action('geodir_update_options', $geodir_settings);
412 412
 
413
-        /**
414
-         * Called after GeoDirectory options settings are updated.
415
-         *
416
-         * Provides tab specific settings.
417
-         *
418
-         * @since 1.0.0
419
-         * @param string $current_tab The current settings tab name.
420
-         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
421
-         */
422
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
413
+		/**
414
+		 * Called after GeoDirectory options settings are updated.
415
+		 *
416
+		 * Provides tab specific settings.
417
+		 *
418
+		 * @since 1.0.0
419
+		 * @param string $current_tab The current settings tab name.
420
+		 * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
421
+		 */
422
+		do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
423 423
 
424
-        flush_rewrite_rules(false);
424
+		flush_rewrite_rules(false);
425 425
 
426
-        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
426
+		$current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
427 427
 
428
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
428
+		$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
429 429
 
430
-        wp_redirect($redirect_url);
431
-        exit();
432
-    endif;
430
+		wp_redirect($redirect_url);
431
+		exit();
432
+	endif;
433 433
 
434 434
 
435 435
 }
@@ -447,144 +447,144 @@  discard block
 block discarded – undo
447 447
  * @return bool Returns true if saved.
448 448
  */
449 449
 function geodir_update_options($options, $dummy = false) {
450
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
450
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
451 451
 
452
-    foreach ($options as $value) {
453
-        if ($dummy && isset($value['std']))
454
-            $_POST[$value['id']] = $value['std'];
452
+	foreach ($options as $value) {
453
+		if ($dummy && isset($value['std']))
454
+			$_POST[$value['id']] = $value['std'];
455 455
 
456 456
 
457
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
457
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
458 458
 
459
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
460
-                update_option($value['id'], $_POST[$value['id']]);
461
-            } else {
462
-                update_option($value['id'], 0);
463
-            }
459
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
460
+				update_option($value['id'], $_POST[$value['id']]);
461
+			} else {
462
+				update_option($value['id'], 0);
463
+			}
464 464
 
465
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
465
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
466 466
 
467
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
468
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
469
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
470
-                if (isset($_POST[$value['id'] . '_crop'])) :
471
-                    update_option($value['id'] . '_crop', 1);
472
-                else :
473
-                    update_option($value['id'] . '_crop', 0);
474
-                endif;
475
-            } else {
476
-                update_option($value['id'] . '_width', $value['std']);
477
-                update_option($value['id'] . '_height', $value['std']);
478
-                update_option($value['id'] . '_crop', 1);
479
-            }
467
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
468
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
469
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
470
+				if (isset($_POST[$value['id'] . '_crop'])) :
471
+					update_option($value['id'] . '_crop', 1);
472
+				else :
473
+					update_option($value['id'] . '_crop', 0);
474
+				endif;
475
+			} else {
476
+				update_option($value['id'] . '_width', $value['std']);
477
+				update_option($value['id'] . '_height', $value['std']);
478
+				update_option($value['id'] . '_crop', 1);
479
+			}
480 480
 
481
-        elseif (isset($value['type']) && $value['type'] == 'map') :
482
-            $post_types = array();
483
-            $categories = array();
481
+		elseif (isset($value['type']) && $value['type'] == 'map') :
482
+			$post_types = array();
483
+			$categories = array();
484 484
 
485
-            if (!empty($_POST['home_map_post_types'])) :
486
-                foreach ($_POST['home_map_post_types'] as $post_type) :
487
-                    $post_types[] = $post_type;
488
-                endforeach;
489
-            endif;
485
+			if (!empty($_POST['home_map_post_types'])) :
486
+				foreach ($_POST['home_map_post_types'] as $post_type) :
487
+					$post_types[] = $post_type;
488
+				endforeach;
489
+			endif;
490 490
 
491
-            update_option('geodir_exclude_post_type_on_map', $post_types);
491
+			update_option('geodir_exclude_post_type_on_map', $post_types);
492 492
 
493
-            if (!empty($_POST['post_category'])) :
494
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
495
-                    $categories[$texonomy] = array();
496
-                    foreach ($cat_arr as $category) :
497
-                        $categories[$texonomy][] = $category;
498
-                    endforeach;
499
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
500
-                endforeach;
501
-            endif;
502
-            update_option('geodir_exclude_cat_on_map', $categories);
503
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
504
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
493
+			if (!empty($_POST['post_category'])) :
494
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
495
+					$categories[$texonomy] = array();
496
+					foreach ($cat_arr as $category) :
497
+						$categories[$texonomy][] = $category;
498
+					endforeach;
499
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
500
+				endforeach;
501
+			endif;
502
+			update_option('geodir_exclude_cat_on_map', $categories);
503
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
504
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
505 505
 
506 506
 
507
-            if (!empty($_POST['geodir_default_map_language'])):
508
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
509
-            endif;
507
+			if (!empty($_POST['geodir_default_map_language'])):
508
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
509
+			endif;
510 510
 
511 511
 
512
-            if (!empty($_POST['geodir_default_map_search_pt'])):
513
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
514
-            endif;
512
+			if (!empty($_POST['geodir_default_map_search_pt'])):
513
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
514
+			endif;
515 515
 
516 516
 
517
-        elseif (isset($value['type']) && $value['type'] == 'file') :
517
+		elseif (isset($value['type']) && $value['type'] == 'file') :
518 518
 
519 519
 
520
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
520
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
521 521
 
522
-                if (get_option($value['id'])) {
523
-                    $image_name_arr = explode('/', get_option($value['id']));
524
-                    $noimg_name = end($image_name_arr);
525
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
526
-                    if (file_exists($img_path))
527
-                        unlink($img_path);
528
-                }
522
+				if (get_option($value['id'])) {
523
+					$image_name_arr = explode('/', get_option($value['id']));
524
+					$noimg_name = end($image_name_arr);
525
+					$img_path = $uploads['path'] . '/' . $noimg_name;
526
+					if (file_exists($img_path))
527
+						unlink($img_path);
528
+				}
529 529
 
530
-                update_option($value['id'], '');
531
-            }
530
+				update_option($value['id'], '');
531
+			}
532 532
 
533
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
534
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
535
-
536
-            if (!empty($filename)):
537
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
538
-                $uplaods = array();
539
-
540
-                foreach ($uploadedfile as $key => $uplaod):
541
-                    if ($key == 'name'):
542
-                        $uplaods[$key] = $filename;
543
-                    else :
544
-                        $uplaods[$key] = $uplaod;
545
-                    endif;
546
-                endforeach;
547
-
548
-                $uploads = wp_upload_dir();
549
-
550
-                if (get_option($value['id'])) {
551
-                    $image_name_arr = explode('/', get_option($value['id']));
552
-                    $noimg_name = end($image_name_arr);
553
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
554
-                    if (file_exists($img_path))
555
-                        unlink($img_path);
556
-                }
533
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
534
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
535
+
536
+			if (!empty($filename)):
537
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
538
+				$uplaods = array();
539
+
540
+				foreach ($uploadedfile as $key => $uplaod):
541
+					if ($key == 'name'):
542
+						$uplaods[$key] = $filename;
543
+					else :
544
+						$uplaods[$key] = $uplaod;
545
+					endif;
546
+				endforeach;
547
+
548
+				$uploads = wp_upload_dir();
549
+
550
+				if (get_option($value['id'])) {
551
+					$image_name_arr = explode('/', get_option($value['id']));
552
+					$noimg_name = end($image_name_arr);
553
+					$img_path = $uploads['path'] . '/' . $noimg_name;
554
+					if (file_exists($img_path))
555
+						unlink($img_path);
556
+				}
557 557
 
558
-                $upload_overrides = array('test_form' => false);
559
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
558
+				$upload_overrides = array('test_form' => false);
559
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
560 560
 
561
-                update_option($value['id'], $movefile['url']);
561
+				update_option($value['id'], $movefile['url']);
562 562
 
563
-            endif;
563
+			endif;
564 564
 
565
-            if (!get_option($value['id']) && isset($value['value'])):
566
-                update_option($value['id'], $value['value']);
567
-            endif;
565
+			if (!get_option($value['id']) && isset($value['value'])):
566
+				update_option($value['id'], $value['value']);
567
+			endif;
568 568
 
569 569
 
570
-        else :
571
-            // same menu setting per theme.
572
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
573
-                $theme = wp_get_theme();
574
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
575
-            }
570
+		else :
571
+			// same menu setting per theme.
572
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
573
+				$theme = wp_get_theme();
574
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
575
+			}
576 576
 
577
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
578
-                update_option($value['id'], $_POST[$value['id']]);
579
-            } else {
580
-                delete_option($value['id']);
581
-            }
577
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
578
+				update_option($value['id'], $_POST[$value['id']]);
579
+			} else {
580
+				delete_option($value['id']);
581
+			}
582 582
 
583
-        endif;
584
-    }
585
-    if ($dummy)
586
-        $_POST = array();
587
-    return true;
583
+		endif;
584
+	}
585
+	if ($dummy)
586
+		$_POST = array();
587
+	return true;
588 588
 
589 589
 }
590 590
 
@@ -633,33 +633,33 @@  discard block
 block discarded – undo
633 633
 function places_custom_fields_tab($tabs)
634 634
 {
635 635
 
636
-    $geodir_post_types = get_option('geodir_post_types');
636
+	$geodir_post_types = get_option('geodir_post_types');
637 637
 
638
-    if (!empty($geodir_post_types)) {
638
+	if (!empty($geodir_post_types)) {
639 639
 
640
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
640
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
641 641
 
642
-            $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory');
642
+			$listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory');
643 643
 
644
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
645
-                'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
646
-                'subtabs' => array(
647
-                    array('subtab' => 'custom_fields',
648
-                        'label' => __('Custom Fields', 'geodirectory'),
649
-                        'request' => array('listing_type' => $geodir_post_type)),
650
-                    array('subtab' => 'sorting_options',
651
-                        'label' => __('Sorting Options', 'geodirectory'),
652
-                        'request' => array('listing_type' => $geodir_post_type)),
653
-                ),
654
-                'tab_index' => 9,
655
-                'request' => array('listing_type' => $geodir_post_type)
656
-            );
644
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
645
+				'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
646
+				'subtabs' => array(
647
+					array('subtab' => 'custom_fields',
648
+						'label' => __('Custom Fields', 'geodirectory'),
649
+						'request' => array('listing_type' => $geodir_post_type)),
650
+					array('subtab' => 'sorting_options',
651
+						'label' => __('Sorting Options', 'geodirectory'),
652
+						'request' => array('listing_type' => $geodir_post_type)),
653
+				),
654
+				'tab_index' => 9,
655
+				'request' => array('listing_type' => $geodir_post_type)
656
+			);
657 657
 
658
-        endforeach;
658
+		endforeach;
659 659
 
660
-    }
660
+	}
661 661
 
662
-    return $tabs;
662
+	return $tabs;
663 663
 }
664 664
 
665 665
 
@@ -675,9 +675,9 @@  discard block
 block discarded – undo
675 675
  */
676 676
 function geodir_tools_setting_tab($tabs)
677 677
 {
678
-    wp_enqueue_script( 'jquery-ui-progressbar' );
679
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
680
-    return $tabs;
678
+	wp_enqueue_script( 'jquery-ui-progressbar' );
679
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
680
+	return $tabs;
681 681
 }
682 682
 
683 683
 /**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
  */
693 693
 function geodir_compatibility_setting_tab($tabs)
694 694
 {
695
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
696
-    return $tabs;
695
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
696
+	return $tabs;
697 697
 }
698 698
 
699 699
 
@@ -709,144 +709,144 @@  discard block
 block discarded – undo
709 709
  */
710 710
 function geodir_extend_geodirectory_setting_tab($tabs)
711 711
 {
712
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
713
-    return $tabs;
712
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
713
+	return $tabs;
714 714
 }
715 715
 
716 716
 
717 717
 if (!function_exists('geodir_edit_post_columns')) {
718
-    /**
719
-     * Modify admin post listing page columns.
720
-     *
721
-     * @since 1.0.0
722
-     * @package GeoDirectory
723
-     * @param array $columns The column array.
724
-     * @return array Altered column array.
725
-     */
726
-    function geodir_edit_post_columns($columns)
727
-    {
728
-
729
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
730
-            'categorys' => __('Categories', 'geodirectory'));
731
-
732
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
733
-        {
734
-            $offset = 0; // should we prepend $array with $data?
735
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
736
-        }
718
+	/**
719
+	 * Modify admin post listing page columns.
720
+	 *
721
+	 * @since 1.0.0
722
+	 * @package GeoDirectory
723
+	 * @param array $columns The column array.
724
+	 * @return array Altered column array.
725
+	 */
726
+	function geodir_edit_post_columns($columns)
727
+	{
737 728
 
738
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
729
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
730
+			'categorys' => __('Categories', 'geodirectory'));
739 731
 
740
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
732
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
733
+		{
734
+			$offset = 0; // should we prepend $array with $data?
735
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
736
+		}
741 737
 
742
-        return $columns;
743
-    }
738
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
739
+
740
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
741
+
742
+		return $columns;
743
+	}
744 744
 }
745 745
 
746 746
 
747 747
 if (!function_exists('geodir_manage_post_columns')) {
748
-    /**
749
-     * Adds content to our custom post listing page columns.
750
-     *
751
-     * @since 1.0.0
752
-     * @package GeoDirectory
753
-     * @global object $wpdb WordPress Database object.
754
-     * @global object $post WordPress Post object.
755
-     * @param string $column The column name.
756
-     * @param int $post_id The post ID.
757
-     */
758
-    function geodir_manage_post_columns($column, $post_id)
759
-    {
760
-        global $post, $wpdb;
761
-
762
-        switch ($column):
763
-            /* If displaying the 'city' column. */
764
-            case 'location' :
765
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
766
-                $location = geodir_get_location($location_id);
767
-                /* If no city is found, output a default message. */
768
-                if (empty($location)) {
769
-                    _e('Unknown', 'geodirectory');
770
-                } else {
771
-                    /* If there is a city id, append 'city name' to the text string. */
772
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
773
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
774
-                }
775
-                break;
776
-
777
-            /* If displaying the 'expire' column. */
778
-            case 'expire' :
779
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
780
-                $d1 = $expire_date; // get expire_date
781
-                $d2 = date('Y-m-d'); // get current date
782
-                $state = __('days left', 'geodirectory');
783
-                $date_diff_text = '';
784
-                $expire_class = 'expire_left';
785
-                if ($expire_date != 'Never') {
786
-                    if (strtotime($d1) < strtotime($d2)) {
787
-                        $state = __('days overdue', 'geodirectory');
788
-                        $expire_class = 'expire_over';
789
-                    }
790
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
791
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
792
-                }
793
-                /* If no expire_date is found, output a default message. */
794
-                if (empty($expire_date))
795
-                    echo __('Unknown', 'geodirectory');
796
-                /* If there is a expire_date, append 'days left' to the text string. */
797
-                else
798
-                    echo $expire_date . $date_diff_text;
799
-                break;
800
-
801
-            /* If displaying the 'categorys' column. */
802
-            case 'categorys' :
803
-
804
-                /* Get the categorys for the post. */
805
-
806
-
807
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
808
-
809
-                /* If terms were found. */
810
-                if (!empty($terms)) {
811
-                    $out = array();
812
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
813
-                    foreach ($terms as $term) {
814
-                        if (!strstr($term->taxonomy, 'tag')) {
815
-                            $out[] = sprintf('<a href="%s">%s</a>',
816
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
817
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
818
-                            );
819
-                        }
820
-                    }
821
-                    /* Join the terms, separating them with a comma. */
822
-                    echo(join(', ', $out));
823
-                } /* If no terms were found, output a default message. */
824
-                else {
825
-                    _e('No Categories', 'geodirectory');
826
-                }
827
-                break;
748
+	/**
749
+	 * Adds content to our custom post listing page columns.
750
+	 *
751
+	 * @since 1.0.0
752
+	 * @package GeoDirectory
753
+	 * @global object $wpdb WordPress Database object.
754
+	 * @global object $post WordPress Post object.
755
+	 * @param string $column The column name.
756
+	 * @param int $post_id The post ID.
757
+	 */
758
+	function geodir_manage_post_columns($column, $post_id)
759
+	{
760
+		global $post, $wpdb;
761
+
762
+		switch ($column):
763
+			/* If displaying the 'city' column. */
764
+			case 'location' :
765
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
766
+				$location = geodir_get_location($location_id);
767
+				/* If no city is found, output a default message. */
768
+				if (empty($location)) {
769
+					_e('Unknown', 'geodirectory');
770
+				} else {
771
+					/* If there is a city id, append 'city name' to the text string. */
772
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
773
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
774
+				}
775
+				break;
776
+
777
+			/* If displaying the 'expire' column. */
778
+			case 'expire' :
779
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
780
+				$d1 = $expire_date; // get expire_date
781
+				$d2 = date('Y-m-d'); // get current date
782
+				$state = __('days left', 'geodirectory');
783
+				$date_diff_text = '';
784
+				$expire_class = 'expire_left';
785
+				if ($expire_date != 'Never') {
786
+					if (strtotime($d1) < strtotime($d2)) {
787
+						$state = __('days overdue', 'geodirectory');
788
+						$expire_class = 'expire_over';
789
+					}
790
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
791
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
792
+				}
793
+				/* If no expire_date is found, output a default message. */
794
+				if (empty($expire_date))
795
+					echo __('Unknown', 'geodirectory');
796
+				/* If there is a expire_date, append 'days left' to the text string. */
797
+				else
798
+					echo $expire_date . $date_diff_text;
799
+				break;
828 800
 
829
-        endswitch;
830
-    }
801
+			/* If displaying the 'categorys' column. */
802
+			case 'categorys' :
803
+
804
+				/* Get the categorys for the post. */
805
+
806
+
807
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
808
+
809
+				/* If terms were found. */
810
+				if (!empty($terms)) {
811
+					$out = array();
812
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
813
+					foreach ($terms as $term) {
814
+						if (!strstr($term->taxonomy, 'tag')) {
815
+							$out[] = sprintf('<a href="%s">%s</a>',
816
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
817
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
818
+							);
819
+						}
820
+					}
821
+					/* Join the terms, separating them with a comma. */
822
+					echo(join(', ', $out));
823
+				} /* If no terms were found, output a default message. */
824
+				else {
825
+					_e('No Categories', 'geodirectory');
826
+				}
827
+				break;
828
+
829
+		endswitch;
830
+	}
831 831
 }
832 832
 
833 833
 
834 834
 if (!function_exists('geodir_post_sortable_columns')) {
835
-    /**
836
-     * Makes admin post listing page columns sortable.
837
-     *
838
-     * @since 1.0.0
839
-     * @package GeoDirectory
840
-     * @param array $columns The column array.
841
-     * @return array Altered column array.
842
-     */
843
-    function geodir_post_sortable_columns($columns)
844
-    {
845
-
846
-        $columns['expire'] = 'expire';
847
-
848
-        return $columns;
849
-    }
835
+	/**
836
+	 * Makes admin post listing page columns sortable.
837
+	 *
838
+	 * @since 1.0.0
839
+	 * @package GeoDirectory
840
+	 * @param array $columns The column array.
841
+	 * @return array Altered column array.
842
+	 */
843
+	function geodir_post_sortable_columns($columns)
844
+	{
845
+
846
+		$columns['expire'] = 'expire';
847
+
848
+		return $columns;
849
+	}
850 850
 }
851 851
 
852 852
 /**
@@ -860,32 +860,32 @@  discard block
 block discarded – undo
860 860
  * @param int $post_id The post ID.
861 861
  */
862 862
 function geodir_post_information_save($post_id, $post) {
863
-    global $wpdb, $current_user;
863
+	global $wpdb, $current_user;
864 864
 
865
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
866
-        return;
867
-    }
865
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
866
+		return;
867
+	}
868 868
 
869
-    $geodir_posttypes = geodir_get_posttypes();
869
+	$geodir_posttypes = geodir_get_posttypes();
870 870
 
871
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
872
-        return;
871
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
872
+		return;
873 873
 
874
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
875
-        if (isset($_REQUEST['_status']))
876
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
874
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
875
+		if (isset($_REQUEST['_status']))
876
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
877 877
 
878
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
879
-            return;
878
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
879
+			return;
880 880
 
881
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
882
-            return;
881
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
882
+			return;
883 883
 
884
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
885
-            return;
884
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
885
+			return;
886 886
 
887
-        geodir_save_listing($_REQUEST);
888
-    }
887
+		geodir_save_listing($_REQUEST);
888
+	}
889 889
 }
890 890
 
891 891
 /**
@@ -901,102 +901,102 @@  discard block
 block discarded – undo
901 901
  */
902 902
 function geodir_admin_fields($options)
903 903
 {
904
-    global $geodirectory;
905
-
906
-    $first_title = true;
907
-    $tab_id = '';
908
-    $i = 0;
909
-    foreach ($options as $value) :
910
-        if (!isset($value['name'])) $value['name'] = '';
911
-        if (!isset($value['class'])) $value['class'] = '';
912
-        if (!isset($value['css'])) $value['css'] = '';
913
-        if (!isset($value['std'])) $value['std'] = '';
914
-        $desc = '';
915
-        switch ($value['type']) :
916
-            case 'dummy_installer':
917
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
918
-                geodir_autoinstall_admin_header($post_type);
919
-                break;
920
-            case 'title':
921
-
922
-                if ($i == 0) {
923
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
924
-                    echo '<div class="inner_content_tab_main">';
925
-                }
904
+	global $geodirectory;
905
+
906
+	$first_title = true;
907
+	$tab_id = '';
908
+	$i = 0;
909
+	foreach ($options as $value) :
910
+		if (!isset($value['name'])) $value['name'] = '';
911
+		if (!isset($value['class'])) $value['class'] = '';
912
+		if (!isset($value['css'])) $value['css'] = '';
913
+		if (!isset($value['std'])) $value['std'] = '';
914
+		$desc = '';
915
+		switch ($value['type']) :
916
+			case 'dummy_installer':
917
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
918
+				geodir_autoinstall_admin_header($post_type);
919
+				break;
920
+			case 'title':
921
+
922
+				if ($i == 0) {
923
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
924
+					echo '<div class="inner_content_tab_main">';
925
+				}
926 926
 
927
-                $i++;
927
+				$i++;
928 928
 
929
-                if (isset($value['id']) && $value['id'])
930
-                    $tab_id = $value['id'];
929
+				if (isset($value['id']) && $value['id'])
930
+					$tab_id = $value['id'];
931 931
 
932
-                if (isset($value['desc']) && $value['desc'])
933
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
932
+				if (isset($value['desc']) && $value['desc'])
933
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
934 934
 
935
-                if (isset($value['name']) && $value['name']) {
936
-                    if ($first_title === true) {
937
-                        $first_title = false;
938
-                    } else {
939
-                        echo '</div>';
940
-                    }
941
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
935
+				if (isset($value['name']) && $value['name']) {
936
+					if ($first_title === true) {
937
+						$first_title = false;
938
+					} else {
939
+						echo '</div>';
940
+					}
941
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
942 942
 
943
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
944
-                }
943
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
944
+				}
945 945
 
946
-                /**
947
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
948
-                 *
949
-                 * The action is called dynamically geodir_settings_$value['id'].
950
-                 *
951
-                 * @since 1.0.0
952
-                 */
953
-                do_action('geodir_settings_' . sanitize_title($value['id']));
954
-                break;
955
-
956
-            case 'no_tabs':
957
-
958
-                echo '<div class="inner_content_tab_main">';
959
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
960
-
961
-                break;
962
-
963
-            case 'sectionstart':
964
-                if (isset($value['desc']) && $value['desc'])
965
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
966
-                if (isset($value['name']) && $value['name'])
967
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
968
-                /**
969
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
970
-                 *
971
-                 * The action is called dynamically geodir_settings_$value['id']_start.
972
-                 *
973
-                 * @since 1.0.0
974
-                 */
975
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
976
-                echo '<table class="form-table">' . "\n\n";
977
-
978
-                break;
979
-            case 'sectionend':
980
-                /**
981
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
982
-                 *
983
-                 * The action is called dynamically geodir_settings_$value['id']_end.
984
-                 *
985
-                 * @since 1.0.0
986
-                 */
987
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
988
-                echo '</table>';
989
-                /**
990
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
991
-                 *
992
-                 * The action is called dynamically geodir_settings_$value['id']_end.
993
-                 *
994
-                 * @since 1.0.0
995
-                 */
996
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
997
-                break;
998
-            case 'text':
999
-                ?>
946
+				/**
947
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
948
+				 *
949
+				 * The action is called dynamically geodir_settings_$value['id'].
950
+				 *
951
+				 * @since 1.0.0
952
+				 */
953
+				do_action('geodir_settings_' . sanitize_title($value['id']));
954
+				break;
955
+
956
+			case 'no_tabs':
957
+
958
+				echo '<div class="inner_content_tab_main">';
959
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
960
+
961
+				break;
962
+
963
+			case 'sectionstart':
964
+				if (isset($value['desc']) && $value['desc'])
965
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
966
+				if (isset($value['name']) && $value['name'])
967
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
968
+				/**
969
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
970
+				 *
971
+				 * The action is called dynamically geodir_settings_$value['id']_start.
972
+				 *
973
+				 * @since 1.0.0
974
+				 */
975
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
976
+				echo '<table class="form-table">' . "\n\n";
977
+
978
+				break;
979
+			case 'sectionend':
980
+				/**
981
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
982
+				 *
983
+				 * The action is called dynamically geodir_settings_$value['id']_end.
984
+				 *
985
+				 * @since 1.0.0
986
+				 */
987
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
988
+				echo '</table>';
989
+				/**
990
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
991
+				 *
992
+				 * The action is called dynamically geodir_settings_$value['id']_end.
993
+				 *
994
+				 * @since 1.0.0
995
+				 */
996
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
997
+				break;
998
+			case 'text':
999
+				?>
1000 1000
                 <tr valign="top">
1001 1001
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1002 1002
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1005,15 +1005,15 @@  discard block
 block discarded – undo
1005 1005
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1006 1006
                                            style=" <?php echo esc_attr($value['css']); ?>"
1007 1007
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1008
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1009
-                                           } else {
1010
-                                               echo esc_attr($value['std']);
1011
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1008
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1009
+										   } else {
1010
+											   echo esc_attr($value['std']);
1011
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1012 1012
                 </tr><?php
1013
-                break;
1013
+				break;
1014 1014
 
1015
-            case 'map-key':
1016
-                ?>
1015
+			case 'map-key':
1016
+				?>
1017 1017
                 <tr valign="top">
1018 1018
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1019 1019
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1022,17 +1022,17 @@  discard block
 block discarded – undo
1022 1022
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1023 1023
                                            style=" <?php echo esc_attr($value['css']); ?>"
1024 1024
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1025
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1026
-                                           } else {
1027
-                                               echo esc_attr($value['std']);
1028
-                                           } ?>"/>
1025
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1026
+										   } else {
1027
+											   echo esc_attr($value['std']);
1028
+										   } ?>"/>
1029 1029
                     <a href='https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]&TB_iframe=true&width=600&height=400' class="thickbox button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','geodirectory');?>" ><?php _e('Generate API Key','geodirectory');?></a>
1030 1030
                     <span class="description"><?php echo $value['desc']; ?></span></td>
1031 1031
                 </tr><?php
1032
-                break;
1032
+				break;
1033 1033
 
1034
-            case 'password':
1035
-                ?>
1034
+			case 'password':
1035
+				?>
1036 1036
                 <tr valign="top">
1037 1037
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1038 1038
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1041,42 +1041,42 @@  discard block
 block discarded – undo
1041 1041
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1042 1042
                                            style="<?php echo esc_attr($value['css']); ?>"
1043 1043
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1044
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1045
-                                           } else {
1046
-                                               echo esc_attr($value['std']);
1047
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1044
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1045
+										   } else {
1046
+											   echo esc_attr($value['std']);
1047
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1048 1048
                 </tr><?php
1049
-                break;
1049
+				break;
1050 1050
 
1051
-            case 'html_content':
1052
-                ?>
1051
+			case 'html_content':
1052
+				?>
1053 1053
                 <tr valign="top">
1054 1054
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1055 1055
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1056 1056
                 </tr><?php
1057
-                break;
1057
+				break;
1058 1058
 
1059
-            case 'color' :
1060
-                ?>
1059
+			case 'color' :
1060
+				?>
1061 1061
                 <tr valign="top">
1062 1062
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1063 1063
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1064 1064
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1065 1065
                                            style="<?php echo esc_attr($value['css']); ?>"
1066 1066
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1067
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1068
-                                           } else {
1069
-                                               echo esc_attr($value['std']);
1070
-                                           } ?>" class="colorpick"/> <span
1067
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1068
+										   } else {
1069
+											   echo esc_attr($value['std']);
1070
+										   } ?>" class="colorpick"/> <span
1071 1071
                         class="description"><?php echo $value['desc']; ?></span>
1072 1072
 
1073 1073
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1074 1074
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1075 1075
                 </td>
1076 1076
                 </tr><?php
1077
-                break;
1078
-            case 'image_width' :
1079
-                ?>
1077
+				break;
1078
+			case 'image_width' :
1079
+				?>
1080 1080
                 <tr valign="top">
1081 1081
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1082 1082
                 <td class="forminp">
@@ -1098,11 +1098,11 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1100 1100
                 </tr><?php
1101
-                break;
1102
-            case 'select':
1103
-                $option_value = get_option($value['id']);
1104
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1105
-                ?>
1101
+				break;
1102
+			case 'select':
1103
+				$option_value = get_option($value['id']);
1104
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1105
+				?>
1106 1106
                 <tr valign="top">
1107 1107
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1108 1108
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1111,33 +1111,33 @@  discard block
 block discarded – undo
1111 1111
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1112 1112
                                             option-ajaxchosen="false">
1113 1113
                         <?php
1114
-                        foreach ($value['options'] as $key => $val) {
1115
-                            $geodir_select_value = '';
1116
-                            if ($option_value != '') {
1117
-                                if ($option_value != '' && $option_value == $key)
1118
-                                    $geodir_select_value = ' selected="selected" ';
1119
-                            } else {
1120
-                                if ($value['std'] == $key)
1121
-                                    $geodir_select_value = ' selected="selected" ';
1122
-                            }
1123
-                            ?>
1114
+						foreach ($value['options'] as $key => $val) {
1115
+							$geodir_select_value = '';
1116
+							if ($option_value != '') {
1117
+								if ($option_value != '' && $option_value == $key)
1118
+									$geodir_select_value = ' selected="selected" ';
1119
+							} else {
1120
+								if ($value['std'] == $key)
1121
+									$geodir_select_value = ' selected="selected" ';
1122
+							}
1123
+							?>
1124 1124
                             <option
1125 1125
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo geodir_utf8_ucfirst($val) ?></option>
1126 1126
                         <?php
1127
-                        }
1128
-                        ?>
1127
+						}
1128
+						?>
1129 1129
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1130 1130
                 </td>
1131 1131
                 </tr><?php
1132
-                break;
1132
+				break;
1133 1133
 
1134
-            case 'multiselect':
1135
-                $option_values = get_option($value['id']);
1136
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1137
-                   $option_values = $value['std'];
1138
-                }
1139
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1140
-                ?>
1134
+			case 'multiselect':
1135
+				$option_values = get_option($value['id']);
1136
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1137
+				   $option_values = $value['std'];
1138
+				}
1139
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1140
+				?>
1141 1141
                 <tr valign="top">
1142 1142
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1143 1143
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1147,26 +1147,26 @@  discard block
 block discarded – undo
1147 1147
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1148 1148
                                             option-ajaxchosen="false">
1149 1149
                         <?php
1150
-                        foreach ($value['options'] as $key => $val) {
1151
-                            if (strpos($key, 'optgroup_start-') === 0) {
1152
-                                ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php
1153
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1154
-                                ?></optgroup><?php
1155
-                            } else {
1156
-                                ?>
1150
+						foreach ($value['options'] as $key => $val) {
1151
+							if (strpos($key, 'optgroup_start-') === 0) {
1152
+								?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php
1153
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1154
+								?></optgroup><?php
1155
+							} else {
1156
+								?>
1157 1157
                                 <option value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>>
1158 1158
                                     <?php echo geodir_utf8_ucfirst($val) ?>
1159 1159
                                 </option>
1160 1160
                             <?php
1161
-                            }
1162
-                        }
1163
-                        ?>
1161
+							}
1162
+						}
1163
+						?>
1164 1164
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1165 1165
                 </td>
1166 1166
                 </tr><?php
1167
-                break;
1168
-            case 'file':
1169
-                ?>
1167
+				break;
1168
+			case 'file':
1169
+				?>
1170 1170
                 <tr valign="top">
1171 1171
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1172 1172
                 <td class="forminp">
@@ -1186,87 +1186,87 @@  discard block
 block discarded – undo
1186 1186
                     <?php } ?>
1187 1187
                 </td>
1188 1188
                 </tr><?php
1189
-                break;
1190
-            case 'map_default_settings' :
1191
-                ?>
1189
+				break;
1190
+			case 'map_default_settings' :
1191
+				?>
1192 1192
 
1193 1193
                 <tr valign="top">
1194 1194
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1195 1195
                     <td width="60%">
1196 1196
                         <select name="geodir_default_map_language" style="width:60%">
1197 1197
                             <?php
1198
-                            $arr_map_langages = array(
1199
-                                'ar' => __('ARABIC', 'geodirectory'),
1200
-                                'eu' => __('BASQUE', 'geodirectory'),
1201
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1202
-                                'bn' => __('BENGALI', 'geodirectory'),
1203
-                                'ca' => __('CATALAN', 'geodirectory'),
1204
-                                'cs' => __('CZECH', 'geodirectory'),
1205
-                                'da' => __('DANISH', 'geodirectory'),
1206
-                                'de' => __('GERMAN', 'geodirectory'),
1207
-                                'el' => __('GREEK', 'geodirectory'),
1208
-                                'en' => __('ENGLISH', 'geodirectory'),
1209
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1210
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1211
-                                'es' => __('SPANISH', 'geodirectory'),
1212
-                                'eu' => __('BASQUE', 'geodirectory'),
1213
-                                'fa' => __('FARSI', 'geodirectory'),
1214
-                                'fi' => __('FINNISH', 'geodirectory'),
1215
-                                'fil' => __('FILIPINO', 'geodirectory'),
1216
-                                'fr' => __('FRENCH', 'geodirectory'),
1217
-                                'gl' => __('GALICIAN', 'geodirectory'),
1218
-                                'gu' => __('GUJARATI', 'geodirectory'),
1219
-                                'hi' => __('HINDI', 'geodirectory'),
1220
-                                'hr' => __('CROATIAN', 'geodirectory'),
1221
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1222
-                                'id' => __('INDONESIAN', 'geodirectory'),
1223
-                                'it' => __('ITALIAN', 'geodirectory'),
1224
-                                'iw' => __('HEBREW', 'geodirectory'),
1225
-                                'ja' => __('JAPANESE', 'geodirectory'),
1226
-                                'kn' => __('KANNADA', 'geodirectory'),
1227
-                                'ko' => __('KOREAN', 'geodirectory'),
1228
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1229
-                                'lv' => __('LATVIAN', 'geodirectory'),
1230
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1231
-                                'mr' => __('MARATHI', 'geodirectory'),
1232
-                                'nl' => __('DUTCH', 'geodirectory'),
1233
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1234
-                                'pl' => __('POLISH', 'geodirectory'),
1235
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1236
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1237
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1238
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1239
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1240
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1241
-                                'sk' => __('SLOVAK', 'geodirectory'),
1242
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1243
-                                'sr' => __('SERBIAN', 'geodirectory'),
1244
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1245
-                                'tl' => __('TAGALOG', 'geodirectory'),
1246
-                                'ta' => __('TAMIL', 'geodirectory'),
1247
-                                'te' => __('TELUGU', 'geodirectory'),
1248
-                                'th' => __('THAI', 'geodirectory'),
1249
-                                'tr' => __('TURKISH', 'geodirectory'),
1250
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1251
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1252
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1253
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1254
-                            );
1255
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1256
-                            if (empty($geodir_default_map_language))
1257
-                                $geodir_default_map_language = 'en';
1258
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
1259
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1260
-                                    $geodir_default_language_selected = "selected='selected'";
1261
-                                else
1262
-                                    $geodir_default_language_selected = '';
1263
-
1264
-                                ?>
1198
+							$arr_map_langages = array(
1199
+								'ar' => __('ARABIC', 'geodirectory'),
1200
+								'eu' => __('BASQUE', 'geodirectory'),
1201
+								'bg' => __('BULGARIAN', 'geodirectory'),
1202
+								'bn' => __('BENGALI', 'geodirectory'),
1203
+								'ca' => __('CATALAN', 'geodirectory'),
1204
+								'cs' => __('CZECH', 'geodirectory'),
1205
+								'da' => __('DANISH', 'geodirectory'),
1206
+								'de' => __('GERMAN', 'geodirectory'),
1207
+								'el' => __('GREEK', 'geodirectory'),
1208
+								'en' => __('ENGLISH', 'geodirectory'),
1209
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1210
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1211
+								'es' => __('SPANISH', 'geodirectory'),
1212
+								'eu' => __('BASQUE', 'geodirectory'),
1213
+								'fa' => __('FARSI', 'geodirectory'),
1214
+								'fi' => __('FINNISH', 'geodirectory'),
1215
+								'fil' => __('FILIPINO', 'geodirectory'),
1216
+								'fr' => __('FRENCH', 'geodirectory'),
1217
+								'gl' => __('GALICIAN', 'geodirectory'),
1218
+								'gu' => __('GUJARATI', 'geodirectory'),
1219
+								'hi' => __('HINDI', 'geodirectory'),
1220
+								'hr' => __('CROATIAN', 'geodirectory'),
1221
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1222
+								'id' => __('INDONESIAN', 'geodirectory'),
1223
+								'it' => __('ITALIAN', 'geodirectory'),
1224
+								'iw' => __('HEBREW', 'geodirectory'),
1225
+								'ja' => __('JAPANESE', 'geodirectory'),
1226
+								'kn' => __('KANNADA', 'geodirectory'),
1227
+								'ko' => __('KOREAN', 'geodirectory'),
1228
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1229
+								'lv' => __('LATVIAN', 'geodirectory'),
1230
+								'ml' => __('MALAYALAM', 'geodirectory'),
1231
+								'mr' => __('MARATHI', 'geodirectory'),
1232
+								'nl' => __('DUTCH', 'geodirectory'),
1233
+								'no' => __('NORWEGIAN', 'geodirectory'),
1234
+								'pl' => __('POLISH', 'geodirectory'),
1235
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1236
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1237
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1238
+								'ro' => __('ROMANIAN', 'geodirectory'),
1239
+								'ru' => __('RUSSIAN', 'geodirectory'),
1240
+								'ru' => __('RUSSIAN', 'geodirectory'),
1241
+								'sk' => __('SLOVAK', 'geodirectory'),
1242
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1243
+								'sr' => __('SERBIAN', 'geodirectory'),
1244
+								'sv' => __('	SWEDISH', 'geodirectory'),
1245
+								'tl' => __('TAGALOG', 'geodirectory'),
1246
+								'ta' => __('TAMIL', 'geodirectory'),
1247
+								'te' => __('TELUGU', 'geodirectory'),
1248
+								'th' => __('THAI', 'geodirectory'),
1249
+								'tr' => __('TURKISH', 'geodirectory'),
1250
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1251
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1252
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1253
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1254
+							);
1255
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1256
+							if (empty($geodir_default_map_language))
1257
+								$geodir_default_map_language = 'en';
1258
+							foreach ($arr_map_langages as $language_key => $language_txt) {
1259
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1260
+									$geodir_default_language_selected = "selected='selected'";
1261
+								else
1262
+									$geodir_default_language_selected = '';
1263
+
1264
+								?>
1265 1265
                                 <option
1266 1266
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1267 1267
 
1268 1268
                             <?php }
1269
-                            ?>
1269
+							?>
1270 1270
                         </select>
1271 1271
                     </td>
1272 1272
                 </tr>
@@ -1277,46 +1277,46 @@  discard block
 block discarded – undo
1277 1277
                     <td width="60%">
1278 1278
                         <select name="geodir_default_map_search_pt" style="width:60%">
1279 1279
                             <?php
1280
-                            $post_types = geodir_get_posttypes('array');
1281
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1282
-                            if (empty($geodir_default_map_search_pt))
1283
-                                $geodir_default_map_search_pt = 'gd_place';
1284
-                            if (is_array($post_types)) {
1285
-                                foreach ($post_types as $key => $post_types_obj) {
1286
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1287
-                                        $geodir_search_pt_selected = "selected='selected'";
1288
-                                    else
1289
-                                        $geodir_search_pt_selected = '';
1290
-
1291
-                                    ?>
1280
+							$post_types = geodir_get_posttypes('array');
1281
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1282
+							if (empty($geodir_default_map_search_pt))
1283
+								$geodir_default_map_search_pt = 'gd_place';
1284
+							if (is_array($post_types)) {
1285
+								foreach ($post_types as $key => $post_types_obj) {
1286
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1287
+										$geodir_search_pt_selected = "selected='selected'";
1288
+									else
1289
+										$geodir_search_pt_selected = '';
1290
+
1291
+									?>
1292 1292
                                     <option
1293 1293
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo __($post_types_obj['labels']['singular_name'], 'geodirectory'); ?></option>
1294 1294
 
1295 1295
                                 <?php }
1296 1296
 
1297
-                            }
1297
+							}
1298 1298
 
1299
-                            ?>
1299
+							?>
1300 1300
                         </select>
1301 1301
                     </td>
1302 1302
                 </tr>
1303 1303
 
1304 1304
                 <?php
1305
-                break;
1305
+				break;
1306 1306
 
1307
-            case 'map':
1308
-                ?>
1307
+			case 'map':
1308
+				?>
1309 1309
                 <tr valign="top">
1310 1310
                     <td class="forminp">
1311 1311
                         <?php
1312
-                        global $post_cat, $cat_display;
1313
-                        $post_types = geodir_get_posttypes('object');
1314
-                        $cat_display = 'checkbox';
1315
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1316
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1317
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1318
-                        $count = 1;
1319
-                        ?>
1312
+						global $post_cat, $cat_display;
1313
+						$post_types = geodir_get_posttypes('object');
1314
+						$cat_display = 'checkbox';
1315
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1316
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1317
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1318
+						$count = 1;
1319
+						?>
1320 1320
                         <table width="70%" class="widefat">
1321 1321
                             <thead>
1322 1322
                             <tr>
@@ -1325,18 +1325,18 @@  discard block
 block discarded – undo
1325 1325
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1326 1326
                             </tr>
1327 1327
                             <?php
1328
-                            $gd_categs = $gd_cats;
1329
-                            foreach ($post_types as $key => $post_types_obj) :
1330
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1331
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1332
-                                if ($gd_cats_upgrade) {
1333
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1334
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1335
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1336
-                                }
1337
-                                $post_cat = implode(',', $gd_cats);
1338
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1339
-                                ?>
1328
+							$gd_categs = $gd_cats;
1329
+							foreach ($post_types as $key => $post_types_obj) :
1330
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1331
+								$gd_taxonomy = geodir_get_taxonomies($key);
1332
+								if ($gd_cats_upgrade) {
1333
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1334
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1335
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1336
+								}
1337
+								$post_cat = implode(',', $gd_cats);
1338
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1339
+								?>
1340 1340
                                 <tr>
1341 1341
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1342 1342
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1357,19 +1357,19 @@  discard block
 block discarded – undo
1357 1357
                     </td>
1358 1358
                 </tr>
1359 1359
                 <?php
1360
-                break;
1360
+				break;
1361 1361
 
1362
-            case 'checkbox' :
1362
+			case 'checkbox' :
1363 1363
 
1364
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1365
-                    ?>
1364
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1365
+					?>
1366 1366
                     <tr valign="top">
1367 1367
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1368 1368
                     <td class="forminp">
1369 1369
                 <?php
1370
-                endif;
1370
+				endif;
1371 1371
 
1372
-                ?>
1372
+				?>
1373 1373
                 <fieldset>
1374 1374
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1375 1375
                     <label for="<?php echo $value['id'] ?>">
@@ -1379,49 +1379,49 @@  discard block
 block discarded – undo
1379 1379
                 </fieldset>
1380 1380
                 <?php
1381 1381
 
1382
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1383
-                    ?>
1382
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1383
+					?>
1384 1384
                     </td>
1385 1385
                     </tr>
1386 1386
                 <?php
1387
-                endif;
1387
+				endif;
1388 1388
 
1389
-                break;
1389
+				break;
1390 1390
 
1391
-            case 'radio' :
1391
+			case 'radio' :
1392 1392
 
1393
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1394
-                    ?>
1393
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1394
+					?>
1395 1395
                     <tr valign="top">
1396 1396
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1397 1397
                     <td class="forminp">
1398 1398
                 <?php
1399
-                endif;
1399
+				endif;
1400 1400
 
1401
-                ?>
1401
+				?>
1402 1402
                 <fieldset>
1403 1403
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1404 1404
                     <label for="<?php echo $value['id'];?>">
1405 1405
                         <input name="<?php echo esc_attr($value['id']); ?>"
1406 1406
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1407 1407
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1408
-                            echo 'checked="checked"';
1409
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1408
+							echo 'checked="checked"';
1409
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1410 1410
                         <?php echo $value['desc']; ?></label><br>
1411 1411
                 </fieldset>
1412 1412
                 <?php
1413 1413
 
1414
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1415
-                    ?>
1414
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1415
+					?>
1416 1416
                     </td>
1417 1417
                     </tr>
1418 1418
                 <?php
1419
-                endif;
1419
+				endif;
1420 1420
 
1421
-                break;
1421
+				break;
1422 1422
 
1423
-            case 'textarea':
1424
-                ?>
1423
+			case 'textarea':
1424
+				?>
1425 1425
                 <tr valign="top">
1426 1426
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1427 1427
                 <td class="forminp">
@@ -1434,30 +1434,30 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
                 </td>
1436 1436
                 </tr><?php
1437
-                break;
1437
+				break;
1438 1438
 
1439
-            case 'editor':
1440
-                ?>
1439
+			case 'editor':
1440
+				?>
1441 1441
                 <tr valign="top">
1442 1442
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1443 1443
                 <td class="forminp"><?php
1444
-                    if (get_option($value['id']))
1445
-                        $content = stripslashes(get_option($value['id']));
1446
-                    else
1447
-                        $content = $value['std'];
1444
+					if (get_option($value['id']))
1445
+						$content = stripslashes(get_option($value['id']));
1446
+					else
1447
+						$content = $value['std'];
1448 1448
 
1449
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1449
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1450 1450
 
1451
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1451
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1452 1452
 
1453
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1453
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1454 1454
 
1455 1455
                 </td>
1456 1456
                 </tr><?php
1457
-                break;
1457
+				break;
1458 1458
 
1459
-            case 'single_select_page' :
1460
-                // WPML
1459
+			case 'single_select_page' :
1460
+				// WPML
1461 1461
 				$switch_lang = false;
1462 1462
 				$disabled = '';
1463 1463
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1475,18 +1475,18 @@  discard block
 block discarded – undo
1475 1475
 				//
1476 1476
 				$page_setting = (int)get_option($value['id']);
1477 1477
 
1478
-                $args = array('name' => $value['id'],
1479
-                    'id' => $value['id'],
1480
-                    'sort_column' => 'menu_order',
1481
-                    'sort_order' => 'ASC',
1482
-                    'show_option_none' => ' ',
1483
-                    'class' => $value['class'],
1484
-                    'echo' => false,
1485
-                    'selected' => $page_setting);
1478
+				$args = array('name' => $value['id'],
1479
+					'id' => $value['id'],
1480
+					'sort_column' => 'menu_order',
1481
+					'sort_order' => 'ASC',
1482
+					'show_option_none' => ' ',
1483
+					'class' => $value['class'],
1484
+					'echo' => false,
1485
+					'selected' => $page_setting);
1486 1486
 
1487
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1487
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1488 1488
 
1489
-                ?>
1489
+				?>
1490 1490
                 <tr valign="top" class="single_select_page">
1491 1491
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1492 1492
                 <td class="forminp">
@@ -1497,17 +1497,17 @@  discard block
 block discarded – undo
1497 1497
 				if ($switch_lang) {
1498 1498
 					$sitepress->switch_lang($switch_lang, true);
1499 1499
 				}
1500
-                break;
1501
-            case 'single_select_country' :
1502
-                $country_setting = (string)get_option($value['id']);
1503
-                if (strstr($country_setting, ':')) :
1504
-                    $country = current(explode(':', $country_setting));
1505
-                    $state = end(explode(':', $country_setting));
1506
-                else :
1507
-                    $country = $country_setting;
1508
-                    $state = '*';
1509
-                endif;
1510
-                ?>
1500
+				break;
1501
+			case 'single_select_country' :
1502
+				$country_setting = (string)get_option($value['id']);
1503
+				if (strstr($country_setting, ':')) :
1504
+					$country = current(explode(':', $country_setting));
1505
+					$state = end(explode(':', $country_setting));
1506
+				else :
1507
+					$country = $country_setting;
1508
+					$state = '*';
1509
+				endif;
1510
+				?>
1511 1511
                 <tr valign="top">
1512 1512
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1513 1513
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1518,12 +1518,12 @@  discard block
 block discarded – undo
1518 1518
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1519 1519
                 </td>
1520 1520
                 </tr><?php
1521
-                break;
1522
-            case 'multi_select_countries' :
1523
-                $countries = $geodirectory->countries->countries;
1524
-                asort($countries);
1525
-                $selections = (array)get_option($value['id']);
1526
-                ?>
1521
+				break;
1522
+			case 'multi_select_countries' :
1523
+				$countries = $geodirectory->countries->countries;
1524
+				asort($countries);
1525
+				$selections = (array)get_option($value['id']);
1526
+				?>
1527 1527
                 <tr valign="top">
1528 1528
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1529 1529
                 <td class="forminp">
@@ -1531,21 +1531,21 @@  discard block
 block discarded – undo
1531 1531
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1532 1532
                             title="Country" class="chosen_select">
1533 1533
                         <?php
1534
-                        if ($countries) foreach ($countries as $key => $val) :
1535
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1536
-                        endforeach;
1537
-                        ?>
1534
+						if ($countries) foreach ($countries as $key => $val) :
1535
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1536
+						endforeach;
1537
+						?>
1538 1538
                     </select>
1539 1539
                 </td>
1540 1540
                 </tr>
1541 1541
 
1542 1542
                 <?php
1543 1543
 
1544
-                break;
1544
+				break;
1545 1545
 
1546
-            case 'google_analytics' :
1547
-                $selections = (array)get_option($value['id']);
1548
-                    ?>
1546
+			case 'google_analytics' :
1547
+				$selections = (array)get_option($value['id']);
1548
+					?>
1549 1549
                     <tr valign="top">
1550 1550
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1551 1551
                         <td class="forminp">
@@ -1553,62 +1553,62 @@  discard block
 block discarded – undo
1553 1553
 
1554 1554
                             <?php
1555 1555
 
1556
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1557
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1558
-                            $state = "&state=123";//any string
1559
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1560
-                            $response_type = "&response_type=code";
1561
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1562
-                            $access_type = "&access_type=offline";
1563
-                            $approval_prompt = "&approval_prompt=force";
1556
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1557
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1558
+							$state = "&state=123";//any string
1559
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1560
+							$response_type = "&response_type=code";
1561
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1562
+							$access_type = "&access_type=offline";
1563
+							$approval_prompt = "&approval_prompt=force";
1564 1564
 
1565
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1565
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1566 1566
 
1567 1567
 
1568
-                            if (get_option('geodir_ga_auth_token')) {
1569
-                                ?>
1568
+							if (get_option('geodir_ga_auth_token')) {
1569
+								?>
1570 1570
                                 <span class="button-primary"
1571 1571
                                       onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
1572 1572
                                 <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1573 1573
                             <?php
1574
-                                global $gd_ga_errors;
1575
-                                if(!empty($gd_ga_errors)){
1576
-                                    print_r($gd_ga_errors);
1577
-                                }
1578
-                            } else {
1579
-                                ?>
1574
+								global $gd_ga_errors;
1575
+								if(!empty($gd_ga_errors)){
1576
+									print_r($gd_ga_errors);
1577
+								}
1578
+							} else {
1579
+								?>
1580 1580
                                 <span class="button-primary"
1581 1581
                                       onclick="window.open('<?php echo  geodir_ga_activation_url();?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Authorize', 'geodirectory');?></span>
1582 1582
                             <?php
1583
-                            }
1584
-                            ?>
1583
+							}
1584
+							?>
1585 1585
                         </td>
1586 1586
                     </tr>
1587 1587
 
1588 1588
                 <?php
1589 1589
 
1590 1590
 
1591
-                break;
1591
+				break;
1592 1592
 
1593
-            case 'field_seperator' :
1593
+			case 'field_seperator' :
1594 1594
 
1595
-                ?>
1595
+				?>
1596 1596
                 <tr valign="top">
1597 1597
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1598 1598
                 </tr>
1599 1599
                 <?php
1600 1600
 
1601
-                break;
1601
+				break;
1602 1602
 
1603
-        endswitch;
1603
+		endswitch;
1604 1604
 
1605
-    endforeach;
1605
+	endforeach;
1606 1606
 
1607
-    if ($first_title === false) {
1608
-        echo "</div>";
1609
-    }
1607
+	if ($first_title === false) {
1608
+		echo "</div>";
1609
+	}
1610 1610
 
1611
-    ?>
1611
+	?>
1612 1612
 
1613 1613
     <script type="text/javascript">
1614 1614
 
@@ -1668,33 +1668,33 @@  discard block
 block discarded – undo
1668 1668
  */
1669 1669
 function geodir_post_info_setting()
1670 1670
 {
1671
-    global $post, $post_id;
1672
-
1673
-    $post_type = get_post_type();
1674
-
1675
-    $package_info = array();
1676
-
1677
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1678
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1679
-    echo '<div id="geodir_wrapper">';
1680
-    /**
1681
-     * Called before the GD custom fields are output in the wp-admin area.
1682
-     *
1683
-     * @since 1.0.0
1684
-     * @see 'geodir_after_default_field_in_meta_box'
1685
-     */
1686
-    do_action('geodir_before_default_field_in_meta_box');
1687
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
1688
-    // to display all fields in one information box
1689
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
1690
-    /**
1691
-     * Called after the GD custom fields are output in the wp-admin area.
1692
-     *
1693
-     * @since 1.0.0
1694
-     * @see 'geodir_before_default_field_in_meta_box'
1695
-     */
1696
-    do_action('geodir_after_default_field_in_meta_box');
1697
-    echo '</div>';
1671
+	global $post, $post_id;
1672
+
1673
+	$post_type = get_post_type();
1674
+
1675
+	$package_info = array();
1676
+
1677
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1678
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1679
+	echo '<div id="geodir_wrapper">';
1680
+	/**
1681
+	 * Called before the GD custom fields are output in the wp-admin area.
1682
+	 *
1683
+	 * @since 1.0.0
1684
+	 * @see 'geodir_after_default_field_in_meta_box'
1685
+	 */
1686
+	do_action('geodir_before_default_field_in_meta_box');
1687
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
1688
+	// to display all fields in one information box
1689
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
1690
+	/**
1691
+	 * Called after the GD custom fields are output in the wp-admin area.
1692
+	 *
1693
+	 * @since 1.0.0
1694
+	 * @see 'geodir_before_default_field_in_meta_box'
1695
+	 */
1696
+	do_action('geodir_after_default_field_in_meta_box');
1697
+	echo '</div>';
1698 1698
 }
1699 1699
 
1700 1700
 /**
@@ -1707,18 +1707,18 @@  discard block
 block discarded – undo
1707 1707
  */
1708 1708
 function geodir_post_addinfo_setting()
1709 1709
 {
1710
-    global $post, $post_id;
1710
+	global $post, $post_id;
1711 1711
 
1712
-    $post_type = get_post_type();
1712
+	$post_type = get_post_type();
1713 1713
 
1714
-    $package_info = array();
1714
+	$package_info = array();
1715 1715
 
1716
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1716
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1717 1717
 
1718
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
1719
-    echo '<div id="geodir_wrapper">';
1720
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
1721
-    echo '</div>';
1718
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
1719
+	echo '<div id="geodir_wrapper">';
1720
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
1721
+	echo '</div>';
1722 1722
 
1723 1723
 }
1724 1724
 
@@ -1732,60 +1732,60 @@  discard block
 block discarded – undo
1732 1732
  */
1733 1733
 function geodir_post_attachments()
1734 1734
 {
1735
-    global $post, $post_id;
1735
+	global $post, $post_id;
1736 1736
 
1737
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
1737
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
1738 1738
 
1739
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
1740
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
1741
-        geodir_show_featured_image($post_id, 'thumbnail');
1742
-    }
1739
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
1740
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
1741
+		geodir_show_featured_image($post_id, 'thumbnail');
1742
+	}
1743 1743
 
1744
-    $image_limit = 0;
1744
+	$image_limit = 0;
1745 1745
 
1746
-    ?>
1746
+	?>
1747 1747
 
1748 1748
 
1749 1749
     <h5 class="form_title">
1750 1750
         <?php if ($image_limit != 0 && $image_limit == 1) {
1751
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
1752
-        } ?>
1751
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
1752
+		} ?>
1753 1753
         <?php if ($image_limit != 0 && $image_limit > 1) {
1754
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
1755
-        } ?>
1754
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
1755
+		} ?>
1756 1756
         <?php if ($image_limit == 0) {
1757
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
1758
-        } ?>
1757
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
1758
+		} ?>
1759 1759
     </h5>
1760 1760
 
1761 1761
 
1762 1762
     <?php
1763 1763
 
1764
-    $curImages = geodir_get_images($post_id);
1765
-    $place_img_array = array();
1764
+	$curImages = geodir_get_images($post_id);
1765
+	$place_img_array = array();
1766 1766
 
1767
-    if (!empty($curImages)):
1768
-        foreach ($curImages as $p_img):
1769
-            $place_img_array[] = $p_img->src;
1770
-        endforeach;
1771
-    endif;
1767
+	if (!empty($curImages)):
1768
+		foreach ($curImages as $p_img):
1769
+			$place_img_array[] = $p_img->src;
1770
+		endforeach;
1771
+	endif;
1772 1772
 
1773
-    if (!empty($place_img_array))
1774
-        $curImages = implode(',', $place_img_array);
1773
+	if (!empty($place_img_array))
1774
+		$curImages = implode(',', $place_img_array);
1775 1775
 
1776 1776
 
1777
-    // adjust values here
1778
-    $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
1777
+	// adjust values here
1778
+	$id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
1779 1779
 
1780
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
1780
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
1781 1781
 
1782
-    $multiple = true; // allow multiple files upload
1782
+	$multiple = true; // allow multiple files upload
1783 1783
 
1784
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
1784
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
1785 1785
 
1786
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
1786
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
1787 1787
 
1788
-    ?>
1788
+	?>
1789 1789
 
1790 1790
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
1791 1791
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -1827,13 +1827,13 @@  discard block
 block discarded – undo
1827 1827
  */
1828 1828
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
1829 1829
 {
1830
-    $post_type = get_post_type($post_ID);
1830
+	$post_type = get_post_type($post_ID);
1831 1831
 
1832
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1833
-        if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
1834
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
1835
-        }
1836
-    }
1832
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1833
+		if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
1834
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
1835
+		}
1836
+	}
1837 1837
 }
1838 1838
 
1839 1839
 /**
@@ -1848,39 +1848,39 @@  discard block
 block discarded – undo
1848 1848
  */
1849 1849
 function geodir_notification_add_bcc_option($settings)
1850 1850
 {
1851
-    if (!empty($settings)) {
1852
-        $new_settings = array();
1853
-        foreach ($settings as $setting) {
1854
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
1855
-                $geodir_bcc_listing_published_yes = array(
1856
-                    'name' => __('Listing published', 'geodirectory'),
1857
-                    'desc' => __('Yes', 'geodirectory'),
1858
-                    'id' => 'geodir_bcc_listing_published',
1859
-                    'std' => 'yes',
1860
-                    'type' => 'radio',
1861
-                    'value' => '1',
1862
-                    'radiogroup' => 'start'
1863
-                );
1864
-
1865
-                $geodir_bcc_listing_published_no = array(
1866
-                    'name' => __('Listing published', 'geodirectory'),
1867
-                    'desc' => __('No', 'geodirectory'),
1868
-                    'id' => 'geodir_bcc_listing_published',
1869
-                    'std' => 'yes',
1870
-                    'type' => 'radio',
1871
-                    'value' => '0',
1872
-                    'radiogroup' => 'end'
1873
-                );
1874
-
1875
-                $new_settings[] = $geodir_bcc_listing_published_yes;
1876
-                $new_settings[] = $geodir_bcc_listing_published_no;
1877
-            }
1878
-            $new_settings[] = $setting;
1879
-        }
1880
-        $settings = $new_settings;
1881
-    }
1851
+	if (!empty($settings)) {
1852
+		$new_settings = array();
1853
+		foreach ($settings as $setting) {
1854
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
1855
+				$geodir_bcc_listing_published_yes = array(
1856
+					'name' => __('Listing published', 'geodirectory'),
1857
+					'desc' => __('Yes', 'geodirectory'),
1858
+					'id' => 'geodir_bcc_listing_published',
1859
+					'std' => 'yes',
1860
+					'type' => 'radio',
1861
+					'value' => '1',
1862
+					'radiogroup' => 'start'
1863
+				);
1864
+
1865
+				$geodir_bcc_listing_published_no = array(
1866
+					'name' => __('Listing published', 'geodirectory'),
1867
+					'desc' => __('No', 'geodirectory'),
1868
+					'id' => 'geodir_bcc_listing_published',
1869
+					'std' => 'yes',
1870
+					'type' => 'radio',
1871
+					'value' => '0',
1872
+					'radiogroup' => 'end'
1873
+				);
1874
+
1875
+				$new_settings[] = $geodir_bcc_listing_published_yes;
1876
+				$new_settings[] = $geodir_bcc_listing_published_no;
1877
+			}
1878
+			$new_settings[] = $setting;
1879
+		}
1880
+		$settings = $new_settings;
1881
+	}
1882 1882
 
1883
-    return $settings;
1883
+	return $settings;
1884 1884
 }
1885 1885
 
1886 1886
 
@@ -1895,19 +1895,19 @@  discard block
 block discarded – undo
1895 1895
  */
1896 1896
 function get_gd_theme_compat_callback()
1897 1897
 {
1898
-    global $wpdb;
1899
-    $themes = get_option('gd_theme_compats');
1900
-
1901
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
1902
-        if (isset($_POST['export'])) {
1903
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
1904
-        } else {
1905
-            echo json_encode($themes[$_POST['theme']]);
1906
-        }
1898
+	global $wpdb;
1899
+	$themes = get_option('gd_theme_compats');
1907 1900
 
1908
-    }
1901
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
1902
+		if (isset($_POST['export'])) {
1903
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
1904
+		} else {
1905
+			echo json_encode($themes[$_POST['theme']]);
1906
+		}
1907
+
1908
+	}
1909 1909
 
1910
-    die();
1910
+	die();
1911 1911
 }
1912 1912
 
1913 1913
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -1921,20 +1921,20 @@  discard block
 block discarded – undo
1921 1921
  */
1922 1922
 function get_gd_theme_compat_import_callback()
1923 1923
 {
1924
-    global $wpdb;
1925
-    $themes = get_option('gd_theme_compats');
1926
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
1927
-        $json = json_decode(stripslashes($_POST['theme']), true);
1928
-        if (!empty($json) && is_array($json)) {
1929
-            $key = sanitize_text_field(key($json));
1930
-            $themes[$key] = $json[$key];
1931
-            update_option('gd_theme_compats', $themes);
1932
-            echo $key;
1933
-            die();
1934
-        }
1935
-    }
1936
-    echo '0';
1937
-    die();
1924
+	global $wpdb;
1925
+	$themes = get_option('gd_theme_compats');
1926
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
1927
+		$json = json_decode(stripslashes($_POST['theme']), true);
1928
+		if (!empty($json) && is_array($json)) {
1929
+			$key = sanitize_text_field(key($json));
1930
+			$themes[$key] = $json[$key];
1931
+			update_option('gd_theme_compats', $themes);
1932
+			echo $key;
1933
+			die();
1934
+		}
1935
+	}
1936
+	echo '0';
1937
+	die();
1938 1938
 }
1939 1939
 
1940 1940
 
@@ -1947,39 +1947,39 @@  discard block
 block discarded – undo
1947 1947
  */
1948 1948
 function gd_set_theme_compat()
1949 1949
 {
1950
-    global $wpdb;
1951
-    $theme = wp_get_theme();
1950
+	global $wpdb;
1951
+	$theme = wp_get_theme();
1952 1952
 
1953
-    if ($theme->parent()) {
1954
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
1955
-    } else {
1956
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
1957
-    }
1953
+	if ($theme->parent()) {
1954
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
1955
+	} else {
1956
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
1957
+	}
1958 1958
 
1959
-    $theme_compats = get_option('gd_theme_compats');
1960
-    $current_compat = get_option('gd_theme_compat');
1961
-    $current_compat = str_replace("_custom", "", $current_compat);
1959
+	$theme_compats = get_option('gd_theme_compats');
1960
+	$current_compat = get_option('gd_theme_compat');
1961
+	$current_compat = str_replace("_custom", "", $current_compat);
1962 1962
  
1963
-    if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
1964
-        return;
1965
-    }// if already running correct compat then bail
1963
+	if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
1964
+		return;
1965
+	}// if already running correct compat then bail
1966 1966
 
1967
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
1968
-        update_option('gd_theme_compat', $theme_name);
1969
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
1967
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
1968
+		update_option('gd_theme_compat', $theme_name);
1969
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
1970 1970
 
1971
-        // if there are default options to set then set them
1972
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
1971
+		// if there are default options to set then set them
1972
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
1973 1973
 
1974
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
1975
-                update_option($key, $val);
1976
-            }
1977
-        }
1974
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
1975
+				update_option($key, $val);
1976
+			}
1977
+		}
1978 1978
 
1979
-    } else {
1980
-        update_option('gd_theme_compat', '');
1981
-        update_option('theme_compatibility_setting', '');
1982
-    }
1979
+	} else {
1980
+		update_option('gd_theme_compat', '');
1981
+		update_option('theme_compatibility_setting', '');
1982
+	}
1983 1983
 
1984 1984
 
1985 1985
 }
@@ -1994,9 +1994,9 @@  discard block
 block discarded – undo
1994 1994
  */
1995 1995
 function gd_check_avada_compat()
1996 1996
 {
1997
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
1998
-        add_action('admin_notices', 'gd_avada_compat_warning');
1999
-    }
1997
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
1998
+		add_action('admin_notices', 'gd_avada_compat_warning');
1999
+	}
2000 2000
 }
2001 2001
 
2002 2002
 
@@ -2009,22 +2009,22 @@  discard block
 block discarded – undo
2009 2009
 function gd_avada_compat_warning()
2010 2010
 {
2011 2011
 
2012
-    /*
2012
+	/*
2013 2013
     $msg_type = error
2014 2014
     $msg_type = updated fade
2015 2015
     $msg_type = update-nag
2016 2016
     */
2017 2017
 
2018
-    $plugin = 'avada-nag';
2019
-    $timestamp = 'avada-nag1234';
2020
-    $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2021
-    echo '<div id="' . $timestamp . '"  class="error">';
2022
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2023
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2024
-    echo "<p>$message</p>";
2025
-    echo "</div>";
2018
+	$plugin = 'avada-nag';
2019
+	$timestamp = 'avada-nag1234';
2020
+	$message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
2021
+	echo '<div id="' . $timestamp . '"  class="error">';
2022
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2023
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2024
+	echo "<p>$message</p>";
2025
+	echo "</div>";
2026 2026
 
2027
-    ?>
2027
+	?>
2028 2028
     <script>
2029 2029
         function gdRemoveANotification($plugin, $timestamp) {
2030 2030
 
@@ -2092,10 +2092,10 @@  discard block
 block discarded – undo
2092 2092
  */
2093 2093
 function geodir_avada_remove_notification()
2094 2094
 {
2095
-    update_option('avada_nag', TRUE);
2095
+	update_option('avada_nag', TRUE);
2096 2096
 
2097
-    // Always die in functions echoing ajax content
2098
-    die();
2097
+	// Always die in functions echoing ajax content
2098
+	die();
2099 2099
 }
2100 2100
 
2101 2101
 
@@ -2117,11 +2117,11 @@  discard block
 block discarded – undo
2117 2117
 	global $post, $typenow, $current_screen;
2118 2118
 	
2119 2119
 	$post_type = NULL;
2120
-    if (isset($_REQUEST['post_type']))
2120
+	if (isset($_REQUEST['post_type']))
2121 2121
 		$post_type = sanitize_key($_REQUEST['post_type']);
2122
-    elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2122
+	elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2123 2123
 		$post_type = get_post_type($_REQUEST['post']);
2124
-    elseif ($post && isset($post->post_type))
2124
+	elseif ($post && isset($post->post_type))
2125 2125
 		$post_type = $post->post_type;
2126 2126
 	elseif ($typenow)
2127 2127
 		$post_type = $typenow;
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 		// Don't allow same slug url for listing and location
2156 2156
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2157 2157
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2158
-        	wp_redirect($redirect_url);
2158
+			wp_redirect($redirect_url);
2159 2159
 			exit;
2160 2160
 		}
2161 2161
 		
@@ -2185,10 +2185,10 @@  discard block
 block discarded – undo
2185 2185
  * @package GeoDirectory
2186 2186
  */
2187 2187
 function geodir_hide_admin_preview_button() {
2188
-    global $post_type;
2189
-    $post_types = geodir_get_posttypes();
2190
-    if(in_array($post_type, $post_types))
2191
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2188
+	global $post_type;
2189
+	$post_types = geodir_get_posttypes();
2190
+	if(in_array($post_type, $post_types))
2191
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2192 2192
 }
2193 2193
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2194 2194
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2203,7 +2203,7 @@  discard block
 block discarded – undo
2203 2203
  */
2204 2204
 function geodir_import_export_tab( $tabs ) {
2205 2205
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2206
-    return $tabs;
2206
+	return $tabs;
2207 2207
 }
2208 2208
 
2209 2209
 /**
@@ -2218,26 +2218,26 @@  discard block
 block discarded – undo
2218 2218
 function geodir_import_export_page() {
2219 2219
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2220 2220
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2221
-    /**
2222
-     * Filter sample category data csv file url.
2223
-     *
2224
-     * @since 1.0.0
2225
-     * @package GeoDirectory
2226
-     *
2227
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2228
-     */
2221
+	/**
2222
+	 * Filter sample category data csv file url.
2223
+	 *
2224
+	 * @since 1.0.0
2225
+	 * @package GeoDirectory
2226
+	 *
2227
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2228
+	 */
2229 2229
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2230 2230
 	
2231 2231
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2232
-    /**
2233
-     * Filter sample post data csv file url.
2234
-     *
2235
-     * @since 1.0.0
2236
-     * @package GeoDirectory
2237
-     *
2238
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2239
-     */
2240
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2232
+	/**
2233
+	 * Filter sample post data csv file url.
2234
+	 *
2235
+	 * @since 1.0.0
2236
+	 * @package GeoDirectory
2237
+	 *
2238
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2239
+	 */
2240
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2241 2241
 	
2242 2242
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2243 2243
 	
@@ -2260,14 +2260,14 @@  discard block
 block discarded – undo
2260 2260
 	$gd_chunksize_options[100000] = 100000;
2261 2261
 	 
2262 2262
 	 /**
2263
-     * Filter max entries per export csv file.
2264
-     *
2265
-     * @since 1.5.6
2266
-     * @package GeoDirectory
2267
-     *
2268
-     * @param string $gd_chunksize_options Entries options.
2269
-     */
2270
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2263
+	  * Filter max entries per export csv file.
2264
+	  *
2265
+	  * @since 1.5.6
2266
+	  * @package GeoDirectory
2267
+	  *
2268
+	  * @param string $gd_chunksize_options Entries options.
2269
+	  */
2270
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2271 2271
 	
2272 2272
 	$gd_chunksize_option = '';
2273 2273
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2284,12 +2284,12 @@  discard block
 block discarded – undo
2284 2284
   <div class="gd-content-heading">
2285 2285
 
2286 2286
   <?php
2287
-    ini_set('max_execution_time', 999999);
2288
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2289
-    ini_restore('max_execution_time');
2287
+	ini_set('max_execution_time', 999999);
2288
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2289
+	ini_restore('max_execution_time');
2290 2290
 
2291
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2292
-        ?>
2291
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2292
+		?>
2293 2293
 	<div id="gd_ie_reqs" class="metabox-holder">
2294 2294
       <div class="meta-box-sortables ui-sortable">
2295 2295
         <div class="postbox">
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
 						 * Called just after the sample CSV download link.
2465 2465
 						 *
2466 2466
 						 * @since 1.0.0
2467
-                         * @package GeoDirectory
2467
+						 * @package GeoDirectory
2468 2468
 						 */
2469 2469
 						do_action('geodir_sample_cats_csv_download_link');
2470 2470
 						?>
@@ -2549,11 +2549,11 @@  discard block
 block discarded – undo
2549 2549
 	 *
2550 2550
 	 * Called after the last setting on the GD > Import & Export page.
2551 2551
 	 * @since 1.4.6
2552
-     * @package GeoDirectory
2552
+	 * @package GeoDirectory
2553 2553
 	 *
2554 2554
 	 * @param array $gd_posttypes GD post types.
2555
-     * @param array $gd_chunksize_options File chunk size options.
2556
-     * @param string $nonce Wordpress security token for GD import & export.
2555
+	 * @param array $gd_chunksize_options File chunk size options.
2556
+	 * @param string $nonce Wordpress security token for GD import & export.
2557 2557
 	 */
2558 2558
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2559 2559
 	?>
@@ -3240,44 +3240,44 @@  discard block
 block discarded – undo
3240 3240
 function geodir_init_filesystem()
3241 3241
 {
3242 3242
 
3243
-    if(!function_exists('get_filesystem_method')){
3244
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3245
-    }
3246
-    $access_type = get_filesystem_method();
3247
-    if ($access_type === 'direct') {
3248
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3249
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3250
-
3251
-        /* initialize the API */
3252
-        if (!WP_Filesystem($creds)) {
3253
-            /* any problems and we exit */
3254
-            //return '@@@3';
3255
-            return false;
3256
-        }
3243
+	if(!function_exists('get_filesystem_method')){
3244
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3245
+	}
3246
+	$access_type = get_filesystem_method();
3247
+	if ($access_type === 'direct') {
3248
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3249
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3250
+
3251
+		/* initialize the API */
3252
+		if (!WP_Filesystem($creds)) {
3253
+			/* any problems and we exit */
3254
+			//return '@@@3';
3255
+			return false;
3256
+		}
3257 3257
 
3258
-        global $wp_filesystem;
3259
-        return $wp_filesystem;
3260
-        /* do our file manipulations below */
3261
-    } elseif (defined('FTP_USER')) {
3262
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3258
+		global $wp_filesystem;
3259
+		return $wp_filesystem;
3260
+		/* do our file manipulations below */
3261
+	} elseif (defined('FTP_USER')) {
3262
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3263
+
3264
+		/* initialize the API */
3265
+		if (!WP_Filesystem($creds)) {
3266
+			/* any problems and we exit */
3267
+			//return '@@@33';
3268
+			return false;
3269
+		}
3263 3270
 
3264
-        /* initialize the API */
3265
-        if (!WP_Filesystem($creds)) {
3266
-            /* any problems and we exit */
3267
-            //return '@@@33';
3268
-            return false;
3269
-        }
3271
+		global $wp_filesystem;
3272
+		//return '@@@1';
3273
+		return $wp_filesystem;
3270 3274
 
3271
-        global $wp_filesystem;
3272
-        //return '@@@1';
3273
-        return $wp_filesystem;
3274
-
3275
-    } else {
3276
-        //return '@@@2';
3277
-        /* don't have direct write access. Prompt user with our notice */
3278
-        add_action('admin_notice', 'geodir_filesystem_notice');
3279
-        return false;
3280
-    }
3275
+	} else {
3276
+		//return '@@@2';
3277
+		/* don't have direct write access. Prompt user with our notice */
3278
+		add_action('admin_notice', 'geodir_filesystem_notice');
3279
+		return false;
3280
+	}
3281 3281
 
3282 3282
 }
3283 3283
 
@@ -3295,10 +3295,10 @@  discard block
 block discarded – undo
3295 3295
  */
3296 3296
 function geodir_filesystem_notice()
3297 3297
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3298
-    $access_type = get_filesystem_method();
3299
-    if ($access_type === 'direct') {
3300
-    } elseif (!defined('FTP_USER')) {
3301
-        ?>
3298
+	$access_type = get_filesystem_method();
3299
+	if ($access_type === 'direct') {
3300
+	} elseif (!defined('FTP_USER')) {
3301
+		?>
3302 3302
         <div class="error">
3303 3303
             <p><?php _e('GeoDirectory does not have access to your filesystem, thing like import/export will not work. Please define your details in wp-config.php as explained here', 'geodirectory'); ?>
3304 3304
                 <a target="_blank" href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants</a>
@@ -3326,1273 +3326,1273 @@  discard block
 block discarded – undo
3326 3326
  * @return string Json data.
3327 3327
  */
3328 3328
 function geodir_ajax_import_export() {
3329
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3329
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3330 3330
     
3331
-    error_reporting(0);
3331
+	error_reporting(0);
3332 3332
 
3333
-    $xstart = microtime(true);
3333
+	$xstart = microtime(true);
3334 3334
 
3335
-    // try to set higher limits for import
3336
-    $max_input_time = ini_get('max_input_time');
3337
-    $max_execution_time = ini_get('max_execution_time');
3338
-    $memory_limit= ini_get('memory_limit');
3335
+	// try to set higher limits for import
3336
+	$max_input_time = ini_get('max_input_time');
3337
+	$max_execution_time = ini_get('max_execution_time');
3338
+	$memory_limit= ini_get('memory_limit');
3339 3339
 
3340
-    if(!$max_input_time || $max_input_time<3000){
3341
-        ini_set('max_input_time', 3000);
3342
-    }
3340
+	if(!$max_input_time || $max_input_time<3000){
3341
+		ini_set('max_input_time', 3000);
3342
+	}
3343 3343
 
3344
-    if(!$max_execution_time || $max_execution_time<3000){
3345
-        ini_set('max_execution_time', 3000);
3346
-    }
3344
+	if(!$max_execution_time || $max_execution_time<3000){
3345
+		ini_set('max_execution_time', 3000);
3346
+	}
3347 3347
 
3348
-    if($memory_limit && str_replace('M','',$memory_limit)){
3349
-        if(str_replace('M','',$memory_limit)<256){
3350
-            ini_set('memory_limit', '256M');
3351
-        }
3352
-    }
3348
+	if($memory_limit && str_replace('M','',$memory_limit)){
3349
+		if(str_replace('M','',$memory_limit)<256){
3350
+			ini_set('memory_limit', '256M');
3351
+		}
3352
+	}
3353 3353
 
3354
-    $json = array();
3354
+	$json = array();
3355 3355
 
3356
-    if ( !current_user_can( 'manage_options' ) ) {
3357
-        wp_send_json( $json );
3358
-    }
3356
+	if ( !current_user_can( 'manage_options' ) ) {
3357
+		wp_send_json( $json );
3358
+	}
3359 3359
 
3360
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3361
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3362
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3360
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3361
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3362
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3363 3363
 
3364
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3365
-        wp_send_json( $json );
3366
-    }
3364
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3365
+		wp_send_json( $json );
3366
+	}
3367 3367
 
3368
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3369
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3370
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3371
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3368
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3369
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3370
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3371
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3372 3372
 
3373
-    $wp_filesystem = geodir_init_filesystem();
3374
-    if (!$wp_filesystem) {
3375
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3376
-        wp_send_json( $json );
3377
-    }
3373
+	$wp_filesystem = geodir_init_filesystem();
3374
+	if (!$wp_filesystem) {
3375
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3376
+		wp_send_json( $json );
3377
+	}
3378 3378
 
3379
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3380
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3381
-        wp_send_json( $json );
3382
-    }
3379
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3380
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3381
+		wp_send_json( $json );
3382
+	}
3383 3383
 
3384
-    $csv_file_dir = geodir_path_import_export( false );
3385
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3386
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3387
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3388
-            wp_send_json( $json );
3389
-        }
3390
-    }
3384
+	$csv_file_dir = geodir_path_import_export( false );
3385
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3386
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3387
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3388
+			wp_send_json( $json );
3389
+		}
3390
+	}
3391 3391
     
3392
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3393
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3394
-
3395
-    switch ( $task ) {
3396
-        case 'export_posts': {
3397
-            // WPML
3398
-            $is_wpml = geodir_is_wpml();
3399
-            if ($is_wpml) {
3400
-                global $sitepress;
3401
-                $active_lang = ICL_LANGUAGE_CODE;
3392
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3393
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3394
+
3395
+	switch ( $task ) {
3396
+		case 'export_posts': {
3397
+			// WPML
3398
+			$is_wpml = geodir_is_wpml();
3399
+			if ($is_wpml) {
3400
+				global $sitepress;
3401
+				$active_lang = ICL_LANGUAGE_CODE;
3402 3402
                 
3403
-                $sitepress->switch_lang('all', true);
3404
-            }
3405
-            // WPML
3406
-            if ( $post_type == 'gd_event' ) {
3407
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3408
-            }
3409
-            $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3403
+				$sitepress->switch_lang('all', true);
3404
+			}
3405
+			// WPML
3406
+			if ( $post_type == 'gd_event' ) {
3407
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3408
+			}
3409
+			$filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
3410 3410
             
3411
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3412
-            if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3413
-                $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3414
-            }
3415
-            $posts_count = geodir_get_posts_count( $post_type );
3416
-            $file_url_base = geodir_path_import_export() . '/';
3417
-            $file_url = $file_url_base . $file_name . '.csv';
3418
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3419
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3411
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3412
+			if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
3413
+				$file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) );
3414
+			}
3415
+			$posts_count = geodir_get_posts_count( $post_type );
3416
+			$file_url_base = geodir_path_import_export() . '/';
3417
+			$file_url = $file_url_base . $file_name . '.csv';
3418
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3419
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3420 3420
             
3421
-            $chunk_file_paths = array();
3421
+			$chunk_file_paths = array();
3422 3422
 
3423
-            if ( isset( $_REQUEST['_c'] ) ) {
3424
-                $json['total'] = $posts_count;
3425
-                // WPML
3426
-                if ($is_wpml) {
3427
-                    $sitepress->switch_lang($active_lang, true);
3428
-                }
3429
-                // WPML
3430
-                wp_send_json( $json );
3431
-                gd_die();
3432
-            } else if ( isset( $_REQUEST['_st'] ) ) {
3433
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3434
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3435
-                $percentage = min( $percentage, 100 );
3423
+			if ( isset( $_REQUEST['_c'] ) ) {
3424
+				$json['total'] = $posts_count;
3425
+				// WPML
3426
+				if ($is_wpml) {
3427
+					$sitepress->switch_lang($active_lang, true);
3428
+				}
3429
+				// WPML
3430
+				wp_send_json( $json );
3431
+				gd_die();
3432
+			} else if ( isset( $_REQUEST['_st'] ) ) {
3433
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3434
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3435
+				$percentage = min( $percentage, 100 );
3436 3436
                 
3437
-                $json['percentage'] = $percentage;
3438
-                // WPML
3439
-                if ($is_wpml) {
3440
-                    $sitepress->switch_lang($active_lang, true);
3441
-                }
3442
-                // WPML
3443
-                wp_send_json( $json );
3444
-                gd_die();
3445
-            } else {
3446
-                if ( !$posts_count > 0 ) {
3447
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3448
-                } else {
3449
-                    $total_posts = $posts_count;
3450
-                    if ($chunk_per_page > $total_posts) {
3451
-                        $chunk_per_page = $total_posts;
3452
-                    }
3453
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3437
+				$json['percentage'] = $percentage;
3438
+				// WPML
3439
+				if ($is_wpml) {
3440
+					$sitepress->switch_lang($active_lang, true);
3441
+				}
3442
+				// WPML
3443
+				wp_send_json( $json );
3444
+				gd_die();
3445
+			} else {
3446
+				if ( !$posts_count > 0 ) {
3447
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3448
+				} else {
3449
+					$total_posts = $posts_count;
3450
+					if ($chunk_per_page > $total_posts) {
3451
+						$chunk_per_page = $total_posts;
3452
+					}
3453
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3454 3454
                     
3455
-                    $j = $chunk_page_no;
3456
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3455
+					$j = $chunk_page_no;
3456
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3457 3457
                     
3458
-                    $per_page = 500;
3459
-                    if ($per_page > $chunk_per_page) {
3460
-                        $per_page = $chunk_per_page;
3461
-                    }
3462
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3458
+					$per_page = 500;
3459
+					if ($per_page > $chunk_per_page) {
3460
+						$per_page = $chunk_per_page;
3461
+					}
3462
+					$total_pages = ceil( $chunk_per_page / $per_page );
3463 3463
                     
3464
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3465
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3464
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3465
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3466 3466
                         
3467
-                        $clear = $i == 0 ? true : false;
3468
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3469
-                    }
3467
+						$clear = $i == 0 ? true : false;
3468
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3469
+					}
3470 3470
                         
3471
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3472
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3473
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3474
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3475
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3471
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3472
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3473
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3474
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3475
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3476 3476
                         
3477
-                        $file_url = $file_url_base . $chunk_file_name;
3478
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3479
-                    }
3477
+						$file_url = $file_url_base . $chunk_file_name;
3478
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3479
+					}
3480 3480
                     
3481
-                    if ( !empty($chunk_file_paths) ) {
3482
-                        $json['total'] = $posts_count;
3483
-                        $json['files'] = $chunk_file_paths;
3484
-                    } else {
3485
-                        if ($j > 1) {
3486
-                            $json['total'] = $posts_count;
3487
-                            $json['files'] = array();
3488
-                        } else {
3489
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3490
-                        }
3491
-                    }
3492
-                }
3493
-                // WPML
3494
-                if ($is_wpml) {
3495
-                    $sitepress->switch_lang($active_lang, true);
3496
-                }
3497
-                // WPML
3498
-                wp_send_json( $json );
3499
-            }
3500
-        }
3501
-        break;
3502
-        case 'export_cats': {
3503
-            // WPML
3504
-            $is_wpml = geodir_is_wpml();
3505
-            if ($is_wpml) {
3506
-                global $sitepress;
3507
-                $active_lang = ICL_LANGUAGE_CODE;
3481
+					if ( !empty($chunk_file_paths) ) {
3482
+						$json['total'] = $posts_count;
3483
+						$json['files'] = $chunk_file_paths;
3484
+					} else {
3485
+						if ($j > 1) {
3486
+							$json['total'] = $posts_count;
3487
+							$json['files'] = array();
3488
+						} else {
3489
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3490
+						}
3491
+					}
3492
+				}
3493
+				// WPML
3494
+				if ($is_wpml) {
3495
+					$sitepress->switch_lang($active_lang, true);
3496
+				}
3497
+				// WPML
3498
+				wp_send_json( $json );
3499
+			}
3500
+		}
3501
+		break;
3502
+		case 'export_cats': {
3503
+			// WPML
3504
+			$is_wpml = geodir_is_wpml();
3505
+			if ($is_wpml) {
3506
+				global $sitepress;
3507
+				$active_lang = ICL_LANGUAGE_CODE;
3508 3508
                 
3509
-                $sitepress->switch_lang('all', true);
3510
-            }
3511
-            // WPML
3512
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3509
+				$sitepress->switch_lang('all', true);
3510
+			}
3511
+			// WPML
3512
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3513 3513
             
3514
-            $terms_count = geodir_get_terms_count( $post_type );
3515
-            $file_url_base = geodir_path_import_export() . '/';
3516
-            $file_url = $file_url_base . $file_name . '.csv';
3517
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3518
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3514
+			$terms_count = geodir_get_terms_count( $post_type );
3515
+			$file_url_base = geodir_path_import_export() . '/';
3516
+			$file_url = $file_url_base . $file_name . '.csv';
3517
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3518
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3519 3519
             
3520
-            $chunk_file_paths = array();
3520
+			$chunk_file_paths = array();
3521 3521
             
3522
-            if ( isset( $_REQUEST['_st'] ) ) {
3523
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3524
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3525
-                $percentage = min( $percentage, 100 );
3522
+			if ( isset( $_REQUEST['_st'] ) ) {
3523
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3524
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3525
+				$percentage = min( $percentage, 100 );
3526 3526
                 
3527
-                $json['percentage'] = $percentage;
3528
-                // WPML
3529
-                if ($is_wpml) {
3530
-                    $sitepress->switch_lang($active_lang, true);
3531
-                }
3532
-                // WPML
3533
-                wp_send_json( $json );
3534
-            } else {
3535
-                if ( !$terms_count > 0 ) {
3536
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3537
-                } else {
3538
-                    $total_terms = $terms_count;
3539
-                    if ($chunk_per_page > $terms_count) {
3540
-                        $chunk_per_page = $terms_count;
3541
-                    }
3542
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3527
+				$json['percentage'] = $percentage;
3528
+				// WPML
3529
+				if ($is_wpml) {
3530
+					$sitepress->switch_lang($active_lang, true);
3531
+				}
3532
+				// WPML
3533
+				wp_send_json( $json );
3534
+			} else {
3535
+				if ( !$terms_count > 0 ) {
3536
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3537
+				} else {
3538
+					$total_terms = $terms_count;
3539
+					if ($chunk_per_page > $terms_count) {
3540
+						$chunk_per_page = $terms_count;
3541
+					}
3542
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3543 3543
                     
3544
-                    $j = $chunk_page_no;
3545
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3544
+					$j = $chunk_page_no;
3545
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3546 3546
                     
3547
-                    $per_page = 500;
3548
-                    if ($per_page > $chunk_per_page) {
3549
-                        $per_page = $chunk_per_page;
3550
-                    }
3551
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3547
+					$per_page = 500;
3548
+					if ($per_page > $chunk_per_page) {
3549
+						$per_page = $chunk_per_page;
3550
+					}
3551
+					$total_pages = ceil( $chunk_per_page / $per_page );
3552 3552
                     
3553
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3554
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3553
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3554
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3555 3555
                         
3556
-                        $clear = $i == 0 ? true : false;
3557
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3558
-                    }
3556
+						$clear = $i == 0 ? true : false;
3557
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3558
+					}
3559 3559
                     
3560
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3561
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3562
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3563
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3564
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3560
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3561
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3562
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3563
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3564
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3565 3565
                         
3566
-                        $file_url = $file_url_base . $chunk_file_name;
3567
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3568
-                    }
3566
+						$file_url = $file_url_base . $chunk_file_name;
3567
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3568
+					}
3569 3569
                     
3570
-                    if ( !empty($chunk_file_paths) ) {
3571
-                        $json['total'] = $terms_count;
3572
-                        $json['files'] = $chunk_file_paths;
3573
-                    } else {
3574
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3575
-                    }
3576
-                }
3577
-                // WPML
3578
-                if ($is_wpml) {
3579
-                    $sitepress->switch_lang($active_lang, true);
3580
-                }
3581
-                // WPML
3582
-                wp_send_json( $json );
3583
-            }
3584
-        }
3585
-        break;
3586
-        case 'export_locations': {
3587
-            $file_url_base = geodir_path_import_export() . '/';
3588
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3589
-            $file_url = $file_url_base . $file_name . '.csv';
3590
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3591
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3570
+					if ( !empty($chunk_file_paths) ) {
3571
+						$json['total'] = $terms_count;
3572
+						$json['files'] = $chunk_file_paths;
3573
+					} else {
3574
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3575
+					}
3576
+				}
3577
+				// WPML
3578
+				if ($is_wpml) {
3579
+					$sitepress->switch_lang($active_lang, true);
3580
+				}
3581
+				// WPML
3582
+				wp_send_json( $json );
3583
+			}
3584
+		}
3585
+		break;
3586
+		case 'export_locations': {
3587
+			$file_url_base = geodir_path_import_export() . '/';
3588
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3589
+			$file_url = $file_url_base . $file_name . '.csv';
3590
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3591
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3592 3592
             
3593
-            $items_count = (int)geodir_location_imex_count_locations();
3593
+			$items_count = (int)geodir_location_imex_count_locations();
3594 3594
             
3595
-            if ( isset( $_REQUEST['_st'] ) ) {
3596
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3597
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3598
-                $percentage = min( $percentage, 100 );
3595
+			if ( isset( $_REQUEST['_st'] ) ) {
3596
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3597
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3598
+				$percentage = min( $percentage, 100 );
3599 3599
                 
3600
-                $json['percentage'] = $percentage;
3601
-                wp_send_json( $json );
3602
-            } else {
3603
-                $chunk_file_paths = array();
3600
+				$json['percentage'] = $percentage;
3601
+				wp_send_json( $json );
3602
+			} else {
3603
+				$chunk_file_paths = array();
3604 3604
                 
3605
-                if ( !$items_count > 0 ) {
3606
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3607
-                } else {
3608
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3609
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3605
+				if ( !$items_count > 0 ) {
3606
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3607
+				} else {
3608
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3609
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3610 3610
                     
3611
-                    $j = $chunk_page_no;
3612
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3611
+					$j = $chunk_page_no;
3612
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3613 3613
                     
3614
-                    $per_page = 500;
3615
-                    $per_page = min( $per_page, $chunk_per_page );
3616
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3614
+					$per_page = 500;
3615
+					$per_page = min( $per_page, $chunk_per_page );
3616
+					$total_pages = ceil( $chunk_per_page / $per_page );
3617 3617
                     
3618
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3619
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3618
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3619
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3620 3620
                         
3621
-                        $clear = $i == 0 ? true : false;
3622
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3623
-                    }
3621
+						$clear = $i == 0 ? true : false;
3622
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3623
+					}
3624 3624
                     
3625
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3626
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3627
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3628
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3629
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3625
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3626
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3627
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3628
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3629
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3630 3630
                         
3631
-                        $file_url = $file_url_base . $chunk_file_name;
3632
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3633
-                    }
3631
+						$file_url = $file_url_base . $chunk_file_name;
3632
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3633
+					}
3634 3634
                     
3635
-                    if ( !empty($chunk_file_paths) ) {
3636
-                        $json['total'] = $items_count;
3637
-                        $json['files'] = $chunk_file_paths;
3638
-                    } else {
3639
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3640
-                    }
3641
-                }
3642
-                wp_send_json( $json );
3643
-            }
3644
-        }
3645
-        break;
3646
-        case 'export_hoods': {
3647
-            $file_url_base = geodir_path_import_export() . '/';
3648
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3649
-            $file_url = $file_url_base . $file_name . '.csv';
3650
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3651
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3635
+					if ( !empty($chunk_file_paths) ) {
3636
+						$json['total'] = $items_count;
3637
+						$json['files'] = $chunk_file_paths;
3638
+					} else {
3639
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3640
+					}
3641
+				}
3642
+				wp_send_json( $json );
3643
+			}
3644
+		}
3645
+		break;
3646
+		case 'export_hoods': {
3647
+			$file_url_base = geodir_path_import_export() . '/';
3648
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3649
+			$file_url = $file_url_base . $file_name . '.csv';
3650
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3651
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3652 3652
             
3653
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3653
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3654 3654
             
3655
-            if ( isset( $_REQUEST['_st'] ) ) {
3656
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3657
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3658
-                $percentage = min( $percentage, 100 );
3655
+			if ( isset( $_REQUEST['_st'] ) ) {
3656
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3657
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3658
+				$percentage = min( $percentage, 100 );
3659 3659
                 
3660
-                $json['percentage'] = $percentage;
3661
-                wp_send_json( $json );
3662
-            } else {
3663
-                $chunk_file_paths = array();
3660
+				$json['percentage'] = $percentage;
3661
+				wp_send_json( $json );
3662
+			} else {
3663
+				$chunk_file_paths = array();
3664 3664
                 
3665
-                if ( !$items_count > 0 ) {
3666
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3667
-                } else {
3668
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3669
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3665
+				if ( !$items_count > 0 ) {
3666
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3667
+				} else {
3668
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3669
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3670 3670
                     
3671
-                    $j = $chunk_page_no;
3672
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3671
+					$j = $chunk_page_no;
3672
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3673 3673
                     
3674
-                    $per_page = 500;
3675
-                    $per_page = min( $per_page, $chunk_per_page );
3676
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3674
+					$per_page = 500;
3675
+					$per_page = min( $per_page, $chunk_per_page );
3676
+					$total_pages = ceil( $chunk_per_page / $per_page );
3677 3677
                     
3678
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3679
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3678
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3679
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3680 3680
                         
3681
-                        $clear = $i == 0 ? true : false;
3682
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3683
-                    }
3681
+						$clear = $i == 0 ? true : false;
3682
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3683
+					}
3684 3684
                     
3685
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3686
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3687
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3688
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3689
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3685
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3686
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3687
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3688
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3689
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3690 3690
                         
3691
-                        $file_url = $file_url_base . $chunk_file_name;
3692
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3693
-                    }
3691
+						$file_url = $file_url_base . $chunk_file_name;
3692
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3693
+					}
3694 3694
                     
3695
-                    if ( !empty($chunk_file_paths) ) {
3696
-                        $json['total'] = $items_count;
3697
-                        $json['files'] = $chunk_file_paths;
3698
-                    } else {
3699
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3700
-                    }
3701
-                }
3702
-                wp_send_json( $json );
3703
-            }
3704
-        }
3705
-        break;
3706
-        case 'prepare_import':
3707
-        case 'import_cat':
3708
-        case 'import_post':
3709
-        case 'import_loc':
3710
-        case 'import_hood': {
3711
-            // WPML
3712
-            $is_wpml = geodir_is_wpml();
3713
-            if ($is_wpml) {
3714
-                global $sitepress;
3715
-                $active_lang = ICL_LANGUAGE_CODE;
3716
-            }
3717
-            // WPML
3695
+					if ( !empty($chunk_file_paths) ) {
3696
+						$json['total'] = $items_count;
3697
+						$json['files'] = $chunk_file_paths;
3698
+					} else {
3699
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3700
+					}
3701
+				}
3702
+				wp_send_json( $json );
3703
+			}
3704
+		}
3705
+		break;
3706
+		case 'prepare_import':
3707
+		case 'import_cat':
3708
+		case 'import_post':
3709
+		case 'import_loc':
3710
+		case 'import_hood': {
3711
+			// WPML
3712
+			$is_wpml = geodir_is_wpml();
3713
+			if ($is_wpml) {
3714
+				global $sitepress;
3715
+				$active_lang = ICL_LANGUAGE_CODE;
3716
+			}
3717
+			// WPML
3718 3718
             
3719
-            ini_set( 'auto_detect_line_endings', true );
3719
+			ini_set( 'auto_detect_line_endings', true );
3720 3720
             
3721
-            $uploads = wp_upload_dir();
3722
-            $uploads_dir = $uploads['path'];
3723
-            $uploads_subdir = $uploads['subdir'];
3721
+			$uploads = wp_upload_dir();
3722
+			$uploads_dir = $uploads['path'];
3723
+			$uploads_subdir = $uploads['subdir'];
3724 3724
             
3725
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3726
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3725
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3726
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3727 3727
             
3728
-            $csv_file_arr = explode( '/', $csv_file );
3729
-            $csv_filename = end( $csv_file_arr );
3730
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3728
+			$csv_file_arr = explode( '/', $csv_file );
3729
+			$csv_filename = end( $csv_file_arr );
3730
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3731 3731
             
3732
-            $json['file'] = $csv_file;
3733
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3734
-            $file = array();
3732
+			$json['file'] = $csv_file;
3733
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3734
+			$file = array();
3735 3735
 
3736
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3737
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3736
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3737
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3738 3738
                 
3739
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
3740
-                    $json['error'] = NULL;
3741
-
3742
-                    $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
3743
-                    setlocale(LC_ALL, 'en_US.UTF-8');
3744
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
3745
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
3746
-                            if ( !empty( $data ) ) {
3747
-                                $file[] = $data;
3748
-                            }
3749
-                        }
3750
-                        fclose($handle);
3751
-                    }
3752
-                    setlocale(LC_ALL, $lc_all);
3739
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
3740
+					$json['error'] = NULL;
3741
+
3742
+					$lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line
3743
+					setlocale(LC_ALL, 'en_US.UTF-8');
3744
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
3745
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
3746
+							if ( !empty( $data ) ) {
3747
+								$file[] = $data;
3748
+							}
3749
+						}
3750
+						fclose($handle);
3751
+					}
3752
+					setlocale(LC_ALL, $lc_all);
3753 3753
 
3754
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
3754
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
3755 3755
                     
3756
-                    if (!$json['rows'] > 0) {
3757
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
3758
-                    }
3759
-                } else {
3760
-                    wp_send_json( $json );
3761
-                }
3762
-            } else {
3763
-                wp_send_json( $json );
3764
-            }
3756
+					if (!$json['rows'] > 0) {
3757
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
3758
+					}
3759
+				} else {
3760
+					wp_send_json( $json );
3761
+				}
3762
+			} else {
3763
+				wp_send_json( $json );
3764
+			}
3765 3765
             
3766
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
3767
-                wp_send_json( $json );
3768
-            }
3766
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
3767
+				wp_send_json( $json );
3768
+			}
3769 3769
             
3770
-            $total = $json['rows'];
3771
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
3772
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
3770
+			$total = $json['rows'];
3771
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
3772
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
3773 3773
             
3774
-            $count = $limit;
3774
+			$count = $limit;
3775 3775
             
3776
-            if ($count < $total) {
3777
-                $count = $processed + $count;
3778
-                if ($count > $total) {
3779
-                    $count = $total;
3780
-                }
3781
-            } else {
3782
-                $count = $total;
3783
-            }
3776
+			if ($count < $total) {
3777
+				$count = $processed + $count;
3778
+				if ($count > $total) {
3779
+					$count = $total;
3780
+				}
3781
+			} else {
3782
+				$count = $total;
3783
+			}
3784 3784
             
3785
-            $created = 0;
3786
-            $updated = 0;
3787
-            $skipped = 0;
3788
-            $invalid = 0;
3789
-            $invalid_addr = 0;
3790
-            $images = 0;
3785
+			$created = 0;
3786
+			$updated = 0;
3787
+			$skipped = 0;
3788
+			$invalid = 0;
3789
+			$invalid_addr = 0;
3790
+			$images = 0;
3791 3791
             
3792
-            $gd_post_info = array();
3793
-            $countpost = 0;
3792
+			$gd_post_info = array();
3793
+			$countpost = 0;
3794 3794
             
3795
-            $post_types = geodir_get_posttypes();
3795
+			$post_types = geodir_get_posttypes();
3796 3796
 
3797
-            if ( $task == 'import_cat' ) {
3798
-                if (!empty($file)) {
3799
-                    $columns = isset($file[0]) ? $file[0] : NULL;
3797
+			if ( $task == 'import_cat' ) {
3798
+				if (!empty($file)) {
3799
+					$columns = isset($file[0]) ? $file[0] : NULL;
3800 3800
                     
3801
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
3802
-                        $json['error'] = CSV_INVAILD_FILE;
3803
-                        wp_send_json( $json );
3804
-                        exit;
3805
-                    }
3801
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
3802
+						$json['error'] = CSV_INVAILD_FILE;
3803
+						wp_send_json( $json );
3804
+						exit;
3805
+					}
3806 3806
                     
3807
-                    $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
3807
+					$gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
3808 3808
                     
3809
-                    for ($i = 1; $i <= $limit; $i++) {
3810
-                        $index = $processed + $i;
3809
+					for ($i = 1; $i <= $limit; $i++) {
3810
+						$index = $processed + $i;
3811 3811
                         
3812
-                        if (isset($file[$index])) {
3813
-                            $row = $file[$index];
3814
-                            $row = array_map( 'trim', $row );
3815
-                            //$row = array_map( 'utf8_encode', $row );
3812
+						if (isset($file[$index])) {
3813
+							$row = $file[$index];
3814
+							$row = array_map( 'trim', $row );
3815
+							//$row = array_map( 'utf8_encode', $row );
3816 3816
                             
3817
-                            $cat_id = '';
3818
-                            $cat_name = '';
3819
-                            $cat_slug = '';
3820
-                            $cat_posttype = '';
3821
-                            $cat_parent = '';
3822
-                            $cat_description = '';
3823
-                            $cat_schema = '';
3824
-                            $cat_top_description = '';
3825
-                            $cat_image = '';
3826
-                            $cat_icon = '';
3827
-                            $cat_language = '';
3828
-                            $cat_id_original = '';
3817
+							$cat_id = '';
3818
+							$cat_name = '';
3819
+							$cat_slug = '';
3820
+							$cat_posttype = '';
3821
+							$cat_parent = '';
3822
+							$cat_description = '';
3823
+							$cat_schema = '';
3824
+							$cat_top_description = '';
3825
+							$cat_image = '';
3826
+							$cat_icon = '';
3827
+							$cat_language = '';
3828
+							$cat_id_original = '';
3829 3829
                             
3830
-                            $c = 0;
3831
-                            foreach ($columns as $column ) {
3832
-                                if ( $column == 'cat_id' ) {
3833
-                                    $cat_id = (int)$row[$c];
3834
-                                } else if ( $column == 'cat_name' ) {
3835
-                                    $cat_name = $row[$c];
3836
-                                } else if ( $column == 'cat_slug' ) {
3837
-                                    $cat_slug = $row[$c];
3838
-                                } else if ( $column == 'cat_posttype' ) {
3839
-                                    $cat_posttype = $row[$c];
3840
-                                } else if ( $column == 'cat_parent' ) {
3841
-                                    $cat_parent = trim($row[$c]);
3842
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
3843
-                                    $cat_schema = $row[$c];
3844
-                                } else if ( $column == 'cat_description' ) {
3845
-                                    $cat_description = $row[$c];
3846
-                                } else if ( $column == 'cat_top_description' ) {
3847
-                                    $cat_top_description = $row[$c];
3848
-                                } else if ( $column == 'cat_image' ) {
3849
-                                    $cat_image = $row[$c];
3850
-                                } else if ( $column == 'cat_icon' ) {
3851
-                                    $cat_icon = $row[$c];
3852
-                                }
3853
-                                // WPML
3854
-                                if ( $is_wpml ) {
3855
-                                    if ( $column == 'cat_language' ) {
3856
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
3857
-                                    } else if ( $column == 'cat_id_original' ) {
3858
-                                        $cat_id_original = (int)$row[$c];
3859
-                                    }
3860
-                                }
3861
-                                // WPML
3862
-                                $c++;
3863
-                            }
3830
+							$c = 0;
3831
+							foreach ($columns as $column ) {
3832
+								if ( $column == 'cat_id' ) {
3833
+									$cat_id = (int)$row[$c];
3834
+								} else if ( $column == 'cat_name' ) {
3835
+									$cat_name = $row[$c];
3836
+								} else if ( $column == 'cat_slug' ) {
3837
+									$cat_slug = $row[$c];
3838
+								} else if ( $column == 'cat_posttype' ) {
3839
+									$cat_posttype = $row[$c];
3840
+								} else if ( $column == 'cat_parent' ) {
3841
+									$cat_parent = trim($row[$c]);
3842
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
3843
+									$cat_schema = $row[$c];
3844
+								} else if ( $column == 'cat_description' ) {
3845
+									$cat_description = $row[$c];
3846
+								} else if ( $column == 'cat_top_description' ) {
3847
+									$cat_top_description = $row[$c];
3848
+								} else if ( $column == 'cat_image' ) {
3849
+									$cat_image = $row[$c];
3850
+								} else if ( $column == 'cat_icon' ) {
3851
+									$cat_icon = $row[$c];
3852
+								}
3853
+								// WPML
3854
+								if ( $is_wpml ) {
3855
+									if ( $column == 'cat_language' ) {
3856
+										$cat_language = geodir_strtolower( trim( $row[$c] ) );
3857
+									} else if ( $column == 'cat_id_original' ) {
3858
+										$cat_id_original = (int)$row[$c];
3859
+									}
3860
+								}
3861
+								// WPML
3862
+								$c++;
3863
+							}
3864 3864
                             
3865
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
3866
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
3865
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
3866
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
3867 3867
                                 
3868
-                                $invalid++;
3869
-                                continue;
3870
-                            }
3868
+								$invalid++;
3869
+								continue;
3870
+							}
3871 3871
                             
3872
-                            // WPML
3873
-                            if ($is_wpml && $cat_language != '') {
3874
-                                $sitepress->switch_lang($cat_language, true);
3875
-                            }
3876
-                            // WPML
3872
+							// WPML
3873
+							if ($is_wpml && $cat_language != '') {
3874
+								$sitepress->switch_lang($cat_language, true);
3875
+							}
3876
+							// WPML
3877 3877
                                                         
3878
-                            $term_data = array();
3879
-                            $term_data['name'] = $cat_name;
3880
-                            $term_data['slug'] = $cat_slug;
3881
-                            $term_data['description'] = $cat_description;
3882
-                            $term_data['cat_schema'] = $cat_schema;
3883
-                            $term_data['top_description'] = $cat_top_description;
3884
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
3885
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
3878
+							$term_data = array();
3879
+							$term_data['name'] = $cat_name;
3880
+							$term_data['slug'] = $cat_slug;
3881
+							$term_data['description'] = $cat_description;
3882
+							$term_data['cat_schema'] = $cat_schema;
3883
+							$term_data['top_description'] = $cat_top_description;
3884
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
3885
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
3886 3886
                             
3887
-                            //$term_data = array_map( 'utf8_encode', $term_data );
3887
+							//$term_data = array_map( 'utf8_encode', $term_data );
3888 3888
                             
3889
-                            $taxonomy = $cat_posttype . 'category';
3889
+							$taxonomy = $cat_posttype . 'category';
3890 3890
                             
3891
-                            $term_data['taxonomy'] = $taxonomy;
3891
+							$term_data['taxonomy'] = $taxonomy;
3892 3892
 
3893
-                            $term_parent_id = 0;
3894
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
3895
-                                $term_parent = '';
3893
+							$term_parent_id = 0;
3894
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
3895
+								$term_parent = '';
3896 3896
                                 
3897
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
3898
-                                    //
3899
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
3900
-                                    //
3901
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
3902
-                                    //
3903
-                                } else {
3904
-                                    $term_parent_data = array();
3905
-                                    $term_parent_data['name'] = $cat_parent;
3906
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
3907
-                                    $term_parent_data['taxonomy'] = $taxonomy;
3897
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
3898
+									//
3899
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
3900
+									//
3901
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
3902
+									//
3903
+								} else {
3904
+									$term_parent_data = array();
3905
+									$term_parent_data['name'] = $cat_parent;
3906
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
3907
+									$term_parent_data['taxonomy'] = $taxonomy;
3908 3908
                                     
3909
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
3910
-                                }
3909
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
3910
+								}
3911 3911
                                 
3912
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
3913
-                                    $term_parent_id = (int)$term_parent->term_id;
3914
-                                }
3915
-                            }
3916
-                            $term_data['parent'] = (int)$term_parent_id;
3912
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
3913
+									$term_parent_id = (int)$term_parent->term_id;
3914
+								}
3915
+							}
3916
+							$term_data['parent'] = (int)$term_parent_id;
3917 3917
 
3918
-                            $term_id = NULL;
3919
-                            if ( $import_choice == 'update' ) {
3920
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3921
-                                    $term_data['term_id'] = $term['term_id'];
3918
+							$term_id = NULL;
3919
+							if ( $import_choice == 'update' ) {
3920
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3921
+									$term_data['term_id'] = $term['term_id'];
3922 3922
                                     
3923
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3924
-                                        $updated++;
3925
-                                    } else {
3926
-                                        $invalid++;
3927
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3928
-                                    }
3929
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3930
-                                    $term_data['term_id'] = $term['term_id'];
3923
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3924
+										$updated++;
3925
+									} else {
3926
+										$invalid++;
3927
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3928
+									}
3929
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3930
+									$term_data['term_id'] = $term['term_id'];
3931 3931
                                     
3932
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3933
-                                        $updated++;
3934
-                                    } else {
3935
-                                        $invalid++;
3936
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3937
-                                    }
3938
-                                } else {
3939
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3940
-                                        $created++;
3941
-                                    } else {
3942
-                                        $invalid++;
3943
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3944
-                                    }
3945
-                                }
3946
-                            } else if ( $import_choice == 'skip' ) {
3947
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3948
-                                    $skipped++;
3949
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3950
-                                    $skipped++;
3951
-                                } else {
3952
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3953
-                                        $created++;
3954
-                                    } else {
3955
-                                        $invalid++;
3956
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3957
-                                    }
3958
-                                }
3959
-                            } else {
3960
-                                $invalid++;
3961
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3962
-                            }
3932
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
3933
+										$updated++;
3934
+									} else {
3935
+										$invalid++;
3936
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3937
+									}
3938
+								} else {
3939
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3940
+										$created++;
3941
+									} else {
3942
+										$invalid++;
3943
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3944
+									}
3945
+								}
3946
+							} else if ( $import_choice == 'skip' ) {
3947
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
3948
+									$skipped++;
3949
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
3950
+									$skipped++;
3951
+								} else {
3952
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
3953
+										$created++;
3954
+									} else {
3955
+										$invalid++;
3956
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3957
+									}
3958
+								}
3959
+							} else {
3960
+								$invalid++;
3961
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) );
3962
+							}
3963 3963
                             
3964
-                            if ( $term_id ) {
3965
-                                // WPML
3966
-                                if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
3967
-                                    $wpml_element_type = 'tax_' . $taxonomy;
3968
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
3969
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
3970
-
3971
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
3964
+							if ( $term_id ) {
3965
+								// WPML
3966
+								if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
3967
+									$wpml_element_type = 'tax_' . $taxonomy;
3968
+									$source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
3969
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
3970
+
3971
+									$trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
3972 3972
                                     
3973
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
3974
-                                }
3975
-                                // WPML
3973
+									$sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
3974
+								}
3975
+								// WPML
3976 3976
                                 
3977
-                                if ( isset( $term_data['top_description'] ) ) {
3978
-                                    geodir_update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
3979
-                                }
3977
+								if ( isset( $term_data['top_description'] ) ) {
3978
+									geodir_update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
3979
+								}
3980 3980
                                 
3981
-                                if ( isset( $term_data['cat_schema'] ) ) {
3982
-                                    geodir_update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
3983
-                                }
3981
+								if ( isset( $term_data['cat_schema'] ) ) {
3982
+									geodir_update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
3983
+								}
3984 3984
             
3985
-                                $attachment = false;
3986
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
3987
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
3988
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
3985
+								$attachment = false;
3986
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
3987
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
3988
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
3989 3989
                                     
3990
-                                    if ( basename($cat_image) != $term_data['image'] ) {
3991
-                                        $attachment = true;
3992
-                                        geodir_update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
3993
-                                    }
3994
-                                }
3990
+									if ( basename($cat_image) != $term_data['image'] ) {
3991
+										$attachment = true;
3992
+										geodir_update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
3993
+									}
3994
+								}
3995 3995
                                 
3996
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
3997
-                                    $cat_icon = geodir_get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
3998
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
3999
-
4000
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4001
-                                        $attachment = true;
4002
-                                        geodir_update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4003
-                                    }
4004
-                                }
3996
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
3997
+									$cat_icon = geodir_get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
3998
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
3999
+
4000
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4001
+										$attachment = true;
4002
+										geodir_update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4003
+									}
4004
+								}
4005 4005
                                 
4006
-                                if ( $attachment ) {
4007
-                                    $images++;
4008
-                                }
4009
-                            }
4006
+								if ( $attachment ) {
4007
+									$images++;
4008
+								}
4009
+							}
4010 4010
                             
4011
-                            // WPML
4012
-                            if ($is_wpml && $cat_language != '') {
4013
-                                $sitepress->switch_lang($active_lang, true);
4014
-                            }
4015
-                            // WPML
4016
-                        }
4017
-                    }
4018
-                }
4011
+							// WPML
4012
+							if ($is_wpml && $cat_language != '') {
4013
+								$sitepress->switch_lang($active_lang, true);
4014
+							}
4015
+							// WPML
4016
+						}
4017
+					}
4018
+				}
4019 4019
                 
4020
-                $json = array();
4021
-                $json['processed'] = $limit;
4022
-                $json['created'] = $created;
4023
-                $json['updated'] = $updated;
4024
-                $json['skipped'] = $skipped;
4025
-                $json['invalid'] = $invalid;
4026
-                $json['images'] = $images;
4020
+				$json = array();
4021
+				$json['processed'] = $limit;
4022
+				$json['created'] = $created;
4023
+				$json['updated'] = $updated;
4024
+				$json['skipped'] = $skipped;
4025
+				$json['invalid'] = $invalid;
4026
+				$json['images'] = $images;
4027 4027
                 
4028
-                wp_send_json( $json );
4029
-                exit;
4030
-            } else if ( $task == 'import_post' ) {
4031
-                $xtimings['###1'] = microtime(true)-$xstart;
4032
-                //run some stuff to make the import quicker
4033
-                wp_defer_term_counting( true );
4034
-                wp_defer_comment_counting( true );
4035
-                $wpdb->query( 'SET autocommit = 0;' );
4028
+				wp_send_json( $json );
4029
+				exit;
4030
+			} else if ( $task == 'import_post' ) {
4031
+				$xtimings['###1'] = microtime(true)-$xstart;
4032
+				//run some stuff to make the import quicker
4033
+				wp_defer_term_counting( true );
4034
+				wp_defer_comment_counting( true );
4035
+				$wpdb->query( 'SET autocommit = 0;' );
4036 4036
 //
4037 4037
 //                remove_all_actions('publish_post');
4038 4038
 //                remove_all_actions('transition_post_status');
4039 4039
 //                remove_all_actions('publish_future_post');
4040 4040
 
4041
-                if (!empty($file)) {
4042
-                    $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4043
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4044
-                    $default_status = 'publish';
4045
-                    $current_date = date_i18n( 'Y-m-d', time() );
4041
+				if (!empty($file)) {
4042
+					$is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
4043
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4044
+					$default_status = 'publish';
4045
+					$current_date = date_i18n( 'Y-m-d', time() );
4046 4046
                     
4047
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4047
+					$columns = isset($file[0]) ? $file[0] : NULL;
4048 4048
                     
4049
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4050
-                        $json['error'] = CSV_INVAILD_FILE;
4051
-                        wp_send_json( $json );
4052
-                        exit;
4053
-                    }
4054
-                    $xtimings['###2'] = microtime(true)-$xstart;
4055
-                    $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4056
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4057
-                    $processed_actual = 0;
4058
-                    for ($i = 1; $i <= $limit; $i++) {
4059
-                        $index = $processed + $i;
4060
-                        $gd_post = array();
4049
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4050
+						$json['error'] = CSV_INVAILD_FILE;
4051
+						wp_send_json( $json );
4052
+						exit;
4053
+					}
4054
+					$xtimings['###2'] = microtime(true)-$xstart;
4055
+					$gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4056
+					$wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4057
+					$processed_actual = 0;
4058
+					for ($i = 1; $i <= $limit; $i++) {
4059
+						$index = $processed + $i;
4060
+						$gd_post = array();
4061 4061
                         
4062
-                        if (isset($file[$index])) {
4063
-                            $processed_actual++;
4064
-                            $row = $file[$index];
4065
-                            $row = array_map( 'trim', $row );
4066
-                            //$row = array_map( 'utf8_encode', $row );
4067
-                            $row = array_map( 'addslashes_gpc', $row );
4062
+						if (isset($file[$index])) {
4063
+							$processed_actual++;
4064
+							$row = $file[$index];
4065
+							$row = array_map( 'trim', $row );
4066
+							//$row = array_map( 'utf8_encode', $row );
4067
+							$row = array_map( 'addslashes_gpc', $row );
4068 4068
                             
4069
-                            $post_id = '';
4070
-                            $post_title = '';
4071
-                            $post_date = '';
4072
-                            $post_author = '';
4073
-                            $post_content = '';
4074
-                            $post_category_arr = array();
4075
-                            $default_category = '';
4076
-                            $post_tags = array();
4077
-                            $post_type = '';
4078
-                            $post_status = '';
4079
-                            $geodir_video = '';
4080
-                            $post_address = '';
4081
-                            $post_city = '';
4082
-                            $post_region = '';
4083
-                            $post_country = '';
4084
-                            $post_zip = '';
4085
-                            $post_latitude = '';
4086
-                            $post_longitude = '';
4087
-                            $post_neighbourhood = '';
4088
-                            $neighbourhood_latitude = '';
4089
-                            $neighbourhood_longitude = '';
4090
-                            $geodir_timing = '';
4091
-                            $geodir_contact = '';
4092
-                            $geodir_email = '';
4093
-                            $geodir_website = '';
4094
-                            $geodir_twitter = '';
4095
-                            $geodir_facebook = '';
4096
-                            $geodir_twitter = '';
4097
-                            $geodir_link_business = null;
4098
-                            $post_images = array();
4069
+							$post_id = '';
4070
+							$post_title = '';
4071
+							$post_date = '';
4072
+							$post_author = '';
4073
+							$post_content = '';
4074
+							$post_category_arr = array();
4075
+							$default_category = '';
4076
+							$post_tags = array();
4077
+							$post_type = '';
4078
+							$post_status = '';
4079
+							$geodir_video = '';
4080
+							$post_address = '';
4081
+							$post_city = '';
4082
+							$post_region = '';
4083
+							$post_country = '';
4084
+							$post_zip = '';
4085
+							$post_latitude = '';
4086
+							$post_longitude = '';
4087
+							$post_neighbourhood = '';
4088
+							$neighbourhood_latitude = '';
4089
+							$neighbourhood_longitude = '';
4090
+							$geodir_timing = '';
4091
+							$geodir_contact = '';
4092
+							$geodir_email = '';
4093
+							$geodir_website = '';
4094
+							$geodir_twitter = '';
4095
+							$geodir_facebook = '';
4096
+							$geodir_twitter = '';
4097
+							$geodir_link_business = null;
4098
+							$post_images = array();
4099 4099
                             
4100
-                            $expire_date = 'Never';
4100
+							$expire_date = 'Never';
4101 4101
                             
4102
-                            $language = '';
4103
-                            $original_post_id = '';
4102
+							$language = '';
4103
+							$original_post_id = '';
4104 4104
                             
4105
-                            $c = 0;
4106
-                            foreach ($columns as $column ) {
4107
-                                $gd_post[$column] = $row[$c];
4105
+							$c = 0;
4106
+							foreach ($columns as $column ) {
4107
+								$gd_post[$column] = $row[$c];
4108 4108
                                 
4109
-                                if ( $column == 'post_id' ) {
4110
-                                    $post_id = $row[$c];
4111
-                                } else if ( $column == 'post_title' ) {
4112
-                                    $post_title = sanitize_text_field($row[$c]);
4113
-                                } else if ( $column == 'post_author' ) {
4114
-                                    $post_author = $row[$c];
4115
-                                } else if ( $column == 'post_date' ) {
4116
-                                    $post_date = $row[$c];
4117
-                                } else if ( $column == 'post_content' ) {
4118
-                                    $post_content = $row[$c];
4119
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4120
-                                    $post_category_arr = explode( ',', $row[$c] );
4121
-                                } else if ( $column == 'default_category' ) {
4122
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4123
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4124
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4125
-                                } else if ( $column == 'post_type' ) {
4126
-                                    $post_type = $row[$c];
4127
-                                } else if ( $column == 'post_status' ) {
4128
-                                    $post_status = sanitize_key( $row[$c] );
4129
-                                } else if ( $column == 'is_featured' ) {
4130
-                                    $is_featured = (int)$row[$c];
4131
-                                } else if ( $column == 'geodir_video' ) {
4132
-                                    $geodir_video = $row[$c];
4133
-                                } else if ( $column == 'post_address' ) {
4134
-                                    $post_address = sanitize_text_field($row[$c]);
4135
-                                } else if ( $column == 'post_city' ) {
4136
-                                    $post_city = sanitize_text_field($row[$c]);
4137
-                                } else if ( $column == 'post_region' ) {
4138
-                                    $post_region = sanitize_text_field($row[$c]);
4139
-                                } else if ( $column == 'post_country' ) {
4140
-                                    $post_country = sanitize_text_field($row[$c]);
4141
-                                } else if ( $column == 'post_zip' ) {
4142
-                                    $post_zip = sanitize_text_field($row[$c]);
4143
-                                } else if ( $column == 'post_latitude' ) {
4144
-                                    $post_latitude = sanitize_text_field($row[$c]);
4145
-                                } else if ( $column == 'post_longitude' ) {
4146
-                                    $post_longitude = sanitize_text_field($row[$c]);
4147
-                                } else if ( $column == 'post_neighbourhood' ) {
4148
-                                    $post_neighbourhood = sanitize_text_field($row[$c]);
4149
-                                    unset($gd_post[$column]);
4150
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4151
-                                    $neighbourhood_latitude = sanitize_text_field($row[$c]);
4152
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4153
-                                    $neighbourhood_longitude = sanitize_text_field($row[$c]);
4154
-                                } else if ( $column == 'geodir_timing' ) {
4155
-                                    $geodir_timing = sanitize_text_field($row[$c]);
4156
-                                } else if ( $column == 'geodir_contact' ) {
4157
-                                    $geodir_contact = sanitize_text_field($row[$c]);
4158
-                                } else if ( $column == 'geodir_email' ) {
4159
-                                    $geodir_email = sanitize_email($row[$c]);
4160
-                                } else if ( $column == 'geodir_website' ) {
4161
-                                    $geodir_website = sanitize_text_field($row[$c]);
4162
-                                } else if ( $column == 'geodir_twitter' ) {
4163
-                                    $geodir_twitter = sanitize_text_field($row[$c]);
4164
-                                } else if ( $column == 'geodir_facebook' ) {
4165
-                                    $geodir_facebook = sanitize_text_field($row[$c]);
4166
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4167
-                                    $post_images[] = $row[$c];
4168
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4169
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4170
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4171
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4172
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4173
-                                } else if ( strpos( $column, 'linked_' ) === 0 ) {
4174
-                                    $geodir_link_business = (int)$row[$c];
4175
-                                }
4176
-                                // WPML
4177
-                                if ($is_wpml) {
4178
-                                    if ($column == 'language') {
4179
-                                        $language = geodir_strtolower(trim($row[$c]));
4180
-                                    } else if ($column == 'original_post_id') {
4181
-                                        $original_post_id = (int)$row[$c];
4182
-                                    }
4183
-                                }
4184
-                                // WPML
4185
-                                $c++;
4186
-                            }
4187
-                            // listing claimed or not
4188
-                            if ($is_claim_active && isset($gd_post['claimed'])) {
4189
-                                $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4190
-                            }
4109
+								if ( $column == 'post_id' ) {
4110
+									$post_id = $row[$c];
4111
+								} else if ( $column == 'post_title' ) {
4112
+									$post_title = sanitize_text_field($row[$c]);
4113
+								} else if ( $column == 'post_author' ) {
4114
+									$post_author = $row[$c];
4115
+								} else if ( $column == 'post_date' ) {
4116
+									$post_date = $row[$c];
4117
+								} else if ( $column == 'post_content' ) {
4118
+									$post_content = $row[$c];
4119
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4120
+									$post_category_arr = explode( ',', $row[$c] );
4121
+								} else if ( $column == 'default_category' ) {
4122
+									$default_category = wp_kses_normalize_entities($row[$c]);
4123
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4124
+									$post_tags = explode( ',', sanitize_text_field($row[$c]) );
4125
+								} else if ( $column == 'post_type' ) {
4126
+									$post_type = $row[$c];
4127
+								} else if ( $column == 'post_status' ) {
4128
+									$post_status = sanitize_key( $row[$c] );
4129
+								} else if ( $column == 'is_featured' ) {
4130
+									$is_featured = (int)$row[$c];
4131
+								} else if ( $column == 'geodir_video' ) {
4132
+									$geodir_video = $row[$c];
4133
+								} else if ( $column == 'post_address' ) {
4134
+									$post_address = sanitize_text_field($row[$c]);
4135
+								} else if ( $column == 'post_city' ) {
4136
+									$post_city = sanitize_text_field($row[$c]);
4137
+								} else if ( $column == 'post_region' ) {
4138
+									$post_region = sanitize_text_field($row[$c]);
4139
+								} else if ( $column == 'post_country' ) {
4140
+									$post_country = sanitize_text_field($row[$c]);
4141
+								} else if ( $column == 'post_zip' ) {
4142
+									$post_zip = sanitize_text_field($row[$c]);
4143
+								} else if ( $column == 'post_latitude' ) {
4144
+									$post_latitude = sanitize_text_field($row[$c]);
4145
+								} else if ( $column == 'post_longitude' ) {
4146
+									$post_longitude = sanitize_text_field($row[$c]);
4147
+								} else if ( $column == 'post_neighbourhood' ) {
4148
+									$post_neighbourhood = sanitize_text_field($row[$c]);
4149
+									unset($gd_post[$column]);
4150
+								} else if ( $column == 'neighbourhood_latitude' ) {
4151
+									$neighbourhood_latitude = sanitize_text_field($row[$c]);
4152
+								} else if ( $column == 'neighbourhood_longitude' ) {
4153
+									$neighbourhood_longitude = sanitize_text_field($row[$c]);
4154
+								} else if ( $column == 'geodir_timing' ) {
4155
+									$geodir_timing = sanitize_text_field($row[$c]);
4156
+								} else if ( $column == 'geodir_contact' ) {
4157
+									$geodir_contact = sanitize_text_field($row[$c]);
4158
+								} else if ( $column == 'geodir_email' ) {
4159
+									$geodir_email = sanitize_email($row[$c]);
4160
+								} else if ( $column == 'geodir_website' ) {
4161
+									$geodir_website = sanitize_text_field($row[$c]);
4162
+								} else if ( $column == 'geodir_twitter' ) {
4163
+									$geodir_twitter = sanitize_text_field($row[$c]);
4164
+								} else if ( $column == 'geodir_facebook' ) {
4165
+									$geodir_facebook = sanitize_text_field($row[$c]);
4166
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4167
+									$post_images[] = $row[$c];
4168
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4169
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4170
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4171
+									$row[$c] = str_replace('/', '-', $row[$c]);
4172
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4173
+								} else if ( strpos( $column, 'linked_' ) === 0 ) {
4174
+									$geodir_link_business = (int)$row[$c];
4175
+								}
4176
+								// WPML
4177
+								if ($is_wpml) {
4178
+									if ($column == 'language') {
4179
+										$language = geodir_strtolower(trim($row[$c]));
4180
+									} else if ($column == 'original_post_id') {
4181
+										$original_post_id = (int)$row[$c];
4182
+									}
4183
+								}
4184
+								// WPML
4185
+								$c++;
4186
+							}
4187
+							// listing claimed or not
4188
+							if ($is_claim_active && isset($gd_post['claimed'])) {
4189
+								$gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0;
4190
+							}
4191 4191
                             
4192
-                            // WPML
4193
-                            if ($is_wpml && $language != '') {
4194
-                                $sitepress->switch_lang($language, true);
4195
-                            }
4196
-                            // WPML
4192
+							// WPML
4193
+							if ($is_wpml && $language != '') {
4194
+								$sitepress->switch_lang($language, true);
4195
+							}
4196
+							// WPML
4197 4197
 
4198
-                            $gd_post['IMAGE'] = $post_images;
4198
+							$gd_post['IMAGE'] = $post_images;
4199 4199
                             
4200
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4201
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4200
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4201
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4202 4202
                                                                                                                 
4203
-                            $valid = true;
4203
+							$valid = true;
4204 4204
                             
4205
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4206
-                                $invalid++;
4207
-                                $valid = false;
4208
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4209
-                            }
4210
-                            $xtimings['###3'] = microtime(true)-$xstart;
4211
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4212
-                            if ( $location_allowed ) {
4213
-                                $location_result = geodir_get_default_location();
4214
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4215
-                                    $invalid_addr++;
4216
-                                    $valid = false;
4217
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4218
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4219
-                                    if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4220
-                                        $invalid_addr++;
4221
-                                        $valid = false;
4222
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4223
-                                    } else {
4224
-                                        if (!$location_manager) {
4225
-                                            $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4226
-                                        }
4227
-                                    }
4228
-                                }
4229
-                            }
4230
-                            $xtimings['###4']   = microtime(true)-$xstart;
4231
-                            if ( !$valid ) {
4232
-                                continue;
4233
-                            }
4205
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4206
+								$invalid++;
4207
+								$valid = false;
4208
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4209
+							}
4210
+							$xtimings['###3'] = microtime(true)-$xstart;
4211
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4212
+							if ( $location_allowed ) {
4213
+								$location_result = geodir_get_default_location();
4214
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4215
+									$invalid_addr++;
4216
+									$valid = false;
4217
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4218
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4219
+									if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
4220
+										$invalid_addr++;
4221
+										$valid = false;
4222
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) );
4223
+									} else {
4224
+										if (!$location_manager) {
4225
+											$gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated.
4226
+										}
4227
+									}
4228
+								}
4229
+							}
4230
+							$xtimings['###4']   = microtime(true)-$xstart;
4231
+							if ( !$valid ) {
4232
+								continue;
4233
+							}
4234 4234
 
4235
-                            $cat_taxonomy = $post_type . 'category';
4236
-                            $tags_taxonomy = $post_type . '_tags';
4235
+							$cat_taxonomy = $post_type . 'category';
4236
+							$tags_taxonomy = $post_type . '_tags';
4237 4237
                             
4238
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4239
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4240
-                            }
4238
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4239
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4240
+							}
4241 4241
 
4242
-                            $post_category = array();
4243
-                            $default_category_id = NULL;
4244
-                            if ( !empty( $post_category_arr ) ) {
4245
-                                foreach ( $post_category_arr as $value ) {
4246
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4242
+							$post_category = array();
4243
+							$default_category_id = NULL;
4244
+							if ( !empty( $post_category_arr ) ) {
4245
+								foreach ( $post_category_arr as $value ) {
4246
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4247 4247
                                     
4248
-                                    if ( $category_name != '' ) {
4249
-                                        $term_category = array();
4248
+									if ( $category_name != '' ) {
4249
+										$term_category = array();
4250 4250
                                         
4251
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4252
-                                            $term_category = $term;
4253
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4254
-                                            $term_category = $term;
4255
-                                        } else {
4256
-                                            $term_data = array();
4257
-                                            $term_data['name'] = $category_name;
4258
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4251
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4252
+											$term_category = $term;
4253
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4254
+											$term_category = $term;
4255
+										} else {
4256
+											$term_data = array();
4257
+											$term_data['name'] = $category_name;
4258
+											$term_data['taxonomy'] = $cat_taxonomy;
4259 4259
                                             
4260
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4261
-                                            if ( $term_id ) {
4262
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4263
-                                            }
4264
-                                        }
4260
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4261
+											if ( $term_id ) {
4262
+												$term_category = get_term( $term_id, $cat_taxonomy );
4263
+											}
4264
+										}
4265 4265
                                         
4266
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4267
-                                            $post_category[] = intval($term_category->term_id);
4266
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4267
+											$post_category[] = intval($term_category->term_id);
4268 4268
                                             
4269
-                                            if ($category_name == $default_category) {
4270
-                                                $default_category_id = intval($term_category->term_id);
4271
-                                            }
4272
-                                        }
4273
-                                    }
4274
-                                }
4275
-                            }
4276
-                            $xtimings['###5'] = microtime(true)-$xstart;
4277
-                            $save_post = array();
4278
-                            $save_post['post_title'] = $post_title;
4279
-                            if (!empty($post_date)) {
4280
-                                $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format.
4269
+											if ($category_name == $default_category) {
4270
+												$default_category_id = intval($term_category->term_id);
4271
+											}
4272
+										}
4273
+									}
4274
+								}
4275
+							}
4276
+							$xtimings['###5'] = microtime(true)-$xstart;
4277
+							$save_post = array();
4278
+							$save_post['post_title'] = $post_title;
4279
+							if (!empty($post_date)) {
4280
+								$post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format.
4281 4281
                                 
4282
-                                $save_post['post_date'] = $post_date;
4283
-                                $save_post['post_date_gmt'] = get_gmt_from_date( $post_date );
4284
-                            }
4285
-                            $save_post['post_content'] = $post_content;
4286
-                            $save_post['post_type'] = $post_type;
4287
-                            $save_post['post_author'] = $post_author;
4288
-                            $save_post['post_status'] = $post_status;
4289
-                            $save_post['post_category'] = $post_category;
4290
-                            $save_post['post_tags'] = $post_tags;
4291
-
4292
-                            $saved_post_id = NULL;
4293
-                            if ( $import_choice == 'update' ) {
4294
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4282
+								$save_post['post_date'] = $post_date;
4283
+								$save_post['post_date_gmt'] = get_gmt_from_date( $post_date );
4284
+							}
4285
+							$save_post['post_content'] = $post_content;
4286
+							$save_post['post_type'] = $post_type;
4287
+							$save_post['post_author'] = $post_author;
4288
+							$save_post['post_status'] = $post_status;
4289
+							$save_post['post_category'] = $post_category;
4290
+							$save_post['post_tags'] = $post_tags;
4291
+
4292
+							$saved_post_id = NULL;
4293
+							if ( $import_choice == 'update' ) {
4294
+								$gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4295 4295
                                 
4296
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4297
-                                    $save_post['ID'] = $post_id;
4296
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4297
+									$save_post['ID'] = $post_id;
4298 4298
                                     
4299
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4300
-                                        if ( is_wp_error( $saved_post_id ) ) {
4301
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4302
-                                            $saved_post_id = 0;
4303
-                                        } else {
4304
-                                            $saved_post_id = $post_id;
4305
-                                            $updated++;
4306
-                                        }
4307
-                                    }
4308
-                                } else {
4309
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4310
-                                        if ( is_wp_error( $saved_post_id ) ) {
4311
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4312
-                                            $saved_post_id = 0;
4313
-                                        } else {
4314
-                                            $created++;
4315
-                                        }
4316
-                                    }
4317
-                                }
4299
+									if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4300
+										if ( is_wp_error( $saved_post_id ) ) {
4301
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4302
+											$saved_post_id = 0;
4303
+										} else {
4304
+											$saved_post_id = $post_id;
4305
+											$updated++;
4306
+										}
4307
+									}
4308
+								} else {
4309
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4310
+										if ( is_wp_error( $saved_post_id ) ) {
4311
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4312
+											$saved_post_id = 0;
4313
+										} else {
4314
+											$created++;
4315
+										}
4316
+									}
4317
+								}
4318 4318
                                 
4319
-                                if ( !$saved_post_id > 0 ) {
4320
-                                    $invalid++;
4321
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4322
-                                }
4323
-                            } else if ( $import_choice == 'skip' ) {
4324
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4325
-                                    $skipped++;	
4326
-                                } else {
4327
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4328
-                                        if ( is_wp_error( $saved_post_id ) ) {
4329
-                                            $invalid++;
4319
+								if ( !$saved_post_id > 0 ) {
4320
+									$invalid++;
4321
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4322
+								}
4323
+							} else if ( $import_choice == 'skip' ) {
4324
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4325
+									$skipped++;	
4326
+								} else {
4327
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4328
+										if ( is_wp_error( $saved_post_id ) ) {
4329
+											$invalid++;
4330 4330
                                             
4331
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4332
-                                            $saved_post_id = 0;
4333
-                                        } else {
4334
-                                            $created++;
4335
-                                        }
4336
-                                    } else {
4337
-                                        $invalid++;
4331
+											geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4332
+											$saved_post_id = 0;
4333
+										} else {
4334
+											$created++;
4335
+										}
4336
+									} else {
4337
+										$invalid++;
4338 4338
                                         
4339
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4340
-                                    }
4341
-                                }
4342
-                            } else {
4343
-                                $invalid++;
4339
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4340
+									}
4341
+								}
4342
+							} else {
4343
+								$invalid++;
4344 4344
                                 
4345
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4346
-                            }
4347
-                            $xtimings['###6'] = microtime(true)-$xstart;
4348
-                            if ( (int)$saved_post_id > 0 ) {
4349
-                                // WPML
4350
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4351
-                                    $wpml_post_type = 'post_' . $post_type;
4352
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4353
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4354
-
4355
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4345
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4346
+							}
4347
+							$xtimings['###6'] = microtime(true)-$xstart;
4348
+							if ( (int)$saved_post_id > 0 ) {
4349
+								// WPML
4350
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4351
+									$wpml_post_type = 'post_' . $post_type;
4352
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4353
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4354
+
4355
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4356 4356
                                     
4357
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4358
-                                }
4359
-                                // WPML
4360
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4357
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4358
+								}
4359
+								// WPML
4360
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4361 4361
                                 
4362
-                                $gd_post['post_id'] = $saved_post_id;
4363
-                                $gd_post['ID'] = $saved_post_id;
4364
-                                $gd_post['post_tags'] = $post_tags;
4365
-                                $gd_post['post_title'] = $post_title;
4366
-                                $gd_post['post_status'] = $post_status;
4367
-                                $gd_post['submit_time'] = time();
4368
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4362
+								$gd_post['post_id'] = $saved_post_id;
4363
+								$gd_post['ID'] = $saved_post_id;
4364
+								$gd_post['post_tags'] = $post_tags;
4365
+								$gd_post['post_title'] = $post_title;
4366
+								$gd_post['post_status'] = $post_status;
4367
+								$gd_post['submit_time'] = time();
4368
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4369 4369
                                                     
4370
-                                // post location
4371
-                                $post_location_id = 0;
4372
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4373
-                                    $gd_post['post_neighbourhood'] = '';
4370
+								// post location
4371
+								$post_location_id = 0;
4372
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4373
+									$gd_post['post_neighbourhood'] = '';
4374 4374
                                     
4375
-                                    $post_location_info = array(
4376
-                                                                'city' => $post_city,
4377
-                                                                'region' => $post_region,
4378
-                                                                'country' => $post_country,
4379
-                                                                'geo_lat' => $post_latitude,
4380
-                                                                'geo_lng' => $post_longitude
4381
-                                                            );
4382
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4383
-                                        $post_location_id = $location_id;
4384
-                                    }
4375
+									$post_location_info = array(
4376
+																'city' => $post_city,
4377
+																'region' => $post_region,
4378
+																'country' => $post_country,
4379
+																'geo_lat' => $post_latitude,
4380
+																'geo_lng' => $post_longitude
4381
+															);
4382
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4383
+										$post_location_id = $location_id;
4384
+									}
4385 4385
                                     
4386
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4387
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4386
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4387
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4388 4388
 
4389
-                                        $hood_data = array();
4390
-                                        $hood_data['hood_location_id'] = $post_location_id;
4391
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4389
+										$hood_data = array();
4390
+										$hood_data['hood_location_id'] = $post_location_id;
4391
+										$hood_data['hood_name'] = $post_neighbourhood;
4392 4392
                                         
4393
-                                        if (!empty($neighbourhood_info)) {
4394
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4395
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4393
+										if (!empty($neighbourhood_info)) {
4394
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4395
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4396 4396
                                             
4397
-                                            if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4398
-                                                $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4399
-                                                $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4400
-                                            }
4401
-                                        }
4397
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4398
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4399
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4400
+											}
4401
+										}
4402 4402
                                         
4403
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4404
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4405
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4406
-                                        }
4403
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4404
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4405
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4406
+										}
4407 4407
                                         
4408
-                                        $hood_data['hood_latitude'] = $post_latitude;
4409
-                                        $hood_data['hood_longitude'] = $post_longitude;
4410
-
4411
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4412
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4413
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4414
-                                        }
4415
-                                    }
4416
-                                }
4417
-                                $gd_post['post_location_id'] = $post_location_id;
4408
+										$hood_data['hood_latitude'] = $post_latitude;
4409
+										$hood_data['hood_longitude'] = $post_longitude;
4410
+
4411
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4412
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4413
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4414
+										}
4415
+									}
4416
+								}
4417
+								$gd_post['post_location_id'] = $post_location_id;
4418 4418
                                 
4419
-                                if ($geodir_link_business !== null) {
4420
-                                    $gd_post['geodir_link_business'] = $geodir_link_business > 0 ? $geodir_link_business : '';
4421
-                                }
4419
+								if ($geodir_link_business !== null) {
4420
+									$gd_post['geodir_link_business'] = $geodir_link_business > 0 ? $geodir_link_business : '';
4421
+								}
4422 4422
                                 
4423
-                                // post package info
4424
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4425
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4426
-                                    $package_id = $gd_post_info->package_id;
4427
-                                }
4423
+								// post package info
4424
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4425
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4426
+									$package_id = $gd_post_info->package_id;
4427
+								}
4428 4428
                                 
4429
-                                $package_info = array();
4430
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4431
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4429
+								$package_info = array();
4430
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4431
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4432 4432
                                     
4433
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4434
-                                        $package_info = array();
4435
-                                    }
4436
-                                }
4433
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4434
+										$package_info = array();
4435
+									}
4436
+								}
4437 4437
                                 
4438
-                                if (empty($package_info)) {
4439
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4440
-                                }
4438
+								if (empty($package_info)) {
4439
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4440
+								}
4441 4441
                                  
4442
-                                if (!empty($package_info))	 {
4443
-                                    $package_id = $package_info['pid'];
4442
+								if (!empty($package_info))	 {
4443
+									$package_id = $package_info['pid'];
4444 4444
                                     
4445
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4446
-                                        $gd_post['expire_date'] = $expire_date;
4447
-                                    } else {
4448
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4449
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4450
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4451
-                                        } else {
4452
-                                            $gd_post['expire_date'] = 'Never';
4453
-                                        }
4454
-                                    }
4445
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4446
+										$gd_post['expire_date'] = $expire_date;
4447
+									} else {
4448
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4449
+											$gd_post['alive_days'] = (int)$package_info['days'];
4450
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4451
+										} else {
4452
+											$gd_post['expire_date'] = 'Never';
4453
+										}
4454
+									}
4455 4455
                                     
4456
-                                    $gd_post['package_id'] = $package_id;
4457
-                                }
4456
+									$gd_post['package_id'] = $package_id;
4457
+								}
4458 4458
 
4459
-                                $table = $plugin_prefix . $post_type . '_detail';
4459
+								$table = $plugin_prefix . $post_type . '_detail';
4460 4460
                                 
4461
-                                if ($post_type == 'gd_event') {
4462
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4463
-                                }
4461
+								if ($post_type == 'gd_event') {
4462
+									$gd_post = geodir_imex_process_event_data($gd_post);
4463
+								}
4464 4464
                                 
4465
-                                if (isset($gd_post['post_id'])) {
4466
-                                    unset($gd_post['post_id']);
4467
-                                }
4465
+								if (isset($gd_post['post_id'])) {
4466
+									unset($gd_post['post_id']);
4467
+								}
4468 4468
 
4469
-                                // Export franchise fields
4470
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4471
-                                if ($is_franchise_active) {
4472
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4473
-                                        $gd_franchise_lock = array();
4469
+								// Export franchise fields
4470
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4471
+								if ($is_franchise_active) {
4472
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4473
+										$gd_franchise_lock = array();
4474 4474
                                         
4475
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4476
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4477
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4478
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4479
-                                        }
4475
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4476
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4477
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4478
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4479
+										}
4480 4480
                                         
4481
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4482
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4483
-                                    } else {
4484
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4485
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4486
-                                        }
4487
-                                    }
4488
-                                }
4481
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4482
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4483
+									} else {
4484
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4485
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4486
+										}
4487
+									}
4488
+								}
4489 4489
                                 
4490
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4491
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4492
-                                    if ($default_category_id) {
4493
-                                        $save_post['post_default_category'] = $default_category_id;
4494
-                                        $gd_post['default_category'] = $default_category_id;
4495
-                                    }
4496
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4497
-                                }
4498
-                                $xtimings['###7'] = microtime(true)-$xstart;
4499
-                                // Save post info
4500
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4501
-                                $xtimings['###8'] = microtime(true)-$xstart;
4502
-                                // post taxonomies
4503
-                                if ( !empty( $save_post['post_category'] ) ) {
4504
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4490
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4491
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4492
+									if ($default_category_id) {
4493
+										$save_post['post_default_category'] = $default_category_id;
4494
+										$gd_post['default_category'] = $default_category_id;
4495
+									}
4496
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4497
+								}
4498
+								$xtimings['###7'] = microtime(true)-$xstart;
4499
+								// Save post info
4500
+								geodir_save_post_info( $saved_post_id, $gd_post );
4501
+								$xtimings['###8'] = microtime(true)-$xstart;
4502
+								// post taxonomies
4503
+								if ( !empty( $save_post['post_category'] ) ) {
4504
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4505 4505
                                     
4506
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4507
-                                    if ($default_category_id) {
4508
-                                        $post_default_category = $default_category_id;
4509
-                                    }
4510
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4511
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4512
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4506
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4507
+									if ($default_category_id) {
4508
+										$post_default_category = $default_category_id;
4509
+									}
4510
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4511
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4512
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4513 4513
                                     
4514
-                                    if ($post_category_str != '' && $post_default_category) {
4515
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4516
-                                    }
4514
+									if ($post_category_str != '' && $post_default_category) {
4515
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4516
+									}
4517 4517
                                     
4518
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4518
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4519 4519
                                     
4520
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4521
-                                }
4522
-                                $xtimings['###8.1'] = microtime(true)-$xstart;
4523
-                                if ( !empty( $save_post['post_tags'] ) ) {
4524
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4525
-                                }
4526
-                                $xtimings['###9'] = microtime(true)-$xstart;
4527
-                                // Post images
4528
-                                if ( !empty( $post_images ) ) {
4529
-                                    $post_images = array_unique($post_images);
4520
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4521
+								}
4522
+								$xtimings['###8.1'] = microtime(true)-$xstart;
4523
+								if ( !empty( $save_post['post_tags'] ) ) {
4524
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4525
+								}
4526
+								$xtimings['###9'] = microtime(true)-$xstart;
4527
+								// Post images
4528
+								if ( !empty( $post_images ) ) {
4529
+									$post_images = array_unique($post_images);
4530 4530
                                     
4531
-                                    $old_post_images_arr = array();
4532
-                                    $saved_post_images_arr = array();
4531
+									$old_post_images_arr = array();
4532
+									$saved_post_images_arr = array();
4533 4533
                                     
4534
-                                    $order = 1;
4534
+									$order = 1;
4535 4535
                                     
4536
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4537
-                                    $xtimings['###9.1'] = microtime(true)-$xstart;
4538
-                                    if (!empty($old_post_images)) {
4539
-                                        foreach( $old_post_images as $old_post_image ) {
4540
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4541
-                                                $old_post_images_arr[] = $old_post_image->file;
4542
-                                            }
4543
-                                        }
4544
-                                    }
4536
+									$old_post_images = geodir_get_images( $saved_post_id );
4537
+									$xtimings['###9.1'] = microtime(true)-$xstart;
4538
+									if (!empty($old_post_images)) {
4539
+										foreach( $old_post_images as $old_post_image ) {
4540
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4541
+												$old_post_images_arr[] = $old_post_image->file;
4542
+											}
4543
+										}
4544
+									}
4545 4545
 
4546
-                                    foreach ( $post_images as $post_image ) {
4547
-                                        $image_name = basename( $post_image );
4548
-                                        $saved_post_images_arr[] = $image_name;
4546
+									foreach ( $post_images as $post_image ) {
4547
+										$image_name = basename( $post_image );
4548
+										$saved_post_images_arr[] = $image_name;
4549 4549
                                         
4550
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4551
-                                            continue; // Skip if image already exists.
4552
-                                        }
4550
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4551
+											continue; // Skip if image already exists.
4552
+										}
4553 4553
                                         
4554
-                                        $image_name_parts = explode( '.', $image_name );
4555
-                                        array_pop( $image_name_parts );
4556
-                                        $proper_image_name = implode( '.', $image_name_parts );
4557
-                                        $xtimings['###9.2'] = microtime(true)-$xstart;
4558
-                                        $arr_file_type = wp_check_filetype( $image_name );
4559
-                                        $xtimings['###9.3'] = microtime(true)-$xstart;
4560
-                                        if ( !empty( $arr_file_type ) ) {
4561
-                                            $uploaded_file_type = $arr_file_type['type'];
4554
+										$image_name_parts = explode( '.', $image_name );
4555
+										array_pop( $image_name_parts );
4556
+										$proper_image_name = implode( '.', $image_name_parts );
4557
+										$xtimings['###9.2'] = microtime(true)-$xstart;
4558
+										$arr_file_type = wp_check_filetype( $image_name );
4559
+										$xtimings['###9.3'] = microtime(true)-$xstart;
4560
+										if ( !empty( $arr_file_type ) ) {
4561
+											$uploaded_file_type = $arr_file_type['type'];
4562 4562
                                             
4563
-                                            $attachment = array();
4564
-                                            $attachment['post_id'] = $saved_post_id;
4565
-                                            $attachment['title'] = $proper_image_name;
4566
-                                            $attachment['content'] = '';
4567
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4568
-                                            $attachment['mime_type'] = $uploaded_file_type;
4569
-                                            $attachment['menu_order'] = $order;
4570
-                                            $attachment['is_featured'] = 0;
4571
-
4572
-                                            $attachment_set = '';
4573
-                                            foreach ( $attachment as $key => $val ) {
4574
-                                                if ( $val != '' ) {
4575
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4576
-                                                }
4577
-                                            }
4578
-                                            $attachment_set = trim( $attachment_set, ", " );
4563
+											$attachment = array();
4564
+											$attachment['post_id'] = $saved_post_id;
4565
+											$attachment['title'] = $proper_image_name;
4566
+											$attachment['content'] = '';
4567
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4568
+											$attachment['mime_type'] = $uploaded_file_type;
4569
+											$attachment['menu_order'] = $order;
4570
+											$attachment['is_featured'] = 0;
4571
+
4572
+											$attachment_set = '';
4573
+											foreach ( $attachment as $key => $val ) {
4574
+												if ( $val != '' ) {
4575
+													$attachment_set .= $key . " = '" . $val . "', ";
4576
+												}
4577
+											}
4578
+											$attachment_set = trim( $attachment_set, ", " );
4579 4579
                                                                                         
4580
-                                            // Add new attachment
4581
-                                            $xtimings['###9.4'] = microtime(true)-$xstart;
4582
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4583
-                                            $xtimings['###9.5'] = microtime(true)-$xstart;
4584
-                                            $order++;
4585
-                                        }
4586
-                                    }
4587
-
4588
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4589
-                                    // Remove previous attachment
4590
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4591
-                                    $xtimings['###9.6'] = microtime(true)-$xstart;
4592
-                                    if ( !empty( $saved_post_images_arr ) ) {
4593
-                                        geodir_set_wp_featured_image($saved_post_id);
4594
-                                        $xtimings['###9.7'] = microtime(true)-$xstart;
4595
-                                        /*
4580
+											// Add new attachment
4581
+											$xtimings['###9.4'] = microtime(true)-$xstart;
4582
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4583
+											$xtimings['###9.5'] = microtime(true)-$xstart;
4584
+											$order++;
4585
+										}
4586
+									}
4587
+
4588
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4589
+									// Remove previous attachment
4590
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4591
+									$xtimings['###9.6'] = microtime(true)-$xstart;
4592
+									if ( !empty( $saved_post_images_arr ) ) {
4593
+										geodir_set_wp_featured_image($saved_post_id);
4594
+										$xtimings['###9.7'] = microtime(true)-$xstart;
4595
+										/*
4596 4596
                                         $menu_order = 1;
4597 4597
                                         
4598 4598
                                         foreach ( $saved_post_images_arr as $img_name ) {
@@ -4605,288 +4605,288 @@  discard block
 block discarded – undo
4605 4605
                                             }
4606 4606
                                             $menu_order++;
4607 4607
                                         }*/
4608
-                                    }
4608
+									}
4609 4609
                                     
4610
-                                    if ( $order > 1 ) {
4611
-                                        $images++;
4612
-                                    }
4613
-                                }
4614
-                                $xtimings['###10'] = microtime(true)-$xstart;
4615
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4616
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4617
-                                $xtimings['###11'] = microtime(true)-$xstart;
4618
-                                if (isset($is_featured)) {
4619
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4620
-                                }
4621
-                                if (isset($gd_post['alive_days'])) {
4622
-                                    geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']);
4623
-                                }
4624
-                                if (isset($gd_post['expire_date'])) {
4625
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4626
-                                }
4627
-                                $xtimings['###12'] = microtime(true)-$xstart;
4628
-                            }
4610
+									if ( $order > 1 ) {
4611
+										$images++;
4612
+									}
4613
+								}
4614
+								$xtimings['###10'] = microtime(true)-$xstart;
4615
+								/** This action is documented in geodirectory-functions/post-functions.php */
4616
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4617
+								$xtimings['###11'] = microtime(true)-$xstart;
4618
+								if (isset($is_featured)) {
4619
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4620
+								}
4621
+								if (isset($gd_post['alive_days'])) {
4622
+									geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']);
4623
+								}
4624
+								if (isset($gd_post['expire_date'])) {
4625
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4626
+								}
4627
+								$xtimings['###12'] = microtime(true)-$xstart;
4628
+							}
4629 4629
                             
4630
-                            // WPML
4631
-                            if ($is_wpml && $language != '') {
4632
-                                $sitepress->switch_lang($active_lang, true);
4633
-                            }
4634
-                            // WPML
4635
-                        }
4636
-                    }
4637
-                }
4630
+							// WPML
4631
+							if ($is_wpml && $language != '') {
4632
+								$sitepress->switch_lang($active_lang, true);
4633
+							}
4634
+							// WPML
4635
+						}
4636
+					}
4637
+				}
4638 4638
 
4639
-                //undo some stuff to make the import quicker
4640
-                wp_defer_term_counting( false );
4641
-                wp_defer_comment_counting( false );
4642
-                $wpdb->query( 'COMMIT;' );
4643
-                $wpdb->query( 'SET autocommit = 1;' );
4644
-                $xtimings['###13'] = microtime(true)-$xstart;
4645
-                $json = array();
4646
-                $json['processed'] = $processed_actual;
4647
-                $json['created'] = $created;
4648
-                $json['updated'] = $updated;
4649
-                $json['skipped'] = $skipped;
4650
-                $json['invalid'] = $invalid;
4651
-                $json['invalid_addr'] = $invalid_addr;
4652
-                $json['images'] = $images;
4653
-                $json['timing'] = microtime(true)-$xstart;
4654
-                $json['timings'] = $xtimings;
4639
+				//undo some stuff to make the import quicker
4640
+				wp_defer_term_counting( false );
4641
+				wp_defer_comment_counting( false );
4642
+				$wpdb->query( 'COMMIT;' );
4643
+				$wpdb->query( 'SET autocommit = 1;' );
4644
+				$xtimings['###13'] = microtime(true)-$xstart;
4645
+				$json = array();
4646
+				$json['processed'] = $processed_actual;
4647
+				$json['created'] = $created;
4648
+				$json['updated'] = $updated;
4649
+				$json['skipped'] = $skipped;
4650
+				$json['invalid'] = $invalid;
4651
+				$json['invalid_addr'] = $invalid_addr;
4652
+				$json['images'] = $images;
4653
+				$json['timing'] = microtime(true)-$xstart;
4654
+				$json['timings'] = $xtimings;
4655 4655
                 
4656 4656
 
4657
-                wp_send_json( $json );
4658
-                exit;
4659
-            } else if ( $task == 'import_loc' ) {
4660
-                global $gd_post_types;
4661
-                $gd_post_types = $post_types;
4657
+				wp_send_json( $json );
4658
+				exit;
4659
+			} else if ( $task == 'import_loc' ) {
4660
+				global $gd_post_types;
4661
+				$gd_post_types = $post_types;
4662 4662
                 
4663
-                if (!empty($file)) {
4664
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4663
+				if (!empty($file)) {
4664
+					$columns = isset($file[0]) ? $file[0] : NULL;
4665 4665
                     
4666
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4667
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4668
-                        wp_send_json( $json );
4669
-                    }
4666
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4667
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4668
+						wp_send_json( $json );
4669
+					}
4670 4670
                     
4671
-                    $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4672
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4673
-                    for ($i = 1; $i <= $limit; $i++) {
4674
-                        $index = $processed + $i;
4671
+					$gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4672
+					$gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4673
+					for ($i = 1; $i <= $limit; $i++) {
4674
+						$index = $processed + $i;
4675 4675
                         
4676
-                        if (isset($file[$index])) {
4677
-                            $row = $file[$index];
4678
-                            $row = array_map( 'trim', $row );
4679
-                            $data = array();
4676
+						if (isset($file[$index])) {
4677
+							$row = $file[$index];
4678
+							$row = array_map( 'trim', $row );
4679
+							$data = array();
4680 4680
                             
4681
-                            foreach ($columns as $c => $column ) {
4682
-                                if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
4683
-                                    $data[$column] = $row[$c];
4684
-                                }
4685
-                            }
4681
+							foreach ($columns as $c => $column ) {
4682
+								if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
4683
+									$data[$column] = $row[$c];
4684
+								}
4685
+							}
4686 4686
 
4687
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4688
-                                $invalid++;
4689
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4690
-                                continue;
4691
-                            }
4687
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4688
+								$invalid++;
4689
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4690
+								continue;
4691
+							}
4692 4692
                             
4693
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4693
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4694 4694
                             
4695
-                            if ( $import_choice == 'update' ) {
4696
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4697
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4698
-                                        $updated++;
4699
-                                    } else {
4700
-                                        $invalid++;
4701
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4702
-                                    }
4703
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4704
-                                    $data['location_id'] = (int)$location->location_id;
4695
+							if ( $import_choice == 'update' ) {
4696
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4697
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4698
+										$updated++;
4699
+									} else {
4700
+										$invalid++;
4701
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4702
+									}
4703
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4704
+									$data['location_id'] = (int)$location->location_id;
4705 4705
                                     
4706
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4707
-                                        $data['location_id'] = (int)$location->location_id;
4708
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4709
-                                        $data['location_id'] = (int)$location->location_id;
4710
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4711
-                                        $data['location_id'] = (int)$location->location_id;
4712
-                                    }
4706
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4707
+										$data['location_id'] = (int)$location->location_id;
4708
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4709
+										$data['location_id'] = (int)$location->location_id;
4710
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4711
+										$data['location_id'] = (int)$location->location_id;
4712
+									}
4713 4713
                                     
4714
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4715
-                                        $updated++;
4716
-                                    } else {
4717
-                                        $invalid++;
4718
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4719
-                                    }
4720
-                                } else {
4721
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4722
-                                        $created++;
4723
-                                    } else {
4724
-                                        $invalid++;
4725
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4726
-                                    }
4727
-                                }
4728
-                            } elseif ( $import_choice == 'skip' ) {
4729
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4730
-                                    $skipped++;
4731
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4732
-                                    $skipped++;
4733
-                                } else {
4734
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4735
-                                        $created++;
4736
-                                    } else {
4737
-                                        $invalid++;
4738
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4739
-                                    }
4740
-                                }
4741
-                            } else {
4742
-                                $invalid++;
4743
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4744
-                            }
4745
-                        }
4746
-                    }
4747
-                }
4714
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4715
+										$updated++;
4716
+									} else {
4717
+										$invalid++;
4718
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4719
+									}
4720
+								} else {
4721
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4722
+										$created++;
4723
+									} else {
4724
+										$invalid++;
4725
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4726
+									}
4727
+								}
4728
+							} elseif ( $import_choice == 'skip' ) {
4729
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4730
+									$skipped++;
4731
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4732
+									$skipped++;
4733
+								} else {
4734
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4735
+										$created++;
4736
+									} else {
4737
+										$invalid++;
4738
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4739
+									}
4740
+								}
4741
+							} else {
4742
+								$invalid++;
4743
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4744
+							}
4745
+						}
4746
+					}
4747
+				}
4748 4748
                 
4749
-                $json = array();
4750
-                $json['processed'] = $limit;
4751
-                $json['created'] = $created;
4752
-                $json['updated'] = $updated;
4753
-                $json['skipped'] = $skipped;
4754
-                $json['invalid'] = $invalid;
4755
-                $json['images'] = $images;
4749
+				$json = array();
4750
+				$json['processed'] = $limit;
4751
+				$json['created'] = $created;
4752
+				$json['updated'] = $updated;
4753
+				$json['skipped'] = $skipped;
4754
+				$json['invalid'] = $invalid;
4755
+				$json['images'] = $images;
4756 4756
                 
4757
-                wp_send_json( $json );
4758
-            } else if ( $task == 'import_hood' ) {               
4759
-                if (!empty($file)) {
4760
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4757
+				wp_send_json( $json );
4758
+			} else if ( $task == 'import_hood' ) {               
4759
+				if (!empty($file)) {
4760
+					$columns = isset($file[0]) ? $file[0] : NULL;
4761 4761
                     
4762
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4763
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4764
-                        wp_send_json( $json );
4765
-                    }
4762
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4763
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4764
+						wp_send_json( $json );
4765
+					}
4766 4766
                     
4767
-                    $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4768
-                    $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
4769
-                    for ($i = 1; $i <= $limit; $i++) {
4770
-                        $index = $processed + $i;
4767
+					$gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4768
+					$gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' );
4769
+					for ($i = 1; $i <= $limit; $i++) {
4770
+						$index = $processed + $i;
4771 4771
                         
4772
-                        if (isset($file[$index])) {
4773
-                            $row = $file[$index];
4774
-                            $row = array_map( 'trim', $row );
4775
-                            $data = array();
4772
+						if (isset($file[$index])) {
4773
+							$row = $file[$index];
4774
+							$row = array_map( 'trim', $row );
4775
+							$data = array();
4776 4776
                             
4777
-                            foreach ($columns as $c => $column) {
4778
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
4779
-                                    $data[$column] = sanitize_text_field($row[$c]);
4780
-                                }
4781
-                            }
4777
+							foreach ($columns as $c => $column) {
4778
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
4779
+									$data[$column] = sanitize_text_field($row[$c]);
4780
+								}
4781
+							}
4782 4782
 
4783
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4784
-                                $invalid++;
4785
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4786
-                                continue;
4787
-                            }
4783
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
4784
+								$invalid++;
4785
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4786
+								continue;
4787
+							}
4788 4788
                             
4789
-                            $location_info = array();
4790
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4791
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4792
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4793
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4794
-                            }
4789
+							$location_info = array();
4790
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
4791
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
4792
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
4793
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
4794
+							}
4795 4795
 
4796
-                            if (empty($location_info)) {
4797
-                                $invalid++;
4798
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4799
-                                continue;
4800
-                            }
4796
+							if (empty($location_info)) {
4797
+								$invalid++;
4798
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4799
+								continue;
4800
+							}
4801 4801
                             
4802
-                            $location_id = $location_info->location_id;
4802
+							$location_id = $location_info->location_id;
4803 4803
 
4804
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
4804
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
4805 4805
                             
4806
-                            $hood_data = array();
4807
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
4808
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
4809
-                            $hood_data['hood_latitude'] = $data['latitude'];
4810
-                            $hood_data['hood_longitude'] = $data['longitude'];
4811
-                            $hood_data['hood_location_id'] = $location_id;
4806
+							$hood_data = array();
4807
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
4808
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
4809
+							$hood_data['hood_latitude'] = $data['latitude'];
4810
+							$hood_data['hood_longitude'] = $data['longitude'];
4811
+							$hood_data['hood_location_id'] = $location_id;
4812 4812
                                     
4813
-                            if ( $import_choice == 'update' ) {
4814
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4815
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4813
+							if ( $import_choice == 'update' ) {
4814
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4815
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
4816 4816
                                     
4817
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4818
-                                        $updated++;
4819
-                                    } else {
4820
-                                        $invalid++;
4821
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4822
-                                    }
4823
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4824
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4817
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4818
+										$updated++;
4819
+									} else {
4820
+										$invalid++;
4821
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4822
+									}
4823
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4824
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
4825 4825
                                     
4826
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4827
-                                        $updated++;
4828
-                                    } else {
4829
-                                        $invalid++;
4830
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4831
-                                    }
4832
-                                } else {
4833
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4834
-                                        $created++;
4835
-                                    } else {
4836
-                                        $invalid++;
4837
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4838
-                                    }
4839
-                                }
4840
-                            } elseif ( $import_choice == 'skip' ) {
4841
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4842
-                                    $skipped++;
4843
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4844
-                                    $skipped++;
4845
-                                } else {
4826
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4827
+										$updated++;
4828
+									} else {
4829
+										$invalid++;
4830
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4831
+									}
4832
+								} else {
4833
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4834
+										$created++;
4835
+									} else {
4836
+										$invalid++;
4837
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4838
+									}
4839
+								}
4840
+							} elseif ( $import_choice == 'skip' ) {
4841
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
4842
+									$skipped++;
4843
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
4844
+									$skipped++;
4845
+								} else {
4846 4846
                                     
4847
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4848
-                                        $created++;
4849
-                                    } else {
4850
-                                        $invalid++;
4851
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4852
-                                    }
4853
-                                }
4854
-                            } else {
4855
-                                $invalid++;
4856
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4857
-                            }
4858
-                        }
4859
-                    }
4860
-                }
4847
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
4848
+										$created++;
4849
+									} else {
4850
+										$invalid++;
4851
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4852
+									}
4853
+								}
4854
+							} else {
4855
+								$invalid++;
4856
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
4857
+							}
4858
+						}
4859
+					}
4860
+				}
4861 4861
                 
4862
-                $json = array();
4863
-                $json['processed'] = $limit;
4864
-                $json['created'] = $created;
4865
-                $json['updated'] = $updated;
4866
-                $json['skipped'] = $skipped;
4867
-                $json['invalid'] = $invalid;
4868
-                $json['images'] = $images;
4862
+				$json = array();
4863
+				$json['processed'] = $limit;
4864
+				$json['created'] = $created;
4865
+				$json['updated'] = $updated;
4866
+				$json['skipped'] = $skipped;
4867
+				$json['invalid'] = $invalid;
4868
+				$json['images'] = $images;
4869 4869
                 
4870
-                wp_send_json( $json );
4871
-            }
4872
-        }
4873
-        break;
4874
-        case 'import_finish':{
4875
-            /**
4876
-             * Run an action when an import finishes.
4877
-             *
4878
-             * This action can be used to fire functions after an import ends.
4879
-             *
4880
-             * @since 1.5.3
4881
-             * @package GeoDirectory
4882
-             */
4883
-            do_action('geodir_import_finished');
4884
-        }
4885
-        break;
4870
+				wp_send_json( $json );
4871
+			}
4872
+		}
4873
+		break;
4874
+		case 'import_finish':{
4875
+			/**
4876
+			 * Run an action when an import finishes.
4877
+			 *
4878
+			 * This action can be used to fire functions after an import ends.
4879
+			 *
4880
+			 * @since 1.5.3
4881
+			 * @package GeoDirectory
4882
+			 */
4883
+			do_action('geodir_import_finished');
4884
+		}
4885
+		break;
4886 4886
 
4887
-    }
4888
-    echo '0';
4889
-    gd_die();
4887
+	}
4888
+	echo '0';
4889
+	gd_die();
4890 4890
 }
4891 4891
 
4892 4892
 /**
@@ -4930,12 +4930,12 @@  discard block
 block discarded – undo
4930 4930
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
4931 4931
 	}
4932 4932
 	
4933
-    if( !empty( $term ) ) {
4933
+	if( !empty( $term ) ) {
4934 4934
 		$result = wp_insert_term( $term, $taxonomy, $args );
4935
-        if( !is_wp_error( $result ) ) {
4936
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4937
-        }
4938
-    }
4935
+		if( !is_wp_error( $result ) ) {
4936
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4937
+		}
4938
+	}
4939 4939
 	
4940 4940
 	return false;
4941 4941
 }
@@ -4981,16 +4981,16 @@  discard block
 block discarded – undo
4981 4981
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
4982 4982
 		
4983 4983
 		if( !is_wp_error( $result ) ) {
4984
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4985
-        }
4984
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4985
+		}
4986 4986
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4987 4987
 		$term_data['term_id'] = $term_info['term_id'];
4988 4988
 		
4989 4989
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
4990 4990
 		
4991 4991
 		if( !is_wp_error( $result ) ) {
4992
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4993
-        }
4992
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
4993
+		}
4994 4994
 	} else {
4995 4995
 		return geodir_imex_insert_term( $taxonomy, $term_data );
4996 4996
 	}
@@ -5012,47 +5012,47 @@  discard block
 block discarded – undo
5012 5012
  * @return int Posts count.
5013 5013
  */
5014 5014
 function geodir_get_posts_count( $post_type ) {
5015
-    global $wpdb, $plugin_prefix;
5015
+	global $wpdb, $plugin_prefix;
5016 5016
 
5017
-    if ( !post_type_exists( $post_type ) ) {
5018
-        return 0;
5019
-    }
5017
+	if ( !post_type_exists( $post_type ) ) {
5018
+		return 0;
5019
+	}
5020 5020
         
5021
-    $table = $plugin_prefix . $post_type . '_detail';
5021
+	$table = $plugin_prefix . $post_type . '_detail';
5022 5022
 
5023
-    // Skip listing with statuses trash, auto-draft etc...
5024
-    $skip_statuses = geodir_imex_export_skip_statuses();
5025
-    $where_statuses = '';
5026
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5027
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5028
-    }
5023
+	// Skip listing with statuses trash, auto-draft etc...
5024
+	$skip_statuses = geodir_imex_export_skip_statuses();
5025
+	$where_statuses = '';
5026
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5027
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5028
+	}
5029 5029
     
5030
-    /**
5031
-     * Filter the SQL where clause part to filter posts count in import/export.
5032
-     *
5033
-     * @since 1.6.4
5034
-     * @package GeoDirectory
5035
-     *
5036
-     * @param string $where SQL where clause part.
5037
-     */
5038
-    $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5039
-
5040
-    $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5041
-
5042
-    $posts_count = (int)$wpdb->get_var( $query );
5030
+	/**
5031
+	 * Filter the SQL where clause part to filter posts count in import/export.
5032
+	 *
5033
+	 * @since 1.6.4
5034
+	 * @package GeoDirectory
5035
+	 *
5036
+	 * @param string $where SQL where clause part.
5037
+	 */
5038
+	$where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type );
5039
+
5040
+	$query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
5041
+
5042
+	$posts_count = (int)$wpdb->get_var( $query );
5043 5043
     
5044
-    /**
5045
-     * Modify returned post counts for the current post type.
5046
-     *
5047
-     * @since 1.4.6
5048
-     * @package GeoDirectory
5049
-     *
5050
-     * @param int $posts_count Post counts.
5051
-     * @param string $post_type Post type.
5052
-     */
5053
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5054
-
5055
-    return $posts_count;
5044
+	/**
5045
+	 * Modify returned post counts for the current post type.
5046
+	 *
5047
+	 * @since 1.4.6
5048
+	 * @package GeoDirectory
5049
+	 *
5050
+	 * @param int $posts_count Post counts.
5051
+	 * @param string $post_type Post type.
5052
+	 */
5053
+	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5054
+
5055
+	return $posts_count;
5056 5056
 }
5057 5057
 
5058 5058
 /**
@@ -5120,7 +5120,7 @@  discard block
 block discarded – undo
5120 5120
 		}
5121 5121
 		$csv_row[] = 'post_status';
5122 5122
 		$csv_row[] = 'is_featured';
5123
-        // Export claim listing field
5123
+		// Export claim listing field
5124 5124
 		if ($is_claim_active) {
5125 5125
 			$csv_row[] = 'claimed';
5126 5126
 		}
@@ -5129,7 +5129,7 @@  discard block
 block discarded – undo
5129 5129
 			$csv_row[] = 'alive_days';
5130 5130
 			$csv_row[] = 'expire_date';
5131 5131
 		}
5132
-        $csv_row[] = 'post_date';
5132
+		$csv_row[] = 'post_date';
5133 5133
 		$csv_row[] = 'post_address';
5134 5134
 		$csv_row[] = 'post_city';
5135 5135
 		$csv_row[] = 'post_region';
@@ -5137,11 +5137,11 @@  discard block
 block discarded – undo
5137 5137
 		$csv_row[] = 'post_zip';
5138 5138
 		$csv_row[] = 'post_latitude';
5139 5139
 		$csv_row[] = 'post_longitude';
5140
-        if ($neighbourhood_active) {
5141
-            $csv_row[] = 'post_neighbourhood';
5142
-            $csv_row[] = 'neighbourhood_latitude';
5143
-            $csv_row[] = 'neighbourhood_longitude';
5144
-        }
5140
+		if ($neighbourhood_active) {
5141
+			$csv_row[] = 'post_neighbourhood';
5142
+			$csv_row[] = 'neighbourhood_latitude';
5143
+			$csv_row[] = 'neighbourhood_longitude';
5144
+		}
5145 5145
 		$csv_row[] = 'geodir_timing';
5146 5146
 		$csv_row[] = 'geodir_contact';
5147 5147
 		$csv_row[] = 'geodir_email';
@@ -5176,21 +5176,21 @@  discard block
 block discarded – undo
5176 5176
 			$csv_row[] = 'franchise';
5177 5177
 		}
5178 5178
         
5179
-        /**
5180
-         * Filter columns field names of gd export listings csv.
5181
-         *
5182
-         * @since 1.6.5
5183
-         * @package GeoDirectory
5184
-         *
5185
-         * @param array $csv_row Column names being exported in csv.
5186
-         * @param string $post_type The post type.
5187
-         */
5188
-        $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
5179
+		/**
5180
+		 * Filter columns field names of gd export listings csv.
5181
+		 *
5182
+		 * @since 1.6.5
5183
+		 * @package GeoDirectory
5184
+		 *
5185
+		 * @param array $csv_row Column names being exported in csv.
5186
+		 * @param string $post_type The post type.
5187
+		 */
5188
+		$csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
5189 5189
 		
5190 5190
 		$csv_rows[] = $csv_row;
5191 5191
 
5192 5192
 		$images_count = 5;
5193
-        $xx=0;
5193
+		$xx=0;
5194 5194
 		foreach ( $posts as $post ) {$xx++;
5195 5195
 			$post_id = $post['ID'];
5196 5196
 			
@@ -5321,15 +5321,15 @@  discard block
 block discarded – undo
5321 5321
 			}
5322 5322
 			$csv_row[] = $post_info['post_status']; // post_status
5323 5323
 			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5324
-            if ($is_claim_active) {
5325
-                $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5326
-            }
5324
+			if ($is_claim_active) {
5325
+				$csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed
5326
+			}
5327 5327
 			if ($is_payment_plugin) {
5328 5328
 				$csv_row[] = (int)$post_info['package_id']; // package_id
5329 5329
 				$csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days
5330 5330
 				$csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
5331 5331
 			}
5332
-            $csv_row[] = $post_info['post_date']; // post_date
5332
+			$csv_row[] = $post_info['post_date']; // post_date
5333 5333
 			$csv_row[] = stripslashes($post_info['post_address']); // post_address
5334 5334
 			$csv_row[] = stripslashes($post_info['post_city']); // post_city
5335 5335
 			$csv_row[] = stripslashes($post_info['post_region']); // post_region
@@ -5337,21 +5337,21 @@  discard block
 block discarded – undo
5337 5337
 			$csv_row[] = stripslashes($post_info['post_zip']); // post_zip
5338 5338
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5339 5339
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5340
-            if ($neighbourhood_active) {
5341
-                $post_neighbourhood = '';
5342
-                $neighbourhood_latitude = '';
5343
-                $neighbourhood_longitude = '';
5344
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5345
-                    if (!empty($hood_info)) {
5346
-                        $post_neighbourhood = $hood_info->hood_name;
5347
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5348
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5349
-                    }
5350
-                }
5351
-                $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood
5352
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5353
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5354
-            }
5340
+			if ($neighbourhood_active) {
5341
+				$post_neighbourhood = '';
5342
+				$neighbourhood_latitude = '';
5343
+				$neighbourhood_longitude = '';
5344
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5345
+					if (!empty($hood_info)) {
5346
+						$post_neighbourhood = $hood_info->hood_name;
5347
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5348
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5349
+					}
5350
+				}
5351
+				$csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood
5352
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5353
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5354
+			}
5355 5355
 			$csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing
5356 5356
 			$csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact
5357 5357
 			$csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email
@@ -5394,16 +5394,16 @@  discard block
 block discarded – undo
5394 5394
 				$csv_row[] = (int)$franchise; // franchise id
5395 5395
 			}
5396 5396
             
5397
-            /**
5398
-             * Filter columns values of gd export listings csv file
5399
-             *
5400
-             * @since 1.6.5
5401
-             * @package GeoDirectory
5402
-             *
5403
-             * @param array $csv_row Field values being exported in csv.
5404
-             * @param array $post_info The post info.
5405
-             */
5406
-            $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5397
+			/**
5398
+			 * Filter columns values of gd export listings csv file
5399
+			 *
5400
+			 * @since 1.6.5
5401
+			 * @package GeoDirectory
5402
+			 *
5403
+			 * @param array $csv_row Field values being exported in csv.
5404
+			 * @param array $post_info The post info.
5405
+			 */
5406
+			$csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
5407 5407
 			
5408 5408
 			for ( $c = 0; $c < $images_count; $c++ ) {
5409 5409
 				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
@@ -5436,64 +5436,64 @@  discard block
 block discarded – undo
5436 5436
  * @return array Array of posts data.
5437 5437
  */
5438 5438
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5439
-    global $wpdb, $plugin_prefix;
5439
+	global $wpdb, $plugin_prefix;
5440 5440
 
5441
-    if ( ! post_type_exists( $post_type ) )
5442
-        return new stdClass;
5441
+	if ( ! post_type_exists( $post_type ) )
5442
+		return new stdClass;
5443 5443
         
5444
-    $table = $plugin_prefix . $post_type . '_detail';
5444
+	$table = $plugin_prefix . $post_type . '_detail';
5445 5445
 
5446
-    $limit = '';
5447
-    if ( $per_page > 0 && $page_no > 0 ) {
5448
-        $offset = ( $page_no - 1 ) * $per_page;
5446
+	$limit = '';
5447
+	if ( $per_page > 0 && $page_no > 0 ) {
5448
+		$offset = ( $page_no - 1 ) * $per_page;
5449 5449
         
5450
-        if ( $offset > 0 ) {
5451
-            $limit = " LIMIT " . $offset . "," . $per_page;
5452
-        } else {
5453
-            $limit = " LIMIT " . $per_page;
5454
-        }
5455
-    }
5450
+		if ( $offset > 0 ) {
5451
+			$limit = " LIMIT " . $offset . "," . $per_page;
5452
+		} else {
5453
+			$limit = " LIMIT " . $per_page;
5454
+		}
5455
+	}
5456 5456
 
5457
-    // Skip listing with statuses trash, auto-draft etc...
5458
-    $skip_statuses = geodir_imex_export_skip_statuses();
5459
-    $where_statuses = '';
5460
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5461
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5462
-    }
5457
+	// Skip listing with statuses trash, auto-draft etc...
5458
+	$skip_statuses = geodir_imex_export_skip_statuses();
5459
+	$where_statuses = '';
5460
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5461
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5462
+	}
5463 5463
     
5464
-    /**
5465
-     * Filter the SQL where clause part to filter posts in import/export.
5466
-     *
5467
-     * @since 1.6.4
5468
-     * @package GeoDirectory
5469
-     *
5470
-     * @param string $where SQL where clause part.
5471
-     */
5472
-    $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5473
-
5474
-    $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5475
-    /**
5476
-     * Modify returned posts SQL query for the current post type.
5477
-     *
5478
-     * @since 1.4.6
5479
-     * @package GeoDirectory
5480
-     *
5481
-     * @param int $query The SQL query.
5482
-     * @param string $post_type Post type.
5483
-     */
5484
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5485
-    $results = (array)$wpdb->get_results( $query, ARRAY_A );
5486
-
5487
-    /**
5488
-     * Modify returned post results for the current post type.
5489
-     *
5490
-     * @since 1.4.6
5491
-     * @package GeoDirectory
5492
-     *
5493
-     * @param object $results An object containing all post ids.
5494
-     * @param string $post_type Post type.
5495
-     */
5496
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5464
+	/**
5465
+	 * Filter the SQL where clause part to filter posts in import/export.
5466
+	 *
5467
+	 * @since 1.6.4
5468
+	 * @package GeoDirectory
5469
+	 *
5470
+	 * @param string $where SQL where clause part.
5471
+	 */
5472
+	$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5473
+
5474
+	$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
5475
+	/**
5476
+	 * Modify returned posts SQL query for the current post type.
5477
+	 *
5478
+	 * @since 1.4.6
5479
+	 * @package GeoDirectory
5480
+	 *
5481
+	 * @param int $query The SQL query.
5482
+	 * @param string $post_type Post type.
5483
+	 */
5484
+	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5485
+	$results = (array)$wpdb->get_results( $query, ARRAY_A );
5486
+
5487
+	/**
5488
+	 * Modify returned post results for the current post type.
5489
+	 *
5490
+	 * @since 1.4.6
5491
+	 * @package GeoDirectory
5492
+	 *
5493
+	 * @param object $results An object containing all post ids.
5494
+	 * @param string $post_type Post type.
5495
+	 */
5496
+	return apply_filters( 'geodir_export_posts', $results, $post_type );
5497 5497
 }
5498 5498
 
5499 5499
 /**
@@ -5512,26 +5512,26 @@  discard block
 block discarded – undo
5512 5512
  * @return string The SQL query.
5513 5513
  */
5514 5514
 function geodir_imex_get_events_query( $query, $post_type ) {
5515
-    if ( $post_type == 'gd_event' ) {
5516
-        global $wpdb, $plugin_prefix;
5515
+	if ( $post_type == 'gd_event' ) {
5516
+		global $wpdb, $plugin_prefix;
5517 5517
         
5518
-        $table = $plugin_prefix . $post_type . '_detail';
5519
-        $schedule_table = EVENT_SCHEDULE;
5518
+		$table = $plugin_prefix . $post_type . '_detail';
5519
+		$schedule_table = EVENT_SCHEDULE;
5520 5520
         
5521
-        // Skip listing with statuses trash, auto-draft etc...
5522
-        $skip_statuses = geodir_imex_export_skip_statuses();
5523
-        $where_statuses = '';
5524
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5525
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5526
-        }
5521
+		// Skip listing with statuses trash, auto-draft etc...
5522
+		$skip_statuses = geodir_imex_export_skip_statuses();
5523
+		$where_statuses = '';
5524
+		if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5525
+			$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5526
+		}
5527 5527
         
5528
-        /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5529
-        $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5528
+		/** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */
5529
+		$where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type );
5530 5530
 
5531
-        $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5532
-    }
5531
+		$query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
5532
+	}
5533 5533
 
5534
-    return $query;
5534
+	return $query;
5535 5535
 }
5536 5536
 
5537 5537
 /**
@@ -5553,36 +5553,36 @@  discard block
 block discarded – undo
5553 5553
  * @return int Total terms count.
5554 5554
  */
5555 5555
 function geodir_get_terms_count( $post_type ) {
5556
-    $args = array( 'hide_empty' => 0 );
5556
+	$args = array( 'hide_empty' => 0 );
5557 5557
 
5558
-    remove_all_filters( 'get_terms' );
5558
+	remove_all_filters( 'get_terms' );
5559 5559
 
5560
-    $taxonomy = $post_type . 'category';
5560
+	$taxonomy = $post_type . 'category';
5561 5561
 
5562
-    // WPML
5563
-    $is_wpml = geodir_is_wpml();
5564
-    $active_lang = 'all';
5565
-    if ( $is_wpml ) {
5566
-        global $sitepress;
5567
-        $active_lang = $sitepress->get_current_language();
5562
+	// WPML
5563
+	$is_wpml = geodir_is_wpml();
5564
+	$active_lang = 'all';
5565
+	if ( $is_wpml ) {
5566
+		global $sitepress;
5567
+		$active_lang = $sitepress->get_current_language();
5568 5568
         
5569
-        if ( $active_lang != 'all' ) {
5570
-            $sitepress->switch_lang( 'all', true );
5571
-        }
5572
-    }
5573
-    // WPML
5569
+		if ( $active_lang != 'all' ) {
5570
+			$sitepress->switch_lang( 'all', true );
5571
+		}
5572
+	}
5573
+	// WPML
5574 5574
             
5575
-    $count_terms = wp_count_terms( $taxonomy, $args );
5575
+	$count_terms = wp_count_terms( $taxonomy, $args );
5576 5576
 
5577
-    // WPML
5578
-    if ( $is_wpml && $active_lang !== 'all' ) {
5579
-        global $sitepress;
5580
-        $sitepress->switch_lang( $active_lang, true );
5581
-    }
5582
-    // WPML
5583
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5577
+	// WPML
5578
+	if ( $is_wpml && $active_lang !== 'all' ) {
5579
+		global $sitepress;
5580
+		$sitepress->switch_lang( $active_lang, true );
5581
+	}
5582
+	// WPML
5583
+	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5584 5584
      
5585
-    return $count_terms;
5585
+	return $count_terms;
5586 5586
 }
5587 5587
 
5588 5588
 /**
@@ -5621,11 +5621,11 @@  discard block
 block discarded – undo
5621 5621
 		$csv_row[] = 'cat_posttype';
5622 5622
 		$csv_row[] = 'cat_parent';
5623 5623
 		$csv_row[] = 'cat_schema';
5624
-        // WPML
5624
+		// WPML
5625 5625
 		$is_wpml = geodir_is_wpml();
5626 5626
 		if ($is_wpml) {
5627 5627
 			$csv_row[] = 'cat_language';
5628
-            $csv_row[] = 'cat_id_original';
5628
+			$csv_row[] = 'cat_id_original';
5629 5629
 		}
5630 5630
 		// WPML
5631 5631
 		$csv_row[] = 'cat_description';
@@ -5655,10 +5655,10 @@  discard block
 block discarded – undo
5655 5655
 			$csv_row[] = $post_type;
5656 5656
 			$csv_row[] = $cat_parent;
5657 5657
 			$csv_row[] = geodir_get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5658
-            // WPML
5658
+			// WPML
5659 5659
 			if ($is_wpml) {
5660 5660
 				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5661
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5661
+				$csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5662 5662
 			}
5663 5663
 			// WPML
5664 5664
 			$csv_row[] = $term->description;
@@ -6076,43 +6076,43 @@  discard block
 block discarded – undo
6076 6076
  * @param string $status Post status.
6077 6077
  */
6078 6078
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6079
-    global $wpdb, $current_user;
6080
-
6081
-    $option_value = get_option($option);
6082
-
6083
-    if ($option_value > 0) :
6084
-        if (get_post($option_value)) :
6085
-            // Page exists
6086
-            return;
6087
-        endif;
6088
-    endif;
6089
-
6090
-    $page_found = $wpdb->get_var(
6091
-        $wpdb->prepare(
6092
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6093
-            array($slug)
6094
-        )
6095
-    );
6096
-
6097
-    if ($page_found) :
6098
-        // Page exists
6099
-        if (!$option_value) update_option($option, $page_found);
6100
-        return;
6101
-    endif;
6102
-
6103
-    $page_data = array(
6104
-        'post_status' => $status,
6105
-        'post_type' => 'page',
6106
-        'post_author' => $current_user->ID,
6107
-        'post_name' => $slug,
6108
-        'post_title' => $page_title,
6109
-        'post_content' => $page_content,
6110
-        'post_parent' => $post_parent,
6111
-        'comment_status' => 'closed'
6112
-    );
6113
-    $page_id = wp_insert_post($page_data);
6114
-
6115
-    add_option($option, $page_id);
6079
+	global $wpdb, $current_user;
6080
+
6081
+	$option_value = get_option($option);
6082
+
6083
+	if ($option_value > 0) :
6084
+		if (get_post($option_value)) :
6085
+			// Page exists
6086
+			return;
6087
+		endif;
6088
+	endif;
6089
+
6090
+	$page_found = $wpdb->get_var(
6091
+		$wpdb->prepare(
6092
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6093
+			array($slug)
6094
+		)
6095
+	);
6096
+
6097
+	if ($page_found) :
6098
+		// Page exists
6099
+		if (!$option_value) update_option($option, $page_found);
6100
+		return;
6101
+	endif;
6102
+
6103
+	$page_data = array(
6104
+		'post_status' => $status,
6105
+		'post_type' => 'page',
6106
+		'post_author' => $current_user->ID,
6107
+		'post_name' => $slug,
6108
+		'post_title' => $page_title,
6109
+		'post_content' => $page_content,
6110
+		'post_parent' => $post_parent,
6111
+		'comment_status' => 'closed'
6112
+	);
6113
+	$page_id = wp_insert_post($page_data);
6114
+
6115
+	add_option($option, $page_id);
6116 6116
 
6117 6117
 }
6118 6118
 
@@ -6143,9 +6143,9 @@  discard block
 block discarded – undo
6143 6143
  * @package GeoDirectory
6144 6144
  */
6145 6145
 function geodir_admin_upgrade_notice() {
6146
-    $class = "error";
6147
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6148
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6146
+	$class = "error";
6147
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6148
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6149 6149
 }
6150 6150
 
6151 6151
 /**
@@ -6158,18 +6158,18 @@  discard block
 block discarded – undo
6158 6158
  */
6159 6159
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6160 6160
 {
6161
-    // readme contents
6162
-    $args = array(
6163
-        'timeout'     => 15,
6164
-        'redirection' => 5
6165
-    );
6166
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6167
-    $data       = wp_remote_get( $url, $args );
6161
+	// readme contents
6162
+	$args = array(
6163
+		'timeout'     => 15,
6164
+		'redirection' => 5
6165
+	);
6166
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6167
+	$data       = wp_remote_get( $url, $args );
6168 6168
 
6169
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6169
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6170 6170
 
6171
-        geodir_in_plugin_update_message($data['body']);
6172
-    }
6171
+		geodir_in_plugin_update_message($data['body']);
6172
+	}
6173 6173
 }
6174 6174
 
6175 6175
 
@@ -6177,28 +6177,28 @@  discard block
 block discarded – undo
6177 6177
 * @param string $content http response body
6178 6178
 */
6179 6179
 function geodir_in_plugin_update_message($content) {
6180
-    // Output Upgrade Notice
6181
-    $matches        = null;
6182
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6183
-    $upgrade_notice = '';
6184
-    if ( preg_match( $regexp, $content, $matches ) ) {
6185
-        if(empty($matches)){return;}
6186
-
6187
-        $version = trim( $matches[1] );
6188
-        if($version && $version>GEODIRECTORY_VERSION){
6189
-
6190
-
6191
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6192
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6193
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6194
-            foreach ( $notices as $index => $line ) {
6195
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6196
-            }
6197
-            $upgrade_notice .= '</div> ';
6198
-        }
6199
-        }
6200
-    }
6201
-    echo $upgrade_notice;
6180
+	// Output Upgrade Notice
6181
+	$matches        = null;
6182
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6183
+	$upgrade_notice = '';
6184
+	if ( preg_match( $regexp, $content, $matches ) ) {
6185
+		if(empty($matches)){return;}
6186
+
6187
+		$version = trim( $matches[1] );
6188
+		if($version && $version>GEODIRECTORY_VERSION){
6189
+
6190
+
6191
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6192
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6193
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6194
+			foreach ( $notices as $index => $line ) {
6195
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6196
+			}
6197
+			$upgrade_notice .= '</div> ';
6198
+		}
6199
+		}
6200
+	}
6201
+	echo $upgrade_notice;
6202 6202
 }
6203 6203
 
6204 6204
 /**
@@ -6231,19 +6231,19 @@  discard block
 block discarded – undo
6231 6231
  * @param array Listing statuses to be skipped.
6232 6232
  */
6233 6233
 function geodir_imex_export_skip_statuses() {
6234
-    $statuses = array( 'trash', 'auto-draft' );
6234
+	$statuses = array( 'trash', 'auto-draft' );
6235 6235
     
6236
-    /**
6237
-     * Filter the statuses to skip during GD export listings.
6238
-     *
6239
-     * @since 1.6.0
6240
-     * @package GeoDirectory
6241
-     *
6242
-     * @param array $statuses Listing statuses to be skipped.
6243
-     */
6244
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6236
+	/**
6237
+	 * Filter the statuses to skip during GD export listings.
6238
+	 *
6239
+	 * @since 1.6.0
6240
+	 * @package GeoDirectory
6241
+	 *
6242
+	 * @param array $statuses Listing statuses to be skipped.
6243
+	 */
6244
+	$statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6245 6245
      
6246
-    return $statuses;
6246
+	return $statuses;
6247 6247
 }
6248 6248
 
6249 6249
 /**
@@ -6259,42 +6259,42 @@  discard block
 block discarded – undo
6259 6259
  * @global string $typenow Current post type.
6260 6260
  */
6261 6261
 function geodir_admin_dequeue_scripts() {
6262
-    global $typenow;
6262
+	global $typenow;
6263 6263
     
6264
-    // EDD
6265
-    if (wp_script_is('jquery-chosen', 'enqueued')) {
6266
-        wp_dequeue_script('jquery-chosen');
6267
-    }
6264
+	// EDD
6265
+	if (wp_script_is('jquery-chosen', 'enqueued')) {
6266
+		wp_dequeue_script('jquery-chosen');
6267
+	}
6268 6268
     
6269
-    // Ultimate Addons for Visual Composer
6270
-    if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6271
-        wp_dequeue_script('ultimate-vc-backend-script');
6272
-    }
6269
+	// Ultimate Addons for Visual Composer
6270
+	if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6271
+		wp_dequeue_script('ultimate-vc-backend-script');
6272
+	}
6273 6273
     
6274
-    // VC editor conflicts
6275
-    if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
6276
-        wp_dequeue_script('dfd_vc_damin_scripts');
6277
-    }
6274
+	// VC editor conflicts
6275
+	if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
6276
+		wp_dequeue_script('dfd_vc_damin_scripts');
6277
+	}
6278 6278
     
6279
-    // Ultimate chosen
6280
-    if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
6281
-        wp_dequeue_script('ultimate-chosen-script');
6282
-    }
6279
+	// Ultimate chosen
6280
+	if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
6281
+		wp_dequeue_script('ultimate-chosen-script');
6282
+	}
6283 6283
     
6284
-    // Crum composer choosen
6285
-    if (wp_script_is('crum-composer-choosen', 'enqueued')) {
6286
-        wp_dequeue_script('crum-composer-choosen');
6287
-    }
6284
+	// Crum composer choosen
6285
+	if (wp_script_is('crum-composer-choosen', 'enqueued')) {
6286
+		wp_dequeue_script('crum-composer-choosen');
6287
+	}
6288 6288
     
6289
-    // Fix conflict Fusion Builder jquery chosen with GD jquery chosen.
6290
-    if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
6291
-        wp_dequeue_script('fusion_builder_chosen_js');
6292
-    }
6289
+	// Fix conflict Fusion Builder jquery chosen with GD jquery chosen.
6290
+	if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
6291
+		wp_dequeue_script('fusion_builder_chosen_js');
6292
+	}
6293 6293
     
6294
-    // Fix conflicts timepicker & setting date value.
6295
-    if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
6296
-        wp_dequeue_script('acf-timepicker');
6297
-    }
6294
+	// Fix conflicts timepicker & setting date value.
6295
+	if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
6296
+		wp_dequeue_script('acf-timepicker');
6297
+	}
6298 6298
 }
6299 6299
 
6300 6300
 /**
@@ -6310,48 +6310,48 @@  discard block
 block discarded – undo
6310 6310
  * @return string SQL where clause part.
6311 6311
  */
6312 6312
 function geodir_imex_get_filter_where($where = '', $post_type = '') {
6313
-    global $wpdb;
6313
+	global $wpdb;
6314 6314
     
6315
-    $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6315
+	$filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL;
6316 6316
     
6317
-    if ( !empty( $filters ) ) {
6318
-        foreach ( $filters as $field => $value ) {
6319
-            switch ($field) {
6320
-                case 'start_date':
6321
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6322
-                break;
6323
-                case 'end_date':
6324
-                    $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6325
-                break;
6326
-            }
6327
-        }
6328
-    }
6317
+	if ( !empty( $filters ) ) {
6318
+		foreach ( $filters as $field => $value ) {
6319
+			switch ($field) {
6320
+				case 'start_date':
6321
+					$where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'";
6322
+				break;
6323
+				case 'end_date':
6324
+					$where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'";
6325
+				break;
6326
+			}
6327
+		}
6328
+	}
6329 6329
     
6330
-    return $where;
6330
+	return $where;
6331 6331
 }
6332 6332
 add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2);
6333 6333
 add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
6334 6334
 
6335 6335
 
6336 6336
 function geodir_fix_for_primer_theme(){
6337
-    if(!defined( 'PRIMER_VERSION' )){return;}
6338
-    global $pagenow;
6337
+	if(!defined( 'PRIMER_VERSION' )){return;}
6338
+	global $pagenow;
6339 6339
 
6340
-    if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) )  ){
6340
+	if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) )  ){
6341 6341
 
6342
-        $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] );
6342
+		$post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] );
6343 6343
 
6344
-        $post_types = geodir_get_posttypes();
6345
-        if ($post_type && in_array($post_type, $post_types) ) {
6346
-            global $primer_customizer_layouts;
6347
-            remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10);
6348
-        }
6349
-    }
6344
+		$post_types = geodir_get_posttypes();
6345
+		if ($post_type && in_array($post_type, $post_types) ) {
6346
+			global $primer_customizer_layouts;
6347
+			remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10);
6348
+		}
6349
+	}
6350 6350
 
6351 6351
 }
6352 6352
 
6353 6353
 if(is_admin()){
6354
-    add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);  
6354
+	add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);  
6355 6355
 }
6356 6356
 
6357 6357
 
@@ -6484,96 +6484,96 @@  discard block
 block discarded – undo
6484 6484
 
6485 6485
 function geodir_ga_activation_url() {
6486 6486
 
6487
-    return add_query_arg( array(
6488
-        'next'          => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
6489
-        'scope'         => GEODIR_GA_SCOPE,
6490
-        'response_type' => 'code',
6491
-        'redirect_uri'  => GEODIR_GA_REDIRECT,
6492
-        'client_id'     => GEODIR_GA_CLIENTID,
6493
-    ), 'https://accounts.google.com/o/oauth2/auth' );
6487
+	return add_query_arg( array(
6488
+		'next'          => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
6489
+		'scope'         => GEODIR_GA_SCOPE,
6490
+		'response_type' => 'code',
6491
+		'redirect_uri'  => GEODIR_GA_REDIRECT,
6492
+		'client_id'     => GEODIR_GA_CLIENTID,
6493
+	), 'https://accounts.google.com/o/oauth2/auth' );
6494 6494
 
6495
-    return $url;
6495
+	return $url;
6496 6496
 }
6497 6497
 
6498 6498
 function geodir_gd_accounts(){
6499
-    $accounts = array();
6500
-    $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true );
6501
-    if($useAuth){
6502
-        try {
6503
-            $accounts = geodir_ga_get_analytics_accounts();
6504
-        } catch (Exception $e) {
6505
-            geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) );
6506
-        }
6499
+	$accounts = array();
6500
+	$useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true );
6501
+	if($useAuth){
6502
+		try {
6503
+			$accounts = geodir_ga_get_analytics_accounts();
6504
+		} catch (Exception $e) {
6505
+			geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) );
6506
+		}
6507 6507
         
6508
-        if(is_array($accounts)){
6509
-            $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
6510
-        }elseif(get_option('geodir_ga_account_id')){
6511
-            $accounts = array();
6512
-            $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
6513
-        }
6514
-    }
6515
-    return $accounts;
6508
+		if(is_array($accounts)){
6509
+			$accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
6510
+		}elseif(get_option('geodir_ga_account_id')){
6511
+			$accounts = array();
6512
+			$accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
6513
+		}
6514
+	}
6515
+	return $accounts;
6516 6516
 }
6517 6517
 
6518 6518
 function geodir_ga_get_analytics_accounts()
6519 6519
 {
6520
-    global $gd_ga_errors;
6521
-    $accounts = array();
6520
+	global $gd_ga_errors;
6521
+	$accounts = array();
6522 6522
 
6523
-    if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
6523
+	if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
6524 6524
 
6525 6525
 
6526
-    if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
6527
-      return get_option('geodir_gd_uids');
6528
-    }
6526
+	if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
6527
+	  return get_option('geodir_gd_uids');
6528
+	}
6529 6529
 
6530
-    # Create a new Gdata call
6531
-    if ( trim(get_option('geodir_ga_auth_code')) != '' )
6532
-        $stats = new GDGoogleAnalyticsStats();
6533
-    else
6534
-        return false;
6530
+	# Create a new Gdata call
6531
+	if ( trim(get_option('geodir_ga_auth_code')) != '' )
6532
+		$stats = new GDGoogleAnalyticsStats();
6533
+	else
6534
+		return false;
6535 6535
 
6536
-    # Check if Google sucessfully logged in
6537
-    if ( ! $stats->checkLogin() )
6538
-        return false;
6536
+	# Check if Google sucessfully logged in
6537
+	if ( ! $stats->checkLogin() )
6538
+		return false;
6539 6539
 
6540
-    # Get a list of accounts
6541
-    try {
6542
-        $accounts = $stats->getAllProfiles();
6543
-    } catch (Exception $e) {
6544
-        $gd_ga_errors[] = $e->getMessage();
6545
-        return false;
6546
-    }
6540
+	# Get a list of accounts
6541
+	try {
6542
+		$accounts = $stats->getAllProfiles();
6543
+	} catch (Exception $e) {
6544
+		$gd_ga_errors[] = $e->getMessage();
6545
+		return false;
6546
+	}
6547 6547
 
6548 6548
 
6549
-    natcasesort ($accounts);
6549
+	natcasesort ($accounts);
6550 6550
 
6551
-    # Return the account array if there are accounts
6552
-    if ( count($accounts) > 0 ){
6553
-        update_option('geodir_gd_uids',$accounts);
6554
-        return $accounts;
6555
-    }
6556
-    else
6557
-        return false;
6551
+	# Return the account array if there are accounts
6552
+	if ( count($accounts) > 0 ){
6553
+		update_option('geodir_gd_uids',$accounts);
6554
+		return $accounts;
6555
+	}
6556
+	else
6557
+		return false;
6558 6558
 }
6559 6559
 
6560 6560
 add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' );
6561 6561
 function geodir_ga_deauthorize(){
6562 6562
 
6563
-    if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
6563
+	if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
6564 6564
 
6565
-        die( 'Security check' );
6565
+		die( 'Security check' );
6566 6566
 
6567
-    } else {
6568
-        update_option('geodir_ga_auth_token','');
6569
-        update_option('geodir_ga_auth_code','');
6570
-        update_option('geodir_gd_uids','');
6567
+	} else {
6568
+		update_option('geodir_ga_auth_token','');
6569
+		update_option('geodir_ga_auth_code','');
6570
+		update_option('geodir_gd_uids','');
6571 6571
 
6572 6572
 
6573
-        echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
6574
-    }
6573
+		echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
6574
+	}
6575 6575
 
6576
-    die();
6576
+	die();
6577 6577
 }
6578 6578
 
6579 6579
 
@@ -6584,12 +6584,12 @@  discard block
 block discarded – undo
6584 6584
  * @package GeoDirectory
6585 6585
  */
6586 6586
 function geodir_post_type_setting_fun() {
6587
-    $post_type_arr = array();
6587
+	$post_type_arr = array();
6588 6588
 
6589
-    $post_types = geodir_get_posttypes('object');
6589
+	$post_types = geodir_get_posttypes('object');
6590 6590
 
6591
-    foreach ($post_types as $key => $post_types_obj) {
6592
-        $post_type_arr[$key] = $post_types_obj->labels->singular_name;
6593
-    }
6594
-    return $post_type_arr;
6591
+	foreach ($post_types as $key => $post_types_obj) {
6592
+		$post_type_arr[$key] = $post_types_obj->labels->singular_name;
6593
+	}
6594
+	return $post_type_arr;
6595 6595
 }
6596 6596
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory_template_actions.php 1 patch
Indentation   +1838 added lines, -1838 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function gd_compat_styles()
19 19
 {
20
-    $tc = get_option('theme_compatibility_setting');
21
-    echo "<style id='gd-compat-styles' type='text/css'>";
22
-    echo $tc['geodir_theme_compat_css'];
23
-    echo "</style>";
20
+	$tc = get_option('theme_compatibility_setting');
21
+	echo "<style id='gd-compat-styles' type='text/css'>";
22
+	echo $tc['geodir_theme_compat_css'];
23
+	echo "</style>";
24 24
 }
25 25
 
26 26
 /**
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function gd_compat_script()
33 33
 {
34
-    $tc = get_option('theme_compatibility_setting');
35
-    echo "<script>";
36
-    echo $tc['geodir_theme_compat_js'];
37
-    echo " </script>";
34
+	$tc = get_option('theme_compatibility_setting');
35
+	echo "<script>";
36
+	echo $tc['geodir_theme_compat_js'];
37
+	echo " </script>";
38 38
 }
39 39
 
40 40
 /**
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_top_content_add_dynamic()
49 49
 {
50
-    $tc = get_option('theme_compatibility_setting');
51
-    echo $tc['geodir_top_content_add'];
50
+	$tc = get_option('theme_compatibility_setting');
51
+	echo $tc['geodir_top_content_add'];
52 52
 }
53 53
 
54 54
 /**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
  */
62 62
 function geodir_before_main_content_add_dynamic()
63 63
 {
64
-    $tc = get_option('theme_compatibility_setting');
65
-    echo $tc['geodir_before_main_content_add'];
64
+	$tc = get_option('theme_compatibility_setting');
65
+	echo $tc['geodir_before_main_content_add'];
66 66
 }
67 67
 
68 68
 /**
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function geodir_full_page_class_dynamic()
77 77
 {
78
-    $tc = get_option('theme_compatibility_setting');
79
-    return $tc['geodir_full_page_class_filter'];
78
+	$tc = get_option('theme_compatibility_setting');
79
+	return $tc['geodir_full_page_class_filter'];
80 80
 }
81 81
 
82 82
 /**
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function geodir_before_widget_dynamic()
91 91
 {
92
-    $tc = get_option('theme_compatibility_setting');
93
-    return $tc['geodir_before_widget_filter'];
92
+	$tc = get_option('theme_compatibility_setting');
93
+	return $tc['geodir_before_widget_filter'];
94 94
 }
95 95
 
96 96
 /**
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function geodir_after_widget_dynamic()
105 105
 {
106
-    $tc = get_option('theme_compatibility_setting');
107
-    return $tc['geodir_after_widget_filter'];
106
+	$tc = get_option('theme_compatibility_setting');
107
+	return $tc['geodir_after_widget_filter'];
108 108
 }
109 109
 
110 110
 /**
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function geodir_before_title_dynamic()
119 119
 {
120
-    $tc = get_option('theme_compatibility_setting');
121
-    return $tc['geodir_before_title_filter'];
120
+	$tc = get_option('theme_compatibility_setting');
121
+	return $tc['geodir_before_title_filter'];
122 122
 }
123 123
 
124 124
 /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function geodir_after_title_dynamic()
133 133
 {
134
-    $tc = get_option('theme_compatibility_setting');
135
-    return $tc['geodir_after_title_filter'];
134
+	$tc = get_option('theme_compatibility_setting');
135
+	return $tc['geodir_after_title_filter'];
136 136
 }
137 137
 
138 138
 /**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function geodir_menu_li_class_dynamic()
147 147
 {
148
-    $tc = get_option('theme_compatibility_setting');
149
-    return $tc['geodir_menu_li_class_filter'];
148
+	$tc = get_option('theme_compatibility_setting');
149
+	return $tc['geodir_menu_li_class_filter'];
150 150
 }
151 151
 
152 152
 /**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
  */
160 160
 function geodir_sub_menu_ul_class_dynamic()
161 161
 {
162
-    $tc = get_option('theme_compatibility_setting');
163
-    return $tc['geodir_sub_menu_ul_class_filter'];
162
+	$tc = get_option('theme_compatibility_setting');
163
+	return $tc['geodir_sub_menu_ul_class_filter'];
164 164
 }
165 165
 
166 166
 /**
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
  */
174 174
 function geodir_sub_menu_li_class_dynamic()
175 175
 {
176
-    $tc = get_option('theme_compatibility_setting');
177
-    return $tc['geodir_sub_menu_li_class_filter'];
176
+	$tc = get_option('theme_compatibility_setting');
177
+	return $tc['geodir_sub_menu_li_class_filter'];
178 178
 }
179 179
 
180 180
 /**
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
  */
188 188
 function geodir_menu_a_class_dynamic()
189 189
 {
190
-    $tc = get_option('theme_compatibility_setting');
191
-    return $tc['geodir_menu_a_class_filter'];
190
+	$tc = get_option('theme_compatibility_setting');
191
+	return $tc['geodir_menu_a_class_filter'];
192 192
 }
193 193
 
194 194
 /**
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
  */
202 202
 function geodir_sub_menu_a_class_dynamic()
203 203
 {
204
-    $tc = get_option('theme_compatibility_setting');
205
-    return $tc['geodir_sub_menu_a_class_filter'];
204
+	$tc = get_option('theme_compatibility_setting');
205
+	return $tc['geodir_sub_menu_a_class_filter'];
206 206
 }
207 207
 
208 208
 /**
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
  */
216 216
 function geodir_location_switcher_menu_li_class_dynamic()
217 217
 {
218
-    $tc = get_option('theme_compatibility_setting');
219
-    return $tc['geodir_location_switcher_menu_li_class_filter'];
218
+	$tc = get_option('theme_compatibility_setting');
219
+	return $tc['geodir_location_switcher_menu_li_class_filter'];
220 220
 }
221 221
 
222 222
 /**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function geodir_location_switcher_menu_a_class_dynamic()
231 231
 {
232
-    $tc = get_option('theme_compatibility_setting');
233
-    return $tc['geodir_location_switcher_menu_a_class_filter'];
232
+	$tc = get_option('theme_compatibility_setting');
233
+	return $tc['geodir_location_switcher_menu_a_class_filter'];
234 234
 }
235 235
 
236 236
 /**
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
  */
244 244
 function geodir_location_switcher_menu_sub_ul_class_dynamic()
245 245
 {
246
-    $tc = get_option('theme_compatibility_setting');
247
-    return $tc['geodir_location_switcher_menu_sub_ul_class_filter'];
246
+	$tc = get_option('theme_compatibility_setting');
247
+	return $tc['geodir_location_switcher_menu_sub_ul_class_filter'];
248 248
 }
249 249
 
250 250
 /**
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
  */
258 258
 function geodir_location_switcher_menu_sub_li_class_dynamic()
259 259
 {
260
-    $tc = get_option('theme_compatibility_setting');
261
-    return $tc['geodir_location_switcher_menu_sub_li_class_filter'];
260
+	$tc = get_option('theme_compatibility_setting');
261
+	return $tc['geodir_location_switcher_menu_sub_li_class_filter'];
262 262
 }
263 263
 
264 264
 
@@ -275,107 +275,107 @@  discard block
 block discarded – undo
275 275
 function geodir_content_actions_dynamic()
276 276
 {
277 277
 
278
-    $tc = get_option('theme_compatibility_setting');
278
+	$tc = get_option('theme_compatibility_setting');
279 279
 //print_r($tc);
280
-    if (empty($tc)) {
281
-        return;
282
-    }
283
-
284
-    //php
285
-    if (!empty($tc['geodir_theme_compat_code'])) {
286
-        include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
287
-    }
288
-
289
-    //geodir_full_page_class
290
-    if (!empty($tc['geodir_full_page_class_filter'])) {
291
-        add_filter('geodir_full_page_class', 'geodir_full_page_class_dynamic', 10);
292
-    }
293
-
294
-    //widget before filter
295
-    if (!empty($tc['geodir_before_widget_filter'])) {
296
-        add_filter('geodir_before_widget', 'geodir_before_widget_dynamic', 10);
297
-    }
298
-
299
-    //widget after filter
300
-    if (!empty($tc['geodir_after_widget_filter'])) {
301
-        add_filter('geodir_after_widget', 'geodir_after_widget_dynamic', 10);
302
-    }
303
-
304
-    //widget before title filter
305
-    if (!empty($tc['geodir_before_title_filter'])) {
306
-        add_filter('geodir_before_title', 'geodir_before_title_dynamic', 10);
307
-    }
308
-
309
-    //widget before title filter
310
-    if (!empty($tc['geodir_after_title_filter'])) {
311
-        add_filter('geodir_after_title', 'geodir_after_title_dynamic', 10);
312
-    }
313
-
314
-    //menu li class
315
-    if (!empty($tc['geodir_menu_li_class_filter'])) {
316
-        add_filter('geodir_menu_li_class', 'geodir_menu_li_class_dynamic', 10);
317
-    }
318
-
319
-    //menu ul class
320
-    if (!empty($tc['geodir_sub_menu_ul_class_filter'])) {
321
-        add_filter('geodir_sub_menu_ul_class', 'geodir_sub_menu_ul_class_dynamic', 10);
322
-    }
323
-
324
-    //menu sub li class
325
-    if (!empty($tc['geodir_sub_menu_li_class_filter'])) {
326
-        add_filter('geodir_sub_menu_li_class', 'geodir_sub_menu_li_class_dynamic', 10);
327
-    }
328
-
329
-    //menu a class
330
-    if (!empty($tc['geodir_menu_a_class_filter'])) {
331
-        add_filter('geodir_menu_a_class', 'geodir_menu_a_class_dynamic', 10);
332
-    }
333
-
334
-    //menu sub a class
335
-    if (!empty($tc['geodir_sub_menu_a_class_filter'])) {
336
-        add_filter('geodir_sub_menu_a_class', 'geodir_sub_menu_a_class_dynamic', 10);
337
-    }
338
-
339
-    //location menu li class
340
-    if (!empty($tc['geodir_location_switcher_menu_li_class_filter'])) {
341
-        add_filter('geodir_location_switcher_menu_li_class', 'geodir_location_switcher_menu_li_class_dynamic', 10);
342
-    }
343
-
344
-    //location menu sub ul class
345
-    if (!empty($tc['geodir_location_switcher_menu_sub_ul_class_filter'])) {
346
-        add_filter('geodir_location_switcher_menu_sub_ul_class', 'geodir_location_switcher_menu_sub_ul_class_dynamic', 10);
347
-    }
348
-
349
-    //location menu sub li class
350
-    if (!empty($tc['geodir_location_switcher_menu_sub_li_class_filter'])) {
351
-        add_filter('geodir_location_switcher_menu_sub_li_class', 'geodir_location_switcher_menu_sub_li_class_dynamic', 10);
352
-    }
353
-
354
-    //location menu a class
355
-    if (!empty($tc['geodir_location_switcher_menu_a_class_filter'])) {
356
-        add_filter('geodir_location_switcher_menu_a_class', 'geodir_location_switcher_menu_a_class_dynamic', 10);
357
-    }
358
-
359
-    // compat styles
360
-    if (!empty($tc['geodir_theme_compat_css'])) {
361
-        add_action('wp_head', 'gd_compat_styles');
362
-    }
363
-
364
-    // compat js
365
-    if (!empty($tc['geodir_theme_compat_js'])) {
366
-        add_action('wp_footer', 'gd_compat_script');
367
-    }
368
-
369
-
370
-    // geodir_top_content_add
371
-    if (!empty($tc['geodir_top_content_add'])) {
372
-        add_action('geodir_top_content', 'geodir_top_content_add_dynamic', 10, 1);
373
-    }
374
-
375
-    // geodir_before_main_content_add
376
-    if (!empty($tc['geodir_before_main_content_add'])) {
377
-        add_action('geodir_before_main_content', 'geodir_before_main_content_add_dynamic', 10, 1);
378
-    }
280
+	if (empty($tc)) {
281
+		return;
282
+	}
283
+
284
+	//php
285
+	if (!empty($tc['geodir_theme_compat_code'])) {
286
+		include_once('geodirectory-functions/compatibility/' . $tc['geodir_theme_compat_code'] . '.php');
287
+	}
288
+
289
+	//geodir_full_page_class
290
+	if (!empty($tc['geodir_full_page_class_filter'])) {
291
+		add_filter('geodir_full_page_class', 'geodir_full_page_class_dynamic', 10);
292
+	}
293
+
294
+	//widget before filter
295
+	if (!empty($tc['geodir_before_widget_filter'])) {
296
+		add_filter('geodir_before_widget', 'geodir_before_widget_dynamic', 10);
297
+	}
298
+
299
+	//widget after filter
300
+	if (!empty($tc['geodir_after_widget_filter'])) {
301
+		add_filter('geodir_after_widget', 'geodir_after_widget_dynamic', 10);
302
+	}
303
+
304
+	//widget before title filter
305
+	if (!empty($tc['geodir_before_title_filter'])) {
306
+		add_filter('geodir_before_title', 'geodir_before_title_dynamic', 10);
307
+	}
308
+
309
+	//widget before title filter
310
+	if (!empty($tc['geodir_after_title_filter'])) {
311
+		add_filter('geodir_after_title', 'geodir_after_title_dynamic', 10);
312
+	}
313
+
314
+	//menu li class
315
+	if (!empty($tc['geodir_menu_li_class_filter'])) {
316
+		add_filter('geodir_menu_li_class', 'geodir_menu_li_class_dynamic', 10);
317
+	}
318
+
319
+	//menu ul class
320
+	if (!empty($tc['geodir_sub_menu_ul_class_filter'])) {
321
+		add_filter('geodir_sub_menu_ul_class', 'geodir_sub_menu_ul_class_dynamic', 10);
322
+	}
323
+
324
+	//menu sub li class
325
+	if (!empty($tc['geodir_sub_menu_li_class_filter'])) {
326
+		add_filter('geodir_sub_menu_li_class', 'geodir_sub_menu_li_class_dynamic', 10);
327
+	}
328
+
329
+	//menu a class
330
+	if (!empty($tc['geodir_menu_a_class_filter'])) {
331
+		add_filter('geodir_menu_a_class', 'geodir_menu_a_class_dynamic', 10);
332
+	}
333
+
334
+	//menu sub a class
335
+	if (!empty($tc['geodir_sub_menu_a_class_filter'])) {
336
+		add_filter('geodir_sub_menu_a_class', 'geodir_sub_menu_a_class_dynamic', 10);
337
+	}
338
+
339
+	//location menu li class
340
+	if (!empty($tc['geodir_location_switcher_menu_li_class_filter'])) {
341
+		add_filter('geodir_location_switcher_menu_li_class', 'geodir_location_switcher_menu_li_class_dynamic', 10);
342
+	}
343
+
344
+	//location menu sub ul class
345
+	if (!empty($tc['geodir_location_switcher_menu_sub_ul_class_filter'])) {
346
+		add_filter('geodir_location_switcher_menu_sub_ul_class', 'geodir_location_switcher_menu_sub_ul_class_dynamic', 10);
347
+	}
348
+
349
+	//location menu sub li class
350
+	if (!empty($tc['geodir_location_switcher_menu_sub_li_class_filter'])) {
351
+		add_filter('geodir_location_switcher_menu_sub_li_class', 'geodir_location_switcher_menu_sub_li_class_dynamic', 10);
352
+	}
353
+
354
+	//location menu a class
355
+	if (!empty($tc['geodir_location_switcher_menu_a_class_filter'])) {
356
+		add_filter('geodir_location_switcher_menu_a_class', 'geodir_location_switcher_menu_a_class_dynamic', 10);
357
+	}
358
+
359
+	// compat styles
360
+	if (!empty($tc['geodir_theme_compat_css'])) {
361
+		add_action('wp_head', 'gd_compat_styles');
362
+	}
363
+
364
+	// compat js
365
+	if (!empty($tc['geodir_theme_compat_js'])) {
366
+		add_action('wp_footer', 'gd_compat_script');
367
+	}
368
+
369
+
370
+	// geodir_top_content_add
371
+	if (!empty($tc['geodir_top_content_add'])) {
372
+		add_action('geodir_top_content', 'geodir_top_content_add_dynamic', 10, 1);
373
+	}
374
+
375
+	// geodir_before_main_content_add
376
+	if (!empty($tc['geodir_before_main_content_add'])) {
377
+		add_action('geodir_before_main_content', 'geodir_before_main_content_add_dynamic', 10, 1);
378
+	}
379 379
 
380 380
 
381 381
 }
@@ -398,23 +398,23 @@  discard block
 block discarded – undo
398 398
  */
399 399
 function geodir_action_wrapper_open($type = '', $id = '', $class = '')
400 400
 {
401
-    $tc = get_option('theme_compatibility_setting');
402
-    if (!empty($tc['geodir_wrapper_open_replace'])) {
403
-        $text = $tc['geodir_wrapper_open_replace'];
404
-    } else {
405
-        $text = '<div id="[id]" class="[class]">';
406
-    }
401
+	$tc = get_option('theme_compatibility_setting');
402
+	if (!empty($tc['geodir_wrapper_open_replace'])) {
403
+		$text = $tc['geodir_wrapper_open_replace'];
404
+	} else {
405
+		$text = '<div id="[id]" class="[class]">';
406
+	}
407 407
 
408
-    if (!empty($tc['geodir_wrapper_open_id'])) {
409
-        $id = $tc['geodir_wrapper_open_id'];
410
-    }
411
-    if (!empty($tc['geodir_wrapper_open_class'])) {
412
-        $class = $tc['geodir_wrapper_open_class'];
413
-    }
408
+	if (!empty($tc['geodir_wrapper_open_id'])) {
409
+		$id = $tc['geodir_wrapper_open_id'];
410
+	}
411
+	if (!empty($tc['geodir_wrapper_open_class'])) {
412
+		$class = $tc['geodir_wrapper_open_class'];
413
+	}
414 414
 
415
-    $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
415
+	$text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
416 416
 
417
-    echo $text;
417
+	echo $text;
418 418
 }
419 419
 
420 420
 // action for adding the wrapperdiv closing tag
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
  */
430 430
 function geodir_action_wrapper_close($type = '')
431 431
 {
432
-    $tc = get_option('theme_compatibility_setting');
433
-    if (!empty($tc['geodir_wrapper_close_replace'])) {
434
-        $text = $tc['geodir_wrapper_close_replace'];
435
-    } else {
436
-        $text = '</div><!-- wrapper ends here-->';
437
-    }
432
+	$tc = get_option('theme_compatibility_setting');
433
+	if (!empty($tc['geodir_wrapper_close_replace'])) {
434
+		$text = $tc['geodir_wrapper_close_replace'];
435
+	} else {
436
+		$text = '</div><!-- wrapper ends here-->';
437
+	}
438 438
 
439
-    echo $text;
439
+	echo $text;
440 440
 }
441 441
 
442 442
 // action for adding the content div opening tag
@@ -452,35 +452,35 @@  discard block
 block discarded – undo
452 452
  */
453 453
 function geodir_action_wrapper_content_open($type = '', $id = '', $class = '')
454 454
 {
455
-    if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
456
-        $width_css = 'style="width:' . $width . '%;"';
457
-    } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
458
-        $width_css = 'style="width:' . $width . '%;"';
459
-    } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
460
-        $width_css = 'style="width:' . $width . '%;"';
461
-    } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
462
-        $width_css = 'style="width:' . $width . '%;"';
463
-    } else {
464
-        $width_css = '';
465
-    }
466
-
467
-    $tc = get_option('theme_compatibility_setting');
468
-    if (!empty($tc['geodir_wrapper_content_open_replace'])) {
469
-        $text = $tc['geodir_wrapper_content_open_replace'];
470
-    } else {
471
-        $text = '<div id="[id]" class="[class]" role="main" [width_css]>';
472
-    }
473
-
474
-    if (!empty($tc['geodir_wrapper_content_open_id'])) {
475
-        $id = $tc['geodir_wrapper_content_open_id'];
476
-    }
477
-    if (!empty($tc['geodir_wrapper_content_open_class'])) {
478
-        $class = $tc['geodir_wrapper_content_open_class'];
479
-    }
480
-
481
-    $text = str_replace(array("[id]", "[class]", "[width_css]"), array($id, $class, $width_css), $text);
482
-
483
-    echo $text;
455
+	if ($type == 'home-page' && $width = get_option('geodir_width_home_contant_section')) {
456
+		$width_css = 'style="width:' . $width . '%;"';
457
+	} elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_contant_section')) {
458
+		$width_css = 'style="width:' . $width . '%;"';
459
+	} elseif ($type == 'search-page' && $width = get_option('geodir_width_search_contant_section')) {
460
+		$width_css = 'style="width:' . $width . '%;"';
461
+	} elseif ($type == 'author-page' && $width = get_option('geodir_width_author_contant_section')) {
462
+		$width_css = 'style="width:' . $width . '%;"';
463
+	} else {
464
+		$width_css = '';
465
+	}
466
+
467
+	$tc = get_option('theme_compatibility_setting');
468
+	if (!empty($tc['geodir_wrapper_content_open_replace'])) {
469
+		$text = $tc['geodir_wrapper_content_open_replace'];
470
+	} else {
471
+		$text = '<div id="[id]" class="[class]" role="main" [width_css]>';
472
+	}
473
+
474
+	if (!empty($tc['geodir_wrapper_content_open_id'])) {
475
+		$id = $tc['geodir_wrapper_content_open_id'];
476
+	}
477
+	if (!empty($tc['geodir_wrapper_content_open_class'])) {
478
+		$class = $tc['geodir_wrapper_content_open_class'];
479
+	}
480
+
481
+	$text = str_replace(array("[id]", "[class]", "[width_css]"), array($id, $class, $width_css), $text);
482
+
483
+	echo $text;
484 484
 }
485 485
 
486 486
 // action for adding the primary div closing tag
@@ -494,13 +494,13 @@  discard block
 block discarded – undo
494 494
  */
495 495
 function geodir_action_wrapper_content_close($type = '')
496 496
 {
497
-    $tc = get_option('theme_compatibility_setting');
498
-    if (!empty($tc['geodir_wrapper_content_close_replace'])) {
499
-        $text = $tc['geodir_wrapper_content_close_replace'];
500
-    } else {
501
-        $text = '</div><!-- content ends here-->';
502
-    }
503
-    echo $text;
497
+	$tc = get_option('theme_compatibility_setting');
498
+	if (!empty($tc['geodir_wrapper_content_close_replace'])) {
499
+		$text = $tc['geodir_wrapper_content_close_replace'];
500
+	} else {
501
+		$text = '</div><!-- content ends here-->';
502
+	}
503
+	echo $text;
504 504
 }
505 505
 
506 506
 // action for adding the <article> opening tag
@@ -518,24 +518,24 @@  discard block
 block discarded – undo
518 518
  */
519 519
 function geodir_action_article_open($type = '', $id = '', $class = '', $itemtype = '')
520 520
 {
521
-    $class = implode(" ", $class);
522
-    $tc = get_option('theme_compatibility_setting');
523
-    if (!empty($tc['geodir_article_open_replace'])) {
524
-        $text = $tc['geodir_article_open_replace'];
525
-    } else {
526
-        $text = '<article  id="[id]" class="[class]" >';
527
-    }
521
+	$class = implode(" ", $class);
522
+	$tc = get_option('theme_compatibility_setting');
523
+	if (!empty($tc['geodir_article_open_replace'])) {
524
+		$text = $tc['geodir_article_open_replace'];
525
+	} else {
526
+		$text = '<article  id="[id]" class="[class]" >';
527
+	}
528 528
 
529
-    if (!empty($tc['geodir_article_open_id'])) {
530
-        $id = $tc['geodir_article_open_id'];
531
-    }
532
-    if (!empty($tc['geodir_article_open_class'])) {
533
-        $class = $tc['geodir_article_open_class'];
534
-    }
529
+	if (!empty($tc['geodir_article_open_id'])) {
530
+		$id = $tc['geodir_article_open_id'];
531
+	}
532
+	if (!empty($tc['geodir_article_open_class'])) {
533
+		$class = $tc['geodir_article_open_class'];
534
+	}
535 535
 
536
-    $text = str_replace(array("[id]", "[class]", "[itemtype]"), array($id, $class, $itemtype), $text);
536
+	$text = str_replace(array("[id]", "[class]", "[itemtype]"), array($id, $class, $itemtype), $text);
537 537
 
538
-    echo $text;
538
+	echo $text;
539 539
 }
540 540
 
541 541
 // action for adding the primary div closing tag
@@ -549,13 +549,13 @@  discard block
 block discarded – undo
549 549
  */
550 550
 function geodir_action_article_close($type = '')
551 551
 {
552
-    $tc = get_option('theme_compatibility_setting');
553
-    if (!empty($tc['geodir_article_close_replace'])) {
554
-        $text = $tc['geodir_article_close_replace'];
555
-    } else {
556
-        $text = '</article><!-- article ends here-->';
557
-    }
558
-    echo $text;
552
+	$tc = get_option('theme_compatibility_setting');
553
+	if (!empty($tc['geodir_article_close_replace'])) {
554
+		$text = $tc['geodir_article_close_replace'];
555
+	} else {
556
+		$text = '</article><!-- article ends here-->';
557
+	}
558
+	echo $text;
559 559
 }
560 560
 
561 561
 // action for adding the sidebar opening tag
@@ -572,35 +572,35 @@  discard block
 block discarded – undo
572 572
  */
573 573
 function geodir_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '')
574 574
 {
575
-    if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
576
-        $width_css = 'style="width:' . $width . '%;"';
577
-    } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
578
-        $width_css = 'style="width:' . $width . '%;"';
579
-    } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
580
-        $width_css = 'style="width:' . $width . '%;"';
581
-    } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
582
-        $width_css = 'style="width:' . $width . '%;"';
583
-    } else {
584
-        $width_css = '';
585
-    }
586
-
587
-    $tc = get_option('theme_compatibility_setting');
588
-    if (!empty($tc['geodir_sidebar_right_open_replace'])) {
589
-        $text = $tc['geodir_sidebar_right_open_replace'];
590
-    } else {
591
-        $text = '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
592
-    }
593
-
594
-    if (!empty($tc['geodir_sidebar_right_open_id'])) {
595
-        $id = $tc['geodir_sidebar_right_open_id'];
596
-    }
597
-    if (!empty($tc['geodir_sidebar_right_open_class'])) {
598
-        $class = $tc['geodir_sidebar_right_open_class'];
599
-    }
600
-
601
-    $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
602
-
603
-    echo $text;
575
+	if ($type == 'home-page' && $width = get_option('geodir_width_home_right_section')) {
576
+		$width_css = 'style="width:' . $width . '%;"';
577
+	} elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_right_section')) {
578
+		$width_css = 'style="width:' . $width . '%;"';
579
+	} elseif ($type == 'search-page' && $width = get_option('geodir_width_search_right_section')) {
580
+		$width_css = 'style="width:' . $width . '%;"';
581
+	} elseif ($type == 'author-page' && $width = get_option('geodir_width_author_right_section')) {
582
+		$width_css = 'style="width:' . $width . '%;"';
583
+	} else {
584
+		$width_css = '';
585
+	}
586
+
587
+	$tc = get_option('theme_compatibility_setting');
588
+	if (!empty($tc['geodir_sidebar_right_open_replace'])) {
589
+		$text = $tc['geodir_sidebar_right_open_replace'];
590
+	} else {
591
+		$text = '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
592
+	}
593
+
594
+	if (!empty($tc['geodir_sidebar_right_open_id'])) {
595
+		$id = $tc['geodir_sidebar_right_open_id'];
596
+	}
597
+	if (!empty($tc['geodir_sidebar_right_open_class'])) {
598
+		$class = $tc['geodir_sidebar_right_open_class'];
599
+	}
600
+
601
+	$text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
602
+
603
+	echo $text;
604 604
 }
605 605
 
606 606
 // action for adding the primary div closing tag
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
  */
615 615
 function geodir_action_sidebar_right_close($type = '')
616 616
 {
617
-    $tc = get_option('theme_compatibility_setting');
618
-    if (!empty($tc['geodir_sidebar_right_close_replace'])) {
619
-        $text = $tc['geodir_sidebar_right_close_replace'];
620
-    } else {
621
-        $text = '</aside><!-- sidebar ends here-->';
622
-    }
623
-    echo $text;
617
+	$tc = get_option('theme_compatibility_setting');
618
+	if (!empty($tc['geodir_sidebar_right_close_replace'])) {
619
+		$text = $tc['geodir_sidebar_right_close_replace'];
620
+	} else {
621
+		$text = '</aside><!-- sidebar ends here-->';
622
+	}
623
+	echo $text;
624 624
 }
625 625
 
626 626
 
@@ -641,121 +641,121 @@  discard block
 block discarded – undo
641 641
  */
642 642
 function geodir_action_geodir_set_preview_post()
643 643
 {
644
-    global $post, $preview, $gd_session;
645
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
646
-    if (!$preview || $is_backend_preview) {
647
-        return;
648
-    }// bail if not previewing
649
-
650
-    $listing_type = isset($_REQUEST['listing_type']) ? sanitize_text_field($_REQUEST['listing_type']) : '';
651
-
652
-    $fields_info = geodir_get_custom_fields_type($listing_type);
653
-
654
-    foreach ($_REQUEST as $pkey => $pval) {
655
-        if ($pkey == 'geodir_video') {
656
-            $tags = '<iframe>';
657
-        } else if ($pkey == 'post_desc') {
658
-            $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
659
-        } else if (is_array($fields_info) && isset($fields_info[$pkey]) && ($fields_info[$pkey] == 'textarea' || $fields_info[$pkey] == 'html')) {
660
-            $tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
661
-        } else if (is_array($_REQUEST[$pkey])) {
662
-            $tags = 'skip_field';
663
-        } else {
664
-            $tags = '';
665
-        }
666
-        /**
667
-         * Allows the filtering of the allowed HTML tags per field when submitting from frontend add listing page.
668
-         *
669
-         * @since 1.0.0
670
-         * @param string $tags The allowed HTML tags for the field. Can be many things, for example the description allows these tags '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'.
671
-         * @param string|array $pkey The field id/name. If array then value is set as "skip_field".
672
-         */
673
-        $tags = apply_filters('geodir_save_post_key', $tags, $pkey);
674
-
675
-        if ($tags != 'skip_field') {
676
-            $_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags);
677
-        }
678
-    }
679
-
680
-    $post = (object)$_REQUEST;
681
-
682
-
683
-    if (isset($post->video)) {
684
-        $post->video = stripslashes($post->video);
685
-    }
686
-
687
-    if (isset($post->Video2)) {
688
-        $post->Video2 = stripslashes($post->Video2);
689
-    }
690
-
691
-    $post_type = $post->listing_type;
692
-    $post_type_info = get_post_type_object($post_type);
693
-
694
-    $listing_label = $post_type_info->labels->singular_name;
695
-
696
-    $term_icon = '';
697
-
698
-    if (!empty($post->post_category)) {
699
-        foreach ($post->post_category as $post_taxonomy => $post_term) {
700
-
701
-            if ($post_term != '' && !is_array($post_term)) {
702
-                $post_term = explode(',', trim($post_term, ','));
703
-            }
644
+	global $post, $preview, $gd_session;
645
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
646
+	if (!$preview || $is_backend_preview) {
647
+		return;
648
+	}// bail if not previewing
649
+
650
+	$listing_type = isset($_REQUEST['listing_type']) ? sanitize_text_field($_REQUEST['listing_type']) : '';
651
+
652
+	$fields_info = geodir_get_custom_fields_type($listing_type);
653
+
654
+	foreach ($_REQUEST as $pkey => $pval) {
655
+		if ($pkey == 'geodir_video') {
656
+			$tags = '<iframe>';
657
+		} else if ($pkey == 'post_desc') {
658
+			$tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
659
+		} else if (is_array($fields_info) && isset($fields_info[$pkey]) && ($fields_info[$pkey] == 'textarea' || $fields_info[$pkey] == 'html')) {
660
+			$tags = '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>';
661
+		} else if (is_array($_REQUEST[$pkey])) {
662
+			$tags = 'skip_field';
663
+		} else {
664
+			$tags = '';
665
+		}
666
+		/**
667
+		 * Allows the filtering of the allowed HTML tags per field when submitting from frontend add listing page.
668
+		 *
669
+		 * @since 1.0.0
670
+		 * @param string $tags The allowed HTML tags for the field. Can be many things, for example the description allows these tags '<p><a><b><i><em><h1><h2><h3><h4><h5><ul><ol><li><img><div><del><ins><span><cite><code><strike><strong><blockquote>'.
671
+		 * @param string|array $pkey The field id/name. If array then value is set as "skip_field".
672
+		 */
673
+		$tags = apply_filters('geodir_save_post_key', $tags, $pkey);
674
+
675
+		if ($tags != 'skip_field') {
676
+			$_REQUEST[$pkey] = strip_tags($_REQUEST[$pkey], $tags);
677
+		}
678
+	}
679
+
680
+	$post = (object)$_REQUEST;
681
+
682
+
683
+	if (isset($post->video)) {
684
+		$post->video = stripslashes($post->video);
685
+	}
686
+
687
+	if (isset($post->Video2)) {
688
+		$post->Video2 = stripslashes($post->Video2);
689
+	}
690
+
691
+	$post_type = $post->listing_type;
692
+	$post_type_info = get_post_type_object($post_type);
693
+
694
+	$listing_label = $post_type_info->labels->singular_name;
695
+
696
+	$term_icon = '';
697
+
698
+	if (!empty($post->post_category)) {
699
+		foreach ($post->post_category as $post_taxonomy => $post_term) {
700
+
701
+			if ($post_term != '' && !is_array($post_term)) {
702
+				$post_term = explode(',', trim($post_term, ','));
703
+			}
704 704
 
705
-            if (is_array($post_term)) {
706
-                $post_term = array_unique($post_term);
707
-            }
705
+			if (is_array($post_term)) {
706
+				$post_term = array_unique($post_term);
707
+			}
708 708
 
709
-            if (!empty($post_term)) {
710
-                foreach ($post_term as $cat_id) {
711
-                    $cat_id = trim($cat_id);
712
-
713
-                    if ($cat_id != '') {
714
-                        $term_icon = get_option('geodir_default_marker_icon');
715
-
716
-                        if (isset($post->post_default_category) && $post->post_default_category == $cat_id) {
717
-                            if ($term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type)) {
718
-                                if (isset($term_icon_url['src']) && $term_icon_url['src'] != '')
719
-                                    $term_icon = $term_icon_url['src'];
720
-                                break;
721
-                            }
722
-                        }
723
-                    }
724
-                }
725
-            }
726
-        }
727
-    }
709
+			if (!empty($post_term)) {
710
+				foreach ($post_term as $cat_id) {
711
+					$cat_id = trim($cat_id);
712
+
713
+					if ($cat_id != '') {
714
+						$term_icon = get_option('geodir_default_marker_icon');
715
+
716
+						if (isset($post->post_default_category) && $post->post_default_category == $cat_id) {
717
+							if ($term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type)) {
718
+								if (isset($term_icon_url['src']) && $term_icon_url['src'] != '')
719
+									$term_icon = $term_icon_url['src'];
720
+								break;
721
+							}
722
+						}
723
+					}
724
+				}
725
+			}
726
+		}
727
+	}
728 728
 
729
-    $post_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
730
-    $post_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
729
+	$post_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
730
+	$post_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
731 731
 
732
-    $srcharr = array("'", "/", "-", '"', '\\');
733
-    $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
732
+	$srcharr = array("'", "/", "-", '"', '\\');
733
+	$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
734 734
 
735
-    $json_title = str_replace($srcharr, $replarr, $post->post_title);
735
+	$json_title = str_replace($srcharr, $replarr, $post->post_title);
736 736
 
737
-    $json = '{';
738
-    $json .= '"post_preview": "1",';
739
-    $json .= '"t": "' . $json_title . '",';
740
-    $json .= '"lt": "' . $post_latitude . '",';
741
-    $json .= '"ln": "' . $post_longitude . '",';
742
-    $json .= '"i":"' . $term_icon . '"';
743
-    $json .= '}';
737
+	$json = '{';
738
+	$json .= '"post_preview": "1",';
739
+	$json .= '"t": "' . $json_title . '",';
740
+	$json .= '"lt": "' . $post_latitude . '",';
741
+	$json .= '"ln": "' . $post_longitude . '",';
742
+	$json .= '"i":"' . $term_icon . '"';
743
+	$json .= '}';
744 744
 
745
-    $post->marker_json = $json;
745
+	$post->marker_json = $json;
746 746
 
747
-    $gd_session->set('listing', $_REQUEST);
747
+	$gd_session->set('listing', $_REQUEST);
748 748
 
749
-    // we need to define a few things to trick the setup_postdata
750
-    if (!isset($post->ID)) {
751
-        $post->ID = '';
752
-        $post->post_author = '';
753
-        $post->post_date = '';
754
-        $post->post_content = '';
755
-        $post->default_category = '';
756
-        $post->post_type = '';
757
-    }
758
-    setup_postdata($post);
749
+	// we need to define a few things to trick the setup_postdata
750
+	if (!isset($post->ID)) {
751
+		$post->ID = '';
752
+		$post->post_author = '';
753
+		$post->post_date = '';
754
+		$post->post_content = '';
755
+		$post->default_category = '';
756
+		$post->post_type = '';
757
+	}
758
+	setup_postdata($post);
759 759
 }
760 760
 
761 761
 /**
@@ -767,15 +767,15 @@  discard block
 block discarded – undo
767 767
  */
768 768
 function geodir_action_geodir_preview_code()
769 769
 {
770
-    global $preview;
770
+	global $preview;
771 771
 
772
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
772
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
773 773
 
774
-    if (!$preview || $is_backend_preview) {
775
-        return;
776
-    }// bail if not previewing
774
+	if (!$preview || $is_backend_preview) {
775
+		return;
776
+	}// bail if not previewing
777 777
 
778
-    geodir_get_template_part('preview', 'buttons');
778
+	geodir_get_template_part('preview', 'buttons');
779 779
 }
780 780
 
781 781
 // action for adding the details page top widget area
@@ -791,20 +791,20 @@  discard block
 block discarded – undo
791 791
  */
792 792
 function geodir_action_geodir_sidebar_detail_top($class = '')
793 793
 {
794
-    if (get_option('geodir_show_detail_top_section')) { ?>
794
+	if (get_option('geodir_show_detail_top_section')) { ?>
795 795
         <div
796 796
             class="<?php
797
-            /**
798
-             * Filter the div class for the wrapper of the full width widget areas.
799
-             *
800
-             * Allows you to filter the class of the div for the HTML Container wrapper for the full width widget areas referred to as "Top Section" or "Bottom Section" in the widget areas.
801
-             *
802
-             * @since 1.0.0
803
-             * @param string $class The class of the div.
804
-             * @param string $type The page type the widget area is being used on. Values can be 'geodir_detail_top', 'geodir_detail_bottom', 'geodir_listing_top', 'geodir_listing_bottom', 'Reg/Login Top Section',
805
-             *               'geodir_author_top','geodir_author_bottom', 'geodir_search_top', 'geodir_search_bottom', 'geodir_home_top' or 'geodir_home_bottom'.
806
-             */
807
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_top'); ?> <?php echo $class; ?>">
797
+			/**
798
+			 * Filter the div class for the wrapper of the full width widget areas.
799
+			 *
800
+			 * Allows you to filter the class of the div for the HTML Container wrapper for the full width widget areas referred to as "Top Section" or "Bottom Section" in the widget areas.
801
+			 *
802
+			 * @since 1.0.0
803
+			 * @param string $class The class of the div.
804
+			 * @param string $type The page type the widget area is being used on. Values can be 'geodir_detail_top', 'geodir_detail_bottom', 'geodir_listing_top', 'geodir_listing_bottom', 'Reg/Login Top Section',
805
+			 *               'geodir_author_top','geodir_author_bottom', 'geodir_search_top', 'geodir_search_bottom', 'geodir_home_top' or 'geodir_home_bottom'.
806
+			 */
807
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_top'); ?> <?php echo $class; ?>">
808 808
             <?php dynamic_sidebar('geodir_detail_top'); ?>
809 809
         </div>
810 810
     <?php }
@@ -828,11 +828,11 @@  discard block
 block discarded – undo
828 828
  */
829 829
 function geodir_action_geodir_sidebar_detail_bottom_section($class = '')
830 830
 {
831
-    if (get_option('geodir_show_detail_bottom_section')) { ?>
831
+	if (get_option('geodir_show_detail_bottom_section')) { ?>
832 832
         <div
833 833
             class="<?php
834
-            /** This action is documented in geodirectory_template_actions.php */
835
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_bottom'); ?> <?php echo $class; ?>">
834
+			/** This action is documented in geodirectory_template_actions.php */
835
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_detail_bottom'); ?> <?php echo $class; ?>">
836 836
             <?php dynamic_sidebar('geodir_detail_bottom'); ?>
837 837
         </div><!-- clearfix ends here-->
838 838
     <?php }
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
  */
847 847
 function geodir_details_sidebar_widget_area()
848 848
 {
849
-    dynamic_sidebar('geodir_detail_sidebar');
849
+	dynamic_sidebar('geodir_detail_sidebar');
850 850
 }
851 851
 
852 852
 /**
@@ -857,12 +857,12 @@  discard block
 block discarded – undo
857 857
  */
858 858
 function geodir_details_sidebar_place_details()
859 859
 {
860
-    /**
861
-     * Used to add items to the details page sidebar.
862
-     *
863
-     * @since 1.0.0
864
-     */
865
-    do_action('geodir_detail_page_sidebar');
860
+	/**
861
+	 * Used to add items to the details page sidebar.
862
+	 *
863
+	 * @since 1.0.0
864
+	 */
865
+	do_action('geodir_detail_page_sidebar');
866 866
 }
867 867
 
868 868
 add_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_place_details', 10);
@@ -877,68 +877,68 @@  discard block
 block discarded – undo
877 877
  */
878 878
 function geodir_action_details_sidebar()
879 879
 {
880
-    // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
881
-    if (get_option('geodir_detail_sidebar_left_section')) {
882
-        /**
883
-         * Called before the details page left sidebar is opened.
884
-         *
885
-         * This is used to add opening wrapper HTML to the details page left sidebar.
886
-         *
887
-         * @since 1.0.0
888
-         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
889
-         * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-left'.
890
-         * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-left geodir-details-sidebar-left'.
891
-         * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
892
-         */
893
-        do_action('geodir_sidebar_left_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-left geodir-details-sidebar-left', 'https://schema.org/WPSideBar');
894
-        ?>
880
+	// this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
881
+	if (get_option('geodir_detail_sidebar_left_section')) {
882
+		/**
883
+		 * Called before the details page left sidebar is opened.
884
+		 *
885
+		 * This is used to add opening wrapper HTML to the details page left sidebar.
886
+		 *
887
+		 * @since 1.0.0
888
+		 * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
889
+		 * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-left'.
890
+		 * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-left geodir-details-sidebar-left'.
891
+		 * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
892
+		 */
893
+		do_action('geodir_sidebar_left_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-left geodir-details-sidebar-left', 'https://schema.org/WPSideBar');
894
+		?>
895 895
         <div class="geodir-content-left geodir-sidebar-wrap"><?php
896
-        /**
897
-         * Called inside the HTML wrapper of the details sidebar for either the left and right sidebar.
898
-         *
899
-         * This is used to add all info to the details page sidebars.
900
-         *
901
-         * @since 1.0.0
902
-         */
903
-        do_action('geodir_detail_sidebar_inside');
904
-        ?></div><!-- end geodir-content-left --><?php
905
-        /**
906
-         * Called after the details page left sidebar.
907
-         *
908
-         * This is used to add closing wrapper HTML to the details page left sidebar.
909
-         *
910
-         * @since 1.0.0
911
-         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
912
-         */
913
-        do_action('geodir_sidebar_left_close', 'details-page');
914
-    } else {
915
-        /**
916
-         * Called before the details page right sidebar is opened.
917
-         *
918
-         * This is used to add opening wrapper HTML to the details page right sidebar.
919
-         *
920
-         * @since 1.0.0
921
-         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'add-listing-page', 'author-page', 'search-page' or 'home-page'.
922
-         * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-right'.
923
-         * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-right geodir-details-sidebar-right'.
924
-         * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
925
-         */
926
-        do_action('geodir_sidebar_right_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-right geodir-details-sidebar-right', 'http://schema.org/WPSideBar');
927
-        ?>
896
+		/**
897
+		 * Called inside the HTML wrapper of the details sidebar for either the left and right sidebar.
898
+		 *
899
+		 * This is used to add all info to the details page sidebars.
900
+		 *
901
+		 * @since 1.0.0
902
+		 */
903
+		do_action('geodir_detail_sidebar_inside');
904
+		?></div><!-- end geodir-content-left --><?php
905
+		/**
906
+		 * Called after the details page left sidebar.
907
+		 *
908
+		 * This is used to add closing wrapper HTML to the details page left sidebar.
909
+		 *
910
+		 * @since 1.0.0
911
+		 * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
912
+		 */
913
+		do_action('geodir_sidebar_left_close', 'details-page');
914
+	} else {
915
+		/**
916
+		 * Called before the details page right sidebar is opened.
917
+		 *
918
+		 * This is used to add opening wrapper HTML to the details page right sidebar.
919
+		 *
920
+		 * @since 1.0.0
921
+		 * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'add-listing-page', 'author-page', 'search-page' or 'home-page'.
922
+		 * @param string $id Usually the ID of the sidebar wrapper. Values can be 'geodir-sidebar' or 'geodir-sidebar-right'.
923
+		 * @param string $class The class of the sidebar wrapper. 'geodir-sidebar-right geodir-details-sidebar-right'.
924
+		 * @param string $itemtype HTML itemtype 'http://schema.org/WPSideBar'.
925
+		 */
926
+		do_action('geodir_sidebar_right_open', 'details-page', 'geodir-sidebar', 'geodir-sidebar-right geodir-details-sidebar-right', 'http://schema.org/WPSideBar');
927
+		?>
928 928
         <div class="geodir-content-right geodir-sidebar-wrap"><?php
929
-        /** This action is documented in geodirectory_template_actions.php */
930
-        do_action('geodir_detail_sidebar_inside');
931
-        ?></div><!-- end geodir-content-right --><?php
932
-        /**
933
-         * Called after the details page right sidebar.
934
-         *
935
-         * This is used to add closing wrapper HTML to the details page right sidebar.
936
-         *
937
-         * @since 1.0.0
938
-         * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
939
-         */
940
-        do_action('geodir_sidebar_right_close', 'details-page');
941
-    }
929
+		/** This action is documented in geodirectory_template_actions.php */
930
+		do_action('geodir_detail_sidebar_inside');
931
+		?></div><!-- end geodir-content-right --><?php
932
+		/**
933
+		 * Called after the details page right sidebar.
934
+		 *
935
+		 * This is used to add closing wrapper HTML to the details page right sidebar.
936
+		 *
937
+		 * @since 1.0.0
938
+		 * @param string $type The current page type. Values can be 'details-page', 'listings-page', 'author-page', 'search-page' or 'home-page'.
939
+		 */
940
+		do_action('geodir_sidebar_right_close', 'details-page');
941
+	}
942 942
 }
943 943
 
944 944
 add_action('geodir_page_title', 'geodir_action_page_title', 10);
@@ -952,21 +952,21 @@  discard block
 block discarded – undo
952 952
  */
953 953
 function geodir_action_page_title()
954 954
 {
955
-    /**
956
-     * Filter the page title HTML h1 class.
957
-     *
958
-     * @since 1.0.0
959
-     * @param string $class The class to use. Default is 'entry-title fn'.
960
-     */
961
-    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
962
-    /**
963
-     * Filter the page title HTML header wrapper class.
964
-     *
965
-     * @since 1.0.0
966
-     * @param string $class The class to use. Default is 'entry-header'.
967
-     */
968
-    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
969
-    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>';
955
+	/**
956
+	 * Filter the page title HTML h1 class.
957
+	 *
958
+	 * @since 1.0.0
959
+	 * @param string $class The class to use. Default is 'entry-title fn'.
960
+	 */
961
+	$class = apply_filters('geodir_page_title_class', 'entry-title fn');
962
+	/**
963
+	 * Filter the page title HTML header wrapper class.
964
+	 *
965
+	 * @since 1.0.0
966
+	 * @param string $class The class to use. Default is 'entry-header'.
967
+	 */
968
+	$class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
969
+	echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' . stripslashes(get_the_title()) . '</h1></header>';
970 970
 }
971 971
 
972 972
 
@@ -983,94 +983,94 @@  discard block
 block discarded – undo
983 983
  */
984 984
 function geodir_action_details_slider()
985 985
 {
986
-    global $preview, $post;
986
+	global $preview, $post;
987 987
 
988
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // preview from backend
988
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // preview from backend
989 989
 
990
-    if ($is_backend_preview && !empty($post) && !empty($post->ID) && !isset($post->post_images)) {
991
-        $preview_get_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
990
+	if ($is_backend_preview && !empty($post) && !empty($post->ID) && !isset($post->post_images)) {
991
+		$preview_get_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
992 992
 
993
-        $preview_post_images = array();
994
-        if ($preview_get_images) {
995
-            foreach ($preview_get_images as $row) {
996
-                $preview_post_images[] = $row->src;
997
-            }
998
-        }
999
-        if (!empty($preview_post_images)) {
1000
-            $post->post_images = implode(',', $preview_post_images);
1001
-        }
1002
-    }
1003
-
1004
-    if ($preview) {
1005
-        $post_images = array();
1006
-        if (isset($post->post_images) && !empty($post->post_images)) {
1007
-            $post->post_images = trim($post->post_images, ",");
1008
-            $post_images = explode(",", $post->post_images);
1009
-        }
1010
-
1011
-        $main_slides = '';
1012
-        $nav_slides = '';
1013
-        $slides = 0;
1014
-
1015
-        if (!empty($post_images)) {
1016
-            foreach ($post_images as $image) {
1017
-                if (!empty($image)) {
1018
-                    $sizes = getimagesize(trim($image));
1019
-                    $width = !empty($sizes) && isset($sizes[0]) ? $sizes[0] : 0;
1020
-                    $height = !empty($sizes) && isset($sizes[1]) ? $sizes[1] : 0;
1021
-
1022
-                    if ($image && $width && $height) {
1023
-                        $image = (object)array('src' => $image, 'width' => $width, 'height' => $height);
1024
-                    }
1025
-
1026
-                    if (isset($image->src)) {
1027
-                        if ($image->height >= 400) {
1028
-                            $spacer_height = 0;
1029
-                        } else {
1030
-                            $spacer_height = ((400 - $image->height) / 2);
1031
-                        }
1032
-
1033
-                        $image_title = isset($image->title) ? $image->title : '';
1034
-
1035
-                        $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />';
1036
-                        $main_slides .= '<img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:400px;margin:0 auto;" /></li>';
1037
-                        $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:48px;margin:0 auto;" /></li>';
1038
-                        $slides++;
1039
-                    }
1040
-                }
1041
-            }// endfore
1042
-        } //end if
1043
-    } else {
1044
-        $main_slides = '';
1045
-        $nav_slides = '';
1046
-        /**
1047
-         * Filter if default images should show on the details page.
1048
-         *
1049
-         * @param bool $use_default_image Default false.
1050
-         * @since 1.6.16
1051
-         */
1052
-        $use_default_image = apply_filters('geodir_details_default_image_show', false);
1053
-        $post_images = geodir_get_images($post->ID, 'thumbnail', $use_default_image); // Hide default image on listing preview/detail page.
1054
-        $slides = 0;
1055
-
1056
-        if (!empty($post_images)) {
1057
-            foreach ($post_images as $image) {
1058
-                if ($image->height >= 400) {
1059
-                    $spacer_height = 0;
1060
-                } else {
1061
-                    $spacer_height = ((400 - $image->height) / 2);
1062
-                }
1063
-                $caption = '';//(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : '';
1064
-                $main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />';
1065
-                $main_slides .= '<img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>';
1066
-                $nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
1067
-                $slides++;
1068
-            }
1069
-        }// endfore
1070
-    }
993
+		$preview_post_images = array();
994
+		if ($preview_get_images) {
995
+			foreach ($preview_get_images as $row) {
996
+				$preview_post_images[] = $row->src;
997
+			}
998
+		}
999
+		if (!empty($preview_post_images)) {
1000
+			$post->post_images = implode(',', $preview_post_images);
1001
+		}
1002
+	}
1003
+
1004
+	if ($preview) {
1005
+		$post_images = array();
1006
+		if (isset($post->post_images) && !empty($post->post_images)) {
1007
+			$post->post_images = trim($post->post_images, ",");
1008
+			$post_images = explode(",", $post->post_images);
1009
+		}
1010
+
1011
+		$main_slides = '';
1012
+		$nav_slides = '';
1013
+		$slides = 0;
1014
+
1015
+		if (!empty($post_images)) {
1016
+			foreach ($post_images as $image) {
1017
+				if (!empty($image)) {
1018
+					$sizes = getimagesize(trim($image));
1019
+					$width = !empty($sizes) && isset($sizes[0]) ? $sizes[0] : 0;
1020
+					$height = !empty($sizes) && isset($sizes[1]) ? $sizes[1] : 0;
1021
+
1022
+					if ($image && $width && $height) {
1023
+						$image = (object)array('src' => $image, 'width' => $width, 'height' => $height);
1024
+					}
1025
+
1026
+					if (isset($image->src)) {
1027
+						if ($image->height >= 400) {
1028
+							$spacer_height = 0;
1029
+						} else {
1030
+							$spacer_height = ((400 - $image->height) / 2);
1031
+						}
1032
+
1033
+						$image_title = isset($image->title) ? $image->title : '';
1034
+
1035
+						$main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />';
1036
+						$main_slides .= '<img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:400px;margin:0 auto;" /></li>';
1037
+						$nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image_title . '" title="' . $image_title . '" style="max-height:48px;margin:0 auto;" /></li>';
1038
+						$slides++;
1039
+					}
1040
+				}
1041
+			}// endfore
1042
+		} //end if
1043
+	} else {
1044
+		$main_slides = '';
1045
+		$nav_slides = '';
1046
+		/**
1047
+		 * Filter if default images should show on the details page.
1048
+		 *
1049
+		 * @param bool $use_default_image Default false.
1050
+		 * @since 1.6.16
1051
+		 */
1052
+		$use_default_image = apply_filters('geodir_details_default_image_show', false);
1053
+		$post_images = geodir_get_images($post->ID, 'thumbnail', $use_default_image); // Hide default image on listing preview/detail page.
1054
+		$slides = 0;
1055
+
1056
+		if (!empty($post_images)) {
1057
+			foreach ($post_images as $image) {
1058
+				if ($image->height >= 400) {
1059
+					$spacer_height = 0;
1060
+				} else {
1061
+					$spacer_height = ((400 - $image->height) / 2);
1062
+				}
1063
+				$caption = '';//(!empty($image->caption)) ? '<p class="flex-caption">'.$image->caption.'</p>' : '';
1064
+				$main_slides .= '<li><img src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:' . $spacer_height . 'px;margin:0 auto;" />';
1065
+				$main_slides .= '<img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:400px;margin:0 auto;" />'.$caption.'</li>';
1066
+				$nav_slides .= '<li><img src="' . $image->src . '" alt="' . $image->title . '" title="' . $image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
1067
+				$slides++;
1068
+			}
1069
+		}// endfore
1070
+	}
1071 1071
 
1072
-    if (!empty($post_images)) {
1073
-        ?>
1072
+	if (!empty($post_images)) {
1073
+		?>
1074 1074
         <div class="geodir_flex-container">
1075 1075
             <div class="geodir_flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
1076 1076
             <div id="geodir_slider" class="geodir_flexslider ">
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
             <?php } ?>
1084 1084
         </div>
1085 1085
     <?php
1086
-    }
1086
+	}
1087 1087
 }
1088 1088
 
1089 1089
 add_action('geodir_details_taxonomies', 'geodir_action_details_taxonomies', 10);
@@ -1098,177 +1098,177 @@  discard block
 block discarded – undo
1098 1098
  */
1099 1099
 function geodir_action_details_taxonomies()
1100 1100
 {
1101
-    global $preview, $post;?>
1101
+	global $preview, $post;?>
1102 1102
     <p class="geodir_post_taxomomies clearfix">
1103 1103
     <?php
1104
-    $taxonomies = array();
1105
-
1106
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1107
-
1108
-    if ($preview && !$is_backend_preview) {
1109
-        $post_type = $post->listing_type;
1110
-        $post_taxonomy = $post_type . 'category';
1111
-        $post->{$post_taxonomy} = $post->post_category[$post_taxonomy];
1112
-    } else {
1113
-        $post_type = $post->post_type;
1114
-        $post_taxonomy = $post_type . 'category';
1115
-    }
1104
+	$taxonomies = array();
1105
+
1106
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1107
+
1108
+	if ($preview && !$is_backend_preview) {
1109
+		$post_type = $post->listing_type;
1110
+		$post_taxonomy = $post_type . 'category';
1111
+		$post->{$post_taxonomy} = $post->post_category[$post_taxonomy];
1112
+	} else {
1113
+		$post_type = $post->post_type;
1114
+		$post_taxonomy = $post_type . 'category';
1115
+	}
1116 1116
 //{	
1117
-    $post_type_info = get_post_type_object($post_type);
1118
-    $listing_label = __($post_type_info->labels->singular_name, 'geodirectory');
1119
-
1120
-    if (!empty($post->post_tags)) {
1121
-
1122
-        if (taxonomy_exists($post_type . '_tags')):
1123
-            $links = array();
1124
-            $terms = array();
1125
-            // to limit post tags
1126
-            $post_tags = trim($post->post_tags, ",");
1127
-            $post_id = isset($post->ID) ? $post->ID : '';
1128
-            /**
1129
-             * Filter the post tags.
1130
-             *
1131
-             * Allows you to filter the post tags output on the details page of a post.
1132
-             *
1133
-             * @since 1.0.0
1134
-             * @param string $post_tags A comma seperated list of tags.
1135
-             * @param int $post_id The current post id.
1136
-             */
1137
-            $post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
1138
-
1139
-            $post->post_tags = $post_tags;
1140
-            $post_tags = explode(",", trim($post->post_tags, ","));
1141
-
1142
-
1143
-            foreach ($post_tags as $post_term) {
1144
-
1145
-                // fix slug creation order for tags & location
1146
-                $post_term = trim($post_term);
1147
-
1148
-                $priority_location = false;
1149
-                if ($insert_term = term_exists($post_term, $post_type . '_tags')) {
1150
-                    $term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags');
1151
-                } else {
1152
-                    $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL;
1153
-                    $post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL;
1154
-                    $post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city'] != '' ? sanitize_text_field($_REQUEST['post_city']) : NULL;
1155
-                    $match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false;
1156
-                    $match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false;
1157
-                    $match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false;
1158
-                    if ($match_country || $match_region || $match_city) {
1159
-                        $priority_location = true;
1160
-                        $term = get_term_by('name', $post_term, $post_type . '_tags');
1161
-                    } else {
1162
-                        $insert_term = wp_insert_term($post_term, $post_type . '_tags');
1163
-                        $term = get_term_by('name', $post_term, $post_type . '_tags');
1164
-                    }
1165
-                }
1166
-
1167
-                if (!is_wp_error($term) && is_object($term)) {
1168
-
1169
-                    // fix tag link on detail page
1170
-                    if ($priority_location) {
1171
-
1172
-                        $tag_link = "<a href=''>$post_term</a>";
1173
-                        /**
1174
-                         * Filter the tag name on the details page.
1175
-                         *
1176
-                         * @since 1.5.6
1177
-                         * @param string $tag_link The tag link html.
1178
-                         * @param object $term The tag term object.
1179
-                         */
1180
-                        $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
1181
-                        $links[] = $tag_link;
1182
-                    } else {
1183
-                        $tag_link = "<a href='" . esc_attr(get_term_link($term->term_id, $term->taxonomy)) . "'>$term->name</a>";
1184
-                        /** This action is documented in geodirectory-template_actions.php */
1185
-                        $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
1186
-                        $links[] = $tag_link;
1187
-                    }
1188
-                    $terms[] = $term;
1189
-                }
1190
-                //
1191
-            }
1192
-            if (!isset($listing_label)) {
1193
-                $listing_label = '';
1194
-            }
1195
-            $taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
1196
-        endif;
1197
-
1198
-    }
1199
-
1200
-    if (!empty($post->{$post_taxonomy})) {
1201
-        $links = array();
1202
-        $terms = array();
1203
-        $termsOrdered = array();
1204
-        if (!is_array($post->{$post_taxonomy})) {
1205
-            $post_term = explode(",", trim($post->{$post_taxonomy}, ","));
1206
-        } else {
1207
-            $post_term = $post->{$post_taxonomy};
1117
+	$post_type_info = get_post_type_object($post_type);
1118
+	$listing_label = __($post_type_info->labels->singular_name, 'geodirectory');
1119
+
1120
+	if (!empty($post->post_tags)) {
1121
+
1122
+		if (taxonomy_exists($post_type . '_tags')):
1123
+			$links = array();
1124
+			$terms = array();
1125
+			// to limit post tags
1126
+			$post_tags = trim($post->post_tags, ",");
1127
+			$post_id = isset($post->ID) ? $post->ID : '';
1128
+			/**
1129
+			 * Filter the post tags.
1130
+			 *
1131
+			 * Allows you to filter the post tags output on the details page of a post.
1132
+			 *
1133
+			 * @since 1.0.0
1134
+			 * @param string $post_tags A comma seperated list of tags.
1135
+			 * @param int $post_id The current post id.
1136
+			 */
1137
+			$post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id);
1138
+
1139
+			$post->post_tags = $post_tags;
1140
+			$post_tags = explode(",", trim($post->post_tags, ","));
1141
+
1142
+
1143
+			foreach ($post_tags as $post_term) {
1144
+
1145
+				// fix slug creation order for tags & location
1146
+				$post_term = trim($post_term);
1147
+
1148
+				$priority_location = false;
1149
+				if ($insert_term = term_exists($post_term, $post_type . '_tags')) {
1150
+					$term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags');
1151
+				} else {
1152
+					$post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL;
1153
+					$post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL;
1154
+					$post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city'] != '' ? sanitize_text_field($_REQUEST['post_city']) : NULL;
1155
+					$match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false;
1156
+					$match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false;
1157
+					$match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false;
1158
+					if ($match_country || $match_region || $match_city) {
1159
+						$priority_location = true;
1160
+						$term = get_term_by('name', $post_term, $post_type . '_tags');
1161
+					} else {
1162
+						$insert_term = wp_insert_term($post_term, $post_type . '_tags');
1163
+						$term = get_term_by('name', $post_term, $post_type . '_tags');
1164
+					}
1165
+				}
1166
+
1167
+				if (!is_wp_error($term) && is_object($term)) {
1168
+
1169
+					// fix tag link on detail page
1170
+					if ($priority_location) {
1171
+
1172
+						$tag_link = "<a href=''>$post_term</a>";
1173
+						/**
1174
+						 * Filter the tag name on the details page.
1175
+						 *
1176
+						 * @since 1.5.6
1177
+						 * @param string $tag_link The tag link html.
1178
+						 * @param object $term The tag term object.
1179
+						 */
1180
+						$tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
1181
+						$links[] = $tag_link;
1182
+					} else {
1183
+						$tag_link = "<a href='" . esc_attr(get_term_link($term->term_id, $term->taxonomy)) . "'>$term->name</a>";
1184
+						/** This action is documented in geodirectory-template_actions.php */
1185
+						$tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term);
1186
+						$links[] = $tag_link;
1187
+					}
1188
+					$terms[] = $term;
1189
+				}
1190
+				//
1191
+			}
1192
+			if (!isset($listing_label)) {
1193
+				$listing_label = '';
1194
+			}
1195
+			$taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
1196
+		endif;
1197
+
1198
+	}
1199
+
1200
+	if (!empty($post->{$post_taxonomy})) {
1201
+		$links = array();
1202
+		$terms = array();
1203
+		$termsOrdered = array();
1204
+		if (!is_array($post->{$post_taxonomy})) {
1205
+			$post_term = explode(",", trim($post->{$post_taxonomy}, ","));
1206
+		} else {
1207
+			$post_term = $post->{$post_taxonomy};
1208 1208
 			
1209 1209
 			if ($preview && !$is_backend_preview) {
1210 1210
 				$post_term = geodir_add_parent_terms($post_term, $post_taxonomy);
1211 1211
 			}
1212
-        }
1213
-
1214
-        $post_term = array_unique($post_term);
1215
-        if (!empty($post_term)) {
1216
-            foreach ($post_term as $post_term) {
1217
-                $post_term = trim($post_term);
1218
-
1219
-                if ($post_term != ''):
1220
-                    $term = get_term_by('id', $post_term, $post_taxonomy);
1221
-
1222
-                    if (is_object($term)) {
1223
-                        $term_link = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>$term->name</a>";
1224
-                        /**
1225
-                         * Filter the category name on the details page.
1226
-                         *
1227
-                         * @since 1.5.6
1228
-                         * @param string $term_link The link html to the category.
1229
-                         * @param object $term The category term object.
1230
-                         */
1231
-                        $term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term);
1232
-                        $links[] = $term_link;
1233
-                        $terms[] = $term;
1234
-                    }
1235
-                endif;
1236
-            }
1237
-            // order alphabetically
1238
-            asort($links);
1239
-            foreach (array_keys($links) as $key) {
1240
-                $termsOrdered[$key] = $terms[$key];
1241
-            }
1242
-            $terms = $termsOrdered;
1212
+		}
1213
+
1214
+		$post_term = array_unique($post_term);
1215
+		if (!empty($post_term)) {
1216
+			foreach ($post_term as $post_term) {
1217
+				$post_term = trim($post_term);
1218
+
1219
+				if ($post_term != ''):
1220
+					$term = get_term_by('id', $post_term, $post_taxonomy);
1221
+
1222
+					if (is_object($term)) {
1223
+						$term_link = "<a href='" . esc_attr(get_term_link($term, $post_taxonomy)) . "'>$term->name</a>";
1224
+						/**
1225
+						 * Filter the category name on the details page.
1226
+						 *
1227
+						 * @since 1.5.6
1228
+						 * @param string $term_link The link html to the category.
1229
+						 * @param object $term The category term object.
1230
+						 */
1231
+						$term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term);
1232
+						$links[] = $term_link;
1233
+						$terms[] = $term;
1234
+					}
1235
+				endif;
1236
+			}
1237
+			// order alphabetically
1238
+			asort($links);
1239
+			foreach (array_keys($links) as $key) {
1240
+				$termsOrdered[$key] = $terms[$key];
1241
+			}
1242
+			$terms = $termsOrdered;
1243 1243
 
1244
-        }
1244
+		}
1245 1245
 
1246
-        if (!isset($listing_label)) {
1247
-            $listing_label = '';
1248
-        }
1249
-        $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
1246
+		if (!isset($listing_label)) {
1247
+			$listing_label = '';
1248
+		}
1249
+		$taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms);
1250 1250
 
1251
-    }
1251
+	}
1252 1252
 
1253
-    /**
1254
-     * Filter the taxonomies array before output.
1255
-     *
1256
-     * @since 1.5.9
1257
-     * @param array $taxonomies The array of cats and tags.
1258
-     * @param string $post_type The post type being output.
1259
-     * @param string $listing_label The post type label.
1260
-     * @param string $listing_label The post type label with ucwords function.
1261
-     */
1262
-    $taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label));
1253
+	/**
1254
+	 * Filter the taxonomies array before output.
1255
+	 *
1256
+	 * @since 1.5.9
1257
+	 * @param array $taxonomies The array of cats and tags.
1258
+	 * @param string $post_type The post type being output.
1259
+	 * @param string $listing_label The post type label.
1260
+	 * @param string $listing_label The post type label with ucwords function.
1261
+	 */
1262
+	$taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label));
1263 1263
 
1264
-    if (isset($taxonomies[$post_taxonomy])) {
1265
-        echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>';
1266
-    }
1264
+	if (isset($taxonomies[$post_taxonomy])) {
1265
+		echo '<span class="geodir-category">' . $taxonomies[$post_taxonomy] . '</span>';
1266
+	}
1267 1267
 
1268
-    if (isset($taxonomies[$post_type . '_tags']))
1269
-        echo '<span class="geodir-tags">' . $taxonomies[$post_type . '_tags'] . '</span>';
1268
+	if (isset($taxonomies[$post_type . '_tags']))
1269
+		echo '<span class="geodir-tags">' . $taxonomies[$post_type . '_tags'] . '</span>';
1270 1270
 
1271
-    ?>
1271
+	?>
1272 1272
     </p><?php
1273 1273
 }
1274 1274
 
@@ -1290,140 +1290,140 @@  discard block
 block discarded – undo
1290 1290
 function geodir_action_details_micordata($post='')
1291 1291
 {
1292 1292
 
1293
-    global $preview;
1294
-    if(empty($post)){global $post;}
1295
-    if ($preview || !geodir_is_page('detail')) {
1296
-        return;
1297
-    }
1298
-
1299
-    // url
1300
-    $c_url = geodir_curPageURL();
1301
-
1302
-    // post reviews
1303
-    $post_reviews = get_comments(array('post_id' => $post->ID, 'status' => 'approve'));
1304
-    if (empty($post_reviews)) {
1305
-        $reviews = '';
1306
-    } else {
1307
-        foreach ($post_reviews as $review) {
1308
-            $reviews[] = array(
1309
-                "@type" => "Review",
1310
-                "author" => $review->comment_author,
1311
-                "datePublished" => $review->comment_date,
1312
-                "description" => $review->comment_content,
1313
-                "reviewRating" => array(
1314
-                    "@type" => "Rating",
1315
-                    "bestRating" => "5",// @todo this will need to be filtered for review manager if user changes the score.
1316
-                    "ratingValue" => geodir_get_commentoverall($review->comment_ID),
1317
-                    "worstRating" => "1"
1318
-                )
1319
-            );
1320
-        }
1321
-
1322
-    }
1323
-
1324
-    // post images
1325
-    $post_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
1326
-    if (empty($post_images)) {
1327
-        $images = '';
1328
-    } else {
1329
-        $i_arr = array();
1330
-        foreach ($post_images as $img) {
1331
-            $i_arr[] = $img->src;
1332
-        }
1333
-
1334
-        if (count($i_arr) == 1) {
1335
-            $images = $i_arr[0];
1336
-        } else {
1337
-            $images = $i_arr;
1338
-        }
1339
-
1340
-    }
1341
-    //print_r($post);
1342
-    // external links
1343
-    $external_links =  array();
1344
-    $external_links[] = $post->geodir_website;
1345
-    $external_links[] = $post->geodir_twitter;
1346
-    $external_links[] = $post->geodir_facebook;
1347
-    $external_links = array_filter($external_links);
1348
-
1349
-    if(!empty($external_links)){
1350
-        $external_links = array_values($external_links);
1351
-    }
1352
-
1353
-    // reviews
1354
-    $comment_count = geodir_get_review_count_total($post->ID);
1355
-    $post_avgratings = geodir_get_post_rating($post->ID);
1356
-
1357
-    // schema type
1358
-    $schema_type = 'LocalBusiness';
1359
-    if(isset($post->default_category) && $post->default_category){
1360
-        $cat_schema = geodir_get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type);
1361
-        if($cat_schema){$schema_type = $cat_schema;}
1362
-        if(!$schema_type && $post->post_type=='gd_event'){$schema_type = 'Event';}
1363
-    }
1364
-
1365
-    $schema = array();
1366
-    $schema['@context'] = "https://schema.org";
1367
-    $schema['@type'] = $schema_type;
1368
-    $schema['name'] = $post->post_title;
1369
-    $schema['description'] = wp_strip_all_tags( $post->post_content, true );
1370
-    $schema['telephone'] = $post->geodir_contact;
1371
-    $schema['url'] = $c_url;
1372
-    $schema['sameAs'] = $external_links;
1373
-    $schema['image'] = $images;
1374
-    $schema['address'] = array(
1375
-        "@type" => "PostalAddress",
1376
-        "streetAddress" => $post->post_address,
1377
-        "addressLocality" => $post->post_city,
1378
-        "addressRegion" => $post->post_region,
1379
-        "addressCountry" => $post->post_country,
1380
-        "postalCode" => $post->post_zip
1381
-    );
1382
-
1383
-    if($post->post_latitude && $post->post_longitude) {
1384
-        $schema['geo'] = array(
1385
-            "@type" => "GeoCoordinates",
1386
-            "latitude" => $post->post_latitude,
1387
-            "longitude" => $post->post_longitude
1388
-        );
1389
-    }
1390
-
1391
-    if($post_avgratings) {
1392
-        $schema['aggregateRating'] = array(
1393
-            "@type" => "AggregateRating",
1394
-            "ratingValue" => $post_avgratings,
1395
-            "bestRating" => "5", // @todo this will need to be filtered for review manager if user changes the score.
1396
-            "worstRating" => "1",
1397
-            "ratingCount" => $comment_count
1398
-        );
1399
-    }
1400
-    $schema['review'] = $reviews;
1401
-
1402
-    /**
1403
-     * Allow the schema JSON-LD info to be filtered.
1404
-     *
1405
-     * @since 1.5.4
1406
-     * @since 1.5.7 Added $post variable.
1407
-     * @param array $schema The array of schema data to be filtered.
1408
-     * @param object $post The post object.
1409
-     */
1410
-    $schema = apply_filters('geodir_details_schema', $schema,$post);
1411
-
1412
-
1413
-    echo '<script type="application/ld+json">' . json_encode($schema) . '</script>';
1414
-
1415
-
1416
-    $uploads = wp_upload_dir();
1417
-    $facebook_og = (isset($post->featured_image) && $post->featured_image) ? '<meta property="og:image" content="'.$uploads['baseurl'].$post->featured_image.'"/>' : '';
1418
-
1419
-    /**
1420
-     * Show facebook open graph meta info
1421
-     *
1422
-     * @since 1.6.6
1423
-     * @param string $facebook_og The open graph html to be filtered.
1424
-     * @param object $post The post object.
1425
-     */
1426
-    echo apply_filters('geodir_details_facebook_og', $facebook_og,$post);
1293
+	global $preview;
1294
+	if(empty($post)){global $post;}
1295
+	if ($preview || !geodir_is_page('detail')) {
1296
+		return;
1297
+	}
1298
+
1299
+	// url
1300
+	$c_url = geodir_curPageURL();
1301
+
1302
+	// post reviews
1303
+	$post_reviews = get_comments(array('post_id' => $post->ID, 'status' => 'approve'));
1304
+	if (empty($post_reviews)) {
1305
+		$reviews = '';
1306
+	} else {
1307
+		foreach ($post_reviews as $review) {
1308
+			$reviews[] = array(
1309
+				"@type" => "Review",
1310
+				"author" => $review->comment_author,
1311
+				"datePublished" => $review->comment_date,
1312
+				"description" => $review->comment_content,
1313
+				"reviewRating" => array(
1314
+					"@type" => "Rating",
1315
+					"bestRating" => "5",// @todo this will need to be filtered for review manager if user changes the score.
1316
+					"ratingValue" => geodir_get_commentoverall($review->comment_ID),
1317
+					"worstRating" => "1"
1318
+				)
1319
+			);
1320
+		}
1321
+
1322
+	}
1323
+
1324
+	// post images
1325
+	$post_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
1326
+	if (empty($post_images)) {
1327
+		$images = '';
1328
+	} else {
1329
+		$i_arr = array();
1330
+		foreach ($post_images as $img) {
1331
+			$i_arr[] = $img->src;
1332
+		}
1333
+
1334
+		if (count($i_arr) == 1) {
1335
+			$images = $i_arr[0];
1336
+		} else {
1337
+			$images = $i_arr;
1338
+		}
1339
+
1340
+	}
1341
+	//print_r($post);
1342
+	// external links
1343
+	$external_links =  array();
1344
+	$external_links[] = $post->geodir_website;
1345
+	$external_links[] = $post->geodir_twitter;
1346
+	$external_links[] = $post->geodir_facebook;
1347
+	$external_links = array_filter($external_links);
1348
+
1349
+	if(!empty($external_links)){
1350
+		$external_links = array_values($external_links);
1351
+	}
1352
+
1353
+	// reviews
1354
+	$comment_count = geodir_get_review_count_total($post->ID);
1355
+	$post_avgratings = geodir_get_post_rating($post->ID);
1356
+
1357
+	// schema type
1358
+	$schema_type = 'LocalBusiness';
1359
+	if(isset($post->default_category) && $post->default_category){
1360
+		$cat_schema = geodir_get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type);
1361
+		if($cat_schema){$schema_type = $cat_schema;}
1362
+		if(!$schema_type && $post->post_type=='gd_event'){$schema_type = 'Event';}
1363
+	}
1364
+
1365
+	$schema = array();
1366
+	$schema['@context'] = "https://schema.org";
1367
+	$schema['@type'] = $schema_type;
1368
+	$schema['name'] = $post->post_title;
1369
+	$schema['description'] = wp_strip_all_tags( $post->post_content, true );
1370
+	$schema['telephone'] = $post->geodir_contact;
1371
+	$schema['url'] = $c_url;
1372
+	$schema['sameAs'] = $external_links;
1373
+	$schema['image'] = $images;
1374
+	$schema['address'] = array(
1375
+		"@type" => "PostalAddress",
1376
+		"streetAddress" => $post->post_address,
1377
+		"addressLocality" => $post->post_city,
1378
+		"addressRegion" => $post->post_region,
1379
+		"addressCountry" => $post->post_country,
1380
+		"postalCode" => $post->post_zip
1381
+	);
1382
+
1383
+	if($post->post_latitude && $post->post_longitude) {
1384
+		$schema['geo'] = array(
1385
+			"@type" => "GeoCoordinates",
1386
+			"latitude" => $post->post_latitude,
1387
+			"longitude" => $post->post_longitude
1388
+		);
1389
+	}
1390
+
1391
+	if($post_avgratings) {
1392
+		$schema['aggregateRating'] = array(
1393
+			"@type" => "AggregateRating",
1394
+			"ratingValue" => $post_avgratings,
1395
+			"bestRating" => "5", // @todo this will need to be filtered for review manager if user changes the score.
1396
+			"worstRating" => "1",
1397
+			"ratingCount" => $comment_count
1398
+		);
1399
+	}
1400
+	$schema['review'] = $reviews;
1401
+
1402
+	/**
1403
+	 * Allow the schema JSON-LD info to be filtered.
1404
+	 *
1405
+	 * @since 1.5.4
1406
+	 * @since 1.5.7 Added $post variable.
1407
+	 * @param array $schema The array of schema data to be filtered.
1408
+	 * @param object $post The post object.
1409
+	 */
1410
+	$schema = apply_filters('geodir_details_schema', $schema,$post);
1411
+
1412
+
1413
+	echo '<script type="application/ld+json">' . json_encode($schema) . '</script>';
1414
+
1415
+
1416
+	$uploads = wp_upload_dir();
1417
+	$facebook_og = (isset($post->featured_image) && $post->featured_image) ? '<meta property="og:image" content="'.$uploads['baseurl'].$post->featured_image.'"/>' : '';
1418
+
1419
+	/**
1420
+	 * Show facebook open graph meta info
1421
+	 *
1422
+	 * @since 1.6.6
1423
+	 * @param string $facebook_og The open graph html to be filtered.
1424
+	 * @param object $post The post object.
1425
+	 */
1426
+	echo apply_filters('geodir_details_facebook_og', $facebook_og,$post);
1427 1427
 
1428 1428
 
1429 1429
 
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
  */
1444 1444
 function geodir_action_details_next_prev()
1445 1445
 {
1446
-    ?>
1446
+	?>
1447 1447
     <div class="geodir-pos_navigation clearfix">
1448 1448
     <div
1449 1449
         class="geodir-post_left"><?php previous_post_link('%link', '' . __('Previous', 'geodirectory'), false) ?></div>
@@ -1461,15 +1461,15 @@  discard block
 block discarded – undo
1461 1461
  */
1462 1462
 function geodir_action_before_single_post()
1463 1463
 {
1464
-    global $post;
1465
-    /**
1466
-     * Called at the very start of the details page output, before the title section.
1467
-     *
1468
-     * @since 1.0.0
1469
-     * @param object $post The current post object.
1470
-     * @global WP_Post|null $post The current post, if available.
1471
-     */
1472
-    do_action('geodir_before_single_post', $post); // extra action	
1464
+	global $post;
1465
+	/**
1466
+	 * Called at the very start of the details page output, before the title section.
1467
+	 *
1468
+	 * @since 1.0.0
1469
+	 * @param object $post The current post object.
1470
+	 * @global WP_Post|null $post The current post, if available.
1471
+	 */
1472
+	do_action('geodir_before_single_post', $post); // extra action	
1473 1473
 }
1474 1474
 
1475 1475
 /**
@@ -1480,13 +1480,13 @@  discard block
 block discarded – undo
1480 1480
  */
1481 1481
 function geodir_action_after_single_post($post)
1482 1482
 {
1483
-    /**
1484
-     * Called on the details page after the details page tabs section and before the next/prev buttons.
1485
-     *
1486
-     * @since 1.0.0
1487
-     * @param object $post The current post object.
1488
-     */
1489
-    do_action('geodir_after_single_post', $post); // extra action	
1483
+	/**
1484
+	 * Called on the details page after the details page tabs section and before the next/prev buttons.
1485
+	 *
1486
+	 * @since 1.0.0
1487
+	 * @param object $post The current post object.
1488
+	 */
1489
+	do_action('geodir_after_single_post', $post); // extra action	
1490 1490
 }
1491 1491
 
1492 1492
 add_action('geodir_details_main_content', 'geodir_action_before_single_post', 10);
@@ -1512,168 +1512,168 @@  discard block
 block discarded – undo
1512 1512
  */
1513 1513
 function geodir_action_listings_title()
1514 1514
 {
1515
-    global $wp, $term;
1516
-
1517
-    $gd_post_type = geodir_get_current_posttype();
1518
-    $post_type_info = get_post_type_object($gd_post_type);
1519
-
1520
-    $add_string_in_title = __('All', 'geodirectory') . ' ';
1521
-    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
1522
-        $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
1523
-    }
1524
-
1525
-    $list_title = $add_string_in_title . __($post_type_info->labels->name, 'geodirectory');
1526
-    $single_name = $post_type_info->labels->singular_name;
1527
-
1528
-    $taxonomy = geodir_get_taxonomies($gd_post_type, true);
1529
-
1530
-    $gd_country = get_query_var('gd_country');
1531
-    $gd_region = get_query_var('gd_region');
1532
-    $gd_city = get_query_var('gd_city');
1533
-
1534
-    if (!empty($term)) {
1535
-        $location_name = '';
1536
-        if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
1537
-            if ($gd_country != '') {
1538
-                $location_name = geodir_sanitize_location_name('gd_country', $gd_country);
1539
-            }
1540
-
1541
-            if ($gd_region != '') {
1542
-                $location_name = geodir_sanitize_location_name('gd_region', $gd_region);
1543
-            }
1544
-
1545
-            if ($gd_city != '') {
1546
-                $location_name = geodir_sanitize_location_name('gd_city', $gd_city);
1547
-            }
1548
-        }
1549
-
1550
-        $current_term = get_term_by('slug', $term, $taxonomy[0]);
1551
-        if (!empty($current_term)) {
1552
-            $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory');
1553
-            if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
1554
-                $location_last_char = substr($location_name, -1);
1555
-                $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
1556
-                $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
1557
-            } else {
1558
-                $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
1559
-            }
1560
-        } else {
1561
-            if (count($taxonomy) > 1) {
1562
-                $current_term = get_term_by('slug', $term, $taxonomy[1]);
1563
-
1564
-                if (!empty($current_term)) {
1565
-                    $current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory');
1566
-                    if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
1567
-                        $location_last_char = substr($location_name, -1);
1568
-                        $location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
1569
-                        $list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
1570
-                    } else {
1571
-                        $list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
1572
-                    }
1573
-                }
1574
-            }
1575
-        }
1515
+	global $wp, $term;
1576 1516
 
1577
-    } else {
1578
-        $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
1579
-        $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
1580
-        $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
1517
+	$gd_post_type = geodir_get_current_posttype();
1518
+	$post_type_info = get_post_type_object($gd_post_type);
1581 1519
 
1582
-        $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
1520
+	$add_string_in_title = __('All', 'geodirectory') . ' ';
1521
+	if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
1522
+		$add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
1523
+	}
1583 1524
 
1584
-        if (function_exists('get_actual_location_name')) {
1585
-            $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
1586
-            $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
1587
-            $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
1588
-        }
1525
+	$list_title = $add_string_in_title . __($post_type_info->labels->name, 'geodirectory');
1526
+	$single_name = $post_type_info->labels->singular_name;
1589 1527
 
1590
-        if ($gd_city != '') {
1591
-            if ($gd_city_actual != '') {
1592
-                $gd_city = $gd_city_actual;
1593
-            } else {
1594
-                $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
1595
-                $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
1596
-                $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
1597
-            }
1528
+	$taxonomy = geodir_get_taxonomies($gd_post_type, true);
1598 1529
 
1599
-            $list_title .= __(' in', 'geodirectory') . " '" . $gd_city . "'";
1600
-        } else if ($gd_region != '') {
1601
-            if ($gd_region_actual != '') {
1602
-                $gd_region = $gd_region_actual;
1603
-            } else {
1604
-                $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
1605
-                $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
1606
-                $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
1607
-            }
1530
+	$gd_country = get_query_var('gd_country');
1531
+	$gd_region = get_query_var('gd_region');
1532
+	$gd_city = get_query_var('gd_city');
1608 1533
 
1609
-            $list_title .= __(' in', 'geodirectory') . " '" . $gd_region . "'";
1610
-        } else if ($gd_country != '') {
1611
-            if ($gd_country_actual != '') {
1612
-                $gd_country = $gd_country_actual;
1613
-            } else {
1614
-                $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
1615
-                $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
1616
-                $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
1617
-            }
1618
-
1619
-            $list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
1620
-        }
1621
-    }
1622
-
1623
-    if (is_search()) {
1624
-        $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
1625
-    }
1626
-    /** This action is documented in geodirectory_template_actions.php */
1627
-    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
1628
-    /** This action is documented in geodirectory_template_actions.php */
1629
-    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
1630
-
1631
-
1632
-    $title = $list_title;
1633
-    $gd_page = '';
1634
-    if(geodir_is_page('pt')){
1635
-        $gd_page = 'pt';
1636
-        $title  = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
1637
-    }
1638
-    elseif(geodir_is_page('listing')){
1639
-        $gd_page = 'listing';
1640
-        global $wp_query;
1641
-        $current_term = $wp_query->get_queried_object();
1642
-        if (strpos($current_term->taxonomy,'_tags') !== false) {
1643
-            $title = (get_option('geodir_page_title_tag-listing')) ? get_option('geodir_page_title_tag-listing') : $title;
1644
-        }else{
1645
-            $title = (get_option('geodir_page_title_cat-listing')) ? get_option('geodir_page_title_cat-listing') : $title;
1646
-        }
1534
+	if (!empty($term)) {
1535
+		$location_name = '';
1536
+		if ($gd_country != '' || $gd_region != '' || $gd_city != '') {
1537
+			if ($gd_country != '') {
1538
+				$location_name = geodir_sanitize_location_name('gd_country', $gd_country);
1539
+			}
1647 1540
 
1648
-    }
1649
-    elseif(geodir_is_page('author')){
1650
-        $gd_page = 'author';
1651
-        if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
1652
-            $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
1653
-        }else{
1654
-            $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
1655
-        }
1541
+			if ($gd_region != '') {
1542
+				$location_name = geodir_sanitize_location_name('gd_region', $gd_region);
1543
+			}
1656 1544
 
1657
-    }
1545
+			if ($gd_city != '') {
1546
+				$location_name = geodir_sanitize_location_name('gd_city', $gd_city);
1547
+			}
1548
+		}
1549
+
1550
+		$current_term = get_term_by('slug', $term, $taxonomy[0]);
1551
+		if (!empty($current_term)) {
1552
+			$current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory');
1553
+			if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
1554
+				$location_last_char = substr($location_name, -1);
1555
+				$location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
1556
+				$list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
1557
+			} else {
1558
+				$list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
1559
+			}
1560
+		} else {
1561
+			if (count($taxonomy) > 1) {
1562
+				$current_term = get_term_by('slug', $term, $taxonomy[1]);
1563
+
1564
+				if (!empty($current_term)) {
1565
+					$current_term_name = __(geodir_utf8_ucfirst($current_term->name), 'geodirectory');
1566
+					if ($current_term_name != '' && $location_name != '' && isset($current_term->taxonomy) && $current_term->taxonomy == $gd_post_type . 'category') {
1567
+						$location_last_char = substr($location_name, -1);
1568
+						$location_name_attach = geodir_strtolower($location_last_char) == 's' ? __("'", 'geodirectory') : __("'s", 'geodirectory');
1569
+						$list_title .= __(' in', 'geodirectory') . ' ' . $location_name . $location_name_attach . ' ' . $current_term_name;
1570
+					} else {
1571
+						$list_title .= __(' in', 'geodirectory') . " '" . $current_term_name . "'";
1572
+					}
1573
+				}
1574
+			}
1575
+		}
1576
+
1577
+	} else {
1578
+		$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
1579
+		$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
1580
+		$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
1581
+
1582
+		$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
1583
+
1584
+		if (function_exists('get_actual_location_name')) {
1585
+			$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
1586
+			$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
1587
+			$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
1588
+		}
1589
+
1590
+		if ($gd_city != '') {
1591
+			if ($gd_city_actual != '') {
1592
+				$gd_city = $gd_city_actual;
1593
+			} else {
1594
+				$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
1595
+				$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
1596
+				$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
1597
+			}
1658 1598
 
1599
+			$list_title .= __(' in', 'geodirectory') . " '" . $gd_city . "'";
1600
+		} else if ($gd_region != '') {
1601
+			if ($gd_region_actual != '') {
1602
+				$gd_region = $gd_region_actual;
1603
+			} else {
1604
+				$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
1605
+				$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
1606
+				$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
1607
+			}
1659 1608
 
1660
-    /**
1661
-     * Filter page title to replace variables.
1662
-     *
1663
-     * @since 1.5.4
1664
-     * @param string $title The page title including variables.
1665
-     * @param string $gd_page The GeoDirectory page type if any.
1666
-     */
1667
-    $title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
1609
+			$list_title .= __(' in', 'geodirectory') . " '" . $gd_region . "'";
1610
+		} else if ($gd_country != '') {
1611
+			if ($gd_country_actual != '') {
1612
+				$gd_country = $gd_country_actual;
1613
+			} else {
1614
+				$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
1615
+				$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
1616
+				$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
1617
+			}
1668 1618
 
1669
-    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
1670
-        /**
1671
-         * Filter the listing page title.
1672
-         *
1673
-         * @since 1.0.0
1674
-         * @param string $list_title The title for the category page.
1675
-         */
1676
-        apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
1619
+			$list_title .= __(' in', 'geodirectory') . " '" . $gd_country . "'";
1620
+		}
1621
+	}
1622
+
1623
+	if (is_search()) {
1624
+		$list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
1625
+	}
1626
+	/** This action is documented in geodirectory_template_actions.php */
1627
+	$class = apply_filters('geodir_page_title_class', 'entry-title fn');
1628
+	/** This action is documented in geodirectory_template_actions.php */
1629
+	$class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
1630
+
1631
+
1632
+	$title = $list_title;
1633
+	$gd_page = '';
1634
+	if(geodir_is_page('pt')){
1635
+		$gd_page = 'pt';
1636
+		$title  = (get_option('geodir_page_title_pt')) ? get_option('geodir_page_title_pt') : $title;
1637
+	}
1638
+	elseif(geodir_is_page('listing')){
1639
+		$gd_page = 'listing';
1640
+		global $wp_query;
1641
+		$current_term = $wp_query->get_queried_object();
1642
+		if (strpos($current_term->taxonomy,'_tags') !== false) {
1643
+			$title = (get_option('geodir_page_title_tag-listing')) ? get_option('geodir_page_title_tag-listing') : $title;
1644
+		}else{
1645
+			$title = (get_option('geodir_page_title_cat-listing')) ? get_option('geodir_page_title_cat-listing') : $title;
1646
+		}
1647
+
1648
+	}
1649
+	elseif(geodir_is_page('author')){
1650
+		$gd_page = 'author';
1651
+		if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
1652
+			$title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
1653
+		}else{
1654
+			$title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
1655
+		}
1656
+
1657
+	}
1658
+
1659
+
1660
+	/**
1661
+	 * Filter page title to replace variables.
1662
+	 *
1663
+	 * @since 1.5.4
1664
+	 * @param string $title The page title including variables.
1665
+	 * @param string $gd_page The GeoDirectory page type if any.
1666
+	 */
1667
+	$title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
1668
+
1669
+	echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
1670
+		/**
1671
+		 * Filter the listing page title.
1672
+		 *
1673
+		 * @since 1.0.0
1674
+		 * @param string $list_title The title for the category page.
1675
+		 */
1676
+		apply_filters('geodir_listing_page_title', $title) . '</h1></header>';
1677 1677
 }
1678 1678
 
1679 1679
 add_action('geodir_listings_page_description', 'geodir_action_listings_description', 10);
@@ -1686,46 +1686,46 @@  discard block
 block discarded – undo
1686 1686
  */
1687 1687
 function geodir_action_listings_description()
1688 1688
 {
1689
-    global $wp_query;
1690
-    $current_term = $wp_query->get_queried_object();
1689
+	global $wp_query;
1690
+	$current_term = $wp_query->get_queried_object();
1691 1691
 
1692
-    $gd_post_type = geodir_get_current_posttype();
1693
-    if (isset($current_term->term_id) && $current_term->term_id != '') {
1692
+	$gd_post_type = geodir_get_current_posttype();
1693
+	if (isset($current_term->term_id) && $current_term->term_id != '') {
1694 1694
 
1695
-        $term_desc = term_description($current_term->term_id, $gd_post_type . '_tags');
1696
-        $saved_data = stripslashes(geodir_get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type));
1697
-        if ($term_desc && !$saved_data) {
1698
-            $saved_data = $term_desc;
1699
-        }
1695
+		$term_desc = term_description($current_term->term_id, $gd_post_type . '_tags');
1696
+		$saved_data = stripslashes(geodir_get_tax_meta($current_term->term_id, 'ct_cat_top_desc', false, $gd_post_type));
1697
+		if ($term_desc && !$saved_data) {
1698
+			$saved_data = $term_desc;
1699
+		}
1700 1700
 
1701
-        // stop payment manager filtering content length
1702
-        $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' );
1703
-        if ( false !== $filter_priority ) {
1704
-            remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1705
-        }
1701
+		// stop payment manager filtering content length
1702
+		$filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' );
1703
+		if ( false !== $filter_priority ) {
1704
+			remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1705
+		}
1706 1706
 
1707
-        /**
1708
-         * Apply the core filter `the_content` filter to the variable string.
1709
-         *
1710
-         * This is a WordPress core filter that does many things.
1711
-         *
1712
-         * @since 1.0.0
1713
-         * @param string $var The string to apply the filter to.
1714
-         */
1715
-        $cat_description = apply_filters('the_content', $saved_data);
1707
+		/**
1708
+		 * Apply the core filter `the_content` filter to the variable string.
1709
+		 *
1710
+		 * This is a WordPress core filter that does many things.
1711
+		 *
1712
+		 * @since 1.0.0
1713
+		 * @param string $var The string to apply the filter to.
1714
+		 */
1715
+		$cat_description = apply_filters('the_content', $saved_data);
1716 1716
 
1717 1717
 
1718
-        if ( false !== $filter_priority ) {
1719
-            add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1720
-        }
1718
+		if ( false !== $filter_priority ) {
1719
+			add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority );
1720
+		}
1721 1721
 
1722
-        if ($cat_description) {
1723
-            ?>
1722
+		if ($cat_description) {
1723
+			?>
1724 1724
 
1725 1725
             <div class="term_description"><?php echo $cat_description;?></div> <?php
1726
-        }
1726
+		}
1727 1727
 
1728
-    }
1728
+	}
1729 1729
 }
1730 1730
 
1731 1731
 // action for adding the listings page top widget area
@@ -1744,11 +1744,11 @@  discard block
 block discarded – undo
1744 1744
  */
1745 1745
 function geodir_action_geodir_sidebar_listings_top()
1746 1746
 {
1747
-    if (get_option('geodir_show_listing_top_section')) { ?>
1747
+	if (get_option('geodir_show_listing_top_section')) { ?>
1748 1748
         <div
1749 1749
             class="<?php
1750
-            /** This action is documented in geodirectory_template_actions.php */
1751
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_top'); ?>">
1750
+			/** This action is documented in geodirectory_template_actions.php */
1751
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_top'); ?>">
1752 1752
             <?php dynamic_sidebar('geodir_listing_top'); ?>
1753 1753
         </div><!-- clearfix ends here-->
1754 1754
     <?php }
@@ -1771,35 +1771,35 @@  discard block
 block discarded – undo
1771 1771
  */
1772 1772
 function geodir_action_sidebar_left_open($type = '', $id = '', $class = '', $itemtype = '')
1773 1773
 {
1774
-    if ($type == 'home-page' && $width = get_option('geodir_width_home_left_section')) {
1775
-        $width_css = 'style="width:' . $width . '%;"';
1776
-    } elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_left_section')) {
1777
-        $width_css = 'style="width:' . $width . '%;"';
1778
-    } elseif ($type == 'search-page' && $width = get_option('geodir_width_search_left_section')) {
1779
-        $width_css = 'style="width:' . $width . '%;"';
1780
-    } elseif ($type == 'author-page' && $width = get_option('geodir_width_author_left_section')) {
1781
-        $width_css = 'style="width:' . $width . '%;"';
1782
-    } else {
1783
-        $width_css = '';
1784
-    }
1785
-
1786
-    $tc = get_option('theme_compatibility_setting');
1787
-    if (!empty($tc['geodir_sidebar_left_open_replace'])) {
1788
-        $text = $tc['geodir_sidebar_left_open_replace'];
1789
-    } else {
1790
-        $text = '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
1791
-    }
1792
-
1793
-    if (!empty($tc['geodir_sidebar_left_open_id'])) {
1794
-        $id = $tc['geodir_sidebar_left_open_id'];
1795
-    }
1796
-    if (!empty($tc['geodir_sidebar_left_open_class'])) {
1797
-        $class = $tc['geodir_sidebar_left_open_class'];
1798
-    }
1799
-
1800
-    $text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
1801
-
1802
-    echo $text;
1774
+	if ($type == 'home-page' && $width = get_option('geodir_width_home_left_section')) {
1775
+		$width_css = 'style="width:' . $width . '%;"';
1776
+	} elseif ($type == 'listings-page' && $width = get_option('geodir_width_listing_left_section')) {
1777
+		$width_css = 'style="width:' . $width . '%;"';
1778
+	} elseif ($type == 'search-page' && $width = get_option('geodir_width_search_left_section')) {
1779
+		$width_css = 'style="width:' . $width . '%;"';
1780
+	} elseif ($type == 'author-page' && $width = get_option('geodir_width_author_left_section')) {
1781
+		$width_css = 'style="width:' . $width . '%;"';
1782
+	} else {
1783
+		$width_css = '';
1784
+	}
1785
+
1786
+	$tc = get_option('theme_compatibility_setting');
1787
+	if (!empty($tc['geodir_sidebar_left_open_replace'])) {
1788
+		$text = $tc['geodir_sidebar_left_open_replace'];
1789
+	} else {
1790
+		$text = '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>';
1791
+	}
1792
+
1793
+	if (!empty($tc['geodir_sidebar_left_open_id'])) {
1794
+		$id = $tc['geodir_sidebar_left_open_id'];
1795
+	}
1796
+	if (!empty($tc['geodir_sidebar_left_open_class'])) {
1797
+		$class = $tc['geodir_sidebar_left_open_class'];
1798
+	}
1799
+
1800
+	$text = str_replace(array("[id]", "[class]", "[itemtype]", "[width_css]"), array($id, $class, $itemtype, $width_css), $text);
1801
+
1802
+	echo $text;
1803 1803
 }
1804 1804
 
1805 1805
 // action for adding the primary div closing tag
@@ -1815,13 +1815,13 @@  discard block
 block discarded – undo
1815 1815
  */
1816 1816
 function geodir_action_sidebar_left_close($type = '')
1817 1817
 {
1818
-    $tc = get_option('theme_compatibility_setting');
1819
-    if (!empty($tc['geodir_sidebar_left_close_replace'])) {
1820
-        $text = $tc['geodir_sidebar_left_close_replace'];
1821
-    } else {
1822
-        $text = '</aside><!-- sidebar ends here-->';
1823
-    }
1824
-    echo $text;
1818
+	$tc = get_option('theme_compatibility_setting');
1819
+	if (!empty($tc['geodir_sidebar_left_close_replace'])) {
1820
+		$text = $tc['geodir_sidebar_left_close_replace'];
1821
+	} else {
1822
+		$text = '</aside><!-- sidebar ends here-->';
1823
+	}
1824
+	echo $text;
1825 1825
 }
1826 1826
 
1827 1827
 /**
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
  */
1835 1835
 function geodir_listing_left_section()
1836 1836
 {
1837
-    if (get_option('geodir_show_listing_left_section')) { ?>
1837
+	if (get_option('geodir_show_listing_left_section')) { ?>
1838 1838
         <div class="geodir-content-left geodir-sidebar-wrap">
1839 1839
             <?php dynamic_sidebar('geodir_listing_left_sidebar'); ?>
1840 1840
         </div><!-- end geodir-content-left -->
@@ -1852,20 +1852,20 @@  discard block
 block discarded – undo
1852 1852
  */
1853 1853
 function geodir_action_listings_sidebar_left()
1854 1854
 {
1855
-    if (get_option('geodir_show_listing_left_section')) {
1856
-        /** This action is documented in geodirectory_template_actions.php */
1857
-        do_action('geodir_sidebar_left_open', 'listings-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'https://schema.org/WPSideBar');
1858
-        /**
1859
-         * Calls the listings page (category) left sidebar content.
1860
-         *
1861
-         * All the content for the listings page left sidebar is added via this hook.
1862
-         *
1863
-         * @since 1.0.0
1864
-         */
1865
-        do_action('geodir_listings_sidebar_left_inside');
1866
-        /** This action is documented in geodirectory_template_actions.php */
1867
-        do_action('geodir_sidebar_left_close', 'listings-page');
1868
-    }
1855
+	if (get_option('geodir_show_listing_left_section')) {
1856
+		/** This action is documented in geodirectory_template_actions.php */
1857
+		do_action('geodir_sidebar_left_open', 'listings-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'https://schema.org/WPSideBar');
1858
+		/**
1859
+		 * Calls the listings page (category) left sidebar content.
1860
+		 *
1861
+		 * All the content for the listings page left sidebar is added via this hook.
1862
+		 *
1863
+		 * @since 1.0.0
1864
+		 */
1865
+		do_action('geodir_listings_sidebar_left_inside');
1866
+		/** This action is documented in geodirectory_template_actions.php */
1867
+		do_action('geodir_sidebar_left_close', 'listings-page');
1868
+	}
1869 1869
 }
1870 1870
 
1871 1871
 /**
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
  */
1879 1879
 function geodir_listing_right_section()
1880 1880
 {
1881
-    if (get_option('geodir_show_listing_right_section')) { ?>
1881
+	if (get_option('geodir_show_listing_right_section')) { ?>
1882 1882
         <div class="geodir-content-right geodir-sidebar-wrap">
1883 1883
             <?php dynamic_sidebar('geodir_listing_right_sidebar'); ?>
1884 1884
         </div><!-- end geodir-content-right -->
@@ -1896,20 +1896,20 @@  discard block
 block discarded – undo
1896 1896
  */
1897 1897
 function geodir_action_listings_sidebar_right()
1898 1898
 {
1899
-    if (get_option('geodir_show_listing_right_section')) {
1900
-        /** This action is documented in geodirectory_template_actions.php */
1901
-        do_action('geodir_sidebar_right_open', 'listings-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
1902
-        /**
1903
-         * Calls the listings page (category) right sidebar content.
1904
-         *
1905
-         * All the content for the listings page right sidebar is added via this hook.
1906
-         *
1907
-         * @since 1.0.0
1908
-         */
1909
-        do_action('geodir_listings_sidebar_right_inside');
1910
-        /** This action is documented in geodirectory_template_actions.php */
1911
-        do_action('geodir_sidebar_right_close', 'listings-page');
1912
-    }
1899
+	if (get_option('geodir_show_listing_right_section')) {
1900
+		/** This action is documented in geodirectory_template_actions.php */
1901
+		do_action('geodir_sidebar_right_open', 'listings-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
1902
+		/**
1903
+		 * Calls the listings page (category) right sidebar content.
1904
+		 *
1905
+		 * All the content for the listings page right sidebar is added via this hook.
1906
+		 *
1907
+		 * @since 1.0.0
1908
+		 */
1909
+		do_action('geodir_listings_sidebar_right_inside');
1910
+		/** This action is documented in geodirectory_template_actions.php */
1911
+		do_action('geodir_sidebar_right_close', 'listings-page');
1912
+	}
1913 1913
 }
1914 1914
 
1915 1915
 
@@ -1926,23 +1926,23 @@  discard block
 block discarded – undo
1926 1926
  */
1927 1927
 function geodir_action_main_content_open($type = '', $id = '', $class = '')
1928 1928
 {
1929
-    $tc = get_option('theme_compatibility_setting');
1930
-    if (!empty($tc['geodir_main_content_open_replace'])) {
1931
-        $text = $tc['geodir_main_content_open_replace'];
1932
-    } else {
1933
-        $text = '<main id="[id]" class="[class]" role="main">';
1934
-    }
1929
+	$tc = get_option('theme_compatibility_setting');
1930
+	if (!empty($tc['geodir_main_content_open_replace'])) {
1931
+		$text = $tc['geodir_main_content_open_replace'];
1932
+	} else {
1933
+		$text = '<main id="[id]" class="[class]" role="main">';
1934
+	}
1935 1935
 
1936
-    if (!empty($tc['geodir_main_content_open_id'])) {
1937
-        $id = $tc['geodir_main_content_open_id'];
1938
-    }
1939
-    if (!empty($tc['geodir_main_content_open_class'])) {
1940
-        $class = $tc['geodir_main_content_open_class'];
1941
-    }
1936
+	if (!empty($tc['geodir_main_content_open_id'])) {
1937
+		$id = $tc['geodir_main_content_open_id'];
1938
+	}
1939
+	if (!empty($tc['geodir_main_content_open_class'])) {
1940
+		$class = $tc['geodir_main_content_open_class'];
1941
+	}
1942 1942
 
1943
-    $text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
1943
+	$text = str_replace(array("[id]", "[class]"), array($id, $class), $text);
1944 1944
 
1945
-    echo $text;
1945
+	echo $text;
1946 1946
 }
1947 1947
 
1948 1948
 // action for adding the primary div closing tag
@@ -1955,13 +1955,13 @@  discard block
 block discarded – undo
1955 1955
  */
1956 1956
 function geodir_action_main_content_close()
1957 1957
 {
1958
-    $tc = get_option('theme_compatibility_setting');
1959
-    if (!empty($tc['geodir_main_content_close_replace'])) {
1960
-        $text = $tc['geodir_main_content_close_replace'];
1961
-    } else {
1962
-        $text = '</main><!-- main ends here-->';
1963
-    }
1964
-    echo $text;
1958
+	$tc = get_option('theme_compatibility_setting');
1959
+	if (!empty($tc['geodir_main_content_close_replace'])) {
1960
+		$text = $tc['geodir_main_content_close_replace'];
1961
+	} else {
1962
+		$text = '</main><!-- main ends here-->';
1963
+	}
1964
+	echo $text;
1965 1965
 }
1966 1966
 
1967 1967
 /**
@@ -1973,14 +1973,14 @@  discard block
 block discarded – undo
1973 1973
  */
1974 1974
 function geodir_action_listings_content_inside()
1975 1975
 {
1976
-    global $gridview_columns;
1977
-    $listing_view = get_option('geodir_listing_view');
1978
-    if (strstr($listing_view, 'gridview')) {
1979
-        $gridview_columns = $listing_view;
1980
-        $listing_view_exp = explode('_', $listing_view);
1981
-        $listing_view = $listing_view_exp[0];
1982
-    }
1983
-    geodir_get_template_part('listing', 'listview');
1976
+	global $gridview_columns;
1977
+	$listing_view = get_option('geodir_listing_view');
1978
+	if (strstr($listing_view, 'gridview')) {
1979
+		$gridview_columns = $listing_view;
1980
+		$listing_view_exp = explode('_', $listing_view);
1981
+		$listing_view = $listing_view_exp[0];
1982
+	}
1983
+	geodir_get_template_part('listing', 'listview');
1984 1984
 }
1985 1985
 
1986 1986
 add_action('geodir_listings_content_inside', 'geodir_action_listings_content_inside', 10);
@@ -1996,47 +1996,47 @@  discard block
 block discarded – undo
1996 1996
  */
1997 1997
 function geodir_action_listings_content()
1998 1998
 {
1999
-    /**
2000
-     * This is used to add HTML opening wrappers to the main content of most pages including listings, author, search, home etc.
2001
-     *
2002
-     * @since 1.0.0
2003
-     * @param string $type The page type. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'.
2004
-     * @param string $id The id for the div. Usually 'geodir-main-content'.
2005
-     * @param string $class The class for the div. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'.
2006
-     * @see 'geodir_main_content_close' Where the oposing closing tag is added.
2007
-     */
2008
-    do_action('geodir_main_content_open', 'listings-page', 'geodir-main-content', 'listings-page');
2009
-    $extra_class = apply_filters('geodir_before_listing_wrapper_extra_class', '', 'listings-page');
2010
-    echo '<div class="clearfix '.$extra_class.'">';
2011
-    /**
2012
-     * Called before the listings page content, inside the outer wrapper. Used on listings pages and search and author pages.
2013
-     *
2014
-     * @since 1.0.0
2015
-     */
2016
-    do_action('geodir_before_listing');
2017
-    echo '</div>';
2018
-
2019
-    /**
2020
-     * This actions calls the listings list content. Used on listings pages and search and author pages.
2021
-     *
2022
-     * @since 1.0.0
2023
-     */
2024
-    do_action('geodir_listings_content_inside');
2025
-
2026
-    /**
2027
-     * Called after the listings content, inside the outer wrapper HTML. Used on listings pages and search and author pages.
2028
-     *
2029
-     * @since 1.0.0
2030
-     */
2031
-    do_action('geodir_after_listing');
2032
-
2033
-    /**
2034
-     * This is used to add HTML closing wrappers to the main content of most pages including listings, author, search, home etc.
2035
-     *
2036
-     * @since 1.0.0
2037
-     * @see 'geodir_main_content_open' Where the oposing opening tag is added.
2038
-     */
2039
-    do_action('geodir_main_content_close', 'listings-page');
1999
+	/**
2000
+	 * This is used to add HTML opening wrappers to the main content of most pages including listings, author, search, home etc.
2001
+	 *
2002
+	 * @since 1.0.0
2003
+	 * @param string $type The page type. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'.
2004
+	 * @param string $id The id for the div. Usually 'geodir-main-content'.
2005
+	 * @param string $class The class for the div. Values can be 'listings-page', 'author-page', 'search-page' or 'home-page'.
2006
+	 * @see 'geodir_main_content_close' Where the oposing closing tag is added.
2007
+	 */
2008
+	do_action('geodir_main_content_open', 'listings-page', 'geodir-main-content', 'listings-page');
2009
+	$extra_class = apply_filters('geodir_before_listing_wrapper_extra_class', '', 'listings-page');
2010
+	echo '<div class="clearfix '.$extra_class.'">';
2011
+	/**
2012
+	 * Called before the listings page content, inside the outer wrapper. Used on listings pages and search and author pages.
2013
+	 *
2014
+	 * @since 1.0.0
2015
+	 */
2016
+	do_action('geodir_before_listing');
2017
+	echo '</div>';
2018
+
2019
+	/**
2020
+	 * This actions calls the listings list content. Used on listings pages and search and author pages.
2021
+	 *
2022
+	 * @since 1.0.0
2023
+	 */
2024
+	do_action('geodir_listings_content_inside');
2025
+
2026
+	/**
2027
+	 * Called after the listings content, inside the outer wrapper HTML. Used on listings pages and search and author pages.
2028
+	 *
2029
+	 * @since 1.0.0
2030
+	 */
2031
+	do_action('geodir_after_listing');
2032
+
2033
+	/**
2034
+	 * This is used to add HTML closing wrappers to the main content of most pages including listings, author, search, home etc.
2035
+	 *
2036
+	 * @since 1.0.0
2037
+	 * @see 'geodir_main_content_open' Where the oposing opening tag is added.
2038
+	 */
2039
+	do_action('geodir_main_content_close', 'listings-page');
2040 2040
 }
2041 2041
 
2042 2042
 
@@ -2051,10 +2051,10 @@  discard block
 block discarded – undo
2051 2051
  */
2052 2052
 function geodir_action_sidebar_listings_bottom_section()
2053 2053
 {
2054
-    if (get_option('geodir_show_listing_bottom_section')) { ?>
2054
+	if (get_option('geodir_show_listing_bottom_section')) { ?>
2055 2055
         <div class="<?php
2056
-            /** This action is documented in geodirectory_template_actions.php */
2057
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_bottom'); ?>">
2056
+			/** This action is documented in geodirectory_template_actions.php */
2057
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_listing_bottom'); ?>">
2058 2058
             <?php dynamic_sidebar('geodir_listing_bottom'); ?>
2059 2059
         </div><!-- clearfix ends here-->
2060 2060
     <?php }
@@ -2074,38 +2074,38 @@  discard block
 block discarded – undo
2074 2074
  */
2075 2075
 function geodir_action_add_listing_page_title()
2076 2076
 {
2077
-    if (isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != '')
2078
-        $listing_type = sanitize_text_field($_REQUEST['listing_type']);
2079
-    /** This action is documented in geodirectory_template_actions.php */
2080
-    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
2081
-    /** This action is documented in geodirectory_template_actions.php */
2082
-    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
2083
-
2084
-    $title = apply_filters('geodir_add_listing_page_title_text', get_the_title());
2085
-
2086
-    if(geodir_is_page('add-listing')){
2087
-        $gd_page = 'add-listing';
2088
-        if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
2089
-            $title = (get_option('geodir_page_title_edit-listing')) ? get_option('geodir_page_title_edit-listing') : $title;
2090
-        }elseif(isset($listing_type)){
2091
-            $title = (get_option('geodir_page_title_add-listing')) ? get_option('geodir_page_title_add-listing') : $title;
2092
-        }
2077
+	if (isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != '')
2078
+		$listing_type = sanitize_text_field($_REQUEST['listing_type']);
2079
+	/** This action is documented in geodirectory_template_actions.php */
2080
+	$class = apply_filters('geodir_page_title_class', 'entry-title fn');
2081
+	/** This action is documented in geodirectory_template_actions.php */
2082
+	$class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
2083
+
2084
+	$title = apply_filters('geodir_add_listing_page_title_text', get_the_title());
2085
+
2086
+	if(geodir_is_page('add-listing')){
2087
+		$gd_page = 'add-listing';
2088
+		if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
2089
+			$title = (get_option('geodir_page_title_edit-listing')) ? get_option('geodir_page_title_edit-listing') : $title;
2090
+		}elseif(isset($listing_type)){
2091
+			$title = (get_option('geodir_page_title_add-listing')) ? get_option('geodir_page_title_add-listing') : $title;
2092
+		}
2093 2093
 
2094
-    }
2094
+	}
2095 2095
 
2096 2096
 
2097
-    /**
2098
-     * Filter page title to replace variables.
2099
-     *
2100
-     * @since 1.5.4
2101
-     * @param string $title The page title including variables.
2102
-     * @param string $gd_page The GeoDirectory page type if any.
2103
-     */
2104
-    $title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
2097
+	/**
2098
+	 * Filter page title to replace variables.
2099
+	 *
2100
+	 * @since 1.5.4
2101
+	 * @param string $title The page title including variables.
2102
+	 * @param string $gd_page The GeoDirectory page type if any.
2103
+	 */
2104
+	$title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
2105 2105
 
2106
-    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">';
2107
-    echo $title;
2108
-    echo '</h1></header>';
2106
+	echo '<header class="' . $class_header . '"><h1 class="' . $class . '">';
2107
+	echo $title;
2108
+	echo '</h1></header>';
2109 2109
 }
2110 2110
 
2111 2111
 add_action('geodir_add_listing_page_mandatory', 'geodir_action_add_listing_page_mandatory', 10);
@@ -2136,61 +2136,61 @@  discard block
 block discarded – undo
2136 2136
  */
2137 2137
 function geodir_action_add_listing_form()
2138 2138
 {
2139
-    global $cat_display, $post_cat, $current_user, $gd_session;
2140
-    $page_id = get_the_ID();
2141
-    $post = '';
2142
-    $title = '';
2143
-    $desc = '';
2144
-    $kw_tags = '';
2145
-    $required_msg = '';
2146
-    $submit_button = '';
2147
-
2148
-    $ajax_action = isset($_REQUEST['ajax_action']) ? $_REQUEST['ajax_action'] : 'add';
2149
-
2150
-    $thumb_img_arr = array();
2151
-    $curImages = '';
2152
-
2153
-    if (isset($_REQUEST['backandedit'])) {
2154
-        global $post;
2155
-        $post = (object)$gd_session->get('listing');
2156
-        $listing_type = $post->listing_type;
2157
-        $title = $post->post_title;
2158
-        $desc = $post->post_desc;
2159
-        $post_cat = $post->post_category;
2160
-
2161
-        $kw_tags = $post->post_tags;
2162
-        $curImages = isset($post->post_images) ? $post->post_images : '';
2163
-    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2164
-        global $post, $post_images;
2165
-
2166
-        $post = geodir_get_post_info($_REQUEST['pid']);
2167
-        $thumb_img_arr = geodir_get_images($post->ID);
2168
-        if ($thumb_img_arr) {
2169
-            foreach ($thumb_img_arr as $post_img) {
2170
-                $curImages .= $post_img->src . ',';
2171
-            }
2172
-        }
2139
+	global $cat_display, $post_cat, $current_user, $gd_session;
2140
+	$page_id = get_the_ID();
2141
+	$post = '';
2142
+	$title = '';
2143
+	$desc = '';
2144
+	$kw_tags = '';
2145
+	$required_msg = '';
2146
+	$submit_button = '';
2147
+
2148
+	$ajax_action = isset($_REQUEST['ajax_action']) ? $_REQUEST['ajax_action'] : 'add';
2149
+
2150
+	$thumb_img_arr = array();
2151
+	$curImages = '';
2152
+
2153
+	if (isset($_REQUEST['backandedit'])) {
2154
+		global $post;
2155
+		$post = (object)$gd_session->get('listing');
2156
+		$listing_type = $post->listing_type;
2157
+		$title = $post->post_title;
2158
+		$desc = $post->post_desc;
2159
+		$post_cat = $post->post_category;
2160
+
2161
+		$kw_tags = $post->post_tags;
2162
+		$curImages = isset($post->post_images) ? $post->post_images : '';
2163
+	} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2164
+		global $post, $post_images;
2165
+
2166
+		$post = geodir_get_post_info($_REQUEST['pid']);
2167
+		$thumb_img_arr = geodir_get_images($post->ID);
2168
+		if ($thumb_img_arr) {
2169
+			foreach ($thumb_img_arr as $post_img) {
2170
+				$curImages .= $post_img->src . ',';
2171
+			}
2172
+		}
2173 2173
 
2174
-        $listing_type = $post->post_type;
2175
-        $title = $post->post_title;
2176
-        $desc = $post->post_content;
2177
-        $kw_tags = $post->post_tags;
2178
-        $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
2179
-    } else {
2180
-        $listing_type = sanitize_text_field($_REQUEST['listing_type']);
2181
-    }
2174
+		$listing_type = $post->post_type;
2175
+		$title = $post->post_title;
2176
+		$desc = $post->post_content;
2177
+		$kw_tags = $post->post_tags;
2178
+		$kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
2179
+	} else {
2180
+		$listing_type = sanitize_text_field($_REQUEST['listing_type']);
2181
+	}
2182 2182
 
2183
-    if ($current_user->ID != '0') {
2184
-        $user_login = true;
2185
-    }
2183
+	if ($current_user->ID != '0') {
2184
+		$user_login = true;
2185
+	}
2186 2186
 
2187
-    $post_type_info = geodir_get_posttype_info($listing_type);
2187
+	$post_type_info = geodir_get_posttype_info($listing_type);
2188 2188
 
2189
-    $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
2189
+	$cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
2190 2190
     
2191
-    $package_info = array();
2192
-    $package_info = geodir_post_package_info($package_info, $post);
2193
-    ?>
2191
+	$package_info = array();
2192
+	$package_info = geodir_post_package_info($package_info, $post);
2193
+	?>
2194 2194
     <form name="propertyform" id="propertyform" action="<?php echo get_page_link(geodir_preview_page_id());?>" method="post" enctype="multipart/form-data">
2195 2195
         <input type="hidden" name="preview" value="<?php echo sanitize_text_field($listing_type);?>"/>
2196 2196
         <input type="hidden" name="listing_type" value="<?php echo sanitize_text_field($listing_type);?>"/>
@@ -2201,114 +2201,114 @@  discard block
 block discarded – undo
2201 2201
         <?php } if (isset($_REQUEST['backandedit'])) { ?>
2202 2202
             <input type="hidden" name="backandedit" value="<?php echo sanitize_text_field($_REQUEST['backandedit']);?>"/>
2203 2203
         <?php
2204
-        } 
2205
-        /**
2206
-         * Called at the very top of the add listing page form for frontend.
2207
-         *
2208
-         * This is called just before the "Enter Listing Details" text.
2209
-         *
2210
-         * @since 1.0.0
2211
-         */
2212
-        do_action('geodir_before_detail_fields');
2213
-        ?>
2204
+		} 
2205
+		/**
2206
+		 * Called at the very top of the add listing page form for frontend.
2207
+		 *
2208
+		 * This is called just before the "Enter Listing Details" text.
2209
+		 *
2210
+		 * @since 1.0.0
2211
+		 */
2212
+		do_action('geodir_before_detail_fields');
2213
+		?>
2214 2214
         <h5 id="geodir_fieldset_details" class="geodir-fieldset-row" gd-fieldset="details"><?php echo LISTING_DETAILS_TEXT;?></h5>
2215 2215
         <?php
2216
-        /**
2217
-         * Called at the top of the add listing page form for frontend.
2218
-         *
2219
-         * This is called after the "Enter Listing Details" text.
2220
-         *
2221
-         * @since 1.0.0
2222
-         */
2223
-        do_action('geodir_before_main_form_fields');
2224
-        ?>
2216
+		/**
2217
+		 * Called at the top of the add listing page form for frontend.
2218
+		 *
2219
+		 * This is called after the "Enter Listing Details" text.
2220
+		 *
2221
+		 * @since 1.0.0
2222
+		 */
2223
+		do_action('geodir_before_main_form_fields');
2224
+		?>
2225 2225
         <div id="geodir_post_title_row" class="required_field geodir_form_row clearfix gd-fieldset-details">
2226 2226
             <label><?php
2227
-                /**
2228
-                 * Filter the add listing page title input label.
2229
-                 *
2230
-                 * @since 1.6.11
2231
-                 * @param string $title The title to be output.
2232
-                 * @param string $cpt_singular_name The singular title of the curent CPT.
2233
-                 * @param string $listing_type The CPT being requested. ie: gd_place.
2234
-                 */
2235
-                echo apply_filters('geodir_add_listing_title_label', sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span>*</span> </label>
2227
+				/**
2228
+				 * Filter the add listing page title input label.
2229
+				 *
2230
+				 * @since 1.6.11
2231
+				 * @param string $title The title to be output.
2232
+				 * @param string $cpt_singular_name The singular title of the curent CPT.
2233
+				 * @param string $listing_type The CPT being requested. ie: gd_place.
2234
+				 */
2235
+				echo apply_filters('geodir_add_listing_title_label', sprintf( __('%s Title', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span>*</span> </label>
2236 2236
             <input type="text" field_type="text" name="post_title" id="post_title" class="geodir_textfield"
2237 2237
                    value="<?php echo esc_attr(stripslashes($title)); ?>"/>
2238 2238
             <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory');?></span>
2239 2239
         </div>
2240 2240
         <?php
2241
-        $show_editor = get_option('geodir_tiny_editor_on_add_listing');
2242
-        $show_editor = !empty($show_editor) && in_array($listing_type, $show_editor) ? true : false;
2243
-        /**
2244
-         * Filter whether to show or don't show the editor.
2245
-         *
2246
-         * @since 1.6.16
2247
-         * @param bool $show_editor If true the editor will be available for description field.
2248
-         * @param object $package_info The listing package.
2249
-         * @param string $listing_type The current post type.
2250
-         * @param object $post The current post object.
2251
-         */
2252
-        $show_editor = apply_filters('geodir_description_field_show_editor', $show_editor, $package_info, $listing_type, $post);
2253
-
2254
-        $desc = $show_editor ? stripslashes($desc) : esc_attr(stripslashes($desc));
2255
-        $desc_limit = '';
2256
-        /**
2257
-         * Filter the add listing description field character limit number.
2258
-         *
2259
-         * @since 1.0.0
2260
-         * @param int $desc_limit The amount of characters to limit the description to.
2261
-         */
2262
-        $desc_limit = apply_filters('geodir_description_field_desc_limit', $desc_limit);
2263
-        /**
2264
-         * Filter the add listing description field text.
2265
-         *
2266
-         * @since 1.0.0
2267
-         * @param string $desc The text for the description field.
2268
-         * @param int $desc_limit The character limit number if any.
2269
-         */
2270
-        $desc = apply_filters('geodir_description_field_desc', $desc, $desc_limit);
2271
-        $desc_limit_msg = '';
2272
-        /**
2273
-         * Filter the add listing description limit message.
2274
-         *
2275
-         * This is the message shown if there is a limit applied to the amount of characters the description can use.
2276
-         *
2277
-         * @since 1.0.0
2278
-         * @param string $desc_limit_msg The limit message string if any.
2279
-         * @param int $desc_limit The character limit numer if any.
2280
-         */
2281
-        $desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
2241
+		$show_editor = get_option('geodir_tiny_editor_on_add_listing');
2242
+		$show_editor = !empty($show_editor) && in_array($listing_type, $show_editor) ? true : false;
2243
+		/**
2244
+		 * Filter whether to show or don't show the editor.
2245
+		 *
2246
+		 * @since 1.6.16
2247
+		 * @param bool $show_editor If true the editor will be available for description field.
2248
+		 * @param object $package_info The listing package.
2249
+		 * @param string $listing_type The current post type.
2250
+		 * @param object $post The current post object.
2251
+		 */
2252
+		$show_editor = apply_filters('geodir_description_field_show_editor', $show_editor, $package_info, $listing_type, $post);
2253
+
2254
+		$desc = $show_editor ? stripslashes($desc) : esc_attr(stripslashes($desc));
2255
+		$desc_limit = '';
2256
+		/**
2257
+		 * Filter the add listing description field character limit number.
2258
+		 *
2259
+		 * @since 1.0.0
2260
+		 * @param int $desc_limit The amount of characters to limit the description to.
2261
+		 */
2262
+		$desc_limit = apply_filters('geodir_description_field_desc_limit', $desc_limit);
2263
+		/**
2264
+		 * Filter the add listing description field text.
2265
+		 *
2266
+		 * @since 1.0.0
2267
+		 * @param string $desc The text for the description field.
2268
+		 * @param int $desc_limit The character limit number if any.
2269
+		 */
2270
+		$desc = apply_filters('geodir_description_field_desc', $desc, $desc_limit);
2271
+		$desc_limit_msg = '';
2272
+		/**
2273
+		 * Filter the add listing description limit message.
2274
+		 *
2275
+		 * This is the message shown if there is a limit applied to the amount of characters the description can use.
2276
+		 *
2277
+		 * @since 1.0.0
2278
+		 * @param string $desc_limit_msg The limit message string if any.
2279
+		 * @param int $desc_limit The character limit numer if any.
2280
+		 */
2281
+		$desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
2282 2282
         
2283
-        $desc_class = '';
2284
-        if ($desc_limit === '' || (int)$desc_limit > 0) {
2285
-            /**
2286
-             * Called on the add listing page form for frontend just before the description field.
2287
-             *
2288
-             * @since 1.0.0
2289
-             */
2290
-            do_action('geodir_before_description_field');
2283
+		$desc_class = '';
2284
+		if ($desc_limit === '' || (int)$desc_limit > 0) {
2285
+			/**
2286
+			 * Called on the add listing page form for frontend just before the description field.
2287
+			 *
2288
+			 * @since 1.0.0
2289
+			 */
2290
+			do_action('geodir_before_description_field');
2291 2291
             
2292
-            $desc_class = ' required_field';
2293
-        } else {
2294
-            $desc_class = ' hidden';
2295
-        }
2296
-        ?>
2292
+			$desc_class = ' required_field';
2293
+		} else {
2294
+			$desc_class = ' hidden';
2295
+		}
2296
+		?>
2297 2297
         <div id="geodir_post_desc_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $desc_class;?>">
2298 2298
             <label><?php
2299
-                /**
2300
-                 * Filter the add listing page description input label.
2301
-                 *
2302
-                 * @since 1.6.11
2303
-                 * @param string $title The title to be output.
2304
-                 * @param string $cpt_singular_name The singular title of the curent CPT.
2305
-                 * @param string $listing_type The CPT being requested. ie: gd_place.
2306
-                 */
2307
-                echo apply_filters('geodir_add_listing_description_label',sprintf( __('%s Description', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
2299
+				/**
2300
+				 * Filter the add listing page description input label.
2301
+				 *
2302
+				 * @since 1.6.11
2303
+				 * @param string $title The title to be output.
2304
+				 * @param string $cpt_singular_name The singular title of the curent CPT.
2305
+				 * @param string $listing_type The CPT being requested. ie: gd_place.
2306
+				 */
2307
+				echo apply_filters('geodir_add_listing_description_label',sprintf( __('%s Description', 'geodirectory'), $cpt_singular_name ),$cpt_singular_name,$listing_type); ?><span><?php if ($desc_limit != '0') { echo '*'; } ?></span> </label>
2308 2308
             <?php
2309
-            if ($show_editor) {
2310
-                $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
2311
-            ?>
2309
+			if ($show_editor) {
2310
+				$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
2311
+			?>
2312 2312
                 <div class="editor" field_id="post_desc" field_type="editor">
2313 2313
                     <?php wp_editor($desc, "post_desc", $editor_settings); ?>
2314 2314
                 </div>
@@ -2322,56 +2322,56 @@  discard block
 block discarded – undo
2322 2322
             <span class="geodir_message_error"><?php echo _e($required_msg, 'geodirectory');?></span>
2323 2323
         </div>
2324 2324
         <?php
2325
-        if ($desc_limit === '' || (int)$desc_limit > 0) {
2326
-            /**
2327
-             * Called on the add listing page form for frontend just after the description field.
2328
-             *
2329
-             * @since 1.0.0
2330
-             */
2331
-            do_action('geodir_after_description_field');
2332
-        }
2325
+		if ($desc_limit === '' || (int)$desc_limit > 0) {
2326
+			/**
2327
+			 * Called on the add listing page form for frontend just after the description field.
2328
+			 *
2329
+			 * @since 1.0.0
2330
+			 */
2331
+			do_action('geodir_after_description_field');
2332
+		}
2333 2333
         
2334
-        $kw_tags = esc_attr(stripslashes($kw_tags));
2335
-        $kw_tags_count = TAGKW_TEXT_COUNT;
2336
-        $kw_tags_msg = TAGKW_MSG;
2337
-        /**
2338
-         * Filter the add listing tags character limit.
2339
-         *
2340
-         * @since 1.0.0
2341
-         * @param int $kw_tags_count The character count limit if any.
2342
-         */
2343
-        $kw_tags_count = apply_filters('geodir_listing_tags_field_tags_count', $kw_tags_count);
2344
-        /**
2345
-         * Filter the add listing tags field value.
2346
-         *
2347
-         * You can use the $_REQUEST values to check if this is a go back and edit value etc.
2348
-         *
2349
-         * @since 1.0.0
2350
-         * @param string $kw_tags The tag field value, usually a comma separated list of tags.
2351
-         * @param int $kw_tags_count The character count limit if any.
2352
-         */
2353
-        $kw_tags = apply_filters('geodir_listing_tags_field_tags', $kw_tags, $kw_tags_count);
2354
-        /**
2355
-         * Filter the add listing tags field message text.
2356
-         *
2357
-         * @since 1.0.0
2358
-         * @param string $kw_tags_msg The message shown under the field.
2359
-         * @param int $kw_tags_count The character count limit if any.
2360
-         */
2361
-        $kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
2334
+		$kw_tags = esc_attr(stripslashes($kw_tags));
2335
+		$kw_tags_count = TAGKW_TEXT_COUNT;
2336
+		$kw_tags_msg = TAGKW_MSG;
2337
+		/**
2338
+		 * Filter the add listing tags character limit.
2339
+		 *
2340
+		 * @since 1.0.0
2341
+		 * @param int $kw_tags_count The character count limit if any.
2342
+		 */
2343
+		$kw_tags_count = apply_filters('geodir_listing_tags_field_tags_count', $kw_tags_count);
2344
+		/**
2345
+		 * Filter the add listing tags field value.
2346
+		 *
2347
+		 * You can use the $_REQUEST values to check if this is a go back and edit value etc.
2348
+		 *
2349
+		 * @since 1.0.0
2350
+		 * @param string $kw_tags The tag field value, usually a comma separated list of tags.
2351
+		 * @param int $kw_tags_count The character count limit if any.
2352
+		 */
2353
+		$kw_tags = apply_filters('geodir_listing_tags_field_tags', $kw_tags, $kw_tags_count);
2354
+		/**
2355
+		 * Filter the add listing tags field message text.
2356
+		 *
2357
+		 * @since 1.0.0
2358
+		 * @param string $kw_tags_msg The message shown under the field.
2359
+		 * @param int $kw_tags_count The character count limit if any.
2360
+		 */
2361
+		$kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
2362 2362
         
2363
-        $tags_class = '';
2364
-        if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
2365
-            /**
2366
-             * Called on the add listing page form for frontend just before the tags field.
2367
-             *
2368
-             * @since 1.0.0
2369
-             */
2370
-            do_action('geodir_before_listing_tags_field');
2371
-        } else {
2372
-            $tags_class = ' hidden';
2373
-        }
2374
-        ?>
2363
+		$tags_class = '';
2364
+		if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
2365
+			/**
2366
+			 * Called on the add listing page form for frontend just before the tags field.
2367
+			 *
2368
+			 * @since 1.0.0
2369
+			 */
2370
+			do_action('geodir_before_listing_tags_field');
2371
+		} else {
2372
+			$tags_class = ' hidden';
2373
+		}
2374
+		?>
2375 2375
         <div id="geodir_post_tags_row" class="geodir_form_row clearfix gd-fieldset-details<?php echo $tags_class;?>">
2376 2376
             <label><?php echo TAGKW_TEXT; ?></label>
2377 2377
             <input name="post_tags" id="post_tags" value="<?php echo $kw_tags; ?>" type="text" class="geodir_textfield"
@@ -2379,90 +2379,90 @@  discard block
 block discarded – undo
2379 2379
             <span class="geodir_message_note"><?php echo $kw_tags_msg;?></span>
2380 2380
         </div>
2381 2381
         <?php
2382
-        if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
2383
-            /**
2384
-             * Called on the add listing page form for frontend just after the tags field.
2385
-             *
2386
-             * @since 1.0.0
2387
-             */
2388
-            do_action('geodir_after_listing_tags_field');
2389
-        }
2382
+		if ($kw_tags_count === '' || (int)$kw_tags_count > 0) {
2383
+			/**
2384
+			 * Called on the add listing page form for frontend just after the tags field.
2385
+			 *
2386
+			 * @since 1.0.0
2387
+			 */
2388
+			do_action('geodir_after_listing_tags_field');
2389
+		}
2390 2390
         
2391
-        $package_info = array();
2392
-        $package_info = geodir_post_package_info($package_info, $post);
2391
+		$package_info = array();
2392
+		$package_info = geodir_post_package_info($package_info, $post);
2393 2393
         
2394
-        geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type);
2394
+		geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type);
2395 2395
         
2396
-        // adjust values here
2397
-        $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2396
+		// adjust values here
2397
+		$id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
2398 2398
 
2399
-        $multiple = true; // allow multiple files upload
2399
+		$multiple = true; // allow multiple files upload
2400 2400
 
2401
-        $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2401
+		$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2402 2402
 
2403
-        $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2403
+		$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2404 2404
 
2405
-        $thumb_img_arr = array();
2406
-        $totImg = 0;
2407
-        if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
2408
-            $post = (object)$gd_session->get('listing');
2409
-            if (isset($post->post_images))
2410
-                $curImages = trim($post->post_images, ",");
2405
+		$thumb_img_arr = array();
2406
+		$totImg = 0;
2407
+		if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
2408
+			$post = (object)$gd_session->get('listing');
2409
+			if (isset($post->post_images))
2410
+				$curImages = trim($post->post_images, ",");
2411 2411
 
2412 2412
 
2413
-            if ($curImages != '') {
2414
-                $curImages_array = explode(',', $curImages);
2415
-                $totImg = count($curImages_array);
2416
-            }
2413
+			if ($curImages != '') {
2414
+				$curImages_array = explode(',', $curImages);
2415
+				$totImg = count($curImages_array);
2416
+			}
2417 2417
 
2418
-            $listing_type = $post->listing_type;
2418
+			$listing_type = $post->listing_type;
2419 2419
 
2420
-        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2421
-            $post = geodir_get_post_info((int)$_REQUEST['pid']);
2422
-            $listing_type = $post->post_type;
2423
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
2420
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2421
+			$post = geodir_get_post_info((int)$_REQUEST['pid']);
2422
+			$listing_type = $post->post_type;
2423
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
2424 2424
 
2425
-        } else {
2426
-            $listing_type = sanitize_text_field($_REQUEST['listing_type']);
2427
-        }
2425
+		} else {
2426
+			$listing_type = sanitize_text_field($_REQUEST['listing_type']);
2427
+		}
2428 2428
 
2429 2429
 
2430
-        if (!empty($thumb_img_arr)) {
2431
-            foreach ($thumb_img_arr as $img) {
2432
-                //$curImages = $img->src.",";
2433
-            }
2434
-
2435
-            $totImg = count((array)$thumb_img_arr);
2436
-        }
2430
+		if (!empty($thumb_img_arr)) {
2431
+			foreach ($thumb_img_arr as $img) {
2432
+				//$curImages = $img->src.",";
2433
+			}
2437 2434
 
2438
-        if ($curImages != '')
2439
-            $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2440
-        else
2441
-            $svalue = '';
2442
-
2443
-        $image_limit = isset($package_info->image_limit) ? $package_info->image_limit : '0';
2444
-        $show_image_input_box = ($image_limit != '0');
2445
-        /**
2446
-         * Filter to be able to show/hide the image upload section of the add listing form.
2447
-         *
2448
-         * @since 1.0.0
2449
-         * @param bool $show_image_input_box Set true to show. Set false to not show.
2450
-         * @param string $listing_type The custom post type slug.
2451
-         */
2452
-        $show_image_input_box = apply_filters('geodir_image_uploader_on_add_listing', $show_image_input_box, $listing_type);
2453
-        if ($show_image_input_box) {
2454
-            ?>
2435
+			$totImg = count((array)$thumb_img_arr);
2436
+		}
2437
+
2438
+		if ($curImages != '')
2439
+			$svalue = $curImages; // this will be initial value of the above form field. Image urls.
2440
+		else
2441
+			$svalue = '';
2442
+
2443
+		$image_limit = isset($package_info->image_limit) ? $package_info->image_limit : '0';
2444
+		$show_image_input_box = ($image_limit != '0');
2445
+		/**
2446
+		 * Filter to be able to show/hide the image upload section of the add listing form.
2447
+		 *
2448
+		 * @since 1.0.0
2449
+		 * @param bool $show_image_input_box Set true to show. Set false to not show.
2450
+		 * @param string $listing_type The custom post type slug.
2451
+		 */
2452
+		$show_image_input_box = apply_filters('geodir_image_uploader_on_add_listing', $show_image_input_box, $listing_type);
2453
+		if ($show_image_input_box) {
2454
+			?>
2455 2455
 
2456 2456
             <h5 id="geodir_form_title_row" class="geodir-form_title"> <?php echo PRO_PHOTO_TEXT;?>
2457 2457
                 <?php if ($image_limit == 1) {
2458
-                    echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2459
-                } ?>
2458
+					echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2459
+				} ?>
2460 2460
                 <?php if ($image_limit > 1) {
2461
-                    echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2462
-                } ?>
2461
+					echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2462
+				} ?>
2463 2463
                 <?php if ($image_limit == '') {
2464
-                    echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2465
-                } ?>
2464
+					echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2465
+				} ?>
2466 2466
             </h5>
2467 2467
 
2468 2468
             <div class="geodir_form_row clearfix" id="<?php echo $id; ?>dropbox"
@@ -2500,12 +2500,12 @@  discard block
 block discarded – undo
2500 2500
         <?php } ?>
2501 2501
 
2502 2502
         <?php
2503
-        /**
2504
-         * Called on the add listing page form for frontend just after the image upload field.
2505
-         *
2506
-         * @since 1.0.0
2507
-         */
2508
-        do_action('geodir_after_main_form_fields');?>
2503
+		/**
2504
+		 * Called on the add listing page form for frontend just after the image upload field.
2505
+		 *
2506
+		 * @since 1.0.0
2507
+		 */
2508
+		do_action('geodir_after_main_form_fields');?>
2509 2509
 
2510 2510
 
2511 2511
         <!-- add captcha code -->
@@ -2534,7 +2534,7 @@  discard block
 block discarded – undo
2534 2534
 
2535 2535
     </form>
2536 2536
     <?php
2537
-    wp_reset_query();
2537
+	wp_reset_query();
2538 2538
 }
2539 2539
 
2540 2540
 /**
@@ -2545,7 +2545,7 @@  discard block
 block discarded – undo
2545 2545
  */
2546 2546
 function geodir_add_listing_sidebar_widget_area()
2547 2547
 {
2548
-    dynamic_sidebar('geodir_add_listing_sidebar');
2548
+	dynamic_sidebar('geodir_add_listing_sidebar');
2549 2549
 }
2550 2550
 
2551 2551
 add_action('geodir_add_listing_sidebar_inside', 'geodir_add_listing_sidebar_widget_area', 10);
@@ -2560,16 +2560,16 @@  discard block
 block discarded – undo
2560 2560
  */
2561 2561
 function geodir_action_add_listing_sidebar()
2562 2562
 {
2563
-    /** This action is documented in geodirectory_template_actions.php */
2564
-    do_action('geodir_sidebar_right_open', 'add-listing-page', 'geodir-sidebar', 'geodir-sidebar-right', 'http://schema.org/WPSideBar');
2565
-    /**
2566
-     * This is used to add the content to the add listing page sidebar.
2567
-     *
2568
-     * @since 1.0.0
2569
-     */
2570
-    do_action('geodir_add_listing_sidebar_inside');
2571
-    /** This action is documented in geodirectory_template_actions.php */
2572
-    do_action('geodir_sidebar_right_close', 'details-page');
2563
+	/** This action is documented in geodirectory_template_actions.php */
2564
+	do_action('geodir_sidebar_right_open', 'add-listing-page', 'geodir-sidebar', 'geodir-sidebar-right', 'http://schema.org/WPSideBar');
2565
+	/**
2566
+	 * This is used to add the content to the add listing page sidebar.
2567
+	 *
2568
+	 * @since 1.0.0
2569
+	 */
2570
+	do_action('geodir_add_listing_sidebar_inside');
2571
+	/** This action is documented in geodirectory_template_actions.php */
2572
+	do_action('geodir_sidebar_right_close', 'details-page');
2573 2573
 }
2574 2574
 
2575 2575
 ###############################################
@@ -2586,11 +2586,11 @@  discard block
 block discarded – undo
2586 2586
  */
2587 2587
 function geodir_action_geodir_sidebar_signup_top()
2588 2588
 {
2589
-    ?>
2589
+	?>
2590 2590
     <div
2591 2591
         class="<?php
2592
-        /** This action is documented in geodirectory_template_actions.php */
2593
-        echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'Reg/Login Top Section'); ?>">
2592
+		/** This action is documented in geodirectory_template_actions.php */
2593
+		echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'Reg/Login Top Section'); ?>">
2594 2594
         <?php dynamic_sidebar('Reg/Login Top Section');?>
2595 2595
     </div><!-- clearfix ends here-->
2596 2596
 <?php
@@ -2609,11 +2609,11 @@  discard block
 block discarded – undo
2609 2609
 function geodir_action_signup_forms()
2610 2610
 {
2611 2611
 
2612
-    global $user_login;
2612
+	global $user_login;
2613 2613
     
2614
-    $is_enable_signup = get_option( 'users_can_register' );
2614
+	$is_enable_signup = get_option( 'users_can_register' );
2615 2615
     
2616
-    ?>
2616
+	?>
2617 2617
     <script type="text/javascript">
2618 2618
         <?php if ( $user_login ) { ?>
2619 2619
         setTimeout(function () {
@@ -2649,67 +2649,67 @@  discard block
 block discarded – undo
2649 2649
         <?php } ?>
2650 2650
     </script><?php
2651 2651
 
2652
-    global $errors;
2653
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'claim')
2654
-        $errors->add('claim_login', LOGIN_CLAIM);
2655
-
2656
-    if (!empty($errors)) {
2657
-        foreach ($errors as $errorsObj) {
2658
-            foreach ($errorsObj as $key => $val) {
2659
-                for ($i = 0; $i < count($val); $i++) {
2660
-                    echo "<div class=error_msg_fix>" . $val[$i] . '</div>';
2661
-                    $registration_error_msg = 1;
2662
-                }
2663
-            }
2664
-        }
2665
-    }
2652
+	global $errors;
2653
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'claim')
2654
+		$errors->add('claim_login', LOGIN_CLAIM);
2655
+
2656
+	if (!empty($errors)) {
2657
+		foreach ($errors as $errorsObj) {
2658
+			foreach ($errorsObj as $key => $val) {
2659
+				for ($i = 0; $i < count($val); $i++) {
2660
+					echo "<div class=error_msg_fix>" . $val[$i] . '</div>';
2661
+					$registration_error_msg = 1;
2662
+				}
2663
+			}
2664
+		}
2665
+	}
2666 2666
 
2667
-    if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_in') {
2668
-        ?>
2667
+	if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_in') {
2668
+		?>
2669 2669
 
2670 2670
         <div class="login_form">
2671 2671
             <?php
2672
-            /**
2673
-             * Contains login form template.
2674
-             *
2675
-             * @since 1.0.0
2676
-             */
2677
-            include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?>
2672
+			/**
2673
+			 * Contains login form template.
2674
+			 *
2675
+			 * @since 1.0.0
2676
+			 */
2677
+			include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?>
2678 2678
         </div>
2679 2679
 
2680 2680
     <?php } elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'login' && isset($_REQUEST['page1']) && $_REQUEST['page1'] == 'sign_up' && $is_enable_signup ) { ?>
2681 2681
 
2682 2682
         <div class="registration_form">
2683 2683
             <?php
2684
-            /**
2685
-             * Contains registration form template.
2686
-             *
2687
-             * @since 1.0.0
2688
-             */
2689
-            include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?>
2684
+			/**
2685
+			 * Contains registration form template.
2686
+			 *
2687
+			 * @since 1.0.0
2688
+			 */
2689
+			include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?>
2690 2690
         </div>
2691 2691
 
2692 2692
     <?php } else { ?>
2693 2693
 
2694 2694
         <div class="login_form_l">
2695 2695
             <?php
2696
-            /**
2697
-             * Contains login form template.
2698
-             *
2699
-             * @since 1.0.0
2700
-             */
2701
-            include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?>
2696
+			/**
2697
+			 * Contains login form template.
2698
+			 *
2699
+			 * @since 1.0.0
2700
+			 */
2701
+			include(geodir_plugin_path() . "/geodirectory-templates/login_frm.php"); ?>
2702 2702
         </div>
2703 2703
         
2704 2704
         <?php if ( $is_enable_signup ) { ?>
2705 2705
             <div class="registration_form_r">
2706 2706
                 <?php
2707
-                /**
2708
-                 * Contains registration form template.
2709
-                 *
2710
-                 * @since 1.0.0
2711
-                 */
2712
-                include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?>
2707
+				/**
2708
+				 * Contains registration form template.
2709
+				 *
2710
+				 * @since 1.0.0
2711
+				 */
2712
+				include(geodir_plugin_path() . "/geodirectory-templates/reg_frm.php"); ?>
2713 2713
             </div>
2714 2714
         <?php } ?>
2715 2715
 
@@ -2741,66 +2741,66 @@  discard block
 block discarded – undo
2741 2741
  */
2742 2742
 function geodir_action_author_page_title()
2743 2743
 {
2744
-    global $term;
2744
+	global $term;
2745 2745
 
2746
-    $gd_post_type = geodir_get_current_posttype();
2747
-    $post_type_info = get_post_type_object($gd_post_type);
2746
+	$gd_post_type = geodir_get_current_posttype();
2747
+	$post_type_info = get_post_type_object($gd_post_type);
2748 2748
 
2749
-    $add_string_in_title = __('All', 'geodirectory') . ' ';
2750
-    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
2751
-        $add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
2752
-    }
2749
+	$add_string_in_title = __('All', 'geodirectory') . ' ';
2750
+	if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite') {
2751
+		$add_string_in_title = __('My Favorite', 'geodirectory') . ' ';
2752
+	}
2753 2753
 
2754
-    $list_title = $add_string_in_title . $post_type_info->labels->name;
2755
-    $single_name = $post_type_info->labels->singular_name;
2754
+	$list_title = $add_string_in_title . $post_type_info->labels->name;
2755
+	$single_name = $post_type_info->labels->singular_name;
2756 2756
 
2757
-    $taxonomy = geodir_get_taxonomies($gd_post_type);
2757
+	$taxonomy = geodir_get_taxonomies($gd_post_type);
2758 2758
 
2759
-    if (!empty($term)) {
2760
-        $current_term = get_term_by('slug', $term, $taxonomy[0]);
2761
-        if (!empty($current_term))
2762
-            $list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
2763
-    }
2759
+	if (!empty($term)) {
2760
+		$current_term = get_term_by('slug', $term, $taxonomy[0]);
2761
+		if (!empty($current_term))
2762
+			$list_title .= __(' in', 'geodirectory') . " '" . geodir_ucwords($current_term->name) . "'";
2763
+	}
2764 2764
 
2765 2765
 
2766
-    if (is_search()) {
2767
-        $list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
2766
+	if (is_search()) {
2767
+		$list_title = __('Search', 'geodirectory') . ' ' . __($post_type_info->labels->name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
2768 2768
 
2769
-    }
2770
-    /** This action is documented in geodirectory_template_actions.php */
2771
-    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
2772
-    /** This action is documented in geodirectory_template_actions.php */
2773
-    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
2769
+	}
2770
+	/** This action is documented in geodirectory_template_actions.php */
2771
+	$class = apply_filters('geodir_page_title_class', 'entry-title fn');
2772
+	/** This action is documented in geodirectory_template_actions.php */
2773
+	$class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
2774 2774
 
2775
-    $title = $list_title;
2776
-    if(geodir_is_page('author')){
2777
-        $gd_page = 'author';
2778
-        if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
2779
-            $title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
2780
-        }else{
2781
-            $title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
2782
-        }
2775
+	$title = $list_title;
2776
+	if(geodir_is_page('author')){
2777
+		$gd_page = 'author';
2778
+		if(isset($_REQUEST['list']) && $_REQUEST['list']=='favourite'){
2779
+			$title = (get_option('geodir_page_title_favorite')) ? get_option('geodir_page_title_favorite') : $title;
2780
+		}else{
2781
+			$title = (get_option('geodir_page_title_author')) ? get_option('geodir_page_title_author') : $title;
2782
+		}
2783 2783
 
2784
-    }
2784
+	}
2785 2785
 
2786 2786
 
2787
-    /**
2788
-     * Filter page title to replace variables.
2789
-     *
2790
-     * @since 1.5.4
2791
-     * @param string $title The page title including variables.
2792
-     * @param string $gd_page The GeoDirectory page type if any.
2793
-     */
2794
-    $title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
2787
+	/**
2788
+	 * Filter page title to replace variables.
2789
+	 *
2790
+	 * @since 1.5.4
2791
+	 * @param string $title The page title including variables.
2792
+	 * @param string $gd_page The GeoDirectory page type if any.
2793
+	 */
2794
+	$title =  apply_filters('geodir_seo_page_title', __($title, 'geodirectory'), $gd_page);
2795 2795
 
2796
-    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
2797
-        /**
2798
-         * Filter the author page title text.
2799
-         *
2800
-         * @since 1.0.0
2801
-         * @param string $list_title The title for the page.
2802
-         */
2803
-        apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
2796
+	echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
2797
+		/**
2798
+		 * Filter the author page title text.
2799
+		 *
2800
+		 * @since 1.0.0
2801
+		 * @param string $list_title The title for the page.
2802
+		 */
2803
+		apply_filters('geodir_author_page_title_text', $title) . '</h1></header>';
2804 2804
 }
2805 2805
 
2806 2806
 
@@ -2818,11 +2818,11 @@  discard block
 block discarded – undo
2818 2818
  */
2819 2819
 function geodir_action_geodir_sidebar_author_top()
2820 2820
 {
2821
-    if (get_option('geodir_show_author_top_section')) { ?>
2821
+	if (get_option('geodir_show_author_top_section')) { ?>
2822 2822
         <div
2823 2823
             class="<?php
2824
-            /** This action is documented in geodirectory_template_actions.php */
2825
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_top'); ?>">
2824
+			/** This action is documented in geodirectory_template_actions.php */
2825
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_top'); ?>">
2826 2826
             <?php dynamic_sidebar('geodir_author_top'); ?>
2827 2827
         </div><!-- clearfix ends here-->
2828 2828
     <?php }
@@ -2838,7 +2838,7 @@  discard block
 block discarded – undo
2838 2838
  */
2839 2839
 function geodir_author_left_section()
2840 2840
 {
2841
-    if (get_option('geodir_show_author_left_section')) { ?>
2841
+	if (get_option('geodir_show_author_left_section')) { ?>
2842 2842
         <div class="geodir-content-left geodir-sidebar-wrap">
2843 2843
             <?php dynamic_sidebar('geodir_author_left_sidebar'); ?>
2844 2844
         </div><!-- end geodir-content-left -->
@@ -2859,19 +2859,19 @@  discard block
 block discarded – undo
2859 2859
  */
2860 2860
 function geodir_action_author_sidebar_left()
2861 2861
 {
2862
-    if (get_option('geodir_show_author_left_section')) {
2862
+	if (get_option('geodir_show_author_left_section')) {
2863 2863
 // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
2864
-        /** This action is documented in geodirectory_template_actions.php */
2865
-        do_action('geodir_sidebar_left_open', 'author-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
2866
-        /**
2867
-         * This is used to add the content to the author page left sidebar (if active).
2868
-         *
2869
-         * @since 1.0.0
2870
-         */
2871
-        do_action('geodir_author_sidebar_left_inside');
2872
-        /** This action is documented in geodirectory_template_actions.php */
2873
-        do_action('geodir_sidebar_left_close', 'author-page');
2874
-    }
2864
+		/** This action is documented in geodirectory_template_actions.php */
2865
+		do_action('geodir_sidebar_left_open', 'author-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
2866
+		/**
2867
+		 * This is used to add the content to the author page left sidebar (if active).
2868
+		 *
2869
+		 * @since 1.0.0
2870
+		 */
2871
+		do_action('geodir_author_sidebar_left_inside');
2872
+		/** This action is documented in geodirectory_template_actions.php */
2873
+		do_action('geodir_sidebar_left_close', 'author-page');
2874
+	}
2875 2875
 }
2876 2876
 
2877 2877
 /**
@@ -2884,7 +2884,7 @@  discard block
 block discarded – undo
2884 2884
  */
2885 2885
 function geodir_author_right_section()
2886 2886
 {
2887
-    if (get_option('geodir_show_author_right_section')) { ?>
2887
+	if (get_option('geodir_show_author_right_section')) { ?>
2888 2888
         <div class="geodir-content-right geodir-sidebar-wrap">
2889 2889
             <?php dynamic_sidebar('geodir_author_right_sidebar'); ?>
2890 2890
         </div><!-- end geodir-content-right -->
@@ -2904,18 +2904,18 @@  discard block
 block discarded – undo
2904 2904
  */
2905 2905
 function geodir_action_author_sidebar_right()
2906 2906
 {
2907
-    if (get_option('geodir_show_author_right_section')) {
2908
-        /** This action is documented in geodirectory_template_actions.php */
2909
-        do_action('geodir_sidebar_right_open', 'author-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
2910
-        /**
2911
-         * This is used to add the content to the author page right sidebar (if active).
2912
-         *
2913
-         * @since 1.0.0
2914
-         */
2915
-        do_action('geodir_author_sidebar_right_inside');
2916
-        /** This action is documented in geodirectory_template_actions.php */
2917
-        do_action('geodir_sidebar_right_close', 'author-page');
2918
-    }
2907
+	if (get_option('geodir_show_author_right_section')) {
2908
+		/** This action is documented in geodirectory_template_actions.php */
2909
+		do_action('geodir_sidebar_right_open', 'author-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
2910
+		/**
2911
+		 * This is used to add the content to the author page right sidebar (if active).
2912
+		 *
2913
+		 * @since 1.0.0
2914
+		 */
2915
+		do_action('geodir_author_sidebar_right_inside');
2916
+		/** This action is documented in geodirectory_template_actions.php */
2917
+		do_action('geodir_sidebar_right_close', 'author-page');
2918
+	}
2919 2919
 }
2920 2920
 
2921 2921
 /**
@@ -2927,14 +2927,14 @@  discard block
 block discarded – undo
2927 2927
  */
2928 2928
 function geodir_action_author_content_inside()
2929 2929
 {
2930
-    global $gridview_columns;
2931
-    $listing_view = get_option('geodir_author_view');
2932
-    if (strstr($listing_view, 'gridview')) {
2933
-        $gridview_columns = $listing_view;
2934
-        $listing_view_exp = explode('_', $listing_view);
2935
-        $listing_view = $listing_view_exp[0];
2936
-    }
2937
-    geodir_get_template_part('listing', 'listview');
2930
+	global $gridview_columns;
2931
+	$listing_view = get_option('geodir_author_view');
2932
+	if (strstr($listing_view, 'gridview')) {
2933
+		$gridview_columns = $listing_view;
2934
+		$listing_view_exp = explode('_', $listing_view);
2935
+		$listing_view = $listing_view_exp[0];
2936
+	}
2937
+	geodir_get_template_part('listing', 'listview');
2938 2938
 }
2939 2939
 
2940 2940
 add_action('geodir_author_content_inside', 'geodir_action_author_content_inside', 10);
@@ -2949,22 +2949,22 @@  discard block
 block discarded – undo
2949 2949
  */
2950 2950
 function geodir_action_author_content()
2951 2951
 {
2952
-    /** This action is documented in geodirectory_template_actions.php */
2953
-    do_action('geodir_main_content_open', 'author-page', 'geodir-main-content', 'author-page');
2954
-    echo '<div class="clearfix">';
2955
-    /** This action is documented in geodirectory_template_actions.php */
2956
-    do_action('geodir_before_listing');
2957
-    echo '</div>';
2958
-    /**
2959
-     * This is used to add the content to the author page main content.
2960
-     *
2961
-     * @since 1.0.0
2962
-     */
2963
-    do_action('geodir_author_content_inside');
2964
-    /** This action is documented in geodirectory_template_actions.php */
2965
-    do_action('geodir_after_listing');
2966
-    /** This action is documented in geodirectory_template_actions.php */
2967
-    do_action('geodir_main_content_close', 'author-page');
2952
+	/** This action is documented in geodirectory_template_actions.php */
2953
+	do_action('geodir_main_content_open', 'author-page', 'geodir-main-content', 'author-page');
2954
+	echo '<div class="clearfix">';
2955
+	/** This action is documented in geodirectory_template_actions.php */
2956
+	do_action('geodir_before_listing');
2957
+	echo '</div>';
2958
+	/**
2959
+	 * This is used to add the content to the author page main content.
2960
+	 *
2961
+	 * @since 1.0.0
2962
+	 */
2963
+	do_action('geodir_author_content_inside');
2964
+	/** This action is documented in geodirectory_template_actions.php */
2965
+	do_action('geodir_after_listing');
2966
+	/** This action is documented in geodirectory_template_actions.php */
2967
+	do_action('geodir_main_content_close', 'author-page');
2968 2968
 }
2969 2969
 
2970 2970
 add_action('geodir_sidebar_author_bottom_section', 'geodir_action_sidebar_author_bottom_section', 10);
@@ -2978,11 +2978,11 @@  discard block
 block discarded – undo
2978 2978
  */
2979 2979
 function geodir_action_sidebar_author_bottom_section()
2980 2980
 {
2981
-    if (get_option('geodir_show_author_bottom_section')) { ?>
2981
+	if (get_option('geodir_show_author_bottom_section')) { ?>
2982 2982
         <div
2983 2983
             class="<?php
2984
-            /** This action is documented in geodirectory_template_actions.php */
2985
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_bottom'); ?>">
2984
+			/** This action is documented in geodirectory_template_actions.php */
2985
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_author_bottom'); ?>">
2986 2986
             <?php dynamic_sidebar('geodir_author_bottom'); ?>
2987 2987
         </div><!-- clearfix ends here-->
2988 2988
     <?php }
@@ -3001,23 +3001,23 @@  discard block
 block discarded – undo
3001 3001
  */
3002 3002
 function geodir_action_search_page_title()
3003 3003
 {
3004
-    $gd_post_type = geodir_get_current_posttype();
3005
-    $post_type_info = get_post_type_object($gd_post_type);
3004
+	$gd_post_type = geodir_get_current_posttype();
3005
+	$post_type_info = get_post_type_object($gd_post_type);
3006 3006
 
3007
-    $pt_name = '';
3008
-    if(isset($post_type_info->labels->name)){$pt_name=$post_type_info->labels->name;}
3007
+	$pt_name = '';
3008
+	if(isset($post_type_info->labels->name)){$pt_name=$post_type_info->labels->name;}
3009 3009
 
3010
-    if (is_search()) {
3011
-        $list_title = __('Search', 'geodirectory') . ' ' . __($pt_name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
3010
+	if (is_search()) {
3011
+		$list_title = __('Search', 'geodirectory') . ' ' . __($pt_name, 'geodirectory') . __(' For :', 'geodirectory') . " '" . get_search_query() . "'";
3012 3012
 
3013
-    }
3014
-    /** This action is documented in geodirectory_template_actions.php */
3015
-    $class = apply_filters('geodir_page_title_class', 'entry-title fn');
3016
-    /** This action is documented in geodirectory_template_actions.php */
3017
-    $class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
3018
-    echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
3019
-        /** This action is documented in geodirectory_template_actions.php */
3020
-        apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
3013
+	}
3014
+	/** This action is documented in geodirectory_template_actions.php */
3015
+	$class = apply_filters('geodir_page_title_class', 'entry-title fn');
3016
+	/** This action is documented in geodirectory_template_actions.php */
3017
+	$class_header = apply_filters('geodir_page_title_header_class', 'entry-header');
3018
+	echo '<header class="' . $class_header . '"><h1 class="' . $class . '">' .
3019
+		/** This action is documented in geodirectory_template_actions.php */
3020
+		apply_filters('geodir_listing_page_title', wptexturize($list_title)) . '</h1></header>';
3021 3021
 }
3022 3022
 
3023 3023
 // action for adding the listings page top widget area
@@ -3033,11 +3033,11 @@  discard block
 block discarded – undo
3033 3033
  */
3034 3034
 function geodir_action_geodir_sidebar_search_top()
3035 3035
 {
3036
-    if (get_option('geodir_show_search_top_section')) { ?>
3036
+	if (get_option('geodir_show_search_top_section')) { ?>
3037 3037
         <div
3038 3038
             class="<?php
3039
-            /** This action is documented in geodirectory_template_actions.php */
3040
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_top'); ?>">
3039
+			/** This action is documented in geodirectory_template_actions.php */
3040
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_top'); ?>">
3041 3041
             <?php dynamic_sidebar('geodir_search_top'); ?>
3042 3042
         </div><!-- clearfix ends here-->
3043 3043
     <?php }
@@ -3053,7 +3053,7 @@  discard block
 block discarded – undo
3053 3053
  */
3054 3054
 function geodir_search_left_section()
3055 3055
 {
3056
-    if (get_option('geodir_show_search_left_section')) { ?>
3056
+	if (get_option('geodir_show_search_left_section')) { ?>
3057 3057
         <div class="geodir-content-left geodir-sidebar-wrap">
3058 3058
             <?php dynamic_sidebar('geodir_search_left_sidebar'); ?>
3059 3059
         </div><!-- end geodir-content-left -->
@@ -3073,19 +3073,19 @@  discard block
 block discarded – undo
3073 3073
  */
3074 3074
 function geodir_action_search_sidebar_left()
3075 3075
 {
3076
-    if (get_option('geodir_show_search_left_section')) {
3076
+	if (get_option('geodir_show_search_left_section')) {
3077 3077
 // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
3078
-        /** This action is documented in geodirectory_template_actions.php */
3079
-        do_action('geodir_sidebar_left_open', 'search-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
3080
-        /**
3081
-         * This is used to add the content to the search page left sidebar (if active).
3082
-         *
3083
-         * @since 1.0.0
3084
-         */
3085
-        do_action('geodir_search_sidebar_left_inside');
3086
-        /** This action is documented in geodirectory_template_actions.php */
3087
-        do_action('geodir_sidebar_left_close', 'search-page');
3088
-    }
3078
+		/** This action is documented in geodirectory_template_actions.php */
3079
+		do_action('geodir_sidebar_left_open', 'search-page', 'geodir-sidebar-left', 'geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
3080
+		/**
3081
+		 * This is used to add the content to the search page left sidebar (if active).
3082
+		 *
3083
+		 * @since 1.0.0
3084
+		 */
3085
+		do_action('geodir_search_sidebar_left_inside');
3086
+		/** This action is documented in geodirectory_template_actions.php */
3087
+		do_action('geodir_sidebar_left_close', 'search-page');
3088
+	}
3089 3089
 }
3090 3090
 
3091 3091
 /**
@@ -3098,7 +3098,7 @@  discard block
 block discarded – undo
3098 3098
  */
3099 3099
 function geodir_search_right_section()
3100 3100
 {
3101
-    if (get_option('geodir_show_search_right_section')) { ?>
3101
+	if (get_option('geodir_show_search_right_section')) { ?>
3102 3102
         <div class="geodir-content-right geodir-sidebar-wrap">
3103 3103
             <?php dynamic_sidebar('geodir_search_right_sidebar'); ?>
3104 3104
         </div><!-- end geodir-content-right -->
@@ -3118,18 +3118,18 @@  discard block
 block discarded – undo
3118 3118
  */
3119 3119
 function geodir_action_search_sidebar_right()
3120 3120
 {
3121
-    if (get_option('geodir_show_search_right_section')) {
3122
-        /** This action is documented in geodirectory_template_actions.php */
3123
-        do_action('geodir_sidebar_right_open', 'search-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
3124
-        /**
3125
-         * This is used to add the content to the search page right sidebar (if active).
3126
-         *
3127
-         * @since 1.0.0
3128
-         */
3129
-        do_action('geodir_search_sidebar_right_inside');
3130
-        /** This action is documented in geodirectory_template_actions.php */
3131
-        do_action('geodir_sidebar_right_close', 'search-page');
3132
-    }
3121
+	if (get_option('geodir_show_search_right_section')) {
3122
+		/** This action is documented in geodirectory_template_actions.php */
3123
+		do_action('geodir_sidebar_right_open', 'search-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
3124
+		/**
3125
+		 * This is used to add the content to the search page right sidebar (if active).
3126
+		 *
3127
+		 * @since 1.0.0
3128
+		 */
3129
+		do_action('geodir_search_sidebar_right_inside');
3130
+		/** This action is documented in geodirectory_template_actions.php */
3131
+		do_action('geodir_sidebar_right_close', 'search-page');
3132
+	}
3133 3133
 }
3134 3134
 
3135 3135
 
@@ -3144,11 +3144,11 @@  discard block
 block discarded – undo
3144 3144
  */
3145 3145
 function geodir_action_sidebar_search_bottom_section()
3146 3146
 {
3147
-    if (get_option('geodir_show_search_bottom_section')) { ?>
3147
+	if (get_option('geodir_show_search_bottom_section')) { ?>
3148 3148
         <div
3149 3149
             class="<?php
3150
-            /** This action is documented in geodirectory_template_actions.php */
3151
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_bottom'); ?>">
3150
+			/** This action is documented in geodirectory_template_actions.php */
3151
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_search_bottom'); ?>">
3152 3152
             <?php dynamic_sidebar('geodir_search_bottom'); ?>
3153 3153
         </div><!-- clearfix ends here-->
3154 3154
     <?php }
@@ -3163,14 +3163,14 @@  discard block
 block discarded – undo
3163 3163
  */
3164 3164
 function geodir_action_search_content_inside()
3165 3165
 {
3166
-    global $gridview_columns;
3167
-    $listing_view = get_option('geodir_search_view');
3168
-    if (strstr($listing_view, 'gridview')) {
3169
-        $gridview_columns = $listing_view;
3170
-        $listing_view_exp = explode('_', $listing_view);
3171
-        $listing_view = $listing_view_exp[0];
3172
-    }
3173
-    geodir_get_template_part('listing', 'listview');
3166
+	global $gridview_columns;
3167
+	$listing_view = get_option('geodir_search_view');
3168
+	if (strstr($listing_view, 'gridview')) {
3169
+		$gridview_columns = $listing_view;
3170
+		$listing_view_exp = explode('_', $listing_view);
3171
+		$listing_view = $listing_view_exp[0];
3172
+	}
3173
+	geodir_get_template_part('listing', 'listview');
3174 3174
 }
3175 3175
 
3176 3176
 add_action('geodir_search_content_inside', 'geodir_action_search_content_inside', 10);
@@ -3186,22 +3186,22 @@  discard block
 block discarded – undo
3186 3186
  */
3187 3187
 function geodir_action_search_content()
3188 3188
 {
3189
-    /** This action is documented in geodirectory_template_actions.php */
3190
-    do_action('geodir_main_content_open', 'search-page', 'geodir-main-content', 'search-page');
3191
-    echo '<div class="clearfix">';
3192
-    /** This action is documented in geodirectory_template_actions.php */
3193
-    do_action('geodir_before_listing');
3194
-    echo '</div>';
3195
-    /**
3196
-     * This is used to add the content to the search page main content.
3197
-     *
3198
-     * @since 1.0.0
3199
-     */
3200
-    do_action('geodir_search_content_inside');
3201
-    /** This action is documented in geodirectory_template_actions.php */
3202
-    do_action('geodir_after_listing');
3203
-    /** This action is documented in geodirectory_template_actions.php */
3204
-    do_action('geodir_main_content_close', 'search-page');
3189
+	/** This action is documented in geodirectory_template_actions.php */
3190
+	do_action('geodir_main_content_open', 'search-page', 'geodir-main-content', 'search-page');
3191
+	echo '<div class="clearfix">';
3192
+	/** This action is documented in geodirectory_template_actions.php */
3193
+	do_action('geodir_before_listing');
3194
+	echo '</div>';
3195
+	/**
3196
+	 * This is used to add the content to the search page main content.
3197
+	 *
3198
+	 * @since 1.0.0
3199
+	 */
3200
+	do_action('geodir_search_content_inside');
3201
+	/** This action is documented in geodirectory_template_actions.php */
3202
+	do_action('geodir_after_listing');
3203
+	/** This action is documented in geodirectory_template_actions.php */
3204
+	do_action('geodir_main_content_close', 'search-page');
3205 3205
 }
3206 3206
 
3207 3207
 ###############################################
@@ -3224,11 +3224,11 @@  discard block
 block discarded – undo
3224 3224
  */
3225 3225
 function geodir_action_geodir_sidebar_home_top()
3226 3226
 {
3227
-    if (get_option('geodir_show_home_top_section')) { ?>
3227
+	if (get_option('geodir_show_home_top_section')) { ?>
3228 3228
         <div
3229 3229
             class="<?php
3230
-            /** This action is documented in geodirectory_template_actions.php */
3231
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_top'); ?>">
3230
+			/** This action is documented in geodirectory_template_actions.php */
3231
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_top'); ?>">
3232 3232
             <?php dynamic_sidebar('geodir_home_top'); ?>
3233 3233
         </div><!-- clearfix ends here-->
3234 3234
     <?php }
@@ -3244,7 +3244,7 @@  discard block
 block discarded – undo
3244 3244
  */
3245 3245
 function geodir_home_left_section()
3246 3246
 {
3247
-    if (get_option('geodir_show_home_left_section')) { ?>
3247
+	if (get_option('geodir_show_home_left_section')) { ?>
3248 3248
         <div class="geodir-content-left geodir-sidebar-wrap">
3249 3249
             <?php dynamic_sidebar('geodir_home_left'); ?>
3250 3250
         </div><!-- end geodir-content-left -->
@@ -3266,19 +3266,19 @@  discard block
 block discarded – undo
3266 3266
  */
3267 3267
 function geodir_action_home_sidebar_left()
3268 3268
 {
3269
-    if (get_option('geodir_show_home_left_section')) {
3269
+	if (get_option('geodir_show_home_left_section')) {
3270 3270
 // this adds the opening html tags to the primary div, this required the closing tag below :: ($type='',$id='',$class='',$itemtype='')
3271
-        /** This action is documented in geodirectory_template_actions.php */
3272
-        do_action('geodir_sidebar_left_open', 'home-page', 'geodir-sidebar-left', 'geodir-sidebar geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
3273
-        /**
3274
-         * This is used to add the content to the home page left sidebar (if active).
3275
-         *
3276
-         * @since 1.0.0
3277
-         */
3278
-        do_action('geodir_home_sidebar_left_inside');
3279
-        /** This action is documented in geodirectory_template_actions.php */
3280
-        do_action('geodir_sidebar_left_close', 'home-page');
3281
-    }
3271
+		/** This action is documented in geodirectory_template_actions.php */
3272
+		do_action('geodir_sidebar_left_open', 'home-page', 'geodir-sidebar-left', 'geodir-sidebar geodir-sidebar-left geodir-listings-sidebar-left', 'http://schema.org/WPSideBar');
3273
+		/**
3274
+		 * This is used to add the content to the home page left sidebar (if active).
3275
+		 *
3276
+		 * @since 1.0.0
3277
+		 */
3278
+		do_action('geodir_home_sidebar_left_inside');
3279
+		/** This action is documented in geodirectory_template_actions.php */
3280
+		do_action('geodir_sidebar_left_close', 'home-page');
3281
+	}
3282 3282
 }
3283 3283
 
3284 3284
 /**
@@ -3291,7 +3291,7 @@  discard block
 block discarded – undo
3291 3291
  */
3292 3292
 function geodir_home_right_section()
3293 3293
 {
3294
-    if (get_option('geodir_show_home_right_section')) { ?>
3294
+	if (get_option('geodir_show_home_right_section')) { ?>
3295 3295
         <div class="geodir-content-right geodir-sidebar-wrap">
3296 3296
             <?php dynamic_sidebar('geodir_home_right'); ?>
3297 3297
         </div><!-- end geodir-content-right -->
@@ -3312,18 +3312,18 @@  discard block
 block discarded – undo
3312 3312
  */
3313 3313
 function geodir_action_home_sidebar_right()
3314 3314
 {
3315
-    if (get_option('geodir_show_home_right_section')) {
3316
-        /** This action is documented in geodirectory_template_actions.php */
3317
-        do_action('geodir_sidebar_right_open', 'home-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
3318
-        /**
3319
-         * This is used to add the content to the home page right sidebar (if active).
3320
-         *
3321
-         * @since 1.0.0
3322
-         */
3323
-        do_action('geodir_home_sidebar_right_inside');
3324
-        /** This action is documented in geodirectory_template_actions.php */
3325
-        do_action('geodir_sidebar_right_close', 'home-page');
3326
-    }
3315
+	if (get_option('geodir_show_home_right_section')) {
3316
+		/** This action is documented in geodirectory_template_actions.php */
3317
+		do_action('geodir_sidebar_right_open', 'home-page', 'geodir-sidebar-right', 'geodir-sidebar-right geodir-listings-sidebar-right', 'http://schema.org/WPSideBar');
3318
+		/**
3319
+		 * This is used to add the content to the home page right sidebar (if active).
3320
+		 *
3321
+		 * @since 1.0.0
3322
+		 */
3323
+		do_action('geodir_home_sidebar_right_inside');
3324
+		/** This action is documented in geodirectory_template_actions.php */
3325
+		do_action('geodir_sidebar_right_close', 'home-page');
3326
+	}
3327 3327
 }
3328 3328
 
3329 3329
 /**
@@ -3334,7 +3334,7 @@  discard block
 block discarded – undo
3334 3334
  */
3335 3335
 function geodir_action_home_content_inside()
3336 3336
 {
3337
-    dynamic_sidebar('geodir_home_content');
3337
+	dynamic_sidebar('geodir_home_content');
3338 3338
 }
3339 3339
 
3340 3340
 add_action('geodir_home_content_inside', 'geodir_action_home_content_inside', 10);
@@ -3349,28 +3349,28 @@  discard block
 block discarded – undo
3349 3349
  */
3350 3350
 function geodir_action_home_content()
3351 3351
 {
3352
-    /** This action is documented in geodirectory_template_actions.php */
3353
-    do_action('geodir_main_content_open', 'home-page', 'geodir-main-content', 'home-page');
3354
-    /**
3355
-     * This called before the home page main content.
3356
-     *
3357
-     * @since 1.0.0
3358
-     */
3359
-    do_action('geodir_before_home_content');
3360
-    /**
3361
-     * This is used to add the content to the home page main content.
3362
-     *
3363
-     * @since 1.0.0
3364
-     */
3365
-    do_action('geodir_home_content_inside');
3366
-    /**
3367
-     * This is called after the homepage main content.
3368
-     *
3369
-     * @since 1.0.0
3370
-     */
3371
-    do_action('geodir_after_home_content');
3372
-    /** This action is documented in geodirectory_template_actions.php */
3373
-    do_action('geodir_main_content_close', 'home-page');
3352
+	/** This action is documented in geodirectory_template_actions.php */
3353
+	do_action('geodir_main_content_open', 'home-page', 'geodir-main-content', 'home-page');
3354
+	/**
3355
+	 * This called before the home page main content.
3356
+	 *
3357
+	 * @since 1.0.0
3358
+	 */
3359
+	do_action('geodir_before_home_content');
3360
+	/**
3361
+	 * This is used to add the content to the home page main content.
3362
+	 *
3363
+	 * @since 1.0.0
3364
+	 */
3365
+	do_action('geodir_home_content_inside');
3366
+	/**
3367
+	 * This is called after the homepage main content.
3368
+	 *
3369
+	 * @since 1.0.0
3370
+	 */
3371
+	do_action('geodir_after_home_content');
3372
+	/** This action is documented in geodirectory_template_actions.php */
3373
+	do_action('geodir_main_content_close', 'home-page');
3374 3374
 }
3375 3375
 
3376 3376
 add_action('geodir_sidebar_location_bottom_section', 'geodir_action_sidebar_home_bottom_section', 10);
@@ -3385,11 +3385,11 @@  discard block
 block discarded – undo
3385 3385
  */
3386 3386
 function geodir_action_sidebar_home_bottom_section()
3387 3387
 {
3388
-    if (get_option('geodir_show_home_bottom_section')) { ?>
3388
+	if (get_option('geodir_show_home_bottom_section')) { ?>
3389 3389
         <div
3390 3390
             class="<?php
3391
-            /** This action is documented in geodirectory_template_actions.php */
3392
-            echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_bottom'); ?>">
3391
+			/** This action is documented in geodirectory_template_actions.php */
3392
+			echo apply_filters('geodir_full_page_class', 'geodir_full_page clearfix', 'geodir_home_bottom'); ?>">
3393 3393
             <?php dynamic_sidebar('geodir_home_bottom'); ?>
3394 3394
         </div><!-- clearfix ends here-->
3395 3395
     <?php }
@@ -3417,13 +3417,13 @@  discard block
 block discarded – undo
3417 3417
  */
3418 3418
 function geodir_filter_listing_page_title($list_title)
3419 3419
 {
3420
-    if (is_search() && trim(get_search_query()) == '') {
3421
-        $gd_post_type = geodir_get_current_posttype();
3422
-        $post_type_info = get_post_type_object($gd_post_type);
3420
+	if (is_search() && trim(get_search_query()) == '') {
3421
+		$gd_post_type = geodir_get_current_posttype();
3422
+		$post_type_info = get_post_type_object($gd_post_type);
3423 3423
 
3424
-        $list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' :', 'geodirectory');
3425
-    }
3426
-    return $list_title;
3424
+		$list_title = __('Search', 'geodirectory') . ' ' . __(geodir_utf8_ucfirst($post_type_info->labels->name), 'geodirectory') . __(' :', 'geodirectory');
3425
+	}
3426
+	return $list_title;
3427 3427
 }
3428 3428
 
3429 3429
 add_action('geodir_message_not_found_on_listing', 'geodir_display_message_not_found_on_listing');
@@ -3438,62 +3438,62 @@  discard block
 block discarded – undo
3438 3438
  * @param string $gd_page The geodirectory page type. Default null.
3439 3439
  */
3440 3440
 function geodir_add_page_content( $position = 'before', $gd_page = '' ) {
3441
-    global $post;
3442
-
3443
-    $gd_page_id = NULL;
3444
-    if ($gd_page == 'home-page' && geodir_is_page('home')) {
3445
-        $gd_page_id = geodir_home_page_id();
3446
-    } else if ($gd_page == 'details-page' && geodir_is_page('preview')) {
3447
-        $gd_page_id = geodir_preview_page_id();
3448
-    } else if ($gd_page == 'add-listing-page' && geodir_is_page('add-listing')) {
3449
-        $gd_page_id = geodir_add_listing_page_id();
3450
-    } else if ($gd_page == 'success-page' && geodir_is_page('listing-success')) {
3451
-        $gd_page_id = geodir_success_page_id();
3452
-    } else if ($gd_page == 'location-page' && geodir_is_page('location')) {
3453
-        $gd_page_id = geodir_location_page_id();
3454
-    } else if ($gd_page == 'info-page' && geodir_is_page('info')) {
3455
-        $gd_page_id = geodir_info_page_id();
3456
-    } else if ($gd_page == 'signup-page' && geodir_is_page('login')) {
3457
-        $gd_page_id = geodir_login_page_id();
3458
-    } else if ($gd_page == 'checkout-page' && geodir_is_page('checkout')) {
3459
-        $gd_page_id = geodir_payment_checkout_page_id();
3460
-    } else if ($gd_page == 'invoices-page' && geodir_is_page('invoices')) {
3461
-        $gd_page_id = geodir_payment_invoices_page_id();
3462
-    }
3463
-
3464
-    if (!$gd_page_id > 0) {
3465
-        return;
3466
-    }
3441
+	global $post;
3442
+
3443
+	$gd_page_id = NULL;
3444
+	if ($gd_page == 'home-page' && geodir_is_page('home')) {
3445
+		$gd_page_id = geodir_home_page_id();
3446
+	} else if ($gd_page == 'details-page' && geodir_is_page('preview')) {
3447
+		$gd_page_id = geodir_preview_page_id();
3448
+	} else if ($gd_page == 'add-listing-page' && geodir_is_page('add-listing')) {
3449
+		$gd_page_id = geodir_add_listing_page_id();
3450
+	} else if ($gd_page == 'success-page' && geodir_is_page('listing-success')) {
3451
+		$gd_page_id = geodir_success_page_id();
3452
+	} else if ($gd_page == 'location-page' && geodir_is_page('location')) {
3453
+		$gd_page_id = geodir_location_page_id();
3454
+	} else if ($gd_page == 'info-page' && geodir_is_page('info')) {
3455
+		$gd_page_id = geodir_info_page_id();
3456
+	} else if ($gd_page == 'signup-page' && geodir_is_page('login')) {
3457
+		$gd_page_id = geodir_login_page_id();
3458
+	} else if ($gd_page == 'checkout-page' && geodir_is_page('checkout')) {
3459
+		$gd_page_id = geodir_payment_checkout_page_id();
3460
+	} else if ($gd_page == 'invoices-page' && geodir_is_page('invoices')) {
3461
+		$gd_page_id = geodir_payment_invoices_page_id();
3462
+	}
3463
+
3464
+	if (!$gd_page_id > 0) {
3465
+		return;
3466
+	}
3467 3467
     
3468
-    $display = 'before';
3469
-    /**
3470
-     * Filter the position to display the page content.
3471
-     *
3472
-     * @since 1.6.3
3473
-     *
3474
-     * @param string $display Position to add the post content.
3475
-     * @param string $gd_page The geodirectory page type.
3476
-     */
3477
-    $display = apply_filters('geodir_add_page_content_position', $display, $gd_page);
3478
-
3479
-    if ($position !== $display) {
3480
-        return;
3481
-    }
3482
-
3483
-    $gd_post = $post;
3468
+	$display = 'before';
3469
+	/**
3470
+	 * Filter the position to display the page content.
3471
+	 *
3472
+	 * @since 1.6.3
3473
+	 *
3474
+	 * @param string $display Position to add the post content.
3475
+	 * @param string $gd_page The geodirectory page type.
3476
+	 */
3477
+	$display = apply_filters('geodir_add_page_content_position', $display, $gd_page);
3478
+
3479
+	if ($position !== $display) {
3480
+		return;
3481
+	}
3482
+
3483
+	$gd_post = $post;
3484 3484
     
3485
-    setup_postdata(get_post($gd_page_id));
3485
+	setup_postdata(get_post($gd_page_id));
3486 3486
 
3487
-    if (get_the_content()) {
3488
-        ?>
3487
+	if (get_the_content()) {
3488
+		?>
3489 3489
         <section class="entry-content clearfix" itemprop="articleBody"><?php the_content(); ?></section>
3490 3490
         <?php
3491
-    }
3491
+	}
3492 3492
 
3493
-    $post = $gd_post;
3494
-    if (!empty($gd_post) && is_object($gd_post)) {
3495
-        setup_postdata($gd_post);
3496
-    }
3493
+	$post = $gd_post;
3494
+	if (!empty($gd_post) && is_object($gd_post)) {
3495
+		setup_postdata($gd_post);
3496
+	}
3497 3497
 
3498 3498
 }
3499 3499
 add_action('geodir_add_page_content', 'geodir_add_page_content', 10, 2);
@@ -3514,13 +3514,13 @@  discard block
 block discarded – undo
3514 3514
  * @return string Filtered SQL JOIN clause.
3515 3515
  */
3516 3516
 function geodir_previous_next_post_join( $join, $in_same_term, $excluded_terms, $taxonomy, $post ) {
3517
-    global $plugin_prefix;
3517
+	global $plugin_prefix;
3518 3518
 
3519
-    if ( !empty($post->post_type) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
3520
-        $join .= " INNER JOIN " . $plugin_prefix . $post->post_type . "_detail AS gd ON gd.post_id = p.ID";
3521
-    }
3519
+	if ( !empty($post->post_type) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
3520
+		$join .= " INNER JOIN " . $plugin_prefix . $post->post_type . "_detail AS gd ON gd.post_id = p.ID";
3521
+	}
3522 3522
     
3523
-    return $join;
3523
+	return $join;
3524 3524
 }
3525 3525
 add_filter( 'get_previous_post_join', 'geodir_previous_next_post_join', 10, 5 );
3526 3526
 add_filter( 'get_next_post_join', 'geodir_previous_next_post_join', 10, 5 );
@@ -3542,31 +3542,31 @@  discard block
 block discarded – undo
3542 3542
  * @return string Filtered SQL WHERE clause.
3543 3543
  */
3544 3544
 function geodir_previous_next_post_where( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) {
3545
-    global $wpdb, $plugin_prefix;
3545
+	global $wpdb, $plugin_prefix;
3546 3546
 
3547
-    if ( !empty($post->post_type) && ( !empty( $post->country_slug ) || !empty( $post->region_slug ) || !empty( $post->city_slug ) ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
3548
-        $post_locations = '';
3549
-        $post_locations_var = array();
3547
+	if ( !empty($post->post_type) && ( !empty( $post->country_slug ) || !empty( $post->region_slug ) || !empty( $post->city_slug ) ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
3548
+		$post_locations = '';
3549
+		$post_locations_var = array();
3550 3550
         
3551
-        if ( !empty( $post->country_slug ) ) {
3552
-            $post_locations .= " AND post_locations LIKE %s";
3553
-            $post_locations_var[] = "%,[" . $post->country_slug . "]";
3554
-        }
3555
-
3556
-        if ( !empty( $post->region_slug ) ) {
3557
-            $post_locations .= " AND post_locations LIKE %s";
3558
-            $post_locations_var[] = "%,[" . $post->region_slug . "],%";
3559
-        }
3560
-
3561
-        if ( !empty( $post->city_slug ) ) {
3562
-            $post_locations .= " AND post_locations LIKE %s";
3563
-            $post_locations_var[] = "[" . $post->city_slug . "],%";
3564
-        }
3551
+		if ( !empty( $post->country_slug ) ) {
3552
+			$post_locations .= " AND post_locations LIKE %s";
3553
+			$post_locations_var[] = "%,[" . $post->country_slug . "]";
3554
+		}
3555
+
3556
+		if ( !empty( $post->region_slug ) ) {
3557
+			$post_locations .= " AND post_locations LIKE %s";
3558
+			$post_locations_var[] = "%,[" . $post->region_slug . "],%";
3559
+		}
3560
+
3561
+		if ( !empty( $post->city_slug ) ) {
3562
+			$post_locations .= " AND post_locations LIKE %s";
3563
+			$post_locations_var[] = "[" . $post->city_slug . "],%";
3564
+		}
3565 3565
         
3566
-        $where .= $wpdb->prepare( $post_locations, $post_locations_var );
3567
-    }
3566
+		$where .= $wpdb->prepare( $post_locations, $post_locations_var );
3567
+	}
3568 3568
     
3569
-    return $where;
3569
+	return $where;
3570 3570
 }
3571 3571
 add_filter( 'get_previous_post_where', 'geodir_previous_next_post_where', 10, 5 );
3572 3572
 add_filter( 'get_next_post_where', 'geodir_previous_next_post_where', 10, 5 );
3573 3573
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/cat-meta-functions/cat_meta.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -11,142 +11,142 @@  discard block
 block discarded – undo
11 11
 //include the main class file
12 12
 require_once("Tax-meta-class.php");
13 13
 if (is_admin()) {
14
-    /*
14
+	/*
15 15
      * prefix of meta keys, optional
16 16
      * use underscore (_) at the beginning to make keys hidden, for example $prefix = '_ba_';
17 17
      *  you also can make prefix empty to disable it
18 18
      *
19 19
      */
20 20
 
21
-    $prefix = 'ct_';
22
-    /*
21
+	$prefix = 'ct_';
22
+	/*
23 23
      * configure your meta box
24 24
      */
25 25
 
26
-    $config = array(
27
-        'id' => 'demo_meta_box',                    // meta box id, unique per meta box
28
-        'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title
29
-        'pages' => geodir_get_taxonomies(),            // taxonomy name, accept categories, post_tag and custom taxonomies
30
-        'context' => 'normal',                        // where the meta box appear: normal (default), advanced, side; optional
31
-        'fields' => array(),                        // list of meta fields (can be added by field arrays)
32
-        'local_images' => false,                    // Use local or hosted images (meta box images for add/remove)
33
-        'use_with_theme' => true                    //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
34
-    );
26
+	$config = array(
27
+		'id' => 'demo_meta_box',                    // meta box id, unique per meta box
28
+		'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title
29
+		'pages' => geodir_get_taxonomies(),            // taxonomy name, accept categories, post_tag and custom taxonomies
30
+		'context' => 'normal',                        // where the meta box appear: normal (default), advanced, side; optional
31
+		'fields' => array(),                        // list of meta fields (can be added by field arrays)
32
+		'local_images' => false,                    // Use local or hosted images (meta box images for add/remove)
33
+		'use_with_theme' => true                    //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
34
+	);
35 35
 
36 36
 
37
-    /*
37
+	/*
38 38
      * Initiate your meta box
39 39
      */
40
-    $my_meta = new Geodir_Tax_Meta_Class($config);
41
-    $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory')));
42
-    $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory')));
43
-    $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty'));
44
-    /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML
45
-
46
-    $my_meta->addSelect($prefix . 'cat_schema',
47
-    /*
40
+	$my_meta = new Geodir_Tax_Meta_Class($config);
41
+	$my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory')));
42
+	$my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory')));
43
+	$my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty'));
44
+	/*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML
45
+
46
+	$my_meta->addSelect($prefix . 'cat_schema',
47
+	/*
48 48
      * Allows you to add/filter the cat schema types.
49 49
      *
50 50
      * @since 1.5.7
51 51
      */
52
-        apply_filters('geodir_cat_schemas',array(
53
-            '' => __('Default (LocalBusiness)', 'geodirectory'),
54
-            'AccountingService' => 'AccountingService',
55
-            'Attorney' => 'Attorney',
56
-            'AutoBodyShop' => 'AutoBodyShop',
57
-            'AutoDealer' => 'AutoDealer',
58
-            'AutoPartsStore' => 'AutoPartsStore',
59
-            'AutoRental' => 'AutoRental',
60
-            'AutoRepair' => 'AutoRepair',
61
-            'AutoWash' => 'AutoWash',
62
-            'Bakery' => 'Bakery',
63
-            'BarOrPub' => 'BarOrPub',
64
-            'BeautySalon' => 'BeautySalon',
65
-            'BedAndBreakfast' => 'BedAndBreakfast',
66
-            'BikeStore' => 'BikeStore',
67
-            'BookStore' => 'BookStore',
68
-            'CafeOrCoffeeShop' => 'CafeOrCoffeeShop',
69
-            'Campground' => 'Campground',
70
-            'ChildCare' => 'ChildCare',
71
-            'ClothingStore' => 'ClothingStore',
72
-            'ComputerStore' => 'ComputerStore',
73
-            'DaySpa' => 'DaySpa',
74
-            'Dentist' => 'Dentist',
75
-            'DryCleaningOrLaundry' => 'DryCleaningOrLaundry',
76
-            'Electrician' => 'Electrician',
77
-            'ElectronicsStore' => 'ElectronicsStore',
78
-            'EmergencyService' => 'EmergencyService',
79
-            'EntertainmentBusiness' => 'EntertainmentBusiness',
80
-            'Event' => 'Event',
81
-            'EventVenue' => 'EventVenue',
82
-            'ExerciseGym' => 'ExerciseGym',
83
-            'FinancialService' => 'FinancialService',
84
-            'Florist' => 'Florist',
85
-            'FoodEstablishment' => 'FoodEstablishment',
86
-            'FurnitureStore' => 'FurnitureStore',
87
-            'GardenStore' => 'GardenStore',
88
-            'GeneralContractor' => 'GeneralContractor',
89
-            'GolfCourse' => 'GolfCourse',
90
-            'HairSalon' => 'HairSalon',
91
-            'HardwareStore' => 'HardwareStore',
92
-            'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness',
93
-            'HobbyShop' => 'HobbyShop',
94
-            'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness',
95
-            'HomeGoodsStore' => 'HomeGoodsStore',
96
-            'Hospital' => 'Hospital',
97
-            'Hostel' => 'Hostel',
98
-            'Hotel' => 'Hotel',
99
-            'HousePainter' => 'HousePainter',
100
-            'HVACBusiness' => 'HVACBusiness',
101
-            'InsuranceAgency' => 'InsuranceAgency',
102
-            'JewelryStore' => 'JewelryStore',
103
-            'LiquorStore' => 'LiquorStore',
104
-            'Locksmith' => 'Locksmith',
105
-            'LodgingBusiness' => 'LodgingBusiness',
106
-            'MedicalClinic' => 'MedicalClinic',
107
-            'MensClothingStore' => 'MensClothingStore',
108
-            'MobilePhoneStore' => 'MobilePhoneStore',
109
-            'Motel' => 'Motel',
110
-            'MotorcycleDealer' => 'MotorcycleDealer',
111
-            'MotorcycleRepair' => 'MotorcycleRepair',
112
-            'MovingCompany' => 'MovingCompany',
113
-            'MusicStore' => 'MusicStore',
114
-            'NailSalon' => 'NailSalon',
115
-            'NightClub' => 'NightClub',
116
-            'Notary' => 'Notary',
117
-            'OfficeEquipmentStore' => 'OfficeEquipmentStore',
118
-            'Optician' => 'Optician',
119
-            'PetStore' => 'PetStore',
120
-            'Physician' => 'Physician',
121
-            'Plumber' => 'Plumber',
122
-            'ProfessionalService' => 'ProfessionalService',
123
-            'RealEstateAgent' => 'RealEstateAgent',
124
-            'Residence' => 'Residence',
125
-            'Restaurant' => 'Restaurant',
126
-            'RoofingContractor' => 'RoofingContractor',
127
-            'RVPark' => 'RVPark',
128
-            'School' => 'School',
129
-            'SelfStorage' => 'SelfStorage',
130
-            'ShoeStore' => 'ShoeStore',
131
-            'SkiResort' => 'SkiResort',
132
-            'SportingGoodsStore' => 'SportingGoodsStore',
133
-            'SportsClub' => 'SportsClub',
134
-            'Store' => 'Store',
135
-            'TattooParlor' => 'TattooParlor',
136
-            'Taxi' => 'Taxi',
137
-            'TennisComplex' => 'TennisComplex',
138
-            'TireShop' => 'TireShop',
139
-            'TouristAttraction' => 'TouristAttraction',
140
-            'ToyStore' => 'ToyStore',
141
-            'TravelAgency' => 'TravelAgency',
142
-            //'VacationRentals' => 'VacationRentals', // Not recognised by google yet
143
-            'VeterinaryCare' => 'VeterinaryCare',
144
-            'WholesaleStore' => 'WholesaleStore',
145
-            'Winery' => 'Winery'
146
-        )),
147
-        array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2')));
148
-
149
-    /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'),
52
+		apply_filters('geodir_cat_schemas',array(
53
+			'' => __('Default (LocalBusiness)', 'geodirectory'),
54
+			'AccountingService' => 'AccountingService',
55
+			'Attorney' => 'Attorney',
56
+			'AutoBodyShop' => 'AutoBodyShop',
57
+			'AutoDealer' => 'AutoDealer',
58
+			'AutoPartsStore' => 'AutoPartsStore',
59
+			'AutoRental' => 'AutoRental',
60
+			'AutoRepair' => 'AutoRepair',
61
+			'AutoWash' => 'AutoWash',
62
+			'Bakery' => 'Bakery',
63
+			'BarOrPub' => 'BarOrPub',
64
+			'BeautySalon' => 'BeautySalon',
65
+			'BedAndBreakfast' => 'BedAndBreakfast',
66
+			'BikeStore' => 'BikeStore',
67
+			'BookStore' => 'BookStore',
68
+			'CafeOrCoffeeShop' => 'CafeOrCoffeeShop',
69
+			'Campground' => 'Campground',
70
+			'ChildCare' => 'ChildCare',
71
+			'ClothingStore' => 'ClothingStore',
72
+			'ComputerStore' => 'ComputerStore',
73
+			'DaySpa' => 'DaySpa',
74
+			'Dentist' => 'Dentist',
75
+			'DryCleaningOrLaundry' => 'DryCleaningOrLaundry',
76
+			'Electrician' => 'Electrician',
77
+			'ElectronicsStore' => 'ElectronicsStore',
78
+			'EmergencyService' => 'EmergencyService',
79
+			'EntertainmentBusiness' => 'EntertainmentBusiness',
80
+			'Event' => 'Event',
81
+			'EventVenue' => 'EventVenue',
82
+			'ExerciseGym' => 'ExerciseGym',
83
+			'FinancialService' => 'FinancialService',
84
+			'Florist' => 'Florist',
85
+			'FoodEstablishment' => 'FoodEstablishment',
86
+			'FurnitureStore' => 'FurnitureStore',
87
+			'GardenStore' => 'GardenStore',
88
+			'GeneralContractor' => 'GeneralContractor',
89
+			'GolfCourse' => 'GolfCourse',
90
+			'HairSalon' => 'HairSalon',
91
+			'HardwareStore' => 'HardwareStore',
92
+			'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness',
93
+			'HobbyShop' => 'HobbyShop',
94
+			'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness',
95
+			'HomeGoodsStore' => 'HomeGoodsStore',
96
+			'Hospital' => 'Hospital',
97
+			'Hostel' => 'Hostel',
98
+			'Hotel' => 'Hotel',
99
+			'HousePainter' => 'HousePainter',
100
+			'HVACBusiness' => 'HVACBusiness',
101
+			'InsuranceAgency' => 'InsuranceAgency',
102
+			'JewelryStore' => 'JewelryStore',
103
+			'LiquorStore' => 'LiquorStore',
104
+			'Locksmith' => 'Locksmith',
105
+			'LodgingBusiness' => 'LodgingBusiness',
106
+			'MedicalClinic' => 'MedicalClinic',
107
+			'MensClothingStore' => 'MensClothingStore',
108
+			'MobilePhoneStore' => 'MobilePhoneStore',
109
+			'Motel' => 'Motel',
110
+			'MotorcycleDealer' => 'MotorcycleDealer',
111
+			'MotorcycleRepair' => 'MotorcycleRepair',
112
+			'MovingCompany' => 'MovingCompany',
113
+			'MusicStore' => 'MusicStore',
114
+			'NailSalon' => 'NailSalon',
115
+			'NightClub' => 'NightClub',
116
+			'Notary' => 'Notary',
117
+			'OfficeEquipmentStore' => 'OfficeEquipmentStore',
118
+			'Optician' => 'Optician',
119
+			'PetStore' => 'PetStore',
120
+			'Physician' => 'Physician',
121
+			'Plumber' => 'Plumber',
122
+			'ProfessionalService' => 'ProfessionalService',
123
+			'RealEstateAgent' => 'RealEstateAgent',
124
+			'Residence' => 'Residence',
125
+			'Restaurant' => 'Restaurant',
126
+			'RoofingContractor' => 'RoofingContractor',
127
+			'RVPark' => 'RVPark',
128
+			'School' => 'School',
129
+			'SelfStorage' => 'SelfStorage',
130
+			'ShoeStore' => 'ShoeStore',
131
+			'SkiResort' => 'SkiResort',
132
+			'SportingGoodsStore' => 'SportingGoodsStore',
133
+			'SportsClub' => 'SportsClub',
134
+			'Store' => 'Store',
135
+			'TattooParlor' => 'TattooParlor',
136
+			'Taxi' => 'Taxi',
137
+			'TennisComplex' => 'TennisComplex',
138
+			'TireShop' => 'TireShop',
139
+			'TouristAttraction' => 'TouristAttraction',
140
+			'ToyStore' => 'ToyStore',
141
+			'TravelAgency' => 'TravelAgency',
142
+			//'VacationRentals' => 'VacationRentals', // Not recognised by google yet
143
+			'VeterinaryCare' => 'VeterinaryCare',
144
+			'WholesaleStore' => 'WholesaleStore',
145
+			'Winery' => 'Winery'
146
+		)),
147
+		array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2')));
148
+
149
+	/*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'),
150 150
     'random'=>__('Random','geodirectory'),
151 151
     'az'=>__('Alphabetical' , 'geodirectory'),
152 152
     'newest'=>__('Newest','geodirectory'),
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
     'low_review'=>__('Lowest Reviews','geodirectory')),
158 158
     array('name'=> __('Sort By','geodirectory'),'desc' => __('Select the default sort option.' ,'geodirectory'), 'std'=> array('selectkey2')));*/
159 159
 
160
-    // Show options for placecategories only
161
-    /*	if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){
160
+	// Show options for placecategories only
161
+	/*	if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){
162 162
         // Exclude sort options
163 163
         $my_meta->addCheckbox($prefix.'cat_exclude_rating',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory')));
164 164
         $my_meta->addCheckbox($prefix.'cat_exclude_reviews',array('name'=> __('<b>Exclude</b> Reviews sort option','geodirectory')));
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 
171 171
         }*/
172 172
 
173
-    //Finish Meta Box Declaration
174
-    $my_meta->Finish();
173
+	//Finish Meta Box Declaration
174
+	$my_meta->Finish();
175 175
 }
176 176
 
177 177
 
@@ -180,87 +180,87 @@  discard block
 block discarded – undo
180 180
 ##############################################################
181 181
 $gd_taxonomies = geodir_get_taxonomies();
182 182
 if (!empty($gd_taxonomies)) {
183
-    foreach ($gd_taxonomies as $gd_taxonomy) {
183
+	foreach ($gd_taxonomies as $gd_taxonomy) {
184 184
 
185
-        add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2);
186
-        add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3);
185
+		add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2);
186
+		add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3);
187 187
 
188
-    }
188
+	}
189 189
 }
190 190
 
191 191
 function addCat_column($columns)
192 192
 {
193
-    if (isset($columns['description']) && $posts = $columns['description']) {
194
-        unset($columns['description']);
195
-    }
196
-
197
-    $columns['cat_icon'] = 'Icon';
198
-    $columns['cat_default_img'] = __('Default Image', 'geodirectory');
199
-    $columns['cat_ID_num'] = __('Cat ID', 'geodirectory');
200
-    return $columns;
193
+	if (isset($columns['description']) && $posts = $columns['description']) {
194
+		unset($columns['description']);
195
+	}
196
+
197
+	$columns['cat_icon'] = 'Icon';
198
+	$columns['cat_default_img'] = __('Default Image', 'geodirectory');
199
+	$columns['cat_ID_num'] = __('Cat ID', 'geodirectory');
200
+	return $columns;
201 201
 }
202 202
 
203 203
 #############################################################
204 204
 function manage_category_custom_fields($deprecated, $column_name, $term_id)
205 205
 {
206
-    if ($column_name == 'cat_ID_num')
207
-        echo $term_id;
206
+	if ($column_name == 'cat_ID_num')
207
+		echo $term_id;
208 208
 
209
-    if ($column_name == 'cat_icon') {
210
-        $term_icon_url = geodir_get_tax_meta($term_id, 'ct_cat_icon');
209
+	if ($column_name == 'cat_icon') {
210
+		$term_icon_url = geodir_get_tax_meta($term_id, 'ct_cat_icon');
211 211
 
212
-        if ($term_icon_url != '') {
213
-            $file_info = pathinfo($term_icon_url['src']);
212
+		if ($term_icon_url != '') {
213
+			$file_info = pathinfo($term_icon_url['src']);
214 214
 
215
-            if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
216
-                $sub_dir = $file_info['dirname'];
217
-            } else {
218
-                $sub_dir = '';
219
-            }
215
+			if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
216
+				$sub_dir = $file_info['dirname'];
217
+			} else {
218
+				$sub_dir = '';
219
+			}
220 220
 
221
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
222
-            $uploads_baseurl = $uploads['baseurl'];
223
-            $uploads_path = $uploads['path'];
221
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
222
+			$uploads_baseurl = $uploads['baseurl'];
223
+			$uploads_path = $uploads['path'];
224 224
 
225
-            $file_name = $file_info['basename'];
225
+			$file_name = $file_info['basename'];
226 226
 
227
-            if (strpos($sub_dir, 'https://') !== false) {
228
-                $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
229
-            } else {
230
-                $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']);
231
-            }
232
-            $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir);
227
+			if (strpos($sub_dir, 'https://') !== false) {
228
+				$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
229
+			} else {
230
+				$uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']);
231
+			}
232
+			$sub_dir = str_replace($uploads['baseurl'], '', $sub_dir);
233 233
 
234
-            $uploads_url = $uploads_baseurl . $sub_dir;
234
+			$uploads_url = $uploads_baseurl . $sub_dir;
235 235
 
236
-            $term_icon_url['src'] = $uploads_url . '/' . $file_name;
237
-            echo '<img src="' . $term_icon_url['src'] . '" />';
238
-        }
239
-    }
236
+			$term_icon_url['src'] = $uploads_url . '/' . $file_name;
237
+			echo '<img src="' . $term_icon_url['src'] . '" />';
238
+		}
239
+	}
240 240
 
241
-    if ($column_name == 'cat_default_img') {
242
-        $cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img');
243
-        if ($cat_default_img != '')
244
-            echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>';
241
+	if ($column_name == 'cat_default_img') {
242
+		$cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img');
243
+		if ($cat_default_img != '')
244
+			echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>';
245 245
 
246
-    }
246
+	}
247 247
 }
248 248
 
249 249
 function geodir_get_default_catimage($term_id, $post_type = 'gd_place')
250 250
 {
251 251
 
252
-    if ($cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type))
253
-        return $cat_default_img;
254
-    else
255
-        return false;
252
+	if ($cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type))
253
+		return $cat_default_img;
254
+	else
255
+		return false;
256 256
 }
257 257
 
258 258
 //Clear custom fields
259 259
 add_action('in_admin_footer', 'geodir_tax_meta_clear_custom_field');
260 260
 function geodir_tax_meta_clear_custom_field()
261 261
 {
262
-    if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])):
263
-        ?>
262
+	if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])):
263
+		?>
264 264
         <script type="text/javascript">
265 265
             jQuery(document).ready(function () {
266 266
                 jQuery('#addtag #submit').click(function () {
@@ -281,5 +281,5 @@  discard block
 block discarded – undo
281 281
             });
282 282
         </script>
283 283
     <?php
284
-    endif;
284
+	endif;
285 285
 }
Please login to merge, or discard this patch.
geodirectory-functions/cat-meta-functions/Tax-meta-class.php 1 patch
Indentation   +2046 added lines, -2046 removed lines patch added patch discarded remove patch
@@ -28,260 +28,260 @@  discard block
 block discarded – undo
28 28
 
29 29
 if (!class_exists('Geodir_Tax_Meta_Class')) :
30 30
 
31
-    /**
32
-     * All Types Meta Box class.
33
-     *
34
-     * @package All Types Meta Box
35
-     * @since 1.0
36
-     *
37
-     * @todo Nothing.
38
-     */
39
-
40
-
41
-    class Geodir_Tax_Meta_Class
42
-    {
43
-
44
-        /**
45
-         * Holds meta box object
46
-         *
47
-         * @var object
48
-         * @access protected
49
-         */
50
-        protected $_meta_box;
51
-
52
-        /**
53
-         * Holds meta box fields.
54
-         *
55
-         * @var array
56
-         * @access protected
57
-         */
58
-        protected $_prefix;
59
-
60
-        /**
61
-         * Holds Prefix for meta box fields.
62
-         *
63
-         * @var array
64
-         * @access protected
65
-         */
66
-        protected $_fields;
67
-
68
-        /**
69
-         * Use local images.
70
-         *
71
-         * @var bool
72
-         * @access protected
73
-         */
74
-        protected $_Local_images;
75
-
76
-        /**
77
-         * What form is this? edit or new term.
78
-         *
79
-         * @var string
80
-         * @access protected
81
-         * $since 1.0
82
-         */
83
-        protected $_form_type;
84
-        /**
85
-         * SelfPath to allow themes as well as plugins.
86
-         *
87
-         * @var string
88
-         * @access protected
89
-         * $since 1.0
90
-         */
91
-        protected $SelfPath;
92
-
93
-        /**
94
-         * Constructor
95
-         *
96
-         * @since 1.0
97
-         * @access public
98
-         *
99
-         * @param array $meta_box
100
-         */
101
-        public function __construct($meta_box)
102
-        {
103
-
104
-            // If we are not in admin area exit.
105
-            if (!is_admin())
106
-                return;
107
-
108
-            // Assign meta box values to local variables and add it's missed values.
109
-            $this->_meta_box = $meta_box;
110
-            $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : '';
111
-            $this->_fields = &$this->_meta_box['fields'];
112
-            $this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113
-            $this->add_missed_values();
114
-            if (isset($meta_box['use_with_theme']))
115
-                if ($meta_box['use_with_theme'] === true) {
116
-                    $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
117
-                } elseif ($meta_box['use_with_theme'] === false) {
118
-                    $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119
-                } else {
120
-                    $this->SelfPath = $meta_box['use_with_theme'];
121
-                }
122
-            else {
123
-                $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124
-            }
125
-
126
-
127
-            // Add Actions
128
-            add_action('admin_init', array(&$this, 'add'));
129
-
130
-            // Check for special fields and add needed actions for them.
131
-            $this->check_field_upload();
132
-            $this->check_field_color();
133
-            $this->check_field_date();
134
-            $this->check_field_time();
135
-
136
-            // Load common js, css files
137
-            // Must enqueue for all pages as we need js for the media upload, too.
138
-            add_action('admin_print_styles', array(&$this, 'load_scripts_styles'));
139
-
140
-        }
141
-
142
-        /**
143
-         * Load all Javascript and CSS
144
-         *
145
-         * @since 1.0
146
-         * @access public
147
-         */
148
-        public function load_scripts_styles()
149
-        {
150
-
151
-            // Get Plugin Path
152
-            $plugin_path = $this->SelfPath;
153
-            //only load styles and js when needed
154
-            /* 
31
+	/**
32
+	 * All Types Meta Box class.
33
+	 *
34
+	 * @package All Types Meta Box
35
+	 * @since 1.0
36
+	 *
37
+	 * @todo Nothing.
38
+	 */
39
+
40
+
41
+	class Geodir_Tax_Meta_Class
42
+	{
43
+
44
+		/**
45
+		 * Holds meta box object
46
+		 *
47
+		 * @var object
48
+		 * @access protected
49
+		 */
50
+		protected $_meta_box;
51
+
52
+		/**
53
+		 * Holds meta box fields.
54
+		 *
55
+		 * @var array
56
+		 * @access protected
57
+		 */
58
+		protected $_prefix;
59
+
60
+		/**
61
+		 * Holds Prefix for meta box fields.
62
+		 *
63
+		 * @var array
64
+		 * @access protected
65
+		 */
66
+		protected $_fields;
67
+
68
+		/**
69
+		 * Use local images.
70
+		 *
71
+		 * @var bool
72
+		 * @access protected
73
+		 */
74
+		protected $_Local_images;
75
+
76
+		/**
77
+		 * What form is this? edit or new term.
78
+		 *
79
+		 * @var string
80
+		 * @access protected
81
+		 * $since 1.0
82
+		 */
83
+		protected $_form_type;
84
+		/**
85
+		 * SelfPath to allow themes as well as plugins.
86
+		 *
87
+		 * @var string
88
+		 * @access protected
89
+		 * $since 1.0
90
+		 */
91
+		protected $SelfPath;
92
+
93
+		/**
94
+		 * Constructor
95
+		 *
96
+		 * @since 1.0
97
+		 * @access public
98
+		 *
99
+		 * @param array $meta_box
100
+		 */
101
+		public function __construct($meta_box)
102
+		{
103
+
104
+			// If we are not in admin area exit.
105
+			if (!is_admin())
106
+				return;
107
+
108
+			// Assign meta box values to local variables and add it's missed values.
109
+			$this->_meta_box = $meta_box;
110
+			$this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : '';
111
+			$this->_fields = &$this->_meta_box['fields'];
112
+			$this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113
+			$this->add_missed_values();
114
+			if (isset($meta_box['use_with_theme']))
115
+				if ($meta_box['use_with_theme'] === true) {
116
+					$this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
117
+				} elseif ($meta_box['use_with_theme'] === false) {
118
+					$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119
+				} else {
120
+					$this->SelfPath = $meta_box['use_with_theme'];
121
+				}
122
+			else {
123
+				$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124
+			}
125
+
126
+
127
+			// Add Actions
128
+			add_action('admin_init', array(&$this, 'add'));
129
+
130
+			// Check for special fields and add needed actions for them.
131
+			$this->check_field_upload();
132
+			$this->check_field_color();
133
+			$this->check_field_date();
134
+			$this->check_field_time();
135
+
136
+			// Load common js, css files
137
+			// Must enqueue for all pages as we need js for the media upload, too.
138
+			add_action('admin_print_styles', array(&$this, 'load_scripts_styles'));
139
+
140
+		}
141
+
142
+		/**
143
+		 * Load all Javascript and CSS
144
+		 *
145
+		 * @since 1.0
146
+		 * @access public
147
+		 */
148
+		public function load_scripts_styles()
149
+		{
150
+
151
+			// Get Plugin Path
152
+			$plugin_path = $this->SelfPath;
153
+			//only load styles and js when needed
154
+			/* 
155 155
 		 * since 1.0
156 156
 		 */
157
-            $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : '';
158
-
159
-            if (!empty($this->_meta_box['pages'])) {
160
-                if (in_array($taxnow, $this->_meta_box['pages'])) {
161
-                    // Enqueue Meta Box Style
162
-                    //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
163
-                    // Enqueue Meta Box Scripts
164
-                    //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
165
-
166
-                }
167
-            }
168
-
169
-        }
170
-
171
-        /**
172
-         * Check the Field Upload, Add needed Actions
173
-         *
174
-         * @since 1.0
175
-         * @access public
176
-         */
177
-        public function enqueue_tax_meta_scripts()
178
-        {
179
-            // Make upload feature work event when custom post type doesn't support 'editor'
180
-            wp_enqueue_script('media-upload');
181
-            wp_enqueue_script('thickbox');
182
-            add_thickbox();
183
-            wp_enqueue_script('jquery-ui-core');
184
-            wp_enqueue_script('jquery-ui-sortable');
185
-
186
-
187
-        }
188
-
189
-        public function check_field_upload()
190
-        {
191
-
192
-            // Check if the field is an image or file. If not, return.
193
-            if (!$this->has_field('image') && !$this->has_field('file'))
194
-                return;
195
-
196
-
197
-            add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
198
-
199
-            // Add data encoding type for file uploading.	
200
-            add_action('post_edit_form_tag', array(&$this, 'add_enctype'));
201
-
202
-
203
-            // Add filters for media upload.
204
-            add_filter('media_upload_gallery', array(&$this, 'insert_images'));
205
-            add_filter('media_upload_library', array(&$this, 'insert_images'));
206
-            add_filter('media_upload_image', array(&$this, 'insert_images'));
207
-
208
-            // Delete all attachments when delete custom post type.
209
-            add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file'));
210
-            add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images'));
211
-            // Delete file via Ajax
212
-            add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image'));
213
-        }
214
-
215
-        /**
216
-         * Add data encoding type for file uploading
217
-         *
218
-         * @since 1.0
219
-         * @access public
220
-         */
221
-        public function add_enctype()
222
-        {
223
-            echo ' enctype="multipart/form-data"';
224
-        }
225
-
226
-        /**
227
-         * Process images added to meta field.
228
-         *
229
-         * Modified from Faster Image Insert plugin.
230
-         *
231
-         * @return void
232
-         * @author Cory Crowley
233
-         */
234
-        public function insert_images()
235
-        {
236
-
237
-            // If post variables are empty, return.
238
-            if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
-                return;
240
-
241
-            // Security Check
242
-            check_admin_referer('media-form');
243
-
244
-            // Create Security Nonce
245
-            $nonce = wp_create_nonce('at_ajax_delete');
246
-
247
-            // Get Post Id and Field Id
248
-            $term_id = $_POST['post_id'];
249
-            $id = $_POST['field_id'];
250
-
251
-            // Modify the insertion string
252
-            $html = '';
253
-            foreach ($_POST['attachments'] as $attachment_id => $attachment) {
254
-
255
-                // Strip Slashes
256
-                $attachment = stripslashes_deep($attachment);
257
-
258
-                // If not selected or url is empty, continue in loop.
259
-                if (empty($attachment['selected']) || empty($attachment['url']))
260
-                    continue;
261
-
262
-                $li = "<li id='item_{$attachment_id}'>";
263
-                $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264
-                //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
265
-                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
266
-                $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267
-                $li .= "</li>";
268
-                $html .= $li;
269
-
270
-            } // End For Each
271
-
272
-            return media_send_to_editor($html);
273
-
274
-        }
275
-
276
-        /**
277
-         * Delete attachments associated with the post.
278
-         *
279
-         * @since 1.0
280
-         * @access public
281
-         *
282
-         * @param int|string $term_id The term ID.
283
-         */
284
-        /*public function delete_attachments( $term_id ) {
157
+			$taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : '';
158
+
159
+			if (!empty($this->_meta_box['pages'])) {
160
+				if (in_array($taxnow, $this->_meta_box['pages'])) {
161
+					// Enqueue Meta Box Style
162
+					//wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
163
+					// Enqueue Meta Box Scripts
164
+					//wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
165
+
166
+				}
167
+			}
168
+
169
+		}
170
+
171
+		/**
172
+		 * Check the Field Upload, Add needed Actions
173
+		 *
174
+		 * @since 1.0
175
+		 * @access public
176
+		 */
177
+		public function enqueue_tax_meta_scripts()
178
+		{
179
+			// Make upload feature work event when custom post type doesn't support 'editor'
180
+			wp_enqueue_script('media-upload');
181
+			wp_enqueue_script('thickbox');
182
+			add_thickbox();
183
+			wp_enqueue_script('jquery-ui-core');
184
+			wp_enqueue_script('jquery-ui-sortable');
185
+
186
+
187
+		}
188
+
189
+		public function check_field_upload()
190
+		{
191
+
192
+			// Check if the field is an image or file. If not, return.
193
+			if (!$this->has_field('image') && !$this->has_field('file'))
194
+				return;
195
+
196
+
197
+			add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
198
+
199
+			// Add data encoding type for file uploading.	
200
+			add_action('post_edit_form_tag', array(&$this, 'add_enctype'));
201
+
202
+
203
+			// Add filters for media upload.
204
+			add_filter('media_upload_gallery', array(&$this, 'insert_images'));
205
+			add_filter('media_upload_library', array(&$this, 'insert_images'));
206
+			add_filter('media_upload_image', array(&$this, 'insert_images'));
207
+
208
+			// Delete all attachments when delete custom post type.
209
+			add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file'));
210
+			add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images'));
211
+			// Delete file via Ajax
212
+			add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image'));
213
+		}
214
+
215
+		/**
216
+		 * Add data encoding type for file uploading
217
+		 *
218
+		 * @since 1.0
219
+		 * @access public
220
+		 */
221
+		public function add_enctype()
222
+		{
223
+			echo ' enctype="multipart/form-data"';
224
+		}
225
+
226
+		/**
227
+		 * Process images added to meta field.
228
+		 *
229
+		 * Modified from Faster Image Insert plugin.
230
+		 *
231
+		 * @return void
232
+		 * @author Cory Crowley
233
+		 */
234
+		public function insert_images()
235
+		{
236
+
237
+			// If post variables are empty, return.
238
+			if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
+				return;
240
+
241
+			// Security Check
242
+			check_admin_referer('media-form');
243
+
244
+			// Create Security Nonce
245
+			$nonce = wp_create_nonce('at_ajax_delete');
246
+
247
+			// Get Post Id and Field Id
248
+			$term_id = $_POST['post_id'];
249
+			$id = $_POST['field_id'];
250
+
251
+			// Modify the insertion string
252
+			$html = '';
253
+			foreach ($_POST['attachments'] as $attachment_id => $attachment) {
254
+
255
+				// Strip Slashes
256
+				$attachment = stripslashes_deep($attachment);
257
+
258
+				// If not selected or url is empty, continue in loop.
259
+				if (empty($attachment['selected']) || empty($attachment['url']))
260
+					continue;
261
+
262
+				$li = "<li id='item_{$attachment_id}'>";
263
+				$li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264
+				//$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
265
+				$li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
266
+				$li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267
+				$li .= "</li>";
268
+				$html .= $li;
269
+
270
+			} // End For Each
271
+
272
+			return media_send_to_editor($html);
273
+
274
+		}
275
+
276
+		/**
277
+		 * Delete attachments associated with the post.
278
+		 *
279
+		 * @since 1.0
280
+		 * @access public
281
+		 *
282
+		 * @param int|string $term_id The term ID.
283
+		 */
284
+		/*public function delete_attachments( $term_id ) {
285 285
 		
286 286
 		// Get Attachments
287 287
 		$attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) );
@@ -295,349 +295,349 @@  discard block
 block discarded – undo
295 295
 		
296 296
 	}*/
297 297
 
298
-        /**
299
-         * Ajax callback for deleting files.
300
-         *
301
-         * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H )
302
-         *
303
-         * @since 1.0
304
-         * @access public
305
-         */
306
-        public function delete_file()
307
-        {
308
-
309
-
310
-            // If data is not set, die.
311
-            if (!isset($_POST['data']))
312
-                die();
313
-
314
-            list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315
-
316
-            if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
-                die('1');
318
-
319
-            $this->delete_tax_meta($term_id, $key, $attach_id);
320
-
321
-            die('0');
322
-
323
-        }
324
-
325
-        /**
326
-         * Ajax callback for deleting files.
327
-         * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq)
328
-         * @since 1.0
329
-         * @access public
330
-         */
331
-        public function wp_ajax_delete_image()
332
-        {
333
-            $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
334
-            $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0;
335
-            $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336
-            $ok = false;
337
-            if (strpos($field_id, '[') === false) {
338
-                check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
-                if ($term_id > 0)
340
-                    $this->delete_tax_meta($term_id, $field_id);
341
-                //$ok = wp_delete_attachment( $attachment_id );
342
-                $ok = 1;
343
-            } else {
344
-                $f = explode('[', urldecode($field_id));
345
-                $f_fiexed = array();
346
-                foreach ($f as $k => $v) {
347
-                    $f[$k] = str_replace(']', '', $v);
348
-                }
349
-                $saved = $this->get_tax_meta($term_id, $f[0], true);
350
-                if (isset($saved[$f[1]][$f[2]])) {
351
-                    unset($saved[$f[1]][$f[2]]);
352
-                    if ($term_id > 0)
353
-                        update_post_meta($term_id, $f[0], $saved);
354
-                    //$ok = wp_delete_attachment( $attachment_id );
355
-                    $ok = 1;
356
-                }
357
-            }
358
-
359
-
360
-            if ($ok) {
361
-                echo json_encode(array('status' => 'success'));
362
-                die();
363
-            } else {
364
-                echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory')));
365
-                die();
366
-            }
367
-        }
368
-
369
-        /**
370
-         * Ajax callback for reordering Images.
371
-         *
372
-         * @since 1.0
373
-         * @access public
374
-         */
375
-        public function reorder_images()
376
-        {
377
-
378
-            if (!isset($_POST['data']))
379
-                die();
380
-
381
-            list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382
-
383
-            if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
-                die('1');
385
-
386
-            parse_str($order, $items);
387
-            $items = $items['item'];
388
-            $order = 1;
389
-            foreach ($items as $item) {
390
-                wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order));
391
-                $order++;
392
-            }
393
-
394
-            die('0');
395
-
396
-        }
397
-
398
-        /**
399
-         * Check Field Color
400
-         *
401
-         * @since 1.0
402
-         * @access public
403
-         */
404
-        public function check_field_color()
405
-        {
406
-
407
-            if ($this->has_field('color') && $this->is_edit_page()) {
408
-                // Enqueu built-in script and style for color picker.
409
-                wp_enqueue_style('farbtastic');
410
-                wp_enqueue_script('farbtastic');
411
-            }
412
-
413
-        }
414
-
415
-        /**
416
-         * Check Field Date
417
-         *
418
-         * @since 1.0
419
-         * @access public
420
-         */
421
-        public function check_field_date()
422
-        {
423
-
424
-            if ($this->has_field('date') && $this->is_edit_page()) {
425
-                // Enqueu JQuery UI, use proper version.
426
-                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
428
-            }
429
-
430
-        }
431
-
432
-        /**
433
-         * Check Field Time
434
-         *
435
-         * @since 1.0
436
-         * @access public
437
-         */
438
-        public function check_field_time()
439
-        {
440
-
441
-            if ($this->has_field('time') && $this->is_edit_page()) {
442
-
443
-                // Enqueu JQuery UI, use proper version.
444
-                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true);
445
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true);
446
-                wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true);
447
-
448
-            }
449
-
450
-        }
451
-
452
-        /**
453
-         * Add Meta Box for multiple post types.
454
-         *
455
-         * @since 1.0
456
-         * @access public
457
-         */
458
-        public function add()
459
-        {
460
-
461
-            // Loop through array
462
-            if (!empty($this->_meta_box['pages'])) {
463
-                foreach ($this->_meta_box['pages'] as $page) {
464
-                    //add fields to edit form
465
-                    add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
466
-                    //add fields to add new form
467
-                    add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
468
-                    // this saves the edit fields
469
-                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
470
-                    // this saves the add fields
471
-                    add_action('created_' . $page, array(&$this, 'save'), 10, 2);
472
-                }
473
-            }
474
-
475
-        }
476
-
477
-        /**
478
-         * Callback function to show fields on add new taxonomy term form.
479
-         *
480
-         * @since 1.0
481
-         * @access public
482
-         */
483
-        public function show_new_form($term_id)
484
-        {
485
-            $this->_form_type = 'new';
486
-            $this->show($term_id);
487
-        }
488
-
489
-        /**
490
-         * Callback function to show fields on term edit form.
491
-         *
492
-         * @since 1.0
493
-         * @access public
494
-         */
495
-        public function show_edit_form($term_id)
496
-        {
497
-            $this->_form_type = 'edit';
498
-            $this->show($term_id);
499
-        }
500
-
501
-
502
-        /**
503
-         * Callback function to show fields in meta box.
504
-         *
505
-         * @since 1.0
506
-         * @access public
507
-         */
508
-        public function show($term_id)
509
-        {
510
-
511
-            wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce');
512
-
513
-            foreach ($this->_fields as $field) {
514
-                $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515
-                $meta = ($meta !== '') ? $meta : $field['std'];
516
-                if ('image' != $field['type'] && $field['type'] != 'repeater')
517
-                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518
-
519
-                if ($field['validate_func']) {
520
-                    echo '<tr class="form-field form-required ' . $field['style'] . '">';
521
-                } else {
522
-                    echo '<tr class="form-field ' . $field['style'] . '">';
523
-                }
524
-
525
-                // Call Separated methods for displaying each type of field.
526
-                call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
527
-                echo '</tr>';
528
-            }
529
-            echo '</table>';
530
-        }
531
-
532
-        /**
533
-         * Show Repeater Fields.
534
-         *
535
-         * @param string $field
536
-         * @param string $meta
537
-         * @since 1.0
538
-         * @access public
539
-         */
540
-        public function show_field_repeater($field, $meta)
541
-        {
542
-            // Get Plugin Path
543
-            $plugin_path = $this->SelfPath;
544
-            $this->show_field_begin($field, $meta);
545
-            echo "<div class='at-repeat' id='{$field['id']}'>";
546
-
547
-            $c = 0;
548
-
549
-            if (count($meta) > 0 && is_array($meta)) {
550
-                foreach ($meta as $me) {
551
-                    //for labling toggles
552
-                    $mmm = $me[$field['fields'][0]['id']];
553
-                    echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
554
-                    if ($field['inline']) {
555
-                        echo '<tr class="at-inline" VALIGN="top">';
556
-                    }
557
-                    foreach ($field['fields'] as $f) {
558
-                        //reset var $id for repeater
559
-                        $id = '';
560
-                        $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561
-                        $m = $me[$f['id']];
562
-                        $m = ($m !== '') ? $m : $f['std'];
563
-                        if ('image' != $f['type'] && $f['type'] != 'repeater')
564
-                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
565
-                        //set new id for field in array format
566
-                        $f['id'] = $id;
567
-                        if (!$field['inline']) {
568
-                            echo '<tr>';
569
-                        }
570
-                        call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
571
-                        if (!$field['inline']) {
572
-                            echo '</tr>';
573
-                        }
574
-                    }
575
-                    if ($field['inline']) {
576
-                        echo '</tr>';
577
-                    }
578
-                    echo '</table>
298
+		/**
299
+		 * Ajax callback for deleting files.
300
+		 *
301
+		 * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H )
302
+		 *
303
+		 * @since 1.0
304
+		 * @access public
305
+		 */
306
+		public function delete_file()
307
+		{
308
+
309
+
310
+			// If data is not set, die.
311
+			if (!isset($_POST['data']))
312
+				die();
313
+
314
+			list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315
+
316
+			if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
+				die('1');
318
+
319
+			$this->delete_tax_meta($term_id, $key, $attach_id);
320
+
321
+			die('0');
322
+
323
+		}
324
+
325
+		/**
326
+		 * Ajax callback for deleting files.
327
+		 * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq)
328
+		 * @since 1.0
329
+		 * @access public
330
+		 */
331
+		public function wp_ajax_delete_image()
332
+		{
333
+			$term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
334
+			$field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0;
335
+			$attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336
+			$ok = false;
337
+			if (strpos($field_id, '[') === false) {
338
+				check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
+				if ($term_id > 0)
340
+					$this->delete_tax_meta($term_id, $field_id);
341
+				//$ok = wp_delete_attachment( $attachment_id );
342
+				$ok = 1;
343
+			} else {
344
+				$f = explode('[', urldecode($field_id));
345
+				$f_fiexed = array();
346
+				foreach ($f as $k => $v) {
347
+					$f[$k] = str_replace(']', '', $v);
348
+				}
349
+				$saved = $this->get_tax_meta($term_id, $f[0], true);
350
+				if (isset($saved[$f[1]][$f[2]])) {
351
+					unset($saved[$f[1]][$f[2]]);
352
+					if ($term_id > 0)
353
+						update_post_meta($term_id, $f[0], $saved);
354
+					//$ok = wp_delete_attachment( $attachment_id );
355
+					$ok = 1;
356
+				}
357
+			}
358
+
359
+
360
+			if ($ok) {
361
+				echo json_encode(array('status' => 'success'));
362
+				die();
363
+			} else {
364
+				echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory')));
365
+				die();
366
+			}
367
+		}
368
+
369
+		/**
370
+		 * Ajax callback for reordering Images.
371
+		 *
372
+		 * @since 1.0
373
+		 * @access public
374
+		 */
375
+		public function reorder_images()
376
+		{
377
+
378
+			if (!isset($_POST['data']))
379
+				die();
380
+
381
+			list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382
+
383
+			if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
+				die('1');
385
+
386
+			parse_str($order, $items);
387
+			$items = $items['item'];
388
+			$order = 1;
389
+			foreach ($items as $item) {
390
+				wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order));
391
+				$order++;
392
+			}
393
+
394
+			die('0');
395
+
396
+		}
397
+
398
+		/**
399
+		 * Check Field Color
400
+		 *
401
+		 * @since 1.0
402
+		 * @access public
403
+		 */
404
+		public function check_field_color()
405
+		{
406
+
407
+			if ($this->has_field('color') && $this->is_edit_page()) {
408
+				// Enqueu built-in script and style for color picker.
409
+				wp_enqueue_style('farbtastic');
410
+				wp_enqueue_script('farbtastic');
411
+			}
412
+
413
+		}
414
+
415
+		/**
416
+		 * Check Field Date
417
+		 *
418
+		 * @since 1.0
419
+		 * @access public
420
+		 */
421
+		public function check_field_date()
422
+		{
423
+
424
+			if ($this->has_field('date') && $this->is_edit_page()) {
425
+				// Enqueu JQuery UI, use proper version.
426
+				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
+				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
428
+			}
429
+
430
+		}
431
+
432
+		/**
433
+		 * Check Field Time
434
+		 *
435
+		 * @since 1.0
436
+		 * @access public
437
+		 */
438
+		public function check_field_time()
439
+		{
440
+
441
+			if ($this->has_field('time') && $this->is_edit_page()) {
442
+
443
+				// Enqueu JQuery UI, use proper version.
444
+				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true);
445
+				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true);
446
+				wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true);
447
+
448
+			}
449
+
450
+		}
451
+
452
+		/**
453
+		 * Add Meta Box for multiple post types.
454
+		 *
455
+		 * @since 1.0
456
+		 * @access public
457
+		 */
458
+		public function add()
459
+		{
460
+
461
+			// Loop through array
462
+			if (!empty($this->_meta_box['pages'])) {
463
+				foreach ($this->_meta_box['pages'] as $page) {
464
+					//add fields to edit form
465
+					add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
466
+					//add fields to add new form
467
+					add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
468
+					// this saves the edit fields
469
+					add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
470
+					// this saves the add fields
471
+					add_action('created_' . $page, array(&$this, 'save'), 10, 2);
472
+				}
473
+			}
474
+
475
+		}
476
+
477
+		/**
478
+		 * Callback function to show fields on add new taxonomy term form.
479
+		 *
480
+		 * @since 1.0
481
+		 * @access public
482
+		 */
483
+		public function show_new_form($term_id)
484
+		{
485
+			$this->_form_type = 'new';
486
+			$this->show($term_id);
487
+		}
488
+
489
+		/**
490
+		 * Callback function to show fields on term edit form.
491
+		 *
492
+		 * @since 1.0
493
+		 * @access public
494
+		 */
495
+		public function show_edit_form($term_id)
496
+		{
497
+			$this->_form_type = 'edit';
498
+			$this->show($term_id);
499
+		}
500
+
501
+
502
+		/**
503
+		 * Callback function to show fields in meta box.
504
+		 *
505
+		 * @since 1.0
506
+		 * @access public
507
+		 */
508
+		public function show($term_id)
509
+		{
510
+
511
+			wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce');
512
+
513
+			foreach ($this->_fields as $field) {
514
+				$meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515
+				$meta = ($meta !== '') ? $meta : $field['std'];
516
+				if ('image' != $field['type'] && $field['type'] != 'repeater')
517
+					$meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518
+
519
+				if ($field['validate_func']) {
520
+					echo '<tr class="form-field form-required ' . $field['style'] . '">';
521
+				} else {
522
+					echo '<tr class="form-field ' . $field['style'] . '">';
523
+				}
524
+
525
+				// Call Separated methods for displaying each type of field.
526
+				call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
527
+				echo '</tr>';
528
+			}
529
+			echo '</table>';
530
+		}
531
+
532
+		/**
533
+		 * Show Repeater Fields.
534
+		 *
535
+		 * @param string $field
536
+		 * @param string $meta
537
+		 * @since 1.0
538
+		 * @access public
539
+		 */
540
+		public function show_field_repeater($field, $meta)
541
+		{
542
+			// Get Plugin Path
543
+			$plugin_path = $this->SelfPath;
544
+			$this->show_field_begin($field, $meta);
545
+			echo "<div class='at-repeat' id='{$field['id']}'>";
546
+
547
+			$c = 0;
548
+
549
+			if (count($meta) > 0 && is_array($meta)) {
550
+				foreach ($meta as $me) {
551
+					//for labling toggles
552
+					$mmm = $me[$field['fields'][0]['id']];
553
+					echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
554
+					if ($field['inline']) {
555
+						echo '<tr class="at-inline" VALIGN="top">';
556
+					}
557
+					foreach ($field['fields'] as $f) {
558
+						//reset var $id for repeater
559
+						$id = '';
560
+						$id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561
+						$m = $me[$f['id']];
562
+						$m = ($m !== '') ? $m : $f['std'];
563
+						if ('image' != $f['type'] && $f['type'] != 'repeater')
564
+							$m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
565
+						//set new id for field in array format
566
+						$f['id'] = $id;
567
+						if (!$field['inline']) {
568
+							echo '<tr>';
569
+						}
570
+						call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
571
+						if (!$field['inline']) {
572
+							echo '</tr>';
573
+						}
574
+					}
575
+					if ($field['inline']) {
576
+						echo '</tr>';
577
+					}
578
+					echo '</table>
579 579
 				<span class="at-re-toggle"><img src="';
580
-                    if ($this->_Local_images) {
581
-                        echo $plugin_path . '/images/edit.png';
582
-                    } else {
583
-                        echo 'http://i.imgur.com/ka0E2.png';
584
-                    }
585
-                    echo '" alt="Edit" title="Edit"/></span> 
580
+					if ($this->_Local_images) {
581
+						echo $plugin_path . '/images/edit.png';
582
+					} else {
583
+						echo 'http://i.imgur.com/ka0E2.png';
584
+					}
585
+					echo '" alt="Edit" title="Edit"/></span> 
586 586
 				<img src="';
587
-                    if ($this->_Local_images) {
588
-                        echo $plugin_path . '/images/remove.png';
589
-                    } else {
590
-                        echo 'http://i.imgur.com/g8Duj.png';
591
-                    }
592
-                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
593
-                    $c = $c + 1;
594
-
595
-                }
596
-                $this->show_field_end($field, $meta);
597
-            }
598
-
599
-            echo '<img src="';
600
-            if ($this->_Local_images) {
601
-                echo $plugin_path . '/images/add.png';
602
-            } else {
603
-                echo 'http://i.imgur.com/w5Tuc.png';
604
-            }
605
-            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
606
-
607
-            //create all fields once more for js function and catch with object buffer
608
-            ob_start();
609
-            echo '<div class="at-repater-block"><table class="repeater-table">';
610
-            if ($field['inline']) {
611
-                echo '<tr class="at-inline" VALIGN="top">';
612
-            }
613
-            foreach ($field['fields'] as $f) {
614
-                //reset var $id for repeater
615
-                $id = '';
616
-                $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
617
-                $f['id'] = $id;
618
-                if (!$field['inline']) {
619
-                    echo '<tr>';
620
-                }
621
-                call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
622
-                if (!$field['inline']) {
623
-                    echo '</tr>';
624
-                }
625
-            }
626
-            if ($field['inline']) {
627
-                echo '</tr>';
628
-            }
629
-            echo '</table><img src="';
630
-            if ($this->_Local_images) {
631
-                echo $plugin_path . '/images/remove.png';
632
-            } else {
633
-                echo 'http://i.imgur.com/g8Duj.png';
634
-            }
635
-            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
-            $counter = 'countadd_' . $field['id'];
637
-            $js_code = ob_get_clean();
638
-            $js_code = str_replace("'", "\"", $js_code);
639
-            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
640
-            echo '<script>
587
+					if ($this->_Local_images) {
588
+						echo $plugin_path . '/images/remove.png';
589
+					} else {
590
+						echo 'http://i.imgur.com/g8Duj.png';
591
+					}
592
+					echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
593
+					$c = $c + 1;
594
+
595
+				}
596
+				$this->show_field_end($field, $meta);
597
+			}
598
+
599
+			echo '<img src="';
600
+			if ($this->_Local_images) {
601
+				echo $plugin_path . '/images/add.png';
602
+			} else {
603
+				echo 'http://i.imgur.com/w5Tuc.png';
604
+			}
605
+			echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
606
+
607
+			//create all fields once more for js function and catch with object buffer
608
+			ob_start();
609
+			echo '<div class="at-repater-block"><table class="repeater-table">';
610
+			if ($field['inline']) {
611
+				echo '<tr class="at-inline" VALIGN="top">';
612
+			}
613
+			foreach ($field['fields'] as $f) {
614
+				//reset var $id for repeater
615
+				$id = '';
616
+				$id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
617
+				$f['id'] = $id;
618
+				if (!$field['inline']) {
619
+					echo '<tr>';
620
+				}
621
+				call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
622
+				if (!$field['inline']) {
623
+					echo '</tr>';
624
+				}
625
+			}
626
+			if ($field['inline']) {
627
+				echo '</tr>';
628
+			}
629
+			echo '</table><img src="';
630
+			if ($this->_Local_images) {
631
+				echo $plugin_path . '/images/remove.png';
632
+			} else {
633
+				echo 'http://i.imgur.com/g8Duj.png';
634
+			}
635
+			echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
+			$counter = 'countadd_' . $field['id'];
637
+			$js_code = ob_get_clean();
638
+			$js_code = str_replace("'", "\"", $js_code);
639
+			$js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
640
+			echo '<script>
641 641
 				jQuery(document).ready(function() {
642 642
 					var ' . $counter . ' = ' . $c . ';
643 643
 					jQuery("#add-' . $field['id'] . '").live(\'click\', function() {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         			});
651 651
     			});
652 652
     		</script>';
653
-            echo '<br/><style>
653
+			echo '<br/><style>
654 654
 .at-inline{line-height: 1 !important;}
655 655
 .at-inline .at-field{border: 0px !important;}
656 656
 .at-inline .at-label{margin: 0 0 1px !important;}
@@ -658,531 +658,531 @@  discard block
 block discarded – undo
658 658
 .at-inline .at-textarea{width: 100px; height: 75px;}
659 659
 .at-repater-block{background-color: #FFFFFF;border: 1px solid;margin: 2px;}
660 660
 </style>';
661
-            $this->show_field_end($field, $meta);
662
-        }
663
-
664
-        /**
665
-         * Begin Field.
666
-         *
667
-         * @param string $field
668
-         * @param string $meta
669
-         * @since 1.0
670
-         * @access public
671
-         */
672
-        public function show_field_begin($field, $meta)
673
-        {
674
-            if (isset($field['group'])) {
675
-                if ($field['group'] == "start") {
676
-                    echo "<td class='at-field'>";
677
-                }
678
-            } else {
679
-                if ($this->_form_type == 'edit') {
680
-                    echo '<th valign="top" scope="row">';
681
-                } else {
682
-                    if ($field['validate_func']) {
683
-                        echo '<td><div class="form-field form-required">';
684
-                    } else {
685
-                        echo '<td><div class="form-field">';
686
-                    }
687
-                }
688
-            }
689
-            if ($field['name'] != '' || $field['name'] != FALSE) {
690
-                //echo "<div class='at-label'>";
691
-                echo "<label for='{$field['id']}'>{$field['name']}</label>";
692
-                //echo "</div>";
693
-            }
694
-            if ($this->_form_type == 'edit') {
695
-                echo '</th><td>';
696
-            }
697
-        }
698
-
699
-        /**
700
-         * End Field.
701
-         *
702
-         * @param string $field
703
-         * @param string $meta
704
-         * @since 1.0
705
-         * @access public
706
-         */
707
-        public function show_field_end($field, $meta = NULL, $group = false)
708
-        {
709
-            if (isset($field['group'])) {
710
-                if ($group == 'end') {
711
-                    if ($field['desc'] != '') {
712
-                        echo "<p class='desc-field'>{$field['desc']}</p></td>";
713
-                    } else {
714
-                        echo "</td>";
715
-                    }
716
-                } else {
717
-                    if ($field['desc'] != '') {
718
-                        echo "<p class='desc-field'>{$field['desc']}</p><br/>";
719
-                    } else {
720
-                        echo '<br/>';
721
-                    }
722
-                }
723
-            } else {
724
-                if ($field['desc'] != '') {
725
-                    echo "<p class='desc-field'>{$field['desc']}</p>";
726
-                }
727
-                if ($this->_form_type == 'edit') {
728
-                    echo '</td>';
729
-                } else {
730
-                    echo '</td></div>';
731
-                }
732
-            }
733
-        }
734
-
735
-        /**
736
-         * Show Field Text.
737
-         *
738
-         * @param string $field
739
-         * @param string $meta
740
-         * @since 1.0
741
-         * @access public
742
-         */
743
-        public function show_field_text($field, $meta)
744
-        {
745
-            $this->show_field_begin($field, $meta);
746
-            echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />";
747
-            $this->show_field_end($field, $meta);
748
-        }
749
-
750
-        /**
751
-         * Show Field hidden.
752
-         *
753
-         * @param string $field
754
-         * @param string|mixed $meta
755
-         * @since 0.1.3
756
-         * @access public
757
-         */
758
-        public function show_field_hidden($field, $meta)
759
-        {
760
-            //$this->show_field_begin( $field, $meta );
761
-            echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>";
762
-            //$this->show_field_end( $field, $meta );
763
-        }
764
-
765
-        /**
766
-         * Show Field Paragraph.
767
-         *
768
-         * @param string $field
769
-         * @since 0.1.3
770
-         * @access public
771
-         */
772
-        public function show_field_paragraph($field)
773
-        {
774
-            //$this->show_field_begin( $field, $meta );
775
-            echo '<p>' . $field['value'] . '</p>';
776
-            //$this->show_field_end( $field, $meta );
777
-        }
778
-
779
-        /**
780
-         * Show Field Textarea.
781
-         *
782
-         * @param string $field
783
-         * @param string $meta
784
-         * @since 1.0
785
-         * @access public
786
-         */
787
-        public function show_field_textarea($field, $meta)
788
-        {
789
-            $this->show_field_begin($field, $meta);
790
-            echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
791
-            $this->show_field_end($field, $meta);
792
-        }
793
-
794
-        /**
795
-         * Show Field Select.
796
-         *
797
-         * @param string $field
798
-         * @param string $meta
799
-         * @since 1.0
800
-         * @access public
801
-         */
802
-        public function show_field_select($field, $meta)
803
-        {
804
-
805
-            if (!is_array($meta))
806
-                $meta = (array)$meta;
807
-
808
-            $this->show_field_begin($field, $meta);
809
-            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
810
-            foreach ($field['options'] as $key => $value) {
811
-                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
812
-            }
813
-            echo "</select>";
814
-            $this->show_field_end($field, $meta);
815
-
816
-        }
817
-
818
-        /**
819
-         * Show Radio Field.
820
-         *
821
-         * @param string $field
822
-         * @param string $meta
823
-         * @since 1.0
824
-         * @access public
825
-         */
826
-        public function show_field_radio($field, $meta)
827
-        {
828
-
829
-            if (!is_array($meta))
830
-                $meta = (array)$meta;
831
-
832
-            $this->show_field_begin($field, $meta);
833
-            foreach ($field['options'] as $key => $value) {
834
-                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>";
835
-            }
836
-            $this->show_field_end($field, $meta);
837
-        }
838
-
839
-        /**
840
-         * Show Checkbox Field.
841
-         *
842
-         * @param string $field
843
-         * @param string $meta
844
-         * @since 1.0
845
-         * @access public
846
-         */
847
-        public function show_field_checkbox($field, $meta)
848
-        {
849
-
850
-            $this->show_field_begin($field, $meta);
851
-            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}";
852
-            $this->show_field_end($field, $meta);
853
-        }
854
-
855
-        /**
856
-         * Show Wysiwig Field.
857
-         *
858
-         * @param string $field
859
-         * @param string $meta
860
-         * @since 1.0
861
-         * @access public
862
-         */
863
-        public function show_field_wysiwyg($field, $meta)
864
-        {
865
-            $this->show_field_begin($field, $meta);
866
-            // Add TinyMCE script for WP version < 3.3
867
-            global $wp_version;
868
-
869
-            if (version_compare($wp_version, '3.2.1') < 1) {
870
-                echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
871
-            } else {
872
-                // Use new wp_editor() since WP 3.3
873
-                wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg'));
874
-            }
875
-            $this->show_field_end($field, $meta);
876
-        }
877
-
878
-        /**
879
-         * Show File Field.
880
-         *
881
-         * @global object $post The current post object.
882
-         * @param string $field
883
-         * @param string $meta
884
-         * @since 1.0
885
-         * @access public
886
-         */
887
-        public function show_field_file($field, $meta)
888
-        {
889
-
890
-            global $post;
891
-
892
-            if (!is_array($meta))
893
-                $meta = (array)$meta;
894
-
895
-            $this->show_field_begin($field, $meta);
896
-            echo "{$field['desc']}<br />";
897
-
898
-            if (!empty($meta)) {
899
-                $nonce = wp_create_nonce('at_ajax_delete');
900
-                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
901
-                echo '<ol class="at-upload">';
902
-                foreach ($meta as $att) {
903
-                    // if (wp_attachment_is_image($att)) continue; // what's image uploader for?
904
-                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>";
905
-                }
906
-                echo '</ol>';
907
-            }
908
-
909
-            // show form upload
910
-
911
-            echo "<div class='at-file-upload-label'>";
912
-            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
913
-            echo "</div>";
914
-            echo "<div class='new-files'>";
915
-            echo "<div class='file-input'>";
916
-            echo "<input type='file' name='{$field['id']}[]' />";
917
-            echo "</div><!-- End .file-input -->";
918
-            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
919
-            echo "</div><!-- End .new-files -->";
920
-            echo "</td>";
921
-            $this->show_field_end($field, $meta);
922
-        }
923
-
924
-        /**
925
-         * Show Image Field.
926
-         *
927
-         * @param array $field
928
-         * @param array $meta
929
-         * @since 1.0
930
-         * @access public
931
-         */
932
-        public function show_field_image($field, $meta)
933
-        {
934
-            $this->show_field_begin($field, $meta);
935
-            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936
-            if (is_array($meta)) {
937
-                if (isset($meta[0]) && is_array($meta[0]))
938
-                    $meta = $meta[0];
939
-            }
940
-
941
-            $uploads = wp_upload_dir();
942
-            if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') {
943
-                $file_info = pathinfo($meta['src']);
944
-
945
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
946
-                    $sub_dir = $file_info['dirname'];
947
-
948
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
949
-                $uploads_baseurl = $uploads['baseurl'];
950
-                $uploads_path = $uploads['path'];
951
-
952
-                $file_name = $file_info['basename'];
953
-
954
-                if (strpos($sub_dir, 'https://') !== false) {
955
-                    $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
956
-                } else {
957
-                    $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']);
958
-                }
959
-                $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir);
960
-
961
-                $uploads_url = $uploads_baseurl . $sub_dir;
962
-
963
-                $meta['src'] = $uploads_url . '/' . $file_name;
964
-
965
-                $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>";
966
-                $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />";
967
-                $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />";
968
-                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />";
969
-            } else {
970
-                $html .= "<span class='mupload_img_holder'></span>";
971
-                $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />";
972
-                $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />";
973
-                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />";
974
-            }
975
-            echo $html;
976
-            $this->show_field_end($field, $meta);
977
-        }
978
-
979
-        /**
980
-         * Show Color Field.
981
-         *
982
-         * @param string $field
983
-         * @param string $meta
984
-         * @since 1.0
985
-         * @access public
986
-         */
987
-        public function show_field_color($field, $meta)
988
-        {
989
-
990
-            if (empty($meta))
991
-                $meta = '#';
992
-
993
-            $this->show_field_begin($field, $meta);
994
-
995
-            echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
996
-            //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>";
997
-            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>";
998
-            echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
999
-            $this->show_field_end($field, $meta);
1000
-
1001
-        }
1002
-
1003
-        /**
1004
-         * Show Checkbox List Field
1005
-         *
1006
-         * @param string $field
1007
-         * @param string $meta
1008
-         * @since 1.0
1009
-         * @access public
1010
-         */
1011
-        public function show_field_checkbox_list($field, $meta)
1012
-        {
1013
-
1014
-            if (!is_array($meta))
1015
-                $meta = (array)$meta;
1016
-
1017
-            $this->show_field_begin($field, $meta);
1018
-
1019
-            $html = array();
1020
-
1021
-            foreach ($field['options'] as $key => $value) {
1022
-                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}";
1023
-            }
1024
-
1025
-            echo implode('<br />', $html);
1026
-
1027
-            $this->show_field_end($field, $meta);
1028
-
1029
-        }
1030
-
1031
-        /**
1032
-         * Show Date Field.
1033
-         *
1034
-         * @param string $field
1035
-         * @param string $meta
1036
-         * @since 1.0
1037
-         * @access public
1038
-         */
1039
-        public function show_field_date($field, $meta)
1040
-        {
1041
-            $this->show_field_begin($field, $meta);
1042
-            echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1043
-            $this->show_field_end($field, $meta);
1044
-        }
1045
-
1046
-        /**
1047
-         * Show time field.
1048
-         *
1049
-         * @param string $field
1050
-         * @param string $meta
1051
-         * @since 1.0
1052
-         * @access public
1053
-         */
1054
-        public function show_field_time($field, $meta)
1055
-        {
1056
-            $this->show_field_begin($field, $meta);
1057
-            echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1058
-            $this->show_field_end($field, $meta);
1059
-        }
1060
-
1061
-        /**
1062
-         * Show Posts field.
1063
-         * used creating a posts/pages/custom types checkboxlist or a select dropdown
1064
-         *
1065
-         * @global object $post The current post object.
1066
-         * @param string $field
1067
-         * @param string $meta
1068
-         * @since 1.0
1069
-         * @access public
1070
-         */
1071
-        public function show_field_posts($field, $meta)
1072
-        {
1073
-            global $post;
1074
-
1075
-            if (!is_array($meta)) $meta = (array)$meta;
1076
-            $this->show_field_begin($field, $meta);
1077
-            $options = $field['options'];
1078
-            $posts = get_posts($options['args']);
1079
-
1080
-            // checkbox_list
1081
-            if ('checkbox_list' == $options['type']) {
1082
-                foreach ($posts as $p) {
1083
-                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>";
1084
-                }
1085
-            } // select
1086
-            else {
1087
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1088
-                foreach ($posts as $p) {
1089
-                    echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1090
-                }
1091
-                echo "</select>";
1092
-            }
1093
-
1094
-            $this->show_field_end($field, $meta);
1095
-        }
1096
-
1097
-        /**
1098
-         * Show Taxonomy field.
1099
-         * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown
1100
-         *
1101
-         * @global object $post The current post object.
1102
-         * @param string $field
1103
-         * @param string $meta
1104
-         * @since 1.0
1105
-         * @access public
1106
-         *
1107
-         * @uses get_terms()
1108
-         */
1109
-        public function show_field_taxonomy($field, $meta)
1110
-        {
1111
-            global $post;
1112
-
1113
-            if (!is_array($meta)) $meta = (array)$meta;
1114
-            $this->show_field_begin($field, $meta);
1115
-            $options = $field['options'];
1116
-            $terms = get_terms($options['taxonomy'], $options['args']);
1117
-
1118
-            // checkbox_list
1119
-            if ('checkbox_list' == $options['type']) {
1120
-                foreach ($terms as $term) {
1121
-                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>";
1122
-                }
1123
-            } // select
1124
-            else {
1125
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1126
-                foreach ($terms as $term) {
1127
-                    echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1128
-                }
1129
-                echo "</select>";
1130
-            }
1131
-
1132
-            $this->show_field_end($field, $meta);
1133
-        }
1134
-
1135
-        /**
1136
-         * Save Data from Metabox
1137
-         *
1138
-         * @param string $term_id The term ID.
1139
-         * @since 1.0
1140
-         * @access public
1141
-         * @return string
1142
-         */
1143
-        public function save($term_id)
1144
-        {
1145
-
1146
-            $taxnow = '';
1147
-            if (isset($_POST['taxonomy']))
1148
-                $taxnow = $_POST['taxonomy'];
1149
-
1150
-            if (!isset($term_id)                                                        // Check Revision
1151
-                || (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1152
-                || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1153
-                || (!current_user_can('manage_categories'))
1154
-            )                                // Check permission
1155
-            {
1156
-                return $term_id;
1157
-            }
1158
-
1159
-
1160
-            foreach ($this->_fields as $field) {
1161
-
1162
-                $name = $field['id'];
1163
-                $type = $field['type'];
1164
-                $old = $this->get_tax_meta($term_id, $name, !$field['multiple']);
1165
-                $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : '');
1166
-
1167
-                // Validate meta value
1168
-                if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) {
1169
-                    $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new);
1170
-                }
1171
-
1172
-
1173
-                if ($name == 'ct_cat_icon') {
1174
-
1175
-                    $upload_dir = wp_upload_dir();
1176
-
1177
-                    $image_name_arr = explode('/', $new['src']);
1178
-                    //$old_filename = end($image_name_arr);
1179
-                    //$img_name_arr = explode('.',$old_filename);
1180
-
1181
-                    //$old_filename = $upload_dir['path'].'/'.$old_filename;
1182
-
1183
-                    $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1184
-
1185
-                    /*rename($old_filename, $new_filename);
661
+			$this->show_field_end($field, $meta);
662
+		}
663
+
664
+		/**
665
+		 * Begin Field.
666
+		 *
667
+		 * @param string $field
668
+		 * @param string $meta
669
+		 * @since 1.0
670
+		 * @access public
671
+		 */
672
+		public function show_field_begin($field, $meta)
673
+		{
674
+			if (isset($field['group'])) {
675
+				if ($field['group'] == "start") {
676
+					echo "<td class='at-field'>";
677
+				}
678
+			} else {
679
+				if ($this->_form_type == 'edit') {
680
+					echo '<th valign="top" scope="row">';
681
+				} else {
682
+					if ($field['validate_func']) {
683
+						echo '<td><div class="form-field form-required">';
684
+					} else {
685
+						echo '<td><div class="form-field">';
686
+					}
687
+				}
688
+			}
689
+			if ($field['name'] != '' || $field['name'] != FALSE) {
690
+				//echo "<div class='at-label'>";
691
+				echo "<label for='{$field['id']}'>{$field['name']}</label>";
692
+				//echo "</div>";
693
+			}
694
+			if ($this->_form_type == 'edit') {
695
+				echo '</th><td>';
696
+			}
697
+		}
698
+
699
+		/**
700
+		 * End Field.
701
+		 *
702
+		 * @param string $field
703
+		 * @param string $meta
704
+		 * @since 1.0
705
+		 * @access public
706
+		 */
707
+		public function show_field_end($field, $meta = NULL, $group = false)
708
+		{
709
+			if (isset($field['group'])) {
710
+				if ($group == 'end') {
711
+					if ($field['desc'] != '') {
712
+						echo "<p class='desc-field'>{$field['desc']}</p></td>";
713
+					} else {
714
+						echo "</td>";
715
+					}
716
+				} else {
717
+					if ($field['desc'] != '') {
718
+						echo "<p class='desc-field'>{$field['desc']}</p><br/>";
719
+					} else {
720
+						echo '<br/>';
721
+					}
722
+				}
723
+			} else {
724
+				if ($field['desc'] != '') {
725
+					echo "<p class='desc-field'>{$field['desc']}</p>";
726
+				}
727
+				if ($this->_form_type == 'edit') {
728
+					echo '</td>';
729
+				} else {
730
+					echo '</td></div>';
731
+				}
732
+			}
733
+		}
734
+
735
+		/**
736
+		 * Show Field Text.
737
+		 *
738
+		 * @param string $field
739
+		 * @param string $meta
740
+		 * @since 1.0
741
+		 * @access public
742
+		 */
743
+		public function show_field_text($field, $meta)
744
+		{
745
+			$this->show_field_begin($field, $meta);
746
+			echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />";
747
+			$this->show_field_end($field, $meta);
748
+		}
749
+
750
+		/**
751
+		 * Show Field hidden.
752
+		 *
753
+		 * @param string $field
754
+		 * @param string|mixed $meta
755
+		 * @since 0.1.3
756
+		 * @access public
757
+		 */
758
+		public function show_field_hidden($field, $meta)
759
+		{
760
+			//$this->show_field_begin( $field, $meta );
761
+			echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>";
762
+			//$this->show_field_end( $field, $meta );
763
+		}
764
+
765
+		/**
766
+		 * Show Field Paragraph.
767
+		 *
768
+		 * @param string $field
769
+		 * @since 0.1.3
770
+		 * @access public
771
+		 */
772
+		public function show_field_paragraph($field)
773
+		{
774
+			//$this->show_field_begin( $field, $meta );
775
+			echo '<p>' . $field['value'] . '</p>';
776
+			//$this->show_field_end( $field, $meta );
777
+		}
778
+
779
+		/**
780
+		 * Show Field Textarea.
781
+		 *
782
+		 * @param string $field
783
+		 * @param string $meta
784
+		 * @since 1.0
785
+		 * @access public
786
+		 */
787
+		public function show_field_textarea($field, $meta)
788
+		{
789
+			$this->show_field_begin($field, $meta);
790
+			echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
791
+			$this->show_field_end($field, $meta);
792
+		}
793
+
794
+		/**
795
+		 * Show Field Select.
796
+		 *
797
+		 * @param string $field
798
+		 * @param string $meta
799
+		 * @since 1.0
800
+		 * @access public
801
+		 */
802
+		public function show_field_select($field, $meta)
803
+		{
804
+
805
+			if (!is_array($meta))
806
+				$meta = (array)$meta;
807
+
808
+			$this->show_field_begin($field, $meta);
809
+			echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
810
+			foreach ($field['options'] as $key => $value) {
811
+				echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
812
+			}
813
+			echo "</select>";
814
+			$this->show_field_end($field, $meta);
815
+
816
+		}
817
+
818
+		/**
819
+		 * Show Radio Field.
820
+		 *
821
+		 * @param string $field
822
+		 * @param string $meta
823
+		 * @since 1.0
824
+		 * @access public
825
+		 */
826
+		public function show_field_radio($field, $meta)
827
+		{
828
+
829
+			if (!is_array($meta))
830
+				$meta = (array)$meta;
831
+
832
+			$this->show_field_begin($field, $meta);
833
+			foreach ($field['options'] as $key => $value) {
834
+				echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>";
835
+			}
836
+			$this->show_field_end($field, $meta);
837
+		}
838
+
839
+		/**
840
+		 * Show Checkbox Field.
841
+		 *
842
+		 * @param string $field
843
+		 * @param string $meta
844
+		 * @since 1.0
845
+		 * @access public
846
+		 */
847
+		public function show_field_checkbox($field, $meta)
848
+		{
849
+
850
+			$this->show_field_begin($field, $meta);
851
+			echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}";
852
+			$this->show_field_end($field, $meta);
853
+		}
854
+
855
+		/**
856
+		 * Show Wysiwig Field.
857
+		 *
858
+		 * @param string $field
859
+		 * @param string $meta
860
+		 * @since 1.0
861
+		 * @access public
862
+		 */
863
+		public function show_field_wysiwyg($field, $meta)
864
+		{
865
+			$this->show_field_begin($field, $meta);
866
+			// Add TinyMCE script for WP version < 3.3
867
+			global $wp_version;
868
+
869
+			if (version_compare($wp_version, '3.2.1') < 1) {
870
+				echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
871
+			} else {
872
+				// Use new wp_editor() since WP 3.3
873
+				wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg'));
874
+			}
875
+			$this->show_field_end($field, $meta);
876
+		}
877
+
878
+		/**
879
+		 * Show File Field.
880
+		 *
881
+		 * @global object $post The current post object.
882
+		 * @param string $field
883
+		 * @param string $meta
884
+		 * @since 1.0
885
+		 * @access public
886
+		 */
887
+		public function show_field_file($field, $meta)
888
+		{
889
+
890
+			global $post;
891
+
892
+			if (!is_array($meta))
893
+				$meta = (array)$meta;
894
+
895
+			$this->show_field_begin($field, $meta);
896
+			echo "{$field['desc']}<br />";
897
+
898
+			if (!empty($meta)) {
899
+				$nonce = wp_create_nonce('at_ajax_delete');
900
+				echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
901
+				echo '<ol class="at-upload">';
902
+				foreach ($meta as $att) {
903
+					// if (wp_attachment_is_image($att)) continue; // what's image uploader for?
904
+					echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>";
905
+				}
906
+				echo '</ol>';
907
+			}
908
+
909
+			// show form upload
910
+
911
+			echo "<div class='at-file-upload-label'>";
912
+			echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
913
+			echo "</div>";
914
+			echo "<div class='new-files'>";
915
+			echo "<div class='file-input'>";
916
+			echo "<input type='file' name='{$field['id']}[]' />";
917
+			echo "</div><!-- End .file-input -->";
918
+			echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
919
+			echo "</div><!-- End .new-files -->";
920
+			echo "</td>";
921
+			$this->show_field_end($field, $meta);
922
+		}
923
+
924
+		/**
925
+		 * Show Image Field.
926
+		 *
927
+		 * @param array $field
928
+		 * @param array $meta
929
+		 * @since 1.0
930
+		 * @access public
931
+		 */
932
+		public function show_field_image($field, $meta)
933
+		{
934
+			$this->show_field_begin($field, $meta);
935
+			$html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936
+			if (is_array($meta)) {
937
+				if (isset($meta[0]) && is_array($meta[0]))
938
+					$meta = $meta[0];
939
+			}
940
+
941
+			$uploads = wp_upload_dir();
942
+			if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') {
943
+				$file_info = pathinfo($meta['src']);
944
+
945
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
946
+					$sub_dir = $file_info['dirname'];
947
+
948
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
949
+				$uploads_baseurl = $uploads['baseurl'];
950
+				$uploads_path = $uploads['path'];
951
+
952
+				$file_name = $file_info['basename'];
953
+
954
+				if (strpos($sub_dir, 'https://') !== false) {
955
+					$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
956
+				} else {
957
+					$uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']);
958
+				}
959
+				$sub_dir = str_replace($uploads['baseurl'], '', $sub_dir);
960
+
961
+				$uploads_url = $uploads_baseurl . $sub_dir;
962
+
963
+				$meta['src'] = $uploads_url . '/' . $file_name;
964
+
965
+				$html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>";
966
+				$html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />";
967
+				$html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />";
968
+				$html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />";
969
+			} else {
970
+				$html .= "<span class='mupload_img_holder'></span>";
971
+				$html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />";
972
+				$html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />";
973
+				$html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />";
974
+			}
975
+			echo $html;
976
+			$this->show_field_end($field, $meta);
977
+		}
978
+
979
+		/**
980
+		 * Show Color Field.
981
+		 *
982
+		 * @param string $field
983
+		 * @param string $meta
984
+		 * @since 1.0
985
+		 * @access public
986
+		 */
987
+		public function show_field_color($field, $meta)
988
+		{
989
+
990
+			if (empty($meta))
991
+				$meta = '#';
992
+
993
+			$this->show_field_begin($field, $meta);
994
+
995
+			echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
996
+			//	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>";
997
+			echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>";
998
+			echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
999
+			$this->show_field_end($field, $meta);
1000
+
1001
+		}
1002
+
1003
+		/**
1004
+		 * Show Checkbox List Field
1005
+		 *
1006
+		 * @param string $field
1007
+		 * @param string $meta
1008
+		 * @since 1.0
1009
+		 * @access public
1010
+		 */
1011
+		public function show_field_checkbox_list($field, $meta)
1012
+		{
1013
+
1014
+			if (!is_array($meta))
1015
+				$meta = (array)$meta;
1016
+
1017
+			$this->show_field_begin($field, $meta);
1018
+
1019
+			$html = array();
1020
+
1021
+			foreach ($field['options'] as $key => $value) {
1022
+				$html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}";
1023
+			}
1024
+
1025
+			echo implode('<br />', $html);
1026
+
1027
+			$this->show_field_end($field, $meta);
1028
+
1029
+		}
1030
+
1031
+		/**
1032
+		 * Show Date Field.
1033
+		 *
1034
+		 * @param string $field
1035
+		 * @param string $meta
1036
+		 * @since 1.0
1037
+		 * @access public
1038
+		 */
1039
+		public function show_field_date($field, $meta)
1040
+		{
1041
+			$this->show_field_begin($field, $meta);
1042
+			echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1043
+			$this->show_field_end($field, $meta);
1044
+		}
1045
+
1046
+		/**
1047
+		 * Show time field.
1048
+		 *
1049
+		 * @param string $field
1050
+		 * @param string $meta
1051
+		 * @since 1.0
1052
+		 * @access public
1053
+		 */
1054
+		public function show_field_time($field, $meta)
1055
+		{
1056
+			$this->show_field_begin($field, $meta);
1057
+			echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1058
+			$this->show_field_end($field, $meta);
1059
+		}
1060
+
1061
+		/**
1062
+		 * Show Posts field.
1063
+		 * used creating a posts/pages/custom types checkboxlist or a select dropdown
1064
+		 *
1065
+		 * @global object $post The current post object.
1066
+		 * @param string $field
1067
+		 * @param string $meta
1068
+		 * @since 1.0
1069
+		 * @access public
1070
+		 */
1071
+		public function show_field_posts($field, $meta)
1072
+		{
1073
+			global $post;
1074
+
1075
+			if (!is_array($meta)) $meta = (array)$meta;
1076
+			$this->show_field_begin($field, $meta);
1077
+			$options = $field['options'];
1078
+			$posts = get_posts($options['args']);
1079
+
1080
+			// checkbox_list
1081
+			if ('checkbox_list' == $options['type']) {
1082
+				foreach ($posts as $p) {
1083
+					echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>";
1084
+				}
1085
+			} // select
1086
+			else {
1087
+				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1088
+				foreach ($posts as $p) {
1089
+					echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1090
+				}
1091
+				echo "</select>";
1092
+			}
1093
+
1094
+			$this->show_field_end($field, $meta);
1095
+		}
1096
+
1097
+		/**
1098
+		 * Show Taxonomy field.
1099
+		 * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown
1100
+		 *
1101
+		 * @global object $post The current post object.
1102
+		 * @param string $field
1103
+		 * @param string $meta
1104
+		 * @since 1.0
1105
+		 * @access public
1106
+		 *
1107
+		 * @uses get_terms()
1108
+		 */
1109
+		public function show_field_taxonomy($field, $meta)
1110
+		{
1111
+			global $post;
1112
+
1113
+			if (!is_array($meta)) $meta = (array)$meta;
1114
+			$this->show_field_begin($field, $meta);
1115
+			$options = $field['options'];
1116
+			$terms = get_terms($options['taxonomy'], $options['args']);
1117
+
1118
+			// checkbox_list
1119
+			if ('checkbox_list' == $options['type']) {
1120
+				foreach ($terms as $term) {
1121
+					echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>";
1122
+				}
1123
+			} // select
1124
+			else {
1125
+				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1126
+				foreach ($terms as $term) {
1127
+					echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1128
+				}
1129
+				echo "</select>";
1130
+			}
1131
+
1132
+			$this->show_field_end($field, $meta);
1133
+		}
1134
+
1135
+		/**
1136
+		 * Save Data from Metabox
1137
+		 *
1138
+		 * @param string $term_id The term ID.
1139
+		 * @since 1.0
1140
+		 * @access public
1141
+		 * @return string
1142
+		 */
1143
+		public function save($term_id)
1144
+		{
1145
+
1146
+			$taxnow = '';
1147
+			if (isset($_POST['taxonomy']))
1148
+				$taxnow = $_POST['taxonomy'];
1149
+
1150
+			if (!isset($term_id)                                                        // Check Revision
1151
+				|| (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1152
+				|| (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1153
+				|| (!current_user_can('manage_categories'))
1154
+			)                                // Check permission
1155
+			{
1156
+				return $term_id;
1157
+			}
1158
+
1159
+
1160
+			foreach ($this->_fields as $field) {
1161
+
1162
+				$name = $field['id'];
1163
+				$type = $field['type'];
1164
+				$old = $this->get_tax_meta($term_id, $name, !$field['multiple']);
1165
+				$new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : '');
1166
+
1167
+				// Validate meta value
1168
+				if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) {
1169
+					$new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new);
1170
+				}
1171
+
1172
+
1173
+				if ($name == 'ct_cat_icon') {
1174
+
1175
+					$upload_dir = wp_upload_dir();
1176
+
1177
+					$image_name_arr = explode('/', $new['src']);
1178
+					//$old_filename = end($image_name_arr);
1179
+					//$img_name_arr = explode('.',$old_filename);
1180
+
1181
+					//$old_filename = $upload_dir['path'].'/'.$old_filename;
1182
+
1183
+					$new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1184
+
1185
+					/*rename($old_filename, $new_filename);
1186 1186
 				
1187 1187
 				//subdir
1188 1188
 				$new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png';
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 				update_attached_file( $new['id'], $new['src'] );*/
1191 1191
 
1192 1192
 
1193
-                    /*	
1193
+					/*	
1194 1194
 		
1195 1195
 		$new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png';
1196 1196
 		
@@ -1215,67 +1215,67 @@  discard block
 block discarded – undo
1215 1215
 		$attach_id = wp_insert_attachment( $attachment, $filename);*/
1216 1216
 
1217 1217
 
1218
-                }
1219
-
1220
-
1221
-                //skip on Paragraph field
1222
-                if ($type != "paragraph") {
1223
-
1224
-                    // Call defined method to save meta value, if there's no methods, call common one.
1225
-                    $save_func = 'save_field_' . $type;
1226
-                    if (method_exists($this, $save_func)) {
1227
-                        call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1228
-                    } else {
1229
-                        $this->save_field($term_id, $field, $old, $new);
1230
-                    }
1231
-                }
1232
-
1233
-            } // End foreach
1234
-
1235
-        }
1236
-
1237
-        /**
1238
-         * Common function for saving fields.
1239
-         *
1240
-         * @param string $term_id The term ID.
1241
-         * @param string $field
1242
-         * @param string $old
1243
-         * @param string|mixed $new
1244
-         * @since 1.0
1245
-         * @access public
1246
-         */
1247
-        public function save_field($term_id, $field, $old, $new)
1248
-        {
1249
-            $name = $field['id'];
1250
-            $this->delete_tax_meta($term_id, $name);
1251
-            if ($new === '' || $new === array())
1252
-                return;
1253
-
1254
-            $this->update_tax_meta($term_id, $name, $new);
1255
-        }
1256
-
1257
-        /**
1258
-         * function for saving image field.
1259
-         *
1260
-         * @param string $term_id The term ID.
1261
-         * @param string $field
1262
-         * @param string $old
1263
-         * @param string|mixed $new
1264
-         * @since 1.0
1265
-         * @access public
1266
-         */
1267
-        public function save_field_image($term_id, $field, $old, $new)
1268
-        {
1269
-            $name = $field['id'];
1270
-
1271
-            $this->delete_tax_meta($term_id, $name);
1272
-            if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1273
-                return;
1274
-
1275
-            $this->update_tax_meta($term_id, $name, $new);
1276
-        }
1277
-
1278
-        /*
1218
+				}
1219
+
1220
+
1221
+				//skip on Paragraph field
1222
+				if ($type != "paragraph") {
1223
+
1224
+					// Call defined method to save meta value, if there's no methods, call common one.
1225
+					$save_func = 'save_field_' . $type;
1226
+					if (method_exists($this, $save_func)) {
1227
+						call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1228
+					} else {
1229
+						$this->save_field($term_id, $field, $old, $new);
1230
+					}
1231
+				}
1232
+
1233
+			} // End foreach
1234
+
1235
+		}
1236
+
1237
+		/**
1238
+		 * Common function for saving fields.
1239
+		 *
1240
+		 * @param string $term_id The term ID.
1241
+		 * @param string $field
1242
+		 * @param string $old
1243
+		 * @param string|mixed $new
1244
+		 * @since 1.0
1245
+		 * @access public
1246
+		 */
1247
+		public function save_field($term_id, $field, $old, $new)
1248
+		{
1249
+			$name = $field['id'];
1250
+			$this->delete_tax_meta($term_id, $name);
1251
+			if ($new === '' || $new === array())
1252
+				return;
1253
+
1254
+			$this->update_tax_meta($term_id, $name, $new);
1255
+		}
1256
+
1257
+		/**
1258
+		 * function for saving image field.
1259
+		 *
1260
+		 * @param string $term_id The term ID.
1261
+		 * @param string $field
1262
+		 * @param string $old
1263
+		 * @param string|mixed $new
1264
+		 * @since 1.0
1265
+		 * @access public
1266
+		 */
1267
+		public function save_field_image($term_id, $field, $old, $new)
1268
+		{
1269
+			$name = $field['id'];
1270
+
1271
+			$this->delete_tax_meta($term_id, $name);
1272
+			if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1273
+				return;
1274
+
1275
+			$this->update_tax_meta($term_id, $name, $new);
1276
+		}
1277
+
1278
+		/*
1279 1279
 	 * Save Wysiwyg Field.
1280 1280
 	 *
1281 1281
 	 * @param string $term_id The term ID. 
@@ -1285,806 +1285,806 @@  discard block
 block discarded – undo
1285 1285
 	 * @since 1.0
1286 1286
 	 * @access public 
1287 1287
 	 */
1288
-        public function save_field_wysiwyg($term_id, $field, $old, $new)
1289
-        {
1290
-            $this->save_field($term_id, $field, $old, $new);
1291
-        }
1292
-
1293
-        /**
1294
-         * Save repeater Fields.
1295
-         *
1296
-         * @param string $term_id The term ID.
1297
-         * @param string $field
1298
-         * @param string|mixed $old
1299
-         * @param string|mixed $new
1300
-         * @since 1.0
1301
-         * @access public
1302
-         */
1303
-        public function save_field_repeater($term_id, $field, $old, $new)
1304
-        {
1305
-            if (is_array($new) && count($new) > 0) {
1306
-                foreach ($new as $n) {
1307
-                    foreach ($field['fields'] as $f) {
1308
-                        $type = $f['type'];
1309
-                        switch ($type) {
1310
-                            case 'wysiwyg':
1311
-                                $n[$f['id']] = wpautop($n[$f['id']]);
1312
-                                break;
1313
-                            case 'file':
1314
-                                $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]);
1315
-                                break;
1316
-                            default:
1317
-                                break;
1318
-                        }
1319
-                    }
1320
-                    if (!$this->is_array_empty($n))
1321
-                        $temp[] = $n;
1322
-                }
1323
-                if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) {
1324
-                    $this->update_tax_meta($term_id, $field['id'], $temp);
1325
-                } else {
1326
-                    //	remove old meta if exists
1327
-                    delete_post_meta($term_id, $field['id']);
1328
-                }
1329
-            } else {
1330
-                //	remove old meta if exists
1331
-                delete_post_meta($term_id, $field['id']);
1332
-            }
1333
-        }
1334
-
1335
-        /**
1336
-         * Save File Field.
1337
-         *
1338
-         * @param string $term_id The term ID.
1339
-         * @param string $field
1340
-         * @param string $old
1341
-         * @param string $new
1342
-         * @since 1.0
1343
-         * @access public
1344
-         */
1345
-        public function save_field_file($term_id, $field, $old, $new)
1346
-        {
1347
-
1348
-            $name = $field['id'];
1349
-            if (empty($_FILES[$name]))
1350
-                return;
1351
-            $this->fix_file_array($_FILES[$name]);
1352
-            foreach ($_FILES[$name] as $position => $fileitem) {
1353
-
1354
-                $file = wp_handle_upload($fileitem, array('test_form' => false));
1355
-                if (empty($file['file']))
1356
-                    continue;
1357
-                $filename = $file['file'];
1358
-
1359
-                $attachment = array(
1360
-                    'post_mime_type' => $file['type'],
1361
-                    'guid' => $file['url'],
1362
-                    'post_parent' => $term_id,
1363
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1364
-                    'post_content' => ''
1365
-                );
1366
-
1367
-                $id = wp_insert_attachment($attachment, $filename, $term_id);
1368
-
1369
-                if (!is_wp_error($id)) {
1370
-
1371
-                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1372
-                    add_post_meta($term_id, $name, $id, false);    // save file's url in meta fields
1373
-
1374
-                } // End if
1375
-
1376
-            } // End foreach
1377
-
1378
-        }
1379
-
1380
-        /**
1381
-         * Save repeater File Field.
1382
-         * @param string $term_id The term ID.
1383
-         * @param string $field
1384
-         * @param string $old
1385
-         * @param string $new
1386
-         * @since 1.0
1387
-         * @access public
1388
-         * @return int|void
1389
-         */
1390
-        public function save_field_file_repeater($term_id, $field, $old, $new)
1391
-        {
1392
-
1393
-            $name = $field['id'];
1394
-            if (empty($_FILES[$name]))
1395
-                return;
1396
-            $this->fix_file_array($_FILES[$name]);
1397
-            foreach ($_FILES[$name] as $position => $fileitem) {
1398
-
1399
-                $file = wp_handle_upload($fileitem, array('test_form' => false));
1400
-                if (empty($file['file']))
1401
-                    continue;
1402
-                $filename = $file['file'];
1403
-
1404
-                $attachment = array(
1405
-                    'post_mime_type' => $file['type'],
1406
-                    'guid' => $file['url'],
1407
-                    'post_parent' => $term_id,
1408
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1409
-                    'post_content' => ''
1410
-                );
1411
-
1412
-                $id = wp_insert_attachment($attachment, $filename);
1413
-
1414
-                if (!is_wp_error($id)) {
1415
-
1416
-                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1417
-                    return $id;    // return file's url in meta fields
1418
-                } // End if
1419
-            } // End foreach
1420
-        }
1421
-
1422
-        /**
1423
-         * Add missed values for meta box.
1424
-         *
1425
-         * @since 1.0
1426
-         * @access public
1427
-         */
1428
-        public function add_missed_values()
1429
-        {
1430
-
1431
-            // Default values for meta box
1432
-            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box);
1433
-
1434
-            if(is_array($this->_fields)) {
1435
-                // Default values for fields
1436
-                foreach ($this->_fields as &$field) {
1437
-                    $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image'));
1438
-                    $std = $multiple ? array() : '';
1439
-                    $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : '');
1440
-                    $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field);
1441
-                } // End foreach
1442
-            }
1443
-        }
1444
-
1445
-        /**
1446
-         * Check if field with $type exists.
1447
-         *
1448
-         * @param string $type
1449
-         * @since 1.0
1450
-         * @access public
1451
-         */
1452
-        public function has_field($type)
1453
-        {
1454
-            if(is_array($this->_fields)) {
1455
-                foreach ($this->_fields as $field) {
1456
-                    if ($type == $field['type'])
1457
-                        return true;
1458
-                }
1459
-            }
1460
-            return false;
1461
-        }
1462
-
1463
-        /**
1464
-         * Check if current page is edit page.
1465
-         *
1466
-         * @since 1.0
1467
-         * @access public
1468
-         */
1469
-        public function is_edit_page()
1470
-        {
1471
-            global $pagenow;
1472
-            return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php');
1473
-        }
1474
-
1475
-        /**
1476
-         * Fixes the odd indexing of multiple file uploads.
1477
-         *
1478
-         * Goes from the format:
1479
-         * $_FILES['field']['key']['index']
1480
-         * to
1481
-         * The More standard and appropriate:
1482
-         * $_FILES['field']['index']['key']
1483
-         *
1484
-         * @param string $files
1485
-         * @since 1.0
1486
-         * @access public
1487
-         */
1488
-        public function fix_file_array(&$files)
1489
-        {
1490
-
1491
-            $output = array();
1492
-
1493
-            foreach ($files as $key => $list) {
1494
-                foreach ($list as $index => $value) {
1495
-                    $output[$index][$key] = $value;
1496
-                }
1497
-            }
1498
-
1499
-            return $files = $output;
1500
-
1501
-        }
1502
-
1503
-        /**
1504
-         * Get proper JQuery UI version.
1505
-         *
1506
-         * Used in order to not conflict with WP Admin Scripts.
1507
-         *
1508
-         * @since 1.0
1509
-         * @access public
1510
-         */
1511
-        public function get_jqueryui_ver()
1512
-        {
1513
-
1514
-            global $wp_version;
1515
-
1516
-            if (version_compare($wp_version, '3.1', '>=')) {
1517
-                return '1.8.10';
1518
-            }
1519
-
1520
-            return '1.7.3';
1521
-
1522
-        }
1523
-
1524
-        /**
1525
-         *  Add Field to meta box (generic function)
1526
-         * @author Ohad Raz
1527
-         * @since 1.0
1528
-         * @access public
1529
-         * @param $id string  field id, i.e. the meta key
1530
-         * @param $args mixed|array
1531
-         */
1532
-        public function addField($id, $args)
1533
-        {
1534
-            $new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => '');
1535
-            $new_field = array_merge($new_field, $args);
1536
-            $this->_fields[] = $new_field;
1537
-        }
1538
-
1539
-
1540
-        /**
1541
-         *  Add Text Field to meta box
1542
-         * @author Ohad Raz
1543
-         * @since 1.0
1544
-         * @access public
1545
-         * @param $id string  field id, i.e. the meta key
1546
-         * @param $args mixed|array
1547
-         *    'name' => // field name/label string optional
1548
-         *    'desc' => // field description, string optional
1549
-         *    'std' => // default value, string optional
1550
-         *    'style' =>    // custom style for field, string optional
1551
-         *    'validate_func' => // validate function, string optional
1552
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1553
-         */
1554
-        public function addText($id, $args, $repeater = false)
1555
-        {
1556
-            $new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1557
-            $new_field = array_merge($new_field, $args);
1558
-            if (false === $repeater) {
1559
-                $this->_fields[] = $new_field;
1560
-            } else {
1561
-                return $new_field;
1562
-            }
1563
-        }
1564
-
1565
-        /**
1566
-         *  Add Hidden Field to meta box
1567
-         * @author Ohad Raz
1568
-         * @since 0.1.3
1569
-         * @access public
1570
-         * @param $id string  field id, i.e. the meta key
1571
-         * @param $args mixed|array
1572
-         *    'name' => // field name/label string optional
1573
-         *    'desc' => // field description, string optional
1574
-         *    'std' => // default value, string optional
1575
-         *    'style' =>    // custom style for field, string optional
1576
-         *    'validate_func' => // validate function, string optional
1577
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1578
-         */
1579
-        public function addHidden($id, $args, $repeater = false)
1580
-        {
1581
-            $new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1582
-            $new_field = array_merge($new_field, $args);
1583
-            if (false === $repeater) {
1584
-                $this->_fields[] = $new_field;
1585
-            } else {
1586
-                return $new_field;
1587
-            }
1588
-        }
1589
-
1590
-        /**
1591
-         *  Add Paragraph to meta box
1592
-         * @author Ohad Raz
1593
-         * @since 0.1.3
1594
-         * @access public
1595
-         * @param $id string  field id, i.e. the meta key
1596
-         * @param $value  paragraph html
1597
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1598
-         */
1599
-        public function addParagraph($id, $args, $repeater = false)
1600
-        {
1601
-            $new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => '');
1602
-            $new_field = array_merge($new_field, $args);
1603
-            if (false === $repeater) {
1604
-                $this->_fields[] = $new_field;
1605
-            } else {
1606
-                return $new_field;
1607
-            }
1608
-        }
1609
-
1610
-        /**
1611
-         *  Add Checkbox Field to meta box
1612
-         * @author Ohad Raz
1613
-         * @since 1.0
1614
-         * @access public
1615
-         * @param $id string  field id, i.e. the meta key
1616
-         * @param $args mixed|array
1617
-         *    'name' => // field name/label string optional
1618
-         *    'desc' => // field description, string optional
1619
-         *    'std' => // default value, string optional
1620
-         *    'validate_func' => // validate function, string optional
1621
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1622
-         */
1623
-        public function addCheckbox($id, $args, $repeater = false)
1624
-        {
1625
-            $new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory'));
1626
-            $new_field = array_merge($new_field, $args);
1627
-            if (false === $repeater) {
1628
-                $this->_fields[] = $new_field;
1629
-            } else {
1630
-                return $new_field;
1631
-            }
1632
-        }
1633
-
1634
-        /**
1635
-         *  Add CheckboxList Field to meta box
1636
-         * @author Ohad Raz
1637
-         * @since 1.0
1638
-         * @access public
1639
-         * @param $id string  field id, i.e. the meta key
1640
-         * @param $options (array)  array of key => value pairs for select options
1641
-         * @param $args mixed|array
1642
-         *    'name' => // field name/label string optional
1643
-         *    'desc' => // field description, string optional
1644
-         *    'std' => // default value, string optional
1645
-         *    'validate_func' => // validate function, string optional
1646
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1647
-         *
1648
-         * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false);
1649
-         *   which means the last param as false to get the values in an array
1650
-         */
1651
-        public function addCheckboxList($id, $options, $args, $repeater = false)
1652
-        {
1653
-            $new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory'));
1654
-            $new_field = array_merge($new_field, $args);
1655
-            if (false === $repeater) {
1656
-                $this->_fields[] = $new_field;
1657
-            } else {
1658
-                return $new_field;
1659
-            }
1660
-        }
1661
-
1662
-        /**
1663
-         *  Add Textarea Field to meta box
1664
-         * @author Ohad Raz
1665
-         * @since 1.0
1666
-         * @access public
1667
-         * @param $id string  field id, i.e. the meta key
1668
-         * @param $args mixed|array
1669
-         *    'name' => // field name/label string optional
1670
-         *    'desc' => // field description, string optional
1671
-         *    'std' => // default value, string optional
1672
-         *    'style' =>    // custom style for field, string optional
1673
-         *    'validate_func' => // validate function, string optional
1674
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1675
-         */
1676
-        public function addTextarea($id, $args, $repeater = false)
1677
-        {
1678
-            $new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory'));
1679
-            $new_field = array_merge($new_field, $args);
1680
-            if (false === $repeater) {
1681
-                $this->_fields[] = $new_field;
1682
-            } else {
1683
-                return $new_field;
1684
-            }
1685
-        }
1686
-
1687
-        /**
1688
-         *  Add Select Field to meta box
1689
-         * @author Ohad Raz
1690
-         * @since 1.0
1691
-         * @access public
1692
-         * @param $id string field id, i.e. the meta key
1693
-         * @param $options (array)  array of key => value pairs for select options
1694
-         * @param $args mixed|array
1695
-         *    'name' => // field name/label string optional
1696
-         *    'desc' => // field description, string optional
1697
-         *    'std' => // default value, (array) optional
1698
-         *    'multiple' => // select multiple values, optional. Default is false.
1699
-         *    'validate_func' => // validate function, string optional
1700
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1701
-         */
1702
-        public function addSelect($id, $options, $args, $repeater = false)
1703
-        {
1704
-            $new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options);
1705
-            $new_field = array_merge($new_field, $args);
1706
-            if (false === $repeater) {
1707
-                $this->_fields[] = $new_field;
1708
-            } else {
1709
-                return $new_field;
1710
-            }
1711
-        }
1712
-
1713
-
1714
-        /**
1715
-         *  Add Radio Field to meta box
1716
-         * @author Ohad Raz
1717
-         * @since 1.0
1718
-         * @access public
1719
-         * @param $id string field id, i.e. the meta key
1720
-         * @param $options (array)  array of key => value pairs for radio options
1721
-         * @param $args mixed|array
1722
-         *    'name' => // field name/label string optional
1723
-         *    'desc' => // field description, string optional
1724
-         *    'std' => // default value, string optional
1725
-         *    'validate_func' => // validate function, string optional
1726
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1727
-         */
1728
-        public function addRadio($id, $options, $args, $repeater = false)
1729
-        {
1730
-            $new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options);
1731
-            $new_field = array_merge($new_field, $args);
1732
-            if (false === $repeater) {
1733
-                $this->_fields[] = $new_field;
1734
-            } else {
1735
-                return $new_field;
1736
-            }
1737
-        }
1738
-
1739
-        /**
1740
-         *  Add Date Field to meta box
1741
-         * @author Ohad Raz
1742
-         * @since 1.0
1743
-         * @access public
1744
-         * @param $id string  field id, i.e. the meta key
1745
-         * @param $args mixed|array
1746
-         *    'name' => // field name/label string optional
1747
-         *    'desc' => // field description, string optional
1748
-         *    'std' => // default value, string optional
1749
-         *    'validate_func' => // validate function, string optional
1750
-         *    'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'"  See more formats here: http://goo.gl/Wcwxn
1751
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1752
-         */
1753
-        public function addDate($id, $args, $repeater = false)
1754
-        {
1755
-            $new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory'));
1756
-            $new_field = array_merge($new_field, $args);
1757
-            if (false === $repeater) {
1758
-                $this->_fields[] = $new_field;
1759
-            } else {
1760
-                return $new_field;
1761
-            }
1762
-        }
1763
-
1764
-        /**
1765
-         *  Add Time Field to meta box
1766
-         * @author Ohad Raz
1767
-         * @since 1.0
1768
-         * @access public
1769
-         * @param $id string- field id, i.e. the meta key
1770
-         * @param $args mixed|array
1771
-         *    'name' => // field name/label string optional
1772
-         *    'desc' => // field description, string optional
1773
-         *    'std' => // default value, string optional
1774
-         *    'validate_func' => // validate function, string optional
1775
-         *    'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX
1776
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1777
-         */
1778
-        public function addTime($id, $args, $repeater = false)
1779
-        {
1780
-            $new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory'));
1781
-            $new_field = array_merge($new_field, $args);
1782
-            if (false === $repeater) {
1783
-                $this->_fields[] = $new_field;
1784
-            } else {
1785
-                return $new_field;
1786
-            }
1787
-        }
1788
-
1789
-        /**
1790
-         *  Add Color Field to meta box
1791
-         * @author Ohad Raz
1792
-         * @since 1.0
1793
-         * @access public
1794
-         * @param $id string  field id, i.e. the meta key
1795
-         * @param $args mixed|array
1796
-         *    'name' => // field name/label string optional
1797
-         *    'desc' => // field description, string optional
1798
-         *    'std' => // default value, string optional
1799
-         *    'validate_func' => // validate function, string optional
1800
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1801
-         */
1802
-        public function addColor($id, $args, $repeater = false)
1803
-        {
1804
-            $new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory'));
1805
-            $new_field = array_merge($new_field, $args);
1806
-            if (false === $repeater) {
1807
-                $this->_fields[] = $new_field;
1808
-            } else {
1809
-                return $new_field;
1810
-            }
1811
-        }
1812
-
1813
-        /**
1814
-         *  Add Image Field to meta box
1815
-         * @author Ohad Raz
1816
-         * @since 1.0
1817
-         * @access public
1818
-         * @param $id string  field id, i.e. the meta key
1819
-         * @param $args mixed|array
1820
-         *    'name' => // field name/label string optional
1821
-         *    'desc' => // field description, string optional
1822
-         *    'validate_func' => // validate function, string optional
1823
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1824
-         */
1825
-        public function addImage($id, $args, $repeater = false)
1826
-        {
1827
-            $new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory'));
1828
-            $new_field = array_merge($new_field, $args);
1829
-
1830
-            if (false === $repeater) {
1831
-                $this->_fields[] = $new_field;
1832
-            } else {
1833
-                return $new_field;
1834
-            }
1835
-        }
1836
-
1837
-        /**
1838
-         *  Add File Field to meta box
1839
-         * @author Ohad Raz
1840
-         * @since 1.0
1841
-         * @access public
1842
-         * @param $id string  field id, i.e. the meta key
1843
-         * @param $args mixed|array
1844
-         *    'name' => // field name/label string optional
1845
-         *    'desc' => // field description, string optional
1846
-         *    'validate_func' => // validate function, string optional
1847
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1848
-         */
1849
-        public function addFile($id, $args, $repeater = false)
1850
-        {
1851
-            $new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory'));
1852
-            $new_field = array_merge($new_field, $args);
1853
-            if (false === $repeater) {
1854
-                $this->_fields[] = $new_field;
1855
-            } else {
1856
-                return $new_field;
1857
-            }
1858
-        }
1859
-
1860
-        /**
1861
-         *  Add WYSIWYG Field to meta box
1862
-         * @author Ohad Raz
1863
-         * @since 1.0
1864
-         * @access public
1865
-         * @param $id string  field id, i.e. the meta key
1866
-         * @param $args mixed|array
1867
-         *    'name' => // field name/label string optional
1868
-         *    'desc' => // field description, string optional
1869
-         *    'std' => // default value, string optional
1870
-         *    'style' =>    // custom style for field, string optional Default 'width: 300px; height: 400px'
1871
-         *    'validate_func' => // validate function, string optional
1872
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1873
-         */
1874
-        public function addWysiwyg($id, $args, $repeater = false)
1875
-        {
1876
-            $new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory'));
1877
-            $new_field = array_merge($new_field, $args);
1878
-            if (false === $repeater) {
1879
-                $this->_fields[] = $new_field;
1880
-            } else {
1881
-                return $new_field;
1882
-            }
1883
-        }
1884
-
1885
-        /**
1886
-         *  Add Taxonomy Field to meta box
1887
-         * @author Ohad Raz
1888
-         * @since 1.0
1889
-         * @access public
1890
-         * @param $id string  field id, i.e. the meta key
1891
-         * @param $options mixed|array options of taxonomy field
1892
-         *    'taxonomy' =>    // taxonomy name can be category,post_tag or any custom taxonomy default is category
1893
-         * 'type' =>  // how to show taxonomy? 'select' (default) or 'checkbox_list'
1894
-         * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false)
1895
-         * @param $args mixed|array
1896
-         *    'name' => // field name/label string optional
1897
-         *    'desc' => // field description, string optional
1898
-         *    'std' => // default value, string optional
1899
-         *    'validate_func' => // validate function, string optional
1900
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1901
-         */
1902
-        public function addTaxonomy($id, $options, $args, $repeater = false)
1903
-        {
1904
-            $q = array('hide_empty' => 0);
1905
-            $tax = 'category';
1906
-            $type = 'select';
1907
-            $temp = array($tax, $type, $q);
1908
-            $options = array_merge($temp, $options);
1909
-            $new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options);
1910
-            $new_field = array_merge($new_field, $args);
1911
-            if (false === $repeater) {
1912
-                $this->_fields[] = $new_field;
1913
-            } else {
1914
-                return $new_field;
1915
-            }
1916
-        }
1917
-
1918
-        /**
1919
-         *  Add posts Field to meta box
1920
-         * @author Ohad Raz
1921
-         * @since 1.0
1922
-         * @access public
1923
-         * @param $id string  field id, i.e. the meta key
1924
-         * @param $options mixed|array options of taxonomy field
1925
-         *    'post_type' =>    // post type name, 'post' (default) 'page' or any custom post type
1926
-         * 'type' =>  // how to show posts? 'select' (default) or 'checkbox_list'
1927
-         * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1)
1928
-         * @param $args mixed|array
1929
-         *    'name' => // field name/label string optional
1930
-         *    'desc' => // field description, string optional
1931
-         *    'std' => // default value, string optional
1932
-         *    'validate_func' => // validate function, string optional
1933
-         * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1934
-         */
1935
-        public function addPosts($id, $options, $args, $repeater = false)
1936
-        {
1937
-            $q = array('posts_per_page' => -1);
1938
-            $temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q);
1939
-            $options = array_merge($temp, $options);
1940
-            $new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options);
1941
-            $new_field = array_merge($new_field, $args);
1942
-            if (false === $repeater) {
1943
-                $this->_fields[] = $new_field;
1944
-            } else {
1945
-                return $new_field;
1946
-            }
1947
-        }
1948
-
1949
-        /**
1950
-         *  Add repeater Field Block to meta box
1951
-         * @author Ohad Raz
1952
-         * @since 1.0
1953
-         * @access public
1954
-         * @param $id string  field id, i.e. the meta key
1955
-         * @param $args mixed|array
1956
-         *    'name' => // field name/label string optional
1957
-         *    'desc' => // field description, string optional
1958
-         *    'std' => // default value, string optional
1959
-         *    'style' =>    // custom style for field, string optional
1960
-         *    'validate_func' => // validate function, string optional
1961
-         *    'fields' => //fields to repeater
1962
-         */
1963
-        public function addRepeaterBlock($id, $args)
1964
-        {
1965
-            $new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false);
1966
-            $new_field = array_merge($new_field, $args);
1967
-            $this->_fields[] = $new_field;
1968
-        }
1969
-
1970
-
1971
-        /**
1972
-         * Finish Declaration of Meta Box
1973
-         * @author Ohad Raz
1974
-         * @since 1.0
1975
-         * @access public
1976
-         */
1977
-        public function Finish()
1978
-        {
1979
-            $this->add_missed_values();
1980
-            $this->check_field_upload();
1981
-            $this->check_field_color();
1982
-            $this->check_field_date();
1983
-            $this->check_field_time();
1984
-        }
1985
-
1986
-        /**
1987
-         * Helper function to check for empty arrays
1988
-         * @author Ohad Raz
1989
-         * @since 1.0
1990
-         * @access public
1991
-         * @param $args mixed|array
1992
-         */
1993
-        public function is_array_empty($array)
1994
-        {
1995
-            if (!is_array($array))
1996
-                return true;
1997
-
1998
-            foreach ($array as $a) {
1999
-                if (is_array($a)) {
2000
-                    foreach ($a as $sub_a) {
2001
-                        if (!empty($sub_a) && $sub_a != '')
2002
-                            return false;
2003
-                    }
2004
-                } else {
2005
-                    if (!empty($a) && $a != '')
2006
-                        return false;
2007
-                }
2008
-            }
2009
-            return true;
2010
-        }
2011
-
2012
-
2013
-        //get term meta field
2014
-        public function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2015
-        {
2016
-
2017
-            if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2018
-                $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2019
-                $post_type = $taxObject->object_type[0];
2020
-            }
2021
-
2022
-            if($post_type=='post'){$post_type='';}
2023
-            if($post_type){$post_type = $post_type.'_';}
2024
-
2025
-            $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2026
-
2027
-            $m = get_option('tax_meta_' . $post_type  . $t_id);
2028
-            if (isset($m[$key])) {
2029
-                return $m[$key];
2030
-            } else {
2031
-                return '';
2032
-            }
2033
-        }
2034
-
2035
-        //delete meta
2036
-        public function delete_tax_meta($term_id, $key, $post_type = '')
2037
-        {
2038
-
2039
-            if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2040
-                $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2041
-                $post_type = $taxObject->object_type[0];
2042
-            }
2043
-
2044
-            if($post_type=='post'){$post_type='';}
2045
-            if($post_type){$post_type = $post_type.'_';}
2046
-
2047
-            $m = get_option('tax_meta_' . $post_type  . $term_id);
2048
-
2049
-            if (isset($m[$key])) {
2050
-                unset($m[$key]);
2051
-            }
2052
-            update_option('tax_meta_' . $post_type  . $term_id, $m);
2053
-        }
2054
-
2055
-        //update meta
2056
-        public function update_tax_meta($term_id, $key, $value, $post_type = '')
2057
-        {
2058
-
2059
-            if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2060
-                $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2061
-                $post_type = $taxObject->object_type[0];
2062
-            }
2063
-
2064
-            if($post_type=='post'){$post_type='';}
2065
-            if($post_type){$post_type = $post_type.'_';}
2066
-
2067
-            $m = get_option('tax_meta_' . $post_type  . $term_id);
2068
-
2069
-            $m[$key] = $value;
2070
-            update_option('tax_meta_' . $post_type  . $term_id, $m);
2071
-
2072
-            /**
2073
-             * Called after the tax meta is updated.
2074
-             *
2075
-             * Used to update things after a GD category is saved.
2076
-             *
2077
-             * @since 1.0.0
2078
-             * @param bool $false False.
2079
-             * @param bool $true True.
2080
-             * @param int $term_id The term id being updated.
2081
-             * @param string $post_type The post type of the cat being updated.
2082
-             */
2083
-            do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2084
-        }
2085
-
2086
-
2087
-    } // End Class
1288
+		public function save_field_wysiwyg($term_id, $field, $old, $new)
1289
+		{
1290
+			$this->save_field($term_id, $field, $old, $new);
1291
+		}
1292
+
1293
+		/**
1294
+		 * Save repeater Fields.
1295
+		 *
1296
+		 * @param string $term_id The term ID.
1297
+		 * @param string $field
1298
+		 * @param string|mixed $old
1299
+		 * @param string|mixed $new
1300
+		 * @since 1.0
1301
+		 * @access public
1302
+		 */
1303
+		public function save_field_repeater($term_id, $field, $old, $new)
1304
+		{
1305
+			if (is_array($new) && count($new) > 0) {
1306
+				foreach ($new as $n) {
1307
+					foreach ($field['fields'] as $f) {
1308
+						$type = $f['type'];
1309
+						switch ($type) {
1310
+							case 'wysiwyg':
1311
+								$n[$f['id']] = wpautop($n[$f['id']]);
1312
+								break;
1313
+							case 'file':
1314
+								$n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]);
1315
+								break;
1316
+							default:
1317
+								break;
1318
+						}
1319
+					}
1320
+					if (!$this->is_array_empty($n))
1321
+						$temp[] = $n;
1322
+				}
1323
+				if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) {
1324
+					$this->update_tax_meta($term_id, $field['id'], $temp);
1325
+				} else {
1326
+					//	remove old meta if exists
1327
+					delete_post_meta($term_id, $field['id']);
1328
+				}
1329
+			} else {
1330
+				//	remove old meta if exists
1331
+				delete_post_meta($term_id, $field['id']);
1332
+			}
1333
+		}
1334
+
1335
+		/**
1336
+		 * Save File Field.
1337
+		 *
1338
+		 * @param string $term_id The term ID.
1339
+		 * @param string $field
1340
+		 * @param string $old
1341
+		 * @param string $new
1342
+		 * @since 1.0
1343
+		 * @access public
1344
+		 */
1345
+		public function save_field_file($term_id, $field, $old, $new)
1346
+		{
1347
+
1348
+			$name = $field['id'];
1349
+			if (empty($_FILES[$name]))
1350
+				return;
1351
+			$this->fix_file_array($_FILES[$name]);
1352
+			foreach ($_FILES[$name] as $position => $fileitem) {
1353
+
1354
+				$file = wp_handle_upload($fileitem, array('test_form' => false));
1355
+				if (empty($file['file']))
1356
+					continue;
1357
+				$filename = $file['file'];
1358
+
1359
+				$attachment = array(
1360
+					'post_mime_type' => $file['type'],
1361
+					'guid' => $file['url'],
1362
+					'post_parent' => $term_id,
1363
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1364
+					'post_content' => ''
1365
+				);
1366
+
1367
+				$id = wp_insert_attachment($attachment, $filename, $term_id);
1368
+
1369
+				if (!is_wp_error($id)) {
1370
+
1371
+					wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1372
+					add_post_meta($term_id, $name, $id, false);    // save file's url in meta fields
1373
+
1374
+				} // End if
1375
+
1376
+			} // End foreach
1377
+
1378
+		}
1379
+
1380
+		/**
1381
+		 * Save repeater File Field.
1382
+		 * @param string $term_id The term ID.
1383
+		 * @param string $field
1384
+		 * @param string $old
1385
+		 * @param string $new
1386
+		 * @since 1.0
1387
+		 * @access public
1388
+		 * @return int|void
1389
+		 */
1390
+		public function save_field_file_repeater($term_id, $field, $old, $new)
1391
+		{
1392
+
1393
+			$name = $field['id'];
1394
+			if (empty($_FILES[$name]))
1395
+				return;
1396
+			$this->fix_file_array($_FILES[$name]);
1397
+			foreach ($_FILES[$name] as $position => $fileitem) {
1398
+
1399
+				$file = wp_handle_upload($fileitem, array('test_form' => false));
1400
+				if (empty($file['file']))
1401
+					continue;
1402
+				$filename = $file['file'];
1403
+
1404
+				$attachment = array(
1405
+					'post_mime_type' => $file['type'],
1406
+					'guid' => $file['url'],
1407
+					'post_parent' => $term_id,
1408
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1409
+					'post_content' => ''
1410
+				);
1411
+
1412
+				$id = wp_insert_attachment($attachment, $filename);
1413
+
1414
+				if (!is_wp_error($id)) {
1415
+
1416
+					wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1417
+					return $id;    // return file's url in meta fields
1418
+				} // End if
1419
+			} // End foreach
1420
+		}
1421
+
1422
+		/**
1423
+		 * Add missed values for meta box.
1424
+		 *
1425
+		 * @since 1.0
1426
+		 * @access public
1427
+		 */
1428
+		public function add_missed_values()
1429
+		{
1430
+
1431
+			// Default values for meta box
1432
+			$this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box);
1433
+
1434
+			if(is_array($this->_fields)) {
1435
+				// Default values for fields
1436
+				foreach ($this->_fields as &$field) {
1437
+					$multiple = in_array($field['type'], array('checkbox_list', 'file', 'image'));
1438
+					$std = $multiple ? array() : '';
1439
+					$format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : '');
1440
+					$field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field);
1441
+				} // End foreach
1442
+			}
1443
+		}
1444
+
1445
+		/**
1446
+		 * Check if field with $type exists.
1447
+		 *
1448
+		 * @param string $type
1449
+		 * @since 1.0
1450
+		 * @access public
1451
+		 */
1452
+		public function has_field($type)
1453
+		{
1454
+			if(is_array($this->_fields)) {
1455
+				foreach ($this->_fields as $field) {
1456
+					if ($type == $field['type'])
1457
+						return true;
1458
+				}
1459
+			}
1460
+			return false;
1461
+		}
1462
+
1463
+		/**
1464
+		 * Check if current page is edit page.
1465
+		 *
1466
+		 * @since 1.0
1467
+		 * @access public
1468
+		 */
1469
+		public function is_edit_page()
1470
+		{
1471
+			global $pagenow;
1472
+			return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php');
1473
+		}
1474
+
1475
+		/**
1476
+		 * Fixes the odd indexing of multiple file uploads.
1477
+		 *
1478
+		 * Goes from the format:
1479
+		 * $_FILES['field']['key']['index']
1480
+		 * to
1481
+		 * The More standard and appropriate:
1482
+		 * $_FILES['field']['index']['key']
1483
+		 *
1484
+		 * @param string $files
1485
+		 * @since 1.0
1486
+		 * @access public
1487
+		 */
1488
+		public function fix_file_array(&$files)
1489
+		{
1490
+
1491
+			$output = array();
1492
+
1493
+			foreach ($files as $key => $list) {
1494
+				foreach ($list as $index => $value) {
1495
+					$output[$index][$key] = $value;
1496
+				}
1497
+			}
1498
+
1499
+			return $files = $output;
1500
+
1501
+		}
1502
+
1503
+		/**
1504
+		 * Get proper JQuery UI version.
1505
+		 *
1506
+		 * Used in order to not conflict with WP Admin Scripts.
1507
+		 *
1508
+		 * @since 1.0
1509
+		 * @access public
1510
+		 */
1511
+		public function get_jqueryui_ver()
1512
+		{
1513
+
1514
+			global $wp_version;
1515
+
1516
+			if (version_compare($wp_version, '3.1', '>=')) {
1517
+				return '1.8.10';
1518
+			}
1519
+
1520
+			return '1.7.3';
1521
+
1522
+		}
1523
+
1524
+		/**
1525
+		 *  Add Field to meta box (generic function)
1526
+		 * @author Ohad Raz
1527
+		 * @since 1.0
1528
+		 * @access public
1529
+		 * @param $id string  field id, i.e. the meta key
1530
+		 * @param $args mixed|array
1531
+		 */
1532
+		public function addField($id, $args)
1533
+		{
1534
+			$new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => '');
1535
+			$new_field = array_merge($new_field, $args);
1536
+			$this->_fields[] = $new_field;
1537
+		}
1538
+
1539
+
1540
+		/**
1541
+		 *  Add Text Field to meta box
1542
+		 * @author Ohad Raz
1543
+		 * @since 1.0
1544
+		 * @access public
1545
+		 * @param $id string  field id, i.e. the meta key
1546
+		 * @param $args mixed|array
1547
+		 *    'name' => // field name/label string optional
1548
+		 *    'desc' => // field description, string optional
1549
+		 *    'std' => // default value, string optional
1550
+		 *    'style' =>    // custom style for field, string optional
1551
+		 *    'validate_func' => // validate function, string optional
1552
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1553
+		 */
1554
+		public function addText($id, $args, $repeater = false)
1555
+		{
1556
+			$new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1557
+			$new_field = array_merge($new_field, $args);
1558
+			if (false === $repeater) {
1559
+				$this->_fields[] = $new_field;
1560
+			} else {
1561
+				return $new_field;
1562
+			}
1563
+		}
1564
+
1565
+		/**
1566
+		 *  Add Hidden Field to meta box
1567
+		 * @author Ohad Raz
1568
+		 * @since 0.1.3
1569
+		 * @access public
1570
+		 * @param $id string  field id, i.e. the meta key
1571
+		 * @param $args mixed|array
1572
+		 *    'name' => // field name/label string optional
1573
+		 *    'desc' => // field description, string optional
1574
+		 *    'std' => // default value, string optional
1575
+		 *    'style' =>    // custom style for field, string optional
1576
+		 *    'validate_func' => // validate function, string optional
1577
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1578
+		 */
1579
+		public function addHidden($id, $args, $repeater = false)
1580
+		{
1581
+			$new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory'));
1582
+			$new_field = array_merge($new_field, $args);
1583
+			if (false === $repeater) {
1584
+				$this->_fields[] = $new_field;
1585
+			} else {
1586
+				return $new_field;
1587
+			}
1588
+		}
1589
+
1590
+		/**
1591
+		 *  Add Paragraph to meta box
1592
+		 * @author Ohad Raz
1593
+		 * @since 0.1.3
1594
+		 * @access public
1595
+		 * @param $id string  field id, i.e. the meta key
1596
+		 * @param $value  paragraph html
1597
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1598
+		 */
1599
+		public function addParagraph($id, $args, $repeater = false)
1600
+		{
1601
+			$new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => '');
1602
+			$new_field = array_merge($new_field, $args);
1603
+			if (false === $repeater) {
1604
+				$this->_fields[] = $new_field;
1605
+			} else {
1606
+				return $new_field;
1607
+			}
1608
+		}
1609
+
1610
+		/**
1611
+		 *  Add Checkbox Field to meta box
1612
+		 * @author Ohad Raz
1613
+		 * @since 1.0
1614
+		 * @access public
1615
+		 * @param $id string  field id, i.e. the meta key
1616
+		 * @param $args mixed|array
1617
+		 *    'name' => // field name/label string optional
1618
+		 *    'desc' => // field description, string optional
1619
+		 *    'std' => // default value, string optional
1620
+		 *    'validate_func' => // validate function, string optional
1621
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1622
+		 */
1623
+		public function addCheckbox($id, $args, $repeater = false)
1624
+		{
1625
+			$new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory'));
1626
+			$new_field = array_merge($new_field, $args);
1627
+			if (false === $repeater) {
1628
+				$this->_fields[] = $new_field;
1629
+			} else {
1630
+				return $new_field;
1631
+			}
1632
+		}
1633
+
1634
+		/**
1635
+		 *  Add CheckboxList Field to meta box
1636
+		 * @author Ohad Raz
1637
+		 * @since 1.0
1638
+		 * @access public
1639
+		 * @param $id string  field id, i.e. the meta key
1640
+		 * @param $options (array)  array of key => value pairs for select options
1641
+		 * @param $args mixed|array
1642
+		 *    'name' => // field name/label string optional
1643
+		 *    'desc' => // field description, string optional
1644
+		 *    'std' => // default value, string optional
1645
+		 *    'validate_func' => // validate function, string optional
1646
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1647
+		 *
1648
+		 * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false);
1649
+		 *   which means the last param as false to get the values in an array
1650
+		 */
1651
+		public function addCheckboxList($id, $options, $args, $repeater = false)
1652
+		{
1653
+			$new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory'));
1654
+			$new_field = array_merge($new_field, $args);
1655
+			if (false === $repeater) {
1656
+				$this->_fields[] = $new_field;
1657
+			} else {
1658
+				return $new_field;
1659
+			}
1660
+		}
1661
+
1662
+		/**
1663
+		 *  Add Textarea Field to meta box
1664
+		 * @author Ohad Raz
1665
+		 * @since 1.0
1666
+		 * @access public
1667
+		 * @param $id string  field id, i.e. the meta key
1668
+		 * @param $args mixed|array
1669
+		 *    'name' => // field name/label string optional
1670
+		 *    'desc' => // field description, string optional
1671
+		 *    'std' => // default value, string optional
1672
+		 *    'style' =>    // custom style for field, string optional
1673
+		 *    'validate_func' => // validate function, string optional
1674
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1675
+		 */
1676
+		public function addTextarea($id, $args, $repeater = false)
1677
+		{
1678
+			$new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory'));
1679
+			$new_field = array_merge($new_field, $args);
1680
+			if (false === $repeater) {
1681
+				$this->_fields[] = $new_field;
1682
+			} else {
1683
+				return $new_field;
1684
+			}
1685
+		}
1686
+
1687
+		/**
1688
+		 *  Add Select Field to meta box
1689
+		 * @author Ohad Raz
1690
+		 * @since 1.0
1691
+		 * @access public
1692
+		 * @param $id string field id, i.e. the meta key
1693
+		 * @param $options (array)  array of key => value pairs for select options
1694
+		 * @param $args mixed|array
1695
+		 *    'name' => // field name/label string optional
1696
+		 *    'desc' => // field description, string optional
1697
+		 *    'std' => // default value, (array) optional
1698
+		 *    'multiple' => // select multiple values, optional. Default is false.
1699
+		 *    'validate_func' => // validate function, string optional
1700
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1701
+		 */
1702
+		public function addSelect($id, $options, $args, $repeater = false)
1703
+		{
1704
+			$new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options);
1705
+			$new_field = array_merge($new_field, $args);
1706
+			if (false === $repeater) {
1707
+				$this->_fields[] = $new_field;
1708
+			} else {
1709
+				return $new_field;
1710
+			}
1711
+		}
1712
+
1713
+
1714
+		/**
1715
+		 *  Add Radio Field to meta box
1716
+		 * @author Ohad Raz
1717
+		 * @since 1.0
1718
+		 * @access public
1719
+		 * @param $id string field id, i.e. the meta key
1720
+		 * @param $options (array)  array of key => value pairs for radio options
1721
+		 * @param $args mixed|array
1722
+		 *    'name' => // field name/label string optional
1723
+		 *    'desc' => // field description, string optional
1724
+		 *    'std' => // default value, string optional
1725
+		 *    'validate_func' => // validate function, string optional
1726
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1727
+		 */
1728
+		public function addRadio($id, $options, $args, $repeater = false)
1729
+		{
1730
+			$new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options);
1731
+			$new_field = array_merge($new_field, $args);
1732
+			if (false === $repeater) {
1733
+				$this->_fields[] = $new_field;
1734
+			} else {
1735
+				return $new_field;
1736
+			}
1737
+		}
1738
+
1739
+		/**
1740
+		 *  Add Date Field to meta box
1741
+		 * @author Ohad Raz
1742
+		 * @since 1.0
1743
+		 * @access public
1744
+		 * @param $id string  field id, i.e. the meta key
1745
+		 * @param $args mixed|array
1746
+		 *    'name' => // field name/label string optional
1747
+		 *    'desc' => // field description, string optional
1748
+		 *    'std' => // default value, string optional
1749
+		 *    'validate_func' => // validate function, string optional
1750
+		 *    'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'"  See more formats here: http://goo.gl/Wcwxn
1751
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1752
+		 */
1753
+		public function addDate($id, $args, $repeater = false)
1754
+		{
1755
+			$new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory'));
1756
+			$new_field = array_merge($new_field, $args);
1757
+			if (false === $repeater) {
1758
+				$this->_fields[] = $new_field;
1759
+			} else {
1760
+				return $new_field;
1761
+			}
1762
+		}
1763
+
1764
+		/**
1765
+		 *  Add Time Field to meta box
1766
+		 * @author Ohad Raz
1767
+		 * @since 1.0
1768
+		 * @access public
1769
+		 * @param $id string- field id, i.e. the meta key
1770
+		 * @param $args mixed|array
1771
+		 *    'name' => // field name/label string optional
1772
+		 *    'desc' => // field description, string optional
1773
+		 *    'std' => // default value, string optional
1774
+		 *    'validate_func' => // validate function, string optional
1775
+		 *    'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX
1776
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1777
+		 */
1778
+		public function addTime($id, $args, $repeater = false)
1779
+		{
1780
+			$new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory'));
1781
+			$new_field = array_merge($new_field, $args);
1782
+			if (false === $repeater) {
1783
+				$this->_fields[] = $new_field;
1784
+			} else {
1785
+				return $new_field;
1786
+			}
1787
+		}
1788
+
1789
+		/**
1790
+		 *  Add Color Field to meta box
1791
+		 * @author Ohad Raz
1792
+		 * @since 1.0
1793
+		 * @access public
1794
+		 * @param $id string  field id, i.e. the meta key
1795
+		 * @param $args mixed|array
1796
+		 *    'name' => // field name/label string optional
1797
+		 *    'desc' => // field description, string optional
1798
+		 *    'std' => // default value, string optional
1799
+		 *    'validate_func' => // validate function, string optional
1800
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1801
+		 */
1802
+		public function addColor($id, $args, $repeater = false)
1803
+		{
1804
+			$new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory'));
1805
+			$new_field = array_merge($new_field, $args);
1806
+			if (false === $repeater) {
1807
+				$this->_fields[] = $new_field;
1808
+			} else {
1809
+				return $new_field;
1810
+			}
1811
+		}
1812
+
1813
+		/**
1814
+		 *  Add Image Field to meta box
1815
+		 * @author Ohad Raz
1816
+		 * @since 1.0
1817
+		 * @access public
1818
+		 * @param $id string  field id, i.e. the meta key
1819
+		 * @param $args mixed|array
1820
+		 *    'name' => // field name/label string optional
1821
+		 *    'desc' => // field description, string optional
1822
+		 *    'validate_func' => // validate function, string optional
1823
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1824
+		 */
1825
+		public function addImage($id, $args, $repeater = false)
1826
+		{
1827
+			$new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory'));
1828
+			$new_field = array_merge($new_field, $args);
1829
+
1830
+			if (false === $repeater) {
1831
+				$this->_fields[] = $new_field;
1832
+			} else {
1833
+				return $new_field;
1834
+			}
1835
+		}
1836
+
1837
+		/**
1838
+		 *  Add File Field to meta box
1839
+		 * @author Ohad Raz
1840
+		 * @since 1.0
1841
+		 * @access public
1842
+		 * @param $id string  field id, i.e. the meta key
1843
+		 * @param $args mixed|array
1844
+		 *    'name' => // field name/label string optional
1845
+		 *    'desc' => // field description, string optional
1846
+		 *    'validate_func' => // validate function, string optional
1847
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1848
+		 */
1849
+		public function addFile($id, $args, $repeater = false)
1850
+		{
1851
+			$new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory'));
1852
+			$new_field = array_merge($new_field, $args);
1853
+			if (false === $repeater) {
1854
+				$this->_fields[] = $new_field;
1855
+			} else {
1856
+				return $new_field;
1857
+			}
1858
+		}
1859
+
1860
+		/**
1861
+		 *  Add WYSIWYG Field to meta box
1862
+		 * @author Ohad Raz
1863
+		 * @since 1.0
1864
+		 * @access public
1865
+		 * @param $id string  field id, i.e. the meta key
1866
+		 * @param $args mixed|array
1867
+		 *    'name' => // field name/label string optional
1868
+		 *    'desc' => // field description, string optional
1869
+		 *    'std' => // default value, string optional
1870
+		 *    'style' =>    // custom style for field, string optional Default 'width: 300px; height: 400px'
1871
+		 *    'validate_func' => // validate function, string optional
1872
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1873
+		 */
1874
+		public function addWysiwyg($id, $args, $repeater = false)
1875
+		{
1876
+			$new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory'));
1877
+			$new_field = array_merge($new_field, $args);
1878
+			if (false === $repeater) {
1879
+				$this->_fields[] = $new_field;
1880
+			} else {
1881
+				return $new_field;
1882
+			}
1883
+		}
1884
+
1885
+		/**
1886
+		 *  Add Taxonomy Field to meta box
1887
+		 * @author Ohad Raz
1888
+		 * @since 1.0
1889
+		 * @access public
1890
+		 * @param $id string  field id, i.e. the meta key
1891
+		 * @param $options mixed|array options of taxonomy field
1892
+		 *    'taxonomy' =>    // taxonomy name can be category,post_tag or any custom taxonomy default is category
1893
+		 * 'type' =>  // how to show taxonomy? 'select' (default) or 'checkbox_list'
1894
+		 * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false)
1895
+		 * @param $args mixed|array
1896
+		 *    'name' => // field name/label string optional
1897
+		 *    'desc' => // field description, string optional
1898
+		 *    'std' => // default value, string optional
1899
+		 *    'validate_func' => // validate function, string optional
1900
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1901
+		 */
1902
+		public function addTaxonomy($id, $options, $args, $repeater = false)
1903
+		{
1904
+			$q = array('hide_empty' => 0);
1905
+			$tax = 'category';
1906
+			$type = 'select';
1907
+			$temp = array($tax, $type, $q);
1908
+			$options = array_merge($temp, $options);
1909
+			$new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options);
1910
+			$new_field = array_merge($new_field, $args);
1911
+			if (false === $repeater) {
1912
+				$this->_fields[] = $new_field;
1913
+			} else {
1914
+				return $new_field;
1915
+			}
1916
+		}
1917
+
1918
+		/**
1919
+		 *  Add posts Field to meta box
1920
+		 * @author Ohad Raz
1921
+		 * @since 1.0
1922
+		 * @access public
1923
+		 * @param $id string  field id, i.e. the meta key
1924
+		 * @param $options mixed|array options of taxonomy field
1925
+		 *    'post_type' =>    // post type name, 'post' (default) 'page' or any custom post type
1926
+		 * 'type' =>  // how to show posts? 'select' (default) or 'checkbox_list'
1927
+		 * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1)
1928
+		 * @param $args mixed|array
1929
+		 *    'name' => // field name/label string optional
1930
+		 *    'desc' => // field description, string optional
1931
+		 *    'std' => // default value, string optional
1932
+		 *    'validate_func' => // validate function, string optional
1933
+		 * @param $repeater bool  is this a field inside a repeatr? true|false(default)
1934
+		 */
1935
+		public function addPosts($id, $options, $args, $repeater = false)
1936
+		{
1937
+			$q = array('posts_per_page' => -1);
1938
+			$temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q);
1939
+			$options = array_merge($temp, $options);
1940
+			$new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options);
1941
+			$new_field = array_merge($new_field, $args);
1942
+			if (false === $repeater) {
1943
+				$this->_fields[] = $new_field;
1944
+			} else {
1945
+				return $new_field;
1946
+			}
1947
+		}
1948
+
1949
+		/**
1950
+		 *  Add repeater Field Block to meta box
1951
+		 * @author Ohad Raz
1952
+		 * @since 1.0
1953
+		 * @access public
1954
+		 * @param $id string  field id, i.e. the meta key
1955
+		 * @param $args mixed|array
1956
+		 *    'name' => // field name/label string optional
1957
+		 *    'desc' => // field description, string optional
1958
+		 *    'std' => // default value, string optional
1959
+		 *    'style' =>    // custom style for field, string optional
1960
+		 *    'validate_func' => // validate function, string optional
1961
+		 *    'fields' => //fields to repeater
1962
+		 */
1963
+		public function addRepeaterBlock($id, $args)
1964
+		{
1965
+			$new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false);
1966
+			$new_field = array_merge($new_field, $args);
1967
+			$this->_fields[] = $new_field;
1968
+		}
1969
+
1970
+
1971
+		/**
1972
+		 * Finish Declaration of Meta Box
1973
+		 * @author Ohad Raz
1974
+		 * @since 1.0
1975
+		 * @access public
1976
+		 */
1977
+		public function Finish()
1978
+		{
1979
+			$this->add_missed_values();
1980
+			$this->check_field_upload();
1981
+			$this->check_field_color();
1982
+			$this->check_field_date();
1983
+			$this->check_field_time();
1984
+		}
1985
+
1986
+		/**
1987
+		 * Helper function to check for empty arrays
1988
+		 * @author Ohad Raz
1989
+		 * @since 1.0
1990
+		 * @access public
1991
+		 * @param $args mixed|array
1992
+		 */
1993
+		public function is_array_empty($array)
1994
+		{
1995
+			if (!is_array($array))
1996
+				return true;
1997
+
1998
+			foreach ($array as $a) {
1999
+				if (is_array($a)) {
2000
+					foreach ($a as $sub_a) {
2001
+						if (!empty($sub_a) && $sub_a != '')
2002
+							return false;
2003
+					}
2004
+				} else {
2005
+					if (!empty($a) && $a != '')
2006
+						return false;
2007
+				}
2008
+			}
2009
+			return true;
2010
+		}
2011
+
2012
+
2013
+		//get term meta field
2014
+		public function get_tax_meta($term_id, $key, $multi = false, $post_type = '')
2015
+		{
2016
+
2017
+			if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2018
+				$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2019
+				$post_type = $taxObject->object_type[0];
2020
+			}
2021
+
2022
+			if($post_type=='post'){$post_type='';}
2023
+			if($post_type){$post_type = $post_type.'_';}
2024
+
2025
+			$t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2026
+
2027
+			$m = get_option('tax_meta_' . $post_type  . $t_id);
2028
+			if (isset($m[$key])) {
2029
+				return $m[$key];
2030
+			} else {
2031
+				return '';
2032
+			}
2033
+		}
2034
+
2035
+		//delete meta
2036
+		public function delete_tax_meta($term_id, $key, $post_type = '')
2037
+		{
2038
+
2039
+			if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2040
+				$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2041
+				$post_type = $taxObject->object_type[0];
2042
+			}
2043
+
2044
+			if($post_type=='post'){$post_type='';}
2045
+			if($post_type){$post_type = $post_type.'_';}
2046
+
2047
+			$m = get_option('tax_meta_' . $post_type  . $term_id);
2048
+
2049
+			if (isset($m[$key])) {
2050
+				unset($m[$key]);
2051
+			}
2052
+			update_option('tax_meta_' . $post_type  . $term_id, $m);
2053
+		}
2054
+
2055
+		//update meta
2056
+		public function update_tax_meta($term_id, $key, $value, $post_type = '')
2057
+		{
2058
+
2059
+			if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2060
+				$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2061
+				$post_type = $taxObject->object_type[0];
2062
+			}
2063
+
2064
+			if($post_type=='post'){$post_type='';}
2065
+			if($post_type){$post_type = $post_type.'_';}
2066
+
2067
+			$m = get_option('tax_meta_' . $post_type  . $term_id);
2068
+
2069
+			$m[$key] = $value;
2070
+			update_option('tax_meta_' . $post_type  . $term_id, $m);
2071
+
2072
+			/**
2073
+			 * Called after the tax meta is updated.
2074
+			 *
2075
+			 * Used to update things after a GD category is saved.
2076
+			 *
2077
+			 * @since 1.0.0
2078
+			 * @param bool $false False.
2079
+			 * @param bool $true True.
2080
+			 * @param int $term_id The term id being updated.
2081
+			 * @param string $post_type The post type of the cat being updated.
2082
+			 */
2083
+			do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2084
+		}
2085
+
2086
+
2087
+	} // End Class
2088 2088
 
2089 2089
 endif; // End Check Class Exists
2090 2090
 
@@ -2094,79 +2094,79 @@  discard block
 block discarded – undo
2094 2094
 
2095 2095
 //get term meta field
2096 2096
 if (!function_exists('geodir_get_tax_meta')) {
2097
-    function geodir_get_tax_meta($term_id, $key, $multi = false, $post_type = '') {
2098
-        if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2099
-            $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2097
+	function geodir_get_tax_meta($term_id, $key, $multi = false, $post_type = '') {
2098
+		if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2099
+			$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2100 2100
             
2101
-            if (!empty($taxObject->object_type)) {
2102
-                $post_type = $taxObject->object_type[0];
2103
-            }
2104
-        }
2105
-
2106
-        if ($post_type == 'post') {
2107
-            $post_type = '';
2108
-        }
2109
-        if ($post_type) {
2110
-            $post_type = $post_type . '_';
2111
-        }
2112
-
2113
-        $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2114
-
2115
-        $m = get_option('tax_meta_' . $post_type  . $t_id);
2116
-        if (isset($m[$key])) {
2117
-            return $m[$key];
2118
-        } else {
2119
-            return '';
2120
-        }
2121
-    }
2101
+			if (!empty($taxObject->object_type)) {
2102
+				$post_type = $taxObject->object_type[0];
2103
+			}
2104
+		}
2105
+
2106
+		if ($post_type == 'post') {
2107
+			$post_type = '';
2108
+		}
2109
+		if ($post_type) {
2110
+			$post_type = $post_type . '_';
2111
+		}
2112
+
2113
+		$t_id = (is_object($term_id)) ? $term_id->term_id : $term_id;
2114
+
2115
+		$m = get_option('tax_meta_' . $post_type  . $t_id);
2116
+		if (isset($m[$key])) {
2117
+			return $m[$key];
2118
+		} else {
2119
+			return '';
2120
+		}
2121
+	}
2122 2122
 }
2123 2123
 
2124 2124
 //delete meta
2125 2125
 if (!function_exists('geodir_delete_tax_meta')) {
2126
-    function geodir_delete_tax_meta($term_id, $key) {
2127
-        $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2128
-        $post_type = !empty($taxObject->object_type) ? $taxObject->object_type[0] : '';
2129
-
2130
-        if ($post_type == 'post') {
2131
-            $post_type = '';
2132
-        }
2133
-        if ($post_type) {
2134
-            $post_type = $post_type . '_';
2135
-        }
2136
-
2137
-        $m = get_option('tax_meta_' . $post_type . $term_id);
2138
-
2139
-        if (isset($m[$key])) {
2140
-            unset($m[$key]);
2141
-        }
2142
-        update_option('tax_meta_' . $post_type  . $term_id, $m);
2143
-    }
2126
+	function geodir_delete_tax_meta($term_id, $key) {
2127
+		$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2128
+		$post_type = !empty($taxObject->object_type) ? $taxObject->object_type[0] : '';
2129
+
2130
+		if ($post_type == 'post') {
2131
+			$post_type = '';
2132
+		}
2133
+		if ($post_type) {
2134
+			$post_type = $post_type . '_';
2135
+		}
2136
+
2137
+		$m = get_option('tax_meta_' . $post_type . $term_id);
2138
+
2139
+		if (isset($m[$key])) {
2140
+			unset($m[$key]);
2141
+		}
2142
+		update_option('tax_meta_' . $post_type  . $term_id, $m);
2143
+	}
2144 2144
 }
2145 2145
 
2146 2146
 //update meta
2147 2147
 if (!function_exists('geodir_update_tax_meta')) {
2148
-    function geodir_update_tax_meta($term_id, $key, $value, $post_type = '') {
2149
-        if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2150
-            $taxObject = get_taxonomy($_REQUEST['taxonomy']);
2148
+	function geodir_update_tax_meta($term_id, $key, $value, $post_type = '') {
2149
+		if (empty($post_type) && isset($_REQUEST['taxonomy'])) {
2150
+			$taxObject = get_taxonomy($_REQUEST['taxonomy']);
2151 2151
             
2152
-            if (!empty($taxObject->object_type)) {
2153
-                $post_type = $taxObject->object_type[0];
2154
-            }
2155
-        }
2156
-
2157
-        if ($post_type == 'post') {
2158
-            $post_type = '';
2159
-        }
2160
-        if ($post_type) {
2161
-            $post_type = $post_type . '_';
2162
-        }
2163
-
2164
-        $m = get_option('tax_meta_' . $post_type  . $term_id);
2165
-
2166
-        $m[$key] = $value;
2167
-        update_option('tax_meta_' . $post_type . $term_id, $m);
2168
-
2169
-        /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */
2170
-        do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2171
-    }
2152
+			if (!empty($taxObject->object_type)) {
2153
+				$post_type = $taxObject->object_type[0];
2154
+			}
2155
+		}
2156
+
2157
+		if ($post_type == 'post') {
2158
+			$post_type = '';
2159
+		}
2160
+		if ($post_type) {
2161
+			$post_type = $post_type . '_';
2162
+		}
2163
+
2164
+		$m = get_option('tax_meta_' . $post_type  . $term_id);
2165
+
2166
+		$m[$key] = $value;
2167
+		update_option('tax_meta_' . $post_type . $term_id, $m);
2168
+
2169
+		/** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */
2170
+		do_action('gd_tax_meta_updated', false, true, $term_id, $post_type);
2171
+	}
2172 2172
 }
2173 2173
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/post_functions.php 1 patch
Indentation   +2264 added lines, -2264 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
-    {
912
+	/**
913
+	 * Save post attachments.
914
+	 *
915
+	 * @since 1.0.0
916
+	 * @package GeoDirectory
917
+	 * @global object $wpdb WordPress Database object.
918
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
919
+	 * @global object $current_user Current user object.
920
+	 * @param int $post_id The post ID.
921
+	 * @param array $post_image Post image urls as an array.
922
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
923
+	 */
924
+	function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
925
+	{
926 926
 
927 927
 
928
-        global $wpdb, $plugin_prefix, $current_user;
928
+		global $wpdb, $plugin_prefix, $current_user;
929 929
 
930
-        $post_type = get_post_type($post_id);
930
+		$post_type = get_post_type($post_id);
931 931
 
932
-        $table = $plugin_prefix . $post_type . '_detail';
932
+		$table = $plugin_prefix . $post_type . '_detail';
933 933
 
934
-        $post_images = geodir_get_images($post_id);
934
+		$post_images = geodir_get_images($post_id);
935 935
 
936
-        $wpdb->query(
937
-            $wpdb->prepare(
938
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
939
-                array($post_id)
940
-            )
941
-        );
936
+		$wpdb->query(
937
+			$wpdb->prepare(
938
+				"UPDATE " . $table . " SET featured_image = '' where post_id =%d",
939
+				array($post_id)
940
+			)
941
+		);
942 942
 
943
-        $invalid_files = $post_images;
944
-        $valid_file_ids = array();
945
-        $valid_files_condition = '';
946
-        $geodir_uploaddir = '';
943
+		$invalid_files = $post_images;
944
+		$valid_file_ids = array();
945
+		$valid_files_condition = '';
946
+		$geodir_uploaddir = '';
947 947
 
948
-        $remove_files = array();
948
+		$remove_files = array();
949 949
 
950
-        if (!empty($post_image)) {
950
+		if (!empty($post_image)) {
951 951
 
952
-            $uploads = wp_upload_dir();
953
-            $uploads_dir = $uploads['path'];
952
+			$uploads = wp_upload_dir();
953
+			$uploads_dir = $uploads['path'];
954 954
 
955
-            $geodir_uploadpath = $uploads['path'];
956
-            $geodir_uploadurl = $uploads['url'];
957
-            $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
955
+			$geodir_uploadpath = $uploads['path'];
956
+			$geodir_uploadurl = $uploads['url'];
957
+			$sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
958 958
 
959
-            $invalid_files = array();
960
-            $postcurr_images = array();
959
+			$invalid_files = array();
960
+			$postcurr_images = array();
961 961
 
962
-            for ($m = 0; $m < count($post_image); $m++) {
963
-                $menu_order = $m + 1;
962
+			for ($m = 0; $m < count($post_image); $m++) {
963
+				$menu_order = $m + 1;
964 964
 
965
-                $file_path = '';
966
-                /* --------- start ------- */
965
+				$file_path = '';
966
+				/* --------- start ------- */
967 967
 
968
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
968
+				$split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
969 969
 
970
-                $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
970
+				$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
971 971
 
972 972
 
973
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
973
+				if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
974 974
 
975
-                    /* --------- end ------- */
976
-                    $curr_img_url = $post_image[$m];
975
+					/* --------- end ------- */
976
+					$curr_img_url = $post_image[$m];
977 977
 
978
-                    $image_name_arr = explode('/', $curr_img_url);
978
+					$image_name_arr = explode('/', $curr_img_url);
979 979
 
980
-                    $count_image_name_arr = count($image_name_arr) - 2;
980
+					$count_image_name_arr = count($image_name_arr) - 2;
981 981
 
982
-                    $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
982
+					$count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
983 983
 
984
-                    $curr_img_dir = $image_name_arr[$count_image_name_arr];
984
+					$curr_img_dir = $image_name_arr[$count_image_name_arr];
985 985
 
986
-                    $filename = end($image_name_arr);
987
-                    if (strpos($filename, '?') !== false) {
988
-                        list($filename) = explode('?', $filename);
989
-                    }
986
+					$filename = end($image_name_arr);
987
+					if (strpos($filename, '?') !== false) {
988
+						list($filename) = explode('?', $filename);
989
+					}
990 990
 
991
-                    $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
992
-                    $curr_img_dir = str_replace($filename, "", $curr_img_dir);
991
+					$curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
992
+					$curr_img_dir = str_replace($filename, "", $curr_img_dir);
993 993
 
994
-                    $img_name_arr = explode('.', $filename);
994
+					$img_name_arr = explode('.', $filename);
995 995
 
996
-                    $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
997
-                    if (!empty($img_name_arr) && count($img_name_arr) > 2) {
998
-                        $new_img_name_arr = $img_name_arr;
999
-                        if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
1000
-                            unset($new_img_name_arr[count($img_name_arr) - 1]);
1001
-                            $file_title = implode('.', $new_img_name_arr);
1002
-                        }
1003
-                    }
1004
-                    $file_title = sanitize_file_name($file_title);
1005
-                    $file_name = sanitize_file_name($filename);
996
+					$file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
997
+					if (!empty($img_name_arr) && count($img_name_arr) > 2) {
998
+						$new_img_name_arr = $img_name_arr;
999
+						if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
1000
+							unset($new_img_name_arr[count($img_name_arr) - 1]);
1001
+							$file_title = implode('.', $new_img_name_arr);
1002
+						}
1003
+					}
1004
+					$file_title = sanitize_file_name($file_title);
1005
+					$file_name = sanitize_file_name($filename);
1006 1006
 
1007
-                    $arr_file_type = wp_check_filetype($filename);
1007
+					$arr_file_type = wp_check_filetype($filename);
1008 1008
 
1009
-                    $uploaded_file_type = $arr_file_type['type'];
1009
+					$uploaded_file_type = $arr_file_type['type'];
1010 1010
 
1011
-                    // Set an array containing a list of acceptable formats
1012
-                    $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1011
+					// Set an array containing a list of acceptable formats
1012
+					$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1013 1013
 
1014
-                    // If the uploaded file is the right format
1015
-                    if (in_array($uploaded_file_type, $allowed_file_types)) {
1016
-                        if (!function_exists('wp_handle_upload')) {
1017
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1018
-                        }
1014
+					// If the uploaded file is the right format
1015
+					if (in_array($uploaded_file_type, $allowed_file_types)) {
1016
+						if (!function_exists('wp_handle_upload')) {
1017
+							require_once(ABSPATH . 'wp-admin/includes/file.php');
1018
+						}
1019 1019
 
1020
-                        if (!is_dir($geodir_uploadpath)) {
1021
-                            mkdir($geodir_uploadpath);
1022
-                        }
1020
+						if (!is_dir($geodir_uploadpath)) {
1021
+							mkdir($geodir_uploadpath);
1022
+						}
1023 1023
 
1024
-                        $external_img = false;
1025
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1026
-                        } else {
1027
-                            $external_img = true;
1028
-                        }
1024
+						$external_img = false;
1025
+						if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1026
+						} else {
1027
+							$external_img = true;
1028
+						}
1029 1029
 
1030
-                        if ($dummy || $external_img) {
1031
-                            $uploaded_file = array();
1032
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1030
+						if ($dummy || $external_img) {
1031
+							$uploaded_file = array();
1032
+							$uploaded = (array)fetch_remote_file($curr_img_url);
1033 1033
 
1034
-                            if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035
-                                $new_name = basename($uploaded['file']);
1036
-                                $uploaded_file = $uploaded;
1037
-                            }else{
1038
-                                print_r($uploaded);exit;
1039
-                            }
1040
-                            $external_img = false;
1041
-                        } else {
1042
-                            $new_name = $post_id . '_' . $file_name;
1034
+							if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035
+								$new_name = basename($uploaded['file']);
1036
+								$uploaded_file = $uploaded;
1037
+							}else{
1038
+								print_r($uploaded);exit;
1039
+							}
1040
+							$external_img = false;
1041
+						} else {
1042
+							$new_name = $post_id . '_' . $file_name;
1043 1043
 
1044
-                            if ($curr_img_dir == $sub_dir) {
1045
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1046
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1047
-                            } else {
1048
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1050
-                            }
1044
+							if ($curr_img_dir == $sub_dir) {
1045
+								$img_path = $geodir_uploadpath . '/' . $filename;
1046
+								$img_url = $geodir_uploadurl . '/' . $filename;
1047
+							} else {
1048
+								$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
+								$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1050
+							}
1051 1051
 
1052
-                            $uploaded_file = '';
1052
+							$uploaded_file = '';
1053 1053
 
1054
-                            if (file_exists($img_path)) {
1055
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1056
-                                $file_path = '';
1057
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1058
-                                $uploaded_file = true;
1059
-                                $file_path = $curr_img_dir . '/' . $filename;
1060
-                            }
1054
+							if (file_exists($img_path)) {
1055
+								$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1056
+								$file_path = '';
1057
+							} else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1058
+								$uploaded_file = true;
1059
+								$file_path = $curr_img_dir . '/' . $filename;
1060
+							}
1061 1061
 
1062
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
-                                unlink($img_path);
1064
-                        }
1062
+							if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
+								unlink($img_path);
1064
+						}
1065 1065
 
1066
-                        if (!empty($uploaded_file)) {
1067
-                            if (!isset($file_path) || !$file_path) {
1068
-                                $file_path = $sub_dir . '/' . $new_name;
1069
-                            }
1066
+						if (!empty($uploaded_file)) {
1067
+							if (!isset($file_path) || !$file_path) {
1068
+								$file_path = $sub_dir . '/' . $new_name;
1069
+							}
1070 1070
 
1071
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1071
+							$postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1072 1072
 
1073
-                            if ($menu_order == 1) {
1073
+							if ($menu_order == 1) {
1074 1074
 
1075
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1075
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1076 1076
 
1077
-                            }
1077
+							}
1078 1078
 
1079
-                            // Set up options array to add this file as an attachment
1080
-                            $attachment = array();
1081
-                            $attachment['post_id'] = $post_id;
1082
-                            $attachment['title'] = $file_title;
1083
-                            $attachment['content'] = '';
1084
-                            $attachment['file'] = $file_path;
1085
-                            $attachment['mime_type'] = $uploaded_file_type;
1086
-                            $attachment['menu_order'] = $menu_order;
1087
-                            $attachment['is_featured'] = 0;
1079
+							// Set up options array to add this file as an attachment
1080
+							$attachment = array();
1081
+							$attachment['post_id'] = $post_id;
1082
+							$attachment['title'] = $file_title;
1083
+							$attachment['content'] = '';
1084
+							$attachment['file'] = $file_path;
1085
+							$attachment['mime_type'] = $uploaded_file_type;
1086
+							$attachment['menu_order'] = $menu_order;
1087
+							$attachment['is_featured'] = 0;
1088 1088
 
1089
-                            $attachment_set = '';
1089
+							$attachment_set = '';
1090 1090
 
1091
-                            foreach ($attachment as $key => $val) {
1092
-                                if ($val != '')
1093
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1094
-                            }
1091
+							foreach ($attachment as $key => $val) {
1092
+								if ($val != '')
1093
+									$attachment_set .= $key . " = '" . $val . "', ";
1094
+							}
1095 1095
 
1096
-                            $attachment_set = trim($attachment_set, ", ");
1096
+							$attachment_set = trim($attachment_set, ", ");
1097
+
1098
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1097 1099
 
1098
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1100
+							$valid_file_ids[] = $wpdb->insert_id;
1101
+						}
1099 1102
 
1100
-                            $valid_file_ids[] = $wpdb->insert_id;
1101
-                        }
1103
+					}
1102 1104
 
1103
-                    }
1104 1105
 
1106
+				} else {
1107
+					$valid_file_ids[] = $find_image;
1105 1108
 
1106
-                } else {
1107
-                    $valid_file_ids[] = $find_image;
1108
-
1109
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1109
+					$postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1110 1110
 
1111
-                    $wpdb->query(
1112
-                        $wpdb->prepare(
1113
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1114
-                            array($menu_order, $split_img_path[1], $post_id)
1115
-                        )
1116
-                    );
1111
+					$wpdb->query(
1112
+						$wpdb->prepare(
1113
+							"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1114
+							array($menu_order, $split_img_path[1], $post_id)
1115
+						)
1116
+					);
1117 1117
 
1118
-                    if ($menu_order == 1)
1119
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1118
+					if ($menu_order == 1)
1119
+						$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1120 1120
 
1121
-                }
1121
+				}
1122 1122
 
1123 1123
 
1124
-            }
1124
+			}
1125 1125
 
1126
-            if (!empty($valid_file_ids)) {
1126
+			if (!empty($valid_file_ids)) {
1127 1127
 
1128
-                $remove_files = $valid_file_ids;
1128
+				$remove_files = $valid_file_ids;
1129 1129
 
1130
-                $remove_files_length = count($remove_files);
1131
-                $remove_files_format = array_fill(0, $remove_files_length, '%d');
1132
-                $format = implode(',', $remove_files_format);
1133
-                $valid_files_condition = " ID NOT IN ($format) AND ";
1130
+				$remove_files_length = count($remove_files);
1131
+				$remove_files_format = array_fill(0, $remove_files_length, '%d');
1132
+				$format = implode(',', $remove_files_format);
1133
+				$valid_files_condition = " ID NOT IN ($format) AND ";
1134 1134
 
1135
-            }
1135
+			}
1136 1136
 
1137
-            //Get and remove all old images of post from database to set by new order
1137
+			//Get and remove all old images of post from database to set by new order
1138 1138
 
1139
-            if (!empty($post_images)) {
1139
+			if (!empty($post_images)) {
1140 1140
 
1141
-                foreach ($post_images as $img) {
1141
+				foreach ($post_images as $img) {
1142 1142
 
1143
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1143
+					if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1144 1144
 
1145
-                        $invalid_files[] = (object)array('src' => $img->src);
1145
+						$invalid_files[] = (object)array('src' => $img->src);
1146 1146
 
1147
-                    }
1147
+					}
1148 1148
 
1149
-                }
1149
+				}
1150 1150
 
1151
-            }
1151
+			}
1152 1152
 
1153
-            $invalid_files = (object)$invalid_files;
1154
-        }
1153
+			$invalid_files = (object)$invalid_files;
1154
+		}
1155 1155
 
1156
-        $remove_files[] = $post_id;
1156
+		$remove_files[] = $post_id;
1157 1157
 
1158
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1158
+		$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1159 1159
 
1160
-        if (!empty($invalid_files))
1161
-            geodir_remove_attachments($invalid_files);
1162
-    }
1160
+		if (!empty($invalid_files))
1161
+			geodir_remove_attachments($invalid_files);
1162
+	}
1163 1163
 
1164 1164
 }
1165 1165
 
@@ -1173,12 +1173,12 @@  discard block
 block discarded – undo
1173 1173
 function geodir_remove_temp_images()
1174 1174
 {
1175 1175
 
1176
-    global $current_user;
1176
+	global $current_user;
1177 1177
 
1178
-    $uploads = wp_upload_dir();
1179
-    $uploads_dir = $uploads['path'];
1178
+	$uploads = wp_upload_dir();
1179
+	$uploads_dir = $uploads['path'];
1180 1180
 
1181
-    /*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1181
+	/*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1182 1182
 
1183 1183
 			$dirPath = $uploads_dir.'/temp_'.$current_user->data->ID;
1184 1184
 			if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
@@ -1195,8 +1195,8 @@  discard block
 block discarded – undo
1195 1195
 			rmdir($dirPath);
1196 1196
 	}	*/
1197 1197
 
1198
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1199
-    geodir_delete_directory($dirname);
1198
+	$dirname = $uploads_dir . '/temp_' . $current_user->ID;
1199
+	geodir_delete_directory($dirname);
1200 1200
 }
1201 1201
 
1202 1202
 
@@ -1210,131 +1210,131 @@  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
+
1287
+		if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1288
+			$post_type = $post->post_type;
1289
+		} else {
1290
+			$post_type = get_post_type($post_id);
1291
+		}
1292
+
1293
+		if (!in_array($post_type, geodir_get_posttypes())) {
1294
+			return false;// if not a GD CPT return;
1295
+		}
1296
+
1297
+
1298
+		/**
1299
+		 * Filter to force the list images to be smaller.
1300
+		 * @since 1.6.18
1301
+		 */
1302
+		if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){
1303
+			$fimg = get_the_post_thumbnail_url($post_id,'medium');
1304
+			if($fimg){
1305
+				$uploads = wp_upload_dir(); 
1306
+				$uploads_baseurl = $uploads['baseurl'];
1307
+				$file = str_replace($uploads_baseurl,'',$fimg);
1308
+			}
1309
+		}
1310
+
1311
+		$table = $plugin_prefix . $post_type . '_detail';
1286 1312
 
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
-        }
1313
+		if (!$file) {
1314
+			if (isset($post->featured_image)) {
1315
+				$file = $post->featured_image;
1316
+			} else {
1317
+				$file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1318
+			}
1319
+		}
1320
+
1321
+		if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1322
+			$img_arr = array();
1292 1323
 
1293
-        if (!in_array($post_type, geodir_get_posttypes())) {
1294
-            return false;// if not a GD CPT return;
1295
-        }
1324
+			$file_info = pathinfo($file);
1325
+			$sub_dir = '';
1326
+			if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1327
+				$sub_dir = stripslashes_deep($file_info['dirname']);
1328
+			}
1296 1329
 
1330
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1331
+			$uploads_baseurl = $uploads['baseurl'];
1332
+			$uploads_path = $uploads['path'];
1297 1333
 
1298
-        /**
1299
-         * Filter to force the list images to be smaller.
1300
-         * @since 1.6.18
1301
-         */
1302
-        if( $size=='list-thumb' && apply_filters('geodir_use_small_list_img',false) ){
1303
-            $fimg = get_the_post_thumbnail_url($post_id,'medium');
1304
-            if($fimg){
1305
-                $uploads = wp_upload_dir(); 
1306
-                $uploads_baseurl = $uploads['baseurl'];
1307
-                $file = str_replace($uploads_baseurl,'',$fimg);
1308
-            }
1309
-        }
1310
-
1311
-        $table = $plugin_prefix . $post_type . '_detail';
1312
-
1313
-        if (!$file) {
1314
-            if (isset($post->featured_image)) {
1315
-                $file = $post->featured_image;
1316
-            } else {
1317
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1318
-            }
1319
-        }
1320
-
1321
-        if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1322
-            $img_arr = array();
1323
-
1324
-            $file_info = pathinfo($file);
1325
-            $sub_dir = '';
1326
-            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1327
-                $sub_dir = stripslashes_deep($file_info['dirname']);
1328
-            }
1329
-
1330
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1331
-            $uploads_baseurl = $uploads['baseurl'];
1332
-            $uploads_path = $uploads['path'];
1333
-
1334
-            $file_name = $file_info['basename'];
1335
-
1336
-            $uploads_url = $uploads_baseurl . $sub_dir;
1337
-            /*
1334
+			$file_name = $file_info['basename'];
1335
+
1336
+			$uploads_url = $uploads_baseurl . $sub_dir;
1337
+			/*
1338 1338
              * Allows the filter of image src for such things as CDN change.
1339 1339
              *
1340 1340
              * @since 1.5.7
@@ -1343,158 +1343,158 @@  discard block
 block discarded – undo
1343 1343
              * @param string $uploads_url The server upload directory url.
1344 1344
              * @param string $uploads_baseurl The uploads dir base url.
1345 1345
              */
1346
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1347
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1348
-            $width = 0;
1349
-            $height = 0;
1350
-            if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1351
-                $imagesize = getimagesize($img_arr['path']);
1352
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1353
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1354
-            }
1355
-            $img_arr['width'] = $width;
1356
-            $img_arr['height'] = $height;
1357
-            $img_arr['title'] = '';
1358
-        } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1359
-            foreach ($post_images as $image) {
1360
-                return $image;
1361
-            }
1362
-        } else if ($no_image) {
1363
-            $img_arr = array();
1364
-
1365
-            $default_img = '';
1366
-            if (isset($post->default_category) && $post->default_category) {
1367
-                $default_cat = $post->default_category;
1368
-            } else {
1369
-                $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1370
-            }
1371
-
1372
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1373
-                $default_img = $default_catimg['src'];
1374
-            elseif ($no_image) {
1375
-                $default_img = get_option('geodir_listing_no_img');
1376
-            }
1377
-
1378
-            if (!empty($default_img)) {
1379
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1380
-                $uploads_baseurl = $uploads['baseurl'];
1381
-                $uploads_path = $uploads['path'];
1382
-
1383
-                $img_arr = array();
1384
-
1385
-                $file_info = pathinfo($default_img);
1386
-
1387
-                $file_name = $file_info['basename'];
1388
-
1389
-                $img_arr['src'] = $default_img;
1390
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1391
-
1392
-                $width = 0;
1393
-                $height = 0;
1394
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1395
-                    $imagesize = getimagesize($img_arr['path']);
1396
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1397
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1398
-                }
1399
-                $img_arr['width'] = $width;
1400
-                $img_arr['height'] = $height;
1401
-
1402
-                $img_arr['title'] = ''; // add the title to the array
1403
-            }
1404
-        }
1405
-
1406
-        if (!empty($img_arr))
1407
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1408
-        else
1409
-            return false;
1410
-    }
1346
+			$img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1347
+			$img_arr['path'] = $uploads_path . '/' . $file_name;
1348
+			$width = 0;
1349
+			$height = 0;
1350
+			if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1351
+				$imagesize = getimagesize($img_arr['path']);
1352
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1353
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1354
+			}
1355
+			$img_arr['width'] = $width;
1356
+			$img_arr['height'] = $height;
1357
+			$img_arr['title'] = '';
1358
+		} elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1359
+			foreach ($post_images as $image) {
1360
+				return $image;
1361
+			}
1362
+		} else if ($no_image) {
1363
+			$img_arr = array();
1364
+
1365
+			$default_img = '';
1366
+			if (isset($post->default_category) && $post->default_category) {
1367
+				$default_cat = $post->default_category;
1368
+			} else {
1369
+				$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1370
+			}
1371
+
1372
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1373
+				$default_img = $default_catimg['src'];
1374
+			elseif ($no_image) {
1375
+				$default_img = get_option('geodir_listing_no_img');
1376
+			}
1377
+
1378
+			if (!empty($default_img)) {
1379
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1380
+				$uploads_baseurl = $uploads['baseurl'];
1381
+				$uploads_path = $uploads['path'];
1382
+
1383
+				$img_arr = array();
1384
+
1385
+				$file_info = pathinfo($default_img);
1386
+
1387
+				$file_name = $file_info['basename'];
1388
+
1389
+				$img_arr['src'] = $default_img;
1390
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1391
+
1392
+				$width = 0;
1393
+				$height = 0;
1394
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1395
+					$imagesize = getimagesize($img_arr['path']);
1396
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1397
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1398
+				}
1399
+				$img_arr['width'] = $width;
1400
+				$img_arr['height'] = $height;
1401
+
1402
+				$img_arr['title'] = ''; // add the title to the array
1403
+			}
1404
+		}
1405
+
1406
+		if (!empty($img_arr))
1407
+			return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1408
+		else
1409
+			return false;
1410
+	}
1411 1411
 }
1412 1412
 
1413 1413
 if (!function_exists('geodir_show_featured_image')) {
1414
-    /**
1415
-     * Gets the post featured image.
1416
-     *
1417
-     * @since 1.0.0
1418
-     * @package GeoDirectory
1419
-     * @param int|string $post_id The post ID.
1420
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1421
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1422
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1423
-     * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1424
-     * @return bool|string Returns image html.
1425
-     */
1426
-    function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1427
-    {
1428
-        $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1429
-
1430
-        $html = geodir_show_image($image, $size, $no_image, false);
1431
-
1432
-        if (!empty($html) && $echo) {
1433
-            echo $html;
1434
-        } elseif (!empty($html)) {
1435
-            return $html;
1436
-        } else
1437
-            return false;
1438
-    }
1414
+	/**
1415
+	 * Gets the post featured image.
1416
+	 *
1417
+	 * @since 1.0.0
1418
+	 * @package GeoDirectory
1419
+	 * @param int|string $post_id The post ID.
1420
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1421
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1422
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1423
+	 * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1424
+	 * @return bool|string Returns image html.
1425
+	 */
1426
+	function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1427
+	{
1428
+		$image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1429
+
1430
+		$html = geodir_show_image($image, $size, $no_image, false);
1431
+
1432
+		if (!empty($html) && $echo) {
1433
+			echo $html;
1434
+		} elseif (!empty($html)) {
1435
+			return $html;
1436
+		} else
1437
+			return false;
1438
+	}
1439 1439
 }
1440 1440
 
1441 1441
 if (!function_exists('geodir_get_images')) {
1442
-    /**
1443
-     * Gets the post images.
1444
-     *
1445
-     * @since 1.0.0
1446
-     * @package GeoDirectory
1447
-     * @global object $wpdb WordPress Database object.
1448
-     * @param int $post_id The post ID.
1449
-     * @param string $img_size Optional. Thumbnail size.
1450
-     * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1451
-     * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1452
-     * @param int|string $limit Optional. Number of images.
1453
-     * @return array|bool Returns images as an array. Each item is an object.
1454
-     */
1455
-    function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1456
-    {
1457
-        global $wpdb;
1458
-        if ($limit) {
1459
-            $limit_q = " LIMIT $limit ";
1460
-        } else {
1461
-            $limit_q = '';
1462
-        }
1463
-        $not_featured = '';
1464
-        $sub_dir = '';
1465
-        if (!$add_featured)
1466
-            $not_featured = " AND is_featured = 0 ";
1467
-
1468
-        $arrImages = $wpdb->get_results(
1469
-            $wpdb->prepare(
1470
-                "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 ",
1471
-                array('%image%', $post_id)
1472
-            )
1473
-        );
1474
-
1475
-        $counter = 0;
1476
-        $return_arr = array();
1477
-
1478
-        if (!empty($arrImages)) {
1479
-            foreach ($arrImages as $attechment) {
1480
-
1481
-                $img_arr = array();
1482
-                $img_arr['id'] = $attechment->ID;
1483
-                $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1484
-
1485
-                $file_info = pathinfo($attechment->file);
1486
-
1487
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1488
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1489
-
1490
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1491
-                $uploads_baseurl = $uploads['baseurl'];
1492
-                $uploads_path = $uploads['path'];
1493
-
1494
-                $file_name = $file_info['basename'];
1495
-
1496
-                $uploads_url = $uploads_baseurl . $sub_dir;
1497
-                /*
1442
+	/**
1443
+	 * Gets the post images.
1444
+	 *
1445
+	 * @since 1.0.0
1446
+	 * @package GeoDirectory
1447
+	 * @global object $wpdb WordPress Database object.
1448
+	 * @param int $post_id The post ID.
1449
+	 * @param string $img_size Optional. Thumbnail size.
1450
+	 * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1451
+	 * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1452
+	 * @param int|string $limit Optional. Number of images.
1453
+	 * @return array|bool Returns images as an array. Each item is an object.
1454
+	 */
1455
+	function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1456
+	{
1457
+		global $wpdb;
1458
+		if ($limit) {
1459
+			$limit_q = " LIMIT $limit ";
1460
+		} else {
1461
+			$limit_q = '';
1462
+		}
1463
+		$not_featured = '';
1464
+		$sub_dir = '';
1465
+		if (!$add_featured)
1466
+			$not_featured = " AND is_featured = 0 ";
1467
+
1468
+		$arrImages = $wpdb->get_results(
1469
+			$wpdb->prepare(
1470
+				"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 ",
1471
+				array('%image%', $post_id)
1472
+			)
1473
+		);
1474
+
1475
+		$counter = 0;
1476
+		$return_arr = array();
1477
+
1478
+		if (!empty($arrImages)) {
1479
+			foreach ($arrImages as $attechment) {
1480
+
1481
+				$img_arr = array();
1482
+				$img_arr['id'] = $attechment->ID;
1483
+				$img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1484
+
1485
+				$file_info = pathinfo($attechment->file);
1486
+
1487
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1488
+					$sub_dir = stripslashes_deep($file_info['dirname']);
1489
+
1490
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1491
+				$uploads_baseurl = $uploads['baseurl'];
1492
+				$uploads_path = $uploads['path'];
1493
+
1494
+				$file_name = $file_info['basename'];
1495
+
1496
+				$uploads_url = $uploads_baseurl . $sub_dir;
1497
+				/*
1498 1498
                 * Allows the filter of image src for such things as CDN change.
1499 1499
                 *
1500 1500
                 * @since 1.5.7
@@ -1503,520 +1503,520 @@  discard block
 block discarded – undo
1503 1503
                 * @param string $uploads_url The server upload directory url.
1504 1504
                 * @param string $uploads_baseurl The uploads dir base url.
1505 1505
                 */
1506
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1507
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1508
-                $width = 0;
1509
-                $height = 0;
1510
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1511
-                    $imagesize = getimagesize($img_arr['path']);
1512
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1513
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1514
-                }
1515
-                $img_arr['width'] = $width;
1516
-                $img_arr['height'] = $height;
1517
-
1518
-                $img_arr['file'] = $file_name; // add the title to the array
1519
-                $img_arr['title'] = $attechment->title; // add the title to the array
1520
-                $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1521
-                $img_arr['content'] = $attechment->content; // add the description to the array
1522
-                $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1523
-
1524
-                $return_arr[] = (object)$img_arr;
1525
-
1526
-                $counter++;
1527
-            }
1528
-            return (object)$return_arr;
1529
-        } else if ($no_images) {
1530
-            $default_img = '';
1531
-            $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1532
-            $post_type = get_post_type($post_id);
1533
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1534
-                $default_img = $default_catimg['src'];
1535
-            elseif ($no_images) {
1536
-                $default_img = get_option('geodir_listing_no_img');
1537
-            }
1538
-
1539
-            if (!empty($default_img)) {
1540
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1506
+				$img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1507
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1508
+				$width = 0;
1509
+				$height = 0;
1510
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1511
+					$imagesize = getimagesize($img_arr['path']);
1512
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1513
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1514
+				}
1515
+				$img_arr['width'] = $width;
1516
+				$img_arr['height'] = $height;
1517
+
1518
+				$img_arr['file'] = $file_name; // add the title to the array
1519
+				$img_arr['title'] = $attechment->title; // add the title to the array
1520
+				$img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1521
+				$img_arr['content'] = $attechment->content; // add the description to the array
1522
+				$img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1523
+
1524
+				$return_arr[] = (object)$img_arr;
1525
+
1526
+				$counter++;
1527
+			}
1528
+			return (object)$return_arr;
1529
+		} else if ($no_images) {
1530
+			$default_img = '';
1531
+			$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1532
+			$post_type = get_post_type($post_id);
1533
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1534
+				$default_img = $default_catimg['src'];
1535
+			elseif ($no_images) {
1536
+				$default_img = get_option('geodir_listing_no_img');
1537
+			}
1538
+
1539
+			if (!empty($default_img)) {
1540
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1541 1541
                 
1542
-                $image_path = $default_img;
1543
-                if (!path_is_absolute($image_path)) {
1544
-                    $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1545
-                }
1546
-
1547
-                $file_info = pathinfo($default_img);
1548
-                $file_name = $file_info['basename'];
1549
-
1550
-                $width = '';
1551
-                $height = '';
1552
-                if (is_file($image_path) && file_exists($image_path)) {
1553
-                    $imagesize = getimagesize($image_path);
1554
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1555
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1556
-                }
1542
+				$image_path = $default_img;
1543
+				if (!path_is_absolute($image_path)) {
1544
+					$image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1545
+				}
1546
+
1547
+				$file_info = pathinfo($default_img);
1548
+				$file_name = $file_info['basename'];
1549
+
1550
+				$width = '';
1551
+				$height = '';
1552
+				if (is_file($image_path) && file_exists($image_path)) {
1553
+					$imagesize = getimagesize($image_path);
1554
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1555
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1556
+				}
1557 1557
                 
1558
-                $img_arr = array();
1559
-                $img_arr['src'] = $default_img;
1560
-                $img_arr['path'] = $image_path;
1561
-                $img_arr['width'] = $width;
1562
-                $img_arr['height'] = $height;
1563
-                $img_arr['file'] = $file_name; // add the title to the array
1564
-                $img_arr['title'] = $file_info['filename']; // add the title to the array
1565
-                $img_arr['content'] = $file_info['filename']; // add the description to the array
1566
-
1567
-                $return_arr[] = (object)$img_arr;
1568
-
1569
-                return $return_arr;
1570
-            } else
1571
-                return false;
1572
-        }
1573
-    }
1558
+				$img_arr = array();
1559
+				$img_arr['src'] = $default_img;
1560
+				$img_arr['path'] = $image_path;
1561
+				$img_arr['width'] = $width;
1562
+				$img_arr['height'] = $height;
1563
+				$img_arr['file'] = $file_name; // add the title to the array
1564
+				$img_arr['title'] = $file_info['filename']; // add the title to the array
1565
+				$img_arr['content'] = $file_info['filename']; // add the description to the array
1566
+
1567
+				$return_arr[] = (object)$img_arr;
1568
+
1569
+				return $return_arr;
1570
+			} else
1571
+				return false;
1572
+		}
1573
+	}
1574 1574
 }
1575 1575
 
1576 1576
 if (!function_exists('geodir_show_image')) {
1577
-    /**
1578
-     * Show image using image details.
1579
-     *
1580
-     * @since 1.0.0
1581
-     * @package GeoDirectory
1582
-     * @param array|object $request Image info either as an array or object.
1583
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1584
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1585
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1586
-     * @return bool|string Returns image html.
1587
-     */
1588
-    function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1589
-    {
1590
-        $image = new stdClass();
1591
-
1592
-        $html = '';
1593
-        if (!empty($request)) {
1594
-            if (!is_object($request)){
1595
-                $request = (object)$request;
1596
-            }
1597
-
1598
-            if (isset($request->src) && !isset($request->path)) {
1599
-                $request->path = $request->src;
1600
-            }
1601
-
1602
-            /*
1577
+	/**
1578
+	 * Show image using image details.
1579
+	 *
1580
+	 * @since 1.0.0
1581
+	 * @package GeoDirectory
1582
+	 * @param array|object $request Image info either as an array or object.
1583
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1584
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1585
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1586
+	 * @return bool|string Returns image html.
1587
+	 */
1588
+	function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1589
+	{
1590
+		$image = new stdClass();
1591
+
1592
+		$html = '';
1593
+		if (!empty($request)) {
1594
+			if (!is_object($request)){
1595
+				$request = (object)$request;
1596
+			}
1597
+
1598
+			if (isset($request->src) && !isset($request->path)) {
1599
+				$request->path = $request->src;
1600
+			}
1601
+
1602
+			/*
1603 1603
              * getimagesize() works faster from path than url so we try and get path if we can.
1604 1604
              */
1605
-            $upload_dir = wp_upload_dir();
1606
-            $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1607
-            $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1608
-            if (strpos($img_no_http, $upload_no_http) !== false) {
1609
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1610
-            }
1605
+			$upload_dir = wp_upload_dir();
1606
+			$img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1607
+			$upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1608
+			if (strpos($img_no_http, $upload_no_http) !== false) {
1609
+				$request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1610
+			}
1611 1611
             
1612
-            $width = 0;
1613
-            $height = 0;
1614
-            if (is_file($request->path) && file_exists($request->path)) {
1615
-                $imagesize = getimagesize($request->path);
1616
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1617
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1618
-            }
1619
-
1620
-            $image->src = $request->src;
1621
-            $image->width = $width;
1622
-            $image->height = $height;
1623
-
1624
-            $max_size = (object)geodir_get_imagesize($size);
1625
-
1626
-            if (!is_wp_error($max_size)) {
1627
-                if ($image->width) {
1628
-                    if ($image->height >= $image->width) {
1629
-                        $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1630
-                    } else if ($image->width < ($max_size->h)) {
1631
-                        $width_per = round((($image->width / $max_size->w) * 100), 2);
1632
-                    } else
1633
-                        $width_per = 100;
1634
-                }
1635
-
1636
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1637
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1638
-                } else {
1639
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1640
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1641
-                    }else{
1642
-                        //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1643
-                        //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1644
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1645
-
1646
-                    }
1647
-
1648
-                }
1649
-            }
1650
-        }
1651
-
1652
-        if (!empty($html) && $echo) {
1653
-            echo $html;
1654
-        } elseif (!empty($html)) {
1655
-            return $html;
1656
-        } else
1657
-            return false;
1658
-    }
1659
-}
1612
+			$width = 0;
1613
+			$height = 0;
1614
+			if (is_file($request->path) && file_exists($request->path)) {
1615
+				$imagesize = getimagesize($request->path);
1616
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1617
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1618
+			}
1660 1619
 
1661
-if (!function_exists('geodir_set_post_terms')) {
1662
-    /**
1663
-     * Set post Categories.
1664
-     *
1665
-     * @since 1.0.0
1666
-     * @package GeoDirectory
1667
-     * @global object $wpdb WordPress Database object.
1668
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1669
-     * @param int $post_id The post ID.
1670
-     * @param array $terms An array of term objects.
1671
-     * @param array $tt_ids An array of term taxonomy IDs.
1672
-     * @param string $taxonomy Taxonomy slug.
1673
-     */
1674
-    function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1675
-    {
1676
-        global $wpdb, $plugin_prefix;
1620
+			$image->src = $request->src;
1621
+			$image->width = $width;
1622
+			$image->height = $height;
1677 1623
 
1678
-        $post_type = get_post_type($post_id);
1624
+			$max_size = (object)geodir_get_imagesize($size);
1679 1625
 
1680
-        $table = $plugin_prefix . $post_type . '_detail';
1626
+			if (!is_wp_error($max_size)) {
1627
+				if ($image->width) {
1628
+					if ($image->height >= $image->width) {
1629
+						$width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1630
+					} else if ($image->width < ($max_size->h)) {
1631
+						$width_per = round((($image->width / $max_size->w) * 100), 2);
1632
+					} else
1633
+						$width_per = 100;
1634
+				}
1635
+
1636
+				if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1637
+					$html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1638
+				} else {
1639
+					if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1640
+						$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1641
+					}else{
1642
+						//$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1643
+						//$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1644
+						$html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1645
+
1646
+					}
1681 1647
 
1682
-        if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1648
+				}
1649
+			}
1650
+		}
1651
+
1652
+		if (!empty($html) && $echo) {
1653
+			echo $html;
1654
+		} elseif (!empty($html)) {
1655
+			return $html;
1656
+		} else
1657
+			return false;
1658
+	}
1659
+}
1683 1660
 
1684
-            if ($taxonomy == $post_type . '_tags') {
1685
-                if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1686
-                    geodir_save_post_meta($post_id, 'post_tags', $terms);
1687
-                }
1688
-            } elseif ($taxonomy == $post_type . 'category') {
1689
-                $srcharr = array('"', '\\');
1690
-                $replarr = array("&quot;", '');
1661
+if (!function_exists('geodir_set_post_terms')) {
1662
+	/**
1663
+	 * Set post Categories.
1664
+	 *
1665
+	 * @since 1.0.0
1666
+	 * @package GeoDirectory
1667
+	 * @global object $wpdb WordPress Database object.
1668
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1669
+	 * @param int $post_id The post ID.
1670
+	 * @param array $terms An array of term objects.
1671
+	 * @param array $tt_ids An array of term taxonomy IDs.
1672
+	 * @param string $taxonomy Taxonomy slug.
1673
+	 */
1674
+	function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1675
+	{
1676
+		global $wpdb, $plugin_prefix;
1677
+
1678
+		$post_type = get_post_type($post_id);
1679
+
1680
+		$table = $plugin_prefix . $post_type . '_detail';
1681
+
1682
+		if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1683
+
1684
+			if ($taxonomy == $post_type . '_tags') {
1685
+				if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1686
+					geodir_save_post_meta($post_id, 'post_tags', $terms);
1687
+				}
1688
+			} elseif ($taxonomy == $post_type . 'category') {
1689
+				$srcharr = array('"', '\\');
1690
+				$replarr = array("&quot;", '');
1691 1691
 
1692
-                $post_obj = get_post($post_id);
1692
+				$post_obj = get_post($post_id);
1693 1693
 
1694
-                $cat_ids = array('0');
1695
-                if (is_array($tt_ids))
1696
-                    $cat_ids = $tt_ids;
1694
+				$cat_ids = array('0');
1695
+				if (is_array($tt_ids))
1696
+					$cat_ids = $tt_ids;
1697 1697
 
1698 1698
 
1699
-                if (!empty($cat_ids)) {
1700
-                    $cat_ids_array = $cat_ids;
1701
-                    $cat_ids_length = count($cat_ids_array);
1702
-                    $cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1703
-                    $format = implode(',', $cat_ids_format);
1699
+				if (!empty($cat_ids)) {
1700
+					$cat_ids_array = $cat_ids;
1701
+					$cat_ids_length = count($cat_ids_array);
1702
+					$cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1703
+					$format = implode(',', $cat_ids_format);
1704 1704
 
1705
-                    $cat_ids_array_del = $cat_ids_array;
1706
-                    $cat_ids_array_del[] = $post_id;
1705
+					$cat_ids_array_del = $cat_ids_array;
1706
+					$cat_ids_array_del[] = $post_id;
1707 1707
 
1708
-                    $wpdb->get_var(
1709
-                        $wpdb->prepare(
1710
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1711
-                            $cat_ids_array_del
1712
-                        )
1713
-                    );
1708
+					$wpdb->get_var(
1709
+						$wpdb->prepare(
1710
+							"DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1711
+							$cat_ids_array_del
1712
+						)
1713
+					);
1714 1714
 
1715 1715
 
1716
-                    $post_term = $wpdb->get_col(
1717
-                        $wpdb->prepare(
1718
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1719
-                            $cat_ids_array
1720
-                        )
1721
-                    );
1716
+					$post_term = $wpdb->get_col(
1717
+						$wpdb->prepare(
1718
+							"SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1719
+							$cat_ids_array
1720
+						)
1721
+					);
1722 1722
 
1723
-                }
1723
+				}
1724 1724
 
1725
-                $post_marker_json = '';
1725
+				$post_marker_json = '';
1726 1726
 
1727
-                if (!empty($post_term)):
1727
+				if (!empty($post_term)):
1728 1728
 
1729
-                    foreach ($post_term as $cat_id):
1729
+					foreach ($post_term as $cat_id):
1730 1730
 
1731
-                        $term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1732
-                        $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1731
+						$term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1732
+						$term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1733 1733
 
1734
-                        $post_title = $post_obj->title;
1735
-                        $title = str_replace($srcharr, $replarr, $post_title);
1734
+						$post_title = $post_obj->title;
1735
+						$title = str_replace($srcharr, $replarr, $post_title);
1736 1736
 
1737
-                        $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1738
-                        $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1737
+						$lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1738
+						$lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1739 1739
 
1740
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1741
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1740
+						$timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1741
+						$timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1742 1742
 
1743
-                        $json = '{';
1744
-                        $json .= '"id":"' . $post_id . '",';
1745
-                        $json .= '"lat_pos": "' . $lat . '",';
1746
-                        $json .= '"long_pos": "' . $lng . '",';
1747
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1748
-                        $json .= '"icon":"' . $term_icon . '",';
1749
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1750
-                        $json .= '}';
1743
+						$json = '{';
1744
+						$json .= '"id":"' . $post_id . '",';
1745
+						$json .= '"lat_pos": "' . $lat . '",';
1746
+						$json .= '"long_pos": "' . $lng . '",';
1747
+						$json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1748
+						$json .= '"icon":"' . $term_icon . '",';
1749
+						$json .= '"group":"catgroup' . $cat_id . '"';
1750
+						$json .= '}';
1751 1751
 
1752 1752
 
1753
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1754
-                            $post_marker_json = $json;
1753
+						if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1754
+							$post_marker_json = $json;
1755 1755
 
1756 1756
 
1757
-                        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)))) {
1757
+						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)))) {
1758 1758
 
1759
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1759
+							$json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1760 1760
 										post_title = %s,
1761 1761
 										json = %s
1762 1762
 										WHERE post_id = %d AND cat_id = %d ",
1763
-                                array($post_title, $json, $post_id, $cat_id));
1763
+								array($post_title, $json, $post_id, $cat_id));
1764 1764
 
1765
-                        } else {
1765
+						} else {
1766 1766
 
1767
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1767
+							$json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1768 1768
 										post_id = %d,
1769 1769
 										post_title = %s,
1770 1770
 										cat_id = %d,
1771 1771
 										json = %s",
1772
-                                array($post_id, $post_title, $cat_id, $json));
1772
+								array($post_id, $post_title, $cat_id, $json));
1773 1773
 
1774
-                        }
1774
+						}
1775 1775
 
1776
-                        $wpdb->query($json_query);
1776
+						$wpdb->query($json_query);
1777 1777
 
1778
-                    endforeach;
1778
+					endforeach;
1779 1779
 
1780
-                endif;
1780
+				endif;
1781 1781
 
1782
-                if (!empty($post_term) && is_array($post_term)) {
1783
-                    $categories = implode(',', $post_term);
1782
+				if (!empty($post_term) && is_array($post_term)) {
1783
+					$categories = implode(',', $post_term);
1784 1784
 
1785
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1785
+					if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1786 1786
 
1787
-                    if (empty($post_marker_json))
1788
-                        $post_marker_json = isset($json) ? $json : '';
1787
+					if (empty($post_marker_json))
1788
+						$post_marker_json = isset($json) ? $json : '';
1789 1789
 
1790
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1790
+					if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1791 1791
 
1792
-                        $wpdb->query(
1793
-                            $wpdb->prepare(
1794
-                                "UPDATE " . $table . " SET
1792
+						$wpdb->query(
1793
+							$wpdb->prepare(
1794
+								"UPDATE " . $table . " SET
1795 1795
 								" . $taxonomy . " = %s,
1796 1796
 								marker_json = %s
1797 1797
 								where post_id = %d",
1798
-                                array($categories, $post_marker_json, $post_id)
1799
-                            )
1800
-                        );
1798
+								array($categories, $post_marker_json, $post_id)
1799
+							)
1800
+						);
1801 1801
 
1802
-                        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1802
+						if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1803 1803
 
1804
-                            $categories = trim($categories, ',');
1804
+							$categories = trim($categories, ',');
1805 1805
 
1806
-                            if ($categories) {
1806
+							if ($categories) {
1807 1807
 
1808
-                                $categories = explode(',', $categories);
1808
+								$categories = explode(',', $categories);
1809 1809
 
1810
-                                $default_category = geodir_get_post_meta($post_id, 'default_category', true);
1810
+								$default_category = geodir_get_post_meta($post_id, 'default_category', true);
1811 1811
 
1812
-                                if (!in_array($default_category, $categories)) {
1812
+								if (!in_array($default_category, $categories)) {
1813 1813
 
1814
-                                    $wpdb->query(
1815
-                                        $wpdb->prepare(
1816
-                                            "UPDATE " . $table . " SET
1814
+									$wpdb->query(
1815
+										$wpdb->prepare(
1816
+											"UPDATE " . $table . " SET
1817 1817
 											default_category = %s
1818 1818
 											where post_id = %d",
1819
-                                            array($categories[0], $post_id)
1820
-                                        )
1821
-                                    );
1819
+											array($categories[0], $post_id)
1820
+										)
1821
+									);
1822 1822
 
1823
-                                    $default_category = $categories[0];
1823
+									$default_category = $categories[0];
1824 1824
 
1825
-                                }
1825
+								}
1826 1826
 
1827
-                                if ($default_category == '')
1828
-                                    $default_category = $categories[0];
1827
+								if ($default_category == '')
1828
+									$default_category = $categories[0];
1829 1829
 
1830
-                                geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1830
+								geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1831 1831
 
1832
-                            }
1832
+							}
1833 1833
 
1834
-                        }
1834
+						}
1835 1835
 
1836 1836
 
1837
-                    } else {
1837
+					} else {
1838 1838
 
1839
-                        $wpdb->query(
1840
-                            $wpdb->prepare(
1841
-                                "INSERT INTO " . $table . " SET
1839
+						$wpdb->query(
1840
+							$wpdb->prepare(
1841
+								"INSERT INTO " . $table . " SET
1842 1842
 								post_id = %d,
1843 1843
 								" . $taxonomy . " = %s,
1844 1844
 								marker_json = %s ",
1845 1845
 
1846
-                                array($post_id, $categories, $post_marker_json)
1847
-                            )
1848
-                        );
1849
-                    }
1850
-                }
1851
-            }
1852
-        }
1853
-    }
1846
+								array($post_id, $categories, $post_marker_json)
1847
+							)
1848
+						);
1849
+					}
1850
+				}
1851
+			}
1852
+		}
1853
+	}
1854 1854
 }
1855 1855
 
1856 1856
 if (!function_exists('geodir_get_infowindow_html')) {
1857
-    /**
1858
-     * Set post Map Marker info html.
1859
-     *
1860
-     * @since 1.0.0
1861
-     * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1862
-     * @since 1.6.16 Changes for disable review stars for certain post type.
1863
-     * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info.
1864
-     * @package GeoDirectory
1865
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
1866
-     * @global object $gd_session GeoDirectory Session object.
1867
-     * @param object $postinfo_obj The post details object.
1868
-     * @param string $post_preview Is this a post preview?.
1869
-     * @global object $post WordPress Post object.
1870
-     * @return mixed|string|void
1871
-     */
1872
-    function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
1873
-        global $preview, $post, $gd_session;
1874
-        $srcharr = array("'", "/", "-", '"', '\\');
1875
-        $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1876
-
1877
-        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1878
-            $ID = '';
1879
-            $plink = '';
1880
-
1881
-            if (isset($postinfo_obj->pid)) {
1882
-                $ID = $postinfo_obj->pid;
1883
-                $plink = get_permalink($ID);
1884
-            }
1885
-
1886
-            $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1887
-            $lat = $postinfo_obj->post_latitude;
1888
-            $lng = $postinfo_obj->post_longitude;
1889
-        } else {
1890
-            $ID = $postinfo_obj->post_id;
1891
-            $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1892
-            $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1893
-            $plink = get_permalink($ID);
1894
-            $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1895
-            $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1896
-        }
1857
+	/**
1858
+	 * Set post Map Marker info html.
1859
+	 *
1860
+	 * @since 1.0.0
1861
+	 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1862
+	 * @since 1.6.16 Changes for disable review stars for certain post type.
1863
+	 * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info.
1864
+	 * @package GeoDirectory
1865
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
1866
+	 * @global object $gd_session GeoDirectory Session object.
1867
+	 * @param object $postinfo_obj The post details object.
1868
+	 * @param string $post_preview Is this a post preview?.
1869
+	 * @global object $post WordPress Post object.
1870
+	 * @return mixed|string|void
1871
+	 */
1872
+	function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
1873
+		global $preview, $post, $gd_session;
1874
+		$srcharr = array("'", "/", "-", '"', '\\');
1875
+		$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1876
+
1877
+		if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1878
+			$ID = '';
1879
+			$plink = '';
1880
+
1881
+			if (isset($postinfo_obj->pid)) {
1882
+				$ID = $postinfo_obj->pid;
1883
+				$plink = get_permalink($ID);
1884
+			}
1885
+
1886
+			$title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1887
+			$lat = $postinfo_obj->post_latitude;
1888
+			$lng = $postinfo_obj->post_longitude;
1889
+		} else {
1890
+			$ID = $postinfo_obj->post_id;
1891
+			$title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1892
+			$title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1893
+			$plink = get_permalink($ID);
1894
+			$lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1895
+			$lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1896
+		}
1897 1897
         
1898
-        // Some theme overwrites global gd listing $post
1899
-        if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
1900
-            $post = geodir_get_post_info($ID);
1901
-        }
1898
+		// Some theme overwrites global gd listing $post
1899
+		if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
1900
+			$post = geodir_get_post_info($ID);
1901
+		}
1902 1902
         
1903
-        $post_type = $ID ? get_post_type($ID) : '';
1904
-
1905
-        // filter field as per price package
1906
-        global $geodir_addon_list;
1907
-        if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1908
-            $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1909
-            $field_name = 'geodir_contact';
1910
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1911
-                $contact = '';
1912
-            }
1913
-
1914
-            $field_name = 'geodir_timing';
1915
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1916
-                $timing = '';
1917
-            }
1918
-        }
1919
-
1920
-        if ($lat && $lng) {
1921
-            ob_start(); ?>
1903
+		$post_type = $ID ? get_post_type($ID) : '';
1904
+
1905
+		// filter field as per price package
1906
+		global $geodir_addon_list;
1907
+		if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1908
+			$package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1909
+			$field_name = 'geodir_contact';
1910
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1911
+				$contact = '';
1912
+			}
1913
+
1914
+			$field_name = 'geodir_timing';
1915
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1916
+				$timing = '';
1917
+			}
1918
+		}
1919
+
1920
+		if ($lat && $lng) {
1921
+			ob_start(); ?>
1922 1922
             <div class="gd-bubble" style="">
1923 1923
                 <div class="gd-bubble-inside">
1924 1924
                     <?php
1925
-                    $comment_count = '';
1926
-                    $rating_star = '';
1927
-                    if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1928
-                        $rating_star = '';
1929
-                        $comment_count = geodir_get_review_count_total($ID);
1930
-
1931
-                        if (!$preview) {
1932
-                            $post_avgratings = geodir_get_post_rating($ID);
1933
-
1934
-                            $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1935
-
1936
-                            /**
1937
-                             * Filter to change rating stars
1938
-                             *
1939
-                             * You can use this filter to change Rating stars.
1940
-                             *
1941
-                             * @since 1.0.0
1942
-                             * @package GeoDirectory
1943
-                             * @param string $rating_star Rating stars.
1944
-                             * @param float $post_avgratings Average ratings of the post.
1945
-                             * @param int $ID The post ID.
1946
-                             */
1947
-                            $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1948
-                        }
1949
-                    }
1950
-                    ?>
1925
+					$comment_count = '';
1926
+					$rating_star = '';
1927
+					if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1928
+						$rating_star = '';
1929
+						$comment_count = geodir_get_review_count_total($ID);
1930
+
1931
+						if (!$preview) {
1932
+							$post_avgratings = geodir_get_post_rating($ID);
1933
+
1934
+							$rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1935
+
1936
+							/**
1937
+							 * Filter to change rating stars
1938
+							 *
1939
+							 * You can use this filter to change Rating stars.
1940
+							 *
1941
+							 * @since 1.0.0
1942
+							 * @package GeoDirectory
1943
+							 * @param string $rating_star Rating stars.
1944
+							 * @param float $post_avgratings Average ratings of the post.
1945
+							 * @param int $ID The post ID.
1946
+							 */
1947
+							$rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1948
+						}
1949
+					}
1950
+					?>
1951 1951
                     <div class="geodir-bubble_desc">
1952 1952
                         <h4>
1953 1953
                             <a href="<?php if ($plink != '') {
1954
-                                echo $plink;
1955
-                            } else {
1956
-                                echo 'javascript:void(0);';
1957
-                            } ?>"><?php echo $title; ?></a>
1954
+								echo $plink;
1955
+							} else {
1956
+								echo 'javascript:void(0);';
1957
+							} ?>"><?php echo $title; ?></a>
1958 1958
                         </h4>
1959 1959
                         <?php
1960
-                        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1961
-                            $post_images = array();
1962
-                            if (!empty($postinfo_obj->post_images)) {
1963
-                                $post_images = explode(",", $postinfo_obj->post_images);
1964
-                            }
1965
-
1966
-                            if (!empty($post_images)) {
1967
-                                ?>
1960
+						if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1961
+							$post_images = array();
1962
+							if (!empty($postinfo_obj->post_images)) {
1963
+								$post_images = explode(",", $postinfo_obj->post_images);
1964
+							}
1965
+
1966
+							if (!empty($post_images)) {
1967
+								?>
1968 1968
                                 <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
1969
-                                        echo $plink;
1970
-                                    } else {
1971
-                                        echo 'javascript:void(0);';
1972
-                                    } ?>"><img alt="bubble image" style="max-height:50px;"
1969
+										echo $plink;
1970
+									} else {
1971
+										echo 'javascript:void(0);';
1972
+									} ?>"><img alt="bubble image" style="max-height:50px;"
1973 1973
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1974 1974
                             <?php
1975
-                            }else{
1976
-                                echo '<div class="geodir-bubble_image"></div>';
1977
-                            }
1978
-                        } else {
1979
-                            if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1980
-                                ?>
1975
+							}else{
1976
+								echo '<div class="geodir-bubble_image"></div>';
1977
+							}
1978
+						} else {
1979
+							if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1980
+								?>
1981 1981
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1982 1982
                             <?php
1983
-                            }else{
1984
-                                echo '<div class="geodir-bubble_image"></div>';
1985
-                            }
1986
-                        }
1987
-                        ?>
1983
+							}else{
1984
+								echo '<div class="geodir-bubble_image"></div>';
1985
+							}
1986
+						}
1987
+						?>
1988 1988
                         <div class="geodir-bubble-meta-side">
1989 1989
                             <?php
1990
-                            /**
1991
-                             * Fires before the meta info in the map info window.
1992
-                             *
1993
-                             * This can be used to add more info to the map info window before the normal meta info.
1994
-                             *
1995
-                             * @since 1.5.4
1996
-                             * @param int $ID The post id.
1997
-                             * @param object $postinfo_obj The posts info as an object.
1998
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1999
-                             */
2000
-                            do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
2001
-
2002
-                            echo geodir_show_listing_info('mapbubble');
2003
-
2004
-                            /**
2005
-                             * Fires after the meta info in the map info window.
2006
-                             *
2007
-                             * This can be used to add more info to the map info window after the normal meta info.
2008
-                             *
2009
-                             * @since 1.4.2
2010
-                             * @param object $postinfo_obj The posts info as an object.
2011
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2012
-                             */
2013
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2014
-                            ?>
1990
+							/**
1991
+							 * Fires before the meta info in the map info window.
1992
+							 *
1993
+							 * This can be used to add more info to the map info window before the normal meta info.
1994
+							 *
1995
+							 * @since 1.5.4
1996
+							 * @param int $ID The post id.
1997
+							 * @param object $postinfo_obj The posts info as an object.
1998
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1999
+							 */
2000
+							do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
2001
+
2002
+							echo geodir_show_listing_info('mapbubble');
2003
+
2004
+							/**
2005
+							 * Fires after the meta info in the map info window.
2006
+							 *
2007
+							 * This can be used to add more info to the map info window after the normal meta info.
2008
+							 *
2009
+							 * @since 1.4.2
2010
+							 * @param object $postinfo_obj The posts info as an object.
2011
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
2012
+							 */
2013
+							do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
2014
+							?>
2015 2015
                         </div>
2016 2016
                         <?php
2017
-                        if ($ID) {
2018
-                            $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2019
-                            ?>
2017
+						if ($ID) {
2018
+							$post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
2019
+							?>
2020 2020
                             <div class="geodir-bubble-meta-fade"></div>
2021 2021
                             <div class="geodir-bubble-meta-bottom">
2022 2022
                                 <?php if ($rating_star != '') { ?>
@@ -2032,69 +2032,69 @@  discard block
 block discarded – undo
2032 2032
                 </div>
2033 2033
             </div>
2034 2034
             <?php
2035
-            $html = ob_get_clean();
2036
-            /**
2037
-             * Filter to change infowindow html
2038
-             *
2039
-             * You can use this filter to change infowindow html.
2040
-             *
2041
-             * @since 1.0.0
2042
-             * @package GeoDirectory
2043
-             * @param string $html Infowindow html.
2044
-             * @param object $postinfo_obj The Post object.
2045
-             * @param bool|string $post_preview Is this a post preview?
2046
-             */
2047
-            $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2048
-            return $html;
2049
-        }
2050
-    }
2035
+			$html = ob_get_clean();
2036
+			/**
2037
+			 * Filter to change infowindow html
2038
+			 *
2039
+			 * You can use this filter to change infowindow html.
2040
+			 *
2041
+			 * @since 1.0.0
2042
+			 * @package GeoDirectory
2043
+			 * @param string $html Infowindow html.
2044
+			 * @param object $postinfo_obj The Post object.
2045
+			 * @param bool|string $post_preview Is this a post preview?
2046
+			 */
2047
+			$html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2048
+			return $html;
2049
+		}
2050
+	}
2051 2051
 }
2052 2052
 
2053 2053
 
2054 2054
 if (!function_exists('geodir_new_post_default_status')) {
2055
-    /**
2056
-     * Default post status for new posts.
2057
-     *
2058
-     * @since 1.0.0
2059
-     * @package GeoDirectory
2060
-     * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2061
-     */
2062
-    function geodir_new_post_default_status()
2063
-    {
2064
-        if (get_option('geodir_new_post_default_status'))
2065
-            return get_option('geodir_new_post_default_status');
2066
-        else
2067
-            return 'publish';
2068
-
2069
-    }
2055
+	/**
2056
+	 * Default post status for new posts.
2057
+	 *
2058
+	 * @since 1.0.0
2059
+	 * @package GeoDirectory
2060
+	 * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2061
+	 */
2062
+	function geodir_new_post_default_status()
2063
+	{
2064
+		if (get_option('geodir_new_post_default_status'))
2065
+			return get_option('geodir_new_post_default_status');
2066
+		else
2067
+			return 'publish';
2068
+
2069
+	}
2070 2070
 }
2071 2071
 
2072 2072
 if (!function_exists('geodir_change_post_status')) {
2073
-    /**
2074
-     * Change post status of a post.
2075
-     *
2076
-     * @global object $wpdb WordPress Database object.
2077
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2078
-     * @param int|string $post_id The post ID.
2079
-     * @param string $status New post status. Ex: draft, publish etc.
2080
-     */
2081
-    function geodir_change_post_status($post_id = '', $status = '')
2082
-    {
2083
-        global $wpdb, $plugin_prefix;
2084
-
2085
-        $post_type = get_post_type($post_id);
2086
-
2087
-        $table = $plugin_prefix . $post_type . '_detail';
2088
-
2089
-        $wpdb->query(
2090
-            $wpdb->prepare(
2091
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2092
-                array($status, $post_id)
2093
-            )
2094
-        );
2095
-
2096
-
2097
-    }
2073
+	/**
2074
+	 * Change post status of a post.
2075
+	 *
2076
+	 * @global object $wpdb WordPress Database object.
2077
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2078
+	 * @param int|string $post_id The post ID.
2079
+	 * @param string $status New post status. Ex: draft, publish etc.
2080
+	 */
2081
+	function geodir_change_post_status($post_id = '', $status = '')
2082
+	{
2083
+		global $wpdb, $plugin_prefix;
2084
+
2085
+		$post_type = get_post_type($post_id);
2086
+
2087
+		$table = $plugin_prefix . $post_type . '_detail';
2088
+
2089
+		$wpdb->query(
2090
+			$wpdb->prepare(
2091
+				"UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2092
+				array($status, $post_id)
2093
+			)
2094
+		);
2095
+
2096
+
2097
+	}
2098 2098
 }
2099 2099
 
2100 2100
 /**
@@ -2108,13 +2108,13 @@  discard block
 block discarded – undo
2108 2108
  */
2109 2109
 function geodir_set_post_status($pid, $status)
2110 2110
 {
2111
-    if ($pid) {
2112
-        global $wpdb;
2113
-        $my_post = array();
2114
-        $my_post['post_status'] = $status;
2115
-        $my_post['ID'] = $pid;
2116
-        $last_postid = wp_update_post($my_post);
2117
-    }
2111
+	if ($pid) {
2112
+		global $wpdb;
2113
+		$my_post = array();
2114
+		$my_post['post_status'] = $status;
2115
+		$my_post['ID'] = $pid;
2116
+		$last_postid = wp_update_post($my_post);
2117
+	}
2118 2118
 }
2119 2119
 
2120 2120
 
@@ -2130,384 +2130,384 @@  discard block
 block discarded – undo
2130 2130
  */
2131 2131
 function geodir_update_poststatus($new_status, $old_status, $post)
2132 2132
 {
2133
-    global $wpdb;
2133
+	global $wpdb;
2134 2134
 
2135
-    $geodir_posttypes = geodir_get_posttypes();
2135
+	$geodir_posttypes = geodir_get_posttypes();
2136 2136
 
2137
-    if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2137
+	if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2138 2138
 
2139
-        geodir_change_post_status($post->ID, $new_status);
2140
-    }
2139
+		geodir_change_post_status($post->ID, $new_status);
2140
+	}
2141 2141
 }
2142 2142
 
2143 2143
 
2144 2144
 if (!function_exists('geodir_update_listing_info')) {
2145
-    /**
2146
-     * Update post info.
2147
-     *
2148
-     * @since 1.0.0
2149
-     * @package GeoDirectory
2150
-     * @global object $wpdb WordPress Database object.
2151
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2152
-     * @param int $updatingpost The updating post ID.
2153
-     * @param int $temppost The temporary post ID.
2154
-     * @todo fix post_id variable
2155
-     */
2156
-    function geodir_update_listing_info($updatingpost, $temppost)
2157
-    {
2158
-
2159
-        global $wpdb, $plugin_prefix;
2160
-
2161
-        $post_type = get_post_type($post_id);
2162
-
2163
-        $table = $plugin_prefix . $post_type . '_detail';
2164
-
2165
-        $wpdb->query(
2166
-            $wpdb->prepare(
2167
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2168
-                array($updatingpost, $temppost)
2169
-            )
2170
-        );
2171
-
2172
-        $wpdb->query(
2173
-            $wpdb->prepare(
2174
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2175
-                array($updatingpost, $temppost)
2176
-            )
2177
-        );
2178
-
2179
-        /* Update Attachments*/
2180
-
2181
-        $wpdb->query(
2182
-            $wpdb->prepare(
2183
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2184
-                array($updatingpost, $temppost)
2185
-            )
2186
-        );
2187
-
2188
-    }
2145
+	/**
2146
+	 * Update post info.
2147
+	 *
2148
+	 * @since 1.0.0
2149
+	 * @package GeoDirectory
2150
+	 * @global object $wpdb WordPress Database object.
2151
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2152
+	 * @param int $updatingpost The updating post ID.
2153
+	 * @param int $temppost The temporary post ID.
2154
+	 * @todo fix post_id variable
2155
+	 */
2156
+	function geodir_update_listing_info($updatingpost, $temppost)
2157
+	{
2158
+
2159
+		global $wpdb, $plugin_prefix;
2160
+
2161
+		$post_type = get_post_type($post_id);
2162
+
2163
+		$table = $plugin_prefix . $post_type . '_detail';
2164
+
2165
+		$wpdb->query(
2166
+			$wpdb->prepare(
2167
+				"UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2168
+				array($updatingpost, $temppost)
2169
+			)
2170
+		);
2171
+
2172
+		$wpdb->query(
2173
+			$wpdb->prepare(
2174
+				"UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2175
+				array($updatingpost, $temppost)
2176
+			)
2177
+		);
2178
+
2179
+		/* Update Attachments*/
2180
+
2181
+		$wpdb->query(
2182
+			$wpdb->prepare(
2183
+				"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2184
+				array($updatingpost, $temppost)
2185
+			)
2186
+		);
2187
+
2188
+	}
2189 2189
 }
2190 2190
 
2191 2191
 
2192 2192
 if (!function_exists('geodir_delete_listing_info')) {
2193
-    /**
2194
-     * Delete Listing info from details table for the given post id.
2195
-     *
2196
-     * @since 1.0.0
2197
-     * @package GeoDirectory
2198
-     * @global object $wpdb WordPress Database object.
2199
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2200
-     * @param int $deleted_postid The post ID.
2201
-     * @param bool $force Optional. Do you want to force delete it? Default: false.
2202
-     * @return bool|void
2203
-     */
2204
-    function geodir_delete_listing_info($deleted_postid, $force = false)
2205
-    {
2206
-        global $wpdb, $plugin_prefix;
2207
-
2208
-        // check for multisite deletions
2209
-        if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2210
-        } else {
2211
-            return;
2212
-        }
2213
-
2214
-        $post_type = get_post_type($deleted_postid);
2215
-
2216
-        $all_postypes = geodir_get_posttypes();
2217
-
2218
-        if (!in_array($post_type, $all_postypes))
2219
-            return false;
2220
-
2221
-        $table = $plugin_prefix . $post_type . '_detail';
2222
-
2223
-        /* Delete custom post meta*/
2224
-        $wpdb->query(
2225
-            $wpdb->prepare(
2226
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2227
-                array($deleted_postid)
2228
-            )
2229
-        );
2230
-
2231
-        /* Delete post map icons*/
2232
-
2233
-        $wpdb->query(
2234
-            $wpdb->prepare(
2235
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2236
-                array($deleted_postid)
2237
-            )
2238
-        );
2239
-
2240
-        /* Delete Attachments*/
2241
-        $postcurr_images = geodir_get_images($deleted_postid);
2242
-
2243
-        $wpdb->query(
2244
-            $wpdb->prepare(
2245
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2246
-                array($deleted_postid)
2247
-            )
2248
-        );
2249
-        geodir_remove_attachments($postcurr_images);
2250
-
2251
-    }
2193
+	/**
2194
+	 * Delete Listing info from details table for the given post id.
2195
+	 *
2196
+	 * @since 1.0.0
2197
+	 * @package GeoDirectory
2198
+	 * @global object $wpdb WordPress Database object.
2199
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2200
+	 * @param int $deleted_postid The post ID.
2201
+	 * @param bool $force Optional. Do you want to force delete it? Default: false.
2202
+	 * @return bool|void
2203
+	 */
2204
+	function geodir_delete_listing_info($deleted_postid, $force = false)
2205
+	{
2206
+		global $wpdb, $plugin_prefix;
2207
+
2208
+		// check for multisite deletions
2209
+		if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2210
+		} else {
2211
+			return;
2212
+		}
2213
+
2214
+		$post_type = get_post_type($deleted_postid);
2215
+
2216
+		$all_postypes = geodir_get_posttypes();
2217
+
2218
+		if (!in_array($post_type, $all_postypes))
2219
+			return false;
2220
+
2221
+		$table = $plugin_prefix . $post_type . '_detail';
2222
+
2223
+		/* Delete custom post meta*/
2224
+		$wpdb->query(
2225
+			$wpdb->prepare(
2226
+				"DELETE FROM " . $table . " WHERE `post_id` = %d",
2227
+				array($deleted_postid)
2228
+			)
2229
+		);
2230
+
2231
+		/* Delete post map icons*/
2232
+
2233
+		$wpdb->query(
2234
+			$wpdb->prepare(
2235
+				"DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2236
+				array($deleted_postid)
2237
+			)
2238
+		);
2239
+
2240
+		/* Delete Attachments*/
2241
+		$postcurr_images = geodir_get_images($deleted_postid);
2242
+
2243
+		$wpdb->query(
2244
+			$wpdb->prepare(
2245
+				"DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2246
+				array($deleted_postid)
2247
+			)
2248
+		);
2249
+		geodir_remove_attachments($postcurr_images);
2250
+
2251
+	}
2252 2252
 }
2253 2253
 
2254 2254
 
2255 2255
 if (!function_exists('geodir_add_to_favorite')) {
2256
-    /**
2257
-     * This function would add listing to favorite listing.
2258
-     *
2259
-     * @since 1.0.0
2260
-     * @package GeoDirectory
2261
-     * @global object $current_user Current user object.
2262
-     * @param int $post_id The post ID.
2263
-     */
2264
-    function geodir_add_to_favorite($post_id)
2265
-    {
2266
-
2267
-        global $current_user;
2268
-
2269
-        /**
2270
-         * Filter to modify "Unfavorite" text
2271
-         *
2272
-         * You can use this filter to rename "Unfavorite" text to something else.
2273
-         *
2274
-         * @since 1.0.0
2275
-         * @package GeoDirectory
2276
-         */
2277
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2278
-
2279
-        /**
2280
-         * Filter to modify "Remove from Favorites" text
2281
-         *
2282
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2283
-         *
2284
-         * @since 1.0.0
2285
-         * @package GeoDirectory
2286
-         */
2287
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2288
-
2289
-        /**
2290
-         * Filter to modify "fa fa-heart" icon
2291
-         *
2292
-         * You can use this filter to change "fa fa-heart" icon to something else.
2293
-         *
2294
-         * @since 1.0.0
2295
-         * @package GeoDirectory
2296
-         */
2297
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2298
-
2299
-        $user_meta_data = array();
2300
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2301
-
2302
-        if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2303
-            $user_meta_data[] = $post_id;
2304
-        }
2305
-
2306
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2307
-
2308
-        /**
2309
-         * Called before adding the post from favourites.
2310
-         *
2311
-         * @since 1.0.0
2312
-         * @package GeoDirectory
2313
-         * @param int $post_id The post ID.
2314
-         */
2315
-        do_action('geodir_before_add_from_favorite', $post_id);
2316
-
2317
-        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>';
2318
-
2319
-        /**
2320
-         * Called after adding the post from favourites.
2321
-         *
2322
-         * @since 1.0.0
2323
-         * @package GeoDirectory
2324
-         * @param int $post_id The post ID.
2325
-         */
2326
-        do_action('geodir_after_add_from_favorite', $post_id);
2256
+	/**
2257
+	 * This function would add listing to favorite listing.
2258
+	 *
2259
+	 * @since 1.0.0
2260
+	 * @package GeoDirectory
2261
+	 * @global object $current_user Current user object.
2262
+	 * @param int $post_id The post ID.
2263
+	 */
2264
+	function geodir_add_to_favorite($post_id)
2265
+	{
2266
+
2267
+		global $current_user;
2268
+
2269
+		/**
2270
+		 * Filter to modify "Unfavorite" text
2271
+		 *
2272
+		 * You can use this filter to rename "Unfavorite" text to something else.
2273
+		 *
2274
+		 * @since 1.0.0
2275
+		 * @package GeoDirectory
2276
+		 */
2277
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2278
+
2279
+		/**
2280
+		 * Filter to modify "Remove from Favorites" text
2281
+		 *
2282
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2283
+		 *
2284
+		 * @since 1.0.0
2285
+		 * @package GeoDirectory
2286
+		 */
2287
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2288
+
2289
+		/**
2290
+		 * Filter to modify "fa fa-heart" icon
2291
+		 *
2292
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2293
+		 *
2294
+		 * @since 1.0.0
2295
+		 * @package GeoDirectory
2296
+		 */
2297
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2298
+
2299
+		$user_meta_data = array();
2300
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2301
+
2302
+		if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2303
+			$user_meta_data[] = $post_id;
2304
+		}
2305
+
2306
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2307
+
2308
+		/**
2309
+		 * Called before adding the post from favourites.
2310
+		 *
2311
+		 * @since 1.0.0
2312
+		 * @package GeoDirectory
2313
+		 * @param int $post_id The post ID.
2314
+		 */
2315
+		do_action('geodir_before_add_from_favorite', $post_id);
2316
+
2317
+		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>';
2318
+
2319
+		/**
2320
+		 * Called after adding the post from favourites.
2321
+		 *
2322
+		 * @since 1.0.0
2323
+		 * @package GeoDirectory
2324
+		 * @param int $post_id The post ID.
2325
+		 */
2326
+		do_action('geodir_after_add_from_favorite', $post_id);
2327 2327
 
2328
-    }
2328
+	}
2329 2329
 }
2330 2330
 
2331 2331
 if (!function_exists('geodir_remove_from_favorite')) {
2332
-    /**
2333
-     * This function would remove the favourited property earlier.
2334
-     *
2335
-     * @since 1.0.0
2336
-     * @package GeoDirectory
2337
-     * @global object $current_user Current user object.
2338
-     * @param int $post_id The post ID.
2339
-     */
2340
-    function geodir_remove_from_favorite($post_id)
2341
-    {
2342
-        global $current_user;
2343
-
2344
-        /**
2345
-         * Filter to modify "Add to Favorites" text
2346
-         *
2347
-         * You can use this filter to rename "Add to Favorites" text to something else.
2348
-         *
2349
-         * @since 1.0.0
2350
-         * @package GeoDirectory
2351
-         */
2352
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2353
-
2354
-        /**
2355
-         * Filter to modify "Favourite" text
2356
-         *
2357
-         * You can use this filter to rename "Favourite" text to something else.
2358
-         *
2359
-         * @since 1.0.0
2360
-         * @package GeoDirectory
2361
-         */
2362
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2363
-
2364
-        /**
2365
-         * Filter to modify "fa fa-heart" icon
2366
-         *
2367
-         * You can use this filter to change "fa fa-heart" icon to something else.
2368
-         *
2369
-         * @since 1.0.0
2370
-         * @package GeoDirectory
2371
-         */
2372
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2373
-
2374
-        $user_meta_data = array();
2375
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2376
-
2377
-        if (!empty($user_meta_data)) {
2378
-
2379
-            if (($key = array_search($post_id, $user_meta_data)) !== false) {
2380
-                unset($user_meta_data[$key]);
2381
-            }
2332
+	/**
2333
+	 * This function would remove the favourited property earlier.
2334
+	 *
2335
+	 * @since 1.0.0
2336
+	 * @package GeoDirectory
2337
+	 * @global object $current_user Current user object.
2338
+	 * @param int $post_id The post ID.
2339
+	 */
2340
+	function geodir_remove_from_favorite($post_id)
2341
+	{
2342
+		global $current_user;
2343
+
2344
+		/**
2345
+		 * Filter to modify "Add to Favorites" text
2346
+		 *
2347
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2348
+		 *
2349
+		 * @since 1.0.0
2350
+		 * @package GeoDirectory
2351
+		 */
2352
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2353
+
2354
+		/**
2355
+		 * Filter to modify "Favourite" text
2356
+		 *
2357
+		 * You can use this filter to rename "Favourite" text to something else.
2358
+		 *
2359
+		 * @since 1.0.0
2360
+		 * @package GeoDirectory
2361
+		 */
2362
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2363
+
2364
+		/**
2365
+		 * Filter to modify "fa fa-heart" icon
2366
+		 *
2367
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2368
+		 *
2369
+		 * @since 1.0.0
2370
+		 * @package GeoDirectory
2371
+		 */
2372
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2373
+
2374
+		$user_meta_data = array();
2375
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2376
+
2377
+		if (!empty($user_meta_data)) {
2378
+
2379
+			if (($key = array_search($post_id, $user_meta_data)) !== false) {
2380
+				unset($user_meta_data[$key]);
2381
+			}
2382 2382
 
2383
-        }
2383
+		}
2384 2384
 
2385
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2385
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2386 2386
 
2387
-        /**
2388
-         * Called before removing the post from favourites.
2389
-         *
2390
-         * @since 1.0.0
2391
-         * @package GeoDirectory
2392
-         * @param int $post_id The post ID.
2393
-         */
2394
-        do_action('geodir_before_remove_from_favorite', $post_id);
2387
+		/**
2388
+		 * Called before removing the post from favourites.
2389
+		 *
2390
+		 * @since 1.0.0
2391
+		 * @package GeoDirectory
2392
+		 * @param int $post_id The post ID.
2393
+		 */
2394
+		do_action('geodir_before_remove_from_favorite', $post_id);
2395 2395
 
2396
-        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>';
2396
+		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>';
2397 2397
 
2398
-        /**
2399
-         * Called after removing the post from favourites.
2400
-         *
2401
-         * @since 1.0.0
2402
-         * @package GeoDirectory
2403
-         * @param int $post_id The post ID.
2404
-         */
2405
-        do_action('geodir_after_remove_from_favorite', $post_id);
2398
+		/**
2399
+		 * Called after removing the post from favourites.
2400
+		 *
2401
+		 * @since 1.0.0
2402
+		 * @package GeoDirectory
2403
+		 * @param int $post_id The post ID.
2404
+		 */
2405
+		do_action('geodir_after_remove_from_favorite', $post_id);
2406 2406
 
2407
-    }
2407
+	}
2408 2408
 }
2409 2409
 
2410 2410
 if (!function_exists('geodir_favourite_html')) {
2411
-    /**
2412
-     * This function would display the html content for add to favorite or remove from favorite.
2413
-     *
2414
-     * @since 1.0.0
2415
-     * @package GeoDirectory
2416
-     * @global object $current_user Current user object.
2417
-     * @global object $post The current post object.
2418
-     * @param int $user_id The user ID.
2419
-     * @param int $post_id The post ID.
2420
-     */
2421
-    function geodir_favourite_html($user_id, $post_id)
2422
-    {
2423
-
2424
-        global $current_user, $post;
2425
-
2426
-        /**
2427
-         * Filter to modify "Add to Favorites" text
2428
-         *
2429
-         * You can use this filter to rename "Add to Favorites" text to something else.
2430
-         *
2431
-         * @since 1.0.0
2432
-         * @package GeoDirectory
2433
-         */
2434
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2435
-
2436
-        /**
2437
-         * Filter to modify "Favourite" text
2438
-         *
2439
-         * You can use this filter to rename "Favourite" text to something else.
2440
-         *
2441
-         * @since 1.0.0
2442
-         * @package GeoDirectory
2443
-         */
2444
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2445
-
2446
-        /**
2447
-         * Filter to modify "Unfavorite" text
2448
-         *
2449
-         * You can use this filter to rename "Unfavorite" text to something else.
2450
-         *
2451
-         * @since 1.0.0
2452
-         * @package GeoDirectory
2453
-         */
2454
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2455
-
2456
-        /**
2457
-         * Filter to modify "Remove from Favorites" text
2458
-         *
2459
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2460
-         *
2461
-         * @since 1.0.0
2462
-         * @package GeoDirectory
2463
-         */
2464
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2465
-
2466
-        /**
2467
-         * Filter to modify "fa fa-heart" icon
2468
-         *
2469
-         * You can use this filter to change "fa fa-heart" icon to something else.
2470
-         *
2471
-         * @since 1.0.0
2472
-         * @package GeoDirectory
2473
-         */
2474
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2475
-
2476
-        /**
2477
-         * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2478
-         *
2479
-         * You can use this filter to change "fa fa-heart" icon to something else.
2480
-         *
2481
-         * @since 1.0.0
2482
-         * @package GeoDirectory
2483
-         */
2484
-        $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2485
-
2486
-        $user_meta_data = '';
2487
-        if (isset($current_user->data->ID))
2488
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2489
-
2490
-        if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2491
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2411
+	/**
2412
+	 * This function would display the html content for add to favorite or remove from favorite.
2413
+	 *
2414
+	 * @since 1.0.0
2415
+	 * @package GeoDirectory
2416
+	 * @global object $current_user Current user object.
2417
+	 * @global object $post The current post object.
2418
+	 * @param int $user_id The user ID.
2419
+	 * @param int $post_id The post ID.
2420
+	 */
2421
+	function geodir_favourite_html($user_id, $post_id)
2422
+	{
2423
+
2424
+		global $current_user, $post;
2425
+
2426
+		/**
2427
+		 * Filter to modify "Add to Favorites" text
2428
+		 *
2429
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2430
+		 *
2431
+		 * @since 1.0.0
2432
+		 * @package GeoDirectory
2433
+		 */
2434
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2435
+
2436
+		/**
2437
+		 * Filter to modify "Favourite" text
2438
+		 *
2439
+		 * You can use this filter to rename "Favourite" text to something else.
2440
+		 *
2441
+		 * @since 1.0.0
2442
+		 * @package GeoDirectory
2443
+		 */
2444
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2445
+
2446
+		/**
2447
+		 * Filter to modify "Unfavorite" text
2448
+		 *
2449
+		 * You can use this filter to rename "Unfavorite" text to something else.
2450
+		 *
2451
+		 * @since 1.0.0
2452
+		 * @package GeoDirectory
2453
+		 */
2454
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2455
+
2456
+		/**
2457
+		 * Filter to modify "Remove from Favorites" text
2458
+		 *
2459
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2460
+		 *
2461
+		 * @since 1.0.0
2462
+		 * @package GeoDirectory
2463
+		 */
2464
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2465
+
2466
+		/**
2467
+		 * Filter to modify "fa fa-heart" icon
2468
+		 *
2469
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2470
+		 *
2471
+		 * @since 1.0.0
2472
+		 * @package GeoDirectory
2473
+		 */
2474
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2475
+
2476
+		/**
2477
+		 * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2478
+		 *
2479
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2480
+		 *
2481
+		 * @since 1.0.0
2482
+		 * @package GeoDirectory
2483
+		 */
2484
+		$unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2485
+
2486
+		$user_meta_data = '';
2487
+		if (isset($current_user->data->ID))
2488
+			$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2489
+
2490
+		if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2491
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2492 2492
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2493 2493
                 onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2494 2494
                 title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2495 2495
             </a>   </span><?php
2496 2496
 
2497
-        } else {
2497
+		} else {
2498 2498
 
2499
-            if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2500
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2501
-            } else
2502
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2499
+			if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2500
+				$script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2501
+			} else
2502
+				$script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2503 2503
 
2504
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2504
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2505 2505
                                                                                         href="javascript:void(0);"
2506 2506
                                                                                         onclick="<?php echo $script_text;?>"
2507 2507
                                                                                         title="<?php echo $add_favourite_text;?>"><i
2508 2508
                     class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2509 2509
         <?php }
2510
-    }
2510
+	}
2511 2511
 }
2512 2512
 
2513 2513
 
@@ -2524,54 +2524,54 @@  discard block
 block discarded – undo
2524 2524
 function geodir_get_cat_postcount($term = array())
2525 2525
 {
2526 2526
 
2527
-    if (!empty($term)) {
2527
+	if (!empty($term)) {
2528 2528
 
2529
-        global $wpdb, $plugin_prefix;
2529
+		global $wpdb, $plugin_prefix;
2530 2530
 
2531
-        $where = '';
2532
-        $join = '';
2533
-        if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2534
-            $taxonomy_obj = get_taxonomy($term->taxonomy);
2531
+		$where = '';
2532
+		$join = '';
2533
+		if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2534
+			$taxonomy_obj = get_taxonomy($term->taxonomy);
2535 2535
 
2536
-            $post_type = $taxonomy_obj->object_type[0];
2536
+			$post_type = $taxonomy_obj->object_type[0];
2537 2537
 
2538
-            $table = $plugin_prefix . $post_type . '_detail';
2538
+			$table = $plugin_prefix . $post_type . '_detail';
2539 2539
 
2540
-            /**
2541
-             * Filter to modify the 'join' query
2542
-             *
2543
-             * @since 1.0.0
2544
-             * @package GeoDirectory
2545
-             * @param object|array $term category / term object that need to be processed.
2546
-             * @param string $join The join query.
2547
-             */
2548
-            $join = apply_filters('geodir_cat_post_count_join', $join, $term);
2540
+			/**
2541
+			 * Filter to modify the 'join' query
2542
+			 *
2543
+			 * @since 1.0.0
2544
+			 * @package GeoDirectory
2545
+			 * @param object|array $term category / term object that need to be processed.
2546
+			 * @param string $join The join query.
2547
+			 */
2548
+			$join = apply_filters('geodir_cat_post_count_join', $join, $term);
2549 2549
 
2550
-            /**
2551
-             * Filter to modify the 'where' query
2552
-             *
2553
-             * @since 1.0.0
2554
-             * @package GeoDirectory
2555
-             * @param object|array $term category / term object that need to be processed.
2556
-             * @param string $where The where query.
2557
-             */
2558
-            $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2550
+			/**
2551
+			 * Filter to modify the 'where' query
2552
+			 *
2553
+			 * @since 1.0.0
2554
+			 * @package GeoDirectory
2555
+			 * @param object|array $term category / term object that need to be processed.
2556
+			 * @param string $where The where query.
2557
+			 */
2558
+			$where = apply_filters('geodir_cat_post_count_where', $where, $term);
2559 2559
 
2560
-            $count_query = "SELECT count(post_id) FROM
2560
+			$count_query = "SELECT count(post_id) FROM
2561 2561
 							" . $table . " as pd " . $join . "
2562 2562
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2563 2563
 
2564
-            $cat_post_count = $wpdb->get_var($count_query);
2565
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2566
-                $cat_post_count = 0;
2564
+			$cat_post_count = $wpdb->get_var($count_query);
2565
+			if (empty($cat_post_count) || is_wp_error($cat_post_count))
2566
+				$cat_post_count = 0;
2567 2567
 
2568
-            return $cat_post_count;
2568
+			return $cat_post_count;
2569 2569
 
2570
-        } else
2570
+		} else
2571 2571
 
2572
-            return $term->count;
2573
-    }
2574
-    return false;
2572
+			return $term->count;
2573
+	}
2574
+	return false;
2575 2575
 
2576 2576
 }
2577 2577
 
@@ -2584,17 +2584,17 @@  discard block
 block discarded – undo
2584 2584
  */
2585 2585
 function geodir_allow_post_type_frontend()
2586 2586
 {
2587
-    $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2587
+	$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2588 2588
 
2589
-    if (!is_admin() && isset($_REQUEST['listing_type'])
2590
-        && !empty($geodir_allow_posttype_frontend)
2591
-        && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2592
-    ) {
2589
+	if (!is_admin() && isset($_REQUEST['listing_type'])
2590
+		&& !empty($geodir_allow_posttype_frontend)
2591
+		&& !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2592
+	) {
2593 2593
 
2594
-        wp_redirect(home_url());
2595
-        exit;
2594
+		wp_redirect(home_url());
2595
+		exit;
2596 2596
 
2597
-    }
2597
+	}
2598 2598
 
2599 2599
 }
2600 2600
 
@@ -2611,20 +2611,20 @@  discard block
 block discarded – undo
2611 2611
  */
2612 2612
 function geodir_excerpt_length($length)
2613 2613
 {
2614
-    global $wp_query, $geodir_is_widget_listing;
2614
+	global $wp_query, $geodir_is_widget_listing;
2615 2615
 	if ($geodir_is_widget_listing) {
2616 2616
 		return $length;
2617 2617
 	}
2618 2618
 	
2619
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2620
-        $length = get_option('geodir_desc_word_limit');
2621
-    elseif (get_query_var('excerpt_length'))
2622
-        $length = get_query_var('excerpt_length');
2619
+	if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2620
+		$length = get_option('geodir_desc_word_limit');
2621
+	elseif (get_query_var('excerpt_length'))
2622
+		$length = get_query_var('excerpt_length');
2623 2623
 
2624
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2625
-        $length = get_option('geodir_author_desc_word_limit');
2624
+	if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2625
+		$length = get_option('geodir_author_desc_word_limit');
2626 2626
 
2627
-    return $length;
2627
+	return $length;
2628 2628
 }
2629 2629
 
2630 2630
 /**
@@ -2639,13 +2639,13 @@  discard block
 block discarded – undo
2639 2639
  */
2640 2640
 function geodir_excerpt_more($more)
2641 2641
 {
2642
-    global $post;
2643
-    $all_postypes = geodir_get_posttypes();
2644
-    if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2645
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2646
-    }
2642
+	global $post;
2643
+	$all_postypes = geodir_get_posttypes();
2644
+	if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2645
+		return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2646
+	}
2647 2647
 
2648
-    return $more;
2648
+	return $more;
2649 2649
 }
2650 2650
 
2651 2651
 
@@ -2662,63 +2662,63 @@  discard block
 block discarded – undo
2662 2662
  */
2663 2663
 function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
2664 2664
 {
2665
-    global $plugin_prefix, $wpdb;
2665
+	global $plugin_prefix, $wpdb;
2666 2666
 
2667
-    $gd_taxonomies = geodir_get_taxonomies();
2667
+	$gd_taxonomies = geodir_get_taxonomies();
2668 2668
 
2669
-    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2669
+	if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2670 2670
 
2671
-        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2672
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2671
+		$geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2672
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
2673 2673
 
2674
-        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2675
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2674
+		$path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2675
+		$term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2676 2676
 
2677
-        $posts = $wpdb->get_results(
2678
-            $wpdb->prepare(
2679
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2680
-                array($term_id, $taxonomy)
2681
-            )
2682
-        );
2677
+		$posts = $wpdb->get_results(
2678
+			$wpdb->prepare(
2679
+				"SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2680
+				array($term_id, $taxonomy)
2681
+			)
2682
+		);
2683 2683
 
2684
-        if (!empty($posts)):
2685
-            foreach ($posts as $post_obj) {
2684
+		if (!empty($posts)):
2685
+			foreach ($posts as $post_obj) {
2686 2686
 
2687
-                $lat = $post_obj->post_latitude;
2688
-                $lng = $post_obj->post_longitude;
2687
+				$lat = $post_obj->post_latitude;
2688
+				$lng = $post_obj->post_longitude;
2689 2689
 
2690
-                $json = '{';
2691
-                $json .= '"id":"' . $post_obj->post_id . '",';
2692
-                $json .= '"lat_pos": "' . $lat . '",';
2693
-                $json .= '"long_pos": "' . $lng . '",';
2694
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2695
-                $json .= '"icon":"' . $term_icon . '",';
2696
-                $json .= '"group":"catgroup' . $term_id . '"';
2697
-                $json .= '}';
2690
+				$json = '{';
2691
+				$json .= '"id":"' . $post_obj->post_id . '",';
2692
+				$json .= '"lat_pos": "' . $lat . '",';
2693
+				$json .= '"long_pos": "' . $lng . '",';
2694
+				$json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2695
+				$json .= '"icon":"' . $term_icon . '",';
2696
+				$json .= '"group":"catgroup' . $term_id . '"';
2697
+				$json .= '}';
2698 2698
 
2699
-                if ($post_obj->default_category == $term_id) {
2699
+				if ($post_obj->default_category == $term_id) {
2700 2700
 
2701
-                    $wpdb->query(
2702
-                        $wpdb->prepare(
2703
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2704
-                            array($json, $post_obj->post_id)
2705
-                        )
2706
-                    );
2707
-                }
2701
+					$wpdb->query(
2702
+						$wpdb->prepare(
2703
+							"UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2704
+							array($json, $post_obj->post_id)
2705
+						)
2706
+					);
2707
+				}
2708 2708
 
2709
-                $wpdb->query(
2710
-                    $wpdb->prepare(
2711
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2712
-                        array($json, $post_obj->post_id, $term_id)
2713
-                    )
2714
-                );
2709
+				$wpdb->query(
2710
+					$wpdb->prepare(
2711
+						"UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2712
+						array($json, $post_obj->post_id, $term_id)
2713
+					)
2714
+				);
2715 2715
 
2716
-            }
2716
+			}
2717 2717
 
2718 2718
 
2719
-        endif;
2719
+		endif;
2720 2720
 
2721
-    }
2721
+	}
2722 2722
 
2723 2723
 }
2724 2724
 
@@ -2732,14 +2732,14 @@  discard block
 block discarded – undo
2732 2732
  */
2733 2733
 function geodir_get_listing_author($listing_id = '')
2734 2734
 {
2735
-    if ($listing_id == '') {
2736
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2737
-            $listing_id = $_REQUEST['pid'];
2738
-        }
2739
-    }
2740
-    $listing = get_post(strip_tags($listing_id));
2741
-    $listing_author_id = $listing->post_author;
2742
-    return $listing_author_id;
2735
+	if ($listing_id == '') {
2736
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2737
+			$listing_id = $_REQUEST['pid'];
2738
+		}
2739
+	}
2740
+	$listing = get_post(strip_tags($listing_id));
2741
+	$listing_author_id = $listing->post_author;
2742
+	return $listing_author_id;
2743 2743
 }
2744 2744
 
2745 2745
 
@@ -2754,11 +2754,11 @@  discard block
 block discarded – undo
2754 2754
  */
2755 2755
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2756 2756
 {
2757
-    $listing_author_id = geodir_get_listing_author($listing_id);
2758
-    if ($listing_author_id == $user_id)
2759
-        return true;
2760
-    else
2761
-        return false;
2757
+	$listing_author_id = geodir_get_listing_author($listing_id);
2758
+	if ($listing_author_id == $user_id)
2759
+		return true;
2760
+	else
2761
+		return false;
2762 2762
 
2763 2763
 }
2764 2764
 
@@ -2774,17 +2774,17 @@  discard block
 block discarded – undo
2774 2774
  */
2775 2775
 function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true)
2776 2776
 {
2777
-    global $current_user;
2778
-    if ($exclude_admin) {
2779
-        foreach ($current_user->caps as $key => $caps) {
2780
-            if (geodir_strtolower($key) == 'administrator') {
2781
-                return true;
2782
-                break;
2783
-            }
2784
-        }
2785
-    }
2786
-
2787
-    return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2777
+	global $current_user;
2778
+	if ($exclude_admin) {
2779
+		foreach ($current_user->caps as $key => $caps) {
2780
+			if (geodir_strtolower($key) == 'administrator') {
2781
+				return true;
2782
+				break;
2783
+			}
2784
+		}
2785
+	}
2786
+
2787
+	return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2788 2788
 }
2789 2789
 
2790 2790
 
@@ -2800,17 +2800,17 @@  discard block
 block discarded – undo
2800 2800
 function geodir_only_supportable_attachments_remove($file)
2801 2801
 {
2802 2802
 
2803
-    global $wpdb;
2803
+	global $wpdb;
2804 2804
 
2805
-    $matches = array();
2805
+	$matches = array();
2806 2806
 
2807
-    $pattern = '/-\d+x\d+\./';
2808
-    preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2807
+	$pattern = '/-\d+x\d+\./';
2808
+	preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2809 2809
 
2810
-    if (empty($matches))
2811
-        return '';
2812
-    else
2813
-        return $file;
2810
+	if (empty($matches))
2811
+		return '';
2812
+	else
2813
+		return $file;
2814 2814
 
2815 2815
 }
2816 2816
 
@@ -2827,78 +2827,78 @@  discard block
 block discarded – undo
2827 2827
 function geodir_set_wp_featured_image($post_id)
2828 2828
 {
2829 2829
 
2830
-    global $wpdb, $plugin_prefix;
2831
-    $uploads = wp_upload_dir();
2830
+	global $wpdb, $plugin_prefix;
2831
+	$uploads = wp_upload_dir();
2832 2832
 //	print_r($uploads ) ;
2833
-    $post_first_image = $wpdb->get_results(
2834
-        $wpdb->prepare(
2835
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2836
-        )
2837
-    );
2838
-
2839
-    $old_attachment_name = '';
2840
-    $post_thumbnail_id = '';
2841
-    if (has_post_thumbnail($post_id)) {
2833
+	$post_first_image = $wpdb->get_results(
2834
+		$wpdb->prepare(
2835
+			"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2836
+		)
2837
+	);
2842 2838
 
2843
-        if (has_post_thumbnail($post_id)) {
2839
+	$old_attachment_name = '';
2840
+	$post_thumbnail_id = '';
2841
+	if (has_post_thumbnail($post_id)) {
2844 2842
 
2845
-            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2843
+		if (has_post_thumbnail($post_id)) {
2846 2844
 
2847
-            $old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2845
+			$post_thumbnail_id = get_post_thumbnail_id($post_id);
2848 2846
 
2849
-        }
2850
-    }
2847
+			$old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2851 2848
 
2852
-    if (!empty($post_first_image)) {
2849
+		}
2850
+	}
2853 2851
 
2854
-        $post_type = get_post_type($post_id);
2852
+	if (!empty($post_first_image)) {
2855 2853
 
2856
-        $table_name = $plugin_prefix . $post_type . '_detail';
2854
+		$post_type = get_post_type($post_id);
2857 2855
 
2858
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2856
+		$table_name = $plugin_prefix . $post_type . '_detail';
2859 2857
 
2860
-        $new_attachment_name = basename($post_first_image[0]->file);
2858
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2861 2859
 
2862
-        if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2860
+		$new_attachment_name = basename($post_first_image[0]->file);
2863 2861
 
2864
-            if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2862
+		if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2865 2863
 
2866
-                add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2864
+			if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2867 2865
 
2868
-                wp_delete_attachment($post_thumbnail_id);
2866
+				add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2869 2867
 
2870
-            }
2871
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2868
+				wp_delete_attachment($post_thumbnail_id);
2872 2869
 
2873
-            $attachment = array(
2874
-                'post_mime_type' => $post_first_image[0]->mime_type,
2875
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2876
-                'post_parent' => $post_id,
2877
-                'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2878
-                'post_content' => ''
2879
-            );
2870
+			}
2871
+			$filename = $uploads['basedir'] . $post_first_image[0]->file;
2872
+
2873
+			$attachment = array(
2874
+				'post_mime_type' => $post_first_image[0]->mime_type,
2875
+				'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2876
+				'post_parent' => $post_id,
2877
+				'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2878
+				'post_content' => ''
2879
+			);
2880 2880
 
2881 2881
 
2882
-            $id = wp_insert_attachment($attachment, $filename, $post_id);
2882
+			$id = wp_insert_attachment($attachment, $filename, $post_id);
2883 2883
 
2884
-            if (!is_wp_error($id)) {
2884
+			if (!is_wp_error($id)) {
2885 2885
 
2886
-                set_post_thumbnail($post_id, $id);
2886
+				set_post_thumbnail($post_id, $id);
2887 2887
 
2888
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2889
-                wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2888
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
2889
+				wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2890 2890
 
2891
-            }
2891
+			}
2892 2892
 
2893
-        }
2893
+		}
2894 2894
 
2895
-    } else {
2896
-        //set_post_thumbnail($post_id,-1);
2895
+	} else {
2896
+		//set_post_thumbnail($post_id,-1);
2897 2897
 
2898
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2899
-            wp_delete_attachment($post_thumbnail_id);
2898
+		if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2899
+			wp_delete_attachment($post_thumbnail_id);
2900 2900
 
2901
-    }
2901
+	}
2902 2902
 }
2903 2903
 
2904 2904
 
@@ -2913,53 +2913,53 @@  discard block
 block discarded – undo
2913 2913
  */
2914 2914
 function gd_copy_original_translation()
2915 2915
 {
2916
-    if (function_exists('icl_object_id')) {
2917
-        global $wpdb, $table_prefix, $plugin_prefix;
2918
-        $post_id = absint($_POST['post_id']);
2919
-        $upload_dir = wp_upload_dir();
2920
-        $post_type = get_post_type($_POST['post_id']);
2921
-        $table = $plugin_prefix . $post_type . '_detail';
2922
-
2923
-        $post_arr = $wpdb->get_results($wpdb->prepare(
2924
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2925
-            array($post_id)
2926
-        )
2927
-            , ARRAY_A);
2928
-
2929
-        $arrImages = $wpdb->get_results(
2930
-            $wpdb->prepare(
2931
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2932
-                array('%image%', $post_id)
2933
-            )
2934
-        );
2935
-        if ($arrImages) {
2936
-            $image_arr = array();
2937
-            foreach ($arrImages as $img) {
2938
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2939
-            }
2940
-            $comma_separated = implode(",", $image_arr);
2941
-            $post_arr[0]['post_images'] = $comma_separated;
2942
-        }
2943
-
2944
-
2945
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2946
-        $cat_arr = array_filter(explode(",", $cats));
2947
-        $trans_cat = array();
2948
-        foreach ($cat_arr as $cat) {
2949
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2950
-        }
2951
-
2952
-
2953
-        $post_arr[0]['categories'] = array_filter($trans_cat);
2916
+	if (function_exists('icl_object_id')) {
2917
+		global $wpdb, $table_prefix, $plugin_prefix;
2918
+		$post_id = absint($_POST['post_id']);
2919
+		$upload_dir = wp_upload_dir();
2920
+		$post_type = get_post_type($_POST['post_id']);
2921
+		$table = $plugin_prefix . $post_type . '_detail';
2922
+
2923
+		$post_arr = $wpdb->get_results($wpdb->prepare(
2924
+			"SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2925
+			array($post_id)
2926
+		)
2927
+			, ARRAY_A);
2928
+
2929
+		$arrImages = $wpdb->get_results(
2930
+			$wpdb->prepare(
2931
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2932
+				array('%image%', $post_id)
2933
+			)
2934
+		);
2935
+		if ($arrImages) {
2936
+			$image_arr = array();
2937
+			foreach ($arrImages as $img) {
2938
+				$image_arr[] = $upload_dir['baseurl'] . $img->file;
2939
+			}
2940
+			$comma_separated = implode(",", $image_arr);
2941
+			$post_arr[0]['post_images'] = $comma_separated;
2942
+		}
2943
+
2944
+
2945
+		$cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2946
+		$cat_arr = array_filter(explode(",", $cats));
2947
+		$trans_cat = array();
2948
+		foreach ($cat_arr as $cat) {
2949
+			$trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2950
+		}
2951
+
2952
+
2953
+		$post_arr[0]['categories'] = array_filter($trans_cat);
2954 2954
 //print_r($image_arr);
2955
-        //print_r($arrImages);
2956
-        //echo $_REQUEST['lang'];
2955
+		//print_r($arrImages);
2956
+		//echo $_REQUEST['lang'];
2957 2957
 //print_r($post_arr);
2958 2958
 //print_r($trans_cat);
2959
-        echo json_encode($post_arr[0]);
2959
+		echo json_encode($post_arr[0]);
2960 2960
 
2961
-    }
2962
-    die();
2961
+	}
2962
+	die();
2963 2963
 }
2964 2964
 
2965 2965
 
@@ -2979,54 +2979,54 @@  discard block
 block discarded – undo
2979 2979
 function geodir_get_custom_fields_type($listing_type = '')
2980 2980
 {
2981 2981
 
2982
-    global $wpdb;
2982
+	global $wpdb;
2983 2983
 
2984
-    if ($listing_type == '')
2985
-        $listing_type = 'gd_place';
2984
+	if ($listing_type == '')
2985
+		$listing_type = 'gd_place';
2986 2986
 
2987
-    $fields_info = array();
2987
+	$fields_info = array();
2988 2988
 
2989
-    $get_data = $wpdb->get_results(
2990
-        $wpdb->prepare(
2991
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2992
-            array($listing_type)
2993
-        )
2994
-    );
2989
+	$get_data = $wpdb->get_results(
2990
+		$wpdb->prepare(
2991
+			"SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2992
+			array($listing_type)
2993
+		)
2994
+	);
2995 2995
 
2996
-    if (!empty($get_data)) {
2996
+	if (!empty($get_data)) {
2997 2997
 
2998
-        foreach ($get_data as $data) {
2998
+		foreach ($get_data as $data) {
2999 2999
 
3000
-            if ($data->field_type == 'address') {
3000
+			if ($data->field_type == 'address') {
3001 3001
 
3002
-                $extra_fields = unserialize($data->extra_fields);
3002
+				$extra_fields = unserialize($data->extra_fields);
3003 3003
 
3004
-                $prefix = $data->htmlvar_name . '_';
3004
+				$prefix = $data->htmlvar_name . '_';
3005 3005
 
3006
-                $fields_info[$prefix . 'address'] = $data->field_type;
3006
+				$fields_info[$prefix . 'address'] = $data->field_type;
3007 3007
 
3008
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3009
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3008
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3009
+					$fields_info[$prefix . 'zip'] = $data->field_type;
3010 3010
 
3011
-            } else {
3011
+			} else {
3012 3012
 
3013
-                $fields_info[$data->htmlvar_name] = $data->field_type;
3013
+				$fields_info[$data->htmlvar_name] = $data->field_type;
3014 3014
 
3015
-            }
3015
+			}
3016 3016
 
3017
-        }
3017
+		}
3018 3018
 
3019
-    }
3019
+	}
3020 3020
 
3021
-    /**
3022
-     * Filter to modify custom fields info using listing post type.
3023
-     *
3024
-     * @since 1.0.0
3025
-     * @package GeoDirectory
3026
-     * @return array $fields_info Custom fields info.
3027
-     * @param string $listing_type The listing post type.
3028
-     */
3029
-    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3021
+	/**
3022
+	 * Filter to modify custom fields info using listing post type.
3023
+	 *
3024
+	 * @since 1.0.0
3025
+	 * @package GeoDirectory
3026
+	 * @return array $fields_info Custom fields info.
3027
+	 * @param string $listing_type The listing post type.
3028
+	 */
3029
+	return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3030 3030
 }
3031 3031
 
3032 3032
 
@@ -3041,58 +3041,58 @@  discard block
 block discarded – undo
3041 3041
  */
3042 3042
 function geodir_function_post_updated($post_ID, $post_after, $post_before)
3043 3043
 {
3044
-    $post_type = get_post_type($post_ID);
3044
+	$post_type = get_post_type($post_ID);
3045 3045
 
3046
-    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3047
-        // send notification to client when post moves from draft to publish
3048
-        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')) {
3049
-            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3050
-            $post_author_data = get_userdata($post_author_id);
3046
+	if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3047
+		// send notification to client when post moves from draft to publish
3048
+		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')) {
3049
+			$post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3050
+			$post_author_data = get_userdata($post_author_id);
3051 3051
 
3052
-            $to_name = geodir_get_client_name($post_author_id);
3052
+			$to_name = geodir_get_client_name($post_author_id);
3053 3053
 
3054
-            $from_email = geodir_get_site_email_id();
3055
-            $from_name = get_site_emailName();
3056
-            $to_email = $post_author_data->user_email;
3054
+			$from_email = geodir_get_site_email_id();
3055
+			$from_name = get_site_emailName();
3056
+			$to_email = $post_author_data->user_email;
3057 3057
 
3058
-            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3059
-                $to_email = $post_author_data->user_email;
3060
-            }
3058
+			if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3059
+				$to_email = $post_author_data->user_email;
3060
+			}
3061 3061
 
3062
-            $message_type = 'listing_published';
3062
+			$message_type = 'listing_published';
3063 3063
 
3064
-            if (get_option('geodir_post_published_email_subject') == '') {
3065
-                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3066
-            }
3064
+			if (get_option('geodir_post_published_email_subject') == '') {
3065
+				update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3066
+			}
3067 3067
 
3068
-            if (get_option('geodir_post_published_email_content') == '') {
3069
-                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'));
3070
-            }
3068
+			if (get_option('geodir_post_published_email_content') == '') {
3069
+				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'));
3070
+			}
3071 3071
 
3072
-            /**
3073
-             * Called before sending the email when listing gets published.
3074
-             *
3075
-             * @since 1.0.0
3076
-             * @package GeoDirectory
3077
-             * @param object $post_after The post object after update.
3078
-             * @param object $post_before The post object before update.
3079
-             */
3080
-            do_action('geodir_before_listing_published_email', $post_after, $post_before);
3081
-            if (is_email($to_email)) {
3082
-                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3083
-            }
3072
+			/**
3073
+			 * Called before sending the email when listing gets published.
3074
+			 *
3075
+			 * @since 1.0.0
3076
+			 * @package GeoDirectory
3077
+			 * @param object $post_after The post object after update.
3078
+			 * @param object $post_before The post object before update.
3079
+			 */
3080
+			do_action('geodir_before_listing_published_email', $post_after, $post_before);
3081
+			if (is_email($to_email)) {
3082
+				geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3083
+			}
3084 3084
 
3085
-            /**
3086
-             * Called after sending the email when listing gets published.
3087
-             *
3088
-             * @since 1.0.0
3089
-             * @package GeoDirectory
3090
-             * @param object $post_after The post object after update.
3091
-             * @param object $post_before The post object before update.
3092
-             */
3093
-            do_action('geodir_after_listing_published_email', $post_after, $post_before);
3094
-        }
3095
-    }
3085
+			/**
3086
+			 * Called after sending the email when listing gets published.
3087
+			 *
3088
+			 * @since 1.0.0
3089
+			 * @package GeoDirectory
3090
+			 * @param object $post_after The post object after update.
3091
+			 * @param object $post_before The post object before update.
3092
+			 */
3093
+			do_action('geodir_after_listing_published_email', $post_after, $post_before);
3094
+		}
3095
+	}
3096 3096
 }
3097 3097
 
3098 3098
 add_action('wp_head', 'geodir_fb_like_thumbnail');
@@ -3106,14 +3106,14 @@  discard block
 block discarded – undo
3106 3106
  */
3107 3107
 function geodir_fb_like_thumbnail(){
3108 3108
 
3109
-    // return if not a single post
3110
-    if(!is_single()){return;}
3109
+	// return if not a single post
3110
+	if(!is_single()){return;}
3111 3111
 
3112
-    global $post;
3113
-    if(isset($post->featured_image) && $post->featured_image){
3114
-        $upload_dir = wp_upload_dir();
3115
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3116
-        echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3112
+	global $post;
3113
+	if(isset($post->featured_image) && $post->featured_image){
3114
+		$upload_dir = wp_upload_dir();
3115
+		$thumb = $upload_dir['baseurl'].$post->featured_image;
3116
+		echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3117 3117
 
3118
-    }
3118
+	}
3119 3119
 }
3120 3120
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/custom_functions.php 1 patch
Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -2363,10 +2363,10 @@  discard block
 block discarded – undo
2363 2363
 	?>
2364 2364
 	<input class="search_text" name="s"
2365 2365
 	       value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) {
2366
-		       echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) );
2367
-	       } else {
2368
-		       echo $default_search_for_text;
2369
-	       } ?>" type="text"
2366
+			   echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) );
2367
+		   } else {
2368
+			   echo $default_search_for_text;
2369
+		   } ?>" type="text"
2370 2370
 	       onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}"
2371 2371
 	       onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}"
2372 2372
 	       onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);">
@@ -2493,11 +2493,11 @@  discard block
 block discarded – undo
2493 2493
  * @return True if WPML is active else False.
2494 2494
  */
2495 2495
 function geodir_is_wpml() {
2496
-    if (function_exists('icl_object_id')) {
2497
-        return true;
2498
-    }
2496
+	if (function_exists('icl_object_id')) {
2497
+		return true;
2498
+	}
2499 2499
 
2500
-    return false;
2500
+	return false;
2501 2501
 }
2502 2502
 
2503 2503
 /**
@@ -2512,9 +2512,9 @@  discard block
 block discarded – undo
2512 2512
  * @return Language code.
2513 2513
  */
2514 2514
 function geodir_get_language_for_element($element_id, $element_type) {
2515
-    global $sitepress;
2515
+	global $sitepress;
2516 2516
 
2517
-    return $sitepress->get_language_for_element($element_id, $element_type);
2517
+	return $sitepress->get_language_for_element($element_id, $element_type);
2518 2518
 }
2519 2519
 
2520 2520
 /**
@@ -2531,31 +2531,31 @@  discard block
 block discarded – undo
2531 2531
  *                         Added to fix duplicate translation for front end.
2532 2532
  */
2533 2533
 function geodir_icl_make_duplicate($master_post_id, $lang, $postarr, $tr_post_id, $after_save = false) {
2534
-    global $sitepress;
2534
+	global $sitepress;
2535 2535
     
2536
-    $post_type = get_post_type($master_post_id);
2537
-    $icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false;
2538
-    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) {
2539
-        $icl_ajx_action = true;
2540
-    }
2536
+	$post_type = get_post_type($master_post_id);
2537
+	$icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false;
2538
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) {
2539
+		$icl_ajx_action = true;
2540
+	}
2541 2541
     
2542
-    if (in_array($post_type, geodir_get_posttypes())) {
2543
-        if ($icl_ajx_action || $after_save) {
2544
-            // Duplicate post details
2545
-            geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang);
2542
+	if (in_array($post_type, geodir_get_posttypes())) {
2543
+		if ($icl_ajx_action || $after_save) {
2544
+			// Duplicate post details
2545
+			geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang);
2546 2546
             
2547
-            // Duplicate taxonomies
2548
-            geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang);
2547
+			// Duplicate taxonomies
2548
+			geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang);
2549 2549
             
2550
-            // Duplicate post images
2551
-            geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang);
2552
-        }
2550
+			// Duplicate post images
2551
+			geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang);
2552
+		}
2553 2553
         
2554
-        // Sync post reviews
2555
-        if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2556
-            geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang);
2557
-        }
2558
-    }
2554
+		// Sync post reviews
2555
+		if ($sitepress->get_setting('sync_comments_on_duplicates')) {
2556
+			geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang);
2557
+		}
2558
+	}
2559 2559
 }
2560 2560
 add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
2561 2561
 
@@ -2569,18 +2569,18 @@  discard block
 block discarded – undo
2569 2569
  * @param array $request_info The post details in an array.
2570 2570
  */
2571 2571
 function geodir_wpml_duplicate_listing($post_id, $request_info) {
2572
-    global $sitepress;
2572
+	global $sitepress;
2573 2573
     
2574
-    $icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false;
2575
-    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) {
2576
-        $icl_ajx_action = true;
2577
-    }
2574
+	$icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false;
2575
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) {
2576
+		$icl_ajx_action = true;
2577
+	}
2578 2578
     
2579
-    if (!$icl_ajx_action && in_array(get_post_type($post_id), geodir_get_posttypes()) && $post_duplicates = $sitepress->get_duplicates($post_id)) {
2580
-        foreach ($post_duplicates as $lang => $dup_post_id) {
2581
-            geodir_icl_make_duplicate($post_id, $lang, $request_info, $dup_post_id, true);
2582
-        }
2583
-    }
2579
+	if (!$icl_ajx_action && in_array(get_post_type($post_id), geodir_get_posttypes()) && $post_duplicates = $sitepress->get_duplicates($post_id)) {
2580
+		foreach ($post_duplicates as $lang => $dup_post_id) {
2581
+			geodir_icl_make_duplicate($post_id, $lang, $request_info, $dup_post_id, true);
2582
+		}
2583
+	}
2584 2584
 }
2585 2585
 
2586 2586
 /**
@@ -2596,17 +2596,17 @@  discard block
 block discarded – undo
2596 2596
  * @return bool True for success, False for fail.
2597 2597
  */
2598 2598
 function geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang) {
2599
-    global $wpdb;
2599
+	global $wpdb;
2600 2600
 
2601
-    $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
2601
+	$reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
2602 2602
 
2603
-    if (!empty($reviews)) {
2604
-        foreach ($reviews as $review) {
2605
-            geodir_wpml_duplicate_post_review($review['comment_id'], $master_post_id, $tr_post_id, $lang);
2606
-        }
2607
-    }
2603
+	if (!empty($reviews)) {
2604
+		foreach ($reviews as $review) {
2605
+			geodir_wpml_duplicate_post_review($review['comment_id'], $master_post_id, $tr_post_id, $lang);
2606
+		}
2607
+	}
2608 2608
 
2609
-    return false;
2609
+	return false;
2610 2610
 }
2611 2611
 
2612 2612
 /**
@@ -2623,22 +2623,22 @@  discard block
 block discarded – undo
2623 2623
  * @return bool True for success, False for fail.
2624 2624
  */
2625 2625
 function geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang) {
2626
-    global $wpdb, $plugin_prefix;
2626
+	global $wpdb, $plugin_prefix;
2627 2627
 
2628
-    $post_type = get_post_type($master_post_id);
2629
-    $post_table = $plugin_prefix . $post_type . '_detail';
2628
+	$post_type = get_post_type($master_post_id);
2629
+	$post_table = $plugin_prefix . $post_type . '_detail';
2630 2630
 
2631
-    $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
2632
-    $data = (array)$wpdb->get_row($query);
2631
+	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
2632
+	$data = (array)$wpdb->get_row($query);
2633 2633
 
2634
-    if ( !empty( $data ) ) {
2635
-        $data['post_id'] = $tr_post_id;
2636
-        unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']);
2637
-        $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
2638
-        return true;
2639
-    }
2634
+	if ( !empty( $data ) ) {
2635
+		$data['post_id'] = $tr_post_id;
2636
+		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']);
2637
+		$wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
2638
+		return true;
2639
+	}
2640 2640
 
2641
-    return false;
2641
+	return false;
2642 2642
 }
2643 2643
 
2644 2644
 /**
@@ -2655,40 +2655,40 @@  discard block
 block discarded – undo
2655 2655
  * @return bool True for success, False for fail.
2656 2656
  */
2657 2657
 function geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang) {
2658
-    global $sitepress, $wpdb;
2659
-    $post_type = get_post_type($master_post_id);
2658
+	global $sitepress, $wpdb;
2659
+	$post_type = get_post_type($master_post_id);
2660 2660
 
2661
-    remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
2661
+	remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
2662 2662
 
2663
-    $taxonomies = get_object_taxonomies($post_type);
2664
-    foreach ($taxonomies as $taxonomy) {
2665
-        $terms = get_the_terms($master_post_id, $taxonomy);
2666
-        $terms_array = array();
2663
+	$taxonomies = get_object_taxonomies($post_type);
2664
+	foreach ($taxonomies as $taxonomy) {
2665
+		$terms = get_the_terms($master_post_id, $taxonomy);
2666
+		$terms_array = array();
2667 2667
         
2668
-        if ($terms) {
2669
-            foreach ($terms as $term) {
2670
-                $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
2668
+		if ($terms) {
2669
+			foreach ($terms as $term) {
2670
+				$tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
2671 2671
                 
2672
-                if (!is_null($tr_id)){
2673
-                    // not using get_term - unfiltered get_term
2674
-                    $translated_term = $wpdb->get_row($wpdb->prepare("
2672
+				if (!is_null($tr_id)){
2673
+					// not using get_term - unfiltered get_term
2674
+					$translated_term = $wpdb->get_row($wpdb->prepare("
2675 2675
                         SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
2676 2676
 
2677
-                    $terms_array[] = $translated_term->term_id;
2678
-                }
2679
-            }
2677
+					$terms_array[] = $translated_term->term_id;
2678
+				}
2679
+			}
2680 2680
 
2681
-            if (!is_taxonomy_hierarchical($taxonomy)){
2682
-                $terms_array = array_unique( array_map( 'intval', $terms_array ) );
2683
-            }
2681
+			if (!is_taxonomy_hierarchical($taxonomy)){
2682
+				$terms_array = array_unique( array_map( 'intval', $terms_array ) );
2683
+			}
2684 2684
 
2685
-            wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
2685
+			wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
2686 2686
             
2687
-            if ($taxonomy == $post_type . 'category') {
2688
-                geodir_set_postcat_structure($tr_post_id, $post_type . 'category');
2689
-            }
2690
-        }
2691
-    }
2687
+			if ($taxonomy == $post_type . 'category') {
2688
+				geodir_set_postcat_structure($tr_post_id, $post_type . 'category');
2689
+			}
2690
+		}
2691
+	}
2692 2692
 }
2693 2693
 
2694 2694
 /**
@@ -2704,29 +2704,29 @@  discard block
 block discarded – undo
2704 2704
  * @return bool True for success, False for fail.
2705 2705
  */
2706 2706
 function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
2707
-    global $wpdb;
2707
+	global $wpdb;
2708 2708
 
2709
-    $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
2710
-    $wpdb->query($query);
2709
+	$query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
2710
+	$wpdb->query($query);
2711 2711
 
2712
-    $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
2713
-    $post_images = $wpdb->get_results($query);
2712
+	$query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
2713
+	$post_images = $wpdb->get_results($query);
2714 2714
 
2715
-    if ( !empty( $post_images ) ) {
2716
-        foreach ( $post_images as $post_image) {
2717
-            $image_data = (array)$post_image;
2718
-            unset($image_data['ID']);
2719
-            $image_data['post_id'] = $tr_post_id;
2715
+	if ( !empty( $post_images ) ) {
2716
+		foreach ( $post_images as $post_image) {
2717
+			$image_data = (array)$post_image;
2718
+			unset($image_data['ID']);
2719
+			$image_data['post_id'] = $tr_post_id;
2720 2720
             
2721
-            $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data);
2721
+			$wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data);
2722 2722
             
2723
-            geodir_set_wp_featured_image($tr_post_id);
2724
-        }
2723
+			geodir_set_wp_featured_image($tr_post_id);
2724
+		}
2725 2725
         
2726
-        return true;
2727
-    }
2726
+		return true;
2727
+	}
2728 2728
 
2729
-    return false;
2729
+	return false;
2730 2730
 }
2731 2731
 
2732 2732
 
@@ -2745,73 +2745,73 @@  discard block
 block discarded – undo
2745 2745
  * @return bool True for success, False for fail.
2746 2746
  */
2747 2747
 function geodir_wpml_duplicate_post_review($master_comment_id, $master_post_id, $tr_post_id, $lang) {
2748
-    global $wpdb, $plugin_prefix, $sitepress;
2749
-
2750
-    $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
2751
-
2752
-    if (empty($review)) {
2753
-        return false;
2754
-    }
2755
-    if ($review['post_id'] != $master_post_id) {
2756
-        $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
2757
-        geodir_update_postrating($master_post_id, $post_type);
2758
-    }
2759
-
2760
-    $tr_comment_id = geodir_wpml_duplicate_comment_exists($tr_post_id, $master_comment_id);
2761
-
2762
-    if (empty($tr_comment_id)) {
2763
-        return false;
2764
-    }
2765
-
2766
-    $post_type = get_post_type($master_post_id);
2767
-    $post_table = $plugin_prefix . $post_type . '_detail';
2768
-
2769
-    $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A);
2770
-    if (empty($translated_post)) {
2771
-        return false;
2772
-    }
2773
-
2774
-    $review['comment_id'] = $tr_comment_id;
2775
-    $review['post_id'] = $tr_post_id;
2776
-    $review['post_title'] = $translated_post['post_title'];
2777
-    $review['post_city'] = $translated_post['post_city'];
2778
-    $review['post_region'] = $translated_post['post_region'];
2779
-    $review['post_country'] = $translated_post['post_country'];
2780
-    $review['post_latitude'] = $translated_post['post_latitude'];
2781
-    $review['post_longitude'] = $translated_post['post_longitude'];
2782
-
2783
-    if (isset($review['id'])) {
2784
-        unset($review['id']);
2785
-    }
2786
-
2787
-    $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
2788
-
2789
-    if ($tr_review_id) { // update review
2790
-        $wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id));
2791
-    } else { // insert review
2792
-        $wpdb->insert(GEODIR_REVIEW_TABLE, $review);
2793
-        $tr_review_id = $wpdb->insert_id;
2794
-    }
2795
-
2796
-    if ($tr_post_id) {
2797
-        geodir_update_postrating($tr_post_id, $post_type);
2748
+	global $wpdb, $plugin_prefix, $sitepress;
2749
+
2750
+	$review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
2751
+
2752
+	if (empty($review)) {
2753
+		return false;
2754
+	}
2755
+	if ($review['post_id'] != $master_post_id) {
2756
+		$wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
2757
+		geodir_update_postrating($master_post_id, $post_type);
2758
+	}
2759
+
2760
+	$tr_comment_id = geodir_wpml_duplicate_comment_exists($tr_post_id, $master_comment_id);
2761
+
2762
+	if (empty($tr_comment_id)) {
2763
+		return false;
2764
+	}
2765
+
2766
+	$post_type = get_post_type($master_post_id);
2767
+	$post_table = $plugin_prefix . $post_type . '_detail';
2768
+
2769
+	$translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A);
2770
+	if (empty($translated_post)) {
2771
+		return false;
2772
+	}
2773
+
2774
+	$review['comment_id'] = $tr_comment_id;
2775
+	$review['post_id'] = $tr_post_id;
2776
+	$review['post_title'] = $translated_post['post_title'];
2777
+	$review['post_city'] = $translated_post['post_city'];
2778
+	$review['post_region'] = $translated_post['post_region'];
2779
+	$review['post_country'] = $translated_post['post_country'];
2780
+	$review['post_latitude'] = $translated_post['post_latitude'];
2781
+	$review['post_longitude'] = $translated_post['post_longitude'];
2782
+
2783
+	if (isset($review['id'])) {
2784
+		unset($review['id']);
2785
+	}
2786
+
2787
+	$tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
2788
+
2789
+	if ($tr_review_id) { // update review
2790
+		$wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id));
2791
+	} else { // insert review
2792
+		$wpdb->insert(GEODIR_REVIEW_TABLE, $review);
2793
+		$tr_review_id = $wpdb->insert_id;
2794
+	}
2795
+
2796
+	if ($tr_post_id) {
2797
+		geodir_update_postrating($tr_post_id, $post_type);
2798 2798
         
2799
-        if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) {
2800
-            $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id)));
2801
-            $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
2802
-
2803
-            if (!empty($likes)) {
2804
-                foreach ($likes as $like) {
2805
-                    unset($like['like_id']);
2806
-                    $like['comment_id'] = $tr_comment_id;
2799
+		if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) {
2800
+			$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id)));
2801
+			$likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
2802
+
2803
+			if (!empty($likes)) {
2804
+				foreach ($likes as $like) {
2805
+					unset($like['like_id']);
2806
+					$like['comment_id'] = $tr_comment_id;
2807 2807
                     
2808
-                    $wpdb->insert(GEODIR_COMMENTS_REVIEWS_TABLE, $like);
2809
-                }
2810
-            }
2811
-        }
2812
-    }
2808
+					$wpdb->insert(GEODIR_COMMENTS_REVIEWS_TABLE, $like);
2809
+				}
2810
+			}
2811
+		}
2812
+	}
2813 2813
 
2814
-    return $tr_review_id;
2814
+	return $tr_review_id;
2815 2815
 }
2816 2816
 
2817 2817
 /**
@@ -2826,36 +2826,36 @@  discard block
 block discarded – undo
2826 2826
  * @param int $comment_id The Comment ID.
2827 2827
  */
2828 2828
 function gepdir_wpml_sync_comment($comment_id) {
2829
-    global $wpdb, $sitepress, $gd_wpml_posttypes;
2830
-
2831
-    if (empty($gd_post_types)) {
2832
-        $gd_wpml_posttypes = geodir_get_posttypes();
2833
-    }
2834
-
2835
-    $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID=%d", $comment_id), ARRAY_A);
2836
-    if (empty($comment)) {
2837
-        return;
2838
-    }
2839
-
2840
-    $post_id = $comment['comment_post_ID'];
2841
-    $post_type = $post_id ? get_post_type($post_id) : NULL;
2842
-
2843
-    if (!($post_type && in_array($post_type, $gd_wpml_posttypes))) {
2844
-        return;
2845
-    }
2846
-
2847
-    $post_duplicates = $sitepress->get_duplicates($post_id);
2848
-    if (empty($post_duplicates)) {
2849
-        return;
2850
-    }
2851
-
2852
-    foreach ($post_duplicates as $lang => $dup_post_id) {
2853
-        if (empty($comment['comment_parent'])) {
2854
-            geodir_wpml_duplicate_post_review($comment_id, $post_id, $dup_post_id, $lang);
2855
-        }
2856
-    }
2829
+	global $wpdb, $sitepress, $gd_wpml_posttypes;
2830
+
2831
+	if (empty($gd_post_types)) {
2832
+		$gd_wpml_posttypes = geodir_get_posttypes();
2833
+	}
2834
+
2835
+	$comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID=%d", $comment_id), ARRAY_A);
2836
+	if (empty($comment)) {
2837
+		return;
2838
+	}
2839
+
2840
+	$post_id = $comment['comment_post_ID'];
2841
+	$post_type = $post_id ? get_post_type($post_id) : NULL;
2842
+
2843
+	if (!($post_type && in_array($post_type, $gd_wpml_posttypes))) {
2844
+		return;
2845
+	}
2846
+
2847
+	$post_duplicates = $sitepress->get_duplicates($post_id);
2848
+	if (empty($post_duplicates)) {
2849
+		return;
2850
+	}
2851
+
2852
+	foreach ($post_duplicates as $lang => $dup_post_id) {
2853
+		if (empty($comment['comment_parent'])) {
2854
+			geodir_wpml_duplicate_post_review($comment_id, $post_id, $dup_post_id, $lang);
2855
+		}
2856
+	}
2857 2857
     
2858
-    return true;
2858
+	return true;
2859 2859
 }
2860 2860
 
2861 2861
 /**
@@ -2870,11 +2870,11 @@  discard block
 block discarded – undo
2870 2870
  * @return int The duplicate comment ID.
2871 2871
  */
2872 2872
 function geodir_wpml_duplicate_comment_exists($dup_post_id, $original_cid) {
2873
-    global $wpdb;
2873
+	global $wpdb;
2874 2874
 
2875
-    $duplicate = $wpdb->get_var(
2876
-        $wpdb->prepare(
2877
-            "   SELECT comm.comment_ID
2875
+	$duplicate = $wpdb->get_var(
2876
+		$wpdb->prepare(
2877
+			"   SELECT comm.comment_ID
2878 2878
                 FROM {$wpdb->comments} comm
2879 2879
                 JOIN {$wpdb->commentmeta} cm
2880 2880
                     ON comm.comment_ID = cm.comment_id
@@ -2882,12 +2882,12 @@  discard block
 block discarded – undo
2882 2882
                     AND cm.meta_key = '_icl_duplicate_of'
2883 2883
                     AND cm.meta_value = %d
2884 2884
                 LIMIT 1",
2885
-            $dup_post_id,
2886
-            $original_cid
2887
-        )
2888
-    );
2885
+			$dup_post_id,
2886
+			$original_cid
2887
+		)
2888
+	);
2889 2889
 
2890
-    return $duplicate;
2890
+	return $duplicate;
2891 2891
 }
2892 2892
 
2893 2893
 /**
@@ -2959,7 +2959,7 @@  discard block
 block discarded – undo
2959 2959
  * @return bool True if Yoast SEO disabled on GD pages.
2960 2960
  */
2961 2961
 function geodir_disable_yoast_seo_metas() {
2962
-    return (bool)get_option( 'geodir_disable_yoast_meta' );
2962
+	return (bool)get_option( 'geodir_disable_yoast_meta' );
2963 2963
 }
2964 2964
 
2965 2965
 /**
@@ -2971,39 +2971,39 @@  discard block
 block discarded – undo
2971 2971
  * @return bool True if allowed.
2972 2972
  */
2973 2973
 function geodir_wpml_allowed_to_duplicate( $post_id ) {
2974
-    $allowed = false;
2974
+	$allowed = false;
2975 2975
     
2976
-    if ( !geodir_is_wpml() || empty( $post_id ) ) {
2977
-        return $allowed;
2978
-    }
2976
+	if ( !geodir_is_wpml() || empty( $post_id ) ) {
2977
+		return $allowed;
2978
+	}
2979 2979
     
2980
-    $user_id = (int)get_current_user_id();
2980
+	$user_id = (int)get_current_user_id();
2981 2981
     
2982
-    if ( empty( $user_id ) ) {
2983
-        return $allowed;
2984
-    }
2982
+	if ( empty( $user_id ) ) {
2983
+		return $allowed;
2984
+	}
2985 2985
     
2986
-    $post_type = get_post_type( $post_id );
2987
-    if ( !is_post_type_translated( $post_type ) || get_post_meta( $post_id, '_icl_lang_duplicate_of', true ) ) {
2988
-        return $allowed;
2989
-    }
2986
+	$post_type = get_post_type( $post_id );
2987
+	if ( !is_post_type_translated( $post_type ) || get_post_meta( $post_id, '_icl_lang_duplicate_of', true ) ) {
2988
+		return $allowed;
2989
+	}
2990 2990
     
2991
-    if ( geodir_listing_belong_to_current_user( $post_id ) ) {
2992
-        $allowed = true;
2993
-    }
2991
+	if ( geodir_listing_belong_to_current_user( $post_id ) ) {
2992
+		$allowed = true;
2993
+	}
2994 2994
     
2995
-    $disable_cpts = get_option( 'geodir_wpml_disable_duplicate' );
2996
-    if ( $allowed && !empty( $disable_cpts ) && in_array( $post_type, $disable_cpts ) ) {
2997
-        $allowed = false;
2998
-    }
2995
+	$disable_cpts = get_option( 'geodir_wpml_disable_duplicate' );
2996
+	if ( $allowed && !empty( $disable_cpts ) && in_array( $post_type, $disable_cpts ) ) {
2997
+		$allowed = false;
2998
+	}
2999 2999
     
3000
-    /**
3001
-     * Filter the user allowed to duplicate listing or not for WPML.
3002
-     *
3003
-     * @param bool $allowed True if allowed.
3004
-     * @param int $post_id The post ID.
3005
-     */
3006
-    return apply_filters( 'geodir_wpml_allowed_to_duplicate', $allowed, $post_id );
3000
+	/**
3001
+	 * Filter the user allowed to duplicate listing or not for WPML.
3002
+	 *
3003
+	 * @param bool $allowed True if allowed.
3004
+	 * @param int $post_id The post ID.
3005
+	 */
3006
+	return apply_filters( 'geodir_wpml_allowed_to_duplicate', $allowed, $post_id );
3007 3007
 }
3008 3008
 
3009 3009
 /**
@@ -3019,71 +3019,71 @@  discard block
 block discarded – undo
3019 3019
  * @return string Filtered html of the geodir_edit_post_link() function.
3020 3020
  */
3021 3021
 function geodir_wpml_frontend_duplicate_listing( $content_html ) {
3022
-    global $post, $preview, $sitepress;
3022
+	global $post, $preview, $sitepress;
3023 3023
     
3024
-    if ( !empty( $post->ID ) && !$preview && geodir_is_page( 'detail' ) && geodir_wpml_allowed_to_duplicate( $post->ID ) ) {
3025
-        $post_id = $post->ID;
3026
-        $element_type = 'post_' . get_post_type( $post_id );
3027
-        $original_post_id = $sitepress->get_original_element_id( $post_id, $element_type );
3024
+	if ( !empty( $post->ID ) && !$preview && geodir_is_page( 'detail' ) && geodir_wpml_allowed_to_duplicate( $post->ID ) ) {
3025
+		$post_id = $post->ID;
3026
+		$element_type = 'post_' . get_post_type( $post_id );
3027
+		$original_post_id = $sitepress->get_original_element_id( $post_id, $element_type );
3028 3028
         
3029
-        if ( $original_post_id == $post_id ) {
3030
-            $wpml_languages = $sitepress->get_active_languages();
3031
-            $post_language = $sitepress->get_language_for_element( $post_id, $element_type );
3029
+		if ( $original_post_id == $post_id ) {
3030
+			$wpml_languages = $sitepress->get_active_languages();
3031
+			$post_language = $sitepress->get_language_for_element( $post_id, $element_type );
3032 3032
             
3033
-            if ( !empty( $wpml_languages ) && isset( $wpml_languages[ $post_language ] ) ) {
3034
-                unset( $wpml_languages[ $post_language ] );
3035
-            }
3033
+			if ( !empty( $wpml_languages ) && isset( $wpml_languages[ $post_language ] ) ) {
3034
+				unset( $wpml_languages[ $post_language ] );
3035
+			}
3036 3036
             
3037
-            if ( !empty( $wpml_languages ) ) {
3038
-                $trid  = $sitepress->get_element_trid( $post_id, $element_type );
3039
-                $element_translations = $sitepress->get_element_translations( $trid, $element_type );
3040
-                $duplicates = $sitepress->get_duplicates( $post_id );
3037
+			if ( !empty( $wpml_languages ) ) {
3038
+				$trid  = $sitepress->get_element_trid( $post_id, $element_type );
3039
+				$element_translations = $sitepress->get_element_translations( $trid, $element_type );
3040
+				$duplicates = $sitepress->get_duplicates( $post_id );
3041 3041
                 
3042
-                $wpml_content = '<div class="geodir-company_info gd-detail-duplicate"><h3 class="widget-title">' . __( 'Translate Listing', 'geodirectory' ) . '</h3>';
3043
-                $wpml_content .= '<table class="gd-duplicate-table" style="width:100%;margin:0"><tbody>';
3044
-                $wpml_content .= '<tr style="border-bottom:solid 1px #efefef"><th style="padding:0 2px 2px 2px">' . __( 'Language', 'geodirectory' ) . '</th><th style="width:25px;"></th><th style="width:5em;text-align:center">' . __( 'Translate', 'geodirectory' ) . '</th></tr>';
3042
+				$wpml_content = '<div class="geodir-company_info gd-detail-duplicate"><h3 class="widget-title">' . __( 'Translate Listing', 'geodirectory' ) . '</h3>';
3043
+				$wpml_content .= '<table class="gd-duplicate-table" style="width:100%;margin:0"><tbody>';
3044
+				$wpml_content .= '<tr style="border-bottom:solid 1px #efefef"><th style="padding:0 2px 2px 2px">' . __( 'Language', 'geodirectory' ) . '</th><th style="width:25px;"></th><th style="width:5em;text-align:center">' . __( 'Translate', 'geodirectory' ) . '</th></tr>';
3045 3045
                 
3046
-                $needs_translation = false;
3046
+				$needs_translation = false;
3047 3047
                 
3048
-                foreach ( $wpml_languages as $lang_code => $lang ) {
3049
-                    $duplicates_text = '';
3050
-                    $translated = false;
3048
+				foreach ( $wpml_languages as $lang_code => $lang ) {
3049
+					$duplicates_text = '';
3050
+					$translated = false;
3051 3051
                     
3052
-                    if ( !empty( $element_translations ) && isset( $element_translations[$lang_code] ) ) {
3053
-                        $translated = true;
3052
+					if ( !empty( $element_translations ) && isset( $element_translations[$lang_code] ) ) {
3053
+						$translated = true;
3054 3054
                         
3055
-                        if ( !empty( $duplicates ) && isset( $duplicates[$lang_code] ) ) {
3056
-                            $duplicates_text = ' ' . __( '(duplicate)', 'geodirectory' );
3057
-                        }
3058
-                    } else {
3059
-                        $needs_translation = true;
3060
-                    }
3055
+						if ( !empty( $duplicates ) && isset( $duplicates[$lang_code] ) ) {
3056
+							$duplicates_text = ' ' . __( '(duplicate)', 'geodirectory' );
3057
+						}
3058
+					} else {
3059
+						$needs_translation = true;
3060
+					}
3061 3061
                     
3062
-                    $wpml_content .= '<tr><td style="padding:4px">' . $lang['english_name'] . $duplicates_text . '</td><td>&nbsp;</td><td style="text-align:center;">';
3062
+					$wpml_content .= '<tr><td style="padding:4px">' . $lang['english_name'] . $duplicates_text . '</td><td>&nbsp;</td><td style="text-align:center;">';
3063 3063
                     
3064
-                    if ( $translated ) {
3065
-                        $wpml_content .= '<i class="fa fa-check" style="color:orange"></i>';
3066
-                    } else {
3067
-                        $wpml_content .= '<input name="gd_icl_dup[]" value="' . $lang_code . '" title="' . esc_attr__( 'Create duplicate', 'geodirectory' ) . '" type="checkbox">';
3068
-                    }
3064
+					if ( $translated ) {
3065
+						$wpml_content .= '<i class="fa fa-check" style="color:orange"></i>';
3066
+					} else {
3067
+						$wpml_content .= '<input name="gd_icl_dup[]" value="' . $lang_code . '" title="' . esc_attr__( 'Create duplicate', 'geodirectory' ) . '" type="checkbox">';
3068
+					}
3069 3069
                     
3070
-                    $wpml_content .= '</td></tr>';
3071
-                }
3070
+					$wpml_content .= '</td></tr>';
3071
+				}
3072 3072
                 
3073
-                if ( $needs_translation ) {
3074
-                    $nonce = wp_create_nonce( 'geodir_duplicate_nonce' );
3075
-                    $wpml_content .= '<tr><td>&nbsp;</td><td style="vertical-align:middle;padding-top:13px"><i style="display:none" class="fa fa-spin fa-refresh"></i></td><td style="padding:15px 3px 3px 3px;text-align:right"><button data-nonce="' . esc_attr( $nonce ) . '" data-post-id="' . $post_id . '" id="gd_make_duplicates" class="button-secondary">' . __( 'Duplicate', 'geodirectory' ) . '</button></td></tr>';
3076
-                }
3073
+				if ( $needs_translation ) {
3074
+					$nonce = wp_create_nonce( 'geodir_duplicate_nonce' );
3075
+					$wpml_content .= '<tr><td>&nbsp;</td><td style="vertical-align:middle;padding-top:13px"><i style="display:none" class="fa fa-spin fa-refresh"></i></td><td style="padding:15px 3px 3px 3px;text-align:right"><button data-nonce="' . esc_attr( $nonce ) . '" data-post-id="' . $post_id . '" id="gd_make_duplicates" class="button-secondary">' . __( 'Duplicate', 'geodirectory' ) . '</button></td></tr>';
3076
+				}
3077 3077
                 
3078
-                $wpml_content .= '</tbody></table>';
3079
-                $wpml_content .= '</div>';
3078
+				$wpml_content .= '</tbody></table>';
3079
+				$wpml_content .= '</div>';
3080 3080
                 
3081
-                $content_html .= $wpml_content;
3082
-            }
3083
-        }
3084
-    }
3081
+				$content_html .= $wpml_content;
3082
+			}
3083
+		}
3084
+	}
3085 3085
     
3086
-    return $content_html;
3086
+	return $content_html;
3087 3087
 }
3088 3088
 
3089 3089
 /**
@@ -3095,26 +3095,26 @@  discard block
 block discarded – undo
3095 3095
  * @return array Filtered GD design settings array..
3096 3096
  */
3097 3097
 function geodir_wpml_duplicate_settings( $settings = array() ) {
3098
-    $new_settings = array();
3098
+	$new_settings = array();
3099 3099
     
3100
-    foreach ( $settings as $key => $setting ) {
3100
+	foreach ( $settings as $key => $setting ) {
3101 3101
         
3102
-        if ( isset( $setting['type'] ) && $setting['type'] == 'sectionend' && $setting['id'] == 'detail_page_settings' ) {
3103
-            $new_settings[] = array(
3104
-                'name' => __('Disable WPML duplicate translation', 'geodirectory'),
3105
-                'desc' => __('Select post types to disable front end WPML duplicate translation. For selected post types the WPML duplicate option will be disabled from listing detail page sidebar.', 'geodirectory'),
3106
-                'tip' => '',
3107
-                'id' => 'geodir_wpml_disable_duplicate',
3108
-                'css' => 'min-width:300px;',
3109
-                'std' => '',
3110
-                'type' => 'multiselect',
3111
-                'placeholder_text' => __('Select post types', 'geodirectory'),
3112
-                'class' => 'chosen_select',
3113
-                'options' => array_unique(geodir_post_type_setting_fun())
3114
-            );
3115
-        }
3116
-        $new_settings[] = $setting;
3117
-    }
3102
+		if ( isset( $setting['type'] ) && $setting['type'] == 'sectionend' && $setting['id'] == 'detail_page_settings' ) {
3103
+			$new_settings[] = array(
3104
+				'name' => __('Disable WPML duplicate translation', 'geodirectory'),
3105
+				'desc' => __('Select post types to disable front end WPML duplicate translation. For selected post types the WPML duplicate option will be disabled from listing detail page sidebar.', 'geodirectory'),
3106
+				'tip' => '',
3107
+				'id' => 'geodir_wpml_disable_duplicate',
3108
+				'css' => 'min-width:300px;',
3109
+				'std' => '',
3110
+				'type' => 'multiselect',
3111
+				'placeholder_text' => __('Select post types', 'geodirectory'),
3112
+				'class' => 'chosen_select',
3113
+				'options' => array_unique(geodir_post_type_setting_fun())
3114
+			);
3115
+		}
3116
+		$new_settings[] = $setting;
3117
+	}
3118 3118
     
3119
-    return $new_settings;
3119
+	return $new_settings;
3120 3120
 }
3121 3121
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 1 patch
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 = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2044
-                    if ($term_icon) {
2045
-                        $term_icon_url = $term_icon["src"];
2046
-                    } else {
2047
-                        $term_icon_url = $default_icon_url;
2048
-                    }
2049
-                    $terms_icons[$term->term_id] = $term_icon_url;
2050
-                }
2051
-            }
2052
-        }
2036
+			}
2037
+		}
2053 2038
 
2054
-        update_option('gd_term_icons', $terms_icons);
2055
-    }
2039
+		if($a_terms) {
2040
+			foreach ($a_terms as $pt => $t2) {
2056 2041
 
2057
-    if ($term_id && isset($terms_icons[$term_id])) {
2058
-        return $terms_icons[$term_id];
2059
-    } elseif ($term_id && !isset($terms_icons[$term_id])) {
2060
-        return get_option('geodir_default_marker_icon');
2061
-    }
2042
+				foreach ($t2 as $term) {
2043
+					$term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt);
2044
+					if ($term_icon) {
2045
+						$term_icon_url = $term_icon["src"];
2046
+					} else {
2047
+						$term_icon_url = $default_icon_url;
2048
+					}
2049
+					$terms_icons[$term->term_id] = $term_icon_url;
2050
+				}
2051
+			}
2052
+		}
2053
+
2054
+		update_option('gd_term_icons', $terms_icons);
2055
+	}
2062 2056
 
2063
-    if (is_ssl()) {
2064
-        $terms_icons = str_replace("http:","https:",$terms_icons );
2065
-    }
2057
+	if ($term_id && isset($terms_icons[$term_id])) {
2058
+		return $terms_icons[$term_id];
2059
+	} elseif ($term_id && !isset($terms_icons[$term_id])) {
2060
+		return get_option('geodir_default_marker_icon');
2061
+	}
2062
+
2063
+	if (is_ssl()) {
2064
+		$terms_icons = str_replace("http:","https:",$terms_icons );
2065
+	}
2066 2066
 
2067
-    return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2067
+	return apply_filters('geodir_get_term_icons', $terms_icons, $term_id);
2068 2068
 }
2069 2069
\ No newline at end of file
Please login to merge, or discard this patch.