Test Failed
Pull Request — master (#274)
by Viruthagiri
10:39
created
geodirectory-functions/ajax_handler_functions.php 1 patch
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -16,22 +16,22 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function geodir_on_wp_loaded()
18 18
 {
19
-    /**
20
-     * Called on the wp_loaded WP hook and used to send the send inquiry and send to friend forms.
21
-     *
22
-     * @since 1.0.0
23
-     */
24
-    do_action('giodir_handle_request_plugins_loaded');
25
-    global $wpdb;
19
+	/**
20
+	 * Called on the wp_loaded WP hook and used to send the send inquiry and send to friend forms.
21
+	 *
22
+	 * @since 1.0.0
23
+	 */
24
+	do_action('giodir_handle_request_plugins_loaded');
25
+	global $wpdb;
26 26
 
27 27
 
28
-    if (isset($_POST['sendact']) && $_POST['sendact'] == 'send_inqury') {
29
-        geodir_send_inquiry($_REQUEST); // function in custom_functions.php
28
+	if (isset($_POST['sendact']) && $_POST['sendact'] == 'send_inqury') {
29
+		geodir_send_inquiry($_REQUEST); // function in custom_functions.php
30 30
 
31
-    } elseif (isset($_POST['sendact']) && $_POST['sendact'] == 'email_frnd') {
32
-        geodir_send_friend($_REQUEST); // function in custom_functions.php
31
+	} elseif (isset($_POST['sendact']) && $_POST['sendact'] == 'email_frnd') {
32
+		geodir_send_friend($_REQUEST); // function in custom_functions.php
33 33
 
34
-    }
34
+	}
35 35
 
36 36
 }
37 37
 
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
  */
45 45
 function geodir_on_wp()
46 46
 {
47
-    if(geodir_is_page('login')) {
48
-        geodir_user_signup();
49
-    }
47
+	if(geodir_is_page('login')) {
48
+		geodir_user_signup();
49
+	}
50 50
 
51 51
 }
52 52
 
@@ -59,47 +59,47 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function geodir_on_init()
61 61
 {
62
-    /**
63
-     * Called on the wp_init WP hook at the start of the geodir_on_init() function.
64
-     *
65
-     * @since 1.0.0
66
-     */
67
-    do_action('giodir_handle_request');
68
-    global $wpdb;
69
-
70
-
71
-
72
-
73
-    if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && !current_user_can('manage_options') && !class_exists('BuddyPress')) {
74
-        show_admin_bar(false);
75
-    }
76
-
77
-
78
-    if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'get_markers') {
79
-        /**
80
-         * Contains map marker functions.
81
-         *
82
-         * @since 1.0.0
83
-         * @package GeoDirectory
84
-         */
85
-        include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php');
86
-        die;
87
-    }
88
-
89
-    if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'ga') {
90
-        if (isset($_REQUEST['ga_start'])) {
91
-            $ga_start = $_REQUEST['ga_start'];
92
-        } else {
93
-            $ga_start = '';
94
-        }
95
-        if (isset($_REQUEST['ga_end'])) {
96
-            $ga_end = $_REQUEST['ga_end'];
97
-        } else {
98
-            $ga_end = '';
99
-        }
100
-        geodir_getGoogleAnalytics($_REQUEST['ga_page'], $ga_start, $ga_end);
101
-        die;
102
-    }
62
+	/**
63
+	 * Called on the wp_init WP hook at the start of the geodir_on_init() function.
64
+	 *
65
+	 * @since 1.0.0
66
+	 */
67
+	do_action('giodir_handle_request');
68
+	global $wpdb;
69
+
70
+
71
+
72
+
73
+	if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && !current_user_can('manage_options') && !class_exists('BuddyPress')) {
74
+		show_admin_bar(false);
75
+	}
76
+
77
+
78
+	if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'get_markers') {
79
+		/**
80
+		 * Contains map marker functions.
81
+		 *
82
+		 * @since 1.0.0
83
+		 * @package GeoDirectory
84
+		 */
85
+		include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php');
86
+		die;
87
+	}
88
+
89
+	if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'ga') {
90
+		if (isset($_REQUEST['ga_start'])) {
91
+			$ga_start = $_REQUEST['ga_start'];
92
+		} else {
93
+			$ga_start = '';
94
+		}
95
+		if (isset($_REQUEST['ga_end'])) {
96
+			$ga_end = $_REQUEST['ga_end'];
97
+		} else {
98
+			$ga_end = '';
99
+		}
100
+		geodir_getGoogleAnalytics($_REQUEST['ga_page'], $ga_start, $ga_end);
101
+		die;
102
+	}
103 103
 
104 104
 
105 105
 }
@@ -118,245 +118,245 @@  discard block
 block discarded – undo
118 118
  * @todo check if nonce is required here and if so add one.
119 119
  */
120 120
 function geodir_ajax_handler() {
121
-    global $wpdb, $gd_session;
121
+	global $wpdb, $gd_session;
122 122
 
123
-    if (isset($_REQUEST['gd_listing_view']) && $_REQUEST['gd_listing_view'] != '') {
123
+	if (isset($_REQUEST['gd_listing_view']) && $_REQUEST['gd_listing_view'] != '') {
124 124
 		$gd_session->set('gd_listing_view', $_REQUEST['gd_listing_view']);
125
-        echo '1';
126
-    }
127
-
128
-    if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'category_ajax') {
129
-        if (isset($_REQUEST['main_catid']) && isset($_REQUEST['cat_tax']) && isset($_REQUEST['exclude']))
130
-            geodir_addpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['main_catid'], '', '', '', $_REQUEST['exclude']);
131
-        else if (isset($_REQUEST['catpid']) && isset($_REQUEST['cat_tax']))
132
-            geodir_editpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['catpid']);
133
-    }
134
-
135
-    if ((isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'admin_ajax') || isset($_REQUEST['create_field']) || isset($_REQUEST['sort_create_field'])) {
136
-        if (current_user_can('manage_options')) {
137
-            /**
138
-             * Contains admin ajax handling functions.
139
-             *
140
-             * @since 1.0.0
141
-             * @package GeoDirectory
142
-             */
143
-            include_once(geodir_plugin_path() . '/geodirectory-admin/geodir_admin_ajax.php');
144
-        } else {
145
-            wp_redirect(geodir_login_url());
146
-            gd_die();
147
-        }
148
-    }
149
-
150
-    if (isset($_REQUEST['geodir_autofill']) && $_REQUEST['geodir_autofill'] != '' && isset($_REQUEST['_wpnonce'])) {
151
-        if (current_user_can('manage_options')) {
152
-            switch ($_REQUEST['geodir_autofill']):
153
-                case "geodir_dummy_delete" :
154
-                    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_delete_noncename'))
155
-                        return;
156
-
157
-                    if (isset($_REQUEST['posttype']))
158
-                        /**
159
-                         * Used to delete the dummy post data per post type.
160
-                         *
161
-                         * Uses dynamic hook, geodir_delete_dummy_posts_$_REQUEST['posttype'].
162
-                         *
163
-                         * @since 1.0.0
164
-                         */
165
-                        do_action('geodir_delete_dummy_posts_' . $_REQUEST['posttype']);
166
-                    break;
167
-                case "geodir_dummy_insert" :
168
-                    if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_insert_noncename'))
169
-                        return;
170
-
171
-                    global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2;
172
-                    $dummy_post_index = $_REQUEST['insert_dummy_post_index'];
173
-                    $city_bound_lat1 = $_REQUEST['city_bound_lat1'];
174
-                    $city_bound_lng1 = $_REQUEST['city_bound_lng1'];
175
-                    $city_bound_lat2 = $_REQUEST['city_bound_lat2'];
176
-                    $city_bound_lng2 = $_REQUEST['city_bound_lng2'];
177
-
178
-                    if (isset($_REQUEST['posttype']))
179
-                        /**
180
-                         * Used to insert the dummy post data per post type.
181
-                         *
182
-                         * Uses dynamic hook, geodir_insert_dummy_posts_$_REQUEST['posttype'].
183
-                         *
184
-                         * @since 1.0.0
185
-                         */
186
-                        do_action('geodir_insert_dummy_posts_' . $_REQUEST['posttype']);
187
-
188
-                    break;
189
-            endswitch;
190
-        } else {
191
-            wp_redirect(geodir_login_url());
192
-            exit();
193
-        }
194
-    }
195
-
196
-    if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') {
197
-
198
-        if ($_REQUEST['popuptype'] == 'b_send_inquiry' || $_REQUEST['popuptype'] == 'b_sendtofriend') {
199
-            $template = locate_template(array("geodirectory/popup-forms.php"));
200
-            if (!$template) {
201
-                $template = geodir_plugin_path() . '/geodirectory-templates/popup-forms.php';
202
-            }
203
-            require_once($template);
204
-        }
205
-
206
-        gd_die();
207
-    }
208
-
209
-    /*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){
125
+		echo '1';
126
+	}
127
+
128
+	if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'category_ajax') {
129
+		if (isset($_REQUEST['main_catid']) && isset($_REQUEST['cat_tax']) && isset($_REQUEST['exclude']))
130
+			geodir_addpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['main_catid'], '', '', '', $_REQUEST['exclude']);
131
+		else if (isset($_REQUEST['catpid']) && isset($_REQUEST['cat_tax']))
132
+			geodir_editpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['catpid']);
133
+	}
134
+
135
+	if ((isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'admin_ajax') || isset($_REQUEST['create_field']) || isset($_REQUEST['sort_create_field'])) {
136
+		if (current_user_can('manage_options')) {
137
+			/**
138
+			 * Contains admin ajax handling functions.
139
+			 *
140
+			 * @since 1.0.0
141
+			 * @package GeoDirectory
142
+			 */
143
+			include_once(geodir_plugin_path() . '/geodirectory-admin/geodir_admin_ajax.php');
144
+		} else {
145
+			wp_redirect(geodir_login_url());
146
+			gd_die();
147
+		}
148
+	}
149
+
150
+	if (isset($_REQUEST['geodir_autofill']) && $_REQUEST['geodir_autofill'] != '' && isset($_REQUEST['_wpnonce'])) {
151
+		if (current_user_can('manage_options')) {
152
+			switch ($_REQUEST['geodir_autofill']):
153
+				case "geodir_dummy_delete" :
154
+					if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_delete_noncename'))
155
+						return;
156
+
157
+					if (isset($_REQUEST['posttype']))
158
+						/**
159
+						 * Used to delete the dummy post data per post type.
160
+						 *
161
+						 * Uses dynamic hook, geodir_delete_dummy_posts_$_REQUEST['posttype'].
162
+						 *
163
+						 * @since 1.0.0
164
+						 */
165
+						do_action('geodir_delete_dummy_posts_' . $_REQUEST['posttype']);
166
+					break;
167
+				case "geodir_dummy_insert" :
168
+					if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_insert_noncename'))
169
+						return;
170
+
171
+					global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2;
172
+					$dummy_post_index = $_REQUEST['insert_dummy_post_index'];
173
+					$city_bound_lat1 = $_REQUEST['city_bound_lat1'];
174
+					$city_bound_lng1 = $_REQUEST['city_bound_lng1'];
175
+					$city_bound_lat2 = $_REQUEST['city_bound_lat2'];
176
+					$city_bound_lng2 = $_REQUEST['city_bound_lng2'];
177
+
178
+					if (isset($_REQUEST['posttype']))
179
+						/**
180
+						 * Used to insert the dummy post data per post type.
181
+						 *
182
+						 * Uses dynamic hook, geodir_insert_dummy_posts_$_REQUEST['posttype'].
183
+						 *
184
+						 * @since 1.0.0
185
+						 */
186
+						do_action('geodir_insert_dummy_posts_' . $_REQUEST['posttype']);
187
+
188
+					break;
189
+			endswitch;
190
+		} else {
191
+			wp_redirect(geodir_login_url());
192
+			exit();
193
+		}
194
+	}
195
+
196
+	if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') {
197
+
198
+		if ($_REQUEST['popuptype'] == 'b_send_inquiry' || $_REQUEST['popuptype'] == 'b_sendtofriend') {
199
+			$template = locate_template(array("geodirectory/popup-forms.php"));
200
+			if (!$template) {
201
+				$template = geodir_plugin_path() . '/geodirectory-templates/popup-forms.php';
202
+			}
203
+			require_once($template);
204
+		}
205
+
206
+		gd_die();
207
+	}
208
+
209
+	/*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){
210 210
         include_once ( geodir_plugin_path() . '/geodirectory-templates/advance-search-form.php');
211 211
     }*/
212 212
 
213
-    if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') {
214
-        /**
215
-         * Contains map marker functions.
216
-         *
217
-         * @since 1.0.0
218
-         * @package GeoDirectory
219
-         */
220
-        include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php');
221
-    }
222
-
223
-    if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') {
224
-        if (is_user_logged_in()) {
225
-            switch ($_REQUEST['ajax_action']):
226
-                case "add" :
227
-                    geodir_add_to_favorite((int)$_REQUEST['pid']);
228
-                    break;
229
-                case "remove" :
230
-                    geodir_remove_from_favorite((int)$_REQUEST['pid']);
231
-                    break;
232
-            endswitch;
233
-        } else {
234
-            wp_redirect(geodir_login_url());
235
-            exit();
236
-        }
237
-    }
238
-
239
-    if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') {
240
-
241
-        $is_current_user_owner = true;
242
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
243
-            $is_current_user_owner = geodir_listing_belong_to_current_user((int)$_REQUEST['pid']);
244
-        }
245
-
246
-        $request = $gd_session->get('listing');
247
-
248
-        if (is_user_logged_in() && $is_current_user_owner) {
249
-
250
-            switch ($_REQUEST['ajax_action']):
251
-                case "add":
252
-                case "update":
253
-
254
-                    if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
255
-                        $last_id = geodir_save_listing();
256
-
257
-                        if ($last_id) {
258
-                            //$redirect_to = get_permalink( $last_id );
259
-                            $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
260
-
261
-                        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
262
-                            $redirect_to = get_permalink(geodir_add_listing_page_id());
263
-                            $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
264
-                        } else
265
-                            $redirect_to = get_permalink(geodir_add_listing_page_id());
266
-
267
-                        wp_redirect($redirect_to);
268
-                    } else {
269
-                        $gd_session->un_set('listing');
270
-                        wp_redirect(home_url());
271
-                    }
272
-
273
-                    break;
274
-                case "cancel" :
275
-
276
-                    $gd_session->un_set('listing');
277
-
278
-                    if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid']))
279
-                        wp_redirect(get_permalink($_REQUEST['pid']));
280
-                    else {
281
-                        geodir_remove_temp_images();
282
-                        wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type'])));
283
-                    }
284
-
285
-                    break;
286
-
287
-                case "publish" :
288
-
289
-                    if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
290
-
291
-                        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
292
-                            $new_post = array();
293
-                            $new_post['ID'] = $_REQUEST['pid'];
294
-
295
-                            $lastid = wp_update_post($new_post);
296
-
297
-                            $gd_session->un_set('listing');
298
-                            wp_redirect(get_permalink($lastid));
299
-                        } else {
300
-                            $last_id = geodir_save_listing();
301
-
302
-                            if ($last_id) {
303
-                                //$redirect_to = get_permalink( $last_id );
304
-                                $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
305
-                            } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
306
-                                $redirect_to = get_permalink(geodir_add_listing_page_id());
307
-                                $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
308
-                            } else
309
-                                $redirect_to = get_permalink(geodir_add_listing_page_id());
310
-
311
-                            $gd_session->un_set('listing');
312
-                            wp_redirect($redirect_to);
313
-                        }
314
-                    } else {
315
-                        $gd_session->un_set('listing');
316
-                        wp_redirect(home_url());
317
-                    }
318
-
319
-                    break;
320
-                case "delete" :
321
-                    if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
322
-                        global $current_user;
323
-
324
-                        if (get_option('geodir_disable_perm_delete')) {
325
-                            $lastid = wp_trash_post($_REQUEST['pid']);
326
-                        } else {
327
-                            $lastid = wp_delete_post($_REQUEST['pid']);
328
-                        }
329
-
330
-                        if ($lastid && !is_wp_error($lastid))
331
-                            wp_redirect($_SERVER['HTTP_REFERER']);
332
-
333
-                        //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) );
334
-                    }
335
-                    break;
336
-            endswitch;
337
-
338
-            $gd_session->un_set('listing');
339
-        } else {
340
-            $gd_session->un_set('listing');
341
-            wp_redirect(geodir_login_url());
342
-            exit();
343
-        }
344
-    }
345
-
346
-    if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') {
347
-        /**
348
-         * Contains registration and login functions.
349
-         * @todo Fix the file path.
350
-         *
351
-         * @since 1.0.0
352
-         * @package GeoDirectory
353
-         */
354
-        include_once(geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php');
355
-    }
356
-
357
-
358
-    if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') {
359
-        $terms_o = get_terms(sanitize_text_field($_REQUEST['term']));
213
+	if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') {
214
+		/**
215
+		 * Contains map marker functions.
216
+		 *
217
+		 * @since 1.0.0
218
+		 * @package GeoDirectory
219
+		 */
220
+		include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php');
221
+	}
222
+
223
+	if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') {
224
+		if (is_user_logged_in()) {
225
+			switch ($_REQUEST['ajax_action']):
226
+				case "add" :
227
+					geodir_add_to_favorite((int)$_REQUEST['pid']);
228
+					break;
229
+				case "remove" :
230
+					geodir_remove_from_favorite((int)$_REQUEST['pid']);
231
+					break;
232
+			endswitch;
233
+		} else {
234
+			wp_redirect(geodir_login_url());
235
+			exit();
236
+		}
237
+	}
238
+
239
+	if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') {
240
+
241
+		$is_current_user_owner = true;
242
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
243
+			$is_current_user_owner = geodir_listing_belong_to_current_user((int)$_REQUEST['pid']);
244
+		}
245
+
246
+		$request = $gd_session->get('listing');
247
+
248
+		if (is_user_logged_in() && $is_current_user_owner) {
249
+
250
+			switch ($_REQUEST['ajax_action']):
251
+				case "add":
252
+				case "update":
253
+
254
+					if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
255
+						$last_id = geodir_save_listing();
256
+
257
+						if ($last_id) {
258
+							//$redirect_to = get_permalink( $last_id );
259
+							$redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
260
+
261
+						} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
262
+							$redirect_to = get_permalink(geodir_add_listing_page_id());
263
+							$redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
264
+						} else
265
+							$redirect_to = get_permalink(geodir_add_listing_page_id());
266
+
267
+						wp_redirect($redirect_to);
268
+					} else {
269
+						$gd_session->un_set('listing');
270
+						wp_redirect(home_url());
271
+					}
272
+
273
+					break;
274
+				case "cancel" :
275
+
276
+					$gd_session->un_set('listing');
277
+
278
+					if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid']))
279
+						wp_redirect(get_permalink($_REQUEST['pid']));
280
+					else {
281
+						geodir_remove_temp_images();
282
+						wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type'])));
283
+					}
284
+
285
+					break;
286
+
287
+				case "publish" :
288
+
289
+					if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
290
+
291
+						if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
292
+							$new_post = array();
293
+							$new_post['ID'] = $_REQUEST['pid'];
294
+
295
+							$lastid = wp_update_post($new_post);
296
+
297
+							$gd_session->un_set('listing');
298
+							wp_redirect(get_permalink($lastid));
299
+						} else {
300
+							$last_id = geodir_save_listing();
301
+
302
+							if ($last_id) {
303
+								//$redirect_to = get_permalink( $last_id );
304
+								$redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
305
+							} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
306
+								$redirect_to = get_permalink(geodir_add_listing_page_id());
307
+								$redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
308
+							} else
309
+								$redirect_to = get_permalink(geodir_add_listing_page_id());
310
+
311
+							$gd_session->un_set('listing');
312
+							wp_redirect($redirect_to);
313
+						}
314
+					} else {
315
+						$gd_session->un_set('listing');
316
+						wp_redirect(home_url());
317
+					}
318
+
319
+					break;
320
+				case "delete" :
321
+					if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
322
+						global $current_user;
323
+
324
+						if (get_option('geodir_disable_perm_delete')) {
325
+							$lastid = wp_trash_post($_REQUEST['pid']);
326
+						} else {
327
+							$lastid = wp_delete_post($_REQUEST['pid']);
328
+						}
329
+
330
+						if ($lastid && !is_wp_error($lastid))
331
+							wp_redirect($_SERVER['HTTP_REFERER']);
332
+
333
+						//wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) );
334
+					}
335
+					break;
336
+			endswitch;
337
+
338
+			$gd_session->un_set('listing');
339
+		} else {
340
+			$gd_session->un_set('listing');
341
+			wp_redirect(geodir_login_url());
342
+			exit();
343
+		}
344
+	}
345
+
346
+	if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') {
347
+		/**
348
+		 * Contains registration and login functions.
349
+		 * @todo Fix the file path.
350
+		 *
351
+		 * @since 1.0.0
352
+		 * @package GeoDirectory
353
+		 */
354
+		include_once(geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php');
355
+	}
356
+
357
+
358
+	if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') {
359
+		$terms_o = get_terms(sanitize_text_field($_REQUEST['term']));
360 360
 		
361 361
 		// Skip terms which has no listing
362 362
 		if (!empty($terms_o)) {
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
 			$terms_o = $filter_terms;
371 371
 		}
372 372
 		
373
-        $terms = geodir_sort_terms($terms_o, 'count');
374
-        geodir_helper_cat_list_output($terms, intval($_REQUEST['limit']));
375
-        exit();
373
+		$terms = geodir_sort_terms($terms_o, 'count');
374
+		geodir_helper_cat_list_output($terms, intval($_REQUEST['limit']));
375
+		exit();
376 376
 
377
-    }
377
+	}
378 378
 
379
-    gd_die();
379
+	gd_die();
380 380
 }
Please login to merge, or discard this patch.