@@ -16,22 +16,22 @@ discard block |
||
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 |
||
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 |
||
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,240 +118,240 @@ discard block |
||
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 | - require_once(geodir_plugin_path() . '/geodirectory-templates/popup-forms.php'); |
|
200 | - |
|
201 | - gd_die(); |
|
202 | - } |
|
203 | - |
|
204 | - /*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 | + require_once(geodir_plugin_path() . '/geodirectory-templates/popup-forms.php'); |
|
200 | + |
|
201 | + gd_die(); |
|
202 | + } |
|
203 | + |
|
204 | + /*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){ |
|
205 | 205 | include_once ( geodir_plugin_path() . '/geodirectory-templates/advance-search-form.php'); |
206 | 206 | }*/ |
207 | 207 | |
208 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') { |
|
209 | - /** |
|
210 | - * Contains map marker functions. |
|
211 | - * |
|
212 | - * @since 1.0.0 |
|
213 | - * @package GeoDirectory |
|
214 | - */ |
|
215 | - include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'); |
|
216 | - } |
|
217 | - |
|
218 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') { |
|
219 | - if (is_user_logged_in()) { |
|
220 | - switch ($_REQUEST['ajax_action']): |
|
221 | - case "add" : |
|
222 | - geodir_add_to_favorite((int)$_REQUEST['pid']); |
|
223 | - break; |
|
224 | - case "remove" : |
|
225 | - geodir_remove_from_favorite((int)$_REQUEST['pid']); |
|
226 | - break; |
|
227 | - endswitch; |
|
228 | - } else { |
|
229 | - wp_redirect(geodir_login_url()); |
|
230 | - exit(); |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') { |
|
235 | - |
|
236 | - $is_current_user_owner = true; |
|
237 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
238 | - $is_current_user_owner = geodir_listing_belong_to_current_user((int)$_REQUEST['pid']); |
|
239 | - } |
|
240 | - |
|
241 | - $request = $gd_session->get('listing'); |
|
242 | - |
|
243 | - if (is_user_logged_in() && $is_current_user_owner) { |
|
244 | - |
|
245 | - switch ($_REQUEST['ajax_action']): |
|
246 | - case "add": |
|
247 | - case "update": |
|
248 | - |
|
249 | - if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { |
|
250 | - $last_id = geodir_save_listing(); |
|
251 | - |
|
252 | - if ($last_id) { |
|
253 | - //$redirect_to = get_permalink( $last_id ); |
|
254 | - $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); |
|
255 | - |
|
256 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
257 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
258 | - $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); |
|
259 | - } else |
|
260 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
261 | - |
|
262 | - wp_redirect($redirect_to); |
|
263 | - } else { |
|
264 | - $gd_session->un_set('listing'); |
|
265 | - wp_redirect(home_url()); |
|
266 | - } |
|
267 | - |
|
268 | - break; |
|
269 | - case "cancel" : |
|
270 | - |
|
271 | - $gd_session->un_set('listing'); |
|
272 | - |
|
273 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid'])) |
|
274 | - wp_redirect(get_permalink($_REQUEST['pid'])); |
|
275 | - else { |
|
276 | - geodir_remove_temp_images(); |
|
277 | - wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type']))); |
|
278 | - } |
|
279 | - |
|
280 | - break; |
|
281 | - |
|
282 | - case "publish" : |
|
283 | - |
|
284 | - if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { |
|
285 | - |
|
286 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
287 | - $new_post = array(); |
|
288 | - $new_post['ID'] = $_REQUEST['pid']; |
|
289 | - |
|
290 | - $lastid = wp_update_post($new_post); |
|
291 | - |
|
292 | - $gd_session->un_set('listing'); |
|
293 | - wp_redirect(get_permalink($lastid)); |
|
294 | - } else { |
|
295 | - $last_id = geodir_save_listing(); |
|
296 | - |
|
297 | - if ($last_id) { |
|
298 | - //$redirect_to = get_permalink( $last_id ); |
|
299 | - $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); |
|
300 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
301 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
302 | - $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); |
|
303 | - } else |
|
304 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
305 | - |
|
306 | - $gd_session->un_set('listing'); |
|
307 | - wp_redirect($redirect_to); |
|
308 | - } |
|
309 | - } else { |
|
310 | - $gd_session->un_set('listing'); |
|
311 | - wp_redirect(home_url()); |
|
312 | - } |
|
313 | - |
|
314 | - break; |
|
315 | - case "delete" : |
|
316 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
317 | - global $current_user; |
|
318 | - |
|
319 | - if (get_option('geodir_disable_perm_delete')) { |
|
320 | - $lastid = wp_trash_post($_REQUEST['pid']); |
|
321 | - } else { |
|
322 | - $lastid = wp_delete_post($_REQUEST['pid']); |
|
323 | - } |
|
324 | - |
|
325 | - if ($lastid && !is_wp_error($lastid)) |
|
326 | - wp_redirect($_SERVER['HTTP_REFERER']); |
|
327 | - |
|
328 | - //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) ); |
|
329 | - } |
|
330 | - break; |
|
331 | - endswitch; |
|
332 | - |
|
333 | - $gd_session->un_set('listing'); |
|
334 | - } else { |
|
335 | - $gd_session->un_set('listing'); |
|
336 | - wp_redirect(geodir_login_url()); |
|
337 | - exit(); |
|
338 | - } |
|
339 | - } |
|
340 | - |
|
341 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') { |
|
342 | - /** |
|
343 | - * Contains registration and login functions. |
|
344 | - * @todo Fix the file path. |
|
345 | - * |
|
346 | - * @since 1.0.0 |
|
347 | - * @package GeoDirectory |
|
348 | - */ |
|
349 | - include_once(geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php'); |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') { |
|
354 | - $terms_o = get_terms(sanitize_text_field($_REQUEST['term'])); |
|
208 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') { |
|
209 | + /** |
|
210 | + * Contains map marker functions. |
|
211 | + * |
|
212 | + * @since 1.0.0 |
|
213 | + * @package GeoDirectory |
|
214 | + */ |
|
215 | + include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'); |
|
216 | + } |
|
217 | + |
|
218 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') { |
|
219 | + if (is_user_logged_in()) { |
|
220 | + switch ($_REQUEST['ajax_action']): |
|
221 | + case "add" : |
|
222 | + geodir_add_to_favorite((int)$_REQUEST['pid']); |
|
223 | + break; |
|
224 | + case "remove" : |
|
225 | + geodir_remove_from_favorite((int)$_REQUEST['pid']); |
|
226 | + break; |
|
227 | + endswitch; |
|
228 | + } else { |
|
229 | + wp_redirect(geodir_login_url()); |
|
230 | + exit(); |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') { |
|
235 | + |
|
236 | + $is_current_user_owner = true; |
|
237 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
238 | + $is_current_user_owner = geodir_listing_belong_to_current_user((int)$_REQUEST['pid']); |
|
239 | + } |
|
240 | + |
|
241 | + $request = $gd_session->get('listing'); |
|
242 | + |
|
243 | + if (is_user_logged_in() && $is_current_user_owner) { |
|
244 | + |
|
245 | + switch ($_REQUEST['ajax_action']): |
|
246 | + case "add": |
|
247 | + case "update": |
|
248 | + |
|
249 | + if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { |
|
250 | + $last_id = geodir_save_listing(); |
|
251 | + |
|
252 | + if ($last_id) { |
|
253 | + //$redirect_to = get_permalink( $last_id ); |
|
254 | + $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); |
|
255 | + |
|
256 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
257 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
258 | + $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); |
|
259 | + } else |
|
260 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
261 | + |
|
262 | + wp_redirect($redirect_to); |
|
263 | + } else { |
|
264 | + $gd_session->un_set('listing'); |
|
265 | + wp_redirect(home_url()); |
|
266 | + } |
|
267 | + |
|
268 | + break; |
|
269 | + case "cancel" : |
|
270 | + |
|
271 | + $gd_session->un_set('listing'); |
|
272 | + |
|
273 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid'])) |
|
274 | + wp_redirect(get_permalink($_REQUEST['pid'])); |
|
275 | + else { |
|
276 | + geodir_remove_temp_images(); |
|
277 | + wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type']))); |
|
278 | + } |
|
279 | + |
|
280 | + break; |
|
281 | + |
|
282 | + case "publish" : |
|
283 | + |
|
284 | + if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { |
|
285 | + |
|
286 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
287 | + $new_post = array(); |
|
288 | + $new_post['ID'] = $_REQUEST['pid']; |
|
289 | + |
|
290 | + $lastid = wp_update_post($new_post); |
|
291 | + |
|
292 | + $gd_session->un_set('listing'); |
|
293 | + wp_redirect(get_permalink($lastid)); |
|
294 | + } else { |
|
295 | + $last_id = geodir_save_listing(); |
|
296 | + |
|
297 | + if ($last_id) { |
|
298 | + //$redirect_to = get_permalink( $last_id ); |
|
299 | + $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); |
|
300 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
301 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
302 | + $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); |
|
303 | + } else |
|
304 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
305 | + |
|
306 | + $gd_session->un_set('listing'); |
|
307 | + wp_redirect($redirect_to); |
|
308 | + } |
|
309 | + } else { |
|
310 | + $gd_session->un_set('listing'); |
|
311 | + wp_redirect(home_url()); |
|
312 | + } |
|
313 | + |
|
314 | + break; |
|
315 | + case "delete" : |
|
316 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
317 | + global $current_user; |
|
318 | + |
|
319 | + if (get_option('geodir_disable_perm_delete')) { |
|
320 | + $lastid = wp_trash_post($_REQUEST['pid']); |
|
321 | + } else { |
|
322 | + $lastid = wp_delete_post($_REQUEST['pid']); |
|
323 | + } |
|
324 | + |
|
325 | + if ($lastid && !is_wp_error($lastid)) |
|
326 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
327 | + |
|
328 | + //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) ); |
|
329 | + } |
|
330 | + break; |
|
331 | + endswitch; |
|
332 | + |
|
333 | + $gd_session->un_set('listing'); |
|
334 | + } else { |
|
335 | + $gd_session->un_set('listing'); |
|
336 | + wp_redirect(geodir_login_url()); |
|
337 | + exit(); |
|
338 | + } |
|
339 | + } |
|
340 | + |
|
341 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') { |
|
342 | + /** |
|
343 | + * Contains registration and login functions. |
|
344 | + * @todo Fix the file path. |
|
345 | + * |
|
346 | + * @since 1.0.0 |
|
347 | + * @package GeoDirectory |
|
348 | + */ |
|
349 | + include_once(geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php'); |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') { |
|
354 | + $terms_o = get_terms(sanitize_text_field($_REQUEST['term'])); |
|
355 | 355 | |
356 | 356 | // Skip terms which has no listing |
357 | 357 | if (!empty($terms_o)) { |
@@ -365,11 +365,11 @@ discard block |
||
365 | 365 | $terms_o = $filter_terms; |
366 | 366 | } |
367 | 367 | |
368 | - $terms = geodir_sort_terms($terms_o, 'count'); |
|
369 | - geodir_helper_cat_list_output($terms, intval($_REQUEST['limit'])); |
|
370 | - exit(); |
|
368 | + $terms = geodir_sort_terms($terms_o, 'count'); |
|
369 | + geodir_helper_cat_list_output($terms, intval($_REQUEST['limit'])); |
|
370 | + exit(); |
|
371 | 371 | |
372 | - } |
|
372 | + } |
|
373 | 373 | |
374 | - gd_die(); |
|
374 | + gd_die(); |
|
375 | 375 | } |