Passed
Pull Request — master (#246)
by Kiran
14:54
created
geodirectory-admin/admin_functions.php 1 patch
Indentation   +2823 added lines, -2823 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 function geodir_deactivation()
16 16
 {
17 17
 
18
-    // Update installed variable
19
-    update_option("geodir_installed", 0);
18
+	// Update installed variable
19
+	update_option("geodir_installed", 0);
20 20
 
21
-    // Remove rewrite rules and then recreate rewrite rules.
22
-    flush_rewrite_rules();
21
+	// Remove rewrite rules and then recreate rewrite rules.
22
+	flush_rewrite_rules();
23 23
 }
24 24
 
25 25
 
@@ -32,124 +32,124 @@  discard block
 block discarded – undo
32 32
 function geodir_uninstall()
33 33
 {
34 34
 
35
-    delete_option('geodir_default_data_installed');
35
+	delete_option('geodir_default_data_installed');
36 36
 
37 37
 }
38 38
 
39 39
 if (!function_exists('geodir_admin_styles')) {
40
-    /**
41
-     * Enqueue Admin Styles.
42
-     *
43
-     * @since 1.0.0
44
-     * @package GeoDirectory
45
-     */
46
-    function geodir_admin_styles()
47
-    {
40
+	/**
41
+	 * Enqueue Admin Styles.
42
+	 *
43
+	 * @since 1.0.0
44
+	 * @package GeoDirectory
45
+	 */
46
+	function geodir_admin_styles()
47
+	{
48 48
 
49
-        wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
50
-        wp_enqueue_style('geodirectory-admin-css');
49
+		wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
50
+		wp_enqueue_style('geodirectory-admin-css');
51 51
 
52
-        wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
53
-        wp_enqueue_style('geodirectory-frontend-style');
52
+		wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
53
+		wp_enqueue_style('geodirectory-frontend-style');
54 54
 
55
-        wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
56
-        wp_enqueue_style('geodir-chosen-style');
55
+		wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
56
+		wp_enqueue_style('geodir-chosen-style');
57 57
 
58
-        wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
59
-        wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
58
+		wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
59
+		wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
60 60
 
61
-        wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
62
-        wp_enqueue_style('geodirectory-jquery-ui-css');
61
+		wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
62
+		wp_enqueue_style('geodirectory-jquery-ui-css');
63 63
 
64
-        wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
65
-        wp_enqueue_style('geodirectory-custom-fields-css');
64
+		wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
65
+		wp_enqueue_style('geodirectory-custom-fields-css');
66 66
 
67
-        wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
68
-        wp_enqueue_style('geodirectory-pluplodar-css');
67
+		wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
68
+		wp_enqueue_style('geodirectory-pluplodar-css');
69 69
 
70
-        wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
71
-        wp_enqueue_style('geodir-rating-style');
70
+		wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
71
+		wp_enqueue_style('geodir-rating-style');
72 72
 
73
-        wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
74
-        wp_enqueue_style('geodir-rtl-style');
73
+		wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
74
+		wp_enqueue_style('geodir-rtl-style');
75 75
 
76
-    }
76
+	}
77 77
 }
78 78
 
79 79
 if (!function_exists('geodir_admin_styles_req')) {
80
-    /**
81
-     * Loads stylesheets from CDN.
82
-     *
83
-     * @since 1.0.0
84
-     * @package GeoDirectory
85
-     */
86
-    function geodir_admin_styles_req()
87
-    {
80
+	/**
81
+	 * Loads stylesheets from CDN.
82
+	 *
83
+	 * @since 1.0.0
84
+	 * @package GeoDirectory
85
+	 */
86
+	function geodir_admin_styles_req()
87
+	{
88 88
 
89
-        wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
-        wp_enqueue_style('geodirectory-font-awesome');
89
+		wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
+		wp_enqueue_style('geodirectory-font-awesome');
91 91
 
92
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93
-        wp_enqueue_script('geodirectory-admin');
92
+		wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93
+		wp_enqueue_script('geodirectory-admin');
94 94
 
95
-    }
95
+	}
96 96
 }
97 97
 
98 98
 if (!function_exists('geodir_admin_scripts')) {
99
-    /**
100
-     * Enqueue Admin Scripts.
101
-     *
102
-     * @since 1.0.0
103
-     * @package GeoDirectory
104
-     */
105
-    function geodir_admin_scripts()
106
-    {
107
-        $geodir_map_name = geodir_map_name();
99
+	/**
100
+	 * Enqueue Admin Scripts.
101
+	 *
102
+	 * @since 1.0.0
103
+	 * @package GeoDirectory
104
+	 */
105
+	function geodir_admin_scripts()
106
+	{
107
+		$geodir_map_name = geodir_map_name();
108 108
         
109
-        wp_enqueue_script('jquery');
109
+		wp_enqueue_script('jquery');
110 110
 
111
-        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);
111
+		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);
112 112
 
113
-        wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
114
-        wp_enqueue_script('chosen');
113
+		wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
114
+		wp_enqueue_script('chosen');
115 115
 
116
-        wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
117
-        wp_enqueue_script('geodirectory-choose-ajax');
116
+		wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
117
+		wp_enqueue_script('geodirectory-choose-ajax');
118 118
 
119
-        if (isset($_REQUEST['listing_type'])) {
120
-            wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
121
-        }
119
+		if (isset($_REQUEST['listing_type'])) {
120
+			wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
121
+		}
122 122
 
123
-        wp_enqueue_script('geodirectory-custom-fields-script');
124
-        $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
123
+		wp_enqueue_script('geodirectory-custom-fields-script');
124
+		$plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions';
125 125
 
126
-        wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
126
+		wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
127 127
 
128
-        if (in_array($geodir_map_name, array('auto', 'google'))) {
129
-            $map_lang = "&language=" . geodir_get_map_default_language();
130
-            /** This filter is documented in geodirectory_template_tags.php */
131
-            $map_extra = apply_filters('geodir_googlemap_script_extra', '');
132
-            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
133
-        }
128
+		if (in_array($geodir_map_name, array('auto', 'google'))) {
129
+			$map_lang = "&language=" . geodir_get_map_default_language();
130
+			/** This filter is documented in geodirectory_template_tags.php */
131
+			$map_extra = apply_filters('geodir_googlemap_script_extra', '');
132
+			wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
133
+		}
134 134
         
135
-        if ($geodir_map_name == 'osm') {
136
-            // Leaflet OpenStreetMap
137
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
138
-            wp_enqueue_style('geodirectory-leaflet-style');
135
+		if ($geodir_map_name == 'osm') {
136
+			// Leaflet OpenStreetMap
137
+			wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
138
+			wp_enqueue_style('geodirectory-leaflet-style');
139 139
                 
140
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
141
-            wp_enqueue_script('geodirectory-leaflet-script');
140
+			wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
141
+			wp_enqueue_script('geodirectory-leaflet-script');
142 142
             
143
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
144
-            wp_enqueue_script('geodirectory-leaflet-geo-script');
145
-        }
146
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
143
+			wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
144
+			wp_enqueue_script('geodirectory-leaflet-geo-script');
145
+		}
146
+		wp_enqueue_script( 'jquery-ui-autocomplete' );
147 147
         
148
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
149
-        wp_enqueue_script('geodirectory-goMap-script');
148
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
149
+		wp_enqueue_script('geodirectory-goMap-script');
150 150
 
151
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
152
-        wp_enqueue_script('geodirectory-goMap-script');
151
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
152
+		wp_enqueue_script('geodirectory-goMap-script');
153 153
 
154 154
 		// font awesome rating script
155 155
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
@@ -160,167 +160,167 @@  discard block
 block discarded – undo
160 160
 			wp_enqueue_script('geodir-jRating-js');
161 161
 		}
162 162
 
163
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
164
-        wp_enqueue_script('geodir-on-document-load');
165
-
166
-
167
-        // SCRIPT FOR UPLOAD
168
-        wp_enqueue_script('plupload-all');
169
-        wp_enqueue_script('jquery-ui-sortable');
170
-
171
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
172
-        wp_enqueue_script('geodirectory-plupload-script');
173
-
174
-        // SCRIPT FOR UPLOAD END
175
-
176
-
177
-        // place js config array for plupload
178
-        $plupload_init = array(
179
-            'runtimes' => 'html5,silverlight,flash,html4',
180
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
181
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
182
-            'drop_element' => 'dropbox', // will be adjusted per uploader
183
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
184
-            'multiple_queues' => true,
185
-            'max_file_size' => geodir_max_upload_size(),
186
-            'url' => admin_url('admin-ajax.php'),
187
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
188
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
189
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
190
-            'multipart' => true,
191
-            'urlstream_upload' => true,
192
-            'multi_selection' => false, // will be added per uploader
193
-            // additional post data to send to our ajax hook
194
-            'multipart_params' => array(
195
-                '_ajax_nonce' => "", // will be added per uploader
196
-                'action' => 'plupload_action', // the ajax action name
197
-                'imgid' => 0 // will be added per uploader
198
-            )
199
-        );
200
-        $base_plupload_config = json_encode($plupload_init);
201
-
202
-
203
-        $thumb_img_arr = array();
204
-
205
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
206
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
207
-
208
-        $totImg = '';
209
-        $image_limit = '';
210
-        if (!empty($thumb_img_arr)) {
211
-            $totImg = count($thumb_img_arr);
212
-        }
163
+		wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
164
+		wp_enqueue_script('geodir-on-document-load');
165
+
166
+
167
+		// SCRIPT FOR UPLOAD
168
+		wp_enqueue_script('plupload-all');
169
+		wp_enqueue_script('jquery-ui-sortable');
170
+
171
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
172
+		wp_enqueue_script('geodirectory-plupload-script');
173
+
174
+		// SCRIPT FOR UPLOAD END
175
+
176
+
177
+		// place js config array for plupload
178
+		$plupload_init = array(
179
+			'runtimes' => 'html5,silverlight,flash,html4',
180
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
181
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
182
+			'drop_element' => 'dropbox', // will be adjusted per uploader
183
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
184
+			'multiple_queues' => true,
185
+			'max_file_size' => geodir_max_upload_size(),
186
+			'url' => admin_url('admin-ajax.php'),
187
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
188
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
189
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
190
+			'multipart' => true,
191
+			'urlstream_upload' => true,
192
+			'multi_selection' => false, // will be added per uploader
193
+			// additional post data to send to our ajax hook
194
+			'multipart_params' => array(
195
+				'_ajax_nonce' => "", // will be added per uploader
196
+				'action' => 'plupload_action', // the ajax action name
197
+				'imgid' => 0 // will be added per uploader
198
+			)
199
+		);
200
+		$base_plupload_config = json_encode($plupload_init);
201
+
202
+
203
+		$thumb_img_arr = array();
204
+
205
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
206
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
207
+
208
+		$totImg = '';
209
+		$image_limit = '';
210
+		if (!empty($thumb_img_arr)) {
211
+			$totImg = count($thumb_img_arr);
212
+		}
213 213
 
214
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
215
-            'totalImg' => $totImg,
216
-            'image_limit' => $image_limit,
217
-            'upload_img_size' => geodir_max_upload_size());
214
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
215
+			'totalImg' => $totImg,
216
+			'image_limit' => $image_limit,
217
+			'upload_img_size' => geodir_max_upload_size());
218 218
 
219
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
219
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
220 220
 
221
-        $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
222
-        wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
221
+		$ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
222
+		wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
223 223
 
224 224
 
225
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
226
-        wp_enqueue_script('geodirectory-admin-script');
225
+		wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
226
+		wp_enqueue_script('geodirectory-admin-script');
227 227
 
228
-        wp_enqueue_style('farbtastic');
229
-        wp_enqueue_script('farbtastic');
228
+		wp_enqueue_style('farbtastic');
229
+		wp_enqueue_script('farbtastic');
230 230
 
231
-        $screen = get_current_screen();
232
-        if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
233
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
234
-        }
231
+		$screen = get_current_screen();
232
+		if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
233
+			wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
234
+		}
235 235
 
236
-        $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
237
-        wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
236
+		$ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
237
+		wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
238 238
 
239
-    }
239
+	}
240 240
 }
241 241
 
242 242
 if (!function_exists('geodir_admin_menu')) {
243
-    /**
244
-     * Admin Menus
245
-     *
246
-     * Sets up the admin menus in wordpress.
247
-     *
248
-     * @since 1.0.0
249
-     * @package GeoDirectory
250
-     * @global array $menu Menu array.
251
-     * @global object $geodirectory GeoDirectory plugin object.
252
-     */
253
-    function geodir_admin_menu()
254
-    {
255
-        global $menu, $geodirectory;
243
+	/**
244
+	 * Admin Menus
245
+	 *
246
+	 * Sets up the admin menus in wordpress.
247
+	 *
248
+	 * @since 1.0.0
249
+	 * @package GeoDirectory
250
+	 * @global array $menu Menu array.
251
+	 * @global object $geodirectory GeoDirectory plugin object.
252
+	 */
253
+	function geodir_admin_menu()
254
+	{
255
+		global $menu, $geodirectory;
256 256
 
257
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
257
+		if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
258 258
 
259
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
259
+		add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
260 260
 
261 261
 
262
-    }
262
+	}
263 263
 }
264 264
 
265 265
 if (!function_exists('geodir_admin_menu_order')) {
266
-    /**
267
-     * Order admin menus.
268
-     *
269
-     * @since 1.0.0
270
-     * @package GeoDirectory
271
-     * @param array $menu_order Menu order array.
272
-     * @return array Modified menu order array.
273
-     */
274
-    function geodir_admin_menu_order($menu_order)
275
-    {
276
-
277
-        // Initialize our custom order array
278
-        $geodir_menu_order = array();
279
-
280
-        // Get the index of our custom separator
281
-        $geodir_separator = array_search('separator-geodirectory', $menu_order);
282
-
283
-        // Get index of posttype menu
284
-        $post_types = geodir_get_posttypes();
285
-
286
-        // Loop through menu order and do some rearranging
287
-        foreach ($menu_order as $index => $item) :
288
-
289
-            if ((('geodirectory') == $item)) :
290
-                $geodir_menu_order[] = 'separator-geodirectory';
291
-                if (!empty($post_types)) {
292
-                    foreach ($post_types as $post_type) {
293
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
294
-                    }
295
-                }
296
-                $geodir_menu_order[] = $item;
266
+	/**
267
+	 * Order admin menus.
268
+	 *
269
+	 * @since 1.0.0
270
+	 * @package GeoDirectory
271
+	 * @param array $menu_order Menu order array.
272
+	 * @return array Modified menu order array.
273
+	 */
274
+	function geodir_admin_menu_order($menu_order)
275
+	{
297 276
 
298
-                unset($menu_order[$geodir_separator]);
299
-            //unset( $menu_order[$geodir_places] );
300
-            elseif (!in_array($item, array('separator-geodirectory'))) :
301
-                $geodir_menu_order[] = $item;
302
-            endif;
277
+		// Initialize our custom order array
278
+		$geodir_menu_order = array();
303 279
 
304
-        endforeach;
280
+		// Get the index of our custom separator
281
+		$geodir_separator = array_search('separator-geodirectory', $menu_order);
305 282
 
306
-        // Return order
307
-        return $geodir_menu_order;
308
-    }
283
+		// Get index of posttype menu
284
+		$post_types = geodir_get_posttypes();
285
+
286
+		// Loop through menu order and do some rearranging
287
+		foreach ($menu_order as $index => $item) :
288
+
289
+			if ((('geodirectory') == $item)) :
290
+				$geodir_menu_order[] = 'separator-geodirectory';
291
+				if (!empty($post_types)) {
292
+					foreach ($post_types as $post_type) {
293
+						$geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
294
+					}
295
+				}
296
+				$geodir_menu_order[] = $item;
297
+
298
+				unset($menu_order[$geodir_separator]);
299
+			//unset( $menu_order[$geodir_places] );
300
+			elseif (!in_array($item, array('separator-geodirectory'))) :
301
+				$geodir_menu_order[] = $item;
302
+			endif;
303
+
304
+		endforeach;
305
+
306
+		// Return order
307
+		return $geodir_menu_order;
308
+	}
309 309
 }
310 310
 
311 311
 if (!function_exists('geodir_admin_custom_menu_order')) {
312
-    /**
313
-     * Enables custom menu order.
314
-     *
315
-     * @since 1.0.0
316
-     * @package GeoDirectory
317
-     * @return bool
318
-     */
319
-    function geodir_admin_custom_menu_order()
320
-    {
321
-        if (!current_user_can('manage_options')) return false;
322
-        return true;
323
-    }
312
+	/**
313
+	 * Enables custom menu order.
314
+	 *
315
+	 * @since 1.0.0
316
+	 * @package GeoDirectory
317
+	 * @return bool
318
+	 */
319
+	function geodir_admin_custom_menu_order()
320
+	{
321
+		if (!current_user_can('manage_options')) return false;
322
+		return true;
323
+	}
324 324
 }
325 325
 
326 326
 /**
@@ -331,41 +331,41 @@  discard block
 block discarded – undo
331 331
  */
332 332
 function geodir_before_admin_panel()
333 333
 {
334
-    if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
335
-        echo '<div id="message" class="updated fade">
334
+	if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
335
+		echo '<div id="message" class="updated fade">
336 336
                         <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>
337 337
                         <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
338 338
                 </div>';
339 339
 
340
-    }
340
+	}
341 341
 
342
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
343
-        switch ($_REQUEST['msg']) {
344
-            case 'success':
345
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
346
-                flush_rewrite_rules(false);
342
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
343
+		switch ($_REQUEST['msg']) {
344
+			case 'success':
345
+				echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
346
+				flush_rewrite_rules(false);
347 347
 
348
-                break;
348
+				break;
349 349
 			case 'fail':
350 350
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
351 351
 				
352 352
 				if ($gderr == 21)
353
-			    	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>';
353
+					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>';
354 354
 				else
355 355
 					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
356
-                break;
357
-        }
358
-    }
356
+				break;
357
+		}
358
+	}
359 359
 
360
-    if (!geodir_is_default_location_set()) {
361
-        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>';
360
+	if (!geodir_is_default_location_set()) {
361
+		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>';
362 362
 
363
-    }
363
+	}
364 364
 
365
-    if (!function_exists('curl_init')) {
366
-        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>';
365
+	if (!function_exists('curl_init')) {
366
+		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>';
367 367
 
368
-    }
368
+	}
369 369
 }
370 370
 
371 371
 /**
@@ -378,19 +378,19 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function geodir_handle_option_form_submit($current_tab)
380 380
 {
381
-    global $geodir_settings;
382
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
383
-        /**
384
-         * Contains settings array for current tab.
385
-         *
386
-         * @since 1.0.0
387
-         * @package GeoDirectory
388
-         */
389
-        include_once('option-pages/' . $current_tab . '_array.php');
390
-    }
391
-    if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
392
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
393
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
381
+	global $geodir_settings;
382
+	if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
383
+		/**
384
+		 * Contains settings array for current tab.
385
+		 *
386
+		 * @since 1.0.0
387
+		 * @package GeoDirectory
388
+		 */
389
+		include_once('option-pages/' . $current_tab . '_array.php');
390
+	}
391
+	if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
392
+		if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
393
+		if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
394 394
 		
395 395
 		/**
396 396
 		 * Fires before updating geodirectory admin settings.
@@ -402,98 +402,98 @@  discard block
 block discarded – undo
402 402
 		 */
403 403
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
404 404
 		
405
-        if (!empty($geodir_settings[$current_tab]))
406
-            geodir_update_options($geodir_settings[$current_tab]);
405
+		if (!empty($geodir_settings[$current_tab]))
406
+			geodir_update_options($geodir_settings[$current_tab]);
407 407
 
408
-        /**
409
-         * Called after GeoDirectory options settings are updated.
410
-         *
411
-         * @since 1.0.0
412
-         * @param array $geodir_settings The array of GeoDirectory settings.
413
-         * @see 'geodir_before_update_options'
414
-         */
415
-        do_action('geodir_update_options', $geodir_settings);
408
+		/**
409
+		 * Called after GeoDirectory options settings are updated.
410
+		 *
411
+		 * @since 1.0.0
412
+		 * @param array $geodir_settings The array of GeoDirectory settings.
413
+		 * @see 'geodir_before_update_options'
414
+		 */
415
+		do_action('geodir_update_options', $geodir_settings);
416 416
 
417
-        /**
418
-         * Called after GeoDirectory options settings are updated.
419
-         *
420
-         * Provides tab specific settings.
421
-         *
422
-         * @since 1.0.0
423
-         * @param string $current_tab The current settings tab name.
424
-         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
425
-         */
426
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
417
+		/**
418
+		 * Called after GeoDirectory options settings are updated.
419
+		 *
420
+		 * Provides tab specific settings.
421
+		 *
422
+		 * @since 1.0.0
423
+		 * @param string $current_tab The current settings tab name.
424
+		 * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
425
+		 */
426
+		do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
427 427
 
428
-        flush_rewrite_rules(false);
428
+		flush_rewrite_rules(false);
429 429
 
430
-        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
430
+		$current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
431 431
 
432
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
432
+		$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
433 433
 
434
-        wp_redirect($redirect_url);
435
-        exit();
436
-    endif;
434
+		wp_redirect($redirect_url);
435
+		exit();
436
+	endif;
437 437
 
438 438
 
439 439
 }
440 440
 
441 441
 
442 442
 if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
443
-    /**
444
-     * GeoDirectory dummy data installation.
445
-     *
446
-     * @since 1.0.0
447
-     * @package GeoDirectory
448
-     * @global object $wpdb WordPress Database object.
449
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
450
-     * @param string $post_type The post type.
451
-     */
452
-    function geodir_autoinstall_admin_header($post_type = 'gd_place')
453
-    {
443
+	/**
444
+	 * GeoDirectory dummy data installation.
445
+	 *
446
+	 * @since 1.0.0
447
+	 * @package GeoDirectory
448
+	 * @global object $wpdb WordPress Database object.
449
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
450
+	 * @param string $post_type The post type.
451
+	 */
452
+	function geodir_autoinstall_admin_header($post_type = 'gd_place')
453
+	{
454 454
 
455
-        global $wpdb, $plugin_prefix;
455
+		global $wpdb, $plugin_prefix;
456 456
 
457
-        if (!geodir_is_default_location_set()) {
458
-            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>';
459
-        } else {
457
+		if (!geodir_is_default_location_set()) {
458
+			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>';
459
+		} else {
460 460
 
461
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
461
+			$geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
462 462
 
463
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
463
+			$post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
464 464
 
465
-            if ($post_counts > 0) {
466
-                $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
465
+			if ($post_counts > 0) {
466
+				$nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
467 467
 
468
-                $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '"  >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>';
469
-                $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>';
470
-            } else {
471
-                $options_list = '';
472
-                for ($option = 1; $option <= 30; $option++) {
473
-                    $selected = '';
474
-                    if ($option == 10)
475
-                        $selected = 'selected="selected"';
468
+				$dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '"  >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>';
469
+				$dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>';
470
+			} else {
471
+				$options_list = '';
472
+				for ($option = 1; $option <= 30; $option++) {
473
+					$selected = '';
474
+					if ($option == 10)
475
+						$selected = 'selected="selected"';
476 476
 
477
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
478
-                }
477
+					$options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
478
+				}
479 479
 
480
-                $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
480
+				$nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
481 481
 
482
-                $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')"   redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>';
483
-                $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>';
482
+				$dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')"   redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>';
483
+				$dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>';
484 484
 
485
-            }
486
-            echo $dummy_msg;
487
-            ?>
485
+			}
486
+			echo $dummy_msg;
487
+			?>
488 488
             <script>
489 489
                 <?php
490
-                  $default_location = geodir_get_default_location();
491
-                  $city =  isset($default_location->city) ? $default_location->city : '';
492
-                  $region =isset($default_location->region) ? $default_location->region : '';
493
-                  $country =isset($default_location->country) ? $default_location->country : '';
494
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
495
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
496
-                ?>
490
+				  $default_location = geodir_get_default_location();
491
+				  $city =  isset($default_location->city) ? $default_location->city : '';
492
+				  $region =isset($default_location->region) ? $default_location->region : '';
493
+				  $country =isset($default_location->country) ? $default_location->country : '';
494
+				  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
495
+				  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
496
+				?>
497 497
                 var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
498 498
                 var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
499 499
                 var bound_lat_lng;
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
                 }
585 585
             </script>
586 586
         <?php
587
-        }
588
-    }
587
+		}
588
+	}
589 589
 }
590 590
 
591 591
 /**
@@ -598,19 +598,19 @@  discard block
 block discarded – undo
598 598
  */
599 599
 function geodir_insert_dummy_posts()
600 600
 {
601
-    geodir_default_taxonomies();
601
+	geodir_default_taxonomies();
602 602
 
603
-    ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
603
+	ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
604 604
 
605
-    global $wpdb, $current_user;
605
+	global $wpdb, $current_user;
606 606
 
607
-    /**
608
-     * Contains dummy post content.
609
-     *
610
-     * @since 1.0.0
611
-     * @package GeoDirectory
612
-     */
613
-    include_once('place_dummy_post.php');
607
+	/**
608
+	 * Contains dummy post content.
609
+	 *
610
+	 * @since 1.0.0
611
+	 * @package GeoDirectory
612
+	 */
613
+	include_once('place_dummy_post.php');
614 614
 
615 615
 }
616 616
 
@@ -624,18 +624,18 @@  discard block
 block discarded – undo
624 624
  */
625 625
 function geodir_delete_dummy_posts()
626 626
 {
627
-    global $wpdb, $plugin_prefix;
627
+	global $wpdb, $plugin_prefix;
628 628
 
629 629
 
630
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
630
+	$post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
631 631
 
632 632
 
633
-    foreach ($post_ids as $post_ids_obj) {
634
-        wp_delete_post($post_ids_obj->post_id);
635
-    }
633
+	foreach ($post_ids as $post_ids_obj) {
634
+		wp_delete_post($post_ids_obj->post_id);
635
+	}
636 636
 
637
-    //double check posts are deleted
638
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
637
+	//double check posts are deleted
638
+	$wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
639 639
 }
640 640
 
641 641
 /**
@@ -649,114 +649,114 @@  discard block
 block discarded – undo
649 649
  * @global string $dummy_image_path The dummy image path.
650 650
  */
651 651
 function geodir_default_taxonomies() {
652
-    global $wpdb, $dummy_image_path;
652
+	global $wpdb, $dummy_image_path;
653 653
 
654
-    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
654
+	$category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
655 655
 
656
-    $last_catid = '';
656
+	$last_catid = '';
657 657
 
658
-    $uploads = wp_upload_dir(); // Array of key => value pairs
658
+	$uploads = wp_upload_dir(); // Array of key => value pairs
659 659
 
660
-    for ($i = 0; $i < count($category_array); $i++) {
661
-        $parent_catid = 0;
662
-        if (is_array($category_array[$i])) {
663
-            $cat_name_arr = $category_array[$i];
664
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
665
-                $catname = $cat_name_arr[$j];
660
+	for ($i = 0; $i < count($category_array); $i++) {
661
+		$parent_catid = 0;
662
+		if (is_array($category_array[$i])) {
663
+			$cat_name_arr = $category_array[$i];
664
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
665
+				$catname = $cat_name_arr[$j];
666 666
 
667
-                if (!term_exists($catname, 'gd_placecategory')) {
668
-                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
667
+				if (!term_exists($catname, 'gd_placecategory')) {
668
+					$last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
669 669
 
670
-                    if ($j == 0) {
671
-                        $parent_catid = $last_catid;
672
-                    }
670
+					if ($j == 0) {
671
+						$parent_catid = $last_catid;
672
+					}
673 673
 
674 674
 
675
-                    if (geodir_dummy_folder_exists())
676
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
677
-                    else
678
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
675
+					if (geodir_dummy_folder_exists())
676
+						$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
677
+					else
678
+						$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
679 679
 
680
-                    $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
680
+					$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
681 681
 
682
-                    $catname = str_replace(' ', '_', $catname);
683
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
682
+					$catname = str_replace(' ', '_', $catname);
683
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
684 684
 
685
-                    if (empty($uploaded['error'])) {
686
-                        $new_path = $uploaded['file'];
687
-                        $new_url = $uploaded['url'];
688
-                    }
685
+					if (empty($uploaded['error'])) {
686
+						$new_path = $uploaded['file'];
687
+						$new_url = $uploaded['url'];
688
+					}
689 689
 
690
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
691
-
692
-                    $attachment = array(
693
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
694
-                        'post_mime_type' => $wp_filetype['type'],
695
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
696
-                        'post_content' => '',
697
-                        'post_status' => 'inherit'
698
-                    );
699
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
700
-
701
-                    // you must first include the image.php file
702
-                    // for the function wp_generate_attachment_metadata() to work
703
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
704
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
705
-                    wp_update_attachment_metadata($attach_id, $attach_data);
706
-
707
-                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
708
-                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
709
-                    }
710
-                }
711
-            }
690
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
691
+
692
+					$attachment = array(
693
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
694
+						'post_mime_type' => $wp_filetype['type'],
695
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
696
+						'post_content' => '',
697
+						'post_status' => 'inherit'
698
+					);
699
+					$attach_id = wp_insert_attachment($attachment, $new_path);
700
+
701
+					// you must first include the image.php file
702
+					// for the function wp_generate_attachment_metadata() to work
703
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
704
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
705
+					wp_update_attachment_metadata($attach_id, $attach_data);
706
+
707
+					if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
708
+						update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
709
+					}
710
+				}
711
+			}
712 712
 
713
-        } else {
714
-            $catname = $category_array[$i];
713
+		} else {
714
+			$catname = $category_array[$i];
715 715
 
716
-            if (!term_exists($catname, 'gd_placecategory')) {
717
-                $last_catid = wp_insert_term($catname, 'gd_placecategory');
716
+			if (!term_exists($catname, 'gd_placecategory')) {
717
+				$last_catid = wp_insert_term($catname, 'gd_placecategory');
718 718
 
719
-                if (geodir_dummy_folder_exists())
720
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
721
-                else
722
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
719
+				if (geodir_dummy_folder_exists())
720
+					$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
721
+				else
722
+					$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
723 723
 
724
-                $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
724
+				$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
725 725
 
726
-                $catname = str_replace(' ', '_', $catname);
727
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
726
+				$catname = str_replace(' ', '_', $catname);
727
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
728 728
 
729
-                if (empty($uploaded['error'])) {
730
-                    $new_path = $uploaded['file'];
731
-                    $new_url = $uploaded['url'];
732
-                }
729
+				if (empty($uploaded['error'])) {
730
+					$new_path = $uploaded['file'];
731
+					$new_url = $uploaded['url'];
732
+				}
733 733
 
734
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
734
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
735 735
 
736
-                $attachment = array(
737
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
738
-                    'post_mime_type' => $wp_filetype['type'],
739
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
740
-                    'post_content' => '',
741
-                    'post_status' => 'inherit'
742
-                );
736
+				$attachment = array(
737
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
738
+					'post_mime_type' => $wp_filetype['type'],
739
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
740
+					'post_content' => '',
741
+					'post_status' => 'inherit'
742
+				);
743 743
 
744
-                $attach_id = wp_insert_attachment($attachment, $new_path);
744
+				$attach_id = wp_insert_attachment($attachment, $new_path);
745 745
 
746 746
 
747
-                // you must first include the image.php file
748
-                // for the function wp_generate_attachment_metadata() to work
749
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
750
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
751
-                wp_update_attachment_metadata($attach_id, $attach_data);
747
+				// you must first include the image.php file
748
+				// for the function wp_generate_attachment_metadata() to work
749
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
750
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
751
+				wp_update_attachment_metadata($attach_id, $attach_data);
752 752
 
753
-                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
754
-                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
755
-                }
756
-            }
757
-        }
753
+				if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
754
+					update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
755
+				}
756
+			}
757
+		}
758 758
 
759
-    }
759
+	}
760 760
 }
761 761
 
762 762
 /**
@@ -771,144 +771,144 @@  discard block
 block discarded – undo
771 771
  * @return bool Returns true if saved.
772 772
  */
773 773
 function geodir_update_options($options, $dummy = false) {
774
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
774
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
775 775
 
776
-    foreach ($options as $value) {
777
-        if ($dummy && isset($value['std']))
778
-            $_POST[$value['id']] = $value['std'];
776
+	foreach ($options as $value) {
777
+		if ($dummy && isset($value['std']))
778
+			$_POST[$value['id']] = $value['std'];
779 779
 
780 780
 
781
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
781
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
782 782
 
783
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
784
-                update_option($value['id'], $_POST[$value['id']]);
785
-            } else {
786
-                update_option($value['id'], 0);
787
-            }
783
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
784
+				update_option($value['id'], $_POST[$value['id']]);
785
+			} else {
786
+				update_option($value['id'], 0);
787
+			}
788 788
 
789
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
789
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
790 790
 
791
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
792
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
793
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
794
-                if (isset($_POST[$value['id'] . '_crop'])) :
795
-                    update_option($value['id'] . '_crop', 1);
796
-                else :
797
-                    update_option($value['id'] . '_crop', 0);
798
-                endif;
799
-            } else {
800
-                update_option($value['id'] . '_width', $value['std']);
801
-                update_option($value['id'] . '_height', $value['std']);
802
-                update_option($value['id'] . '_crop', 1);
803
-            }
791
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
792
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
793
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
794
+				if (isset($_POST[$value['id'] . '_crop'])) :
795
+					update_option($value['id'] . '_crop', 1);
796
+				else :
797
+					update_option($value['id'] . '_crop', 0);
798
+				endif;
799
+			} else {
800
+				update_option($value['id'] . '_width', $value['std']);
801
+				update_option($value['id'] . '_height', $value['std']);
802
+				update_option($value['id'] . '_crop', 1);
803
+			}
804 804
 
805
-        elseif (isset($value['type']) && $value['type'] == 'map') :
806
-            $post_types = array();
807
-            $categories = array();
805
+		elseif (isset($value['type']) && $value['type'] == 'map') :
806
+			$post_types = array();
807
+			$categories = array();
808 808
 
809
-            if (!empty($_POST['home_map_post_types'])) :
810
-                foreach ($_POST['home_map_post_types'] as $post_type) :
811
-                    $post_types[] = $post_type;
812
-                endforeach;
813
-            endif;
809
+			if (!empty($_POST['home_map_post_types'])) :
810
+				foreach ($_POST['home_map_post_types'] as $post_type) :
811
+					$post_types[] = $post_type;
812
+				endforeach;
813
+			endif;
814 814
 
815
-            update_option('geodir_exclude_post_type_on_map', $post_types);
815
+			update_option('geodir_exclude_post_type_on_map', $post_types);
816 816
 
817
-            if (!empty($_POST['post_category'])) :
818
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
819
-                    $categories[$texonomy] = array();
820
-                    foreach ($cat_arr as $category) :
821
-                        $categories[$texonomy][] = $category;
822
-                    endforeach;
823
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
824
-                endforeach;
825
-            endif;
826
-            update_option('geodir_exclude_cat_on_map', $categories);
827
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
828
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
817
+			if (!empty($_POST['post_category'])) :
818
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
819
+					$categories[$texonomy] = array();
820
+					foreach ($cat_arr as $category) :
821
+						$categories[$texonomy][] = $category;
822
+					endforeach;
823
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
824
+				endforeach;
825
+			endif;
826
+			update_option('geodir_exclude_cat_on_map', $categories);
827
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
828
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
829 829
 
830 830
 
831
-            if (!empty($_POST['geodir_default_map_language'])):
832
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
833
-            endif;
831
+			if (!empty($_POST['geodir_default_map_language'])):
832
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
833
+			endif;
834 834
 
835 835
 
836
-            if (!empty($_POST['geodir_default_map_search_pt'])):
837
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
838
-            endif;
836
+			if (!empty($_POST['geodir_default_map_search_pt'])):
837
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
838
+			endif;
839 839
 
840 840
 
841
-        elseif (isset($value['type']) && $value['type'] == 'file') :
841
+		elseif (isset($value['type']) && $value['type'] == 'file') :
842 842
 
843 843
 
844
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
844
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
845 845
 
846
-                if (get_option($value['id'])) {
847
-                    $image_name_arr = explode('/', get_option($value['id']));
848
-                    $noimg_name = end($image_name_arr);
849
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
850
-                    if (file_exists($img_path))
851
-                        unlink($img_path);
852
-                }
846
+				if (get_option($value['id'])) {
847
+					$image_name_arr = explode('/', get_option($value['id']));
848
+					$noimg_name = end($image_name_arr);
849
+					$img_path = $uploads['path'] . '/' . $noimg_name;
850
+					if (file_exists($img_path))
851
+						unlink($img_path);
852
+				}
853 853
 
854
-                update_option($value['id'], '');
855
-            }
854
+				update_option($value['id'], '');
855
+			}
856 856
 
857
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
858
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
859
-
860
-            if (!empty($filename)):
861
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
862
-                $uplaods = array();
863
-
864
-                foreach ($uploadedfile as $key => $uplaod):
865
-                    if ($key == 'name'):
866
-                        $uplaods[$key] = $filename;
867
-                    else :
868
-                        $uplaods[$key] = $uplaod;
869
-                    endif;
870
-                endforeach;
871
-
872
-                $uploads = wp_upload_dir();
873
-
874
-                if (get_option($value['id'])) {
875
-                    $image_name_arr = explode('/', get_option($value['id']));
876
-                    $noimg_name = end($image_name_arr);
877
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
878
-                    if (file_exists($img_path))
879
-                        unlink($img_path);
880
-                }
857
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
858
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
859
+
860
+			if (!empty($filename)):
861
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
862
+				$uplaods = array();
863
+
864
+				foreach ($uploadedfile as $key => $uplaod):
865
+					if ($key == 'name'):
866
+						$uplaods[$key] = $filename;
867
+					else :
868
+						$uplaods[$key] = $uplaod;
869
+					endif;
870
+				endforeach;
871
+
872
+				$uploads = wp_upload_dir();
873
+
874
+				if (get_option($value['id'])) {
875
+					$image_name_arr = explode('/', get_option($value['id']));
876
+					$noimg_name = end($image_name_arr);
877
+					$img_path = $uploads['path'] . '/' . $noimg_name;
878
+					if (file_exists($img_path))
879
+						unlink($img_path);
880
+				}
881 881
 
882
-                $upload_overrides = array('test_form' => false);
883
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
882
+				$upload_overrides = array('test_form' => false);
883
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
884 884
 
885
-                update_option($value['id'], $movefile['url']);
885
+				update_option($value['id'], $movefile['url']);
886 886
 
887
-            endif;
887
+			endif;
888 888
 
889
-            if (!get_option($value['id']) && isset($value['value'])):
890
-                update_option($value['id'], $value['value']);
891
-            endif;
889
+			if (!get_option($value['id']) && isset($value['value'])):
890
+				update_option($value['id'], $value['value']);
891
+			endif;
892 892
 
893 893
 
894
-        else :
895
-            // same menu setting per theme.
896
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
897
-                $theme = wp_get_theme();
898
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
899
-            }
894
+		else :
895
+			// same menu setting per theme.
896
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
897
+				$theme = wp_get_theme();
898
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
899
+			}
900 900
 
901
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
902
-                update_option($value['id'], $_POST[$value['id']]);
903
-            } else {
904
-                delete_option($value['id']);
905
-            }
901
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
902
+				update_option($value['id'], $_POST[$value['id']]);
903
+			} else {
904
+				delete_option($value['id']);
905
+			}
906 906
 
907
-        endif;
908
-    }
909
-    if ($dummy)
910
-        $_POST = array();
911
-    return true;
907
+		endif;
908
+	}
909
+	if ($dummy)
910
+		$_POST = array();
911
+	return true;
912 912
 
913 913
 }
914 914
 
@@ -957,33 +957,33 @@  discard block
 block discarded – undo
957 957
 function places_custom_fields_tab($tabs)
958 958
 {
959 959
 
960
-    $geodir_post_types = get_option('geodir_post_types');
960
+	$geodir_post_types = get_option('geodir_post_types');
961 961
 
962
-    if (!empty($geodir_post_types)) {
962
+	if (!empty($geodir_post_types)) {
963 963
 
964
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
964
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
965 965
 
966
-            $listing_slug = $geodir_posttype_info['labels']['singular_name'];
966
+			$listing_slug = $geodir_posttype_info['labels']['singular_name'];
967 967
 
968
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
969
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
970
-                'subtabs' => array(
971
-                    array('subtab' => 'custom_fields',
972
-                        'label' => __('Custom Fields', 'geodirectory'),
973
-                        'request' => array('listing_type' => $geodir_post_type)),
974
-                    array('subtab' => 'sorting_options',
975
-                        'label' => __('Sorting Options', 'geodirectory'),
976
-                        'request' => array('listing_type' => $geodir_post_type)),
977
-                ),
978
-                'tab_index' => 9,
979
-                'request' => array('listing_type' => $geodir_post_type)
980
-            );
968
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
969
+				'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
970
+				'subtabs' => array(
971
+					array('subtab' => 'custom_fields',
972
+						'label' => __('Custom Fields', 'geodirectory'),
973
+						'request' => array('listing_type' => $geodir_post_type)),
974
+					array('subtab' => 'sorting_options',
975
+						'label' => __('Sorting Options', 'geodirectory'),
976
+						'request' => array('listing_type' => $geodir_post_type)),
977
+				),
978
+				'tab_index' => 9,
979
+				'request' => array('listing_type' => $geodir_post_type)
980
+			);
981 981
 
982
-        endforeach;
982
+		endforeach;
983 983
 
984
-    }
984
+	}
985 985
 
986
-    return $tabs;
986
+	return $tabs;
987 987
 }
988 988
 
989 989
 
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
  */
1000 1000
 function geodir_tools_setting_tab($tabs)
1001 1001
 {
1002
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1003
-    return $tabs;
1002
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1003
+	return $tabs;
1004 1004
 }
1005 1005
 
1006 1006
 /**
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
  */
1016 1016
 function geodir_compatibility_setting_tab($tabs)
1017 1017
 {
1018
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1019
-    return $tabs;
1018
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1019
+	return $tabs;
1020 1020
 }
1021 1021
 
1022 1022
 
@@ -1032,144 +1032,144 @@  discard block
 block discarded – undo
1032 1032
  */
1033 1033
 function geodir_extend_geodirectory_setting_tab($tabs)
1034 1034
 {
1035
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1036
-    return $tabs;
1035
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1036
+	return $tabs;
1037 1037
 }
1038 1038
 
1039 1039
 
1040 1040
 if (!function_exists('geodir_edit_post_columns')) {
1041
-    /**
1042
-     * Modify admin post listing page columns.
1043
-     *
1044
-     * @since 1.0.0
1045
-     * @package GeoDirectory
1046
-     * @param array $columns The column array.
1047
-     * @return array Altered column array.
1048
-     */
1049
-    function geodir_edit_post_columns($columns)
1050
-    {
1051
-
1052
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1053
-            'categorys' => __('Categories', 'geodirectory'));
1054
-
1055
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1056
-        {
1057
-            $offset = 0; // should we prepend $array with $data?
1058
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
1059
-        }
1041
+	/**
1042
+	 * Modify admin post listing page columns.
1043
+	 *
1044
+	 * @since 1.0.0
1045
+	 * @package GeoDirectory
1046
+	 * @param array $columns The column array.
1047
+	 * @return array Altered column array.
1048
+	 */
1049
+	function geodir_edit_post_columns($columns)
1050
+	{
1051
+
1052
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1053
+			'categorys' => __('Categories', 'geodirectory'));
1060 1054
 
1061
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1055
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1056
+		{
1057
+			$offset = 0; // should we prepend $array with $data?
1058
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
1059
+		}
1062 1060
 
1063
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1061
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1064 1062
 
1065
-        return $columns;
1066
-    }
1063
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1064
+
1065
+		return $columns;
1066
+	}
1067 1067
 }
1068 1068
 
1069 1069
 
1070 1070
 if (!function_exists('geodir_manage_post_columns')) {
1071
-    /**
1072
-     * Adds content to our custom post listing page columns.
1073
-     *
1074
-     * @since 1.0.0
1075
-     * @package GeoDirectory
1076
-     * @global object $wpdb WordPress Database object.
1077
-     * @global object $post WordPress Post object.
1078
-     * @param string $column The column name.
1079
-     * @param int $post_id The post ID.
1080
-     */
1081
-    function geodir_manage_post_columns($column, $post_id)
1082
-    {
1083
-        global $post, $wpdb;
1084
-
1085
-        switch ($column):
1086
-            /* If displaying the 'city' column. */
1087
-            case 'location' :
1088
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1089
-                $location = geodir_get_location($location_id);
1090
-                /* If no city is found, output a default message. */
1091
-                if (empty($location)) {
1092
-                    _e('Unknown', 'geodirectory');
1093
-                } else {
1094
-                    /* If there is a city id, append 'city name' to the text string. */
1095
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1096
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1097
-                }
1098
-                break;
1099
-
1100
-            /* If displaying the 'expire' column. */
1101
-            case 'expire' :
1102
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1103
-                $d1 = $expire_date; // get expire_date
1104
-                $d2 = date('Y-m-d'); // get current date
1105
-                $state = __('days left', 'geodirectory');
1106
-                $date_diff_text = '';
1107
-                $expire_class = 'expire_left';
1108
-                if ($expire_date != 'Never') {
1109
-                    if (strtotime($d1) < strtotime($d2)) {
1110
-                        $state = __('days overdue', 'geodirectory');
1111
-                        $expire_class = 'expire_over';
1112
-                    }
1113
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1114
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1115
-                }
1116
-                /* If no expire_date is found, output a default message. */
1117
-                if (empty($expire_date))
1118
-                    echo __('Unknown', 'geodirectory');
1119
-                /* If there is a expire_date, append 'days left' to the text string. */
1120
-                else
1121
-                    echo $expire_date . $date_diff_text;
1122
-                break;
1123
-
1124
-            /* If displaying the 'categorys' column. */
1125
-            case 'categorys' :
1126
-
1127
-                /* Get the categorys for the post. */
1128
-
1129
-
1130
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1131
-
1132
-                /* If terms were found. */
1133
-                if (!empty($terms)) {
1134
-                    $out = array();
1135
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
1136
-                    foreach ($terms as $term) {
1137
-                        if (!strstr($term->taxonomy, 'tag')) {
1138
-                            $out[] = sprintf('<a href="%s">%s</a>',
1139
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1140
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1141
-                            );
1142
-                        }
1143
-                    }
1144
-                    /* Join the terms, separating them with a comma. */
1145
-                    echo(join(', ', $out));
1146
-                } /* If no terms were found, output a default message. */
1147
-                else {
1148
-                    _e('No Categories', 'geodirectory');
1149
-                }
1150
-                break;
1071
+	/**
1072
+	 * Adds content to our custom post listing page columns.
1073
+	 *
1074
+	 * @since 1.0.0
1075
+	 * @package GeoDirectory
1076
+	 * @global object $wpdb WordPress Database object.
1077
+	 * @global object $post WordPress Post object.
1078
+	 * @param string $column The column name.
1079
+	 * @param int $post_id The post ID.
1080
+	 */
1081
+	function geodir_manage_post_columns($column, $post_id)
1082
+	{
1083
+		global $post, $wpdb;
1084
+
1085
+		switch ($column):
1086
+			/* If displaying the 'city' column. */
1087
+			case 'location' :
1088
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1089
+				$location = geodir_get_location($location_id);
1090
+				/* If no city is found, output a default message. */
1091
+				if (empty($location)) {
1092
+					_e('Unknown', 'geodirectory');
1093
+				} else {
1094
+					/* If there is a city id, append 'city name' to the text string. */
1095
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1096
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1097
+				}
1098
+				break;
1099
+
1100
+			/* If displaying the 'expire' column. */
1101
+			case 'expire' :
1102
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1103
+				$d1 = $expire_date; // get expire_date
1104
+				$d2 = date('Y-m-d'); // get current date
1105
+				$state = __('days left', 'geodirectory');
1106
+				$date_diff_text = '';
1107
+				$expire_class = 'expire_left';
1108
+				if ($expire_date != 'Never') {
1109
+					if (strtotime($d1) < strtotime($d2)) {
1110
+						$state = __('days overdue', 'geodirectory');
1111
+						$expire_class = 'expire_over';
1112
+					}
1113
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1114
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1115
+				}
1116
+				/* If no expire_date is found, output a default message. */
1117
+				if (empty($expire_date))
1118
+					echo __('Unknown', 'geodirectory');
1119
+				/* If there is a expire_date, append 'days left' to the text string. */
1120
+				else
1121
+					echo $expire_date . $date_diff_text;
1122
+				break;
1151 1123
 
1152
-        endswitch;
1153
-    }
1124
+			/* If displaying the 'categorys' column. */
1125
+			case 'categorys' :
1126
+
1127
+				/* Get the categorys for the post. */
1128
+
1129
+
1130
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1131
+
1132
+				/* If terms were found. */
1133
+				if (!empty($terms)) {
1134
+					$out = array();
1135
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
1136
+					foreach ($terms as $term) {
1137
+						if (!strstr($term->taxonomy, 'tag')) {
1138
+							$out[] = sprintf('<a href="%s">%s</a>',
1139
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1140
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1141
+							);
1142
+						}
1143
+					}
1144
+					/* Join the terms, separating them with a comma. */
1145
+					echo(join(', ', $out));
1146
+				} /* If no terms were found, output a default message. */
1147
+				else {
1148
+					_e('No Categories', 'geodirectory');
1149
+				}
1150
+				break;
1151
+
1152
+		endswitch;
1153
+	}
1154 1154
 }
1155 1155
 
1156 1156
 
1157 1157
 if (!function_exists('geodir_post_sortable_columns')) {
1158
-    /**
1159
-     * Makes admin post listing page columns sortable.
1160
-     *
1161
-     * @since 1.0.0
1162
-     * @package GeoDirectory
1163
-     * @param array $columns The column array.
1164
-     * @return array Altered column array.
1165
-     */
1166
-    function geodir_post_sortable_columns($columns)
1167
-    {
1168
-
1169
-        $columns['expire'] = 'expire';
1170
-
1171
-        return $columns;
1172
-    }
1158
+	/**
1159
+	 * Makes admin post listing page columns sortable.
1160
+	 *
1161
+	 * @since 1.0.0
1162
+	 * @package GeoDirectory
1163
+	 * @param array $columns The column array.
1164
+	 * @return array Altered column array.
1165
+	 */
1166
+	function geodir_post_sortable_columns($columns)
1167
+	{
1168
+
1169
+		$columns['expire'] = 'expire';
1170
+
1171
+		return $columns;
1172
+	}
1173 1173
 }
1174 1174
 
1175 1175
 /**
@@ -1183,32 +1183,32 @@  discard block
 block discarded – undo
1183 1183
  * @param int $post_id The post ID.
1184 1184
  */
1185 1185
 function geodir_post_information_save($post_id, $post) {
1186
-    global $wpdb, $current_user;
1186
+	global $wpdb, $current_user;
1187 1187
 
1188
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1189
-        return;
1190
-    }
1188
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1189
+		return;
1190
+	}
1191 1191
 
1192
-    $geodir_posttypes = geodir_get_posttypes();
1192
+	$geodir_posttypes = geodir_get_posttypes();
1193 1193
 
1194
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1195
-        return;
1194
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1195
+		return;
1196 1196
 
1197
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1198
-        if (isset($_REQUEST['_status']))
1199
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1197
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1198
+		if (isset($_REQUEST['_status']))
1199
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
1200 1200
 
1201
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1202
-            return;
1201
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1202
+			return;
1203 1203
 
1204
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1205
-            return;
1204
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1205
+			return;
1206 1206
 
1207
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1208
-            return;
1207
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1208
+			return;
1209 1209
 
1210
-        geodir_save_listing($_REQUEST);
1211
-    }
1210
+		geodir_save_listing($_REQUEST);
1211
+	}
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1224,102 +1224,102 @@  discard block
 block discarded – undo
1224 1224
  */
1225 1225
 function geodir_admin_fields($options)
1226 1226
 {
1227
-    global $geodirectory;
1228
-
1229
-    $first_title = true;
1230
-    $tab_id = '';
1231
-    $i = 0;
1232
-    foreach ($options as $value) :
1233
-        if (!isset($value['name'])) $value['name'] = '';
1234
-        if (!isset($value['class'])) $value['class'] = '';
1235
-        if (!isset($value['css'])) $value['css'] = '';
1236
-        if (!isset($value['std'])) $value['std'] = '';
1237
-        $desc = '';
1238
-        switch ($value['type']) :
1239
-            case 'dummy_installer':
1240
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1241
-                geodir_autoinstall_admin_header($post_type);
1242
-                break;
1243
-            case 'title':
1244
-
1245
-                if ($i == 0) {
1246
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1247
-                    echo '<div class="inner_content_tab_main">';
1248
-                }
1227
+	global $geodirectory;
1228
+
1229
+	$first_title = true;
1230
+	$tab_id = '';
1231
+	$i = 0;
1232
+	foreach ($options as $value) :
1233
+		if (!isset($value['name'])) $value['name'] = '';
1234
+		if (!isset($value['class'])) $value['class'] = '';
1235
+		if (!isset($value['css'])) $value['css'] = '';
1236
+		if (!isset($value['std'])) $value['std'] = '';
1237
+		$desc = '';
1238
+		switch ($value['type']) :
1239
+			case 'dummy_installer':
1240
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1241
+				geodir_autoinstall_admin_header($post_type);
1242
+				break;
1243
+			case 'title':
1244
+
1245
+				if ($i == 0) {
1246
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1247
+					echo '<div class="inner_content_tab_main">';
1248
+				}
1249 1249
 
1250
-                $i++;
1250
+				$i++;
1251 1251
 
1252
-                if (isset($value['id']) && $value['id'])
1253
-                    $tab_id = $value['id'];
1252
+				if (isset($value['id']) && $value['id'])
1253
+					$tab_id = $value['id'];
1254 1254
 
1255
-                if (isset($value['desc']) && $value['desc'])
1256
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1255
+				if (isset($value['desc']) && $value['desc'])
1256
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1257 1257
 
1258
-                if (isset($value['name']) && $value['name']) {
1259
-                    if ($first_title === true) {
1260
-                        $first_title = false;
1261
-                    } else {
1262
-                        echo '</div>';
1263
-                    }
1264
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1258
+				if (isset($value['name']) && $value['name']) {
1259
+					if ($first_title === true) {
1260
+						$first_title = false;
1261
+					} else {
1262
+						echo '</div>';
1263
+					}
1264
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1265 1265
 
1266
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1267
-                }
1266
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1267
+				}
1268 1268
 
1269
-                /**
1270
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
1271
-                 *
1272
-                 * The action is called dynamically geodir_settings_$value['id'].
1273
-                 *
1274
-                 * @since 1.0.0
1275
-                 */
1276
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1277
-                break;
1278
-
1279
-            case 'no_tabs':
1280
-
1281
-                echo '<div class="inner_content_tab_main">';
1282
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1283
-
1284
-                break;
1285
-
1286
-            case 'sectionstart':
1287
-                if (isset($value['desc']) && $value['desc'])
1288
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1289
-                if (isset($value['name']) && $value['name'])
1290
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1291
-                /**
1292
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1293
-                 *
1294
-                 * The action is called dynamically geodir_settings_$value['id']_start.
1295
-                 *
1296
-                 * @since 1.0.0
1297
-                 */
1298
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1299
-                echo '<table class="form-table">' . "\n\n";
1300
-
1301
-                break;
1302
-            case 'sectionend':
1303
-                /**
1304
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1305
-                 *
1306
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1307
-                 *
1308
-                 * @since 1.0.0
1309
-                 */
1310
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1311
-                echo '</table>';
1312
-                /**
1313
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1314
-                 *
1315
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1316
-                 *
1317
-                 * @since 1.0.0
1318
-                 */
1319
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1320
-                break;
1321
-            case 'text':
1322
-                ?>
1269
+				/**
1270
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
1271
+				 *
1272
+				 * The action is called dynamically geodir_settings_$value['id'].
1273
+				 *
1274
+				 * @since 1.0.0
1275
+				 */
1276
+				do_action('geodir_settings_' . sanitize_title($value['id']));
1277
+				break;
1278
+
1279
+			case 'no_tabs':
1280
+
1281
+				echo '<div class="inner_content_tab_main">';
1282
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1283
+
1284
+				break;
1285
+
1286
+			case 'sectionstart':
1287
+				if (isset($value['desc']) && $value['desc'])
1288
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1289
+				if (isset($value['name']) && $value['name'])
1290
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
1291
+				/**
1292
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1293
+				 *
1294
+				 * The action is called dynamically geodir_settings_$value['id']_start.
1295
+				 *
1296
+				 * @since 1.0.0
1297
+				 */
1298
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1299
+				echo '<table class="form-table">' . "\n\n";
1300
+
1301
+				break;
1302
+			case 'sectionend':
1303
+				/**
1304
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1305
+				 *
1306
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1307
+				 *
1308
+				 * @since 1.0.0
1309
+				 */
1310
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1311
+				echo '</table>';
1312
+				/**
1313
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1314
+				 *
1315
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1316
+				 *
1317
+				 * @since 1.0.0
1318
+				 */
1319
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1320
+				break;
1321
+			case 'text':
1322
+				?>
1323 1323
                 <tr valign="top">
1324 1324
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1325 1325
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1328,15 +1328,15 @@  discard block
 block discarded – undo
1328 1328
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1329 1329
                                            style=" <?php echo esc_attr($value['css']); ?>"
1330 1330
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1331
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1332
-                                           } else {
1333
-                                               echo esc_attr($value['std']);
1334
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1331
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1332
+										   } else {
1333
+											   echo esc_attr($value['std']);
1334
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1335 1335
                 </tr><?php
1336
-                break;
1336
+				break;
1337 1337
 
1338
-            case 'password':
1339
-                ?>
1338
+			case 'password':
1339
+				?>
1340 1340
                 <tr valign="top">
1341 1341
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1342 1342
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1345,42 +1345,42 @@  discard block
 block discarded – undo
1345 1345
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1346 1346
                                            style="<?php echo esc_attr($value['css']); ?>"
1347 1347
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1348
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1349
-                                           } else {
1350
-                                               echo esc_attr($value['std']);
1351
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1348
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1349
+										   } else {
1350
+											   echo esc_attr($value['std']);
1351
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1352 1352
                 </tr><?php
1353
-                break;
1353
+				break;
1354 1354
 
1355
-            case 'html_content':
1356
-                ?>
1355
+			case 'html_content':
1356
+				?>
1357 1357
                 <tr valign="top">
1358 1358
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1359 1359
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1360 1360
                 </tr><?php
1361
-                break;
1361
+				break;
1362 1362
 
1363
-            case 'color' :
1364
-                ?>
1363
+			case 'color' :
1364
+				?>
1365 1365
                 <tr valign="top">
1366 1366
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1367 1367
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1368 1368
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1369 1369
                                            style="<?php echo esc_attr($value['css']); ?>"
1370 1370
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1371
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1372
-                                           } else {
1373
-                                               echo esc_attr($value['std']);
1374
-                                           } ?>" class="colorpick"/> <span
1371
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1372
+										   } else {
1373
+											   echo esc_attr($value['std']);
1374
+										   } ?>" class="colorpick"/> <span
1375 1375
                         class="description"><?php echo $value['desc']; ?></span>
1376 1376
 
1377 1377
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1378 1378
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1379 1379
                 </td>
1380 1380
                 </tr><?php
1381
-                break;
1382
-            case 'image_width' :
1383
-                ?>
1381
+				break;
1382
+			case 'image_width' :
1383
+				?>
1384 1384
                 <tr valign="top">
1385 1385
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1386 1386
                 <td class="forminp">
@@ -1402,11 +1402,11 @@  discard block
 block discarded – undo
1402 1402
 
1403 1403
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1404 1404
                 </tr><?php
1405
-                break;
1406
-            case 'select':
1407
-                $option_value = get_option($value['id']);
1408
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1409
-                ?>
1405
+				break;
1406
+			case 'select':
1407
+				$option_value = get_option($value['id']);
1408
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1409
+				?>
1410 1410
                 <tr valign="top">
1411 1411
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1412 1412
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1415,33 +1415,33 @@  discard block
 block discarded – undo
1415 1415
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1416 1416
                                             option-ajaxchosen="false">
1417 1417
                         <?php
1418
-                        foreach ($value['options'] as $key => $val) {
1419
-                            $geodir_select_value = '';
1420
-                            if ($option_value != '') {
1421
-                                if ($option_value != '' && $option_value == $key)
1422
-                                    $geodir_select_value = ' selected="selected" ';
1423
-                            } else {
1424
-                                if ($value['std'] == $key)
1425
-                                    $geodir_select_value = ' selected="selected" ';
1426
-                            }
1427
-                            ?>
1418
+						foreach ($value['options'] as $key => $val) {
1419
+							$geodir_select_value = '';
1420
+							if ($option_value != '') {
1421
+								if ($option_value != '' && $option_value == $key)
1422
+									$geodir_select_value = ' selected="selected" ';
1423
+							} else {
1424
+								if ($value['std'] == $key)
1425
+									$geodir_select_value = ' selected="selected" ';
1426
+							}
1427
+							?>
1428 1428
                             <option
1429 1429
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option>
1430 1430
                         <?php
1431
-                        }
1432
-                        ?>
1431
+						}
1432
+						?>
1433 1433
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1434 1434
                 </td>
1435 1435
                 </tr><?php
1436
-                break;
1436
+				break;
1437 1437
 
1438
-            case 'multiselect':
1439
-                $option_values = get_option($value['id']);
1440
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1441
-                   $option_values = $value['std'];
1442
-                }
1443
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1444
-                ?>
1438
+			case 'multiselect':
1439
+				$option_values = get_option($value['id']);
1440
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1441
+				   $option_values = $value['std'];
1442
+				}
1443
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1444
+				?>
1445 1445
                 <tr valign="top">
1446 1446
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1447 1447
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1451,25 +1451,25 @@  discard block
 block discarded – undo
1451 1451
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1452 1452
                                             option-ajaxchosen="false">
1453 1453
                         <?php
1454
-                        foreach ($value['options'] as $key => $val) {
1455
-                            if (strpos($key, 'optgroup_start-') === 0) {
1456
-                                ?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1457
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1458
-                                ?></optgroup><?php
1459
-                            } else {
1460
-                                ?>
1454
+						foreach ($value['options'] as $key => $val) {
1455
+							if (strpos($key, 'optgroup_start-') === 0) {
1456
+								?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1457
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1458
+								?></optgroup><?php
1459
+							} else {
1460
+								?>
1461 1461
                                 <option
1462 1462
                                     value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1463 1463
                             <?php
1464
-                            }
1465
-                        }
1466
-                        ?>
1464
+							}
1465
+						}
1466
+						?>
1467 1467
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1468 1468
                 </td>
1469 1469
                 </tr><?php
1470
-                break;
1471
-            case 'file':
1472
-                ?>
1470
+				break;
1471
+			case 'file':
1472
+				?>
1473 1473
                 <tr valign="top">
1474 1474
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1475 1475
                 <td class="forminp">
@@ -1489,87 +1489,87 @@  discard block
 block discarded – undo
1489 1489
                     <?php } ?>
1490 1490
                 </td>
1491 1491
                 </tr><?php
1492
-                break;
1493
-            case 'map_default_settings' :
1494
-                ?>
1492
+				break;
1493
+			case 'map_default_settings' :
1494
+				?>
1495 1495
 
1496 1496
                 <tr valign="top">
1497 1497
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1498 1498
                     <td width="60%">
1499 1499
                         <select name="geodir_default_map_language" style="width:60%">
1500 1500
                             <?php
1501
-                            $arr_map_langages = array(
1502
-                                'ar' => __('ARABIC', 'geodirectory'),
1503
-                                'eu' => __('BASQUE', 'geodirectory'),
1504
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1505
-                                'bn' => __('BENGALI', 'geodirectory'),
1506
-                                'ca' => __('CATALAN', 'geodirectory'),
1507
-                                'cs' => __('CZECH', 'geodirectory'),
1508
-                                'da' => __('DANISH', 'geodirectory'),
1509
-                                'de' => __('GERMAN', 'geodirectory'),
1510
-                                'el' => __('GREEK', 'geodirectory'),
1511
-                                'en' => __('ENGLISH', 'geodirectory'),
1512
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1513
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1514
-                                'es' => __('SPANISH', 'geodirectory'),
1515
-                                'eu' => __('BASQUE', 'geodirectory'),
1516
-                                'fa' => __('FARSI', 'geodirectory'),
1517
-                                'fi' => __('FINNISH', 'geodirectory'),
1518
-                                'fil' => __('FILIPINO', 'geodirectory'),
1519
-                                'fr' => __('FRENCH', 'geodirectory'),
1520
-                                'gl' => __('GALICIAN', 'geodirectory'),
1521
-                                'gu' => __('GUJARATI', 'geodirectory'),
1522
-                                'hi' => __('HINDI', 'geodirectory'),
1523
-                                'hr' => __('CROATIAN', 'geodirectory'),
1524
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1525
-                                'id' => __('INDONESIAN', 'geodirectory'),
1526
-                                'it' => __('ITALIAN', 'geodirectory'),
1527
-                                'iw' => __('HEBREW', 'geodirectory'),
1528
-                                'ja' => __('JAPANESE', 'geodirectory'),
1529
-                                'kn' => __('KANNADA', 'geodirectory'),
1530
-                                'ko' => __('KOREAN', 'geodirectory'),
1531
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1532
-                                'lv' => __('LATVIAN', 'geodirectory'),
1533
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1534
-                                'mr' => __('MARATHI', 'geodirectory'),
1535
-                                'nl' => __('DUTCH', 'geodirectory'),
1536
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1537
-                                'pl' => __('POLISH', 'geodirectory'),
1538
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1539
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1540
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1541
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1542
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1543
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1544
-                                'sk' => __('SLOVAK', 'geodirectory'),
1545
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1546
-                                'sr' => __('SERBIAN', 'geodirectory'),
1547
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1548
-                                'tl' => __('TAGALOG', 'geodirectory'),
1549
-                                'ta' => __('TAMIL', 'geodirectory'),
1550
-                                'te' => __('TELUGU', 'geodirectory'),
1551
-                                'th' => __('THAI', 'geodirectory'),
1552
-                                'tr' => __('TURKISH', 'geodirectory'),
1553
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1554
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1555
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1556
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1557
-                            );
1558
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1559
-                            if (empty($geodir_default_map_language))
1560
-                                $geodir_default_map_language = 'en';
1561
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
1562
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1563
-                                    $geodir_default_language_selected = "selected='selected'";
1564
-                                else
1565
-                                    $geodir_default_language_selected = '';
1566
-
1567
-                                ?>
1501
+							$arr_map_langages = array(
1502
+								'ar' => __('ARABIC', 'geodirectory'),
1503
+								'eu' => __('BASQUE', 'geodirectory'),
1504
+								'bg' => __('BULGARIAN', 'geodirectory'),
1505
+								'bn' => __('BENGALI', 'geodirectory'),
1506
+								'ca' => __('CATALAN', 'geodirectory'),
1507
+								'cs' => __('CZECH', 'geodirectory'),
1508
+								'da' => __('DANISH', 'geodirectory'),
1509
+								'de' => __('GERMAN', 'geodirectory'),
1510
+								'el' => __('GREEK', 'geodirectory'),
1511
+								'en' => __('ENGLISH', 'geodirectory'),
1512
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1513
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1514
+								'es' => __('SPANISH', 'geodirectory'),
1515
+								'eu' => __('BASQUE', 'geodirectory'),
1516
+								'fa' => __('FARSI', 'geodirectory'),
1517
+								'fi' => __('FINNISH', 'geodirectory'),
1518
+								'fil' => __('FILIPINO', 'geodirectory'),
1519
+								'fr' => __('FRENCH', 'geodirectory'),
1520
+								'gl' => __('GALICIAN', 'geodirectory'),
1521
+								'gu' => __('GUJARATI', 'geodirectory'),
1522
+								'hi' => __('HINDI', 'geodirectory'),
1523
+								'hr' => __('CROATIAN', 'geodirectory'),
1524
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1525
+								'id' => __('INDONESIAN', 'geodirectory'),
1526
+								'it' => __('ITALIAN', 'geodirectory'),
1527
+								'iw' => __('HEBREW', 'geodirectory'),
1528
+								'ja' => __('JAPANESE', 'geodirectory'),
1529
+								'kn' => __('KANNADA', 'geodirectory'),
1530
+								'ko' => __('KOREAN', 'geodirectory'),
1531
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1532
+								'lv' => __('LATVIAN', 'geodirectory'),
1533
+								'ml' => __('MALAYALAM', 'geodirectory'),
1534
+								'mr' => __('MARATHI', 'geodirectory'),
1535
+								'nl' => __('DUTCH', 'geodirectory'),
1536
+								'no' => __('NORWEGIAN', 'geodirectory'),
1537
+								'pl' => __('POLISH', 'geodirectory'),
1538
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1539
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1540
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1541
+								'ro' => __('ROMANIAN', 'geodirectory'),
1542
+								'ru' => __('RUSSIAN', 'geodirectory'),
1543
+								'ru' => __('RUSSIAN', 'geodirectory'),
1544
+								'sk' => __('SLOVAK', 'geodirectory'),
1545
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1546
+								'sr' => __('SERBIAN', 'geodirectory'),
1547
+								'sv' => __('	SWEDISH', 'geodirectory'),
1548
+								'tl' => __('TAGALOG', 'geodirectory'),
1549
+								'ta' => __('TAMIL', 'geodirectory'),
1550
+								'te' => __('TELUGU', 'geodirectory'),
1551
+								'th' => __('THAI', 'geodirectory'),
1552
+								'tr' => __('TURKISH', 'geodirectory'),
1553
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1554
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1555
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1556
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1557
+							);
1558
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1559
+							if (empty($geodir_default_map_language))
1560
+								$geodir_default_map_language = 'en';
1561
+							foreach ($arr_map_langages as $language_key => $language_txt) {
1562
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1563
+									$geodir_default_language_selected = "selected='selected'";
1564
+								else
1565
+									$geodir_default_language_selected = '';
1566
+
1567
+								?>
1568 1568
                                 <option
1569 1569
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1570 1570
 
1571 1571
                             <?php }
1572
-                            ?>
1572
+							?>
1573 1573
                         </select>
1574 1574
                     </td>
1575 1575
                 </tr>
@@ -1580,46 +1580,46 @@  discard block
 block discarded – undo
1580 1580
                     <td width="60%">
1581 1581
                         <select name="geodir_default_map_search_pt" style="width:60%">
1582 1582
                             <?php
1583
-                            $post_types = geodir_get_posttypes('array');
1584
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1585
-                            if (empty($geodir_default_map_search_pt))
1586
-                                $geodir_default_map_search_pt = 'gd_place';
1587
-                            if (is_array($post_types)) {
1588
-                                foreach ($post_types as $key => $post_types_obj) {
1589
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1590
-                                        $geodir_search_pt_selected = "selected='selected'";
1591
-                                    else
1592
-                                        $geodir_search_pt_selected = '';
1593
-
1594
-                                    ?>
1583
+							$post_types = geodir_get_posttypes('array');
1584
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1585
+							if (empty($geodir_default_map_search_pt))
1586
+								$geodir_default_map_search_pt = 'gd_place';
1587
+							if (is_array($post_types)) {
1588
+								foreach ($post_types as $key => $post_types_obj) {
1589
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1590
+										$geodir_search_pt_selected = "selected='selected'";
1591
+									else
1592
+										$geodir_search_pt_selected = '';
1593
+
1594
+									?>
1595 1595
                                     <option
1596 1596
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option>
1597 1597
 
1598 1598
                                 <?php }
1599 1599
 
1600
-                            }
1600
+							}
1601 1601
 
1602
-                            ?>
1602
+							?>
1603 1603
                         </select>
1604 1604
                     </td>
1605 1605
                 </tr>
1606 1606
 
1607 1607
                 <?php
1608
-                break;
1608
+				break;
1609 1609
 
1610
-            case 'map':
1611
-                ?>
1610
+			case 'map':
1611
+				?>
1612 1612
                 <tr valign="top">
1613 1613
                     <td class="forminp">
1614 1614
                         <?php
1615
-                        global $post_cat, $cat_display;
1616
-                        $post_types = geodir_get_posttypes('object');
1617
-                        $cat_display = 'checkbox';
1618
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1619
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1620
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1621
-                        $count = 1;
1622
-                        ?>
1615
+						global $post_cat, $cat_display;
1616
+						$post_types = geodir_get_posttypes('object');
1617
+						$cat_display = 'checkbox';
1618
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1619
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1620
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1621
+						$count = 1;
1622
+						?>
1623 1623
                         <table width="70%" class="widefat">
1624 1624
                             <thead>
1625 1625
                             <tr>
@@ -1628,18 +1628,18 @@  discard block
 block discarded – undo
1628 1628
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1629 1629
                             </tr>
1630 1630
                             <?php
1631
-                            $gd_categs = $gd_cats;
1632
-                            foreach ($post_types as $key => $post_types_obj) :
1633
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1634
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1635
-                                if ($gd_cats_upgrade) {
1636
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1637
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1638
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1639
-                                }
1640
-                                $post_cat = implode(',', $gd_cats);
1641
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1642
-                                ?>
1631
+							$gd_categs = $gd_cats;
1632
+							foreach ($post_types as $key => $post_types_obj) :
1633
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1634
+								$gd_taxonomy = geodir_get_taxonomies($key);
1635
+								if ($gd_cats_upgrade) {
1636
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1637
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1638
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1639
+								}
1640
+								$post_cat = implode(',', $gd_cats);
1641
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1642
+								?>
1643 1643
                                 <tr>
1644 1644
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1645 1645
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1660,19 +1660,19 @@  discard block
 block discarded – undo
1660 1660
                     </td>
1661 1661
                 </tr>
1662 1662
                 <?php
1663
-                break;
1663
+				break;
1664 1664
 
1665
-            case 'checkbox' :
1665
+			case 'checkbox' :
1666 1666
 
1667
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1668
-                    ?>
1667
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1668
+					?>
1669 1669
                     <tr valign="top">
1670 1670
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1671 1671
                     <td class="forminp">
1672 1672
                 <?php
1673
-                endif;
1673
+				endif;
1674 1674
 
1675
-                ?>
1675
+				?>
1676 1676
                 <fieldset>
1677 1677
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1678 1678
                     <label for="<?php echo $value['id'] ?>">
@@ -1682,49 +1682,49 @@  discard block
 block discarded – undo
1682 1682
                 </fieldset>
1683 1683
                 <?php
1684 1684
 
1685
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1686
-                    ?>
1685
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1686
+					?>
1687 1687
                     </td>
1688 1688
                     </tr>
1689 1689
                 <?php
1690
-                endif;
1690
+				endif;
1691 1691
 
1692
-                break;
1692
+				break;
1693 1693
 
1694
-            case 'radio' :
1694
+			case 'radio' :
1695 1695
 
1696
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1697
-                    ?>
1696
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1697
+					?>
1698 1698
                     <tr valign="top">
1699 1699
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1700 1700
                     <td class="forminp">
1701 1701
                 <?php
1702
-                endif;
1702
+				endif;
1703 1703
 
1704
-                ?>
1704
+				?>
1705 1705
                 <fieldset>
1706 1706
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1707 1707
                     <label for="<?php echo $value['id'];?>">
1708 1708
                         <input name="<?php echo esc_attr($value['id']); ?>"
1709 1709
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1710 1710
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1711
-                            echo 'checked="checked"';
1712
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1711
+							echo 'checked="checked"';
1712
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1713 1713
                         <?php echo $value['desc']; ?></label><br>
1714 1714
                 </fieldset>
1715 1715
                 <?php
1716 1716
 
1717
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1718
-                    ?>
1717
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1718
+					?>
1719 1719
                     </td>
1720 1720
                     </tr>
1721 1721
                 <?php
1722
-                endif;
1722
+				endif;
1723 1723
 
1724
-                break;
1724
+				break;
1725 1725
 
1726
-            case 'textarea':
1727
-                ?>
1726
+			case 'textarea':
1727
+				?>
1728 1728
                 <tr valign="top">
1729 1729
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1730 1730
                 <td class="forminp">
@@ -1737,30 +1737,30 @@  discard block
 block discarded – undo
1737 1737
 
1738 1738
                 </td>
1739 1739
                 </tr><?php
1740
-                break;
1740
+				break;
1741 1741
 
1742
-            case 'editor':
1743
-                ?>
1742
+			case 'editor':
1743
+				?>
1744 1744
                 <tr valign="top">
1745 1745
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1746 1746
                 <td class="forminp"><?php
1747
-                    if (get_option($value['id']))
1748
-                        $content = stripslashes(get_option($value['id']));
1749
-                    else
1750
-                        $content = $value['std'];
1747
+					if (get_option($value['id']))
1748
+						$content = stripslashes(get_option($value['id']));
1749
+					else
1750
+						$content = $value['std'];
1751 1751
 
1752
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1752
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1753 1753
 
1754
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1754
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1755 1755
 
1756
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1756
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1757 1757
 
1758 1758
                 </td>
1759 1759
                 </tr><?php
1760
-                break;
1760
+				break;
1761 1761
 
1762
-            case 'single_select_page' :
1763
-                // WPML
1762
+			case 'single_select_page' :
1763
+				// WPML
1764 1764
 				$switch_lang = false;
1765 1765
 				$disabled = '';
1766 1766
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1778,18 +1778,18 @@  discard block
 block discarded – undo
1778 1778
 				//
1779 1779
 				$page_setting = (int)get_option($value['id']);
1780 1780
 
1781
-                $args = array('name' => $value['id'],
1782
-                    'id' => $value['id'],
1783
-                    'sort_column' => 'menu_order',
1784
-                    'sort_order' => 'ASC',
1785
-                    'show_option_none' => ' ',
1786
-                    'class' => $value['class'],
1787
-                    'echo' => false,
1788
-                    'selected' => $page_setting);
1781
+				$args = array('name' => $value['id'],
1782
+					'id' => $value['id'],
1783
+					'sort_column' => 'menu_order',
1784
+					'sort_order' => 'ASC',
1785
+					'show_option_none' => ' ',
1786
+					'class' => $value['class'],
1787
+					'echo' => false,
1788
+					'selected' => $page_setting);
1789 1789
 
1790
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1790
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1791 1791
 
1792
-                ?>
1792
+				?>
1793 1793
                 <tr valign="top" class="single_select_page">
1794 1794
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1795 1795
                 <td class="forminp">
@@ -1800,17 +1800,17 @@  discard block
 block discarded – undo
1800 1800
 				if ($switch_lang) {
1801 1801
 					$sitepress->switch_lang($switch_lang, true);
1802 1802
 				}
1803
-                break;
1804
-            case 'single_select_country' :
1805
-                $country_setting = (string)get_option($value['id']);
1806
-                if (strstr($country_setting, ':')) :
1807
-                    $country = current(explode(':', $country_setting));
1808
-                    $state = end(explode(':', $country_setting));
1809
-                else :
1810
-                    $country = $country_setting;
1811
-                    $state = '*';
1812
-                endif;
1813
-                ?>
1803
+				break;
1804
+			case 'single_select_country' :
1805
+				$country_setting = (string)get_option($value['id']);
1806
+				if (strstr($country_setting, ':')) :
1807
+					$country = current(explode(':', $country_setting));
1808
+					$state = end(explode(':', $country_setting));
1809
+				else :
1810
+					$country = $country_setting;
1811
+					$state = '*';
1812
+				endif;
1813
+				?>
1814 1814
                 <tr valign="top">
1815 1815
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1816 1816
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1821,12 +1821,12 @@  discard block
 block discarded – undo
1821 1821
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1822 1822
                 </td>
1823 1823
                 </tr><?php
1824
-                break;
1825
-            case 'multi_select_countries' :
1826
-                $countries = $geodirectory->countries->countries;
1827
-                asort($countries);
1828
-                $selections = (array)get_option($value['id']);
1829
-                ?>
1824
+				break;
1825
+			case 'multi_select_countries' :
1826
+				$countries = $geodirectory->countries->countries;
1827
+				asort($countries);
1828
+				$selections = (array)get_option($value['id']);
1829
+				?>
1830 1830
                 <tr valign="top">
1831 1831
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1832 1832
                 <td class="forminp">
@@ -1834,22 +1834,22 @@  discard block
 block discarded – undo
1834 1834
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1835 1835
                             title="Country" class="chosen_select">
1836 1836
                         <?php
1837
-                        if ($countries) foreach ($countries as $key => $val) :
1838
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1839
-                        endforeach;
1840
-                        ?>
1837
+						if ($countries) foreach ($countries as $key => $val) :
1838
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1839
+						endforeach;
1840
+						?>
1841 1841
                     </select>
1842 1842
                 </td>
1843 1843
                 </tr>
1844 1844
 
1845 1845
                 <?php
1846 1846
 
1847
-                break;
1847
+				break;
1848 1848
 
1849
-            case 'google_analytics' :
1850
-                $selections = (array)get_option($value['id']);
1851
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1852
-                    ?>
1849
+			case 'google_analytics' :
1850
+				$selections = (array)get_option($value['id']);
1851
+				if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1852
+					?>
1853 1853
                     <tr valign="top">
1854 1854
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1855 1855
                         <td class="forminp">
@@ -1857,19 +1857,19 @@  discard block
 block discarded – undo
1857 1857
 
1858 1858
                             <?php
1859 1859
 
1860
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1861
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1862
-                            $state = "&state=123";//any string
1863
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1864
-                            $response_type = "&response_type=code";
1865
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1866
-                            $access_type = "&access_type=offline";
1867
-                            $approval_prompt = "&approval_prompt=force";
1860
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1861
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1862
+							$state = "&state=123";//any string
1863
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1864
+							$response_type = "&response_type=code";
1865
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1866
+							$access_type = "&access_type=offline";
1867
+							$approval_prompt = "&approval_prompt=force";
1868 1868
 
1869
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1869
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1870 1870
 
1871 1871
 
1872
-                            ?>
1872
+							?>
1873 1873
                             <script>
1874 1874
                                 function gd_ga_popup() {
1875 1875
                                     var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
@@ -1884,47 +1884,47 @@  discard block
 block discarded – undo
1884 1884
                             </script>
1885 1885
 
1886 1886
                             <?php
1887
-                            if (get_option('gd_ga_refresh_token')) {
1888
-                                ?>
1887
+							if (get_option('gd_ga_refresh_token')) {
1888
+								?>
1889 1889
                                 <span class="button-primary"
1890 1890
                                       onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
1891 1891
                                 <span
1892 1892
                                     style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1893 1893
                             <?php
1894
-                            } else {
1895
-                                ?>
1894
+							} else {
1895
+								?>
1896 1896
                                 <span class="button-primary"
1897 1897
                                       onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1898 1898
                             <?php
1899
-                            }
1900
-                            ?>
1899
+							}
1900
+							?>
1901 1901
                         </td>
1902 1902
                     </tr>
1903 1903
 
1904 1904
                 <?php
1905
-                }
1905
+				}
1906 1906
 
1907
-                break;
1907
+				break;
1908 1908
 
1909
-            case 'field_seperator' :
1909
+			case 'field_seperator' :
1910 1910
 
1911
-                ?>
1911
+				?>
1912 1912
                 <tr valign="top">
1913 1913
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1914 1914
                 </tr>
1915 1915
                 <?php
1916 1916
 
1917
-                break;
1917
+				break;
1918 1918
 
1919
-        endswitch;
1919
+		endswitch;
1920 1920
 
1921
-    endforeach;
1921
+	endforeach;
1922 1922
 
1923
-    if ($first_title === false) {
1924
-        echo "</div>";
1925
-    }
1923
+	if ($first_title === false) {
1924
+		echo "</div>";
1925
+	}
1926 1926
 
1927
-    ?>
1927
+	?>
1928 1928
 
1929 1929
     <script type="text/javascript">
1930 1930
 
@@ -1984,33 +1984,33 @@  discard block
 block discarded – undo
1984 1984
  */
1985 1985
 function geodir_post_info_setting()
1986 1986
 {
1987
-    global $post, $post_id;
1988
-
1989
-    $post_type = get_post_type();
1990
-
1991
-    $package_info = array();
1992
-
1993
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1994
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1995
-    echo '<div id="geodir_wrapper">';
1996
-    /**
1997
-     * Called before the GD custom fields are output in the wp-admin area.
1998
-     *
1999
-     * @since 1.0.0
2000
-     * @see 'geodir_after_default_field_in_meta_box'
2001
-     */
2002
-    do_action('geodir_before_default_field_in_meta_box');
2003
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2004
-    // to display all fields in one information box
2005
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2006
-    /**
2007
-     * Called after the GD custom fields are output in the wp-admin area.
2008
-     *
2009
-     * @since 1.0.0
2010
-     * @see 'geodir_before_default_field_in_meta_box'
2011
-     */
2012
-    do_action('geodir_after_default_field_in_meta_box');
2013
-    echo '</div>';
1987
+	global $post, $post_id;
1988
+
1989
+	$post_type = get_post_type();
1990
+
1991
+	$package_info = array();
1992
+
1993
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1994
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1995
+	echo '<div id="geodir_wrapper">';
1996
+	/**
1997
+	 * Called before the GD custom fields are output in the wp-admin area.
1998
+	 *
1999
+	 * @since 1.0.0
2000
+	 * @see 'geodir_after_default_field_in_meta_box'
2001
+	 */
2002
+	do_action('geodir_before_default_field_in_meta_box');
2003
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2004
+	// to display all fields in one information box
2005
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2006
+	/**
2007
+	 * Called after the GD custom fields are output in the wp-admin area.
2008
+	 *
2009
+	 * @since 1.0.0
2010
+	 * @see 'geodir_before_default_field_in_meta_box'
2011
+	 */
2012
+	do_action('geodir_after_default_field_in_meta_box');
2013
+	echo '</div>';
2014 2014
 }
2015 2015
 
2016 2016
 /**
@@ -2023,18 +2023,18 @@  discard block
 block discarded – undo
2023 2023
  */
2024 2024
 function geodir_post_addinfo_setting()
2025 2025
 {
2026
-    global $post, $post_id;
2026
+	global $post, $post_id;
2027 2027
 
2028
-    $post_type = get_post_type();
2028
+	$post_type = get_post_type();
2029 2029
 
2030
-    $package_info = array();
2030
+	$package_info = array();
2031 2031
 
2032
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2032
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2033 2033
 
2034
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2035
-    echo '<div id="geodir_wrapper">';
2036
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2037
-    echo '</div>';
2034
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2035
+	echo '<div id="geodir_wrapper">';
2036
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2037
+	echo '</div>';
2038 2038
 
2039 2039
 }
2040 2040
 
@@ -2048,60 +2048,60 @@  discard block
 block discarded – undo
2048 2048
  */
2049 2049
 function geodir_post_attachments()
2050 2050
 {
2051
-    global $post, $post_id;
2051
+	global $post, $post_id;
2052 2052
 
2053
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2053
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2054 2054
 
2055
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
2056
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2057
-        geodir_show_featured_image($post_id, 'thumbnail');
2058
-    }
2055
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
2056
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2057
+		geodir_show_featured_image($post_id, 'thumbnail');
2058
+	}
2059 2059
 
2060
-    $image_limit = 0;
2060
+	$image_limit = 0;
2061 2061
 
2062
-    ?>
2062
+	?>
2063 2063
 
2064 2064
 
2065 2065
     <h5 class="form_title">
2066 2066
         <?php if ($image_limit != 0 && $image_limit == 1) {
2067
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2068
-        } ?>
2067
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2068
+		} ?>
2069 2069
         <?php if ($image_limit != 0 && $image_limit > 1) {
2070
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2071
-        } ?>
2070
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2071
+		} ?>
2072 2072
         <?php if ($image_limit == 0) {
2073
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2074
-        } ?>
2073
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2074
+		} ?>
2075 2075
     </h5>
2076 2076
 
2077 2077
 
2078 2078
     <?php
2079 2079
 
2080
-    $curImages = geodir_get_images($post_id);
2081
-    $place_img_array = array();
2080
+	$curImages = geodir_get_images($post_id);
2081
+	$place_img_array = array();
2082 2082
 
2083
-    if (!empty($curImages)):
2084
-        foreach ($curImages as $p_img):
2085
-            $place_img_array[] = $p_img->src;
2086
-        endforeach;
2087
-    endif;
2083
+	if (!empty($curImages)):
2084
+		foreach ($curImages as $p_img):
2085
+			$place_img_array[] = $p_img->src;
2086
+		endforeach;
2087
+	endif;
2088 2088
 
2089
-    if (!empty($place_img_array))
2090
-        $curImages = implode(',', $place_img_array);
2089
+	if (!empty($place_img_array))
2090
+		$curImages = implode(',', $place_img_array);
2091 2091
 
2092 2092
 
2093
-    // adjust values here
2094
-    $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
2093
+	// adjust values here
2094
+	$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
2095 2095
 
2096
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2096
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
2097 2097
 
2098
-    $multiple = true; // allow multiple files upload
2098
+	$multiple = true; // allow multiple files upload
2099 2099
 
2100
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2100
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2101 2101
 
2102
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2102
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2103 2103
 
2104
-    ?>
2104
+	?>
2105 2105
 
2106 2106
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
2107 2107
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -2143,13 +2143,13 @@  discard block
 block discarded – undo
2143 2143
  */
2144 2144
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
2145 2145
 {
2146
-    $post_type = get_post_type($post_ID);
2146
+	$post_type = get_post_type($post_ID);
2147 2147
 
2148
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2149
-        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) {
2150
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2151
-        }
2152
-    }
2148
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2149
+		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) {
2150
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2151
+		}
2152
+	}
2153 2153
 }
2154 2154
 
2155 2155
 /**
@@ -2164,39 +2164,39 @@  discard block
 block discarded – undo
2164 2164
  */
2165 2165
 function geodir_notification_add_bcc_option($settings)
2166 2166
 {
2167
-    if (!empty($settings)) {
2168
-        $new_settings = array();
2169
-        foreach ($settings as $setting) {
2170
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2171
-                $geodir_bcc_listing_published_yes = array(
2172
-                    'name' => __('Listing published', 'geodirectory'),
2173
-                    'desc' => __('Yes', 'geodirectory'),
2174
-                    'id' => 'geodir_bcc_listing_published',
2175
-                    'std' => 'yes',
2176
-                    'type' => 'radio',
2177
-                    'value' => '1',
2178
-                    'radiogroup' => 'start'
2179
-                );
2180
-
2181
-                $geodir_bcc_listing_published_no = array(
2182
-                    'name' => __('Listing published', 'geodirectory'),
2183
-                    'desc' => __('No', 'geodirectory'),
2184
-                    'id' => 'geodir_bcc_listing_published',
2185
-                    'std' => 'yes',
2186
-                    'type' => 'radio',
2187
-                    'value' => '0',
2188
-                    'radiogroup' => 'end'
2189
-                );
2190
-
2191
-                $new_settings[] = $geodir_bcc_listing_published_yes;
2192
-                $new_settings[] = $geodir_bcc_listing_published_no;
2193
-            }
2194
-            $new_settings[] = $setting;
2195
-        }
2196
-        $settings = $new_settings;
2197
-    }
2167
+	if (!empty($settings)) {
2168
+		$new_settings = array();
2169
+		foreach ($settings as $setting) {
2170
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2171
+				$geodir_bcc_listing_published_yes = array(
2172
+					'name' => __('Listing published', 'geodirectory'),
2173
+					'desc' => __('Yes', 'geodirectory'),
2174
+					'id' => 'geodir_bcc_listing_published',
2175
+					'std' => 'yes',
2176
+					'type' => 'radio',
2177
+					'value' => '1',
2178
+					'radiogroup' => 'start'
2179
+				);
2180
+
2181
+				$geodir_bcc_listing_published_no = array(
2182
+					'name' => __('Listing published', 'geodirectory'),
2183
+					'desc' => __('No', 'geodirectory'),
2184
+					'id' => 'geodir_bcc_listing_published',
2185
+					'std' => 'yes',
2186
+					'type' => 'radio',
2187
+					'value' => '0',
2188
+					'radiogroup' => 'end'
2189
+				);
2190
+
2191
+				$new_settings[] = $geodir_bcc_listing_published_yes;
2192
+				$new_settings[] = $geodir_bcc_listing_published_no;
2193
+			}
2194
+			$new_settings[] = $setting;
2195
+		}
2196
+		$settings = $new_settings;
2197
+	}
2198 2198
 
2199
-    return $settings;
2199
+	return $settings;
2200 2200
 }
2201 2201
 
2202 2202
 
@@ -2211,19 +2211,19 @@  discard block
 block discarded – undo
2211 2211
  */
2212 2212
 function get_gd_theme_compat_callback()
2213 2213
 {
2214
-    global $wpdb;
2215
-    $themes = get_option('gd_theme_compats');
2216
-
2217
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2218
-        if (isset($_POST['export'])) {
2219
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2220
-        } else {
2221
-            echo json_encode($themes[$_POST['theme']]);
2222
-        }
2214
+	global $wpdb;
2215
+	$themes = get_option('gd_theme_compats');
2223 2216
 
2224
-    }
2217
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2218
+		if (isset($_POST['export'])) {
2219
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2220
+		} else {
2221
+			echo json_encode($themes[$_POST['theme']]);
2222
+		}
2223
+
2224
+	}
2225 2225
 
2226
-    die();
2226
+	die();
2227 2227
 }
2228 2228
 
2229 2229
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -2237,20 +2237,20 @@  discard block
 block discarded – undo
2237 2237
  */
2238 2238
 function get_gd_theme_compat_import_callback()
2239 2239
 {
2240
-    global $wpdb;
2241
-    $themes = get_option('gd_theme_compats');
2242
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2243
-        $json = json_decode(stripslashes($_POST['theme']), true);
2244
-        if (!empty($json) && is_array($json)) {
2245
-            $key = sanitize_text_field(key($json));
2246
-            $themes[$key] = $json[$key];
2247
-            update_option('gd_theme_compats', $themes);
2248
-            echo $key;
2249
-            die();
2250
-        }
2251
-    }
2252
-    echo '0';
2253
-    die();
2240
+	global $wpdb;
2241
+	$themes = get_option('gd_theme_compats');
2242
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2243
+		$json = json_decode(stripslashes($_POST['theme']), true);
2244
+		if (!empty($json) && is_array($json)) {
2245
+			$key = sanitize_text_field(key($json));
2246
+			$themes[$key] = $json[$key];
2247
+			update_option('gd_theme_compats', $themes);
2248
+			echo $key;
2249
+			die();
2250
+		}
2251
+	}
2252
+	echo '0';
2253
+	die();
2254 2254
 }
2255 2255
 
2256 2256
 
@@ -2263,39 +2263,39 @@  discard block
 block discarded – undo
2263 2263
  */
2264 2264
 function gd_set_theme_compat()
2265 2265
 {
2266
-    global $wpdb;
2267
-    $theme = wp_get_theme();
2266
+	global $wpdb;
2267
+	$theme = wp_get_theme();
2268 2268
 
2269
-    if ($theme->parent()) {
2270
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2271
-    } else {
2272
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
2273
-    }
2269
+	if ($theme->parent()) {
2270
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2271
+	} else {
2272
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
2273
+	}
2274 2274
 
2275
-    $theme_compats = get_option('gd_theme_compats');
2276
-    $current_compat = get_option('gd_theme_compat');
2277
-    $current_compat = str_replace("_custom", "", $current_compat);
2275
+	$theme_compats = get_option('gd_theme_compats');
2276
+	$current_compat = get_option('gd_theme_compat');
2277
+	$current_compat = str_replace("_custom", "", $current_compat);
2278 2278
 
2279
-    if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2280
-        return;
2281
-    }// if already running correct compat then bail
2279
+	if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2280
+		return;
2281
+	}// if already running correct compat then bail
2282 2282
 
2283
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2284
-        update_option('gd_theme_compat', $theme_name);
2285
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2283
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2284
+		update_option('gd_theme_compat', $theme_name);
2285
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2286 2286
 
2287
-        // if there are default options to set then set them
2288
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2287
+		// if there are default options to set then set them
2288
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2289 2289
 
2290
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2291
-                update_option($key, $val);
2292
-            }
2293
-        }
2290
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2291
+				update_option($key, $val);
2292
+			}
2293
+		}
2294 2294
 
2295
-    } else {
2296
-        update_option('gd_theme_compat', '');
2297
-        update_option('theme_compatibility_setting', '');
2298
-    }
2295
+	} else {
2296
+		update_option('gd_theme_compat', '');
2297
+		update_option('theme_compatibility_setting', '');
2298
+	}
2299 2299
 
2300 2300
 
2301 2301
 }
@@ -2310,9 +2310,9 @@  discard block
 block discarded – undo
2310 2310
  */
2311 2311
 function gd_check_avada_compat()
2312 2312
 {
2313
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2314
-        add_action('admin_notices', 'gd_avada_compat_warning');
2315
-    }
2313
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2314
+		add_action('admin_notices', 'gd_avada_compat_warning');
2315
+	}
2316 2316
 }
2317 2317
 
2318 2318
 
@@ -2325,22 +2325,22 @@  discard block
 block discarded – undo
2325 2325
 function gd_avada_compat_warning()
2326 2326
 {
2327 2327
 
2328
-    /*
2328
+	/*
2329 2329
     $msg_type = error
2330 2330
     $msg_type = updated fade
2331 2331
     $msg_type = update-nag
2332 2332
     */
2333 2333
 
2334
-    $plugin = 'avada-nag';
2335
-    $timestamp = 'avada-nag1234';
2336
-    $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');
2337
-    echo '<div id="' . $timestamp . '"  class="error">';
2338
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2339
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2340
-    echo "<p>$message</p>";
2341
-    echo "</div>";
2334
+	$plugin = 'avada-nag';
2335
+	$timestamp = 'avada-nag1234';
2336
+	$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');
2337
+	echo '<div id="' . $timestamp . '"  class="error">';
2338
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2339
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2340
+	echo "<p>$message</p>";
2341
+	echo "</div>";
2342 2342
 
2343
-    ?>
2343
+	?>
2344 2344
     <script>
2345 2345
         function gdRemoveANotification($plugin, $timestamp) {
2346 2346
 
@@ -2408,10 +2408,10 @@  discard block
 block discarded – undo
2408 2408
  */
2409 2409
 function geodir_avada_remove_notification()
2410 2410
 {
2411
-    update_option('avada_nag', TRUE);
2411
+	update_option('avada_nag', TRUE);
2412 2412
 
2413
-    // Always die in functions echoing ajax content
2414
-    die();
2413
+	// Always die in functions echoing ajax content
2414
+	die();
2415 2415
 }
2416 2416
 
2417 2417
 
@@ -2433,9 +2433,9 @@  discard block
 block discarded – undo
2433 2433
 	global $post, $typenow, $current_screen;
2434 2434
 	
2435 2435
 	$post_type = NULL;
2436
-    if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2436
+	if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2437 2437
 		$post_type = get_post_type($_REQUEST['post']);
2438
-    elseif ($post && isset($post->post_type))
2438
+	elseif ($post && isset($post->post_type))
2439 2439
 		$post_type = $post->post_type;
2440 2440
 	elseif ($typenow)
2441 2441
 		$post_type = $typenow;
@@ -2470,7 +2470,7 @@  discard block
 block discarded – undo
2470 2470
 		// Don't allow same slug url for listing and location
2471 2471
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2472 2472
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2473
-        	wp_redirect($redirect_url);
2473
+			wp_redirect($redirect_url);
2474 2474
 			exit;
2475 2475
 		}
2476 2476
 		
@@ -2500,10 +2500,10 @@  discard block
 block discarded – undo
2500 2500
  * @package GeoDirectory
2501 2501
  */
2502 2502
 function geodir_hide_admin_preview_button() {
2503
-    global $post_type;
2504
-    $post_types = geodir_get_posttypes();
2505
-    if(in_array($post_type, $post_types))
2506
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2503
+	global $post_type;
2504
+	$post_types = geodir_get_posttypes();
2505
+	if(in_array($post_type, $post_types))
2506
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2507 2507
 }
2508 2508
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2509 2509
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
  */
2519 2519
 function geodir_import_export_tab( $tabs ) {
2520 2520
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2521
-    return $tabs;
2521
+	return $tabs;
2522 2522
 }
2523 2523
 
2524 2524
 /**
@@ -2533,26 +2533,26 @@  discard block
 block discarded – undo
2533 2533
 function geodir_import_export_page() {
2534 2534
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2535 2535
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2536
-    /**
2537
-     * Filter sample category data csv file url.
2538
-     *
2539
-     * @since 1.0.0
2540
-     * @package GeoDirectory
2541
-     *
2542
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2543
-     */
2536
+	/**
2537
+	 * Filter sample category data csv file url.
2538
+	 *
2539
+	 * @since 1.0.0
2540
+	 * @package GeoDirectory
2541
+	 *
2542
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2543
+	 */
2544 2544
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2545 2545
 	
2546 2546
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2547
-    /**
2548
-     * Filter sample post data csv file url.
2549
-     *
2550
-     * @since 1.0.0
2551
-     * @package GeoDirectory
2552
-     *
2553
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2554
-     */
2555
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2547
+	/**
2548
+	 * Filter sample post data csv file url.
2549
+	 *
2550
+	 * @since 1.0.0
2551
+	 * @package GeoDirectory
2552
+	 *
2553
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2554
+	 */
2555
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2556 2556
 	
2557 2557
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2558 2558
 	
@@ -2575,14 +2575,14 @@  discard block
 block discarded – undo
2575 2575
 	$gd_chunksize_options[100000] = 100000;
2576 2576
 	 
2577 2577
 	 /**
2578
-     * Filter max entries per export csv file.
2579
-     *
2580
-     * @since 1.5.6
2581
-     * @package GeoDirectory
2582
-     *
2583
-     * @param string $gd_chunksize_options Entries options.
2584
-     */
2585
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2578
+	  * Filter max entries per export csv file.
2579
+	  *
2580
+	  * @since 1.5.6
2581
+	  * @package GeoDirectory
2582
+	  *
2583
+	  * @param string $gd_chunksize_options Entries options.
2584
+	  */
2585
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2586 2586
 	
2587 2587
 	$gd_chunksize_option = '';
2588 2588
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2598,12 +2598,12 @@  discard block
 block discarded – undo
2598 2598
   <div class="gd-content-heading">
2599 2599
 
2600 2600
   <?php
2601
-    ini_set('max_execution_time', 999999);
2602
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2603
-    ini_restore('max_execution_time');
2601
+	ini_set('max_execution_time', 999999);
2602
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2603
+	ini_restore('max_execution_time');
2604 2604
 
2605
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2606
-        ?>
2605
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2606
+		?>
2607 2607
 	<div id="gd_ie_reqs" class="metabox-holder">
2608 2608
       <div class="meta-box-sortables ui-sortable">
2609 2609
         <div class="postbox">
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
 						 * Called just after the sample CSV download link.
2773 2773
 						 *
2774 2774
 						 * @since 1.0.0
2775
-                         * @package GeoDirectory
2775
+						 * @package GeoDirectory
2776 2776
 						 */
2777 2777
 						do_action('geodir_sample_cats_csv_download_link');
2778 2778
 						?>
@@ -2857,11 +2857,11 @@  discard block
 block discarded – undo
2857 2857
 	 *
2858 2858
 	 * Called after the last setting on the GD > Import & Export page.
2859 2859
 	 * @since 1.4.6
2860
-     * @package GeoDirectory
2860
+	 * @package GeoDirectory
2861 2861
 	 *
2862 2862
 	 * @param array $gd_posttypes GD post types.
2863
-     * @param array $gd_chunksize_options File chunk size options.
2864
-     * @param string $nonce Wordpress security token for GD import & export.
2863
+	 * @param array $gd_chunksize_options File chunk size options.
2864
+	 * @param string $nonce Wordpress security token for GD import & export.
2865 2865
 	 */
2866 2866
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2867 2867
 	?>
@@ -3526,44 +3526,44 @@  discard block
 block discarded – undo
3526 3526
 function geodir_init_filesystem()
3527 3527
 {
3528 3528
 
3529
-    if(!function_exists('get_filesystem_method')){
3530
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3531
-    }
3532
-    $access_type = get_filesystem_method();
3533
-    if ($access_type === 'direct') {
3534
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3535
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3536
-
3537
-        /* initialize the API */
3538
-        if (!WP_Filesystem($creds)) {
3539
-            /* any problems and we exit */
3540
-            //return '@@@3';
3541
-            return false;
3542
-        }
3543
-
3544
-        global $wp_filesystem;
3545
-        return $wp_filesystem;
3546
-        /* do our file manipulations below */
3547
-    } elseif (defined('FTP_USER')) {
3548
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3529
+	if(!function_exists('get_filesystem_method')){
3530
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3531
+	}
3532
+	$access_type = get_filesystem_method();
3533
+	if ($access_type === 'direct') {
3534
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3535
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3536
+
3537
+		/* initialize the API */
3538
+		if (!WP_Filesystem($creds)) {
3539
+			/* any problems and we exit */
3540
+			//return '@@@3';
3541
+			return false;
3542
+		}
3549 3543
 
3550
-        /* initialize the API */
3551
-        if (!WP_Filesystem($creds)) {
3552
-            /* any problems and we exit */
3553
-            //return '@@@33';
3554
-            return false;
3555
-        }
3544
+		global $wp_filesystem;
3545
+		return $wp_filesystem;
3546
+		/* do our file manipulations below */
3547
+	} elseif (defined('FTP_USER')) {
3548
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3549
+
3550
+		/* initialize the API */
3551
+		if (!WP_Filesystem($creds)) {
3552
+			/* any problems and we exit */
3553
+			//return '@@@33';
3554
+			return false;
3555
+		}
3556 3556
 
3557
-        global $wp_filesystem;
3558
-        //return '@@@1';
3559
-        return $wp_filesystem;
3557
+		global $wp_filesystem;
3558
+		//return '@@@1';
3559
+		return $wp_filesystem;
3560 3560
 
3561
-    } else {
3562
-        //return '@@@2';
3563
-        /* don't have direct write access. Prompt user with our notice */
3564
-        add_action('admin_notice', 'geodir_filesystem_notice');
3565
-        return false;
3566
-    }
3561
+	} else {
3562
+		//return '@@@2';
3563
+		/* don't have direct write access. Prompt user with our notice */
3564
+		add_action('admin_notice', 'geodir_filesystem_notice');
3565
+		return false;
3566
+	}
3567 3567
 
3568 3568
 }
3569 3569
 
@@ -3581,10 +3581,10 @@  discard block
 block discarded – undo
3581 3581
  */
3582 3582
 function geodir_filesystem_notice()
3583 3583
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3584
-    $access_type = get_filesystem_method();
3585
-    if ($access_type === 'direct') {
3586
-    } elseif (!defined('FTP_USER')) {
3587
-        ?>
3584
+	$access_type = get_filesystem_method();
3585
+	if ($access_type === 'direct') {
3586
+	} elseif (!defined('FTP_USER')) {
3587
+		?>
3588 3588
         <div class="error">
3589 3589
             <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'); ?>
3590 3590
                 <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>
@@ -3610,1514 +3610,1514 @@  discard block
 block discarded – undo
3610 3610
  * @return string Json data.
3611 3611
  */
3612 3612
 function geodir_ajax_import_export() {
3613
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3613
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3614 3614
     
3615
-    error_reporting(0);
3615
+	error_reporting(0);
3616 3616
 
3617
-    // try to set higher limits for import
3618
-    $max_input_time = ini_get('max_input_time');
3619
-    $max_execution_time = ini_get('max_execution_time');
3620
-    $memory_limit= ini_get('memory_limit');
3617
+	// try to set higher limits for import
3618
+	$max_input_time = ini_get('max_input_time');
3619
+	$max_execution_time = ini_get('max_execution_time');
3620
+	$memory_limit= ini_get('memory_limit');
3621 3621
 
3622
-    if(!$max_input_time || $max_input_time<3000){
3623
-        ini_set('max_input_time', 3000);
3624
-    }
3622
+	if(!$max_input_time || $max_input_time<3000){
3623
+		ini_set('max_input_time', 3000);
3624
+	}
3625 3625
 
3626
-    if(!$max_execution_time || $max_execution_time<3000){
3627
-        ini_set('max_execution_time', 3000);
3628
-    }
3626
+	if(!$max_execution_time || $max_execution_time<3000){
3627
+		ini_set('max_execution_time', 3000);
3628
+	}
3629 3629
 
3630
-    if($memory_limit && str_replace('M','',$memory_limit)){
3631
-        if(str_replace('M','',$memory_limit)<256){
3632
-            ini_set('memory_limit', '256M');
3633
-        }
3634
-    }
3630
+	if($memory_limit && str_replace('M','',$memory_limit)){
3631
+		if(str_replace('M','',$memory_limit)<256){
3632
+			ini_set('memory_limit', '256M');
3633
+		}
3634
+	}
3635 3635
 
3636
-    $json = array();
3636
+	$json = array();
3637 3637
 
3638
-    if ( !current_user_can( 'manage_options' ) ) {
3639
-        wp_send_json( $json );
3640
-    }
3638
+	if ( !current_user_can( 'manage_options' ) ) {
3639
+		wp_send_json( $json );
3640
+	}
3641 3641
 
3642
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3643
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3644
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3642
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3643
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3644
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3645 3645
 
3646
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3647
-        wp_send_json( $json );
3648
-    }
3646
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3647
+		wp_send_json( $json );
3648
+	}
3649 3649
 
3650
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3651
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3652
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3653
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3650
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3651
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3652
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3653
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3654 3654
 
3655
-    $wp_filesystem = geodir_init_filesystem();
3656
-    if (!$wp_filesystem) {
3657
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3658
-        wp_send_json( $json );
3659
-    }
3655
+	$wp_filesystem = geodir_init_filesystem();
3656
+	if (!$wp_filesystem) {
3657
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3658
+		wp_send_json( $json );
3659
+	}
3660 3660
 
3661
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3662
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3663
-        wp_send_json( $json );
3664
-    }
3661
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3662
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3663
+		wp_send_json( $json );
3664
+	}
3665 3665
 
3666
-    $csv_file_dir = geodir_path_import_export( false );
3667
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3668
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3669
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3670
-            wp_send_json( $json );
3671
-        }
3672
-    }
3666
+	$csv_file_dir = geodir_path_import_export( false );
3667
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3668
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3669
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3670
+			wp_send_json( $json );
3671
+		}
3672
+	}
3673 3673
     
3674
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3675
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3676
-
3677
-    switch ( $task ) {
3678
-        case 'export_posts': {
3679
-            // WPML
3680
-            $is_wpml = geodir_is_wpml();
3681
-            if ($is_wpml) {
3682
-                global $sitepress;
3683
-                $active_lang = ICL_LANGUAGE_CODE;
3674
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3675
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3676
+
3677
+	switch ( $task ) {
3678
+		case 'export_posts': {
3679
+			// WPML
3680
+			$is_wpml = geodir_is_wpml();
3681
+			if ($is_wpml) {
3682
+				global $sitepress;
3683
+				$active_lang = ICL_LANGUAGE_CODE;
3684 3684
                 
3685
-                $sitepress->switch_lang('all', true);
3686
-            }
3687
-            // WPML
3688
-            if ( $post_type == 'gd_event' ) {
3689
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3690
-            }
3691
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3692
-            $posts_count = geodir_get_posts_count( $post_type );
3693
-            $file_url_base = geodir_path_import_export() . '/';
3694
-            $file_url = $file_url_base . $file_name . '.csv';
3695
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3696
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3685
+				$sitepress->switch_lang('all', true);
3686
+			}
3687
+			// WPML
3688
+			if ( $post_type == 'gd_event' ) {
3689
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3690
+			}
3691
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3692
+			$posts_count = geodir_get_posts_count( $post_type );
3693
+			$file_url_base = geodir_path_import_export() . '/';
3694
+			$file_url = $file_url_base . $file_name . '.csv';
3695
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3696
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3697 3697
             
3698
-            $chunk_file_paths = array();
3698
+			$chunk_file_paths = array();
3699 3699
 
3700
-            if ( isset( $_REQUEST['_st'] ) ) {
3701
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3702
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3703
-                $percentage = min( $percentage, 100 );
3700
+			if ( isset( $_REQUEST['_st'] ) ) {
3701
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3702
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3703
+				$percentage = min( $percentage, 100 );
3704 3704
                 
3705
-                $json['percentage'] = $percentage;
3706
-                // WPML
3707
-                if ($is_wpml) {
3708
-                    $sitepress->switch_lang($active_lang, true);
3709
-                }
3710
-                // WPML
3711
-                wp_send_json( $json );
3712
-                gd_die();
3713
-            } else {
3714
-                if ( !$posts_count > 0 ) {
3715
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3716
-                } else {
3717
-                    $total_posts = $posts_count;
3718
-                    if ($chunk_per_page > $total_posts) {
3719
-                        $chunk_per_page = $total_posts;
3720
-                    }
3721
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3705
+				$json['percentage'] = $percentage;
3706
+				// WPML
3707
+				if ($is_wpml) {
3708
+					$sitepress->switch_lang($active_lang, true);
3709
+				}
3710
+				// WPML
3711
+				wp_send_json( $json );
3712
+				gd_die();
3713
+			} else {
3714
+				if ( !$posts_count > 0 ) {
3715
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3716
+				} else {
3717
+					$total_posts = $posts_count;
3718
+					if ($chunk_per_page > $total_posts) {
3719
+						$chunk_per_page = $total_posts;
3720
+					}
3721
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3722 3722
                     
3723
-                    $j = $chunk_page_no;
3724
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3723
+					$j = $chunk_page_no;
3724
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3725 3725
                     
3726
-                    $per_page = 500;
3727
-                    if ($per_page > $chunk_per_page) {
3728
-                        $per_page = $chunk_per_page;
3729
-                    }
3730
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3726
+					$per_page = 500;
3727
+					if ($per_page > $chunk_per_page) {
3728
+						$per_page = $chunk_per_page;
3729
+					}
3730
+					$total_pages = ceil( $chunk_per_page / $per_page );
3731 3731
                     
3732
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3733
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3732
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3733
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3734 3734
                         
3735
-                        $clear = $i == 0 ? true : false;
3736
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3737
-                    }
3735
+						$clear = $i == 0 ? true : false;
3736
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3737
+					}
3738 3738
                         
3739
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3740
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3741
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3742
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3743
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3739
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3740
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3741
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3742
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3743
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3744 3744
                         
3745
-                        $file_url = $file_url_base . $chunk_file_name;
3746
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3747
-                    }
3745
+						$file_url = $file_url_base . $chunk_file_name;
3746
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3747
+					}
3748 3748
                     
3749
-                    if ( !empty($chunk_file_paths) ) {
3750
-                        $json['total'] = $posts_count;
3751
-                        $json['files'] = $chunk_file_paths;
3752
-                    } else {
3753
-                        if ($j > 1) {
3754
-                            $json['total'] = $posts_count;
3755
-                            $json['files'] = array();
3756
-                        } else {
3757
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3758
-                        }
3759
-                    }
3760
-                }
3761
-                // WPML
3762
-                if ($is_wpml) {
3763
-                    $sitepress->switch_lang($active_lang, true);
3764
-                }
3765
-                // WPML
3766
-                wp_send_json( $json );
3767
-            }
3768
-        }
3769
-        break;
3770
-        case 'export_cats': {
3771
-            // WPML
3772
-            $is_wpml = geodir_is_wpml();
3773
-            if ($is_wpml) {
3774
-                global $sitepress;
3775
-                $active_lang = ICL_LANGUAGE_CODE;
3749
+					if ( !empty($chunk_file_paths) ) {
3750
+						$json['total'] = $posts_count;
3751
+						$json['files'] = $chunk_file_paths;
3752
+					} else {
3753
+						if ($j > 1) {
3754
+							$json['total'] = $posts_count;
3755
+							$json['files'] = array();
3756
+						} else {
3757
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3758
+						}
3759
+					}
3760
+				}
3761
+				// WPML
3762
+				if ($is_wpml) {
3763
+					$sitepress->switch_lang($active_lang, true);
3764
+				}
3765
+				// WPML
3766
+				wp_send_json( $json );
3767
+			}
3768
+		}
3769
+		break;
3770
+		case 'export_cats': {
3771
+			// WPML
3772
+			$is_wpml = geodir_is_wpml();
3773
+			if ($is_wpml) {
3774
+				global $sitepress;
3775
+				$active_lang = ICL_LANGUAGE_CODE;
3776 3776
                 
3777
-                $sitepress->switch_lang('all', true);
3778
-            }
3779
-            // WPML
3780
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3777
+				$sitepress->switch_lang('all', true);
3778
+			}
3779
+			// WPML
3780
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3781 3781
             
3782
-            $terms_count = geodir_get_terms_count( $post_type );
3783
-            $file_url_base = geodir_path_import_export() . '/';
3784
-            $file_url = $file_url_base . $file_name . '.csv';
3785
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3786
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3782
+			$terms_count = geodir_get_terms_count( $post_type );
3783
+			$file_url_base = geodir_path_import_export() . '/';
3784
+			$file_url = $file_url_base . $file_name . '.csv';
3785
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3786
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3787 3787
             
3788
-            $chunk_file_paths = array();
3788
+			$chunk_file_paths = array();
3789 3789
             
3790
-            if ( isset( $_REQUEST['_st'] ) ) {
3791
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3792
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3793
-                $percentage = min( $percentage, 100 );
3790
+			if ( isset( $_REQUEST['_st'] ) ) {
3791
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3792
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3793
+				$percentage = min( $percentage, 100 );
3794 3794
                 
3795
-                $json['percentage'] = $percentage;
3796
-                // WPML
3797
-                if ($is_wpml) {
3798
-                    $sitepress->switch_lang($active_lang, true);
3799
-                }
3800
-                // WPML
3801
-                wp_send_json( $json );
3802
-            } else {
3803
-                if ( !$terms_count > 0 ) {
3804
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3805
-                } else {
3806
-                    $total_terms = $terms_count;
3807
-                    if ($chunk_per_page > $terms_count) {
3808
-                        $chunk_per_page = $terms_count;
3809
-                    }
3810
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3795
+				$json['percentage'] = $percentage;
3796
+				// WPML
3797
+				if ($is_wpml) {
3798
+					$sitepress->switch_lang($active_lang, true);
3799
+				}
3800
+				// WPML
3801
+				wp_send_json( $json );
3802
+			} else {
3803
+				if ( !$terms_count > 0 ) {
3804
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3805
+				} else {
3806
+					$total_terms = $terms_count;
3807
+					if ($chunk_per_page > $terms_count) {
3808
+						$chunk_per_page = $terms_count;
3809
+					}
3810
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3811 3811
                     
3812
-                    $j = $chunk_page_no;
3813
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3812
+					$j = $chunk_page_no;
3813
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3814 3814
                     
3815
-                    $per_page = 500;
3816
-                    if ($per_page > $chunk_per_page) {
3817
-                        $per_page = $chunk_per_page;
3818
-                    }
3819
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3815
+					$per_page = 500;
3816
+					if ($per_page > $chunk_per_page) {
3817
+						$per_page = $chunk_per_page;
3818
+					}
3819
+					$total_pages = ceil( $chunk_per_page / $per_page );
3820 3820
                     
3821
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3822
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3821
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3822
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3823 3823
                         
3824
-                        $clear = $i == 0 ? true : false;
3825
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3826
-                    }
3824
+						$clear = $i == 0 ? true : false;
3825
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3826
+					}
3827 3827
                     
3828
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3829
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3830
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3831
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3832
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3828
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3829
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3830
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3831
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3832
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3833 3833
                         
3834
-                        $file_url = $file_url_base . $chunk_file_name;
3835
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3836
-                    }
3834
+						$file_url = $file_url_base . $chunk_file_name;
3835
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3836
+					}
3837 3837
                     
3838
-                    if ( !empty($chunk_file_paths) ) {
3839
-                        $json['total'] = $terms_count;
3840
-                        $json['files'] = $chunk_file_paths;
3841
-                    } else {
3842
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3843
-                    }
3844
-                }
3845
-                // WPML
3846
-                if ($is_wpml) {
3847
-                    $sitepress->switch_lang($active_lang, true);
3848
-                }
3849
-                // WPML
3850
-                wp_send_json( $json );
3851
-            }
3852
-        }
3853
-        break;
3854
-        case 'export_locations': {
3855
-            $file_url_base = geodir_path_import_export() . '/';
3856
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3857
-            $file_url = $file_url_base . $file_name . '.csv';
3858
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3859
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3838
+					if ( !empty($chunk_file_paths) ) {
3839
+						$json['total'] = $terms_count;
3840
+						$json['files'] = $chunk_file_paths;
3841
+					} else {
3842
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3843
+					}
3844
+				}
3845
+				// WPML
3846
+				if ($is_wpml) {
3847
+					$sitepress->switch_lang($active_lang, true);
3848
+				}
3849
+				// WPML
3850
+				wp_send_json( $json );
3851
+			}
3852
+		}
3853
+		break;
3854
+		case 'export_locations': {
3855
+			$file_url_base = geodir_path_import_export() . '/';
3856
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3857
+			$file_url = $file_url_base . $file_name . '.csv';
3858
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3859
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3860 3860
             
3861
-            $items_count = (int)geodir_location_imex_count_locations();
3861
+			$items_count = (int)geodir_location_imex_count_locations();
3862 3862
             
3863
-            if ( isset( $_REQUEST['_st'] ) ) {
3864
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3865
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3866
-                $percentage = min( $percentage, 100 );
3863
+			if ( isset( $_REQUEST['_st'] ) ) {
3864
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3865
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3866
+				$percentage = min( $percentage, 100 );
3867 3867
                 
3868
-                $json['percentage'] = $percentage;
3869
-                wp_send_json( $json );
3870
-            } else {
3871
-                $chunk_file_paths = array();
3868
+				$json['percentage'] = $percentage;
3869
+				wp_send_json( $json );
3870
+			} else {
3871
+				$chunk_file_paths = array();
3872 3872
                 
3873
-                if ( !$items_count > 0 ) {
3874
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3875
-                } else {
3876
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3877
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3873
+				if ( !$items_count > 0 ) {
3874
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3875
+				} else {
3876
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3877
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3878 3878
                     
3879
-                    $j = $chunk_page_no;
3880
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3879
+					$j = $chunk_page_no;
3880
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3881 3881
                     
3882
-                    $per_page = 500;
3883
-                    $per_page = min( $per_page, $chunk_per_page );
3884
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3882
+					$per_page = 500;
3883
+					$per_page = min( $per_page, $chunk_per_page );
3884
+					$total_pages = ceil( $chunk_per_page / $per_page );
3885 3885
                     
3886
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3887
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3886
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3887
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3888 3888
                         
3889
-                        $clear = $i == 0 ? true : false;
3890
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3891
-                    }
3889
+						$clear = $i == 0 ? true : false;
3890
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3891
+					}
3892 3892
                     
3893
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3894
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3895
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3896
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3897
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3893
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3894
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3895
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3896
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3897
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3898 3898
                         
3899
-                        $file_url = $file_url_base . $chunk_file_name;
3900
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3901
-                    }
3899
+						$file_url = $file_url_base . $chunk_file_name;
3900
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3901
+					}
3902 3902
                     
3903
-                    if ( !empty($chunk_file_paths) ) {
3904
-                        $json['total'] = $items_count;
3905
-                        $json['files'] = $chunk_file_paths;
3906
-                    } else {
3907
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3908
-                    }
3909
-                }
3910
-                wp_send_json( $json );
3911
-            }
3912
-        }
3913
-        break;
3914
-        case 'export_hoods': {
3915
-            $file_url_base = geodir_path_import_export() . '/';
3916
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3917
-            $file_url = $file_url_base . $file_name . '.csv';
3918
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3919
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3903
+					if ( !empty($chunk_file_paths) ) {
3904
+						$json['total'] = $items_count;
3905
+						$json['files'] = $chunk_file_paths;
3906
+					} else {
3907
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3908
+					}
3909
+				}
3910
+				wp_send_json( $json );
3911
+			}
3912
+		}
3913
+		break;
3914
+		case 'export_hoods': {
3915
+			$file_url_base = geodir_path_import_export() . '/';
3916
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3917
+			$file_url = $file_url_base . $file_name . '.csv';
3918
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3919
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3920 3920
             
3921
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3921
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3922 3922
             
3923
-            if ( isset( $_REQUEST['_st'] ) ) {
3924
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3925
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3926
-                $percentage = min( $percentage, 100 );
3923
+			if ( isset( $_REQUEST['_st'] ) ) {
3924
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3925
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3926
+				$percentage = min( $percentage, 100 );
3927 3927
                 
3928
-                $json['percentage'] = $percentage;
3929
-                wp_send_json( $json );
3930
-            } else {
3931
-                $chunk_file_paths = array();
3928
+				$json['percentage'] = $percentage;
3929
+				wp_send_json( $json );
3930
+			} else {
3931
+				$chunk_file_paths = array();
3932 3932
                 
3933
-                if ( !$items_count > 0 ) {
3934
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3935
-                } else {
3936
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3937
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3933
+				if ( !$items_count > 0 ) {
3934
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3935
+				} else {
3936
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3937
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3938 3938
                     
3939
-                    $j = $chunk_page_no;
3940
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3939
+					$j = $chunk_page_no;
3940
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3941 3941
                     
3942
-                    $per_page = 500;
3943
-                    $per_page = min( $per_page, $chunk_per_page );
3944
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3942
+					$per_page = 500;
3943
+					$per_page = min( $per_page, $chunk_per_page );
3944
+					$total_pages = ceil( $chunk_per_page / $per_page );
3945 3945
                     
3946
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3947
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3946
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3947
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3948 3948
                         
3949
-                        $clear = $i == 0 ? true : false;
3950
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3951
-                    }
3949
+						$clear = $i == 0 ? true : false;
3950
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3951
+					}
3952 3952
                     
3953
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3954
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3955
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3956
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3957
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3953
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3954
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3955
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3956
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3957
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3958 3958
                         
3959
-                        $file_url = $file_url_base . $chunk_file_name;
3960
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3961
-                    }
3959
+						$file_url = $file_url_base . $chunk_file_name;
3960
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3961
+					}
3962 3962
                     
3963
-                    if ( !empty($chunk_file_paths) ) {
3964
-                        $json['total'] = $items_count;
3965
-                        $json['files'] = $chunk_file_paths;
3966
-                    } else {
3967
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3968
-                    }
3969
-                }
3970
-                wp_send_json( $json );
3971
-            }
3972
-        }
3973
-        break;
3974
-        case 'prepare_import':
3975
-        case 'import_cat':
3976
-        case 'import_post':
3977
-        case 'import_loc':
3978
-        case 'import_hood': {
3979
-            // WPML
3980
-            $is_wpml = geodir_is_wpml();
3981
-            if ($is_wpml) {
3982
-                global $sitepress;
3983
-                $active_lang = ICL_LANGUAGE_CODE;
3984
-            }
3985
-            // WPML
3963
+					if ( !empty($chunk_file_paths) ) {
3964
+						$json['total'] = $items_count;
3965
+						$json['files'] = $chunk_file_paths;
3966
+					} else {
3967
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3968
+					}
3969
+				}
3970
+				wp_send_json( $json );
3971
+			}
3972
+		}
3973
+		break;
3974
+		case 'prepare_import':
3975
+		case 'import_cat':
3976
+		case 'import_post':
3977
+		case 'import_loc':
3978
+		case 'import_hood': {
3979
+			// WPML
3980
+			$is_wpml = geodir_is_wpml();
3981
+			if ($is_wpml) {
3982
+				global $sitepress;
3983
+				$active_lang = ICL_LANGUAGE_CODE;
3984
+			}
3985
+			// WPML
3986 3986
             
3987
-            ini_set( 'auto_detect_line_endings', true );
3987
+			ini_set( 'auto_detect_line_endings', true );
3988 3988
             
3989
-            $uploads = wp_upload_dir();
3990
-            $uploads_dir = $uploads['path'];
3991
-            $uploads_subdir = $uploads['subdir'];
3989
+			$uploads = wp_upload_dir();
3990
+			$uploads_dir = $uploads['path'];
3991
+			$uploads_subdir = $uploads['subdir'];
3992 3992
             
3993
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3994
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3993
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3994
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3995 3995
             
3996
-            $csv_file_arr = explode( '/', $csv_file );
3997
-            $csv_filename = end( $csv_file_arr );
3998
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3996
+			$csv_file_arr = explode( '/', $csv_file );
3997
+			$csv_filename = end( $csv_file_arr );
3998
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3999 3999
             
4000
-            $json['file'] = $csv_file;
4001
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4002
-            $file = array();
4000
+			$json['file'] = $csv_file;
4001
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4002
+			$file = array();
4003 4003
 
4004
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4005
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4004
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4005
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4006 4006
                 
4007
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4008
-                    $json['error'] = NULL;
4009
-                    $json['rows'] = 0;
4007
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4008
+					$json['error'] = NULL;
4009
+					$json['rows'] = 0;
4010 4010
                     
4011
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4012
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4013
-                            if ( !empty( $data ) ) {
4014
-                                $file[] = $data;
4015
-                            }
4016
-                        }
4017
-                        fclose($handle);
4018
-                    }
4011
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4012
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4013
+							if ( !empty( $data ) ) {
4014
+								$file[] = $data;
4015
+							}
4016
+						}
4017
+						fclose($handle);
4018
+					}
4019 4019
 
4020
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4020
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4021 4021
                     
4022
-                    if (!$json['rows'] > 0) {
4023
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
4024
-                    }
4025
-                } else {
4026
-                    wp_send_json( $json );
4027
-                }
4028
-            } else {
4029
-                wp_send_json( $json );
4030
-            }
4022
+					if (!$json['rows'] > 0) {
4023
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
4024
+					}
4025
+				} else {
4026
+					wp_send_json( $json );
4027
+				}
4028
+			} else {
4029
+				wp_send_json( $json );
4030
+			}
4031 4031
             
4032
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4033
-                wp_send_json( $json );
4034
-            }
4032
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4033
+				wp_send_json( $json );
4034
+			}
4035 4035
             
4036
-            $total = $json['rows'];
4037
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4038
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4036
+			$total = $json['rows'];
4037
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4038
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4039 4039
             
4040
-            $count = $limit;
4040
+			$count = $limit;
4041 4041
             
4042
-            if ($count < $total) {
4043
-                $count = $processed + $count;
4044
-                if ($count > $total) {
4045
-                    $count = $total;
4046
-                }
4047
-            } else {
4048
-                $count = $total;
4049
-            }
4042
+			if ($count < $total) {
4043
+				$count = $processed + $count;
4044
+				if ($count > $total) {
4045
+					$count = $total;
4046
+				}
4047
+			} else {
4048
+				$count = $total;
4049
+			}
4050 4050
             
4051
-            $created = 0;
4052
-            $updated = 0;
4053
-            $skipped = 0;
4054
-            $invalid = 0;
4055
-            $invalid_addr = 0;
4056
-            $images = 0;
4051
+			$created = 0;
4052
+			$updated = 0;
4053
+			$skipped = 0;
4054
+			$invalid = 0;
4055
+			$invalid_addr = 0;
4056
+			$images = 0;
4057 4057
             
4058
-            $gd_post_info = array();
4059
-            $countpost = 0;
4058
+			$gd_post_info = array();
4059
+			$countpost = 0;
4060 4060
             
4061
-            $post_types = geodir_get_posttypes();
4061
+			$post_types = geodir_get_posttypes();
4062 4062
 
4063
-            if ( $task == 'import_cat' ) {
4064
-                if (!empty($file)) {
4065
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4063
+			if ( $task == 'import_cat' ) {
4064
+				if (!empty($file)) {
4065
+					$columns = isset($file[0]) ? $file[0] : NULL;
4066 4066
                     
4067
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4068
-                        $json['error'] = CSV_INVAILD_FILE;
4069
-                        wp_send_json( $json );
4070
-                        exit;
4071
-                    }
4067
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4068
+						$json['error'] = CSV_INVAILD_FILE;
4069
+						wp_send_json( $json );
4070
+						exit;
4071
+					}
4072 4072
                     
4073
-                    $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4073
+					$gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4074 4074
                     
4075
-                    for ($i = 1; $i <= $limit; $i++) {
4076
-                        $index = $processed + $i;
4075
+					for ($i = 1; $i <= $limit; $i++) {
4076
+						$index = $processed + $i;
4077 4077
                         
4078
-                        if (isset($file[$index])) {
4079
-                            $row = $file[$index];
4080
-                            $row = array_map( 'trim', $row );
4081
-                            //$row = array_map( 'utf8_encode', $row );
4078
+						if (isset($file[$index])) {
4079
+							$row = $file[$index];
4080
+							$row = array_map( 'trim', $row );
4081
+							//$row = array_map( 'utf8_encode', $row );
4082 4082
                             
4083
-                            $cat_id = '';
4084
-                            $cat_name = '';
4085
-                            $cat_slug = '';
4086
-                            $cat_posttype = '';
4087
-                            $cat_parent = '';
4088
-                            $cat_description = '';
4089
-                            $cat_schema = '';
4090
-                            $cat_top_description = '';
4091
-                            $cat_image = '';
4092
-                            $cat_icon = '';
4093
-                            $cat_language = '';
4094
-                            $cat_id_original = '';
4083
+							$cat_id = '';
4084
+							$cat_name = '';
4085
+							$cat_slug = '';
4086
+							$cat_posttype = '';
4087
+							$cat_parent = '';
4088
+							$cat_description = '';
4089
+							$cat_schema = '';
4090
+							$cat_top_description = '';
4091
+							$cat_image = '';
4092
+							$cat_icon = '';
4093
+							$cat_language = '';
4094
+							$cat_id_original = '';
4095 4095
                             
4096
-                            $c = 0;
4097
-                            foreach ($columns as $column ) {
4098
-                                if ( $column == 'cat_id' ) {
4099
-                                    $cat_id = (int)$row[$c];
4100
-                                } else if ( $column == 'cat_name' ) {
4101
-                                    $cat_name = $row[$c];
4102
-                                } else if ( $column == 'cat_slug' ) {
4103
-                                    $cat_slug = $row[$c];
4104
-                                } else if ( $column == 'cat_posttype' ) {
4105
-                                    $cat_posttype = $row[$c];
4106
-                                } else if ( $column == 'cat_parent' ) {
4107
-                                    $cat_parent = trim($row[$c]);
4108
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4109
-                                    $cat_schema = $row[$c];
4110
-                                } else if ( $column == 'cat_description' ) {
4111
-                                    $cat_description = $row[$c];
4112
-                                } else if ( $column == 'cat_top_description' ) {
4113
-                                    $cat_top_description = $row[$c];
4114
-                                } else if ( $column == 'cat_image' ) {
4115
-                                    $cat_image = $row[$c];
4116
-                                } else if ( $column == 'cat_icon' ) {
4117
-                                    $cat_icon = $row[$c];
4118
-                                }
4119
-                                // WPML
4120
-                                if ( $is_wpml ) {
4121
-                                    if ( $column == 'cat_language' ) {
4122
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4123
-                                    } else if ( $column == 'cat_id_original' ) {
4124
-                                        $cat_id_original = (int)$row[$c];
4125
-                                    }
4126
-                                }
4127
-                                // WPML
4128
-                                $c++;
4129
-                            }
4096
+							$c = 0;
4097
+							foreach ($columns as $column ) {
4098
+								if ( $column == 'cat_id' ) {
4099
+									$cat_id = (int)$row[$c];
4100
+								} else if ( $column == 'cat_name' ) {
4101
+									$cat_name = $row[$c];
4102
+								} else if ( $column == 'cat_slug' ) {
4103
+									$cat_slug = $row[$c];
4104
+								} else if ( $column == 'cat_posttype' ) {
4105
+									$cat_posttype = $row[$c];
4106
+								} else if ( $column == 'cat_parent' ) {
4107
+									$cat_parent = trim($row[$c]);
4108
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4109
+									$cat_schema = $row[$c];
4110
+								} else if ( $column == 'cat_description' ) {
4111
+									$cat_description = $row[$c];
4112
+								} else if ( $column == 'cat_top_description' ) {
4113
+									$cat_top_description = $row[$c];
4114
+								} else if ( $column == 'cat_image' ) {
4115
+									$cat_image = $row[$c];
4116
+								} else if ( $column == 'cat_icon' ) {
4117
+									$cat_icon = $row[$c];
4118
+								}
4119
+								// WPML
4120
+								if ( $is_wpml ) {
4121
+									if ( $column == 'cat_language' ) {
4122
+										$cat_language = geodir_strtolower( trim( $row[$c] ) );
4123
+									} else if ( $column == 'cat_id_original' ) {
4124
+										$cat_id_original = (int)$row[$c];
4125
+									}
4126
+								}
4127
+								// WPML
4128
+								$c++;
4129
+							}
4130 4130
                             
4131
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4132
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4131
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4132
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4133 4133
                                 
4134
-                                $invalid++;
4135
-                                continue;
4136
-                            }
4134
+								$invalid++;
4135
+								continue;
4136
+							}
4137 4137
                             
4138
-                            // WPML
4139
-                            if ($is_wpml && $cat_language != '') {
4140
-                                $sitepress->switch_lang($cat_language, true);
4141
-                            }
4142
-                            // WPML
4138
+							// WPML
4139
+							if ($is_wpml && $cat_language != '') {
4140
+								$sitepress->switch_lang($cat_language, true);
4141
+							}
4142
+							// WPML
4143 4143
                                                         
4144
-                            $term_data = array();
4145
-                            $term_data['name'] = $cat_name;
4146
-                            $term_data['slug'] = $cat_slug;
4147
-                            $term_data['description'] = $cat_description;
4148
-                            $term_data['cat_schema'] = $cat_schema;
4149
-                            $term_data['top_description'] = $cat_top_description;
4150
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4151
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4144
+							$term_data = array();
4145
+							$term_data['name'] = $cat_name;
4146
+							$term_data['slug'] = $cat_slug;
4147
+							$term_data['description'] = $cat_description;
4148
+							$term_data['cat_schema'] = $cat_schema;
4149
+							$term_data['top_description'] = $cat_top_description;
4150
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4151
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4152 4152
                             
4153
-                            //$term_data = array_map( 'utf8_encode', $term_data );
4153
+							//$term_data = array_map( 'utf8_encode', $term_data );
4154 4154
                             
4155
-                            $taxonomy = $cat_posttype . 'category';
4155
+							$taxonomy = $cat_posttype . 'category';
4156 4156
                             
4157
-                            $term_data['taxonomy'] = $taxonomy;
4157
+							$term_data['taxonomy'] = $taxonomy;
4158 4158
 
4159
-                            $term_parent_id = 0;
4160
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4161
-                                $term_parent = '';
4159
+							$term_parent_id = 0;
4160
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
4161
+								$term_parent = '';
4162 4162
                                 
4163
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4164
-                                    //
4165
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4166
-                                    //
4167
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4168
-                                    //
4169
-                                } else {
4170
-                                    $term_parent_data = array();
4171
-                                    $term_parent_data['name'] = $cat_parent;
4172
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4173
-                                    $term_parent_data['taxonomy'] = $taxonomy;
4163
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4164
+									//
4165
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4166
+									//
4167
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4168
+									//
4169
+								} else {
4170
+									$term_parent_data = array();
4171
+									$term_parent_data['name'] = $cat_parent;
4172
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4173
+									$term_parent_data['taxonomy'] = $taxonomy;
4174 4174
                                     
4175
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4176
-                                }
4175
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4176
+								}
4177 4177
                                 
4178
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4179
-                                    $term_parent_id = (int)$term_parent->term_id;
4180
-                                }
4181
-                            }
4182
-                            $term_data['parent'] = (int)$term_parent_id;
4178
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4179
+									$term_parent_id = (int)$term_parent->term_id;
4180
+								}
4181
+							}
4182
+							$term_data['parent'] = (int)$term_parent_id;
4183 4183
 
4184
-                            $term_id = NULL;
4185
-                            if ( $import_choice == 'update' ) {
4186
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4187
-                                    $term_data['term_id'] = $term['term_id'];
4184
+							$term_id = NULL;
4185
+							if ( $import_choice == 'update' ) {
4186
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4187
+									$term_data['term_id'] = $term['term_id'];
4188 4188
                                     
4189
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4190
-                                        $updated++;
4191
-                                    } else {
4192
-                                        $invalid++;
4193
-                                        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' ) );
4194
-                                    }
4195
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4196
-                                    $term_data['term_id'] = $term['term_id'];
4189
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4190
+										$updated++;
4191
+									} else {
4192
+										$invalid++;
4193
+										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' ) );
4194
+									}
4195
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4196
+									$term_data['term_id'] = $term['term_id'];
4197 4197
                                     
4198
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4199
-                                        $updated++;
4200
-                                    } else {
4201
-                                        $invalid++;
4202
-                                        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' ) );
4203
-                                    }
4204
-                                } else {
4205
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4206
-                                        $created++;
4207
-                                    } else {
4208
-                                        $invalid++;
4209
-                                        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' ) );
4210
-                                    }
4211
-                                }
4212
-                            } else if ( $import_choice == 'skip' ) {
4213
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4214
-                                    $skipped++;
4215
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4216
-                                    $skipped++;
4217
-                                } else {
4218
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4219
-                                        $created++;
4220
-                                    } else {
4221
-                                        $invalid++;
4222
-                                        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' ) );
4223
-                                    }
4224
-                                }
4225
-                            } else {
4226
-                                $invalid++;
4227
-                                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' ) );
4228
-                            }
4198
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4199
+										$updated++;
4200
+									} else {
4201
+										$invalid++;
4202
+										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' ) );
4203
+									}
4204
+								} else {
4205
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4206
+										$created++;
4207
+									} else {
4208
+										$invalid++;
4209
+										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' ) );
4210
+									}
4211
+								}
4212
+							} else if ( $import_choice == 'skip' ) {
4213
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4214
+									$skipped++;
4215
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4216
+									$skipped++;
4217
+								} else {
4218
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4219
+										$created++;
4220
+									} else {
4221
+										$invalid++;
4222
+										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' ) );
4223
+									}
4224
+								}
4225
+							} else {
4226
+								$invalid++;
4227
+								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' ) );
4228
+							}
4229 4229
                             
4230
-                            if ( $term_id ) {
4231
-                                // WPML
4232
-                                if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4233
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4234
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4235
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4236
-
4237
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4230
+							if ( $term_id ) {
4231
+								// WPML
4232
+								if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4233
+									$wpml_element_type = 'tax_' . $taxonomy;
4234
+									$source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4235
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4236
+
4237
+									$trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4238 4238
                                     
4239
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4240
-                                }
4241
-                                // WPML
4239
+									$sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4240
+								}
4241
+								// WPML
4242 4242
                                 
4243
-                                if ( isset( $term_data['top_description'] ) ) {
4244
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4245
-                                }
4243
+								if ( isset( $term_data['top_description'] ) ) {
4244
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4245
+								}
4246 4246
                                 
4247
-                                if ( isset( $term_data['cat_schema'] ) ) {
4248
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4249
-                                }
4247
+								if ( isset( $term_data['cat_schema'] ) ) {
4248
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4249
+								}
4250 4250
             
4251
-                                $attachment = false;
4252
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4253
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4254
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4251
+								$attachment = false;
4252
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4253
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4254
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4255 4255
                                     
4256
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4257
-                                        $attachment = true;
4258
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4259
-                                    }
4260
-                                }
4256
+									if ( basename($cat_image) != $term_data['image'] ) {
4257
+										$attachment = true;
4258
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4259
+									}
4260
+								}
4261 4261
                                 
4262
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4263
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4264
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4262
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4263
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4264
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4265 4265
                                         
4266
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4267
-                                        $attachment = true;
4268
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4269
-                                    }
4270
-                                }
4266
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4267
+										$attachment = true;
4268
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4269
+									}
4270
+								}
4271 4271
                                 
4272
-                                if ( $attachment ) {
4273
-                                    $images++;
4274
-                                }
4275
-                            }
4272
+								if ( $attachment ) {
4273
+									$images++;
4274
+								}
4275
+							}
4276 4276
                             
4277
-                            // WPML
4278
-                            if ($is_wpml && $cat_language != '') {
4279
-                                $sitepress->switch_lang($active_lang, true);
4280
-                            }
4281
-                            // WPML
4282
-                        }
4283
-                    }
4284
-                }
4277
+							// WPML
4278
+							if ($is_wpml && $cat_language != '') {
4279
+								$sitepress->switch_lang($active_lang, true);
4280
+							}
4281
+							// WPML
4282
+						}
4283
+					}
4284
+				}
4285 4285
                 
4286
-                $json = array();
4287
-                $json['processed'] = $limit;
4288
-                $json['created'] = $created;
4289
-                $json['updated'] = $updated;
4290
-                $json['skipped'] = $skipped;
4291
-                $json['invalid'] = $invalid;
4292
-                $json['images'] = $images;
4286
+				$json = array();
4287
+				$json['processed'] = $limit;
4288
+				$json['created'] = $created;
4289
+				$json['updated'] = $updated;
4290
+				$json['skipped'] = $skipped;
4291
+				$json['invalid'] = $invalid;
4292
+				$json['images'] = $images;
4293 4293
                 
4294
-                wp_send_json( $json );
4295
-                exit;
4296
-            } else if ( $task == 'import_post' ) {
4297
-                //run some stuff to make the import quicker
4298
-                wp_defer_term_counting( true );
4299
-                wp_defer_comment_counting( true );
4300
-                $wpdb->query( 'SET autocommit = 0;' );
4301
-
4302
-                //remove_all_actions('publish_post');
4303
-                //remove_all_actions('transition_post_status');
4304
-                //remove_all_actions('publish_future_post');
4305
-
4306
-                if (!empty($file)) {
4307
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4308
-                    $default_status = 'publish';
4309
-                    $current_date = date_i18n( 'Y-m-d', time() );
4294
+				wp_send_json( $json );
4295
+				exit;
4296
+			} else if ( $task == 'import_post' ) {
4297
+				//run some stuff to make the import quicker
4298
+				wp_defer_term_counting( true );
4299
+				wp_defer_comment_counting( true );
4300
+				$wpdb->query( 'SET autocommit = 0;' );
4301
+
4302
+				//remove_all_actions('publish_post');
4303
+				//remove_all_actions('transition_post_status');
4304
+				//remove_all_actions('publish_future_post');
4305
+
4306
+				if (!empty($file)) {
4307
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4308
+					$default_status = 'publish';
4309
+					$current_date = date_i18n( 'Y-m-d', time() );
4310 4310
                     
4311
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4311
+					$columns = isset($file[0]) ? $file[0] : NULL;
4312 4312
                     
4313
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4314
-                        $json['error'] = CSV_INVAILD_FILE;
4315
-                        wp_send_json( $json );
4316
-                        exit;
4317
-                    }
4313
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4314
+						$json['error'] = CSV_INVAILD_FILE;
4315
+						wp_send_json( $json );
4316
+						exit;
4317
+					}
4318 4318
 
4319
-                    $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4320
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4321
-                    $processed_actual = 0;
4322
-                    for ($i = 1; $i <= $limit; $i++) {
4323
-                        $index = $processed + $i;
4324
-                        $gd_post = array();
4319
+					$gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4320
+					$wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4321
+					$processed_actual = 0;
4322
+					for ($i = 1; $i <= $limit; $i++) {
4323
+						$index = $processed + $i;
4324
+						$gd_post = array();
4325 4325
                         
4326
-                        if (isset($file[$index])) {
4327
-                            $processed_actual++;
4328
-                            $row = $file[$index];
4329
-                            $row = array_map( 'trim', $row );
4330
-                            //$row = array_map( 'utf8_encode', $row );
4331
-                            $row = array_map( 'addslashes_gpc', $row );
4326
+						if (isset($file[$index])) {
4327
+							$processed_actual++;
4328
+							$row = $file[$index];
4329
+							$row = array_map( 'trim', $row );
4330
+							//$row = array_map( 'utf8_encode', $row );
4331
+							$row = array_map( 'addslashes_gpc', $row );
4332 4332
                             
4333
-                            $post_id = '';
4334
-                            $post_title = '';
4335
-                            $post_author = '';
4336
-                            $post_content = '';
4337
-                            $post_category_arr = array();
4338
-                            $default_category = '';
4339
-                            $post_tags = array();
4340
-                            $post_type = '';
4341
-                            $post_status = '';
4342
-                            $geodir_video = '';
4343
-                            $post_address = '';
4344
-                            $post_city = '';
4345
-                            $post_region = '';
4346
-                            $post_country = '';
4347
-                            $post_zip = '';
4348
-                            $post_latitude = '';
4349
-                            $post_longitude = '';
4350
-                            $post_neighbourhood = '';
4351
-                            $neighbourhood_latitude = '';
4352
-                            $neighbourhood_longitude = '';
4353
-                            $geodir_timing = '';
4354
-                            $geodir_contact = '';
4355
-                            $geodir_email = '';
4356
-                            $geodir_website = '';
4357
-                            $geodir_twitter = '';
4358
-                            $geodir_facebook = '';
4359
-                            $geodir_twitter = '';
4360
-                            $post_images = array();
4333
+							$post_id = '';
4334
+							$post_title = '';
4335
+							$post_author = '';
4336
+							$post_content = '';
4337
+							$post_category_arr = array();
4338
+							$default_category = '';
4339
+							$post_tags = array();
4340
+							$post_type = '';
4341
+							$post_status = '';
4342
+							$geodir_video = '';
4343
+							$post_address = '';
4344
+							$post_city = '';
4345
+							$post_region = '';
4346
+							$post_country = '';
4347
+							$post_zip = '';
4348
+							$post_latitude = '';
4349
+							$post_longitude = '';
4350
+							$post_neighbourhood = '';
4351
+							$neighbourhood_latitude = '';
4352
+							$neighbourhood_longitude = '';
4353
+							$geodir_timing = '';
4354
+							$geodir_contact = '';
4355
+							$geodir_email = '';
4356
+							$geodir_website = '';
4357
+							$geodir_twitter = '';
4358
+							$geodir_facebook = '';
4359
+							$geodir_twitter = '';
4360
+							$post_images = array();
4361 4361
                             
4362
-                            $expire_date = 'Never';
4362
+							$expire_date = 'Never';
4363 4363
                             
4364
-                            $language = '';
4365
-                            $original_post_id = '';
4364
+							$language = '';
4365
+							$original_post_id = '';
4366 4366
                                                         
4367
-                            $c = 0;
4368
-                            foreach ($columns as $column ) {
4369
-                                $gd_post[$column] = $row[$c];
4367
+							$c = 0;
4368
+							foreach ($columns as $column ) {
4369
+								$gd_post[$column] = $row[$c];
4370 4370
                                 
4371
-                                if ( $column == 'post_id' ) {
4372
-                                    $post_id = $row[$c];
4373
-                                } else if ( $column == 'post_title' ) {
4374
-                                    $post_title = sanitize_text_field($row[$c]);
4375
-                                } else if ( $column == 'post_author' ) {
4376
-                                    $post_author = $row[$c];
4377
-                                } else if ( $column == 'post_content' ) {
4378
-                                    $post_content = $row[$c];
4379
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4380
-                                    $post_category_arr = explode( ',', $row[$c] );
4381
-                                } else if ( $column == 'default_category' ) {
4382
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4383
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4384
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4385
-                                } else if ( $column == 'post_type' ) {
4386
-                                    $post_type = $row[$c];
4387
-                                } else if ( $column == 'post_status' ) {
4388
-                                    $post_status = sanitize_key( $row[$c] );
4389
-                                } else if ( $column == 'is_featured' ) {
4390
-                                    $is_featured = (int)$row[$c];
4391
-                                } else if ( $column == 'geodir_video' ) {
4392
-                                    $geodir_video = $row[$c];
4393
-                                } else if ( $column == 'post_address' ) {
4394
-                                    $post_address = sanitize_text_field($row[$c]);
4395
-                                } else if ( $column == 'post_city' ) {
4396
-                                    $post_city = sanitize_text_field($row[$c]);
4397
-                                } else if ( $column == 'post_region' ) {
4398
-                                    $post_region = sanitize_text_field($row[$c]);
4399
-                                } else if ( $column == 'post_country' ) {
4400
-                                    $post_country = sanitize_text_field($row[$c]);
4401
-                                } else if ( $column == 'post_zip' ) {
4402
-                                    $post_zip = sanitize_text_field($row[$c]);
4403
-                                } else if ( $column == 'post_latitude' ) {
4404
-                                    $post_latitude = sanitize_text_field($row[$c]);
4405
-                                } else if ( $column == 'post_longitude' ) {
4406
-                                    $post_longitude = sanitize_text_field($row[$c]);
4407
-                                } else if ( $column == 'post_neighbourhood' ) {
4408
-                                    $post_neighbourhood = sanitize_text_field($row[$c]);
4409
-                                    unset($gd_post[$column]);
4410
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4411
-                                    $neighbourhood_latitude = sanitize_text_field($row[$c]);
4412
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4413
-                                    $neighbourhood_longitude = sanitize_text_field($row[$c]);
4414
-                                } else if ( $column == 'geodir_timing' ) {
4415
-                                    $geodir_timing = sanitize_text_field($row[$c]);
4416
-                                } else if ( $column == 'geodir_contact' ) {
4417
-                                    $geodir_contact = sanitize_text_field($row[$c]);
4418
-                                } else if ( $column == 'geodir_email' ) {
4419
-                                    $geodir_email = sanitize_email($row[$c]);
4420
-                                } else if ( $column == 'geodir_website' ) {
4421
-                                    $geodir_website = sanitize_text_field($row[$c]);
4422
-                                } else if ( $column == 'geodir_twitter' ) {
4423
-                                    $geodir_twitter = sanitize_text_field($row[$c]);
4424
-                                } else if ( $column == 'geodir_facebook' ) {
4425
-                                    $geodir_facebook = sanitize_text_field($row[$c]);
4426
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4427
-                                    $post_images[] = $row[$c];
4428
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4429
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4430
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4431
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4432
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4433
-                                }
4434
-                                // WPML
4435
-                                if ($is_wpml) {
4436
-                                    if ($column == 'language') {
4437
-                                        $language = geodir_strtolower(trim($row[$c]));
4438
-                                    } else if ($column == 'original_post_id') {
4439
-                                        $original_post_id = (int)$row[$c];
4440
-                                    }
4441
-                                }
4442
-                                // WPML
4443
-                                $c++;
4444
-                            }
4371
+								if ( $column == 'post_id' ) {
4372
+									$post_id = $row[$c];
4373
+								} else if ( $column == 'post_title' ) {
4374
+									$post_title = sanitize_text_field($row[$c]);
4375
+								} else if ( $column == 'post_author' ) {
4376
+									$post_author = $row[$c];
4377
+								} else if ( $column == 'post_content' ) {
4378
+									$post_content = $row[$c];
4379
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4380
+									$post_category_arr = explode( ',', $row[$c] );
4381
+								} else if ( $column == 'default_category' ) {
4382
+									$default_category = wp_kses_normalize_entities($row[$c]);
4383
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4384
+									$post_tags = explode( ',', sanitize_text_field($row[$c]) );
4385
+								} else if ( $column == 'post_type' ) {
4386
+									$post_type = $row[$c];
4387
+								} else if ( $column == 'post_status' ) {
4388
+									$post_status = sanitize_key( $row[$c] );
4389
+								} else if ( $column == 'is_featured' ) {
4390
+									$is_featured = (int)$row[$c];
4391
+								} else if ( $column == 'geodir_video' ) {
4392
+									$geodir_video = $row[$c];
4393
+								} else if ( $column == 'post_address' ) {
4394
+									$post_address = sanitize_text_field($row[$c]);
4395
+								} else if ( $column == 'post_city' ) {
4396
+									$post_city = sanitize_text_field($row[$c]);
4397
+								} else if ( $column == 'post_region' ) {
4398
+									$post_region = sanitize_text_field($row[$c]);
4399
+								} else if ( $column == 'post_country' ) {
4400
+									$post_country = sanitize_text_field($row[$c]);
4401
+								} else if ( $column == 'post_zip' ) {
4402
+									$post_zip = sanitize_text_field($row[$c]);
4403
+								} else if ( $column == 'post_latitude' ) {
4404
+									$post_latitude = sanitize_text_field($row[$c]);
4405
+								} else if ( $column == 'post_longitude' ) {
4406
+									$post_longitude = sanitize_text_field($row[$c]);
4407
+								} else if ( $column == 'post_neighbourhood' ) {
4408
+									$post_neighbourhood = sanitize_text_field($row[$c]);
4409
+									unset($gd_post[$column]);
4410
+								} else if ( $column == 'neighbourhood_latitude' ) {
4411
+									$neighbourhood_latitude = sanitize_text_field($row[$c]);
4412
+								} else if ( $column == 'neighbourhood_longitude' ) {
4413
+									$neighbourhood_longitude = sanitize_text_field($row[$c]);
4414
+								} else if ( $column == 'geodir_timing' ) {
4415
+									$geodir_timing = sanitize_text_field($row[$c]);
4416
+								} else if ( $column == 'geodir_contact' ) {
4417
+									$geodir_contact = sanitize_text_field($row[$c]);
4418
+								} else if ( $column == 'geodir_email' ) {
4419
+									$geodir_email = sanitize_email($row[$c]);
4420
+								} else if ( $column == 'geodir_website' ) {
4421
+									$geodir_website = sanitize_text_field($row[$c]);
4422
+								} else if ( $column == 'geodir_twitter' ) {
4423
+									$geodir_twitter = sanitize_text_field($row[$c]);
4424
+								} else if ( $column == 'geodir_facebook' ) {
4425
+									$geodir_facebook = sanitize_text_field($row[$c]);
4426
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4427
+									$post_images[] = $row[$c];
4428
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4429
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4430
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4431
+									$row[$c] = str_replace('/', '-', $row[$c]);
4432
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4433
+								}
4434
+								// WPML
4435
+								if ($is_wpml) {
4436
+									if ($column == 'language') {
4437
+										$language = geodir_strtolower(trim($row[$c]));
4438
+									} else if ($column == 'original_post_id') {
4439
+										$original_post_id = (int)$row[$c];
4440
+									}
4441
+								}
4442
+								// WPML
4443
+								$c++;
4444
+							}
4445 4445
                             
4446
-                            // WPML
4447
-                            if ($is_wpml && $language != '') {
4448
-                                $sitepress->switch_lang($language, true);
4449
-                            }
4450
-                            // WPML
4446
+							// WPML
4447
+							if ($is_wpml && $language != '') {
4448
+								$sitepress->switch_lang($language, true);
4449
+							}
4450
+							// WPML
4451 4451
 
4452
-                            $gd_post['IMAGE'] = $post_images;
4452
+							$gd_post['IMAGE'] = $post_images;
4453 4453
                             
4454
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4455
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4454
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4455
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4456 4456
                                                                                                                 
4457
-                            $valid = true;
4457
+							$valid = true;
4458 4458
                             
4459
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4460
-                                $invalid++;
4461
-                                $valid = false;
4462
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4463
-                            }
4459
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4460
+								$invalid++;
4461
+								$valid = false;
4462
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4463
+							}
4464 4464
                             
4465
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4466
-                            if ( $location_allowed ) {
4467
-                                $location_result = geodir_get_default_location();
4468
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4469
-                                    $invalid_addr++;
4470
-                                    $valid = false;
4471
-                                    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' ) );
4472
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4473
-                                    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 ) ) ) {
4474
-                                        $invalid_addr++;
4475
-                                        $valid = false;
4476
-                                        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' ) );
4477
-                                    } else {
4478
-                                        if (!$location_manager) {
4479
-                                            $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.
4480
-                                        }
4481
-                                    }
4482
-                                }
4483
-                            }
4465
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4466
+							if ( $location_allowed ) {
4467
+								$location_result = geodir_get_default_location();
4468
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4469
+									$invalid_addr++;
4470
+									$valid = false;
4471
+									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' ) );
4472
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4473
+									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 ) ) ) {
4474
+										$invalid_addr++;
4475
+										$valid = false;
4476
+										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' ) );
4477
+									} else {
4478
+										if (!$location_manager) {
4479
+											$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.
4480
+										}
4481
+									}
4482
+								}
4483
+							}
4484 4484
                             
4485
-                            if ( !$valid ) {
4486
-                                continue;
4487
-                            }
4485
+							if ( !$valid ) {
4486
+								continue;
4487
+							}
4488 4488
 
4489
-                            $cat_taxonomy = $post_type . 'category';
4490
-                            $tags_taxonomy = $post_type . '_tags';
4489
+							$cat_taxonomy = $post_type . 'category';
4490
+							$tags_taxonomy = $post_type . '_tags';
4491 4491
                             
4492
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4493
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4494
-                            }
4492
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4493
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4494
+							}
4495 4495
 
4496
-                            $post_category = array();
4497
-                            $default_category_id = NULL;
4498
-                            if ( !empty( $post_category_arr ) ) {
4499
-                                foreach ( $post_category_arr as $value ) {
4500
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4496
+							$post_category = array();
4497
+							$default_category_id = NULL;
4498
+							if ( !empty( $post_category_arr ) ) {
4499
+								foreach ( $post_category_arr as $value ) {
4500
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4501 4501
                                     
4502
-                                    if ( $category_name != '' ) {
4503
-                                        $term_category = array();
4502
+									if ( $category_name != '' ) {
4503
+										$term_category = array();
4504 4504
                                         
4505
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4506
-                                            $term_category = $term;
4507
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4508
-                                            $term_category = $term;
4509
-                                        } else {
4510
-                                            $term_data = array();
4511
-                                            $term_data['name'] = $category_name;
4512
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4505
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4506
+											$term_category = $term;
4507
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4508
+											$term_category = $term;
4509
+										} else {
4510
+											$term_data = array();
4511
+											$term_data['name'] = $category_name;
4512
+											$term_data['taxonomy'] = $cat_taxonomy;
4513 4513
                                             
4514
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4515
-                                            if ( $term_id ) {
4516
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4517
-                                            }
4518
-                                        }
4514
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4515
+											if ( $term_id ) {
4516
+												$term_category = get_term( $term_id, $cat_taxonomy );
4517
+											}
4518
+										}
4519 4519
                                         
4520
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4521
-                                            $post_category[] = intval($term_category->term_id);
4520
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4521
+											$post_category[] = intval($term_category->term_id);
4522 4522
                                             
4523
-                                            if ($category_name == $default_category) {
4524
-                                                $default_category_id = intval($term_category->term_id);
4525
-                                            }
4526
-                                        }
4527
-                                    }
4528
-                                }
4529
-                            }
4523
+											if ($category_name == $default_category) {
4524
+												$default_category_id = intval($term_category->term_id);
4525
+											}
4526
+										}
4527
+									}
4528
+								}
4529
+							}
4530 4530
 
4531
-                            $save_post = array();
4532
-                            $save_post['post_title'] = $post_title;
4533
-                            $save_post['post_content'] = $post_content;
4534
-                            $save_post['post_type'] = $post_type;
4535
-                            $save_post['post_author'] = $post_author;
4536
-                            $save_post['post_status'] = $post_status;
4537
-                            $save_post['post_category'] = $post_category;
4538
-                            $save_post['post_tags'] = $post_tags;
4539
-
4540
-                            $saved_post_id = NULL;
4541
-                            if ( $import_choice == 'update' ) {
4542
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4531
+							$save_post = array();
4532
+							$save_post['post_title'] = $post_title;
4533
+							$save_post['post_content'] = $post_content;
4534
+							$save_post['post_type'] = $post_type;
4535
+							$save_post['post_author'] = $post_author;
4536
+							$save_post['post_status'] = $post_status;
4537
+							$save_post['post_category'] = $post_category;
4538
+							$save_post['post_tags'] = $post_tags;
4539
+
4540
+							$saved_post_id = NULL;
4541
+							if ( $import_choice == 'update' ) {
4542
+								$gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4543 4543
                                 
4544
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4545
-                                    $save_post['ID'] = $post_id;
4544
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4545
+									$save_post['ID'] = $post_id;
4546 4546
                                     
4547
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4548
-                                        if ( is_wp_error( $saved_post_id ) ) {
4549
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4550
-                                            $saved_post_id = 0;
4551
-                                        } else {
4552
-                                            $saved_post_id = $post_id;
4553
-                                            $updated++;
4554
-                                        }
4555
-                                    }
4556
-                                } else {
4557
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4558
-                                        if ( is_wp_error( $saved_post_id ) ) {
4559
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4560
-                                            $saved_post_id = 0;
4561
-                                        } else {
4562
-                                            $created++;
4563
-                                        }
4564
-                                    }
4565
-                                }
4547
+									if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4548
+										if ( is_wp_error( $saved_post_id ) ) {
4549
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4550
+											$saved_post_id = 0;
4551
+										} else {
4552
+											$saved_post_id = $post_id;
4553
+											$updated++;
4554
+										}
4555
+									}
4556
+								} else {
4557
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4558
+										if ( is_wp_error( $saved_post_id ) ) {
4559
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4560
+											$saved_post_id = 0;
4561
+										} else {
4562
+											$created++;
4563
+										}
4564
+									}
4565
+								}
4566 4566
                                 
4567
-                                if ( !$saved_post_id > 0 ) {
4568
-                                    $invalid++;
4569
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4570
-                                }
4571
-                            } else if ( $import_choice == 'skip' ) {
4572
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4573
-                                    $skipped++;	
4574
-                                } else {
4575
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4576
-                                        if ( is_wp_error( $saved_post_id ) ) {
4577
-                                            $invalid++;
4567
+								if ( !$saved_post_id > 0 ) {
4568
+									$invalid++;
4569
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4570
+								}
4571
+							} else if ( $import_choice == 'skip' ) {
4572
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4573
+									$skipped++;	
4574
+								} else {
4575
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4576
+										if ( is_wp_error( $saved_post_id ) ) {
4577
+											$invalid++;
4578 4578
                                             
4579
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4580
-                                            $saved_post_id = 0;
4581
-                                        } else {
4582
-                                            $created++;
4583
-                                        }
4584
-                                    } else {
4585
-                                        $invalid++;
4579
+											geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4580
+											$saved_post_id = 0;
4581
+										} else {
4582
+											$created++;
4583
+										}
4584
+									} else {
4585
+										$invalid++;
4586 4586
                                         
4587
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4588
-                                    }
4589
-                                }
4590
-                            } else {
4591
-                                $invalid++;
4587
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4588
+									}
4589
+								}
4590
+							} else {
4591
+								$invalid++;
4592 4592
                                 
4593
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4594
-                            }
4593
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4594
+							}
4595 4595
 
4596
-                            if ( (int)$saved_post_id > 0 ) {
4597
-                                // WPML
4598
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4599
-                                    $wpml_post_type = 'post_' . $post_type;
4600
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4601
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4596
+							if ( (int)$saved_post_id > 0 ) {
4597
+								// WPML
4598
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4599
+									$wpml_post_type = 'post_' . $post_type;
4600
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4601
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4602 4602
 
4603
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4603
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4604 4604
                                     
4605
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4606
-                                }
4607
-                                // WPML
4608
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4605
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4606
+								}
4607
+								// WPML
4608
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4609 4609
                                 
4610
-                                $gd_post['post_id'] = $saved_post_id;
4611
-                                $gd_post['ID'] = $saved_post_id;
4612
-                                $gd_post['post_tags'] = $post_tags;
4613
-                                $gd_post['post_title'] = $post_title;
4614
-                                $gd_post['post_status'] = $post_status;
4615
-                                $gd_post['submit_time'] = time();
4616
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4610
+								$gd_post['post_id'] = $saved_post_id;
4611
+								$gd_post['ID'] = $saved_post_id;
4612
+								$gd_post['post_tags'] = $post_tags;
4613
+								$gd_post['post_title'] = $post_title;
4614
+								$gd_post['post_status'] = $post_status;
4615
+								$gd_post['submit_time'] = time();
4616
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4617 4617
                                                     
4618
-                                // post location
4619
-                                $post_location_id = 0;
4620
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4621
-                                    $gd_post['post_neighbourhood'] = '';
4618
+								// post location
4619
+								$post_location_id = 0;
4620
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4621
+									$gd_post['post_neighbourhood'] = '';
4622 4622
                                     
4623
-                                    $post_location_info = array(
4624
-                                                                'city' => $post_city,
4625
-                                                                'region' => $post_region,
4626
-                                                                'country' => $post_country,
4627
-                                                                'geo_lat' => $post_latitude,
4628
-                                                                'geo_lng' => $post_longitude
4629
-                                                            );
4630
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4631
-                                        $post_location_id = $location_id;
4632
-                                    }
4623
+									$post_location_info = array(
4624
+																'city' => $post_city,
4625
+																'region' => $post_region,
4626
+																'country' => $post_country,
4627
+																'geo_lat' => $post_latitude,
4628
+																'geo_lng' => $post_longitude
4629
+															);
4630
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4631
+										$post_location_id = $location_id;
4632
+									}
4633 4633
                                     
4634
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4635
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4634
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4635
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4636 4636
 
4637
-                                        $hood_data = array();
4638
-                                        $hood_data['hood_location_id'] = $post_location_id;
4639
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4637
+										$hood_data = array();
4638
+										$hood_data['hood_location_id'] = $post_location_id;
4639
+										$hood_data['hood_name'] = $post_neighbourhood;
4640 4640
                                         
4641
-                                        if (!empty($neighbourhood_info)) {
4642
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4643
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4641
+										if (!empty($neighbourhood_info)) {
4642
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4643
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4644 4644
                                             
4645
-                                            if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4646
-                                                $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4647
-                                                $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4648
-                                            }
4649
-                                        }
4645
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4646
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4647
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4648
+											}
4649
+										}
4650 4650
                                         
4651
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4652
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4653
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4654
-                                        }
4651
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4652
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4653
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4654
+										}
4655 4655
                                         
4656
-                                        $hood_data['hood_latitude'] = $post_latitude;
4657
-                                        $hood_data['hood_longitude'] = $post_longitude;
4656
+										$hood_data['hood_latitude'] = $post_latitude;
4657
+										$hood_data['hood_longitude'] = $post_longitude;
4658 4658
 
4659
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4660
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4661
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4662
-                                        }
4663
-                                    }
4664
-                                }
4665
-                                $gd_post['post_location_id'] = $post_location_id;
4659
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4660
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4661
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4662
+										}
4663
+									}
4664
+								}
4665
+								$gd_post['post_location_id'] = $post_location_id;
4666 4666
                                 
4667
-                                // post package info
4668
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4669
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4670
-                                    $package_id = $gd_post_info->package_id;
4671
-                                }
4667
+								// post package info
4668
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4669
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4670
+									$package_id = $gd_post_info->package_id;
4671
+								}
4672 4672
                                 
4673
-                                $package_info = array();
4674
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4675
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4673
+								$package_info = array();
4674
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4675
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4676 4676
                                     
4677
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4678
-                                        $package_info = array();
4679
-                                    }
4680
-                                }
4677
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4678
+										$package_info = array();
4679
+									}
4680
+								}
4681 4681
                                 
4682
-                                if (empty($package_info)) {
4683
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4684
-                                }
4682
+								if (empty($package_info)) {
4683
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4684
+								}
4685 4685
                                  
4686
-                                if (!empty($package_info))	 {
4687
-                                    $package_id = $package_info['pid'];
4686
+								if (!empty($package_info))	 {
4687
+									$package_id = $package_info['pid'];
4688 4688
                                     
4689
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4690
-                                        $gd_post['expire_date'] = $expire_date;
4691
-                                    } else {
4692
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4693
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4694
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4695
-                                        } else {
4696
-                                            $gd_post['expire_date'] = 'Never';
4697
-                                        }
4698
-                                    }
4689
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4690
+										$gd_post['expire_date'] = $expire_date;
4691
+									} else {
4692
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4693
+											$gd_post['alive_days'] = (int)$package_info['days'];
4694
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4695
+										} else {
4696
+											$gd_post['expire_date'] = 'Never';
4697
+										}
4698
+									}
4699 4699
                                     
4700
-                                    $gd_post['package_id'] = $package_id;
4701
-                                }
4700
+									$gd_post['package_id'] = $package_id;
4701
+								}
4702 4702
 
4703
-                                $table = $plugin_prefix . $post_type . '_detail';
4703
+								$table = $plugin_prefix . $post_type . '_detail';
4704 4704
                                 
4705
-                                if ($post_type == 'gd_event') {
4706
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4707
-                                }
4705
+								if ($post_type == 'gd_event') {
4706
+									$gd_post = geodir_imex_process_event_data($gd_post);
4707
+								}
4708 4708
                                 
4709
-                                if (isset($gd_post['post_id'])) {
4710
-                                    unset($gd_post['post_id']);
4711
-                                }
4709
+								if (isset($gd_post['post_id'])) {
4710
+									unset($gd_post['post_id']);
4711
+								}
4712 4712
 
4713
-                                // Export franchise fields
4714
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4715
-                                if ($is_franchise_active) {
4716
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4717
-                                        $gd_franchise_lock = array();
4713
+								// Export franchise fields
4714
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4715
+								if ($is_franchise_active) {
4716
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4717
+										$gd_franchise_lock = array();
4718 4718
                                         
4719
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4720
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4721
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4722
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4723
-                                        }
4719
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4720
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4721
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4722
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4723
+										}
4724 4724
                                         
4725
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4726
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4727
-                                    } else {
4728
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4729
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4730
-                                        }
4731
-                                    }
4732
-                                }
4725
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4726
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4727
+									} else {
4728
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4729
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4730
+										}
4731
+									}
4732
+								}
4733 4733
                                 
4734
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4735
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4736
-                                    if ($default_category_id) {
4737
-                                        $save_post['post_default_category'] = $default_category_id;
4738
-                                        $gd_post['default_category'] = $default_category_id;
4739
-                                    }
4740
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4741
-                                }
4734
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4735
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4736
+									if ($default_category_id) {
4737
+										$save_post['post_default_category'] = $default_category_id;
4738
+										$gd_post['default_category'] = $default_category_id;
4739
+									}
4740
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4741
+								}
4742 4742
                                 
4743
-                                // Save post info
4744
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4745
-                                // post taxonomies
4746
-                                if ( !empty( $save_post['post_category'] ) ) {
4747
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4743
+								// Save post info
4744
+								geodir_save_post_info( $saved_post_id, $gd_post );
4745
+								// post taxonomies
4746
+								if ( !empty( $save_post['post_category'] ) ) {
4747
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4748 4748
                                     
4749
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4750
-                                    if ($default_category_id) {
4751
-                                        $post_default_category = $default_category_id;
4752
-                                    }
4753
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4754
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4755
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4749
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4750
+									if ($default_category_id) {
4751
+										$post_default_category = $default_category_id;
4752
+									}
4753
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4754
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4755
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4756 4756
                                     
4757
-                                    if ($post_category_str != '' && $post_default_category) {
4758
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4759
-                                    }
4757
+									if ($post_category_str != '' && $post_default_category) {
4758
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4759
+									}
4760 4760
                                     
4761
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4761
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4762 4762
                                     
4763
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4764
-                                }
4763
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4764
+								}
4765 4765
 
4766
-                                if ( !empty( $save_post['post_tags'] ) ) {
4767
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4768
-                                }
4766
+								if ( !empty( $save_post['post_tags'] ) ) {
4767
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4768
+								}
4769 4769
 
4770
-                                // Post images
4771
-                                if ( !empty( $post_images ) ) {
4772
-                                    $post_images = array_unique($post_images);
4770
+								// Post images
4771
+								if ( !empty( $post_images ) ) {
4772
+									$post_images = array_unique($post_images);
4773 4773
                                     
4774
-                                    $old_post_images_arr = array();
4775
-                                    $saved_post_images_arr = array();
4774
+									$old_post_images_arr = array();
4775
+									$saved_post_images_arr = array();
4776 4776
                                     
4777
-                                    $order = 1;
4777
+									$order = 1;
4778 4778
                                     
4779
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4780
-                                    if (!empty($old_post_images)) {
4781
-                                        foreach( $old_post_images as $old_post_image ) {
4782
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4783
-                                                $old_post_images_arr[] = $old_post_image->file;
4784
-                                            }
4785
-                                        }
4786
-                                    }
4779
+									$old_post_images = geodir_get_images( $saved_post_id );
4780
+									if (!empty($old_post_images)) {
4781
+										foreach( $old_post_images as $old_post_image ) {
4782
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4783
+												$old_post_images_arr[] = $old_post_image->file;
4784
+											}
4785
+										}
4786
+									}
4787 4787
                                     
4788
-                                    foreach ( $post_images as $post_image ) {
4789
-                                        $image_name = basename( $post_image );
4790
-                                        $saved_post_images_arr[] = $image_name;
4788
+									foreach ( $post_images as $post_image ) {
4789
+										$image_name = basename( $post_image );
4790
+										$saved_post_images_arr[] = $image_name;
4791 4791
                                         
4792
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4793
-                                            continue; // Skip if image already exists.
4794
-                                        }
4792
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4793
+											continue; // Skip if image already exists.
4794
+										}
4795 4795
                                         
4796
-                                        $image_name_parts = explode( '.', $image_name );
4797
-                                        array_pop( $image_name_parts );
4798
-                                        $proper_image_name = implode( '.', $image_name_parts );
4796
+										$image_name_parts = explode( '.', $image_name );
4797
+										array_pop( $image_name_parts );
4798
+										$proper_image_name = implode( '.', $image_name_parts );
4799 4799
                                         
4800
-                                        $arr_file_type = wp_check_filetype( $image_name );
4800
+										$arr_file_type = wp_check_filetype( $image_name );
4801 4801
                                         
4802
-                                        if ( !empty( $arr_file_type ) ) {
4803
-                                            $uploaded_file_type = $arr_file_type['type'];
4802
+										if ( !empty( $arr_file_type ) ) {
4803
+											$uploaded_file_type = $arr_file_type['type'];
4804 4804
                                             
4805
-                                            $attachment = array();
4806
-                                            $attachment['post_id'] = $saved_post_id;
4807
-                                            $attachment['title'] = $proper_image_name;
4808
-                                            $attachment['content'] = '';
4809
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4810
-                                            $attachment['mime_type'] = $uploaded_file_type;
4811
-                                            $attachment['menu_order'] = $order;
4812
-                                            $attachment['is_featured'] = 0;
4813
-
4814
-                                            $attachment_set = '';
4815
-                                            foreach ( $attachment as $key => $val ) {
4816
-                                                if ( $val != '' ) {
4817
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4818
-                                                }
4819
-                                            }
4820
-                                            $attachment_set = trim( $attachment_set, ", " );
4805
+											$attachment = array();
4806
+											$attachment['post_id'] = $saved_post_id;
4807
+											$attachment['title'] = $proper_image_name;
4808
+											$attachment['content'] = '';
4809
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4810
+											$attachment['mime_type'] = $uploaded_file_type;
4811
+											$attachment['menu_order'] = $order;
4812
+											$attachment['is_featured'] = 0;
4813
+
4814
+											$attachment_set = '';
4815
+											foreach ( $attachment as $key => $val ) {
4816
+												if ( $val != '' ) {
4817
+													$attachment_set .= $key . " = '" . $val . "', ";
4818
+												}
4819
+											}
4820
+											$attachment_set = trim( $attachment_set, ", " );
4821 4821
                                                                                         
4822
-                                            // Add new attachment
4823
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4822
+											// Add new attachment
4823
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4824 4824
                                                                                         
4825
-                                            $order++;
4826
-                                        }
4827
-                                    }
4825
+											$order++;
4826
+										}
4827
+									}
4828 4828
 
4829
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4830
-                                    // Remove previous attachment
4831
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4829
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4830
+									// Remove previous attachment
4831
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4832 4832
                                     
4833
-                                    if ( !empty( $saved_post_images_arr ) ) {
4834
-                                        $menu_order = 1;
4833
+									if ( !empty( $saved_post_images_arr ) ) {
4834
+										$menu_order = 1;
4835 4835
                                         
4836
-                                        foreach ( $saved_post_images_arr as $img_name ) {
4837
-                                            $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4836
+										foreach ( $saved_post_images_arr as $img_name ) {
4837
+											$wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4838 4838
                                             
4839
-                                            if( $menu_order == 1 ) {
4840
-                                                if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4841
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4842
-                                                }
4843
-                                            }
4844
-                                            $menu_order++;
4845
-                                        }
4846
-                                    }
4839
+											if( $menu_order == 1 ) {
4840
+												if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4841
+													$wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4842
+												}
4843
+											}
4844
+											$menu_order++;
4845
+										}
4846
+									}
4847 4847
                                     
4848
-                                    if ( $order > 1 ) {
4849
-                                        $images++;
4850
-                                    }
4851
-                                }
4848
+									if ( $order > 1 ) {
4849
+										$images++;
4850
+									}
4851
+								}
4852 4852
 
4853
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4854
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4853
+								/** This action is documented in geodirectory-functions/post-functions.php */
4854
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4855 4855
                                 
4856
-                                if (isset($is_featured)) {
4857
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4858
-                                }
4859
-                                if (isset($gd_post['expire_date'])) {
4860
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4861
-                                }
4862
-                            }
4856
+								if (isset($is_featured)) {
4857
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4858
+								}
4859
+								if (isset($gd_post['expire_date'])) {
4860
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4861
+								}
4862
+							}
4863 4863
                             
4864
-                            // WPML
4865
-                            if ($is_wpml && $language != '') {
4866
-                                $sitepress->switch_lang($active_lang, true);
4867
-                            }
4868
-                            // WPML
4869
-                        }
4870
-                    }
4871
-                }
4864
+							// WPML
4865
+							if ($is_wpml && $language != '') {
4866
+								$sitepress->switch_lang($active_lang, true);
4867
+							}
4868
+							// WPML
4869
+						}
4870
+					}
4871
+				}
4872 4872
 
4873
-                //undo some stuff to make the import quicker
4874
-                wp_defer_term_counting( false );
4875
-                wp_defer_comment_counting( false );
4876
-                $wpdb->query( 'COMMIT;' );
4877
-                $wpdb->query( 'SET autocommit = 1;' );
4878
-
4879
-                $json = array();
4880
-                $json['processed'] = $processed_actual;
4881
-                $json['created'] = $created;
4882
-                $json['updated'] = $updated;
4883
-                $json['skipped'] = $skipped;
4884
-                $json['invalid'] = $invalid;
4885
-                $json['invalid_addr'] = $invalid_addr;
4886
-                $json['images'] = $images;
4873
+				//undo some stuff to make the import quicker
4874
+				wp_defer_term_counting( false );
4875
+				wp_defer_comment_counting( false );
4876
+				$wpdb->query( 'COMMIT;' );
4877
+				$wpdb->query( 'SET autocommit = 1;' );
4878
+
4879
+				$json = array();
4880
+				$json['processed'] = $processed_actual;
4881
+				$json['created'] = $created;
4882
+				$json['updated'] = $updated;
4883
+				$json['skipped'] = $skipped;
4884
+				$json['invalid'] = $invalid;
4885
+				$json['invalid_addr'] = $invalid_addr;
4886
+				$json['images'] = $images;
4887 4887
                 
4888
-                wp_send_json( $json );
4889
-                exit;
4890
-            } else if ( $task == 'import_loc' ) {
4891
-                global $gd_post_types;
4892
-                $gd_post_types = $post_types;
4888
+				wp_send_json( $json );
4889
+				exit;
4890
+			} else if ( $task == 'import_loc' ) {
4891
+				global $gd_post_types;
4892
+				$gd_post_types = $post_types;
4893 4893
                 
4894
-                if (!empty($file)) {
4895
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4894
+				if (!empty($file)) {
4895
+					$columns = isset($file[0]) ? $file[0] : NULL;
4896 4896
                     
4897
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4898
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4899
-                        wp_send_json( $json );
4900
-                    }
4897
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4898
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4899
+						wp_send_json( $json );
4900
+					}
4901 4901
                     
4902
-                    $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4903
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4904
-                    for ($i = 1; $i <= $limit; $i++) {
4905
-                        $index = $processed + $i;
4902
+					$gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4903
+					$gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4904
+					for ($i = 1; $i <= $limit; $i++) {
4905
+						$index = $processed + $i;
4906 4906
                         
4907
-                        if (isset($file[$index])) {
4908
-                            $row = $file[$index];
4909
-                            $row = array_map( 'trim', $row );
4910
-                            $data = array();
4907
+						if (isset($file[$index])) {
4908
+							$row = $file[$index];
4909
+							$row = array_map( 'trim', $row );
4910
+							$data = array();
4911 4911
                             
4912
-                            foreach ($columns as $c => $column ) {
4913
-                                if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
4914
-                                    $data[$column] = $row[$c];
4915
-                                }
4916
-                            }
4912
+							foreach ($columns as $c => $column ) {
4913
+								if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
4914
+									$data[$column] = $row[$c];
4915
+								}
4916
+							}
4917 4917
 
4918
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4919
-                                $invalid++;
4920
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4921
-                                continue;
4922
-                            }
4918
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4919
+								$invalid++;
4920
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4921
+								continue;
4922
+							}
4923 4923
                             
4924
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4924
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4925 4925
                             
4926
-                            if ( $import_choice == 'update' ) {
4927
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4928
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4929
-                                        $updated++;
4930
-                                    } else {
4931
-                                        $invalid++;
4932
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4933
-                                    }
4934
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4935
-                                    $data['location_id'] = (int)$location->location_id;
4926
+							if ( $import_choice == 'update' ) {
4927
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4928
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4929
+										$updated++;
4930
+									} else {
4931
+										$invalid++;
4932
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4933
+									}
4934
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4935
+									$data['location_id'] = (int)$location->location_id;
4936 4936
                                     
4937
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4938
-                                        $data['location_id'] = (int)$location->location_id;
4939
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4940
-                                        $data['location_id'] = (int)$location->location_id;
4941
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4942
-                                        $data['location_id'] = (int)$location->location_id;
4943
-                                    }
4937
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4938
+										$data['location_id'] = (int)$location->location_id;
4939
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4940
+										$data['location_id'] = (int)$location->location_id;
4941
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4942
+										$data['location_id'] = (int)$location->location_id;
4943
+									}
4944 4944
                                     
4945
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4946
-                                        $updated++;
4947
-                                    } else {
4948
-                                        $invalid++;
4949
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4950
-                                    }
4951
-                                } else {
4952
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4953
-                                        $created++;
4954
-                                    } else {
4955
-                                        $invalid++;
4956
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4957
-                                    }
4958
-                                }
4959
-                            } elseif ( $import_choice == 'skip' ) {
4960
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4961
-                                    $skipped++;
4962
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4963
-                                    $skipped++;
4964
-                                } else {
4965
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4966
-                                        $created++;
4967
-                                    } else {
4968
-                                        $invalid++;
4969
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4970
-                                    }
4971
-                                }
4972
-                            } else {
4973
-                                $invalid++;
4974
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4975
-                            }
4976
-                        }
4977
-                    }
4978
-                }
4945
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4946
+										$updated++;
4947
+									} else {
4948
+										$invalid++;
4949
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4950
+									}
4951
+								} else {
4952
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4953
+										$created++;
4954
+									} else {
4955
+										$invalid++;
4956
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4957
+									}
4958
+								}
4959
+							} elseif ( $import_choice == 'skip' ) {
4960
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4961
+									$skipped++;
4962
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4963
+									$skipped++;
4964
+								} else {
4965
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4966
+										$created++;
4967
+									} else {
4968
+										$invalid++;
4969
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4970
+									}
4971
+								}
4972
+							} else {
4973
+								$invalid++;
4974
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4975
+							}
4976
+						}
4977
+					}
4978
+				}
4979 4979
                 
4980
-                $json = array();
4981
-                $json['processed'] = $limit;
4982
-                $json['created'] = $created;
4983
-                $json['updated'] = $updated;
4984
-                $json['skipped'] = $skipped;
4985
-                $json['invalid'] = $invalid;
4986
-                $json['images'] = $images;
4980
+				$json = array();
4981
+				$json['processed'] = $limit;
4982
+				$json['created'] = $created;
4983
+				$json['updated'] = $updated;
4984
+				$json['skipped'] = $skipped;
4985
+				$json['invalid'] = $invalid;
4986
+				$json['images'] = $images;
4987 4987
                 
4988
-                wp_send_json( $json );
4989
-            } else if ( $task == 'import_hood' ) {               
4990
-                if (!empty($file)) {
4991
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4988
+				wp_send_json( $json );
4989
+			} else if ( $task == 'import_hood' ) {               
4990
+				if (!empty($file)) {
4991
+					$columns = isset($file[0]) ? $file[0] : NULL;
4992 4992
                     
4993
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4994
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4995
-                        wp_send_json( $json );
4996
-                    }
4993
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4994
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4995
+						wp_send_json( $json );
4996
+					}
4997 4997
                     
4998
-                    $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4999
-                    $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' );
5000
-                    for ($i = 1; $i <= $limit; $i++) {
5001
-                        $index = $processed + $i;
4998
+					$gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4999
+					$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' );
5000
+					for ($i = 1; $i <= $limit; $i++) {
5001
+						$index = $processed + $i;
5002 5002
                         
5003
-                        if (isset($file[$index])) {
5004
-                            $row = $file[$index];
5005
-                            $row = array_map( 'trim', $row );
5006
-                            $data = array();
5003
+						if (isset($file[$index])) {
5004
+							$row = $file[$index];
5005
+							$row = array_map( 'trim', $row );
5006
+							$data = array();
5007 5007
                             
5008
-                            foreach ($columns as $c => $column) {
5009
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5010
-                                    $data[$column] = sanitize_text_field($row[$c]);
5011
-                                }
5012
-                            }
5008
+							foreach ($columns as $c => $column) {
5009
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5010
+									$data[$column] = sanitize_text_field($row[$c]);
5011
+								}
5012
+							}
5013 5013
 
5014
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5015
-                                $invalid++;
5016
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5017
-                                continue;
5018
-                            }
5014
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5015
+								$invalid++;
5016
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5017
+								continue;
5018
+							}
5019 5019
                             
5020
-                            $location_info = array();
5021
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5022
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5023
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5024
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5025
-                            }
5020
+							$location_info = array();
5021
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5022
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5023
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5024
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5025
+							}
5026 5026
 
5027
-                            if (empty($location_info)) {
5028
-                                $invalid++;
5029
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5030
-                                continue;
5031
-                            }
5027
+							if (empty($location_info)) {
5028
+								$invalid++;
5029
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5030
+								continue;
5031
+							}
5032 5032
                             
5033
-                            $location_id = $location_info->location_id;
5033
+							$location_id = $location_info->location_id;
5034 5034
 
5035
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5035
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5036 5036
                             
5037
-                            $hood_data = array();
5038
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
5039
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
5040
-                            $hood_data['hood_latitude'] = $data['latitude'];
5041
-                            $hood_data['hood_longitude'] = $data['longitude'];
5042
-                            $hood_data['hood_location_id'] = $location_id;
5037
+							$hood_data = array();
5038
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
5039
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
5040
+							$hood_data['hood_latitude'] = $data['latitude'];
5041
+							$hood_data['hood_longitude'] = $data['longitude'];
5042
+							$hood_data['hood_location_id'] = $location_id;
5043 5043
                                     
5044
-                            if ( $import_choice == 'update' ) {
5045
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5046
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5044
+							if ( $import_choice == 'update' ) {
5045
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5046
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5047 5047
                                     
5048
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5049
-                                        $updated++;
5050
-                                    } else {
5051
-                                        $invalid++;
5052
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5053
-                                    }
5054
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5055
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5048
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5049
+										$updated++;
5050
+									} else {
5051
+										$invalid++;
5052
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5053
+									}
5054
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5055
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5056 5056
                                     
5057
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5058
-                                        $updated++;
5059
-                                    } else {
5060
-                                        $invalid++;
5061
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5062
-                                    }
5063
-                                } else {
5064
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5065
-                                        $created++;
5066
-                                    } else {
5067
-                                        $invalid++;
5068
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5069
-                                    }
5070
-                                }
5071
-                            } elseif ( $import_choice == 'skip' ) {
5072
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5073
-                                    $skipped++;
5074
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5075
-                                    $skipped++;
5076
-                                } else {
5057
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5058
+										$updated++;
5059
+									} else {
5060
+										$invalid++;
5061
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5062
+									}
5063
+								} else {
5064
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5065
+										$created++;
5066
+									} else {
5067
+										$invalid++;
5068
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5069
+									}
5070
+								}
5071
+							} elseif ( $import_choice == 'skip' ) {
5072
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5073
+									$skipped++;
5074
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5075
+									$skipped++;
5076
+								} else {
5077 5077
                                     
5078
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5079
-                                        $created++;
5080
-                                    } else {
5081
-                                        $invalid++;
5082
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5083
-                                    }
5084
-                                }
5085
-                            } else {
5086
-                                $invalid++;
5087
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5088
-                            }
5089
-                        }
5090
-                    }
5091
-                }
5078
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5079
+										$created++;
5080
+									} else {
5081
+										$invalid++;
5082
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5083
+									}
5084
+								}
5085
+							} else {
5086
+								$invalid++;
5087
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5088
+							}
5089
+						}
5090
+					}
5091
+				}
5092 5092
                 
5093
-                $json = array();
5094
-                $json['processed'] = $limit;
5095
-                $json['created'] = $created;
5096
-                $json['updated'] = $updated;
5097
-                $json['skipped'] = $skipped;
5098
-                $json['invalid'] = $invalid;
5099
-                $json['images'] = $images;
5093
+				$json = array();
5094
+				$json['processed'] = $limit;
5095
+				$json['created'] = $created;
5096
+				$json['updated'] = $updated;
5097
+				$json['skipped'] = $skipped;
5098
+				$json['invalid'] = $invalid;
5099
+				$json['images'] = $images;
5100 5100
                 
5101
-                wp_send_json( $json );
5102
-            }
5103
-        }
5104
-        break;
5105
-        case 'import_finish':{
5106
-            /**
5107
-             * Run an action when an import finishes.
5108
-             *
5109
-             * This action can be used to fire functions after an import ends.
5110
-             *
5111
-             * @since 1.5.3
5112
-             * @package GeoDirectory
5113
-             */
5114
-            do_action('geodir_import_finished');
5115
-        }
5116
-        break;
5101
+				wp_send_json( $json );
5102
+			}
5103
+		}
5104
+		break;
5105
+		case 'import_finish':{
5106
+			/**
5107
+			 * Run an action when an import finishes.
5108
+			 *
5109
+			 * This action can be used to fire functions after an import ends.
5110
+			 *
5111
+			 * @since 1.5.3
5112
+			 * @package GeoDirectory
5113
+			 */
5114
+			do_action('geodir_import_finished');
5115
+		}
5116
+		break;
5117 5117
 
5118
-    }
5119
-    echo '0';
5120
-    gd_die();
5118
+	}
5119
+	echo '0';
5120
+	gd_die();
5121 5121
 }
5122 5122
 
5123 5123
 /**
@@ -5161,12 +5161,12 @@  discard block
 block discarded – undo
5161 5161
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5162 5162
 	}
5163 5163
 	
5164
-    if( !empty( $term ) ) {
5164
+	if( !empty( $term ) ) {
5165 5165
 		$result = wp_insert_term( $term, $taxonomy, $args );
5166
-        if( !is_wp_error( $result ) ) {
5167
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5168
-        }
5169
-    }
5166
+		if( !is_wp_error( $result ) ) {
5167
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5168
+		}
5169
+	}
5170 5170
 	
5171 5171
 	return false;
5172 5172
 }
@@ -5212,16 +5212,16 @@  discard block
 block discarded – undo
5212 5212
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5213 5213
 		
5214 5214
 		if( !is_wp_error( $result ) ) {
5215
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5216
-        }
5215
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5216
+		}
5217 5217
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5218 5218
 		$term_data['term_id'] = $term_info['term_id'];
5219 5219
 		
5220 5220
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5221 5221
 		
5222 5222
 		if( !is_wp_error( $result ) ) {
5223
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5224
-        }
5223
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5224
+		}
5225 5225
 	} else {
5226 5226
 		return geodir_imex_insert_term( $taxonomy, $term_data );
5227 5227
 	}
@@ -5242,37 +5242,37 @@  discard block
 block discarded – undo
5242 5242
  * @return int Posts count.
5243 5243
  */
5244 5244
 function geodir_get_posts_count( $post_type ) {
5245
-    global $wpdb, $plugin_prefix;
5245
+	global $wpdb, $plugin_prefix;
5246 5246
 
5247
-    if ( !post_type_exists( $post_type ) ) {
5248
-        return 0;
5249
-    }
5247
+	if ( !post_type_exists( $post_type ) ) {
5248
+		return 0;
5249
+	}
5250 5250
         
5251
-    $table = $plugin_prefix . $post_type . '_detail';
5251
+	$table = $plugin_prefix . $post_type . '_detail';
5252 5252
 
5253
-    // Skip listing with statuses trash, auto-draft etc...
5254
-    $skip_statuses = geodir_imex_export_skip_statuses();
5255
-    $where_statuses = '';
5256
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5257
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5258
-    }
5253
+	// Skip listing with statuses trash, auto-draft etc...
5254
+	$skip_statuses = geodir_imex_export_skip_statuses();
5255
+	$where_statuses = '';
5256
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5257
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5258
+	}
5259 5259
 
5260
-    $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 );
5260
+	$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 );
5261 5261
 
5262
-    $posts_count = (int)$wpdb->get_var( $query );
5262
+	$posts_count = (int)$wpdb->get_var( $query );
5263 5263
     
5264
-    /**
5265
-     * Modify returned post counts for the current post type.
5266
-     *
5267
-     * @since 1.4.6
5268
-     * @package GeoDirectory
5269
-     *
5270
-     * @param int $posts_count Post counts.
5271
-     * @param string $post_type Post type.
5272
-     */
5273
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5274
-
5275
-    return $posts_count;
5264
+	/**
5265
+	 * Modify returned post counts for the current post type.
5266
+	 *
5267
+	 * @since 1.4.6
5268
+	 * @package GeoDirectory
5269
+	 *
5270
+	 * @param int $posts_count Post counts.
5271
+	 * @param string $post_type Post type.
5272
+	 */
5273
+	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5274
+
5275
+	return $posts_count;
5276 5276
 }
5277 5277
 
5278 5278
 /**
@@ -5300,9 +5300,9 @@  discard block
 block discarded – undo
5300 5300
 	
5301 5301
 	if ( !empty( $posts ) ) {
5302 5302
 		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5303
-        $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5304
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5305
-        $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5303
+		$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5304
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5305
+		$neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5306 5306
 		
5307 5307
 		$csv_row = array();
5308 5308
 		$csv_row[] = 'post_id';
@@ -5346,11 +5346,11 @@  discard block
 block discarded – undo
5346 5346
 		$csv_row[] = 'post_zip';
5347 5347
 		$csv_row[] = 'post_latitude';
5348 5348
 		$csv_row[] = 'post_longitude';
5349
-        if ($neighbourhood_active) {
5350
-            $csv_row[] = 'post_neighbourhood';
5351
-            $csv_row[] = 'neighbourhood_latitude';
5352
-            $csv_row[] = 'neighbourhood_longitude';
5353
-        }
5349
+		if ($neighbourhood_active) {
5350
+			$csv_row[] = 'post_neighbourhood';
5351
+			$csv_row[] = 'neighbourhood_latitude';
5352
+			$csv_row[] = 'neighbourhood_longitude';
5353
+		}
5354 5354
 		$csv_row[] = 'geodir_timing';
5355 5355
 		$csv_row[] = 'geodir_contact';
5356 5356
 		$csv_row[] = 'geodir_email';
@@ -5385,7 +5385,7 @@  discard block
 block discarded – undo
5385 5385
 		$csv_rows[] = $csv_row;
5386 5386
 
5387 5387
 		$images_count = 5;
5388
-        $xx=0;
5388
+		$xx=0;
5389 5389
 		foreach ( $posts as $post ) {$xx++;
5390 5390
 			$post_id = $post['ID'];
5391 5391
 			
@@ -5528,21 +5528,21 @@  discard block
 block discarded – undo
5528 5528
 			$csv_row[] = $post_info['post_zip']; // post_zip
5529 5529
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5530 5530
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5531
-            if ($neighbourhood_active) {
5532
-                $post_neighbourhood = '';
5533
-                $neighbourhood_latitude = '';
5534
-                $neighbourhood_longitude = '';
5535
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5536
-                    if (!empty($hood_info)) {
5537
-                        $post_neighbourhood = $hood_info->hood_name;
5538
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5539
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5540
-                    }
5541
-                }
5542
-                $csv_row[] = $post_neighbourhood; // post_neighbourhood
5543
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5544
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5545
-            }
5531
+			if ($neighbourhood_active) {
5532
+				$post_neighbourhood = '';
5533
+				$neighbourhood_latitude = '';
5534
+				$neighbourhood_longitude = '';
5535
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5536
+					if (!empty($hood_info)) {
5537
+						$post_neighbourhood = $hood_info->hood_name;
5538
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5539
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5540
+					}
5541
+				}
5542
+				$csv_row[] = $post_neighbourhood; // post_neighbourhood
5543
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5544
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5545
+			}
5546 5546
 			$csv_row[] = $post_info['geodir_timing']; // geodir_timing
5547 5547
 			$csv_row[] = $post_info['geodir_contact']; // geodir_contact
5548 5548
 			$csv_row[] = $post_info['geodir_email']; // geodir_email
@@ -5613,55 +5613,55 @@  discard block
 block discarded – undo
5613 5613
  * @return array Array of posts data.
5614 5614
  */
5615 5615
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5616
-    global $wpdb, $plugin_prefix;
5616
+	global $wpdb, $plugin_prefix;
5617 5617
 
5618
-    if ( ! post_type_exists( $post_type ) )
5619
-        return new stdClass;
5618
+	if ( ! post_type_exists( $post_type ) )
5619
+		return new stdClass;
5620 5620
         
5621
-    $table = $plugin_prefix . $post_type . '_detail';
5621
+	$table = $plugin_prefix . $post_type . '_detail';
5622 5622
 
5623
-    $limit = '';
5624
-    if ( $per_page > 0 && $page_no > 0 ) {
5625
-        $offset = ( $page_no - 1 ) * $per_page;
5623
+	$limit = '';
5624
+	if ( $per_page > 0 && $page_no > 0 ) {
5625
+		$offset = ( $page_no - 1 ) * $per_page;
5626 5626
         
5627
-        if ( $offset > 0 ) {
5628
-            $limit = " LIMIT " . $offset . "," . $per_page;
5629
-        } else {
5630
-            $limit = " LIMIT " . $per_page;
5631
-        }
5632
-    }
5627
+		if ( $offset > 0 ) {
5628
+			$limit = " LIMIT " . $offset . "," . $per_page;
5629
+		} else {
5630
+			$limit = " LIMIT " . $per_page;
5631
+		}
5632
+	}
5633 5633
 
5634
-    // Skip listing with statuses trash, auto-draft etc...
5635
-    $skip_statuses = geodir_imex_export_skip_statuses();
5636
-    $where_statuses = '';
5637
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5638
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5639
-    }
5634
+	// Skip listing with statuses trash, auto-draft etc...
5635
+	$skip_statuses = geodir_imex_export_skip_statuses();
5636
+	$where_statuses = '';
5637
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5638
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5639
+	}
5640
+
5641
+	$query = "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;
5642
+	/**
5643
+	 * Modify returned posts SQL query for the current post type.
5644
+	 *
5645
+	 * @since 1.4.6
5646
+	 * @package GeoDirectory
5647
+	 *
5648
+	 * @param int $query The SQL query.
5649
+	 * @param string $post_type Post type.
5650
+	 */
5651
+	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5652
+
5653
+	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5640 5654
 
5641
-    $query = "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;
5642
-    /**
5643
-     * Modify returned posts SQL query for the current post type.
5644
-     *
5645
-     * @since 1.4.6
5646
-     * @package GeoDirectory
5647
-     *
5648
-     * @param int $query The SQL query.
5649
-     * @param string $post_type Post type.
5650
-     */
5651
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5652
-
5653
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5654
-
5655
-    /**
5656
-     * Modify returned post results for the current post type.
5657
-     *
5658
-     * @since 1.4.6
5659
-     * @package GeoDirectory
5660
-     *
5661
-     * @param object $results An object containing all post ids.
5662
-     * @param string $post_type Post type.
5663
-     */
5664
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5655
+	/**
5656
+	 * Modify returned post results for the current post type.
5657
+	 *
5658
+	 * @since 1.4.6
5659
+	 * @package GeoDirectory
5660
+	 *
5661
+	 * @param object $results An object containing all post ids.
5662
+	 * @param string $post_type Post type.
5663
+	 */
5664
+	return apply_filters( 'geodir_export_posts', $results, $post_type );
5665 5665
 }
5666 5666
 
5667 5667
 /**
@@ -5679,23 +5679,23 @@  discard block
 block discarded – undo
5679 5679
  * @return string The SQL query.
5680 5680
  */
5681 5681
 function geodir_imex_get_events_query( $query, $post_type ) {
5682
-    if ( $post_type == 'gd_event' ) {
5683
-        global $wpdb, $plugin_prefix;
5682
+	if ( $post_type == 'gd_event' ) {
5683
+		global $wpdb, $plugin_prefix;
5684 5684
         
5685
-        $table = $plugin_prefix . $post_type . '_detail';
5686
-        $schedule_table = EVENT_SCHEDULE;
5685
+		$table = $plugin_prefix . $post_type . '_detail';
5686
+		$schedule_table = EVENT_SCHEDULE;
5687 5687
         
5688
-        // Skip listing with statuses trash, auto-draft etc...
5689
-        $skip_statuses = geodir_imex_export_skip_statuses();
5690
-        $where_statuses = '';
5691
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5692
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5693
-        }
5688
+		// Skip listing with statuses trash, auto-draft etc...
5689
+		$skip_statuses = geodir_imex_export_skip_statuses();
5690
+		$where_statuses = '';
5691
+		if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5692
+			$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5693
+		}
5694 5694
 
5695
-        $query = "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";
5696
-    }
5695
+		$query = "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";
5696
+	}
5697 5697
 
5698
-    return $query;
5698
+	return $query;
5699 5699
 }
5700 5700
 
5701 5701
 /**
@@ -5717,36 +5717,36 @@  discard block
 block discarded – undo
5717 5717
  * @return int Total terms count.
5718 5718
  */
5719 5719
 function geodir_get_terms_count( $post_type ) {
5720
-    $args = array( 'hide_empty' => 0 );
5720
+	$args = array( 'hide_empty' => 0 );
5721 5721
 
5722
-    remove_all_filters( 'get_terms' );
5722
+	remove_all_filters( 'get_terms' );
5723 5723
 
5724
-    $taxonomy = $post_type . 'category';
5724
+	$taxonomy = $post_type . 'category';
5725 5725
 
5726
-    // WPML
5727
-    $is_wpml = geodir_is_wpml();
5728
-    $active_lang = 'all';
5729
-    if ( $is_wpml ) {
5730
-        global $sitepress;
5731
-        $active_lang = $sitepress->get_current_language();
5726
+	// WPML
5727
+	$is_wpml = geodir_is_wpml();
5728
+	$active_lang = 'all';
5729
+	if ( $is_wpml ) {
5730
+		global $sitepress;
5731
+		$active_lang = $sitepress->get_current_language();
5732 5732
         
5733
-        if ( $active_lang != 'all' ) {
5734
-            $sitepress->switch_lang( 'all', true );
5735
-        }
5736
-    }
5737
-    // WPML
5733
+		if ( $active_lang != 'all' ) {
5734
+			$sitepress->switch_lang( 'all', true );
5735
+		}
5736
+	}
5737
+	// WPML
5738 5738
             
5739
-    $count_terms = wp_count_terms( $taxonomy, $args );
5739
+	$count_terms = wp_count_terms( $taxonomy, $args );
5740 5740
 
5741
-    // WPML
5742
-    if ( $is_wpml && $active_lang !== 'all' ) {
5743
-        global $sitepress;
5744
-        $sitepress->switch_lang( $active_lang, true );
5745
-    }
5746
-    // WPML
5747
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5741
+	// WPML
5742
+	if ( $is_wpml && $active_lang !== 'all' ) {
5743
+		global $sitepress;
5744
+		$sitepress->switch_lang( $active_lang, true );
5745
+	}
5746
+	// WPML
5747
+	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5748 5748
      
5749
-    return $count_terms;
5749
+	return $count_terms;
5750 5750
 }
5751 5751
 
5752 5752
 /**
@@ -5785,11 +5785,11 @@  discard block
 block discarded – undo
5785 5785
 		$csv_row[] = 'cat_posttype';
5786 5786
 		$csv_row[] = 'cat_parent';
5787 5787
 		$csv_row[] = 'cat_schema';
5788
-        // WPML
5788
+		// WPML
5789 5789
 		$is_wpml = geodir_is_wpml();
5790 5790
 		if ($is_wpml) {
5791 5791
 			$csv_row[] = 'cat_language';
5792
-            $csv_row[] = 'cat_id_original';
5792
+			$csv_row[] = 'cat_id_original';
5793 5793
 		}
5794 5794
 		// WPML
5795 5795
 		$csv_row[] = 'cat_description';
@@ -5819,10 +5819,10 @@  discard block
 block discarded – undo
5819 5819
 			$csv_row[] = $post_type;
5820 5820
 			$csv_row[] = $cat_parent;
5821 5821
 			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5822
-            // WPML
5822
+			// WPML
5823 5823
 			if ($is_wpml) {
5824 5824
 				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5825
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5825
+				$csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5826 5826
 			}
5827 5827
 			// WPML
5828 5828
 			$csv_row[] = $term->description;
@@ -6418,43 +6418,43 @@  discard block
 block discarded – undo
6418 6418
  * @param string $status Post status.
6419 6419
  */
6420 6420
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6421
-    global $wpdb, $current_user;
6422
-
6423
-    $option_value = get_option($option);
6424
-
6425
-    if ($option_value > 0) :
6426
-        if (get_post($option_value)) :
6427
-            // Page exists
6428
-            return;
6429
-        endif;
6430
-    endif;
6431
-
6432
-    $page_found = $wpdb->get_var(
6433
-        $wpdb->prepare(
6434
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6435
-            array($slug)
6436
-        )
6437
-    );
6438
-
6439
-    if ($page_found) :
6440
-        // Page exists
6441
-        if (!$option_value) update_option($option, $page_found);
6442
-        return;
6443
-    endif;
6444
-
6445
-    $page_data = array(
6446
-        'post_status' => $status,
6447
-        'post_type' => 'page',
6448
-        'post_author' => $current_user->ID,
6449
-        'post_name' => $slug,
6450
-        'post_title' => $page_title,
6451
-        'post_content' => $page_content,
6452
-        'post_parent' => $post_parent,
6453
-        'comment_status' => 'closed'
6454
-    );
6455
-    $page_id = wp_insert_post($page_data);
6456
-
6457
-    add_option($option, $page_id);
6421
+	global $wpdb, $current_user;
6422
+
6423
+	$option_value = get_option($option);
6424
+
6425
+	if ($option_value > 0) :
6426
+		if (get_post($option_value)) :
6427
+			// Page exists
6428
+			return;
6429
+		endif;
6430
+	endif;
6431
+
6432
+	$page_found = $wpdb->get_var(
6433
+		$wpdb->prepare(
6434
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6435
+			array($slug)
6436
+		)
6437
+	);
6438
+
6439
+	if ($page_found) :
6440
+		// Page exists
6441
+		if (!$option_value) update_option($option, $page_found);
6442
+		return;
6443
+	endif;
6444
+
6445
+	$page_data = array(
6446
+		'post_status' => $status,
6447
+		'post_type' => 'page',
6448
+		'post_author' => $current_user->ID,
6449
+		'post_name' => $slug,
6450
+		'post_title' => $page_title,
6451
+		'post_content' => $page_content,
6452
+		'post_parent' => $post_parent,
6453
+		'comment_status' => 'closed'
6454
+	);
6455
+	$page_id = wp_insert_post($page_data);
6456
+
6457
+	add_option($option, $page_id);
6458 6458
 
6459 6459
 }
6460 6460
 
@@ -6485,9 +6485,9 @@  discard block
 block discarded – undo
6485 6485
  * @package GeoDirectory
6486 6486
  */
6487 6487
 function geodir_admin_upgrade_notice() {
6488
-    $class = "error";
6489
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6490
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6488
+	$class = "error";
6489
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6490
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6491 6491
 }
6492 6492
 
6493 6493
 /**
@@ -6500,18 +6500,18 @@  discard block
 block discarded – undo
6500 6500
  */
6501 6501
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6502 6502
 {
6503
-    // readme contents
6504
-    $args = array(
6505
-        'timeout'     => 15,
6506
-        'redirection' => 5
6507
-    );
6508
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6509
-    $data       = wp_remote_get( $url, $args );
6503
+	// readme contents
6504
+	$args = array(
6505
+		'timeout'     => 15,
6506
+		'redirection' => 5
6507
+	);
6508
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6509
+	$data       = wp_remote_get( $url, $args );
6510 6510
 
6511
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6511
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6512 6512
 
6513
-        geodir_in_plugin_update_message($data['body']);
6514
-    }
6513
+		geodir_in_plugin_update_message($data['body']);
6514
+	}
6515 6515
 }
6516 6516
 
6517 6517
 
@@ -6519,28 +6519,28 @@  discard block
 block discarded – undo
6519 6519
 * @param string $content http response body
6520 6520
 */
6521 6521
 function geodir_in_plugin_update_message($content) {
6522
-    // Output Upgrade Notice
6523
-    $matches        = null;
6524
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6525
-    $upgrade_notice = '';
6526
-    if ( preg_match( $regexp, $content, $matches ) ) {
6527
-        if(empty($matches)){return;}
6528
-
6529
-        $version = trim( $matches[1] );
6530
-        if($version && $version>GEODIRECTORY_VERSION){
6531
-
6532
-
6533
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6534
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6535
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6536
-            foreach ( $notices as $index => $line ) {
6537
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6538
-            }
6539
-            $upgrade_notice .= '</div> ';
6540
-        }
6541
-        }
6542
-    }
6543
-    echo $upgrade_notice;
6522
+	// Output Upgrade Notice
6523
+	$matches        = null;
6524
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6525
+	$upgrade_notice = '';
6526
+	if ( preg_match( $regexp, $content, $matches ) ) {
6527
+		if(empty($matches)){return;}
6528
+
6529
+		$version = trim( $matches[1] );
6530
+		if($version && $version>GEODIRECTORY_VERSION){
6531
+
6532
+
6533
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6534
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6535
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6536
+			foreach ( $notices as $index => $line ) {
6537
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6538
+			}
6539
+			$upgrade_notice .= '</div> ';
6540
+		}
6541
+		}
6542
+	}
6543
+	echo $upgrade_notice;
6544 6544
 }
6545 6545
 
6546 6546
 /**
@@ -6573,19 +6573,19 @@  discard block
 block discarded – undo
6573 6573
  * @param array Listing statuses to be skipped.
6574 6574
  */
6575 6575
 function geodir_imex_export_skip_statuses() {
6576
-    $statuses = array( 'trash', 'auto-draft' );
6576
+	$statuses = array( 'trash', 'auto-draft' );
6577 6577
     
6578
-    /**
6579
-     * Filter the statuses to skip during GD export listings.
6580
-     *
6581
-     * @since 1.6.0
6582
-     * @package GeoDirectory
6583
-     *
6584
-     * @param array $statuses Listing statuses to be skipped.
6585
-     */
6586
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6578
+	/**
6579
+	 * Filter the statuses to skip during GD export listings.
6580
+	 *
6581
+	 * @since 1.6.0
6582
+	 * @package GeoDirectory
6583
+	 *
6584
+	 * @param array $statuses Listing statuses to be skipped.
6585
+	 */
6586
+	$statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6587 6587
      
6588
-    return $statuses;
6588
+	return $statuses;
6589 6589
 }
6590 6590
 
6591 6591
 /**
@@ -6597,15 +6597,15 @@  discard block
 block discarded – undo
6597 6597
  * @since 1.6.3
6598 6598
  */
6599 6599
 function geodir_admin_dequeue_scripts() {
6600
-    // EDD
6601
-    if (wp_script_is('jquery-chosen', 'enqueued')) {
6602
-        wp_dequeue_script('jquery-chosen');
6603
-    }
6600
+	// EDD
6601
+	if (wp_script_is('jquery-chosen', 'enqueued')) {
6602
+		wp_dequeue_script('jquery-chosen');
6603
+	}
6604 6604
     
6605
-    // Ultimate Addons for Visual Composer
6606
-    if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6607
-        wp_dequeue_script('ultimate-vc-backend-script');
6608
-    }
6605
+	// Ultimate Addons for Visual Composer
6606
+	if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6607
+		wp_dequeue_script('ultimate-vc-backend-script');
6608
+	}
6609 6609
 }
6610 6610
 
6611 6611
 /*
Please login to merge, or discard this patch.
geodirectory-admin/admin_hooks_actions.php 1 patch
Indentation   +1300 added lines, -1300 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@  discard block
 block discarded – undo
10 10
 
11 11
 add_action('admin_init', 'geodir_admin_init');
12 12
 if (!function_exists('geodir_admin_init')) {
13
-    /**
14
-     * Adds GD setting pages in admin.
15
-     *
16
-     * @since 1.0.0
17
-     * @package GeoDirectory
18
-     * @global string $current_tab The current settings tab name.
19
-     */
20
-    function geodir_admin_init()
21
-    {
22
-
23
-        if (is_admin()):
24
-            global $current_tab;
25
-            geodir_redirect_to_admin_panel_on_installed();
26
-            $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
-            if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
-                geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
-            /**
30
-             * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
-             *
32
-             * @since 1.0.0
33
-             */
34
-            do_action('admin_panel_init');
35
-            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
-
37
-
38
-        endif;
39
-    }
13
+	/**
14
+	 * Adds GD setting pages in admin.
15
+	 *
16
+	 * @since 1.0.0
17
+	 * @package GeoDirectory
18
+	 * @global string $current_tab The current settings tab name.
19
+	 */
20
+	function geodir_admin_init()
21
+	{
22
+
23
+		if (is_admin()):
24
+			global $current_tab;
25
+			geodir_redirect_to_admin_panel_on_installed();
26
+			$current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings';
27
+			if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests
28
+				geodir_handle_option_form_submit($current_tab); // located in admin function.php
29
+			/**
30
+			 * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area.
31
+			 *
32
+			 * @since 1.0.0
33
+			 */
34
+			do_action('admin_panel_init');
35
+			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
36
+
37
+
38
+		endif;
39
+	}
40 40
 }
41 41
 
42 42
 /**
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function geodir_redirect_to_admin_panel_on_installed()
49 49
 {
50
-    if (get_option('geodir_installation_redirect', false)) {
51
-        delete_option('geodir_installation_redirect');
52
-        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
-    }
50
+	if (get_option('geodir_installation_redirect', false)) {
51
+		delete_option('geodir_installation_redirect');
52
+		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
53
+	}
54 54
 }
55 55
 
56 56
 /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function geodir_get_admin_option_form($current_tab)
64 64
 {
65
-    geodir_admin_option_form($current_tab);// defined in admin template tags.php
65
+	geodir_admin_option_form($current_tab);// defined in admin template tags.php
66 66
 }
67 67
 
68 68
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function geodir_conditional_admin_script_load()
87 87
 {
88
-    global $pagenow;
88
+	global $pagenow;
89 89
 	
90 90
 	// Get the current post type
91 91
 	$post_type = geodir_admin_current_post_type();
92 92
 	$geodir_post_types = geodir_get_posttypes();
93 93
     
94 94
 	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
95
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
-        add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
-    }
95
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
96
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
97
+		add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
98
+	}
99 99
 
100
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
100
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
101 101
 
102 102
 }
103 103
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function create_default_admin_main_nav()
133 133
 {
134
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
134
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
135
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
136
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
137
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
138
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
139
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
140 140
 
141 141
 }
142 142
 
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function geodir_admin_list_columns()
151 151
 {
152
-    if ($post_types = geodir_get_posttypes()) {
152
+	if ($post_types = geodir_get_posttypes()) {
153 153
 
154
-        foreach ($post_types as $post_type):
155
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
-            //Filter-Payment-Manager to show Package
157
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
154
+		foreach ($post_types as $post_type):
155
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
156
+			//Filter-Payment-Manager to show Package
157
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
158 158
 
159
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
-        endforeach;
161
-    }
159
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
160
+		endforeach;
161
+	}
162 162
 }
163 163
 
164 164
 /**
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
  */
172 172
 function geodir_default_admin_main_tabs($tabs)
173 173
 {
174
-    return $tabs = array(
175
-        'general_settings' => array('label' => __('General', 'geodirectory')),
176
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
177
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
-
182
-    );
174
+	return $tabs = array(
175
+		'general_settings' => array('label' => __('General', 'geodirectory')),
176
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
177
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
178
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
179
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
180
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
181
+
182
+	);
183 183
 }
184 184
 
185 185
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
  */
193 193
 function geodir_remove_image_box()
194 194
 {
195
-    global $post;
195
+	global $post;
196 196
 
197
-    $geodir_posttypes = geodir_get_posttypes();
197
+	$geodir_posttypes = geodir_get_posttypes();
198 198
 
199
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
199
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
200 200
 
201
-        remove_meta_box('postimagediv', $post->post_type, 'side');
202
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
201
+		remove_meta_box('postimagediv', $post->post_type, 'side');
202
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
203 203
 
204
-    endif;
204
+	endif;
205 205
 
206 206
 }
207 207
 
@@ -216,26 +216,26 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function geodir_meta_box_add()
218 218
 {
219
-    global $post;
219
+	global $post;
220 220
 
221
-    $geodir_post_types = geodir_get_posttypes('array');
222
-    $geodir_posttypes = array_keys($geodir_post_types);
221
+	$geodir_post_types = geodir_get_posttypes('array');
222
+	$geodir_posttypes = array_keys($geodir_post_types);
223 223
 
224
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
224
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
225 225
 
226
-        $geodir_posttype = $post->post_type;
227
-        $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
226
+		$geodir_posttype = $post->post_type;
227
+		$post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
228 228
 
229
-        // Filter-Payment-Manager
229
+		// Filter-Payment-Manager
230 230
 
231
-        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
231
+		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
232 232
 
233
-        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
233
+		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
234 234
 
235
-        // no need of this box as all fields moved to main information box
236
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
235
+		// no need of this box as all fields moved to main information box
236
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
237 237
 
238
-    endif;
238
+	endif;
239 239
 
240 240
 }
241 241
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
 function geodir_hide_post_taxonomy_meta_boxes()
260 260
 {
261 261
 
262
-    $geodir_post_types = get_option('geodir_post_types');
262
+	$geodir_post_types = get_option('geodir_post_types');
263 263
 
264
-    if (!empty($geodir_post_types)) {
265
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
264
+	if (!empty($geodir_post_types)) {
265
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
266 266
 
267
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
267
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
268 268
 
269
-            if(!empty($gd_taxonomy)) {
270
-                foreach ($gd_taxonomy as $tax) {
269
+			if(!empty($gd_taxonomy)) {
270
+				foreach ($gd_taxonomy as $tax) {
271 271
 
272
-                    remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
272
+					remove_meta_box($tax . 'div', $geodir_post_type, 'normal');
273 273
 
274
-                }
275
-            }
274
+				}
275
+			}
276 276
 
277
-        }
278
-    }
277
+		}
278
+	}
279 279
 }
280 280
 
281 281
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
  */
290 290
 function geodir_add_listing_map_restrict($map_restirct)
291 291
 {
292
-    if (is_admin()) {
293
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
-            $map_restirct = false;
295
-        }
296
-    }
297
-    return $map_restirct;
292
+	if (is_admin()) {
293
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
294
+			$map_restirct = false;
295
+		}
296
+	}
297
+	return $map_restirct;
298 298
 }
299 299
 
300 300
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 function geodir_enable_editor_on_notifications($notification)
314 314
 {
315 315
 
316
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
316
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
317 317
 
318
-        foreach ($notification as $key => $value) {
319
-            if ($value['type'] == 'textarea')
320
-                $notification[$key]['type'] = 'editor';
321
-        }
318
+		foreach ($notification as $key => $value) {
319
+			if ($value['type'] == 'textarea')
320
+				$notification[$key]['type'] = 'editor';
321
+		}
322 322
 
323
-    }
323
+	}
324 324
 
325
-    return $notification;
325
+	return $notification;
326 326
 }
327 327
 
328 328
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 function geodir_enable_editor_on_design_settings($design_setting)
340 340
 {
341 341
 
342
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
342
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
343 343
 
344
-        foreach ($design_setting as $key => $value) {
345
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
-                $design_setting[$key]['type'] = 'editor';
347
-        }
344
+		foreach ($design_setting as $key => $value) {
345
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
346
+				$design_setting[$key]['type'] = 'editor';
347
+		}
348 348
 
349
-    }
349
+	}
350 350
 
351
-    return $design_setting;
351
+	return $design_setting;
352 352
 }
353 353
 
354 354
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 function geodir_manage_available_fields($sub_tab)
370 370
 {
371 371
 
372
-    switch ($sub_tab) {
373
-        case 'custom_fields':
374
-            geodir_custom_available_fields();
375
-            break;
372
+	switch ($sub_tab) {
373
+		case 'custom_fields':
374
+			geodir_custom_available_fields();
375
+			break;
376 376
 
377
-        case 'sorting_options':
378
-            geodir_sorting_options_available_fields();
379
-            break;
377
+		case 'sorting_options':
378
+			geodir_sorting_options_available_fields();
379
+			break;
380 380
 
381
-    }
381
+	}
382 382
 }
383 383
 
384 384
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 function geodir_manage_selected_fields($sub_tab)
395 395
 {
396 396
 
397
-    switch ($sub_tab) {
398
-        case 'custom_fields':
399
-            geodir_custom_selected_fields();
400
-            break;
397
+	switch ($sub_tab) {
398
+		case 'custom_fields':
399
+			geodir_custom_selected_fields();
400
+			break;
401 401
 
402
-        case 'sorting_options':
403
-            geodir_sorting_options_selected_fields();
404
-            break;
402
+		case 'sorting_options':
403
+			geodir_sorting_options_selected_fields();
404
+			break;
405 405
 
406
-    }
406
+	}
407 407
 }
408 408
 
409 409
 /**
@@ -415,27 +415,27 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function geodir_sorting_options_available_fields()
417 417
 {
418
-    global $wpdb;
419
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
420
-    ?>
418
+	global $wpdb;
419
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
420
+	?>
421 421
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
422 422
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
423 423
     <ul>
424 424
     <?php
425
-        $sort_options = geodir_get_custom_sort_options($listing_type);
425
+		$sort_options = geodir_get_custom_sort_options($listing_type);
426 426
         
427
-        foreach ($sort_options as $key => $val) {
428
-            $val = stripslashes_deep($val); // strip slashes
429
-
430
-            $check_html_variable = $wpdb->get_var(
431
-                $wpdb->prepare(
432
-                    "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
433
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
434
-                )
435
-            );
427
+		foreach ($sort_options as $key => $val) {
428
+			$val = stripslashes_deep($val); // strip slashes
429
+
430
+			$check_html_variable = $wpdb->get_var(
431
+				$wpdb->prepare(
432
+					"SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s",
433
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
434
+				)
435
+			);
436 436
             
437
-            $display = $check_html_variable ? ' style="display:none;"' : '';
438
-            ?>
437
+			$display = $check_html_variable ? ' style="display:none;"' : '';
438
+			?>
439 439
             <li <?php echo $display;?>>
440 440
             <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
441 441
                title="<?php echo $val['site_title'];?>"
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
                href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
444 444
             </li>
445 445
             <?php
446
-        }
447
-    ?>
446
+		}
447
+	?>
448 448
     </ul>
449 449
     <?php
450 450
 }
@@ -458,28 +458,28 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function geodir_sorting_options_selected_fields()
460 460
 {
461
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
462
-    ?>
461
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
462
+	?>
463 463
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
464 464
     <ul class="core">
465 465
     <?php 
466
-        global $wpdb;
466
+		global $wpdb;
467 467
         
468
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
468
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
469 469
 
470
-        if (!empty($fields)) {
471
-            foreach ($fields as $field) {
472
-                //$result_str = $field->id;
473
-                $result_str = $field;
474
-                $field_type = $field->field_type;
475
-                $field_ins_upd = 'display';
470
+		if (!empty($fields)) {
471
+			foreach ($fields as $field) {
472
+				//$result_str = $field->id;
473
+				$result_str = $field;
474
+				$field_type = $field->field_type;
475
+				$field_ins_upd = 'display';
476 476
 
477
-                $default = false;
477
+				$default = false;
478 478
 
479
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
480
-            }
481
-        }
482
-    ?>
479
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
480
+			}
481
+		}
482
+	?>
483 483
     </ul>
484 484
     <?php
485 485
 }
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
  */
493 493
 function geodir_custom_available_fields()
494 494
 {
495
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
496
-    ?>
495
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
496
+	?>
497 497
     <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/>
498 498
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
499 499
     <ul class="full">
@@ -544,25 +544,25 @@  discard block
 block discarded – undo
544 544
  */
545 545
 function geodir_custom_selected_fields()
546 546
 {
547
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
548
-    ?>
547
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
548
+	?>
549 549
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
550 550
     <ul class="core">
551 551
     <?php 
552
-        global $wpdb;
553
-        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
554
-
555
-        if (!empty($fields)) {
556
-            foreach ($fields as $field) {
557
-                //$result_str = $field->id;
558
-                $result_str = $field;
559
-                $field_type = $field->field_type;
560
-                $field_ins_upd = 'display';
561
-
562
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
563
-            }
564
-        }
565
-        ?></ul>
552
+		global $wpdb;
553
+		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
554
+
555
+		if (!empty($fields)) {
556
+			foreach ($fields as $field) {
557
+				//$result_str = $field->id;
558
+				$result_str = $field;
559
+				$field_type = $field->field_type;
560
+				$field_ins_upd = 'display';
561
+
562
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
563
+			}
564
+		}
565
+		?></ul>
566 566
 <?php
567 567
 
568 568
 }
@@ -581,16 +581,16 @@  discard block
 block discarded – undo
581 581
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
582 582
 {
583 583
 
584
-    switch ($sub_tab) {
585
-        case 'custom_fields':
586
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
587
-            break;
584
+	switch ($sub_tab) {
585
+		case 'custom_fields':
586
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
587
+			break;
588 588
 
589
-        case 'sorting_options':
590
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
591
-            break;
592
-    }
593
-    return $heading;
589
+		case 'sorting_options':
590
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
591
+			break;
592
+	}
593
+	return $heading;
594 594
 }
595 595
 
596 596
 
@@ -608,16 +608,16 @@  discard block
 block discarded – undo
608 608
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
609 609
 {
610 610
 
611
-    switch ($sub_tab) {
612
-        case 'custom_fields':
613
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
614
-            break;
611
+	switch ($sub_tab) {
612
+		case 'custom_fields':
613
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
614
+			break;
615 615
 
616
-        case 'sorting_options':
617
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
618
-            break;
619
-    }
620
-    return $heading;
616
+		case 'sorting_options':
617
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
618
+			break;
619
+	}
620
+	return $heading;
621 621
 }
622 622
 
623 623
 
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
636 636
 {
637 637
 
638
-    switch ($sub_tab) {
639
-        case 'custom_fields':
640
-            $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
641
-            break;
638
+	switch ($sub_tab) {
639
+		case 'custom_fields':
640
+			$note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
641
+			break;
642 642
 
643
-        case 'sorting_options':
644
-            $note = sprintf(__('Click on any box below to make it appear in sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
645
-            break;
646
-    }
647
-    return $note;
643
+		case 'sorting_options':
644
+			$note = sprintf(__('Click on any box below to make it appear in sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
645
+			break;
646
+	}
647
+	return $note;
648 648
 }
649 649
 
650 650
 
@@ -662,16 +662,16 @@  discard block
 block discarded – undo
662 662
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
663 663
 {
664 664
 
665
-    switch ($sub_tab) {
666
-        case 'custom_fields':
667
-            $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
668
-            break;
665
+	switch ($sub_tab) {
666
+		case 'custom_fields':
667
+			$heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
668
+			break;
669 669
 
670
-        case 'sorting_options':
671
-            $heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
672
-            break;
673
-    }
674
-    return $heading;
670
+		case 'sorting_options':
671
+			$heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
672
+			break;
673
+	}
674
+	return $heading;
675 675
 }
676 676
 
677 677
 
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
690 690
 {
691 691
 
692
-    switch ($sub_tab) {
693
-        case 'custom_fields':
694
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
695
-            break;
692
+	switch ($sub_tab) {
693
+		case 'custom_fields':
694
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
695
+			break;
696 696
 
697
-        case 'sorting_options':
698
-            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
699
-            break;
700
-    }
701
-    return $note;
697
+		case 'sorting_options':
698
+			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
699
+			break;
700
+	}
701
+	return $note;
702 702
 }
703 703
 
704 704
 
@@ -714,16 +714,16 @@  discard block
 block discarded – undo
714 714
  */
715 715
 function geodir_remove_unnecessary_fields()
716 716
 {
717
-    global $wpdb, $plugin_prefix;
717
+	global $wpdb, $plugin_prefix;
718 718
 
719
-    if (!get_option('geodir_remove_unnecessary_fields')) {
719
+	if (!get_option('geodir_remove_unnecessary_fields')) {
720 720
 
721
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
722
-            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
721
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
722
+			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
723 723
 
724
-        update_option('geodir_remove_unnecessary_fields', '1');
724
+		update_option('geodir_remove_unnecessary_fields', '1');
725 725
 
726
-    }
726
+	}
727 727
 
728 728
 }
729 729
 
@@ -741,25 +741,25 @@  discard block
 block discarded – undo
741 741
  */
742 742
 function geodir_admin_ajax_handler()
743 743
 {
744
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
745
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
746
-        switch ($geodir_admin_ajax_action) {
747
-            case 'diagnosis' :
748
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
749
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
750
-                call_user_func('geodir_diagnose_' . $diagnose_this);
751
-                exit();
752
-                break;
753
-
754
-            case 'diagnosis-fix' :
755
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
756
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
757
-                call_user_func('geodir_diagnose_' . $diagnose_this);
758
-                exit();
759
-                break;
760
-        }
761
-    }
762
-    exit();
744
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
745
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
746
+		switch ($geodir_admin_ajax_action) {
747
+			case 'diagnosis' :
748
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
749
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
750
+				call_user_func('geodir_diagnose_' . $diagnose_this);
751
+				exit();
752
+				break;
753
+
754
+			case 'diagnosis-fix' :
755
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
756
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
757
+				call_user_func('geodir_diagnose_' . $diagnose_this);
758
+				exit();
759
+				break;
760
+		}
761
+	}
762
+	exit();
763 763
 }
764 764
 
765 765
 
@@ -777,127 +777,127 @@  discard block
 block discarded – undo
777 777
  */
778 778
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
779 779
 {
780
-    global $wpdb;
781
-    //$filter_arr['output_str'] .='###'.$table.'###';
782
-    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
783
-        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
784
-        $filter_arr['is_error_during_diagnose'] = true;
785
-
786
-    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
787
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
788
-        $filter_arr['is_error_during_diagnose'] = true;
789
-        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
790
-        $filter_arr['is_error_during_diagnose'] = true;
791
-
792
-        if ($fix) {
793
-            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
794
-            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
795
-
796
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
797
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
798
-
799
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
800
-
801
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
802
-                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
803
-                } else {
804
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
805
-                }
806
-
807
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
808
-
809
-                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
810
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
811
-
812
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
813
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
814
-                } else {
815
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
816
-                }
817
-
818
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
819
-
820
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
821
-
822
-                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
823
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
824
-                } else {
825
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
826
-                }
827
-
828
-            }
829
-
830
-        }
831
-
832
-
833
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
834
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
835
-        $filter_arr['is_error_during_diagnose'] = true;
836
-
837
-        if ($fix) {
838
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
839
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
840
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
841
-                } else {
842
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
843
-                }
844
-
845
-            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
846
-                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
847
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
848
-                } else {
849
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
850
-                }
851
-                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
852
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
853
-                } else {
854
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
855
-                }
856
-            } else {// else rename the original table to _ms_bak
857
-                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
858
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
859
-                } else {
860
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
861
-                }
862
-            }
863
-        }
864
-
865
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
866
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
867
-        $filter_arr['is_error_during_diagnose'] = true;
868
-
869
-        if ($fix) {
870
-            // if original table exists but new does not, rename
871
-            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
872
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
873
-            } else {
874
-                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
875
-            }
876
-
877
-        }
878
-
879
-    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
880
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
881
-        $filter_arr['is_error_during_diagnose'] = true;
882
-
883
-        if ($fix) {
884
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
885
-            delete_option('geodirlocation_db_version');
886
-            delete_option('geodirevents_db_version');
887
-            delete_option('geodir_reviewrating_db_version');
888
-            delete_option('gdevents_db_version');
889
-            delete_option('geodirectory_db_version');
890
-            delete_option('geodirclaim_db_version');
891
-            delete_option('geodir_custom_posts_db_version');
892
-            delete_option('geodir_reviewratings_db_version');
893
-            delete_option('geodiradvancesearch_db_version');
894
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
895
-        }
896
-
897
-    } else {
898
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
899
-    }
900
-    return $filter_arr;
780
+	global $wpdb;
781
+	//$filter_arr['output_str'] .='###'.$table.'###';
782
+	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
783
+		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
784
+		$filter_arr['is_error_during_diagnose'] = true;
785
+
786
+	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
787
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
788
+		$filter_arr['is_error_during_diagnose'] = true;
789
+		$filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
790
+		$filter_arr['is_error_during_diagnose'] = true;
791
+
792
+		if ($fix) {
793
+			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
794
+			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
795
+
796
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
797
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
798
+
799
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
800
+
801
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
802
+					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
803
+				} else {
804
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
805
+				}
806
+
807
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
808
+
809
+				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
810
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
811
+
812
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
813
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
814
+				} else {
815
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
816
+				}
817
+
818
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
819
+
820
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
821
+
822
+				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
823
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
824
+				} else {
825
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
826
+				}
827
+
828
+			}
829
+
830
+		}
831
+
832
+
833
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
834
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
835
+		$filter_arr['is_error_during_diagnose'] = true;
836
+
837
+		if ($fix) {
838
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
839
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
840
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
841
+				} else {
842
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
843
+				}
844
+
845
+			} elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
846
+				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
847
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
848
+				} else {
849
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
850
+				}
851
+				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
852
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
853
+				} else {
854
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
855
+				}
856
+			} else {// else rename the original table to _ms_bak
857
+				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
858
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
859
+				} else {
860
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
861
+				}
862
+			}
863
+		}
864
+
865
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
866
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
867
+		$filter_arr['is_error_during_diagnose'] = true;
868
+
869
+		if ($fix) {
870
+			// if original table exists but new does not, rename
871
+			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
872
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
873
+			} else {
874
+				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
875
+			}
876
+
877
+		}
878
+
879
+	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
880
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
881
+		$filter_arr['is_error_during_diagnose'] = true;
882
+
883
+		if ($fix) {
884
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
885
+			delete_option('geodirlocation_db_version');
886
+			delete_option('geodirevents_db_version');
887
+			delete_option('geodir_reviewrating_db_version');
888
+			delete_option('gdevents_db_version');
889
+			delete_option('geodirectory_db_version');
890
+			delete_option('geodirclaim_db_version');
891
+			delete_option('geodir_custom_posts_db_version');
892
+			delete_option('geodir_reviewratings_db_version');
893
+			delete_option('geodiradvancesearch_db_version');
894
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
895
+		}
896
+
897
+	} else {
898
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
899
+	}
900
+	return $filter_arr;
901 901
 }
902 902
 
903 903
 
@@ -911,53 +911,53 @@  discard block
 block discarded – undo
911 911
  */
912 912
 function geodir_diagnose_tags_sync()
913 913
 {
914
-    global $wpdb, $plugin_prefix;
915
-    $fix = isset($_POST['fix']) ? true : false;
916
-
917
-    //if($fix){echo 'true';}else{echo 'false';}
918
-    $is_error_during_diagnose = false;
919
-    $output_str = '';
920
-
921
-
922
-    $all_postypes = geodir_get_posttypes();
923
-
924
-    if (!empty($all_postypes)) {
925
-        foreach ($all_postypes as $key) {
926
-            // update each GD CPT
927
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
928
-
929
-            if (!empty($posts)) {
930
-
931
-                foreach ($posts as $p) {
932
-                    $p->post_type = $key;
933
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
934
-                    if (empty($raw_tags)) {
935
-                        $post_tags = '';
936
-                    } else {
937
-                        $post_tags = implode(",", $raw_tags);
938
-                    }
939
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
940
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
941
-
942
-                }
943
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
944
-            }
945
-
946
-        }
947
-
948
-    }
949
-
950
-    if ($is_error_during_diagnose) {
951
-        $info_div_class = "geodir_problem_info";
952
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
953
-    } else {
954
-        $info_div_class = "geodir_noproblem_info";
955
-        $fix_button_txt = '';
956
-    }
957
-    echo "<ul class='$info_div_class'>";
958
-    echo $output_str;
959
-    echo $fix_button_txt;
960
-    echo "</ul>";
914
+	global $wpdb, $plugin_prefix;
915
+	$fix = isset($_POST['fix']) ? true : false;
916
+
917
+	//if($fix){echo 'true';}else{echo 'false';}
918
+	$is_error_during_diagnose = false;
919
+	$output_str = '';
920
+
921
+
922
+	$all_postypes = geodir_get_posttypes();
923
+
924
+	if (!empty($all_postypes)) {
925
+		foreach ($all_postypes as $key) {
926
+			// update each GD CPT
927
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
928
+
929
+			if (!empty($posts)) {
930
+
931
+				foreach ($posts as $p) {
932
+					$p->post_type = $key;
933
+					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
934
+					if (empty($raw_tags)) {
935
+						$post_tags = '';
936
+					} else {
937
+						$post_tags = implode(",", $raw_tags);
938
+					}
939
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
940
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
941
+
942
+				}
943
+				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
944
+			}
945
+
946
+		}
947
+
948
+	}
949
+
950
+	if ($is_error_during_diagnose) {
951
+		$info_div_class = "geodir_problem_info";
952
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
953
+	} else {
954
+		$info_div_class = "geodir_noproblem_info";
955
+		$fix_button_txt = '';
956
+	}
957
+	echo "<ul class='$info_div_class'>";
958
+	echo $output_str;
959
+	echo $fix_button_txt;
960
+	echo "</ul>";
961 961
 
962 962
 }
963 963
 
@@ -973,75 +973,75 @@  discard block
 block discarded – undo
973 973
  */
974 974
 function geodir_diagnose_cats_sync()
975 975
 {
976
-    global $wpdb, $plugin_prefix;
977
-    $fix = isset($_POST['fix']) ? true : false;
976
+	global $wpdb, $plugin_prefix;
977
+	$fix = isset($_POST['fix']) ? true : false;
978 978
 
979
-    //if($fix){echo 'true';}else{echo 'false';}
980
-    $is_error_during_diagnose = false;
981
-    $output_str = '';
979
+	//if($fix){echo 'true';}else{echo 'false';}
980
+	$is_error_during_diagnose = false;
981
+	$output_str = '';
982 982
 
983 983
 
984
-    $all_postypes = geodir_get_posttypes();
984
+	$all_postypes = geodir_get_posttypes();
985 985
 
986
-    if (!empty($all_postypes)) {
987
-        foreach ($all_postypes as $key) {
988
-            // update each GD CTP
989
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
986
+	if (!empty($all_postypes)) {
987
+		foreach ($all_postypes as $key) {
988
+			// update each GD CTP
989
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
990 990
 
991
-            if (!empty($posts)) {
991
+			if (!empty($posts)) {
992 992
 
993
-                foreach ($posts as $p) {
994
-                    $p->post_type = $key;
995
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
993
+				foreach ($posts as $p) {
994
+					$p->post_type = $key;
995
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
996 996
 
997
-                    if (empty($raw_cats)) {
998
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
997
+					if (empty($raw_cats)) {
998
+						$post_categories = get_post_meta($p->post_id, 'post_categories', true);
999 999
 
1000
-                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1001
-                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1002
-                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1003
-                                if (is_numeric($cat_part)) {
1004
-                                    $raw_cats[] = (int)$cat_part;
1005
-                                }
1006
-                            }
1000
+						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
1001
+							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
1002
+							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
1003
+								if (is_numeric($cat_part)) {
1004
+									$raw_cats[] = (int)$cat_part;
1005
+								}
1006
+							}
1007 1007
 
1008
-                        }
1008
+						}
1009 1009
 
1010
-                        if (!empty($raw_cats)) {
1011
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1010
+						if (!empty($raw_cats)) {
1011
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1012 1012
 
1013
-                        }
1013
+						}
1014 1014
 
1015
-                    }
1015
+					}
1016 1016
 
1017 1017
 
1018
-                    if (empty($raw_cats)) {
1019
-                        $post_cats = '';
1020
-                    } else {
1021
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
1022
-                    }
1023
-                    $tablename = $plugin_prefix . $p->post_type . '_detail';
1024
-                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1025
-                }
1018
+					if (empty($raw_cats)) {
1019
+						$post_cats = '';
1020
+					} else {
1021
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
1022
+					}
1023
+					$tablename = $plugin_prefix . $p->post_type . '_detail';
1024
+					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
1025
+				}
1026 1026
 
1027
-            }
1028
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1027
+			}
1028
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1029 1029
 
1030
-        }
1030
+		}
1031 1031
 
1032
-    }
1032
+	}
1033 1033
 
1034
-    if ($is_error_during_diagnose) {
1035
-        $info_div_class = "geodir_problem_info";
1036
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1037
-    } else {
1038
-        $info_div_class = "geodir_noproblem_info";
1039
-        $fix_button_txt = '';
1040
-    }
1041
-    echo "<ul class='$info_div_class'>";
1042
-    echo $output_str;
1043
-    echo $fix_button_txt;
1044
-    echo "</ul>";
1034
+	if ($is_error_during_diagnose) {
1035
+		$info_div_class = "geodir_problem_info";
1036
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1037
+	} else {
1038
+		$info_div_class = "geodir_noproblem_info";
1039
+		$fix_button_txt = '';
1040
+	}
1041
+	echo "<ul class='$info_div_class'>";
1042
+	echo $output_str;
1043
+	echo $fix_button_txt;
1044
+	echo "</ul>";
1045 1045
 
1046 1046
 }
1047 1047
 
@@ -1055,61 +1055,61 @@  discard block
 block discarded – undo
1055 1055
  */
1056 1056
 function geodir_diagnose_version_clear()
1057 1057
 {
1058
-    global $wpdb, $plugin_prefix;
1059
-    $fix = isset($_POST['fix']) ? true : false;
1060
-
1061
-    //if($fix){echo 'true';}else{echo 'false';}
1062
-    $is_error_during_diagnose = false;
1063
-    $output_str = '';
1064
-
1065
-
1066
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1067
-        'Payment Manager' => 'geodir_payments_db_version',
1068
-        'GeoDirectory Framework' => 'gdf_db_version',
1069
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1070
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1071
-        'Claim Manager' => 'geodirclaim_db_version',
1072
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1073
-        'Location Manager' => 'geodirlocation_db_version',
1074
-        'Payment Manager' => 'geodir_payments_db_version',
1075
-        'Events Manager' => 'geodirevents_db_version',
1076
-    );
1077
-
1078
-    /**
1079
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1080
-     *
1081
-     * @since 1.0.0
1082
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1083
-     */
1084
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1085
-
1086
-    if (!empty($ver_arr)) {
1087
-        foreach ($ver_arr as $key => $val) {
1088
-            if (delete_option($val)) {
1089
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1090
-            } else {
1091
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1092
-            }
1093
-
1094
-        }
1095
-
1096
-        if ($output_str) {
1097
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1098
-        }
1099
-
1100
-    }
1101
-
1102
-    if ($is_error_during_diagnose) {
1103
-        $info_div_class = "geodir_problem_info";
1104
-        $fix_button_txt = "";
1105
-    } else {
1106
-        $info_div_class = "geodir_noproblem_info";
1107
-        $fix_button_txt = '';
1108
-    }
1109
-    echo "<ul class='$info_div_class'>";
1110
-    echo $output_str;
1111
-    echo $fix_button_txt;
1112
-    echo "</ul>";
1058
+	global $wpdb, $plugin_prefix;
1059
+	$fix = isset($_POST['fix']) ? true : false;
1060
+
1061
+	//if($fix){echo 'true';}else{echo 'false';}
1062
+	$is_error_during_diagnose = false;
1063
+	$output_str = '';
1064
+
1065
+
1066
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1067
+		'Payment Manager' => 'geodir_payments_db_version',
1068
+		'GeoDirectory Framework' => 'gdf_db_version',
1069
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1070
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1071
+		'Claim Manager' => 'geodirclaim_db_version',
1072
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1073
+		'Location Manager' => 'geodirlocation_db_version',
1074
+		'Payment Manager' => 'geodir_payments_db_version',
1075
+		'Events Manager' => 'geodirevents_db_version',
1076
+	);
1077
+
1078
+	/**
1079
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1080
+	 *
1081
+	 * @since 1.0.0
1082
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1083
+	 */
1084
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1085
+
1086
+	if (!empty($ver_arr)) {
1087
+		foreach ($ver_arr as $key => $val) {
1088
+			if (delete_option($val)) {
1089
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1090
+			} else {
1091
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1092
+			}
1093
+
1094
+		}
1095
+
1096
+		if ($output_str) {
1097
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1098
+		}
1099
+
1100
+	}
1101
+
1102
+	if ($is_error_during_diagnose) {
1103
+		$info_div_class = "geodir_problem_info";
1104
+		$fix_button_txt = "";
1105
+	} else {
1106
+		$info_div_class = "geodir_noproblem_info";
1107
+		$fix_button_txt = '';
1108
+	}
1109
+	echo "<ul class='$info_div_class'>";
1110
+	echo $output_str;
1111
+	echo $fix_button_txt;
1112
+	echo "</ul>";
1113 1113
 
1114 1114
 }
1115 1115
 
@@ -1123,59 +1123,59 @@  discard block
 block discarded – undo
1123 1123
  */
1124 1124
 function geodir_diagnose_ratings()
1125 1125
 {
1126
-    global $wpdb;
1127
-    $fix = isset($_POST['fix']) ? true : false;
1128
-
1129
-    //if($fix){echo 'true';}else{echo 'false';}
1130
-    $is_error_during_diagnose = false;
1131
-    $output_str = '';
1132
-
1133
-    // check review locations
1134
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1135
-        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1136
-        $is_error_during_diagnose = true;
1137
-
1138
-        if ($fix) {
1139
-            if (geodir_fix_review_location()) {
1140
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1141
-            } else {
1142
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1143
-            }
1144
-        }
1145
-
1146
-    } else {
1147
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1148
-    }
1149
-
1150
-    // check review content
1151
-    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1152
-        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1153
-        $is_error_during_diagnose = true;
1154
-
1155
-        if ($fix) {
1156
-            if (geodir_fix_review_content()) {
1157
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1158
-            } else {
1159
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1160
-            }
1161
-        }
1162
-
1163
-    } else {
1164
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1165
-    }
1166
-
1167
-
1168
-    if ($is_error_during_diagnose) {
1169
-        $info_div_class = "geodir_problem_info";
1170
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1171
-    } else {
1172
-        $info_div_class = "geodir_noproblem_info";
1173
-        $fix_button_txt = '';
1174
-    }
1175
-    echo "<ul class='$info_div_class'>";
1176
-    echo $output_str;
1177
-    echo $fix_button_txt;
1178
-    echo "</ul>";
1126
+	global $wpdb;
1127
+	$fix = isset($_POST['fix']) ? true : false;
1128
+
1129
+	//if($fix){echo 'true';}else{echo 'false';}
1130
+	$is_error_during_diagnose = false;
1131
+	$output_str = '';
1132
+
1133
+	// check review locations
1134
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
1135
+		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
1136
+		$is_error_during_diagnose = true;
1137
+
1138
+		if ($fix) {
1139
+			if (geodir_fix_review_location()) {
1140
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1141
+			} else {
1142
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1143
+			}
1144
+		}
1145
+
1146
+	} else {
1147
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1148
+	}
1149
+
1150
+	// check review content
1151
+	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
1152
+		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
1153
+		$is_error_during_diagnose = true;
1154
+
1155
+		if ($fix) {
1156
+			if (geodir_fix_review_content()) {
1157
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1158
+			} else {
1159
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1160
+			}
1161
+		}
1162
+
1163
+	} else {
1164
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1165
+	}
1166
+
1167
+
1168
+	if ($is_error_during_diagnose) {
1169
+		$info_div_class = "geodir_problem_info";
1170
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
1171
+	} else {
1172
+		$info_div_class = "geodir_noproblem_info";
1173
+		$fix_button_txt = '';
1174
+	}
1175
+	echo "<ul class='$info_div_class'>";
1176
+	echo $output_str;
1177
+	echo $fix_button_txt;
1178
+	echo "</ul>";
1179 1179
 
1180 1180
 }
1181 1181
 
@@ -1189,57 +1189,57 @@  discard block
 block discarded – undo
1189 1189
  */
1190 1190
 function geodir_diagnose_multisite_conversion()
1191 1191
 {
1192
-    global $wpdb;
1193
-    $fix = isset($_POST['fix']) ? true : false;
1194
-    //if($fix){echo 'true';}else{echo 'false';}
1195
-    $is_error_during_diagnose = false;
1196
-    $output_str = '';
1197
-
1198
-    $filter_arr = array();
1199
-    $filter_arr['output_str'] = $output_str;
1200
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1201
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1202
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1203
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1204
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1205
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1206
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1207
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1208
-    );
1209
-
1210
-    // allow other addons to hook in and add their checks
1211
-
1212
-    /**
1213
-     * Filter the array of tables.
1214
-     *
1215
-     * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1216
-     *
1217
-     * @since 1.0.0
1218
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1219
-     */
1220
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1221
-
1222
-    foreach ($table_arr as $table => $table_name) {
1223
-        // Diagnose table
1224
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1225
-    }
1226
-
1227
-
1228
-    $output_str = $filter_arr['output_str'];
1229
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1230
-
1231
-
1232
-    if ($is_error_during_diagnose) {
1233
-        $info_div_class = "geodir_problem_info";
1234
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1235
-    } else {
1236
-        $info_div_class = "geodir_noproblem_info";
1237
-        $fix_button_txt = '';
1238
-    }
1239
-    echo "<ul class='$info_div_class'>";
1240
-    echo $output_str;
1241
-    echo $fix_button_txt;
1242
-    echo "</ul>";
1192
+	global $wpdb;
1193
+	$fix = isset($_POST['fix']) ? true : false;
1194
+	//if($fix){echo 'true';}else{echo 'false';}
1195
+	$is_error_during_diagnose = false;
1196
+	$output_str = '';
1197
+
1198
+	$filter_arr = array();
1199
+	$filter_arr['output_str'] = $output_str;
1200
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1201
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1202
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1203
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1204
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1205
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1206
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1207
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1208
+	);
1209
+
1210
+	// allow other addons to hook in and add their checks
1211
+
1212
+	/**
1213
+	 * Filter the array of tables.
1214
+	 *
1215
+	 * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks.
1216
+	 *
1217
+	 * @since 1.0.0
1218
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1219
+	 */
1220
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1221
+
1222
+	foreach ($table_arr as $table => $table_name) {
1223
+		// Diagnose table
1224
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1225
+	}
1226
+
1227
+
1228
+	$output_str = $filter_arr['output_str'];
1229
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1230
+
1231
+
1232
+	if ($is_error_during_diagnose) {
1233
+		$info_div_class = "geodir_problem_info";
1234
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
1235
+	} else {
1236
+		$info_div_class = "geodir_noproblem_info";
1237
+		$fix_button_txt = '';
1238
+	}
1239
+	echo "<ul class='$info_div_class'>";
1240
+	echo $output_str;
1241
+	echo $fix_button_txt;
1242
+	echo "</ul>";
1243 1243
 }
1244 1244
 
1245 1245
 /**
@@ -1257,39 +1257,39 @@  discard block
 block discarded – undo
1257 1257
  */
1258 1258
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1259 1259
 {
1260
-    global $wpdb, $current_user;
1261
-
1262
-    if (!empty($old_id)) {
1263
-        wp_delete_post($old_id, true);
1264
-    }//delete post if already there
1265
-    else {
1266
-        $page_found = $wpdb->get_var(
1267
-            $wpdb->prepare(
1268
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1269
-                array($slug)
1270
-            )
1271
-        );
1272
-        wp_delete_post($page_found, true);
1273
-
1274
-    }
1275
-
1276
-    $page_data = array(
1277
-        'post_status' => 'publish',
1278
-        'post_type' => 'page',
1279
-        'post_author' => $current_user->ID,
1280
-        'post_name' => $slug,
1281
-        'post_title' => $page_title,
1282
-        'post_content' => '',
1283
-        'post_parent' => 0,
1284
-        'comment_status' => 'closed'
1285
-    );
1286
-    $page_id = wp_insert_post($page_data);
1287
-    update_option($option, $page_id);
1288
-    if ($page_id) {
1289
-        return true;
1290
-    } else {
1291
-        return false;
1292
-    }
1260
+	global $wpdb, $current_user;
1261
+
1262
+	if (!empty($old_id)) {
1263
+		wp_delete_post($old_id, true);
1264
+	}//delete post if already there
1265
+	else {
1266
+		$page_found = $wpdb->get_var(
1267
+			$wpdb->prepare(
1268
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1269
+				array($slug)
1270
+			)
1271
+		);
1272
+		wp_delete_post($page_found, true);
1273
+
1274
+	}
1275
+
1276
+	$page_data = array(
1277
+		'post_status' => 'publish',
1278
+		'post_type' => 'page',
1279
+		'post_author' => $current_user->ID,
1280
+		'post_name' => $slug,
1281
+		'post_title' => $page_title,
1282
+		'post_content' => '',
1283
+		'post_parent' => 0,
1284
+		'comment_status' => 'closed'
1285
+	);
1286
+	$page_id = wp_insert_post($page_data);
1287
+	update_option($option, $page_id);
1288
+	if ($page_id) {
1289
+		return true;
1290
+	} else {
1291
+		return false;
1292
+	}
1293 1293
 }
1294 1294
 
1295 1295
 /**
@@ -1301,212 +1301,212 @@  discard block
 block discarded – undo
1301 1301
  */
1302 1302
 function geodir_diagnose_default_pages()
1303 1303
 {
1304
-    global $wpdb;
1305
-    $is_error_during_diagnose = false;
1306
-    $output_str = '';
1307
-    $fix = isset($_POST['fix']) ? true : false;
1308
-
1309
-    //////////////////////////////////
1310
-    /* Diagnose GD Home Page Starts */
1311
-    //////////////////////////////////
1312
-    $option_value = get_option('geodir_home_page');
1313
-    $page = get_post($option_value);
1314
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1315
-
1316
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1317
-        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1318
-    else {
1319
-        $is_error_during_diagnose = true;
1320
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1321
-        if ($fix) {
1322
-            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1323
-                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1324
-            } else {
1325
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1326
-            }
1327
-        }
1328
-    }
1329
-
1330
-    ////////////////////////////////
1331
-    /* Diagnose GD Home Page Ends */
1332
-    ////////////////////////////////
1333
-
1334
-    //////////////////////////////////
1335
-    /* Diagnose Add Listing Page Starts */
1336
-    //////////////////////////////////
1337
-    $option_value = get_option('geodir_add_listing_page');
1338
-    $page = get_post($option_value);
1339
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1340
-
1341
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1342
-        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1343
-    else {
1344
-        $is_error_during_diagnose = true;
1345
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1346
-        if ($fix) {
1347
-            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1348
-                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1349
-            } else {
1350
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1351
-            }
1352
-        }
1353
-    }
1354
-
1355
-    ////////////////////////////////
1356
-    /* Diagnose Add Listing Page Ends */
1357
-    ////////////////////////////////
1358
-
1359
-
1360
-    //////////////////////////////////
1361
-    /* Diagnose Listing Preview Page Starts */
1362
-    //////////////////////////////////
1363
-    $option_value = get_option('geodir_preview_page');
1364
-    $page = get_post($option_value);
1365
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1366
-
1367
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1368
-        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1369
-    else {
1370
-        $is_error_during_diagnose = true;
1371
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1372
-        if ($fix) {
1373
-            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1374
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1375
-            } else {
1376
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1377
-            }
1378
-        }
1379
-    }
1380
-
1381
-    ////////////////////////////////
1382
-    /* Diagnose Listing Preview Page Ends */
1383
-    ////////////////////////////////
1384
-
1385
-    //////////////////////////////////
1386
-    /* Diagnose Listing Success Page Starts */
1387
-    //////////////////////////////////
1388
-    $option_value = get_option('geodir_success_page');
1389
-    $page = get_post($option_value);
1390
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1391
-
1392
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1393
-        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1394
-    else {
1395
-        $is_error_during_diagnose = true;
1396
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1397
-        if ($fix) {
1398
-            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1399
-                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1400
-            } else {
1401
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1402
-            }
1403
-        }
1404
-    }
1405
-
1406
-    ////////////////////////////////
1407
-    /* Diagnose Listing Sucess Page Ends */
1408
-    ////////////////////////////////
1409
-
1410
-    //////////////////////////////////
1411
-    /* Diagnose Info Page Starts */
1412
-    //////////////////////////////////
1413
-    $option_value = get_option('geodir_info_page');
1414
-    $page = get_post($option_value);
1415
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1416
-
1417
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1418
-        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1419
-    else {
1420
-        $is_error_during_diagnose = true;
1421
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1422
-        if ($fix) {
1423
-            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1424
-                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1425
-            } else {
1426
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1427
-            }
1428
-        }
1429
-    }
1430
-
1431
-    ////////////////////////////////
1432
-    /* Diagnose Info Page Ends */
1433
-    ////////////////////////////////
1434
-
1435
-    //////////////////////////////////
1436
-    /* Diagnose Login Page Starts */
1437
-    //////////////////////////////////
1438
-    $option_value = get_option('geodir_login_page');
1439
-    $page = get_post($option_value);
1440
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1441
-
1442
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1443
-        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1444
-    else {
1445
-        $is_error_during_diagnose = true;
1446
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1447
-        if ($fix) {
1448
-            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1449
-                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1450
-            } else {
1451
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1452
-            }
1453
-        }
1454
-    }
1455
-
1456
-    ////////////////////////////////
1457
-    /* Diagnose Info Page Ends */
1458
-    ////////////////////////////////
1459
-
1460
-    //////////////////////////////////
1461
-    /* Diagnose Location Page Starts */
1462
-    //////////////////////////////////
1463
-    $option_value = get_option('geodir_location_page');
1464
-    $page = get_post($option_value);
1465
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1466
-
1467
-    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1468
-        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1469
-    else {
1470
-        $is_error_during_diagnose = true;
1471
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1472
-        if ($fix) {
1473
-            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1474
-                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1475
-            } else {
1476
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1477
-            }
1478
-        }
1479
-    }
1480
-
1481
-    ////////////////////////////////
1482
-    /* Diagnose Location Page Ends */
1483
-    ////////////////////////////////
1484
-
1485
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1486
-    /**
1487
-     * This action is called at the end of the GD Tools page check function.
1488
-     *
1489
-     * @since 1.5.2
1490
-     */
1491
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1492
-
1493
-    $output_str = $page_chk_arr['output_str'];
1494
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1495
-
1496
-    if ($is_error_during_diagnose) {
1497
-        if ($fix) {
1498
-            flush_rewrite_rules();
1499
-        }
1500
-        $info_div_class = "geodir_problem_info";
1501
-        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1502
-    } else {
1503
-        $info_div_class = "geodir_noproblem_info";
1504
-        $fix_button_txt = '';
1505
-    }
1506
-    echo "<ul class='$info_div_class'>";
1507
-    echo $output_str;
1508
-    echo $fix_button_txt;
1509
-    echo "</ul>";
1304
+	global $wpdb;
1305
+	$is_error_during_diagnose = false;
1306
+	$output_str = '';
1307
+	$fix = isset($_POST['fix']) ? true : false;
1308
+
1309
+	//////////////////////////////////
1310
+	/* Diagnose GD Home Page Starts */
1311
+	//////////////////////////////////
1312
+	$option_value = get_option('geodir_home_page');
1313
+	$page = get_post($option_value);
1314
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1315
+
1316
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1317
+		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
1318
+	else {
1319
+		$is_error_during_diagnose = true;
1320
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1321
+		if ($fix) {
1322
+			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
1323
+				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
1324
+			} else {
1325
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1326
+			}
1327
+		}
1328
+	}
1329
+
1330
+	////////////////////////////////
1331
+	/* Diagnose GD Home Page Ends */
1332
+	////////////////////////////////
1333
+
1334
+	//////////////////////////////////
1335
+	/* Diagnose Add Listing Page Starts */
1336
+	//////////////////////////////////
1337
+	$option_value = get_option('geodir_add_listing_page');
1338
+	$page = get_post($option_value);
1339
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1340
+
1341
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1342
+		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
1343
+	else {
1344
+		$is_error_during_diagnose = true;
1345
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1346
+		if ($fix) {
1347
+			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
1348
+				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
1349
+			} else {
1350
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1351
+			}
1352
+		}
1353
+	}
1354
+
1355
+	////////////////////////////////
1356
+	/* Diagnose Add Listing Page Ends */
1357
+	////////////////////////////////
1358
+
1359
+
1360
+	//////////////////////////////////
1361
+	/* Diagnose Listing Preview Page Starts */
1362
+	//////////////////////////////////
1363
+	$option_value = get_option('geodir_preview_page');
1364
+	$page = get_post($option_value);
1365
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1366
+
1367
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1368
+		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
1369
+	else {
1370
+		$is_error_during_diagnose = true;
1371
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1372
+		if ($fix) {
1373
+			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
1374
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
1375
+			} else {
1376
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1377
+			}
1378
+		}
1379
+	}
1380
+
1381
+	////////////////////////////////
1382
+	/* Diagnose Listing Preview Page Ends */
1383
+	////////////////////////////////
1384
+
1385
+	//////////////////////////////////
1386
+	/* Diagnose Listing Success Page Starts */
1387
+	//////////////////////////////////
1388
+	$option_value = get_option('geodir_success_page');
1389
+	$page = get_post($option_value);
1390
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1391
+
1392
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1393
+		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
1394
+	else {
1395
+		$is_error_during_diagnose = true;
1396
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1397
+		if ($fix) {
1398
+			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
1399
+				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
1400
+			} else {
1401
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1402
+			}
1403
+		}
1404
+	}
1405
+
1406
+	////////////////////////////////
1407
+	/* Diagnose Listing Sucess Page Ends */
1408
+	////////////////////////////////
1409
+
1410
+	//////////////////////////////////
1411
+	/* Diagnose Info Page Starts */
1412
+	//////////////////////////////////
1413
+	$option_value = get_option('geodir_info_page');
1414
+	$page = get_post($option_value);
1415
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1416
+
1417
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1418
+		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
1419
+	else {
1420
+		$is_error_during_diagnose = true;
1421
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1422
+		if ($fix) {
1423
+			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
1424
+				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
1425
+			} else {
1426
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1427
+			}
1428
+		}
1429
+	}
1430
+
1431
+	////////////////////////////////
1432
+	/* Diagnose Info Page Ends */
1433
+	////////////////////////////////
1434
+
1435
+	//////////////////////////////////
1436
+	/* Diagnose Login Page Starts */
1437
+	//////////////////////////////////
1438
+	$option_value = get_option('geodir_login_page');
1439
+	$page = get_post($option_value);
1440
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1441
+
1442
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1443
+		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
1444
+	else {
1445
+		$is_error_during_diagnose = true;
1446
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1447
+		if ($fix) {
1448
+			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
1449
+				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
1450
+			} else {
1451
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1452
+			}
1453
+		}
1454
+	}
1455
+
1456
+	////////////////////////////////
1457
+	/* Diagnose Info Page Ends */
1458
+	////////////////////////////////
1459
+
1460
+	//////////////////////////////////
1461
+	/* Diagnose Location Page Starts */
1462
+	//////////////////////////////////
1463
+	$option_value = get_option('geodir_location_page');
1464
+	$page = get_post($option_value);
1465
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
1466
+
1467
+	if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish')
1468
+		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
1469
+	else {
1470
+		$is_error_during_diagnose = true;
1471
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1472
+		if ($fix) {
1473
+			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
1474
+				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
1475
+			} else {
1476
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1477
+			}
1478
+		}
1479
+	}
1480
+
1481
+	////////////////////////////////
1482
+	/* Diagnose Location Page Ends */
1483
+	////////////////////////////////
1484
+
1485
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1486
+	/**
1487
+	 * This action is called at the end of the GD Tools page check function.
1488
+	 *
1489
+	 * @since 1.5.2
1490
+	 */
1491
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1492
+
1493
+	$output_str = $page_chk_arr['output_str'];
1494
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1495
+
1496
+	if ($is_error_during_diagnose) {
1497
+		if ($fix) {
1498
+			flush_rewrite_rules();
1499
+		}
1500
+		$info_div_class = "geodir_problem_info";
1501
+		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
1502
+	} else {
1503
+		$info_div_class = "geodir_noproblem_info";
1504
+		$fix_button_txt = '';
1505
+	}
1506
+	echo "<ul class='$info_div_class'>";
1507
+	echo $output_str;
1508
+	echo $fix_button_txt;
1509
+	echo "</ul>";
1510 1510
 
1511 1511
 }
1512 1512
 
@@ -1518,26 +1518,26 @@  discard block
 block discarded – undo
1518 1518
  * @global object $wpdb WordPress Database object.
1519 1519
  */
1520 1520
 function geodir_diagnose_load_db_language() {
1521
-    global $wpdb;
1521
+	global $wpdb;
1522 1522
 	
1523 1523
 	$is_error_during_diagnose = geodirectory_load_db_language();
1524 1524
 
1525
-    $output_str = '';
1526
-    $fix_button_txt = '';
1525
+	$output_str = '';
1526
+	$fix_button_txt = '';
1527 1527
 
1528
-    if ($is_error_during_diagnose) {
1529
-        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1528
+	if ($is_error_during_diagnose) {
1529
+		$output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
1530 1530
 		$info_div_class = "geodir_problem_info";
1531
-    } else {
1532
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1531
+	} else {
1532
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1533 1533
 		$info_div_class = "geodir_noproblem_info";
1534
-        $fix_button_txt = '';
1535
-    }
1534
+		$fix_button_txt = '';
1535
+	}
1536 1536
     
1537 1537
 	echo "<ul class='$info_div_class'>";
1538
-    echo $output_str;
1539
-    echo $fix_button_txt;
1540
-    echo "</ul>";
1538
+	echo $output_str;
1539
+	echo $fix_button_txt;
1540
+	echo "</ul>";
1541 1541
 
1542 1542
 }
1543 1543
 
@@ -1568,23 +1568,23 @@  discard block
 block discarded – undo
1568 1568
  */
1569 1569
 function geodir_posts_clauses_request($clauses)
1570 1570
 {
1571
-    global $wpdb, $wp_query, $plugin_prefix;
1571
+	global $wpdb, $wp_query, $plugin_prefix;
1572 1572
 
1573
-    if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1574
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1573
+	if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
1574
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1575 1575
 
1576
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1577
-        $clauses['join'] = $join;
1576
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1577
+		$clauses['join'] = $join;
1578 1578
 
1579
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1580
-        $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1581
-        $clauses['fields'] = $fields;
1579
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1580
+		$fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire';
1581
+		$clauses['fields'] = $fields;
1582 1582
 
1583
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1584
-        $orderby = 'gd_expire ' . $order;
1585
-        $clauses['orderby'] = $orderby;
1586
-    }
1587
-    return $clauses;
1583
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1584
+		$orderby = 'gd_expire ' . $order;
1585
+		$clauses['orderby'] = $orderby;
1586
+	}
1587
+	return $clauses;
1588 1588
 }
1589 1589
 
1590 1590
 
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
  */
1606 1606
 function gd_theme_switch_compat_check()
1607 1607
 {
1608
-    gd_set_theme_compat();
1608
+	gd_set_theme_compat();
1609 1609
 }
1610 1610
 
1611 1611
 /**
@@ -1618,27 +1618,27 @@  discard block
 block discarded – undo
1618 1618
  */
1619 1619
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1620 1620
 {
1621
-    if (function_exists('str_getcsv')) {
1622
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1623
-    } else {
1624
-        global $current_user;
1625
-        $upload_dir = wp_upload_dir();
1626
-
1627
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1628
-        $handle = fopen($file, 'w');
1629
-
1630
-        fwrite($handle, $input);
1631
-        fclose($handle);
1632
-
1633
-        $handle = fopen($file, 'rt');
1634
-        if (PHP_VERSION >= '5.3.0') {
1635
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1636
-        } else {
1637
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1638
-        }
1639
-        fclose($handle);
1640
-    }
1641
-    return $fgetcsv;
1621
+	if (function_exists('str_getcsv')) {
1622
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1623
+	} else {
1624
+		global $current_user;
1625
+		$upload_dir = wp_upload_dir();
1626
+
1627
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1628
+		$handle = fopen($file, 'w');
1629
+
1630
+		fwrite($handle, $input);
1631
+		fclose($handle);
1632
+
1633
+		$handle = fopen($file, 'rt');
1634
+		if (PHP_VERSION >= '5.3.0') {
1635
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1636
+		} else {
1637
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1638
+		}
1639
+		fclose($handle);
1640
+	}
1641
+	return $fgetcsv;
1642 1642
 }
1643 1643
 
1644 1644
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1653,375 +1653,375 @@  discard block
 block discarded – undo
1653 1653
  */
1654 1654
 function geodir_ajax_import_csv()
1655 1655
 {
1656
-    error_reporting(0); // hide error to get clean json response
1656
+	error_reporting(0); // hide error to get clean json response
1657 1657
 
1658
-    global $wpdb, $plugin_prefix, $current_user;
1659
-    $uploads = wp_upload_dir();
1660
-    ini_set('auto_detect_line_endings', true);
1658
+	global $wpdb, $plugin_prefix, $current_user;
1659
+	$uploads = wp_upload_dir();
1660
+	ini_set('auto_detect_line_endings', true);
1661 1661
 	
1662 1662
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1663 1663
 
1664
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1665
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1666
-    $filename = $uploadedFile;
1667
-
1668
-    $uploads = wp_upload_dir();
1669
-    $uploads_dir = $uploads['path'];
1670
-    $image_name_arr = explode('/', $filename);
1671
-    $filename = end($image_name_arr);
1672
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1673
-    $return = array();
1674
-    $return['file'] = $uploadedFile;
1675
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1676
-
1677
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1678
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1679
-
1680
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1681
-            $return['error'] = NULL;
1682
-
1683
-            $return['rows'] = 0;
1684
-
1685
-
1686
-
1687
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1688
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1689
-                        if(is_array($data) && !empty($data)) {
1690
-                            $file[] = '"' . implode('","', $data) . '"';
1691
-                        }
1692
-                    }
1693
-                    fclose($handle);
1694
-                    $file = $file;
1695
-                }
1696
-
1697
-
1698
-
1699
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1700
-
1701
-
1702
-            if (!$return['rows'] > 0) {
1703
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
1704
-            }
1705
-        }
1706
-    }
1707
-    if ($task == 'prepare' || !empty($return['error'])) {
1708
-        echo json_encode($return);
1709
-        exit;
1710
-    }
1711
-
1712
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1713
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1714
-    $count = $importlimit;
1715
-    $requested_limit = $importlimit;
1716
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1717
-
1718
-    if ($count < $totRecords) {
1719
-        $count = $tmpCnt + $count;
1720
-        if ($count > $totRecords) {
1721
-            $count = $totRecords;
1722
-        }
1723
-    } else {
1724
-        $count = $totRecords;
1725
-    }
1726
-
1727
-    $total_records = 0;
1728
-    $rowcount = 0;
1729
-    $address_invalid = 0;
1730
-    $blank_address = 0;
1731
-    $upload_files = 0;
1732
-    $invalid_post_type = 0;
1733
-    $invalid_title = 0;
1734
-    $customKeyarray = array();
1735
-    $gd_post_info = array();
1736
-    $post_location = array();
1737
-    $countpost = 0;
1738
-
1739
-    if (!empty($file)) {
1740
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1741
-        $customKeyarray = $columns;
1742
-
1743
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1744
-            $return['error'] = CSV_INVAILD_FILE;
1745
-            echo json_encode($return);
1746
-            exit;
1747
-        }
1748
-
1749
-        for ($i = 1; $i <= $importlimit; $i++) {
1750
-            $current_index = $tmpCnt + $i;
1751
-            if (isset($file[$current_index])) {
1752
-                $total_records++;
1753
-
1754
-                $buffer = geodir_str_getcsv($file[$current_index]);
1755
-                $post_title = addslashes($buffer[0]);
1756
-                $current_post_author = $buffer[1];
1757
-                $post_desc = addslashes($buffer[2]);
1758
-                $post_cat = array();
1759
-                $catids_arr = array();
1760
-                $post_cat = trim($buffer[3]); // comma seperated category name
1761
-
1762
-                if ($post_cat) {
1763
-                    $post_cat_arr = explode(',', $post_cat);
1764
-
1765
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
1766
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1767
-
1768
-                        if (!empty($buffer[5])) {
1769
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
1770
-
1771
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1772
-
1773
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
1774
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1775
-                                    $catids_arr[] = $cat->slug;
1776
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1777
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1778
-                                    $catids_arr[] = $cat->slug;
1779
-                                } else {
1780
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
1781
-                                    if ($ret && !is_wp_error($ret)) {
1782
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
1783
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1784
-                                            $catids_arr[] = $cat->slug;
1785
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1786
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1787
-                                            $catids_arr[] = $cat->slug;
1788
-                                        }
1789
-                                    }
1790
-                                }
1791
-                            }
1792
-                        }
1793
-                    }
1794
-                }
1795
-
1796
-                if (!$catids_arr) {
1797
-                    $catids_arr[] = 1;
1798
-                }
1799
-
1800
-                $post_tags = trim($buffer[4]); // comma seperated tags
1801
-
1802
-                $tag_arr = '';
1803
-                if ($post_tags) {
1804
-                    $tag_arr = explode(',', $post_tags);
1805
-                }
1806
-
1807
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1808
-
1809
-                $error = '';
1810
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1811
-                    $invalid_post_type++;
1812
-                    continue;
1813
-                }
1814
-
1815
-                if ($post_title != '') {
1816
-                    $menu_order = 0;
1817
-                    $image_folder_name = 'uplaod/';
1818
-
1819
-                    $image_names = array();
1820
-
1821
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
1822
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1823
-
1824
-                        if ($customKeyarray[$c] == 'IMAGE') {
1825
-                            $buffer[$c] = trim($buffer[$c]);
1826
-
1827
-                            if (!empty($buffer[$c])) {
1828
-                                $image_names[] = $buffer[$c];
1829
-                            }
1830
-                        }
1831
-
1832
-                        if ($customKeyarray[$c] == 'alive_days') {
1833
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
1834
-                                $submitdata = date('Y-m-d');
1835
-
1836
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1837
-                            } else {
1838
-                                $gd_post_info['expire_date'] = 'Never';
1839
-                            }
1840
-                        }
1841
-
1842
-                        if ($customKeyarray[$c] == 'post_city') {
1843
-                            $post_city = addslashes($buffer[$c]);
1844
-                        }
1845
-
1846
-                        if ($customKeyarray[$c] == 'post_region') {
1847
-                            $post_region = addslashes($buffer[$c]);
1848
-                        }
1849
-
1850
-                        if ($customKeyarray[$c] == 'post_country') {
1851
-                            $post_country = addslashes($buffer[$c]);
1852
-                        }
1853
-
1854
-                        if ($customKeyarray[$c] == 'post_latitude') {
1855
-                            $post_latitude = addslashes($buffer[$c]);
1856
-                        }
1857
-
1858
-                        if ($customKeyarray[$c] == 'post_longitude') {
1859
-                            $post_longitude = addslashes($buffer[$c]);
1860
-                        }
1664
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1665
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1666
+	$filename = $uploadedFile;
1667
+
1668
+	$uploads = wp_upload_dir();
1669
+	$uploads_dir = $uploads['path'];
1670
+	$image_name_arr = explode('/', $filename);
1671
+	$filename = end($image_name_arr);
1672
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1673
+	$return = array();
1674
+	$return['file'] = $uploadedFile;
1675
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1676
+
1677
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1678
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1679
+
1680
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1681
+			$return['error'] = NULL;
1682
+
1683
+			$return['rows'] = 0;
1684
+
1685
+
1686
+
1687
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1688
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1689
+						if(is_array($data) && !empty($data)) {
1690
+							$file[] = '"' . implode('","', $data) . '"';
1691
+						}
1692
+					}
1693
+					fclose($handle);
1694
+					$file = $file;
1695
+				}
1696
+
1697
+
1698
+
1699
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1700
+
1701
+
1702
+			if (!$return['rows'] > 0) {
1703
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
1704
+			}
1705
+		}
1706
+	}
1707
+	if ($task == 'prepare' || !empty($return['error'])) {
1708
+		echo json_encode($return);
1709
+		exit;
1710
+	}
1711
+
1712
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1713
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1714
+	$count = $importlimit;
1715
+	$requested_limit = $importlimit;
1716
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1717
+
1718
+	if ($count < $totRecords) {
1719
+		$count = $tmpCnt + $count;
1720
+		if ($count > $totRecords) {
1721
+			$count = $totRecords;
1722
+		}
1723
+	} else {
1724
+		$count = $totRecords;
1725
+	}
1726
+
1727
+	$total_records = 0;
1728
+	$rowcount = 0;
1729
+	$address_invalid = 0;
1730
+	$blank_address = 0;
1731
+	$upload_files = 0;
1732
+	$invalid_post_type = 0;
1733
+	$invalid_title = 0;
1734
+	$customKeyarray = array();
1735
+	$gd_post_info = array();
1736
+	$post_location = array();
1737
+	$countpost = 0;
1738
+
1739
+	if (!empty($file)) {
1740
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1741
+		$customKeyarray = $columns;
1742
+
1743
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1744
+			$return['error'] = CSV_INVAILD_FILE;
1745
+			echo json_encode($return);
1746
+			exit;
1747
+		}
1748
+
1749
+		for ($i = 1; $i <= $importlimit; $i++) {
1750
+			$current_index = $tmpCnt + $i;
1751
+			if (isset($file[$current_index])) {
1752
+				$total_records++;
1753
+
1754
+				$buffer = geodir_str_getcsv($file[$current_index]);
1755
+				$post_title = addslashes($buffer[0]);
1756
+				$current_post_author = $buffer[1];
1757
+				$post_desc = addslashes($buffer[2]);
1758
+				$post_cat = array();
1759
+				$catids_arr = array();
1760
+				$post_cat = trim($buffer[3]); // comma seperated category name
1761
+
1762
+				if ($post_cat) {
1763
+					$post_cat_arr = explode(',', $post_cat);
1764
+
1765
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
1766
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1767
+
1768
+						if (!empty($buffer[5])) {
1769
+							if (in_array($buffer[5], geodir_get_posttypes())) {
1770
+
1771
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1772
+
1773
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
1774
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1775
+									$catids_arr[] = $cat->slug;
1776
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1777
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1778
+									$catids_arr[] = $cat->slug;
1779
+								} else {
1780
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
1781
+									if ($ret && !is_wp_error($ret)) {
1782
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
1783
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1784
+											$catids_arr[] = $cat->slug;
1785
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1786
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1787
+											$catids_arr[] = $cat->slug;
1788
+										}
1789
+									}
1790
+								}
1791
+							}
1792
+						}
1793
+					}
1794
+				}
1795
+
1796
+				if (!$catids_arr) {
1797
+					$catids_arr[] = 1;
1798
+				}
1799
+
1800
+				$post_tags = trim($buffer[4]); // comma seperated tags
1801
+
1802
+				$tag_arr = '';
1803
+				if ($post_tags) {
1804
+					$tag_arr = explode(',', $post_tags);
1805
+				}
1806
+
1807
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1808
+
1809
+				$error = '';
1810
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1811
+					$invalid_post_type++;
1812
+					continue;
1813
+				}
1814
+
1815
+				if ($post_title != '') {
1816
+					$menu_order = 0;
1817
+					$image_folder_name = 'uplaod/';
1818
+
1819
+					$image_names = array();
1820
+
1821
+					for ($c = 5; $c < count($customKeyarray); $c++) {
1822
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1823
+
1824
+						if ($customKeyarray[$c] == 'IMAGE') {
1825
+							$buffer[$c] = trim($buffer[$c]);
1826
+
1827
+							if (!empty($buffer[$c])) {
1828
+								$image_names[] = $buffer[$c];
1829
+							}
1830
+						}
1831
+
1832
+						if ($customKeyarray[$c] == 'alive_days') {
1833
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
1834
+								$submitdata = date('Y-m-d');
1835
+
1836
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1837
+							} else {
1838
+								$gd_post_info['expire_date'] = 'Never';
1839
+							}
1840
+						}
1841
+
1842
+						if ($customKeyarray[$c] == 'post_city') {
1843
+							$post_city = addslashes($buffer[$c]);
1844
+						}
1845
+
1846
+						if ($customKeyarray[$c] == 'post_region') {
1847
+							$post_region = addslashes($buffer[$c]);
1848
+						}
1849
+
1850
+						if ($customKeyarray[$c] == 'post_country') {
1851
+							$post_country = addslashes($buffer[$c]);
1852
+						}
1853
+
1854
+						if ($customKeyarray[$c] == 'post_latitude') {
1855
+							$post_latitude = addslashes($buffer[$c]);
1856
+						}
1857
+
1858
+						if ($customKeyarray[$c] == 'post_longitude') {
1859
+							$post_longitude = addslashes($buffer[$c]);
1860
+						}
1861 1861
 						
1862 1862
 						// Post status
1863 1863
 						if ($customKeyarray[$c] == 'post_status') {
1864
-                            $post_status = sanitize_key( $buffer[$c] );
1865
-                        }
1866
-                    }
1867
-
1868
-                    /* ================ before array create ============== */
1869
-                    $location_result = geodir_get_default_location();
1870
-                    if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
1871
-                        $blank_address++;
1872
-                        continue;
1873
-                    } else if ($location_result->location_id == 0) {
1874
-                        if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
1875
-                            $address_invalid++;
1876
-                            continue;
1877
-                        }
1878
-                    }
1864
+							$post_status = sanitize_key( $buffer[$c] );
1865
+						}
1866
+					}
1867
+
1868
+					/* ================ before array create ============== */
1869
+					$location_result = geodir_get_default_location();
1870
+					if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
1871
+						$blank_address++;
1872
+						continue;
1873
+					} else if ($location_result->location_id == 0) {
1874
+						if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
1875
+							$address_invalid++;
1876
+							continue;
1877
+						}
1878
+					}
1879 1879
 					
1880 1880
 					// Default post status
1881 1881
 					$default_status = 'publish';
1882 1882
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
1883 1883
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
1884 1884
 
1885
-                    $my_post['post_title'] = $post_title;
1886
-                    $my_post['post_content'] = $post_desc;
1887
-                    $my_post['post_type'] = addslashes($buffer[5]);
1888
-                    $my_post['post_author'] = $current_post_author;
1889
-                    $my_post['post_status'] = $post_status;
1890
-                    $my_post['post_category'] = $catids_arr;
1891
-                    $my_post['post_tags'] = $tag_arr;
1892
-
1893
-                    $gd_post_info['post_tags'] = $tag_arr;
1894
-                    $gd_post_info['post_title'] = $post_title;
1895
-                    $gd_post_info['post_status'] = $post_status;
1896
-                    $gd_post_info['submit_time'] = time();
1897
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1898
-
1899
-                    $last_postid = wp_insert_post($my_post);
1900
-                    $countpost++;
1901
-
1902
-                    // Check if we need to save post location as new location
1903
-                    if ($location_result->location_id > 0) {
1904
-                        if (isset($post_city) && isset($post_region)) {
1905
-                            $request_info['post_location'] = array(
1906
-                                'city' => $post_city,
1907
-                                'region' => $post_region,
1908
-                                'country' => $post_country,
1909
-                                'geo_lat' => $post_latitude,
1910
-                                'geo_lng' => $post_longitude
1911
-                            );
1912
-
1913
-                            $post_location_info = $request_info['post_location'];
1914
-                            if ($location_id = geodir_add_new_location($post_location_info))
1915
-                                $post_location_id = $location_id;
1916
-                        } else {
1917
-                            $post_location_id = 0;
1918
-                        }
1919
-                    } else {
1920
-                        $post_location_id = 0;
1921
-                    }
1922
-
1923
-                    /* ------- get default package info ----- */
1924
-                    $payment_info = array();
1925
-                    $package_info = array();
1926
-
1927
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1928
-                    $package_id = '';
1929
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1930
-                        $package_id = $gd_post_info['package_id'];
1931
-                    }
1932
-
1933
-                    if (!empty($package_info)) {
1934
-                        $payment_info['package_id'] = $package_info['pid'];
1935
-
1936
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1937
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1938
-                        } else {
1939
-                            $payment_info['expire_date'] = 'Never';
1940
-                        }
1941
-
1942
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
1943
-                    }
1944
-
1945
-                    $gd_post_info['post_location_id'] = $post_location_id;
1946
-
1947
-                    $post_type = get_post_type($last_postid);
1948
-
1949
-                    $table = $plugin_prefix . $post_type . '_detail';
1950
-
1951
-                    geodir_save_post_info($last_postid, $gd_post_info);
1952
-
1953
-                    if (!empty($image_names)) {
1954
-                        $upload_files++;
1955
-                        $menu_order = 1;
1956
-
1957
-                        foreach ($image_names as $image_name) {
1958
-                            $img_name_arr = explode('.', $image_name);
1959
-
1960
-                            $uploads = wp_upload_dir();
1961
-                            $sub_dir = $uploads['subdir'];
1962
-
1963
-                            $arr_file_type = wp_check_filetype($image_name);
1964
-                            $uploaded_file_type = $arr_file_type['type'];
1965
-
1966
-                            $attachment = array();
1967
-                            $attachment['post_id'] = $last_postid;
1968
-                            $attachment['title'] = $img_name_arr[0];
1969
-                            $attachment['content'] = '';
1970
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
1971
-                            $attachment['mime_type'] = $uploaded_file_type;
1972
-                            $attachment['menu_order'] = $menu_order;
1973
-                            $attachment['is_featured'] = 0;
1974
-
1975
-                            $attachment_set = '';
1976
-
1977
-                            foreach ($attachment as $key => $val) {
1978
-                                if ($val != '')
1979
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1980
-                            }
1981
-                            $attachment_set = trim($attachment_set, ", ");
1982
-
1983
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1984
-
1985
-                            if ($menu_order == 1) {
1986
-                                $post_type = get_post_type($last_postid);
1987
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1988
-                            }
1989
-                            $menu_order++;
1990
-                        }
1991
-                    }
1992
-
1993
-                    $gd_post_info['package_id'] = $package_id;
1994
-
1995
-                    /** This action is documented in geodirectory-functions/post-functions.php */
1996
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1997
-
1998
-                    if (!empty($buffer[5])) {
1999
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
2000
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2001
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2002
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2003
-
2004
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2005
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2006
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2007
-                        }
2008
-                    }
2009
-                } else {
2010
-                    $invalid_title++;
2011
-                }
2012
-            }
2013
-        }
2014
-    }
2015
-    $return['rowcount'] = $countpost;
2016
-    $return['invalidcount'] = $address_invalid;
2017
-    $return['blank_address'] = $blank_address;
2018
-    $return['upload_files'] = $upload_files;
2019
-    $return['invalid_post_type'] = $invalid_post_type;
2020
-    $return['invalid_title'] = $invalid_title;
2021
-    $return['total_records'] = $total_records;
2022
-
2023
-    echo json_encode($return);
2024
-    exit;
1885
+					$my_post['post_title'] = $post_title;
1886
+					$my_post['post_content'] = $post_desc;
1887
+					$my_post['post_type'] = addslashes($buffer[5]);
1888
+					$my_post['post_author'] = $current_post_author;
1889
+					$my_post['post_status'] = $post_status;
1890
+					$my_post['post_category'] = $catids_arr;
1891
+					$my_post['post_tags'] = $tag_arr;
1892
+
1893
+					$gd_post_info['post_tags'] = $tag_arr;
1894
+					$gd_post_info['post_title'] = $post_title;
1895
+					$gd_post_info['post_status'] = $post_status;
1896
+					$gd_post_info['submit_time'] = time();
1897
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1898
+
1899
+					$last_postid = wp_insert_post($my_post);
1900
+					$countpost++;
1901
+
1902
+					// Check if we need to save post location as new location
1903
+					if ($location_result->location_id > 0) {
1904
+						if (isset($post_city) && isset($post_region)) {
1905
+							$request_info['post_location'] = array(
1906
+								'city' => $post_city,
1907
+								'region' => $post_region,
1908
+								'country' => $post_country,
1909
+								'geo_lat' => $post_latitude,
1910
+								'geo_lng' => $post_longitude
1911
+							);
1912
+
1913
+							$post_location_info = $request_info['post_location'];
1914
+							if ($location_id = geodir_add_new_location($post_location_info))
1915
+								$post_location_id = $location_id;
1916
+						} else {
1917
+							$post_location_id = 0;
1918
+						}
1919
+					} else {
1920
+						$post_location_id = 0;
1921
+					}
1922
+
1923
+					/* ------- get default package info ----- */
1924
+					$payment_info = array();
1925
+					$package_info = array();
1926
+
1927
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1928
+					$package_id = '';
1929
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1930
+						$package_id = $gd_post_info['package_id'];
1931
+					}
1932
+
1933
+					if (!empty($package_info)) {
1934
+						$payment_info['package_id'] = $package_info['pid'];
1935
+
1936
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1937
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1938
+						} else {
1939
+							$payment_info['expire_date'] = 'Never';
1940
+						}
1941
+
1942
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
1943
+					}
1944
+
1945
+					$gd_post_info['post_location_id'] = $post_location_id;
1946
+
1947
+					$post_type = get_post_type($last_postid);
1948
+
1949
+					$table = $plugin_prefix . $post_type . '_detail';
1950
+
1951
+					geodir_save_post_info($last_postid, $gd_post_info);
1952
+
1953
+					if (!empty($image_names)) {
1954
+						$upload_files++;
1955
+						$menu_order = 1;
1956
+
1957
+						foreach ($image_names as $image_name) {
1958
+							$img_name_arr = explode('.', $image_name);
1959
+
1960
+							$uploads = wp_upload_dir();
1961
+							$sub_dir = $uploads['subdir'];
1962
+
1963
+							$arr_file_type = wp_check_filetype($image_name);
1964
+							$uploaded_file_type = $arr_file_type['type'];
1965
+
1966
+							$attachment = array();
1967
+							$attachment['post_id'] = $last_postid;
1968
+							$attachment['title'] = $img_name_arr[0];
1969
+							$attachment['content'] = '';
1970
+							$attachment['file'] = $sub_dir . '/' . $image_name;
1971
+							$attachment['mime_type'] = $uploaded_file_type;
1972
+							$attachment['menu_order'] = $menu_order;
1973
+							$attachment['is_featured'] = 0;
1974
+
1975
+							$attachment_set = '';
1976
+
1977
+							foreach ($attachment as $key => $val) {
1978
+								if ($val != '')
1979
+									$attachment_set .= $key . " = '" . $val . "', ";
1980
+							}
1981
+							$attachment_set = trim($attachment_set, ", ");
1982
+
1983
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1984
+
1985
+							if ($menu_order == 1) {
1986
+								$post_type = get_post_type($last_postid);
1987
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1988
+							}
1989
+							$menu_order++;
1990
+						}
1991
+					}
1992
+
1993
+					$gd_post_info['package_id'] = $package_id;
1994
+
1995
+					/** This action is documented in geodirectory-functions/post-functions.php */
1996
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1997
+
1998
+					if (!empty($buffer[5])) {
1999
+						if (in_array($buffer[5], geodir_get_posttypes())) {
2000
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
2001
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2002
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2003
+
2004
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2005
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2006
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2007
+						}
2008
+					}
2009
+				} else {
2010
+					$invalid_title++;
2011
+				}
2012
+			}
2013
+		}
2014
+	}
2015
+	$return['rowcount'] = $countpost;
2016
+	$return['invalidcount'] = $address_invalid;
2017
+	$return['blank_address'] = $blank_address;
2018
+	$return['upload_files'] = $upload_files;
2019
+	$return['invalid_post_type'] = $invalid_post_type;
2020
+	$return['invalid_title'] = $invalid_title;
2021
+	$return['total_records'] = $total_records;
2022
+
2023
+	echo json_encode($return);
2024
+	exit;
2025 2025
 }
2026 2026
 
2027 2027
 // Add the tab in left sidebar menu fro import & export page.
@@ -2041,9 +2041,9 @@  discard block
 block discarded – undo
2041 2041
  * @param $post object $post The post object of the post being saved.
2042 2042
  */
2043 2043
 function geodir_update_location_prefix($post_id,$post){
2044
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2045
-        update_option('geodir_location_prefix',$post->post_name);
2046
-    }
2044
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2045
+		update_option('geodir_location_prefix',$post->post_name);
2046
+	}
2047 2047
 
2048 2048
 }
2049 2049
 
@@ -2054,50 +2054,50 @@  discard block
 block discarded – undo
2054 2054
 function geodir_ga_callback(){
2055 2055
 
2056 2056
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2057
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2058
-    $code = "code=".$_REQUEST['code'];
2059
-    $grant_type = "&grant_type=authorization_code";
2060
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2061
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2062
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2057
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2058
+	$code = "code=".$_REQUEST['code'];
2059
+	$grant_type = "&grant_type=authorization_code";
2060
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2061
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2062
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2063 2063
 
2064
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2064
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2065 2065
 
2066
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2066
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2067 2067
 
2068
-    //print_r($response);
2068
+	//print_r($response);
2069 2069
 
2070
-    $error_msg =  __('Something went wrong','geodirectory');
2071
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2070
+	$error_msg =  __('Something went wrong','geodirectory');
2071
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2072 2072
 
2073
-        $parts = json_decode($response['body']);
2074
-        //print_r($parts);
2075
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2076
-        else{
2073
+		$parts = json_decode($response['body']);
2074
+		//print_r($parts);
2075
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2076
+		else{
2077 2077
 
2078
-            update_option('gd_ga_access_token', $parts->access_token);
2079
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2080
-            ?><script>window.close();</script><?php
2081
-        }
2078
+			update_option('gd_ga_access_token', $parts->access_token);
2079
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2080
+			?><script>window.close();</script><?php
2081
+		}
2082 2082
 
2083 2083
 
2084
-    }
2085
-    elseif(!empty($response['response']['code'])) {
2086
-        $parts = json_decode($response['body']);
2084
+	}
2085
+	elseif(!empty($response['response']['code'])) {
2086
+		$parts = json_decode($response['body']);
2087 2087
 
2088
-        if(isset($parts->error)){
2089
-            echo $parts->error.": ".$parts->error_description;exit;
2090
-        }else{
2091
-            echo $error_msg." - #2";exit;
2092
-        }
2088
+		if(isset($parts->error)){
2089
+			echo $parts->error.": ".$parts->error_description;exit;
2090
+		}else{
2091
+			echo $error_msg." - #2";exit;
2092
+		}
2093 2093
 
2094
-    }else{
2094
+	}else{
2095 2095
 
2096
-        echo $error_msg." - #3";exit;
2096
+		echo $error_msg." - #3";exit;
2097 2097
 
2098
-    }
2098
+	}
2099 2099
 }
2100
-    exit;
2100
+	exit;
2101 2101
 }
2102 2102
 
2103 2103
 add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 );
Please login to merge, or discard this patch.