@@ -10,33 +10,33 @@ discard block |
||
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 |
||
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 |
||
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 | |
@@ -86,24 +86,24 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function geodir_conditional_admin_script_load() |
88 | 88 | { |
89 | - global $pagenow; |
|
89 | + global $pagenow; |
|
90 | 90 | |
91 | 91 | // Get the current post type |
92 | 92 | $post_type = geodir_admin_current_post_type(); |
93 | 93 | $geodir_post_types = geodir_get_posttypes(); |
94 | 94 | |
95 | 95 | 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')) { |
96 | - add_action('admin_enqueue_scripts', 'geodir_admin_scripts'); |
|
97 | - add_action('admin_enqueue_scripts', 'geodir_admin_styles'); |
|
98 | - add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100); |
|
96 | + add_action('admin_enqueue_scripts', 'geodir_admin_scripts'); |
|
97 | + add_action('admin_enqueue_scripts', 'geodir_admin_styles'); |
|
98 | + add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100); |
|
99 | 99 | |
100 | - // Disable VC editor for GD post types. |
|
101 | - if (class_exists('Vc_Role_Access_Controller')) { |
|
102 | - add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 ); |
|
103 | - } |
|
104 | - } |
|
100 | + // Disable VC editor for GD post types. |
|
101 | + if (class_exists('Vc_Role_Access_Controller')) { |
|
102 | + add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 ); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - add_action('admin_enqueue_scripts', 'geodir_admin_styles_req'); |
|
106 | + add_action('admin_enqueue_scripts', 'geodir_admin_styles_req'); |
|
107 | 107 | |
108 | 108 | } |
109 | 109 | |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | */ |
139 | 139 | function create_default_admin_main_nav() |
140 | 140 | { |
141 | - add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1); |
|
142 | - add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2); |
|
143 | - add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90); |
|
144 | - add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95); |
|
145 | - add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100); |
|
146 | - //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3); |
|
141 | + add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1); |
|
142 | + add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2); |
|
143 | + add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90); |
|
144 | + add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95); |
|
145 | + add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100); |
|
146 | + //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3); |
|
147 | 147 | |
148 | 148 | } |
149 | 149 | |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function geodir_admin_list_columns() |
159 | 159 | { |
160 | - if ($post_types = geodir_get_posttypes()) { |
|
160 | + if ($post_types = geodir_get_posttypes()) { |
|
161 | 161 | |
162 | - foreach ($post_types as $post_type): |
|
163 | - add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100); |
|
164 | - //Filter-Payment-Manager to show Package |
|
165 | - add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2); |
|
162 | + foreach ($post_types as $post_type): |
|
163 | + add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100); |
|
164 | + //Filter-Payment-Manager to show Package |
|
165 | + add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2); |
|
166 | 166 | |
167 | - add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns'); |
|
167 | + add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns'); |
|
168 | 168 | |
169 | - // Filter bulk actions |
|
170 | - add_filter("bulk_actions-edit-{$post_type}", 'geodir_filter_bulk_actions', 10, 1); |
|
171 | - endforeach; |
|
172 | - } |
|
169 | + // Filter bulk actions |
|
170 | + add_filter("bulk_actions-edit-{$post_type}", 'geodir_filter_bulk_actions', 10, 1); |
|
171 | + endforeach; |
|
172 | + } |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function geodir_default_admin_main_tabs($tabs) |
184 | 184 | { |
185 | - return $tabs = array( |
|
186 | - 'general_settings' => array('label' => __('General', 'geodirectory')), |
|
187 | - 'design_settings' => array('label' => __('Design', 'geodirectory')), |
|
188 | - 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')), |
|
189 | - 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')), |
|
190 | - 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')), |
|
191 | - 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')), |
|
192 | - |
|
193 | - ); |
|
185 | + return $tabs = array( |
|
186 | + 'general_settings' => array('label' => __('General', 'geodirectory')), |
|
187 | + 'design_settings' => array('label' => __('Design', 'geodirectory')), |
|
188 | + 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')), |
|
189 | + 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')), |
|
190 | + 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')), |
|
191 | + 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')), |
|
192 | + |
|
193 | + ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | add_action('do_meta_boxes', 'geodir_remove_image_box'); |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | */ |
204 | 204 | function geodir_remove_image_box() |
205 | 205 | { |
206 | - global $post; |
|
206 | + global $post; |
|
207 | 207 | |
208 | - $geodir_posttypes = geodir_get_posttypes(); |
|
208 | + $geodir_posttypes = geodir_get_posttypes(); |
|
209 | 209 | |
210 | - if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
210 | + if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
211 | 211 | |
212 | - remove_meta_box('postimagediv', $post->post_type, 'side'); |
|
213 | - remove_meta_box('revisionsdiv', $post->post_type, 'normal'); |
|
212 | + remove_meta_box('postimagediv', $post->post_type, 'side'); |
|
213 | + remove_meta_box('revisionsdiv', $post->post_type, 'normal'); |
|
214 | 214 | |
215 | - endif; |
|
215 | + endif; |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -227,27 +227,27 @@ discard block |
||
227 | 227 | */ |
228 | 228 | function geodir_meta_box_add() |
229 | 229 | { |
230 | - global $post; |
|
230 | + global $post; |
|
231 | 231 | |
232 | - $geodir_post_types = geodir_get_posttypes('array'); |
|
233 | - $geodir_posttypes = array_keys($geodir_post_types); |
|
232 | + $geodir_post_types = geodir_get_posttypes('array'); |
|
233 | + $geodir_posttypes = array_keys($geodir_post_types); |
|
234 | 234 | |
235 | - if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
235 | + if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
236 | 236 | |
237 | - $geodir_posttype = $post->post_type; |
|
238 | - $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory'); |
|
239 | - $post_typename = geodir_ucwords($post_typename); |
|
237 | + $geodir_posttype = $post->post_type; |
|
238 | + $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory'); |
|
239 | + $post_typename = geodir_ucwords($post_typename); |
|
240 | 240 | |
241 | - // Filter-Payment-Manager |
|
241 | + // Filter-Payment-Manager |
|
242 | 242 | |
243 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
243 | + add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
244 | 244 | |
245 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
245 | + add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
246 | 246 | |
247 | - // no need of this box as all fields moved to main information box |
|
248 | - //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' ); |
|
247 | + // no need of this box as all fields moved to main information box |
|
248 | + //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' ); |
|
249 | 249 | |
250 | - endif; |
|
250 | + endif; |
|
251 | 251 | |
252 | 252 | } |
253 | 253 | |
@@ -271,23 +271,23 @@ discard block |
||
271 | 271 | function geodir_hide_post_taxonomy_meta_boxes() |
272 | 272 | { |
273 | 273 | |
274 | - $geodir_post_types = get_option('geodir_post_types'); |
|
274 | + $geodir_post_types = get_option('geodir_post_types'); |
|
275 | 275 | |
276 | - if (!empty($geodir_post_types)) { |
|
277 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) { |
|
276 | + if (!empty($geodir_post_types)) { |
|
277 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) { |
|
278 | 278 | |
279 | - $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
279 | + $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
280 | 280 | |
281 | - if(!empty($gd_taxonomy)) { |
|
282 | - foreach ($gd_taxonomy as $tax) { |
|
281 | + if(!empty($gd_taxonomy)) { |
|
282 | + foreach ($gd_taxonomy as $tax) { |
|
283 | 283 | |
284 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
284 | + remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
285 | 285 | |
286 | - } |
|
287 | - } |
|
286 | + } |
|
287 | + } |
|
288 | 288 | |
289 | - } |
|
290 | - } |
|
289 | + } |
|
290 | + } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict'); |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | */ |
302 | 302 | function geodir_add_listing_map_restrict($map_restirct) |
303 | 303 | { |
304 | - if (is_admin()) { |
|
305 | - if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') { |
|
306 | - $map_restirct = false; |
|
307 | - } |
|
308 | - } |
|
309 | - return $map_restirct; |
|
304 | + if (is_admin()) { |
|
305 | + if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') { |
|
306 | + $map_restirct = false; |
|
307 | + } |
|
308 | + } |
|
309 | + return $map_restirct; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -325,16 +325,16 @@ discard block |
||
325 | 325 | function geodir_enable_editor_on_notifications($notification) |
326 | 326 | { |
327 | 327 | |
328 | - if (!empty($notification) && get_option('geodir_tiny_editor') == '1') { |
|
328 | + if (!empty($notification) && get_option('geodir_tiny_editor') == '1') { |
|
329 | 329 | |
330 | - foreach ($notification as $key => $value) { |
|
331 | - if ($value['type'] == 'textarea') |
|
332 | - $notification[$key]['type'] = 'editor'; |
|
333 | - } |
|
330 | + foreach ($notification as $key => $value) { |
|
331 | + if ($value['type'] == 'textarea') |
|
332 | + $notification[$key]['type'] = 'editor'; |
|
333 | + } |
|
334 | 334 | |
335 | - } |
|
335 | + } |
|
336 | 336 | |
337 | - return $notification; |
|
337 | + return $notification; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -351,16 +351,16 @@ discard block |
||
351 | 351 | function geodir_enable_editor_on_design_settings($design_setting) |
352 | 352 | { |
353 | 353 | |
354 | - if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') { |
|
354 | + if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') { |
|
355 | 355 | |
356 | - foreach ($design_setting as $key => $value) { |
|
357 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
358 | - $design_setting[$key]['type'] = 'editor'; |
|
359 | - } |
|
356 | + foreach ($design_setting as $key => $value) { |
|
357 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
358 | + $design_setting[$key]['type'] = 'editor'; |
|
359 | + } |
|
360 | 360 | |
361 | - } |
|
361 | + } |
|
362 | 362 | |
363 | - return $design_setting; |
|
363 | + return $design_setting; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /* ----------- START MANAGE CUSTOM FIELDS ---------------- */ |
@@ -368,15 +368,15 @@ discard block |
||
368 | 368 | add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom'); |
369 | 369 | |
370 | 370 | function geodir_manage_available_fields_predefined($sub_tab){ |
371 | - if($sub_tab=='custom_fields'){ |
|
372 | - geodir_custom_available_fields('predefined'); |
|
373 | - } |
|
371 | + if($sub_tab=='custom_fields'){ |
|
372 | + geodir_custom_available_fields('predefined'); |
|
373 | + } |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | function geodir_manage_available_fields_custom($sub_tab){ |
377 | - if($sub_tab=='custom_fields'){ |
|
378 | - geodir_custom_available_fields('custom'); |
|
379 | - } |
|
377 | + if($sub_tab=='custom_fields'){ |
|
378 | + geodir_custom_available_fields('custom'); |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -395,16 +395,16 @@ discard block |
||
395 | 395 | function geodir_manage_available_fields($sub_tab) |
396 | 396 | { |
397 | 397 | |
398 | - switch ($sub_tab) { |
|
399 | - case 'custom_fields': |
|
400 | - geodir_custom_available_fields(); |
|
401 | - break; |
|
398 | + switch ($sub_tab) { |
|
399 | + case 'custom_fields': |
|
400 | + geodir_custom_available_fields(); |
|
401 | + break; |
|
402 | 402 | |
403 | - case 'sorting_options': |
|
404 | - geodir_sorting_options_available_fields(); |
|
405 | - break; |
|
403 | + case 'sorting_options': |
|
404 | + geodir_sorting_options_available_fields(); |
|
405 | + break; |
|
406 | 406 | |
407 | - } |
|
407 | + } |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -420,16 +420,16 @@ discard block |
||
420 | 420 | function geodir_manage_selected_fields($sub_tab) |
421 | 421 | { |
422 | 422 | |
423 | - switch ($sub_tab) { |
|
424 | - case 'custom_fields': |
|
425 | - geodir_custom_selected_fields(); |
|
426 | - break; |
|
423 | + switch ($sub_tab) { |
|
424 | + case 'custom_fields': |
|
425 | + geodir_custom_selected_fields(); |
|
426 | + break; |
|
427 | 427 | |
428 | - case 'sorting_options': |
|
429 | - geodir_sorting_options_selected_fields(); |
|
430 | - break; |
|
428 | + case 'sorting_options': |
|
429 | + geodir_sorting_options_selected_fields(); |
|
430 | + break; |
|
431 | 431 | |
432 | - } |
|
432 | + } |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -441,52 +441,52 @@ discard block |
||
441 | 441 | */ |
442 | 442 | function geodir_sorting_options_available_fields() |
443 | 443 | { |
444 | - global $wpdb; |
|
445 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
446 | - ?> |
|
444 | + global $wpdb; |
|
445 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
446 | + ?> |
|
447 | 447 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
448 | 448 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
449 | 449 | <ul> |
450 | 450 | <?php |
451 | - $sort_options = geodir_get_custom_sort_options($listing_type); |
|
451 | + $sort_options = geodir_get_custom_sort_options($listing_type); |
|
452 | 452 | |
453 | - foreach ($sort_options as $key => $val) { |
|
454 | - $val = stripslashes_deep($val); // strip slashes |
|
455 | - |
|
456 | - $check_html_variable = $wpdb->get_var( |
|
457 | - $wpdb->prepare( |
|
458 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
459 | - array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
460 | - ) |
|
461 | - ); |
|
453 | + foreach ($sort_options as $key => $val) { |
|
454 | + $val = stripslashes_deep($val); // strip slashes |
|
455 | + |
|
456 | + $check_html_variable = $wpdb->get_var( |
|
457 | + $wpdb->prepare( |
|
458 | + "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
459 | + array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
460 | + ) |
|
461 | + ); |
|
462 | 462 | |
463 | - $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
464 | - ?> |
|
463 | + $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
464 | + ?> |
|
465 | 465 | |
466 | 466 | <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> |
467 | 467 | <?php |
468 | - if(isset($val['description']) && $val['description']){ |
|
469 | - echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
|
470 | - }?> |
|
468 | + if(isset($val['description']) && $val['description']){ |
|
469 | + echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
|
470 | + }?> |
|
471 | 471 | |
472 | 472 | <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>" data-field-type="<?php echo $val['field_type'];?>" |
473 | 473 | title="<?php echo $val['site_title'];?>" |
474 | 474 | class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
475 | 475 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], ' fa-') !== false) { |
476 | - echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
|
477 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
478 | - echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>'; |
|
479 | - }else{ |
|
480 | - echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
481 | - }?> |
|
476 | + echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
|
477 | + }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
478 | + echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>'; |
|
479 | + }else{ |
|
480 | + echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
481 | + }?> |
|
482 | 482 | <?php echo (! empty( $val['admin_title'] ) ? $val['admin_title'] : $val['site_title'] );?> |
483 | 483 | </a> |
484 | 484 | </li> |
485 | 485 | |
486 | 486 | |
487 | 487 | <?php |
488 | - } |
|
489 | - ?> |
|
488 | + } |
|
489 | + ?> |
|
490 | 490 | </ul> |
491 | 491 | <?php |
492 | 492 | } |
@@ -500,28 +500,28 @@ discard block |
||
500 | 500 | */ |
501 | 501 | function geodir_sorting_options_selected_fields() |
502 | 502 | { |
503 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
504 | - ?> |
|
503 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
504 | + ?> |
|
505 | 505 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
506 | 506 | <ul class="core"> |
507 | 507 | <?php |
508 | - global $wpdb; |
|
508 | + global $wpdb; |
|
509 | 509 | |
510 | - $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))); |
|
510 | + $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))); |
|
511 | 511 | |
512 | - if (!empty($fields)) { |
|
513 | - foreach ($fields as $field) { |
|
514 | - //$result_str = $field->id; |
|
515 | - $result_str = $field; |
|
516 | - $field_type = $field->field_type; |
|
517 | - $field_ins_upd = 'display'; |
|
512 | + if (!empty($fields)) { |
|
513 | + foreach ($fields as $field) { |
|
514 | + //$result_str = $field->id; |
|
515 | + $result_str = $field; |
|
516 | + $field_type = $field->field_type; |
|
517 | + $field_ins_upd = 'display'; |
|
518 | 518 | |
519 | - $default = false; |
|
519 | + $default = false; |
|
520 | 520 | |
521 | - geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
522 | - } |
|
523 | - } |
|
524 | - ?> |
|
521 | + geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
522 | + } |
|
523 | + } |
|
524 | + ?> |
|
525 | 525 | </ul> |
526 | 526 | <?php |
527 | 527 | } |
@@ -534,12 +534,12 @@ discard block |
||
534 | 534 | */ |
535 | 535 | function geodir_custom_fields_custom($post_type=''){ |
536 | 536 | |
537 | - $custom_fields = array(); |
|
537 | + $custom_fields = array(); |
|
538 | 538 | |
539 | - /** |
|
540 | - * @see `geodir_custom_fields` |
|
541 | - */ |
|
542 | - return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type); |
|
539 | + /** |
|
540 | + * @see `geodir_custom_fields` |
|
541 | + */ |
|
542 | + return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -552,140 +552,140 @@ discard block |
||
552 | 552 | */ |
553 | 553 | function geodir_custom_fields($post_type=''){ |
554 | 554 | |
555 | - $custom_fields = array( |
|
556 | - 'text' => array( |
|
557 | - 'field_type' => 'text', |
|
558 | - 'class' => 'gd-text', |
|
559 | - 'icon' => 'fas fa-minus', |
|
560 | - 'name' => __('Text', 'geodirectory'), |
|
561 | - 'description' => __('Add any sort of text field, text or numbers', 'geodirectory') |
|
562 | - ), |
|
563 | - 'datepicker' => array( |
|
564 | - 'field_type' => 'datepicker', |
|
565 | - 'class' => 'gd-datepicker', |
|
566 | - 'icon' => 'fas fa-calendar-alt', |
|
567 | - 'name' => __('Date', 'geodirectory'), |
|
568 | - 'description' => __('Adds a date picker.', 'geodirectory') |
|
569 | - ), |
|
570 | - 'textarea' => array( |
|
571 | - 'field_type' => 'textarea', |
|
572 | - 'class' => 'gd-textarea', |
|
573 | - 'icon' => 'fas fa-bars', |
|
574 | - 'name' => __('Textarea', 'geodirectory'), |
|
575 | - 'description' => __('Adds a textarea', 'geodirectory') |
|
576 | - ), |
|
577 | - 'time' => array( |
|
578 | - 'field_type' => 'time', |
|
579 | - 'class' => 'gd-time', |
|
580 | - 'icon' => 'far fa-clock', |
|
581 | - 'name' => __('Time', 'geodirectory'), |
|
582 | - 'description' => __('Adds a time picker', 'geodirectory') |
|
583 | - ), |
|
584 | - 'checkbox' => array( |
|
585 | - 'field_type' => 'checkbox', |
|
586 | - 'class' => 'gd-checkbox', |
|
587 | - 'icon' => 'far fa-check-square', |
|
588 | - 'name' => __('Checkbox', 'geodirectory'), |
|
589 | - 'description' => __('Adds a checkbox', 'geodirectory') |
|
590 | - ), |
|
591 | - 'phone' => array( |
|
592 | - 'field_type' => 'phone', |
|
593 | - 'class' => 'gd-phone', |
|
594 | - 'icon' => 'fas fa-phone', |
|
595 | - 'name' => __('Phone', 'geodirectory'), |
|
596 | - 'description' => __('Adds a phone input', 'geodirectory') |
|
597 | - ), |
|
598 | - 'radio' => array( |
|
599 | - 'field_type' => 'radio', |
|
600 | - 'class' => 'gd-radio', |
|
601 | - 'icon' => 'far fa-dot-circle', |
|
602 | - 'name' => __('Radio', 'geodirectory'), |
|
603 | - 'description' => __('Adds a radio input', 'geodirectory') |
|
604 | - ), |
|
605 | - 'email' => array( |
|
606 | - 'field_type' => 'email', |
|
607 | - 'class' => 'gd-email', |
|
608 | - 'icon' => 'far fa-envelope', |
|
609 | - 'name' => __('Email', 'geodirectory'), |
|
610 | - 'description' => __('Adds a email input', 'geodirectory') |
|
611 | - ), |
|
612 | - 'select' => array( |
|
613 | - 'field_type' => 'select', |
|
614 | - 'class' => 'gd-select', |
|
615 | - 'icon' => 'far fa-caret-square-down', |
|
616 | - 'name' => __('Select', 'geodirectory'), |
|
617 | - 'description' => __('Adds a select input', 'geodirectory') |
|
618 | - ), |
|
619 | - 'multiselect' => array( |
|
620 | - 'field_type' => 'multiselect', |
|
621 | - 'class' => 'gd-multiselect', |
|
622 | - 'icon' => 'far fa-caret-square-down', |
|
623 | - 'name' => __('Multi Select', 'geodirectory'), |
|
624 | - 'description' => __('Adds a multiselect input', 'geodirectory') |
|
625 | - ), |
|
626 | - 'url' => array( |
|
627 | - 'field_type' => 'url', |
|
628 | - 'class' => 'gd-url', |
|
629 | - 'icon' => 'fas fa-link', |
|
630 | - 'name' => __('URL', 'geodirectory'), |
|
631 | - 'description' => __('Adds a url input', 'geodirectory') |
|
632 | - ), |
|
633 | - 'html' => array( |
|
634 | - 'field_type' => 'html', |
|
635 | - 'class' => 'gd-html', |
|
636 | - 'icon' => 'fas fa-code', |
|
637 | - 'name' => __('HTML', 'geodirectory'), |
|
638 | - 'description' => __('Adds a html input textarea', 'geodirectory') |
|
639 | - ), |
|
640 | - 'file' => array( |
|
641 | - 'field_type' => 'file', |
|
642 | - 'class' => 'gd-file', |
|
643 | - 'icon' => 'fas fa-file', |
|
644 | - 'name' => __('File Upload', 'geodirectory'), |
|
645 | - 'description' => __('Adds a file input', 'geodirectory') |
|
646 | - ) |
|
647 | - ); |
|
648 | - |
|
649 | - /** |
|
650 | - * Filter the custom fields array to be able to add or remove items. |
|
651 | - * |
|
652 | - * @since 1.6.6 |
|
653 | - * |
|
654 | - * @param array $custom_fields { |
|
655 | - * The custom fields array to be filtered. |
|
656 | - * |
|
657 | - * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. |
|
658 | - * @type string $class The class for the field in backend. |
|
659 | - * @type string $icon Can be font-awesome class name or icon image url. |
|
660 | - * @type string $name The name of the field. |
|
661 | - * @type string $description A short description about the field. |
|
662 | - * @type array $defaults { |
|
663 | - * Optional. Used to set the default value of the field. |
|
664 | - * |
|
665 | - * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE |
|
666 | - * @type int decimal_point limit if using FLOAT data_type |
|
667 | - * @type string admin_title The admin title for the field. |
|
668 | - * @type string site_title This will be the title for the field on the frontend. |
|
669 | - * @type string admin_desc This will be shown below the field on the add listing form. |
|
670 | - * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. |
|
671 | - * @type bool is_active If false the field will not be displayed anywhere. |
|
672 | - * @type bool for_admin_use If true then only site admin can see and edit this field. |
|
673 | - * @type string default_value The default value for the input on the add listing page. |
|
674 | - * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] |
|
675 | - * @type bool is_required If true the field will be required on the add listing page. |
|
676 | - * @type string option_values The option values for select and multiselect only |
|
677 | - * @type string validation_pattern HTML5 validation pattern (text input only by default). |
|
678 | - * @type string validation_msg HTML5 validation message (text input only by default). |
|
679 | - * @type string required_msg Required warning message. |
|
680 | - * @type string field_icon Icon url or font awesome class. |
|
681 | - * @type string css_class Field custom css class for field custom style. |
|
682 | - * @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option. |
|
683 | - * @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required) |
|
684 | - * } |
|
685 | - * } |
|
686 | - * @param string $post_type The post type requested. |
|
687 | - */ |
|
688 | - return apply_filters('geodir_custom_fields',$custom_fields,$post_type); |
|
555 | + $custom_fields = array( |
|
556 | + 'text' => array( |
|
557 | + 'field_type' => 'text', |
|
558 | + 'class' => 'gd-text', |
|
559 | + 'icon' => 'fas fa-minus', |
|
560 | + 'name' => __('Text', 'geodirectory'), |
|
561 | + 'description' => __('Add any sort of text field, text or numbers', 'geodirectory') |
|
562 | + ), |
|
563 | + 'datepicker' => array( |
|
564 | + 'field_type' => 'datepicker', |
|
565 | + 'class' => 'gd-datepicker', |
|
566 | + 'icon' => 'fas fa-calendar-alt', |
|
567 | + 'name' => __('Date', 'geodirectory'), |
|
568 | + 'description' => __('Adds a date picker.', 'geodirectory') |
|
569 | + ), |
|
570 | + 'textarea' => array( |
|
571 | + 'field_type' => 'textarea', |
|
572 | + 'class' => 'gd-textarea', |
|
573 | + 'icon' => 'fas fa-bars', |
|
574 | + 'name' => __('Textarea', 'geodirectory'), |
|
575 | + 'description' => __('Adds a textarea', 'geodirectory') |
|
576 | + ), |
|
577 | + 'time' => array( |
|
578 | + 'field_type' => 'time', |
|
579 | + 'class' => 'gd-time', |
|
580 | + 'icon' => 'far fa-clock', |
|
581 | + 'name' => __('Time', 'geodirectory'), |
|
582 | + 'description' => __('Adds a time picker', 'geodirectory') |
|
583 | + ), |
|
584 | + 'checkbox' => array( |
|
585 | + 'field_type' => 'checkbox', |
|
586 | + 'class' => 'gd-checkbox', |
|
587 | + 'icon' => 'far fa-check-square', |
|
588 | + 'name' => __('Checkbox', 'geodirectory'), |
|
589 | + 'description' => __('Adds a checkbox', 'geodirectory') |
|
590 | + ), |
|
591 | + 'phone' => array( |
|
592 | + 'field_type' => 'phone', |
|
593 | + 'class' => 'gd-phone', |
|
594 | + 'icon' => 'fas fa-phone', |
|
595 | + 'name' => __('Phone', 'geodirectory'), |
|
596 | + 'description' => __('Adds a phone input', 'geodirectory') |
|
597 | + ), |
|
598 | + 'radio' => array( |
|
599 | + 'field_type' => 'radio', |
|
600 | + 'class' => 'gd-radio', |
|
601 | + 'icon' => 'far fa-dot-circle', |
|
602 | + 'name' => __('Radio', 'geodirectory'), |
|
603 | + 'description' => __('Adds a radio input', 'geodirectory') |
|
604 | + ), |
|
605 | + 'email' => array( |
|
606 | + 'field_type' => 'email', |
|
607 | + 'class' => 'gd-email', |
|
608 | + 'icon' => 'far fa-envelope', |
|
609 | + 'name' => __('Email', 'geodirectory'), |
|
610 | + 'description' => __('Adds a email input', 'geodirectory') |
|
611 | + ), |
|
612 | + 'select' => array( |
|
613 | + 'field_type' => 'select', |
|
614 | + 'class' => 'gd-select', |
|
615 | + 'icon' => 'far fa-caret-square-down', |
|
616 | + 'name' => __('Select', 'geodirectory'), |
|
617 | + 'description' => __('Adds a select input', 'geodirectory') |
|
618 | + ), |
|
619 | + 'multiselect' => array( |
|
620 | + 'field_type' => 'multiselect', |
|
621 | + 'class' => 'gd-multiselect', |
|
622 | + 'icon' => 'far fa-caret-square-down', |
|
623 | + 'name' => __('Multi Select', 'geodirectory'), |
|
624 | + 'description' => __('Adds a multiselect input', 'geodirectory') |
|
625 | + ), |
|
626 | + 'url' => array( |
|
627 | + 'field_type' => 'url', |
|
628 | + 'class' => 'gd-url', |
|
629 | + 'icon' => 'fas fa-link', |
|
630 | + 'name' => __('URL', 'geodirectory'), |
|
631 | + 'description' => __('Adds a url input', 'geodirectory') |
|
632 | + ), |
|
633 | + 'html' => array( |
|
634 | + 'field_type' => 'html', |
|
635 | + 'class' => 'gd-html', |
|
636 | + 'icon' => 'fas fa-code', |
|
637 | + 'name' => __('HTML', 'geodirectory'), |
|
638 | + 'description' => __('Adds a html input textarea', 'geodirectory') |
|
639 | + ), |
|
640 | + 'file' => array( |
|
641 | + 'field_type' => 'file', |
|
642 | + 'class' => 'gd-file', |
|
643 | + 'icon' => 'fas fa-file', |
|
644 | + 'name' => __('File Upload', 'geodirectory'), |
|
645 | + 'description' => __('Adds a file input', 'geodirectory') |
|
646 | + ) |
|
647 | + ); |
|
648 | + |
|
649 | + /** |
|
650 | + * Filter the custom fields array to be able to add or remove items. |
|
651 | + * |
|
652 | + * @since 1.6.6 |
|
653 | + * |
|
654 | + * @param array $custom_fields { |
|
655 | + * The custom fields array to be filtered. |
|
656 | + * |
|
657 | + * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. |
|
658 | + * @type string $class The class for the field in backend. |
|
659 | + * @type string $icon Can be font-awesome class name or icon image url. |
|
660 | + * @type string $name The name of the field. |
|
661 | + * @type string $description A short description about the field. |
|
662 | + * @type array $defaults { |
|
663 | + * Optional. Used to set the default value of the field. |
|
664 | + * |
|
665 | + * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE |
|
666 | + * @type int decimal_point limit if using FLOAT data_type |
|
667 | + * @type string admin_title The admin title for the field. |
|
668 | + * @type string site_title This will be the title for the field on the frontend. |
|
669 | + * @type string admin_desc This will be shown below the field on the add listing form. |
|
670 | + * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. |
|
671 | + * @type bool is_active If false the field will not be displayed anywhere. |
|
672 | + * @type bool for_admin_use If true then only site admin can see and edit this field. |
|
673 | + * @type string default_value The default value for the input on the add listing page. |
|
674 | + * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] |
|
675 | + * @type bool is_required If true the field will be required on the add listing page. |
|
676 | + * @type string option_values The option values for select and multiselect only |
|
677 | + * @type string validation_pattern HTML5 validation pattern (text input only by default). |
|
678 | + * @type string validation_msg HTML5 validation message (text input only by default). |
|
679 | + * @type string required_msg Required warning message. |
|
680 | + * @type string field_icon Icon url or font awesome class. |
|
681 | + * @type string css_class Field custom css class for field custom style. |
|
682 | + * @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option. |
|
683 | + * @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required) |
|
684 | + * } |
|
685 | + * } |
|
686 | + * @param string $post_type The post type requested. |
|
687 | + */ |
|
688 | + return apply_filters('geodir_custom_fields',$custom_fields,$post_type); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -698,19 +698,19 @@ discard block |
||
698 | 698 | */ |
699 | 699 | function geodir_custom_available_fields($type='') |
700 | 700 | { |
701 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
702 | - ?> |
|
701 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
702 | + ?> |
|
703 | 703 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
704 | 704 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> |
705 | 705 | |
706 | 706 | <?php |
707 | - if($type=='predefined'){ |
|
708 | - $cfs = geodir_custom_fields_predefined($listing_type); |
|
709 | - }elseif($type=='custom'){ |
|
710 | - $cfs = geodir_custom_fields_custom($listing_type); |
|
711 | - }else{ |
|
712 | - $cfs = geodir_custom_fields($listing_type); |
|
713 | - ?> |
|
707 | + if($type=='predefined'){ |
|
708 | + $cfs = geodir_custom_fields_predefined($listing_type); |
|
709 | + }elseif($type=='custom'){ |
|
710 | + $cfs = geodir_custom_fields_custom($listing_type); |
|
711 | + }else{ |
|
712 | + $cfs = geodir_custom_fields($listing_type); |
|
713 | + ?> |
|
714 | 714 | <ul class="full gd-cf-tooltip-wrap"> |
715 | 715 | <li> |
716 | 716 | <div class="gdcf-tooltip"> |
@@ -731,18 +731,18 @@ discard block |
||
731 | 731 | </ul> |
732 | 732 | |
733 | 733 | <?php |
734 | - } |
|
734 | + } |
|
735 | 735 | |
736 | - if(!empty($cfs)) { |
|
737 | - echo '<ul>'; |
|
738 | - foreach ( $cfs as $id => $cf ) { |
|
739 | - ?> |
|
736 | + if(!empty($cfs)) { |
|
737 | + echo '<ul>'; |
|
738 | + foreach ( $cfs as $id => $cf ) { |
|
739 | + ?> |
|
740 | 740 | |
741 | 741 | <li class="gd-cf-tooltip-wrap"> |
742 | 742 | <?php |
743 | - if ( isset( $cf['description'] ) && $cf['description'] ) { |
|
744 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
745 | - } ?> |
|
743 | + if ( isset( $cf['description'] ) && $cf['description'] ) { |
|
744 | + echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
745 | + } ?> |
|
746 | 746 | |
747 | 747 | <a id="gd-<?php echo $id; ?>" |
748 | 748 | data-field-custom-type="<?php echo $type; ?>" |
@@ -752,21 +752,21 @@ discard block |
||
752 | 752 | href="javascript:void(0);"> |
753 | 753 | |
754 | 754 | <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], ' fa-' ) !== false ) { |
755 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
756 | - } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) { |
|
757 | - echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>'; |
|
758 | - } else { |
|
759 | - echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
760 | - } ?> |
|
755 | + echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
756 | + } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) { |
|
757 | + echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>'; |
|
758 | + } else { |
|
759 | + echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
|
760 | + } ?> |
|
761 | 761 | <?php echo $cf['name']; ?> |
762 | 762 | </a> |
763 | 763 | </li> |
764 | 764 | <?php |
765 | - } |
|
766 | - }else{ |
|
767 | - _e('There are no custom fields here yet.', 'geodirectory'); |
|
768 | - } |
|
769 | - ?> |
|
765 | + } |
|
766 | + }else{ |
|
767 | + _e('There are no custom fields here yet.', 'geodirectory'); |
|
768 | + } |
|
769 | + ?> |
|
770 | 770 | |
771 | 771 | |
772 | 772 | </ul> |
@@ -785,26 +785,26 @@ discard block |
||
785 | 785 | */ |
786 | 786 | function geodir_custom_selected_fields() |
787 | 787 | { |
788 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
789 | - ?> |
|
788 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
789 | + ?> |
|
790 | 790 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
791 | 791 | <ul class="core"> |
792 | 792 | <?php |
793 | - global $wpdb; |
|
794 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
795 | - |
|
796 | - if (!empty($fields)) { |
|
797 | - foreach ($fields as $field) { |
|
798 | - //$result_str = $field->id; |
|
799 | - $result_str = $field; |
|
800 | - $field_type = $field->field_type; |
|
801 | - $field_type_key = $field->field_type_key; |
|
802 | - $field_ins_upd = 'display'; |
|
803 | - |
|
804 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
805 | - } |
|
806 | - } |
|
807 | - ?></ul> |
|
793 | + global $wpdb; |
|
794 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
795 | + |
|
796 | + if (!empty($fields)) { |
|
797 | + foreach ($fields as $field) { |
|
798 | + //$result_str = $field->id; |
|
799 | + $result_str = $field; |
|
800 | + $field_type = $field->field_type; |
|
801 | + $field_type_key = $field->field_type_key; |
|
802 | + $field_ins_upd = 'display'; |
|
803 | + |
|
804 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
805 | + } |
|
806 | + } |
|
807 | + ?></ul> |
|
808 | 808 | <?php |
809 | 809 | |
810 | 810 | } |
@@ -823,16 +823,16 @@ discard block |
||
823 | 823 | function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type) |
824 | 824 | { |
825 | 825 | |
826 | - switch ($sub_tab) { |
|
827 | - case 'custom_fields': |
|
828 | - $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
829 | - break; |
|
826 | + switch ($sub_tab) { |
|
827 | + case 'custom_fields': |
|
828 | + $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
829 | + break; |
|
830 | 830 | |
831 | - case 'sorting_options': |
|
832 | - $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
833 | - break; |
|
834 | - } |
|
835 | - return $heading; |
|
831 | + case 'sorting_options': |
|
832 | + $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
833 | + break; |
|
834 | + } |
|
835 | + return $heading; |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | |
@@ -850,16 +850,16 @@ discard block |
||
850 | 850 | function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type) |
851 | 851 | { |
852 | 852 | |
853 | - switch ($sub_tab) { |
|
854 | - case 'custom_fields': |
|
855 | - $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
856 | - break; |
|
853 | + switch ($sub_tab) { |
|
854 | + case 'custom_fields': |
|
855 | + $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
856 | + break; |
|
857 | 857 | |
858 | - case 'sorting_options': |
|
859 | - $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
860 | - break; |
|
861 | - } |
|
862 | - return $heading; |
|
858 | + case 'sorting_options': |
|
859 | + $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
860 | + break; |
|
861 | + } |
|
862 | + return $heading; |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | |
@@ -877,16 +877,16 @@ discard block |
||
877 | 877 | function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type) |
878 | 878 | { |
879 | 879 | |
880 | - switch ($sub_tab) { |
|
881 | - case 'custom_fields': |
|
882 | - $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
883 | - break; |
|
880 | + switch ($sub_tab) { |
|
881 | + case 'custom_fields': |
|
882 | + $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
883 | + break; |
|
884 | 884 | |
885 | - case 'sorting_options': |
|
886 | - $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing page.<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, false, true)); |
|
887 | - break; |
|
888 | - } |
|
889 | - return $note; |
|
885 | + case 'sorting_options': |
|
886 | + $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing page.<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, false, true)); |
|
887 | + break; |
|
888 | + } |
|
889 | + return $note; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
@@ -904,16 +904,16 @@ discard block |
||
904 | 904 | function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type) |
905 | 905 | { |
906 | 906 | |
907 | - switch ($sub_tab) { |
|
908 | - case 'custom_fields': |
|
909 | - $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
910 | - break; |
|
907 | + switch ($sub_tab) { |
|
908 | + case 'custom_fields': |
|
909 | + $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
910 | + break; |
|
911 | 911 | |
912 | - case 'sorting_options': |
|
913 | - $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
914 | - break; |
|
915 | - } |
|
916 | - return $heading; |
|
912 | + case 'sorting_options': |
|
913 | + $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
914 | + break; |
|
915 | + } |
|
916 | + return $heading; |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | |
@@ -931,16 +931,16 @@ discard block |
||
931 | 931 | function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type) |
932 | 932 | { |
933 | 933 | |
934 | - switch ($sub_tab) { |
|
935 | - case 'custom_fields': |
|
936 | - $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, false, true)); |
|
937 | - break; |
|
934 | + switch ($sub_tab) { |
|
935 | + case 'custom_fields': |
|
936 | + $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, false, true)); |
|
937 | + break; |
|
938 | 938 | |
939 | - case 'sorting_options': |
|
940 | - $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 page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
941 | - break; |
|
942 | - } |
|
943 | - return $note; |
|
939 | + case 'sorting_options': |
|
940 | + $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 page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
941 | + break; |
|
942 | + } |
|
943 | + return $note; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | |
@@ -956,16 +956,16 @@ discard block |
||
956 | 956 | */ |
957 | 957 | function geodir_remove_unnecessary_fields() |
958 | 958 | { |
959 | - global $wpdb, $plugin_prefix; |
|
959 | + global $wpdb, $plugin_prefix; |
|
960 | 960 | |
961 | - if (!get_option('geodir_remove_unnecessary_fields')) { |
|
961 | + if (!get_option('geodir_remove_unnecessary_fields')) { |
|
962 | 962 | |
963 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
964 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
963 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
964 | + $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
965 | 965 | |
966 | - update_option('geodir_remove_unnecessary_fields', '1'); |
|
966 | + update_option('geodir_remove_unnecessary_fields', '1'); |
|
967 | 967 | |
968 | - } |
|
968 | + } |
|
969 | 969 | |
970 | 970 | } |
971 | 971 | |
@@ -983,28 +983,28 @@ discard block |
||
983 | 983 | */ |
984 | 984 | function geodir_admin_ajax_handler() |
985 | 985 | { |
986 | - if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') { |
|
987 | - $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
988 | - $diagnose_this = ""; |
|
989 | - switch ($geodir_admin_ajax_action) { |
|
990 | - case 'diagnosis' : |
|
991 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
992 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
993 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
994 | - |
|
995 | - } |
|
996 | - exit(); |
|
997 | - break; |
|
998 | - |
|
999 | - case 'diagnosis-fix' : |
|
1000 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
1001 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
1002 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
1003 | - exit(); |
|
1004 | - break; |
|
1005 | - } |
|
1006 | - } |
|
1007 | - exit(); |
|
986 | + if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') { |
|
987 | + $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
988 | + $diagnose_this = ""; |
|
989 | + switch ($geodir_admin_ajax_action) { |
|
990 | + case 'diagnosis' : |
|
991 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
992 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
993 | + call_user_func('geodir_diagnose_' . $diagnose_this); |
|
994 | + |
|
995 | + } |
|
996 | + exit(); |
|
997 | + break; |
|
998 | + |
|
999 | + case 'diagnosis-fix' : |
|
1000 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
1001 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
1002 | + call_user_func('geodir_diagnose_' . $diagnose_this); |
|
1003 | + exit(); |
|
1004 | + break; |
|
1005 | + } |
|
1006 | + } |
|
1007 | + exit(); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | |
@@ -1022,127 +1022,127 @@ discard block |
||
1022 | 1022 | */ |
1023 | 1023 | function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix) |
1024 | 1024 | { |
1025 | - global $wpdb; |
|
1026 | - //$filter_arr['output_str'] .='###'.$table.'###'; |
|
1027 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) { |
|
1028 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>"; |
|
1029 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1030 | - |
|
1031 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1032 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1033 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1034 | - $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>"; |
|
1035 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1036 | - |
|
1037 | - if ($fix) { |
|
1038 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count |
|
1039 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count |
|
1040 | - |
|
1041 | - if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2 |
|
1042 | - //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ; |
|
1043 | - |
|
1044 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table |
|
1045 | - |
|
1046 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1047 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>"; |
|
1048 | - } else { |
|
1049 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1050 | - } |
|
1051 | - |
|
1052 | - } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it |
|
1053 | - |
|
1054 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2 |
|
1055 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table |
|
1056 | - |
|
1057 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1058 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>"; |
|
1059 | - } else { |
|
1060 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1061 | - } |
|
1062 | - |
|
1063 | - } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors |
|
1064 | - |
|
1065 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2 |
|
1066 | - |
|
1067 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1068 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>"; |
|
1069 | - } else { |
|
1070 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1071 | - } |
|
1072 | - |
|
1073 | - } |
|
1074 | - |
|
1075 | - } |
|
1076 | - |
|
1077 | - |
|
1078 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1079 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1080 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1081 | - |
|
1082 | - if ($fix) { |
|
1083 | - if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it |
|
1084 | - if ($wpdb->query("DROP TABLE IF EXISTS $table")) { |
|
1085 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>"; |
|
1086 | - } else { |
|
1087 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>"; |
|
1088 | - } |
|
1089 | - |
|
1090 | - } 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 |
|
1091 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) { |
|
1092 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1093 | - } else { |
|
1094 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1095 | - } |
|
1096 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1097 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1098 | - } else { |
|
1099 | - $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>"; |
|
1100 | - } |
|
1101 | - } else {// else rename the original table to _ms_bak |
|
1102 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1103 | - $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>"; |
|
1104 | - } else { |
|
1105 | - $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>"; |
|
1106 | - } |
|
1107 | - } |
|
1108 | - } |
|
1109 | - |
|
1110 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1111 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>"; |
|
1112 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1113 | - |
|
1114 | - if ($fix) { |
|
1115 | - // if original table exists but new does not, rename |
|
1116 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1117 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1118 | - } else { |
|
1119 | - $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>"; |
|
1120 | - } |
|
1121 | - |
|
1122 | - } |
|
1123 | - |
|
1124 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1125 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>"; |
|
1126 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1127 | - |
|
1128 | - if ($fix) { |
|
1129 | - // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
1130 | - delete_option('geodirlocation_db_version'); |
|
1131 | - delete_option('geodirevents_db_version'); |
|
1132 | - delete_option('geodir_reviewrating_db_version'); |
|
1133 | - delete_option('gdevents_db_version'); |
|
1134 | - delete_option('geodirectory_db_version'); |
|
1135 | - delete_option('geodirclaim_db_version'); |
|
1136 | - delete_option('geodir_custom_posts_db_version'); |
|
1137 | - delete_option('geodir_reviewratings_db_version'); |
|
1138 | - delete_option('geodiradvancesearch_db_version'); |
|
1139 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>"; |
|
1140 | - } |
|
1141 | - |
|
1142 | - } else { |
|
1143 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>"; |
|
1144 | - } |
|
1145 | - return $filter_arr; |
|
1025 | + global $wpdb; |
|
1026 | + //$filter_arr['output_str'] .='###'.$table.'###'; |
|
1027 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) { |
|
1028 | + $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>"; |
|
1029 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1030 | + |
|
1031 | + } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1032 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1033 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1034 | + $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>"; |
|
1035 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1036 | + |
|
1037 | + if ($fix) { |
|
1038 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count |
|
1039 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count |
|
1040 | + |
|
1041 | + if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2 |
|
1042 | + //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ; |
|
1043 | + |
|
1044 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table |
|
1045 | + |
|
1046 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1047 | + $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>"; |
|
1048 | + } else { |
|
1049 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1050 | + } |
|
1051 | + |
|
1052 | + } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it |
|
1053 | + |
|
1054 | + $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2 |
|
1055 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table |
|
1056 | + |
|
1057 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1058 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>"; |
|
1059 | + } else { |
|
1060 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1061 | + } |
|
1062 | + |
|
1063 | + } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors |
|
1064 | + |
|
1065 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2 |
|
1066 | + |
|
1067 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1068 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>"; |
|
1069 | + } else { |
|
1070 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1071 | + } |
|
1072 | + |
|
1073 | + } |
|
1074 | + |
|
1075 | + } |
|
1076 | + |
|
1077 | + |
|
1078 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1079 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1080 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1081 | + |
|
1082 | + if ($fix) { |
|
1083 | + if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it |
|
1084 | + if ($wpdb->query("DROP TABLE IF EXISTS $table")) { |
|
1085 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>"; |
|
1086 | + } else { |
|
1087 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>"; |
|
1088 | + } |
|
1089 | + |
|
1090 | + } 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 |
|
1091 | + if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) { |
|
1092 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1093 | + } else { |
|
1094 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1095 | + } |
|
1096 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1097 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1098 | + } else { |
|
1099 | + $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>"; |
|
1100 | + } |
|
1101 | + } else {// else rename the original table to _ms_bak |
|
1102 | + if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1103 | + $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>"; |
|
1104 | + } else { |
|
1105 | + $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>"; |
|
1106 | + } |
|
1107 | + } |
|
1108 | + } |
|
1109 | + |
|
1110 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1111 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>"; |
|
1112 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1113 | + |
|
1114 | + if ($fix) { |
|
1115 | + // if original table exists but new does not, rename |
|
1116 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1117 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1118 | + } else { |
|
1119 | + $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>"; |
|
1120 | + } |
|
1121 | + |
|
1122 | + } |
|
1123 | + |
|
1124 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1125 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>"; |
|
1126 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1127 | + |
|
1128 | + if ($fix) { |
|
1129 | + // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
1130 | + delete_option('geodirlocation_db_version'); |
|
1131 | + delete_option('geodirevents_db_version'); |
|
1132 | + delete_option('geodir_reviewrating_db_version'); |
|
1133 | + delete_option('gdevents_db_version'); |
|
1134 | + delete_option('geodirectory_db_version'); |
|
1135 | + delete_option('geodirclaim_db_version'); |
|
1136 | + delete_option('geodir_custom_posts_db_version'); |
|
1137 | + delete_option('geodir_reviewratings_db_version'); |
|
1138 | + delete_option('geodiradvancesearch_db_version'); |
|
1139 | + $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>"; |
|
1140 | + } |
|
1141 | + |
|
1142 | + } else { |
|
1143 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>"; |
|
1144 | + } |
|
1145 | + return $filter_arr; |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | |
@@ -1156,111 +1156,111 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | function geodir_diagnose_tags_sync() |
1158 | 1158 | { |
1159 | - global $wpdb, $plugin_prefix; |
|
1160 | - $fix = isset($_POST['fix']) ? true : false; |
|
1161 | - $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0; |
|
1162 | - $step_max_items = geodir_get_diagnose_step_max_items(); |
|
1163 | - $offset = (int) $step * $step_max_items; |
|
1164 | - $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false; |
|
1165 | - |
|
1166 | - $total_listings = geodir_total_listings_count(); |
|
1167 | - $total_ptype_listings = 0; |
|
1168 | - if ($ptype) { |
|
1169 | - $total_ptype_listings = geodir_total_listings_count($ptype); |
|
1170 | - } |
|
1171 | - $max_step = ceil($total_ptype_listings / $step_max_items) - 1; |
|
1159 | + global $wpdb, $plugin_prefix; |
|
1160 | + $fix = isset($_POST['fix']) ? true : false; |
|
1161 | + $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0; |
|
1162 | + $step_max_items = geodir_get_diagnose_step_max_items(); |
|
1163 | + $offset = (int) $step * $step_max_items; |
|
1164 | + $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false; |
|
1165 | + |
|
1166 | + $total_listings = geodir_total_listings_count(); |
|
1167 | + $total_ptype_listings = 0; |
|
1168 | + if ($ptype) { |
|
1169 | + $total_ptype_listings = geodir_total_listings_count($ptype); |
|
1170 | + } |
|
1171 | + $max_step = ceil($total_ptype_listings / $step_max_items) - 1; |
|
1172 | 1172 | |
1173 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1174 | - $is_error_during_diagnose = false; |
|
1175 | - $output_str = ''; |
|
1173 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1174 | + $is_error_during_diagnose = false; |
|
1175 | + $output_str = ''; |
|
1176 | 1176 | |
1177 | - if ($ptype && !empty($ptype) && $total_listings > $step_max_items) { |
|
1178 | - $stepped_process = true; |
|
1179 | - } else { |
|
1180 | - $stepped_process = false; |
|
1181 | - } |
|
1182 | - |
|
1183 | - if ($stepped_process) { |
|
1184 | - $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset ); |
|
1185 | - $posts = $wpdb->get_results( $sql ); |
|
1186 | - |
|
1187 | - if (!empty($posts)) { |
|
1188 | - |
|
1189 | - foreach ($posts as $p) { |
|
1190 | - $p->post_type = $ptype; |
|
1191 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1192 | - if (empty($raw_tags)) { |
|
1193 | - $post_tags = ''; |
|
1194 | - } else { |
|
1195 | - $post_tags = implode(",", $raw_tags); |
|
1196 | - } |
|
1197 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1198 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1199 | - |
|
1200 | - } |
|
1201 | - if ($step >= $max_step) { |
|
1202 | - $output_str = "done"; |
|
1203 | - } else { |
|
1204 | - $output_str = $step + 1; |
|
1205 | - } |
|
1206 | - } |
|
1207 | - |
|
1208 | - } else { |
|
1209 | - $all_postypes = geodir_get_posttypes(); |
|
1210 | - |
|
1211 | - if (!empty($all_postypes)) { |
|
1212 | - foreach ($all_postypes as $key) { |
|
1213 | - // update each GD CPT |
|
1214 | - $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1215 | - |
|
1216 | - if (!empty($posts)) { |
|
1217 | - |
|
1218 | - foreach ($posts as $p) { |
|
1219 | - $p->post_type = $key; |
|
1220 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1221 | - if (empty($raw_tags)) { |
|
1222 | - $post_tags = ''; |
|
1223 | - } else { |
|
1224 | - $post_tags = implode(",", $raw_tags); |
|
1225 | - } |
|
1226 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1227 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1228 | - |
|
1229 | - } |
|
1230 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1231 | - } |
|
1232 | - |
|
1233 | - } |
|
1234 | - |
|
1235 | - } |
|
1236 | - } |
|
1237 | - |
|
1238 | - |
|
1239 | - if ($is_error_during_diagnose) { |
|
1240 | - $info_div_class = "geodir_problem_info"; |
|
1241 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1242 | - } else { |
|
1243 | - $info_div_class = "geodir_noproblem_info"; |
|
1244 | - $fix_button_txt = ''; |
|
1245 | - } |
|
1246 | - |
|
1247 | - if ($stepped_process) { |
|
1248 | - $percent = ($step/$max_step) * 100; |
|
1249 | - if ($output_str == 'done') { |
|
1250 | - echo $output_str; |
|
1251 | - } else { |
|
1252 | - $output = array( |
|
1253 | - 'step' => $output_str, |
|
1254 | - 'percent' => $percent |
|
1255 | - ); |
|
1256 | - echo json_encode($output); |
|
1257 | - } |
|
1258 | - } else { |
|
1259 | - echo "<ul class='$info_div_class'>"; |
|
1260 | - echo $output_str; |
|
1261 | - echo $fix_button_txt; |
|
1262 | - echo "</ul>"; |
|
1263 | - } |
|
1177 | + if ($ptype && !empty($ptype) && $total_listings > $step_max_items) { |
|
1178 | + $stepped_process = true; |
|
1179 | + } else { |
|
1180 | + $stepped_process = false; |
|
1181 | + } |
|
1182 | + |
|
1183 | + if ($stepped_process) { |
|
1184 | + $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset ); |
|
1185 | + $posts = $wpdb->get_results( $sql ); |
|
1186 | + |
|
1187 | + if (!empty($posts)) { |
|
1188 | + |
|
1189 | + foreach ($posts as $p) { |
|
1190 | + $p->post_type = $ptype; |
|
1191 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1192 | + if (empty($raw_tags)) { |
|
1193 | + $post_tags = ''; |
|
1194 | + } else { |
|
1195 | + $post_tags = implode(",", $raw_tags); |
|
1196 | + } |
|
1197 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1198 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1199 | + |
|
1200 | + } |
|
1201 | + if ($step >= $max_step) { |
|
1202 | + $output_str = "done"; |
|
1203 | + } else { |
|
1204 | + $output_str = $step + 1; |
|
1205 | + } |
|
1206 | + } |
|
1207 | + |
|
1208 | + } else { |
|
1209 | + $all_postypes = geodir_get_posttypes(); |
|
1210 | + |
|
1211 | + if (!empty($all_postypes)) { |
|
1212 | + foreach ($all_postypes as $key) { |
|
1213 | + // update each GD CPT |
|
1214 | + $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1215 | + |
|
1216 | + if (!empty($posts)) { |
|
1217 | + |
|
1218 | + foreach ($posts as $p) { |
|
1219 | + $p->post_type = $key; |
|
1220 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1221 | + if (empty($raw_tags)) { |
|
1222 | + $post_tags = ''; |
|
1223 | + } else { |
|
1224 | + $post_tags = implode(",", $raw_tags); |
|
1225 | + } |
|
1226 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1227 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1228 | + |
|
1229 | + } |
|
1230 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1231 | + } |
|
1232 | + |
|
1233 | + } |
|
1234 | + |
|
1235 | + } |
|
1236 | + } |
|
1237 | + |
|
1238 | + |
|
1239 | + if ($is_error_during_diagnose) { |
|
1240 | + $info_div_class = "geodir_problem_info"; |
|
1241 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1242 | + } else { |
|
1243 | + $info_div_class = "geodir_noproblem_info"; |
|
1244 | + $fix_button_txt = ''; |
|
1245 | + } |
|
1246 | + |
|
1247 | + if ($stepped_process) { |
|
1248 | + $percent = ($step/$max_step) * 100; |
|
1249 | + if ($output_str == 'done') { |
|
1250 | + echo $output_str; |
|
1251 | + } else { |
|
1252 | + $output = array( |
|
1253 | + 'step' => $output_str, |
|
1254 | + 'percent' => $percent |
|
1255 | + ); |
|
1256 | + echo json_encode($output); |
|
1257 | + } |
|
1258 | + } else { |
|
1259 | + echo "<ul class='$info_div_class'>"; |
|
1260 | + echo $output_str; |
|
1261 | + echo $fix_button_txt; |
|
1262 | + echo "</ul>"; |
|
1263 | + } |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | /** |
@@ -1275,75 +1275,75 @@ discard block |
||
1275 | 1275 | */ |
1276 | 1276 | function geodir_diagnose_cats_sync() |
1277 | 1277 | { |
1278 | - global $wpdb, $plugin_prefix; |
|
1279 | - $fix = isset($_POST['fix']) ? true : false; |
|
1278 | + global $wpdb, $plugin_prefix; |
|
1279 | + $fix = isset($_POST['fix']) ? true : false; |
|
1280 | 1280 | |
1281 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1282 | - $is_error_during_diagnose = false; |
|
1283 | - $output_str = ''; |
|
1281 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1282 | + $is_error_during_diagnose = false; |
|
1283 | + $output_str = ''; |
|
1284 | 1284 | |
1285 | 1285 | |
1286 | - $all_postypes = geodir_get_posttypes(); |
|
1286 | + $all_postypes = geodir_get_posttypes(); |
|
1287 | 1287 | |
1288 | - if (!empty($all_postypes)) { |
|
1289 | - foreach ($all_postypes as $key) { |
|
1290 | - // update each GD CTP |
|
1291 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' "); |
|
1288 | + if (!empty($all_postypes)) { |
|
1289 | + foreach ($all_postypes as $key) { |
|
1290 | + // update each GD CTP |
|
1291 | + $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' "); |
|
1292 | 1292 | |
1293 | - if (!empty($posts)) { |
|
1293 | + if (!empty($posts)) { |
|
1294 | 1294 | |
1295 | - foreach ($posts as $p) { |
|
1296 | - $p->post_type = $key; |
|
1297 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids')); |
|
1295 | + foreach ($posts as $p) { |
|
1296 | + $p->post_type = $key; |
|
1297 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids')); |
|
1298 | 1298 | |
1299 | - if (empty($raw_cats)) { |
|
1300 | - $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
1299 | + if (empty($raw_cats)) { |
|
1300 | + $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
1301 | 1301 | |
1302 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) { |
|
1303 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']); |
|
1304 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) { |
|
1305 | - if (is_numeric($cat_part)) { |
|
1306 | - $raw_cats[] = (int)$cat_part; |
|
1307 | - } |
|
1308 | - } |
|
1302 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) { |
|
1303 | + $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']); |
|
1304 | + foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) { |
|
1305 | + if (is_numeric($cat_part)) { |
|
1306 | + $raw_cats[] = (int)$cat_part; |
|
1307 | + } |
|
1308 | + } |
|
1309 | 1309 | |
1310 | - } |
|
1310 | + } |
|
1311 | 1311 | |
1312 | - if (!empty($raw_cats)) { |
|
1313 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
1312 | + if (!empty($raw_cats)) { |
|
1313 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
1314 | 1314 | |
1315 | - } |
|
1315 | + } |
|
1316 | 1316 | |
1317 | - } |
|
1317 | + } |
|
1318 | 1318 | |
1319 | 1319 | |
1320 | - if (empty($raw_cats)) { |
|
1321 | - $post_cats = ''; |
|
1322 | - } else { |
|
1323 | - $post_cats = ',' . implode(",", $raw_cats) . ','; |
|
1324 | - } |
|
1325 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1326 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1327 | - } |
|
1320 | + if (empty($raw_cats)) { |
|
1321 | + $post_cats = ''; |
|
1322 | + } else { |
|
1323 | + $post_cats = ',' . implode(",", $raw_cats) . ','; |
|
1324 | + } |
|
1325 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1326 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1327 | + } |
|
1328 | 1328 | |
1329 | - } |
|
1330 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1329 | + } |
|
1330 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1331 | 1331 | |
1332 | - } |
|
1332 | + } |
|
1333 | 1333 | |
1334 | - } |
|
1334 | + } |
|
1335 | 1335 | |
1336 | - if ($is_error_during_diagnose) { |
|
1337 | - $info_div_class = "geodir_problem_info"; |
|
1338 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1339 | - } else { |
|
1340 | - $info_div_class = "geodir_noproblem_info"; |
|
1341 | - $fix_button_txt = ''; |
|
1342 | - } |
|
1343 | - echo "<ul class='$info_div_class'>"; |
|
1344 | - echo $output_str; |
|
1345 | - echo $fix_button_txt; |
|
1346 | - echo "</ul>"; |
|
1336 | + if ($is_error_during_diagnose) { |
|
1337 | + $info_div_class = "geodir_problem_info"; |
|
1338 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1339 | + } else { |
|
1340 | + $info_div_class = "geodir_noproblem_info"; |
|
1341 | + $fix_button_txt = ''; |
|
1342 | + } |
|
1343 | + echo "<ul class='$info_div_class'>"; |
|
1344 | + echo $output_str; |
|
1345 | + echo $fix_button_txt; |
|
1346 | + echo "</ul>"; |
|
1347 | 1347 | |
1348 | 1348 | } |
1349 | 1349 | |
@@ -1357,61 +1357,61 @@ discard block |
||
1357 | 1357 | */ |
1358 | 1358 | function geodir_diagnose_version_clear() |
1359 | 1359 | { |
1360 | - global $wpdb, $plugin_prefix; |
|
1361 | - $fix = isset($_POST['fix']) ? true : false; |
|
1362 | - |
|
1363 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1364 | - $is_error_during_diagnose = false; |
|
1365 | - $output_str = ''; |
|
1366 | - |
|
1367 | - |
|
1368 | - $gd_arr = array('GeoDirectory' => 'geodirectory_db_version', |
|
1369 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
1370 | - 'GeoDirectory Framework' => 'gdf_db_version', |
|
1371 | - 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
1372 | - 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
1373 | - 'Claim Manager' => 'geodirclaim_db_version', |
|
1374 | - 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
1375 | - 'Location Manager' => 'geodirlocation_db_version', |
|
1376 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
1377 | - 'Events Manager' => 'geodirevents_db_version', |
|
1378 | - ); |
|
1379 | - |
|
1380 | - /** |
|
1381 | - * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
1382 | - * |
|
1383 | - * @since 1.0.0 |
|
1384 | - * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',... |
|
1385 | - */ |
|
1386 | - $ver_arr = apply_filters('geodir_db_version_name', $gd_arr); |
|
1387 | - |
|
1388 | - if (!empty($ver_arr)) { |
|
1389 | - foreach ($ver_arr as $key => $val) { |
|
1390 | - if (delete_option($val)) { |
|
1391 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>"; |
|
1392 | - } else { |
|
1393 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>"; |
|
1394 | - } |
|
1395 | - |
|
1396 | - } |
|
1397 | - |
|
1398 | - if ($output_str) { |
|
1399 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>"; |
|
1400 | - } |
|
1401 | - |
|
1402 | - } |
|
1403 | - |
|
1404 | - if ($is_error_during_diagnose) { |
|
1405 | - $info_div_class = "geodir_problem_info"; |
|
1406 | - $fix_button_txt = ""; |
|
1407 | - } else { |
|
1408 | - $info_div_class = "geodir_noproblem_info"; |
|
1409 | - $fix_button_txt = ''; |
|
1410 | - } |
|
1411 | - echo "<ul class='$info_div_class'>"; |
|
1412 | - echo $output_str; |
|
1413 | - echo $fix_button_txt; |
|
1414 | - echo "</ul>"; |
|
1360 | + global $wpdb, $plugin_prefix; |
|
1361 | + $fix = isset($_POST['fix']) ? true : false; |
|
1362 | + |
|
1363 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1364 | + $is_error_during_diagnose = false; |
|
1365 | + $output_str = ''; |
|
1366 | + |
|
1367 | + |
|
1368 | + $gd_arr = array('GeoDirectory' => 'geodirectory_db_version', |
|
1369 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
1370 | + 'GeoDirectory Framework' => 'gdf_db_version', |
|
1371 | + 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
1372 | + 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
1373 | + 'Claim Manager' => 'geodirclaim_db_version', |
|
1374 | + 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
1375 | + 'Location Manager' => 'geodirlocation_db_version', |
|
1376 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
1377 | + 'Events Manager' => 'geodirevents_db_version', |
|
1378 | + ); |
|
1379 | + |
|
1380 | + /** |
|
1381 | + * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
1382 | + * |
|
1383 | + * @since 1.0.0 |
|
1384 | + * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',... |
|
1385 | + */ |
|
1386 | + $ver_arr = apply_filters('geodir_db_version_name', $gd_arr); |
|
1387 | + |
|
1388 | + if (!empty($ver_arr)) { |
|
1389 | + foreach ($ver_arr as $key => $val) { |
|
1390 | + if (delete_option($val)) { |
|
1391 | + $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>"; |
|
1392 | + } else { |
|
1393 | + $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>"; |
|
1394 | + } |
|
1395 | + |
|
1396 | + } |
|
1397 | + |
|
1398 | + if ($output_str) { |
|
1399 | + $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>"; |
|
1400 | + } |
|
1401 | + |
|
1402 | + } |
|
1403 | + |
|
1404 | + if ($is_error_during_diagnose) { |
|
1405 | + $info_div_class = "geodir_problem_info"; |
|
1406 | + $fix_button_txt = ""; |
|
1407 | + } else { |
|
1408 | + $info_div_class = "geodir_noproblem_info"; |
|
1409 | + $fix_button_txt = ''; |
|
1410 | + } |
|
1411 | + echo "<ul class='$info_div_class'>"; |
|
1412 | + echo $output_str; |
|
1413 | + echo $fix_button_txt; |
|
1414 | + echo "</ul>"; |
|
1415 | 1415 | |
1416 | 1416 | } |
1417 | 1417 | |
@@ -1425,12 +1425,12 @@ discard block |
||
1425 | 1425 | */ |
1426 | 1426 | function geodir_diagnose_ratings() |
1427 | 1427 | { |
1428 | - global $wpdb; |
|
1429 | - $fix = isset($_POST['fix']) ? true : false; |
|
1428 | + global $wpdb; |
|
1429 | + $fix = isset($_POST['fix']) ? true : false; |
|
1430 | 1430 | |
1431 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1432 | - $is_error_during_diagnose = false; |
|
1433 | - $output_str = ''; |
|
1431 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1432 | + $is_error_during_diagnose = false; |
|
1433 | + $output_str = ''; |
|
1434 | 1434 | |
1435 | 1435 | $gd_post_types = geodir_get_posttypes(); |
1436 | 1436 | |
@@ -1446,52 +1446,52 @@ discard block |
||
1446 | 1446 | } |
1447 | 1447 | $skip_post_types_where = ! empty( $skip_post_types ) ? " AND post_type NOT IN( '" . implode( "','", $skip_post_types ) . "' )" : ''; |
1448 | 1448 | |
1449 | - // check review locations |
|
1450 | - if ($wpdb->get_var("SELECT COUNT(*) FROM " . GEODIR_REVIEW_TABLE . " WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) { |
|
1451 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; |
|
1452 | - $is_error_during_diagnose = true; |
|
1453 | - |
|
1454 | - if ($fix) { |
|
1455 | - if (geodir_fix_review_location()) { |
|
1456 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; |
|
1457 | - } else { |
|
1458 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; |
|
1459 | - } |
|
1460 | - } |
|
1461 | - |
|
1462 | - } else { |
|
1463 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; |
|
1464 | - } |
|
1465 | - |
|
1466 | - // check review content |
|
1467 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { |
|
1468 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; |
|
1469 | - $is_error_during_diagnose = true; |
|
1470 | - |
|
1471 | - if ($fix) { |
|
1472 | - if (geodir_fix_review_content()) { |
|
1473 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; |
|
1474 | - } else { |
|
1475 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; |
|
1476 | - } |
|
1477 | - } |
|
1478 | - |
|
1479 | - } else { |
|
1480 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; |
|
1481 | - } |
|
1482 | - |
|
1483 | - |
|
1484 | - if ($is_error_during_diagnose) { |
|
1485 | - $info_div_class = "geodir_problem_info"; |
|
1486 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1487 | - } else { |
|
1488 | - $info_div_class = "geodir_noproblem_info"; |
|
1489 | - $fix_button_txt = ''; |
|
1490 | - } |
|
1491 | - echo "<ul class='$info_div_class'>"; |
|
1492 | - echo $output_str; |
|
1493 | - echo $fix_button_txt; |
|
1494 | - echo "</ul>"; |
|
1449 | + // check review locations |
|
1450 | + if ($wpdb->get_var("SELECT COUNT(*) FROM " . GEODIR_REVIEW_TABLE . " WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) { |
|
1451 | + $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; |
|
1452 | + $is_error_during_diagnose = true; |
|
1453 | + |
|
1454 | + if ($fix) { |
|
1455 | + if (geodir_fix_review_location()) { |
|
1456 | + $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; |
|
1457 | + } else { |
|
1458 | + $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; |
|
1459 | + } |
|
1460 | + } |
|
1461 | + |
|
1462 | + } else { |
|
1463 | + $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; |
|
1464 | + } |
|
1465 | + |
|
1466 | + // check review content |
|
1467 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { |
|
1468 | + $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; |
|
1469 | + $is_error_during_diagnose = true; |
|
1470 | + |
|
1471 | + if ($fix) { |
|
1472 | + if (geodir_fix_review_content()) { |
|
1473 | + $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; |
|
1474 | + } else { |
|
1475 | + $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; |
|
1476 | + } |
|
1477 | + } |
|
1478 | + |
|
1479 | + } else { |
|
1480 | + $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; |
|
1481 | + } |
|
1482 | + |
|
1483 | + |
|
1484 | + if ($is_error_during_diagnose) { |
|
1485 | + $info_div_class = "geodir_problem_info"; |
|
1486 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1487 | + } else { |
|
1488 | + $info_div_class = "geodir_noproblem_info"; |
|
1489 | + $fix_button_txt = ''; |
|
1490 | + } |
|
1491 | + echo "<ul class='$info_div_class'>"; |
|
1492 | + echo $output_str; |
|
1493 | + echo $fix_button_txt; |
|
1494 | + echo "</ul>"; |
|
1495 | 1495 | |
1496 | 1496 | } |
1497 | 1497 | |
@@ -1505,57 +1505,57 @@ discard block |
||
1505 | 1505 | */ |
1506 | 1506 | function geodir_diagnose_multisite_conversion() |
1507 | 1507 | { |
1508 | - global $wpdb; |
|
1509 | - $fix = isset($_POST['fix']) ? true : false; |
|
1510 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1511 | - $is_error_during_diagnose = false; |
|
1512 | - $output_str = ''; |
|
1513 | - |
|
1514 | - $filter_arr = array(); |
|
1515 | - $filter_arr['output_str'] = $output_str; |
|
1516 | - $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
1517 | - $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'), |
|
1518 | - 'geodir_custom_fields' => __('Custom fields', 'geodirectory'), |
|
1519 | - 'geodir_post_icon' => __('Post icon', 'geodirectory'), |
|
1520 | - 'geodir_attachments' => __('Attachments', 'geodirectory'), |
|
1521 | - 'geodir_post_review' => __('Reviews', 'geodirectory'), |
|
1522 | - 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'), |
|
1523 | - 'geodir_gd_place_detail' => __('Place detail', 'geodirectory') |
|
1524 | - ); |
|
1525 | - |
|
1526 | - // allow other addons to hook in and add their checks |
|
1527 | - |
|
1528 | - /** |
|
1529 | - * Filter the array of tables. |
|
1530 | - * |
|
1531 | - * 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. |
|
1532 | - * |
|
1533 | - * @since 1.0.0 |
|
1534 | - * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),... |
|
1535 | - */ |
|
1536 | - $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr); |
|
1537 | - |
|
1538 | - foreach ($table_arr as $table => $table_name) { |
|
1539 | - // Diagnose table |
|
1540 | - $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
1541 | - } |
|
1542 | - |
|
1543 | - |
|
1544 | - $output_str = $filter_arr['output_str']; |
|
1545 | - $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
1546 | - |
|
1547 | - |
|
1548 | - if ($is_error_during_diagnose) { |
|
1549 | - $info_div_class = "geodir_problem_info"; |
|
1550 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1551 | - } else { |
|
1552 | - $info_div_class = "geodir_noproblem_info"; |
|
1553 | - $fix_button_txt = ''; |
|
1554 | - } |
|
1555 | - echo "<ul class='$info_div_class'>"; |
|
1556 | - echo $output_str; |
|
1557 | - echo $fix_button_txt; |
|
1558 | - echo "</ul>"; |
|
1508 | + global $wpdb; |
|
1509 | + $fix = isset($_POST['fix']) ? true : false; |
|
1510 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1511 | + $is_error_during_diagnose = false; |
|
1512 | + $output_str = ''; |
|
1513 | + |
|
1514 | + $filter_arr = array(); |
|
1515 | + $filter_arr['output_str'] = $output_str; |
|
1516 | + $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
1517 | + $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'), |
|
1518 | + 'geodir_custom_fields' => __('Custom fields', 'geodirectory'), |
|
1519 | + 'geodir_post_icon' => __('Post icon', 'geodirectory'), |
|
1520 | + 'geodir_attachments' => __('Attachments', 'geodirectory'), |
|
1521 | + 'geodir_post_review' => __('Reviews', 'geodirectory'), |
|
1522 | + 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'), |
|
1523 | + 'geodir_gd_place_detail' => __('Place detail', 'geodirectory') |
|
1524 | + ); |
|
1525 | + |
|
1526 | + // allow other addons to hook in and add their checks |
|
1527 | + |
|
1528 | + /** |
|
1529 | + * Filter the array of tables. |
|
1530 | + * |
|
1531 | + * 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. |
|
1532 | + * |
|
1533 | + * @since 1.0.0 |
|
1534 | + * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),... |
|
1535 | + */ |
|
1536 | + $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr); |
|
1537 | + |
|
1538 | + foreach ($table_arr as $table => $table_name) { |
|
1539 | + // Diagnose table |
|
1540 | + $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
1541 | + } |
|
1542 | + |
|
1543 | + |
|
1544 | + $output_str = $filter_arr['output_str']; |
|
1545 | + $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
1546 | + |
|
1547 | + |
|
1548 | + if ($is_error_during_diagnose) { |
|
1549 | + $info_div_class = "geodir_problem_info"; |
|
1550 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1551 | + } else { |
|
1552 | + $info_div_class = "geodir_noproblem_info"; |
|
1553 | + $fix_button_txt = ''; |
|
1554 | + } |
|
1555 | + echo "<ul class='$info_div_class'>"; |
|
1556 | + echo $output_str; |
|
1557 | + echo $fix_button_txt; |
|
1558 | + echo "</ul>"; |
|
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | /** |
@@ -1573,39 +1573,39 @@ discard block |
||
1573 | 1573 | */ |
1574 | 1574 | function geodir_fix_virtual_page($slug, $page_title, $old_id, $option) |
1575 | 1575 | { |
1576 | - global $wpdb, $current_user; |
|
1577 | - |
|
1578 | - if (!empty($old_id)) { |
|
1579 | - wp_delete_post($old_id, true); |
|
1580 | - }//delete post if already there |
|
1581 | - else { |
|
1582 | - $page_found = $wpdb->get_var( |
|
1583 | - $wpdb->prepare( |
|
1584 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
1585 | - array($slug) |
|
1586 | - ) |
|
1587 | - ); |
|
1588 | - wp_delete_post($page_found, true); |
|
1589 | - |
|
1590 | - } |
|
1591 | - |
|
1592 | - $page_data = array( |
|
1593 | - 'post_status' => 'publish', |
|
1594 | - 'post_type' => 'page', |
|
1595 | - 'post_author' => $current_user->ID, |
|
1596 | - 'post_name' => $slug, |
|
1597 | - 'post_title' => $page_title, |
|
1598 | - 'post_content' => '', |
|
1599 | - 'post_parent' => 0, |
|
1600 | - 'comment_status' => 'closed' |
|
1601 | - ); |
|
1602 | - $page_id = wp_insert_post($page_data); |
|
1603 | - update_option($option, $page_id); |
|
1604 | - if ($page_id) { |
|
1605 | - return true; |
|
1606 | - } else { |
|
1607 | - return false; |
|
1608 | - } |
|
1576 | + global $wpdb, $current_user; |
|
1577 | + |
|
1578 | + if (!empty($old_id)) { |
|
1579 | + wp_delete_post($old_id, true); |
|
1580 | + }//delete post if already there |
|
1581 | + else { |
|
1582 | + $page_found = $wpdb->get_var( |
|
1583 | + $wpdb->prepare( |
|
1584 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
1585 | + array($slug) |
|
1586 | + ) |
|
1587 | + ); |
|
1588 | + wp_delete_post($page_found, true); |
|
1589 | + |
|
1590 | + } |
|
1591 | + |
|
1592 | + $page_data = array( |
|
1593 | + 'post_status' => 'publish', |
|
1594 | + 'post_type' => 'page', |
|
1595 | + 'post_author' => $current_user->ID, |
|
1596 | + 'post_name' => $slug, |
|
1597 | + 'post_title' => $page_title, |
|
1598 | + 'post_content' => '', |
|
1599 | + 'post_parent' => 0, |
|
1600 | + 'comment_status' => 'closed' |
|
1601 | + ); |
|
1602 | + $page_id = wp_insert_post($page_data); |
|
1603 | + update_option($option, $page_id); |
|
1604 | + if ($page_id) { |
|
1605 | + return true; |
|
1606 | + } else { |
|
1607 | + return false; |
|
1608 | + } |
|
1609 | 1609 | } |
1610 | 1610 | |
1611 | 1611 | /** |
@@ -1617,212 +1617,212 @@ discard block |
||
1617 | 1617 | */ |
1618 | 1618 | function geodir_diagnose_default_pages() |
1619 | 1619 | { |
1620 | - global $wpdb; |
|
1621 | - $is_error_during_diagnose = false; |
|
1622 | - $output_str = ''; |
|
1623 | - $fix = isset($_POST['fix']) ? true : false; |
|
1624 | - |
|
1625 | - ////////////////////////////////// |
|
1626 | - /* Diagnose GD Home Page Starts */ |
|
1627 | - ////////////////////////////////// |
|
1628 | - $option_value = get_option('geodir_home_page'); |
|
1629 | - $page = get_post($option_value); |
|
1630 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1631 | - |
|
1632 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1633 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1634 | - else { |
|
1635 | - $is_error_during_diagnose = true; |
|
1636 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
|
1637 | - if ($fix) { |
|
1638 | - if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { |
|
1639 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; |
|
1640 | - } else { |
|
1641 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; |
|
1642 | - } |
|
1643 | - } |
|
1644 | - } |
|
1645 | - |
|
1646 | - //////////////////////////////// |
|
1647 | - /* Diagnose GD Home Page Ends */ |
|
1648 | - //////////////////////////////// |
|
1649 | - |
|
1650 | - ////////////////////////////////// |
|
1651 | - /* Diagnose Add Listing Page Starts */ |
|
1652 | - ////////////////////////////////// |
|
1653 | - $option_value = get_option('geodir_add_listing_page'); |
|
1654 | - $page = get_post($option_value); |
|
1655 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1656 | - |
|
1657 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1658 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1659 | - else { |
|
1660 | - $is_error_during_diagnose = true; |
|
1661 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
|
1662 | - if ($fix) { |
|
1663 | - if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { |
|
1664 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; |
|
1665 | - } else { |
|
1666 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; |
|
1667 | - } |
|
1668 | - } |
|
1669 | - } |
|
1670 | - |
|
1671 | - //////////////////////////////// |
|
1672 | - /* Diagnose Add Listing Page Ends */ |
|
1673 | - //////////////////////////////// |
|
1674 | - |
|
1675 | - |
|
1676 | - ////////////////////////////////// |
|
1677 | - /* Diagnose Listing Preview Page Starts */ |
|
1678 | - ////////////////////////////////// |
|
1679 | - $option_value = get_option('geodir_preview_page'); |
|
1680 | - $page = get_post($option_value); |
|
1681 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1682 | - |
|
1683 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1684 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1685 | - else { |
|
1686 | - $is_error_during_diagnose = true; |
|
1687 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
|
1688 | - if ($fix) { |
|
1689 | - if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { |
|
1690 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; |
|
1691 | - } else { |
|
1692 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; |
|
1693 | - } |
|
1694 | - } |
|
1695 | - } |
|
1696 | - |
|
1697 | - //////////////////////////////// |
|
1698 | - /* Diagnose Listing Preview Page Ends */ |
|
1699 | - //////////////////////////////// |
|
1700 | - |
|
1701 | - ////////////////////////////////// |
|
1702 | - /* Diagnose Listing Success Page Starts */ |
|
1703 | - ////////////////////////////////// |
|
1704 | - $option_value = get_option('geodir_success_page'); |
|
1705 | - $page = get_post($option_value); |
|
1706 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1707 | - |
|
1708 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1709 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1710 | - else { |
|
1711 | - $is_error_during_diagnose = true; |
|
1712 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
|
1713 | - if ($fix) { |
|
1714 | - if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { |
|
1715 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; |
|
1716 | - } else { |
|
1717 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; |
|
1718 | - } |
|
1719 | - } |
|
1720 | - } |
|
1721 | - |
|
1722 | - //////////////////////////////// |
|
1723 | - /* Diagnose Listing Sucess Page Ends */ |
|
1724 | - //////////////////////////////// |
|
1725 | - |
|
1726 | - ////////////////////////////////// |
|
1727 | - /* Diagnose Info Page Starts */ |
|
1728 | - ////////////////////////////////// |
|
1729 | - $option_value = get_option('geodir_info_page'); |
|
1730 | - $page = get_post($option_value); |
|
1731 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1732 | - |
|
1733 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1734 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1735 | - else { |
|
1736 | - $is_error_during_diagnose = true; |
|
1737 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
|
1738 | - if ($fix) { |
|
1739 | - if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { |
|
1740 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; |
|
1741 | - } else { |
|
1742 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; |
|
1743 | - } |
|
1744 | - } |
|
1745 | - } |
|
1746 | - |
|
1747 | - //////////////////////////////// |
|
1748 | - /* Diagnose Info Page Ends */ |
|
1749 | - //////////////////////////////// |
|
1750 | - |
|
1751 | - ////////////////////////////////// |
|
1752 | - /* Diagnose Login Page Starts */ |
|
1753 | - ////////////////////////////////// |
|
1754 | - $option_value = get_option('geodir_login_page'); |
|
1755 | - $page = get_post($option_value); |
|
1756 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1757 | - |
|
1758 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1759 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1760 | - else { |
|
1761 | - $is_error_during_diagnose = true; |
|
1762 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
|
1763 | - if ($fix) { |
|
1764 | - if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { |
|
1765 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; |
|
1766 | - } else { |
|
1767 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; |
|
1768 | - } |
|
1769 | - } |
|
1770 | - } |
|
1771 | - |
|
1772 | - //////////////////////////////// |
|
1773 | - /* Diagnose Info Page Ends */ |
|
1774 | - //////////////////////////////// |
|
1775 | - |
|
1776 | - ////////////////////////////////// |
|
1777 | - /* Diagnose Location Page Starts */ |
|
1778 | - ////////////////////////////////// |
|
1779 | - $option_value = get_option('geodir_location_page'); |
|
1780 | - $page = get_post($option_value); |
|
1781 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1782 | - |
|
1783 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1784 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1785 | - else { |
|
1786 | - $is_error_during_diagnose = true; |
|
1787 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
|
1788 | - if ($fix) { |
|
1789 | - if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { |
|
1790 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; |
|
1791 | - } else { |
|
1792 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; |
|
1793 | - } |
|
1794 | - } |
|
1795 | - } |
|
1796 | - |
|
1797 | - //////////////////////////////// |
|
1798 | - /* Diagnose Location Page Ends */ |
|
1799 | - //////////////////////////////// |
|
1800 | - |
|
1801 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose ); |
|
1802 | - /** |
|
1803 | - * This action is called at the end of the GD Tools page check function. |
|
1804 | - * |
|
1805 | - * @since 1.5.2 |
|
1806 | - */ |
|
1807 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr); |
|
1808 | - |
|
1809 | - $output_str = $page_chk_arr['output_str']; |
|
1810 | - $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
1811 | - |
|
1812 | - if ($is_error_during_diagnose) { |
|
1813 | - if ($fix) { |
|
1814 | - flush_rewrite_rules(); |
|
1815 | - } |
|
1816 | - $info_div_class = "geodir_problem_info"; |
|
1817 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1818 | - } else { |
|
1819 | - $info_div_class = "geodir_noproblem_info"; |
|
1820 | - $fix_button_txt = ''; |
|
1821 | - } |
|
1822 | - echo "<ul class='$info_div_class'>"; |
|
1823 | - echo $output_str; |
|
1824 | - echo $fix_button_txt; |
|
1825 | - echo "</ul>"; |
|
1620 | + global $wpdb; |
|
1621 | + $is_error_during_diagnose = false; |
|
1622 | + $output_str = ''; |
|
1623 | + $fix = isset($_POST['fix']) ? true : false; |
|
1624 | + |
|
1625 | + ////////////////////////////////// |
|
1626 | + /* Diagnose GD Home Page Starts */ |
|
1627 | + ////////////////////////////////// |
|
1628 | + $option_value = get_option('geodir_home_page'); |
|
1629 | + $page = get_post($option_value); |
|
1630 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1631 | + |
|
1632 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1633 | + $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1634 | + else { |
|
1635 | + $is_error_during_diagnose = true; |
|
1636 | + $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
|
1637 | + if ($fix) { |
|
1638 | + if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { |
|
1639 | + $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; |
|
1640 | + } else { |
|
1641 | + $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; |
|
1642 | + } |
|
1643 | + } |
|
1644 | + } |
|
1645 | + |
|
1646 | + //////////////////////////////// |
|
1647 | + /* Diagnose GD Home Page Ends */ |
|
1648 | + //////////////////////////////// |
|
1649 | + |
|
1650 | + ////////////////////////////////// |
|
1651 | + /* Diagnose Add Listing Page Starts */ |
|
1652 | + ////////////////////////////////// |
|
1653 | + $option_value = get_option('geodir_add_listing_page'); |
|
1654 | + $page = get_post($option_value); |
|
1655 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1656 | + |
|
1657 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1658 | + $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1659 | + else { |
|
1660 | + $is_error_during_diagnose = true; |
|
1661 | + $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
|
1662 | + if ($fix) { |
|
1663 | + if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { |
|
1664 | + $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; |
|
1665 | + } else { |
|
1666 | + $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; |
|
1667 | + } |
|
1668 | + } |
|
1669 | + } |
|
1670 | + |
|
1671 | + //////////////////////////////// |
|
1672 | + /* Diagnose Add Listing Page Ends */ |
|
1673 | + //////////////////////////////// |
|
1674 | + |
|
1675 | + |
|
1676 | + ////////////////////////////////// |
|
1677 | + /* Diagnose Listing Preview Page Starts */ |
|
1678 | + ////////////////////////////////// |
|
1679 | + $option_value = get_option('geodir_preview_page'); |
|
1680 | + $page = get_post($option_value); |
|
1681 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1682 | + |
|
1683 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1684 | + $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1685 | + else { |
|
1686 | + $is_error_during_diagnose = true; |
|
1687 | + $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
|
1688 | + if ($fix) { |
|
1689 | + if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { |
|
1690 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; |
|
1691 | + } else { |
|
1692 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; |
|
1693 | + } |
|
1694 | + } |
|
1695 | + } |
|
1696 | + |
|
1697 | + //////////////////////////////// |
|
1698 | + /* Diagnose Listing Preview Page Ends */ |
|
1699 | + //////////////////////////////// |
|
1700 | + |
|
1701 | + ////////////////////////////////// |
|
1702 | + /* Diagnose Listing Success Page Starts */ |
|
1703 | + ////////////////////////////////// |
|
1704 | + $option_value = get_option('geodir_success_page'); |
|
1705 | + $page = get_post($option_value); |
|
1706 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1707 | + |
|
1708 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1709 | + $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1710 | + else { |
|
1711 | + $is_error_during_diagnose = true; |
|
1712 | + $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
|
1713 | + if ($fix) { |
|
1714 | + if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { |
|
1715 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; |
|
1716 | + } else { |
|
1717 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; |
|
1718 | + } |
|
1719 | + } |
|
1720 | + } |
|
1721 | + |
|
1722 | + //////////////////////////////// |
|
1723 | + /* Diagnose Listing Sucess Page Ends */ |
|
1724 | + //////////////////////////////// |
|
1725 | + |
|
1726 | + ////////////////////////////////// |
|
1727 | + /* Diagnose Info Page Starts */ |
|
1728 | + ////////////////////////////////// |
|
1729 | + $option_value = get_option('geodir_info_page'); |
|
1730 | + $page = get_post($option_value); |
|
1731 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1732 | + |
|
1733 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1734 | + $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1735 | + else { |
|
1736 | + $is_error_during_diagnose = true; |
|
1737 | + $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
|
1738 | + if ($fix) { |
|
1739 | + if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { |
|
1740 | + $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; |
|
1741 | + } else { |
|
1742 | + $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; |
|
1743 | + } |
|
1744 | + } |
|
1745 | + } |
|
1746 | + |
|
1747 | + //////////////////////////////// |
|
1748 | + /* Diagnose Info Page Ends */ |
|
1749 | + //////////////////////////////// |
|
1750 | + |
|
1751 | + ////////////////////////////////// |
|
1752 | + /* Diagnose Login Page Starts */ |
|
1753 | + ////////////////////////////////// |
|
1754 | + $option_value = get_option('geodir_login_page'); |
|
1755 | + $page = get_post($option_value); |
|
1756 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1757 | + |
|
1758 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1759 | + $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1760 | + else { |
|
1761 | + $is_error_during_diagnose = true; |
|
1762 | + $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
|
1763 | + if ($fix) { |
|
1764 | + if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { |
|
1765 | + $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; |
|
1766 | + } else { |
|
1767 | + $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; |
|
1768 | + } |
|
1769 | + } |
|
1770 | + } |
|
1771 | + |
|
1772 | + //////////////////////////////// |
|
1773 | + /* Diagnose Info Page Ends */ |
|
1774 | + //////////////////////////////// |
|
1775 | + |
|
1776 | + ////////////////////////////////// |
|
1777 | + /* Diagnose Location Page Starts */ |
|
1778 | + ////////////////////////////////// |
|
1779 | + $option_value = get_option('geodir_location_page'); |
|
1780 | + $page = get_post($option_value); |
|
1781 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1782 | + |
|
1783 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1784 | + $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1785 | + else { |
|
1786 | + $is_error_during_diagnose = true; |
|
1787 | + $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
|
1788 | + if ($fix) { |
|
1789 | + if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { |
|
1790 | + $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; |
|
1791 | + } else { |
|
1792 | + $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; |
|
1793 | + } |
|
1794 | + } |
|
1795 | + } |
|
1796 | + |
|
1797 | + //////////////////////////////// |
|
1798 | + /* Diagnose Location Page Ends */ |
|
1799 | + //////////////////////////////// |
|
1800 | + |
|
1801 | + $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose ); |
|
1802 | + /** |
|
1803 | + * This action is called at the end of the GD Tools page check function. |
|
1804 | + * |
|
1805 | + * @since 1.5.2 |
|
1806 | + */ |
|
1807 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr); |
|
1808 | + |
|
1809 | + $output_str = $page_chk_arr['output_str']; |
|
1810 | + $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
1811 | + |
|
1812 | + if ($is_error_during_diagnose) { |
|
1813 | + if ($fix) { |
|
1814 | + flush_rewrite_rules(); |
|
1815 | + } |
|
1816 | + $info_div_class = "geodir_problem_info"; |
|
1817 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1818 | + } else { |
|
1819 | + $info_div_class = "geodir_noproblem_info"; |
|
1820 | + $fix_button_txt = ''; |
|
1821 | + } |
|
1822 | + echo "<ul class='$info_div_class'>"; |
|
1823 | + echo $output_str; |
|
1824 | + echo $fix_button_txt; |
|
1825 | + echo "</ul>"; |
|
1826 | 1826 | |
1827 | 1827 | } |
1828 | 1828 | |
@@ -1834,26 +1834,26 @@ discard block |
||
1834 | 1834 | * @global object $wpdb WordPress Database object. |
1835 | 1835 | */ |
1836 | 1836 | function geodir_diagnose_load_db_language() { |
1837 | - global $wpdb; |
|
1837 | + global $wpdb; |
|
1838 | 1838 | |
1839 | 1839 | $is_error_during_diagnose = geodirectory_load_db_language(); |
1840 | 1840 | |
1841 | - $output_str = ''; |
|
1842 | - $fix_button_txt = ''; |
|
1841 | + $output_str = ''; |
|
1842 | + $fix_button_txt = ''; |
|
1843 | 1843 | |
1844 | - if ($is_error_during_diagnose) { |
|
1845 | - $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>"; |
|
1844 | + if ($is_error_during_diagnose) { |
|
1845 | + $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>"; |
|
1846 | 1846 | $info_div_class = "geodir_problem_info"; |
1847 | - } else { |
|
1848 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>"; |
|
1847 | + } else { |
|
1848 | + $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>"; |
|
1849 | 1849 | $info_div_class = "geodir_noproblem_info"; |
1850 | - $fix_button_txt = ''; |
|
1851 | - } |
|
1850 | + $fix_button_txt = ''; |
|
1851 | + } |
|
1852 | 1852 | |
1853 | 1853 | echo "<ul class='$info_div_class'>"; |
1854 | - echo $output_str; |
|
1855 | - echo $fix_button_txt; |
|
1856 | - echo "</ul>"; |
|
1854 | + echo $output_str; |
|
1855 | + echo $fix_button_txt; |
|
1856 | + echo "</ul>"; |
|
1857 | 1857 | |
1858 | 1858 | } |
1859 | 1859 | |
@@ -1884,23 +1884,23 @@ discard block |
||
1884 | 1884 | */ |
1885 | 1885 | function geodir_posts_clauses_request($clauses) |
1886 | 1886 | { |
1887 | - global $wpdb, $wp_query, $plugin_prefix; |
|
1887 | + global $wpdb, $wp_query, $plugin_prefix; |
|
1888 | 1888 | |
1889 | - 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'])) { |
|
1890 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
1889 | + 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'])) { |
|
1890 | + $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
1891 | 1891 | |
1892 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
1893 | - $clauses['join'] = $join; |
|
1892 | + $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
1893 | + $clauses['join'] = $join; |
|
1894 | 1894 | |
1895 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
1896 | - $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'; |
|
1897 | - $clauses['fields'] = $fields; |
|
1895 | + $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
1896 | + $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'; |
|
1897 | + $clauses['fields'] = $fields; |
|
1898 | 1898 | |
1899 | - $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
1900 | - $orderby = 'gd_expire ' . $order; |
|
1901 | - $clauses['orderby'] = $orderby; |
|
1902 | - } |
|
1903 | - return $clauses; |
|
1899 | + $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
1900 | + $orderby = 'gd_expire ' . $order; |
|
1901 | + $clauses['orderby'] = $orderby; |
|
1902 | + } |
|
1903 | + return $clauses; |
|
1904 | 1904 | } |
1905 | 1905 | |
1906 | 1906 | |
@@ -1921,7 +1921,7 @@ discard block |
||
1921 | 1921 | */ |
1922 | 1922 | function gd_theme_switch_compat_check() |
1923 | 1923 | { |
1924 | - gd_set_theme_compat(); |
|
1924 | + gd_set_theme_compat(); |
|
1925 | 1925 | } |
1926 | 1926 | |
1927 | 1927 | /** |
@@ -1934,27 +1934,27 @@ discard block |
||
1934 | 1934 | */ |
1935 | 1935 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") |
1936 | 1936 | { |
1937 | - if (function_exists('str_getcsv')) { |
|
1938 | - $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
1939 | - } else { |
|
1940 | - global $current_user; |
|
1941 | - $upload_dir = wp_upload_dir(); |
|
1942 | - |
|
1943 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
1944 | - $handle = fopen($file, 'w'); |
|
1945 | - |
|
1946 | - fwrite($handle, $input); |
|
1947 | - fclose($handle); |
|
1948 | - |
|
1949 | - $handle = fopen($file, 'rt'); |
|
1950 | - if (PHP_VERSION >= '5.3.0') { |
|
1951 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
1952 | - } else { |
|
1953 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
1954 | - } |
|
1955 | - fclose($handle); |
|
1956 | - } |
|
1957 | - return $fgetcsv; |
|
1937 | + if (function_exists('str_getcsv')) { |
|
1938 | + $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
1939 | + } else { |
|
1940 | + global $current_user; |
|
1941 | + $upload_dir = wp_upload_dir(); |
|
1942 | + |
|
1943 | + $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
1944 | + $handle = fopen($file, 'w'); |
|
1945 | + |
|
1946 | + fwrite($handle, $input); |
|
1947 | + fclose($handle); |
|
1948 | + |
|
1949 | + $handle = fopen($file, 'rt'); |
|
1950 | + if (PHP_VERSION >= '5.3.0') { |
|
1951 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
1952 | + } else { |
|
1953 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
1954 | + } |
|
1955 | + fclose($handle); |
|
1956 | + } |
|
1957 | + return $fgetcsv; |
|
1958 | 1958 | } |
1959 | 1959 | |
1960 | 1960 | add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv'); |
@@ -1969,375 +1969,375 @@ discard block |
||
1969 | 1969 | */ |
1970 | 1970 | function geodir_ajax_import_csv() |
1971 | 1971 | { |
1972 | - error_reporting(0); // hide error to get clean json response |
|
1972 | + error_reporting(0); // hide error to get clean json response |
|
1973 | 1973 | |
1974 | - global $wpdb, $plugin_prefix, $current_user; |
|
1975 | - $uploads = wp_upload_dir(); |
|
1976 | - @ini_set('auto_detect_line_endings', true); |
|
1974 | + global $wpdb, $plugin_prefix, $current_user; |
|
1975 | + $uploads = wp_upload_dir(); |
|
1976 | + @ini_set('auto_detect_line_endings', true); |
|
1977 | 1977 | |
1978 | 1978 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
1979 | 1979 | |
1980 | - $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
1981 | - $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
1982 | - $filename = $uploadedFile; |
|
1983 | - |
|
1984 | - $uploads = wp_upload_dir(); |
|
1985 | - $uploads_dir = $uploads['path']; |
|
1986 | - $image_name_arr = explode('/', $filename); |
|
1987 | - $filename = end($image_name_arr); |
|
1988 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1989 | - $return = array(); |
|
1990 | - $return['file'] = $uploadedFile; |
|
1991 | - $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); |
|
1992 | - |
|
1993 | - if (is_file($target_path) && file_exists($target_path) && $uploadedFile) { |
|
1994 | - $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
1995 | - |
|
1996 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
1997 | - $return['error'] = NULL; |
|
1998 | - |
|
1999 | - $return['rows'] = 0; |
|
2000 | - |
|
2001 | - |
|
2002 | - |
|
2003 | - if (($handle = fopen($target_path, "r")) !== FALSE) { |
|
2004 | - while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
|
2005 | - if(is_array($data) && !empty($data)) { |
|
2006 | - $file[] = '"' . implode('","', $data) . '"'; |
|
2007 | - } |
|
2008 | - } |
|
2009 | - fclose($handle); |
|
2010 | - $file = $file; |
|
2011 | - } |
|
2012 | - |
|
2013 | - |
|
2014 | - |
|
2015 | - $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
2016 | - |
|
2017 | - |
|
2018 | - if (!$return['rows'] > 0) { |
|
2019 | - $return['error'] = __('No data found in csv file.', 'geodirectory'); |
|
2020 | - } |
|
2021 | - } |
|
2022 | - } |
|
2023 | - if ($task == 'prepare' || !empty($return['error'])) { |
|
2024 | - echo json_encode($return); |
|
2025 | - exit; |
|
2026 | - } |
|
2027 | - |
|
2028 | - $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
2029 | - $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
2030 | - $count = $importlimit; |
|
2031 | - $requested_limit = $importlimit; |
|
2032 | - $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
2033 | - |
|
2034 | - if ($count < $totRecords) { |
|
2035 | - $count = $tmpCnt + $count; |
|
2036 | - if ($count > $totRecords) { |
|
2037 | - $count = $totRecords; |
|
2038 | - } |
|
2039 | - } else { |
|
2040 | - $count = $totRecords; |
|
2041 | - } |
|
2042 | - |
|
2043 | - $total_records = 0; |
|
2044 | - $rowcount = 0; |
|
2045 | - $address_invalid = 0; |
|
2046 | - $blank_address = 0; |
|
2047 | - $upload_files = 0; |
|
2048 | - $invalid_post_type = 0; |
|
2049 | - $invalid_title = 0; |
|
2050 | - $customKeyarray = array(); |
|
2051 | - $gd_post_info = array(); |
|
2052 | - $post_location = array(); |
|
2053 | - $countpost = 0; |
|
2054 | - |
|
2055 | - if (!empty($file)) { |
|
2056 | - $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
2057 | - $customKeyarray = $columns; |
|
2058 | - |
|
2059 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
2060 | - $return['error'] = CSV_INVAILD_FILE; |
|
2061 | - echo json_encode($return); |
|
2062 | - exit; |
|
2063 | - } |
|
2064 | - |
|
2065 | - for ($i = 1; $i <= $importlimit; $i++) { |
|
2066 | - $current_index = $tmpCnt + $i; |
|
2067 | - if (isset($file[$current_index])) { |
|
2068 | - $total_records++; |
|
2069 | - |
|
2070 | - $buffer = geodir_str_getcsv($file[$current_index]); |
|
2071 | - $post_title = addslashes($buffer[0]); |
|
2072 | - $current_post_author = $buffer[1]; |
|
2073 | - $post_desc = addslashes($buffer[2]); |
|
2074 | - $post_cat = array(); |
|
2075 | - $catids_arr = array(); |
|
2076 | - $post_cat = trim($buffer[3]); // comma seperated category name |
|
2077 | - |
|
2078 | - if ($post_cat) { |
|
2079 | - $post_cat_arr = explode(',', $post_cat); |
|
2080 | - |
|
2081 | - for ($c = 0; $c < count($post_cat_arr); $c++) { |
|
2082 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
2083 | - |
|
2084 | - if (!empty($buffer[5])) { |
|
2085 | - if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2086 | - |
|
2087 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
2088 | - |
|
2089 | - if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2090 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2091 | - $catids_arr[] = $cat->slug; |
|
2092 | - } else if (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2093 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2094 | - $catids_arr[] = $cat->slug; |
|
2095 | - } else { |
|
2096 | - $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
2097 | - if ($ret && !is_wp_error($ret)) { |
|
2098 | - if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2099 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2100 | - $catids_arr[] = $cat->slug; |
|
2101 | - } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2102 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2103 | - $catids_arr[] = $cat->slug; |
|
2104 | - } |
|
2105 | - } |
|
2106 | - } |
|
2107 | - } |
|
2108 | - } |
|
2109 | - } |
|
2110 | - } |
|
2111 | - |
|
2112 | - if (!$catids_arr) { |
|
2113 | - $catids_arr[] = 1; |
|
2114 | - } |
|
2115 | - |
|
2116 | - $post_tags = trim($buffer[4]); // comma seperated tags |
|
2117 | - |
|
2118 | - $tag_arr = ''; |
|
2119 | - if ($post_tags) { |
|
2120 | - $tag_arr = explode(',', $post_tags); |
|
2121 | - } |
|
2122 | - |
|
2123 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
2124 | - |
|
2125 | - $error = ''; |
|
2126 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { |
|
2127 | - $invalid_post_type++; |
|
2128 | - continue; |
|
2129 | - } |
|
2130 | - |
|
2131 | - if ($post_title != '') { |
|
2132 | - $menu_order = 0; |
|
2133 | - $image_folder_name = 'uplaod/'; |
|
2134 | - |
|
2135 | - $image_names = array(); |
|
2136 | - |
|
2137 | - for ($c = 5; $c < count($customKeyarray); $c++) { |
|
2138 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
2139 | - |
|
2140 | - if ($customKeyarray[$c] == 'IMAGE') { |
|
2141 | - $buffer[$c] = trim($buffer[$c]); |
|
2142 | - |
|
2143 | - if (!empty($buffer[$c])) { |
|
2144 | - $image_names[] = $buffer[$c]; |
|
2145 | - } |
|
2146 | - } |
|
2147 | - |
|
2148 | - if ($customKeyarray[$c] == 'alive_days') { |
|
2149 | - if ($buffer[$c] != '0' && $buffer[$c] != '') { |
|
2150 | - $submitdata = date('Y-m-d'); |
|
2151 | - |
|
2152 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); |
|
2153 | - } else { |
|
2154 | - $gd_post_info['expire_date'] = 'Never'; |
|
2155 | - } |
|
2156 | - } |
|
2157 | - |
|
2158 | - if ($customKeyarray[$c] == 'post_city') { |
|
2159 | - $post_city = addslashes($buffer[$c]); |
|
2160 | - } |
|
2161 | - |
|
2162 | - if ($customKeyarray[$c] == 'post_region') { |
|
2163 | - $post_region = addslashes($buffer[$c]); |
|
2164 | - } |
|
2165 | - |
|
2166 | - if ($customKeyarray[$c] == 'post_country') { |
|
2167 | - $post_country = addslashes($buffer[$c]); |
|
2168 | - } |
|
2169 | - |
|
2170 | - if ($customKeyarray[$c] == 'post_latitude') { |
|
2171 | - $post_latitude = addslashes($buffer[$c]); |
|
2172 | - } |
|
2173 | - |
|
2174 | - if ($customKeyarray[$c] == 'post_longitude') { |
|
2175 | - $post_longitude = addslashes($buffer[$c]); |
|
2176 | - } |
|
1980 | + $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
1981 | + $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
1982 | + $filename = $uploadedFile; |
|
1983 | + |
|
1984 | + $uploads = wp_upload_dir(); |
|
1985 | + $uploads_dir = $uploads['path']; |
|
1986 | + $image_name_arr = explode('/', $filename); |
|
1987 | + $filename = end($image_name_arr); |
|
1988 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1989 | + $return = array(); |
|
1990 | + $return['file'] = $uploadedFile; |
|
1991 | + $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); |
|
1992 | + |
|
1993 | + if (is_file($target_path) && file_exists($target_path) && $uploadedFile) { |
|
1994 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
1995 | + |
|
1996 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
1997 | + $return['error'] = NULL; |
|
1998 | + |
|
1999 | + $return['rows'] = 0; |
|
2000 | + |
|
2001 | + |
|
2002 | + |
|
2003 | + if (($handle = fopen($target_path, "r")) !== FALSE) { |
|
2004 | + while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
|
2005 | + if(is_array($data) && !empty($data)) { |
|
2006 | + $file[] = '"' . implode('","', $data) . '"'; |
|
2007 | + } |
|
2008 | + } |
|
2009 | + fclose($handle); |
|
2010 | + $file = $file; |
|
2011 | + } |
|
2012 | + |
|
2013 | + |
|
2014 | + |
|
2015 | + $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
2016 | + |
|
2017 | + |
|
2018 | + if (!$return['rows'] > 0) { |
|
2019 | + $return['error'] = __('No data found in csv file.', 'geodirectory'); |
|
2020 | + } |
|
2021 | + } |
|
2022 | + } |
|
2023 | + if ($task == 'prepare' || !empty($return['error'])) { |
|
2024 | + echo json_encode($return); |
|
2025 | + exit; |
|
2026 | + } |
|
2027 | + |
|
2028 | + $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
2029 | + $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
2030 | + $count = $importlimit; |
|
2031 | + $requested_limit = $importlimit; |
|
2032 | + $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
2033 | + |
|
2034 | + if ($count < $totRecords) { |
|
2035 | + $count = $tmpCnt + $count; |
|
2036 | + if ($count > $totRecords) { |
|
2037 | + $count = $totRecords; |
|
2038 | + } |
|
2039 | + } else { |
|
2040 | + $count = $totRecords; |
|
2041 | + } |
|
2042 | + |
|
2043 | + $total_records = 0; |
|
2044 | + $rowcount = 0; |
|
2045 | + $address_invalid = 0; |
|
2046 | + $blank_address = 0; |
|
2047 | + $upload_files = 0; |
|
2048 | + $invalid_post_type = 0; |
|
2049 | + $invalid_title = 0; |
|
2050 | + $customKeyarray = array(); |
|
2051 | + $gd_post_info = array(); |
|
2052 | + $post_location = array(); |
|
2053 | + $countpost = 0; |
|
2054 | + |
|
2055 | + if (!empty($file)) { |
|
2056 | + $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
2057 | + $customKeyarray = $columns; |
|
2058 | + |
|
2059 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
2060 | + $return['error'] = CSV_INVAILD_FILE; |
|
2061 | + echo json_encode($return); |
|
2062 | + exit; |
|
2063 | + } |
|
2064 | + |
|
2065 | + for ($i = 1; $i <= $importlimit; $i++) { |
|
2066 | + $current_index = $tmpCnt + $i; |
|
2067 | + if (isset($file[$current_index])) { |
|
2068 | + $total_records++; |
|
2069 | + |
|
2070 | + $buffer = geodir_str_getcsv($file[$current_index]); |
|
2071 | + $post_title = addslashes($buffer[0]); |
|
2072 | + $current_post_author = $buffer[1]; |
|
2073 | + $post_desc = addslashes($buffer[2]); |
|
2074 | + $post_cat = array(); |
|
2075 | + $catids_arr = array(); |
|
2076 | + $post_cat = trim($buffer[3]); // comma seperated category name |
|
2077 | + |
|
2078 | + if ($post_cat) { |
|
2079 | + $post_cat_arr = explode(',', $post_cat); |
|
2080 | + |
|
2081 | + for ($c = 0; $c < count($post_cat_arr); $c++) { |
|
2082 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
2083 | + |
|
2084 | + if (!empty($buffer[5])) { |
|
2085 | + if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2086 | + |
|
2087 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
2088 | + |
|
2089 | + if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2090 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2091 | + $catids_arr[] = $cat->slug; |
|
2092 | + } else if (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2093 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2094 | + $catids_arr[] = $cat->slug; |
|
2095 | + } else { |
|
2096 | + $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
2097 | + if ($ret && !is_wp_error($ret)) { |
|
2098 | + if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2099 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2100 | + $catids_arr[] = $cat->slug; |
|
2101 | + } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2102 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2103 | + $catids_arr[] = $cat->slug; |
|
2104 | + } |
|
2105 | + } |
|
2106 | + } |
|
2107 | + } |
|
2108 | + } |
|
2109 | + } |
|
2110 | + } |
|
2111 | + |
|
2112 | + if (!$catids_arr) { |
|
2113 | + $catids_arr[] = 1; |
|
2114 | + } |
|
2115 | + |
|
2116 | + $post_tags = trim($buffer[4]); // comma seperated tags |
|
2117 | + |
|
2118 | + $tag_arr = ''; |
|
2119 | + if ($post_tags) { |
|
2120 | + $tag_arr = explode(',', $post_tags); |
|
2121 | + } |
|
2122 | + |
|
2123 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
2124 | + |
|
2125 | + $error = ''; |
|
2126 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { |
|
2127 | + $invalid_post_type++; |
|
2128 | + continue; |
|
2129 | + } |
|
2130 | + |
|
2131 | + if ($post_title != '') { |
|
2132 | + $menu_order = 0; |
|
2133 | + $image_folder_name = 'uplaod/'; |
|
2134 | + |
|
2135 | + $image_names = array(); |
|
2136 | + |
|
2137 | + for ($c = 5; $c < count($customKeyarray); $c++) { |
|
2138 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
2139 | + |
|
2140 | + if ($customKeyarray[$c] == 'IMAGE') { |
|
2141 | + $buffer[$c] = trim($buffer[$c]); |
|
2142 | + |
|
2143 | + if (!empty($buffer[$c])) { |
|
2144 | + $image_names[] = $buffer[$c]; |
|
2145 | + } |
|
2146 | + } |
|
2147 | + |
|
2148 | + if ($customKeyarray[$c] == 'alive_days') { |
|
2149 | + if ($buffer[$c] != '0' && $buffer[$c] != '') { |
|
2150 | + $submitdata = date('Y-m-d'); |
|
2151 | + |
|
2152 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); |
|
2153 | + } else { |
|
2154 | + $gd_post_info['expire_date'] = 'Never'; |
|
2155 | + } |
|
2156 | + } |
|
2157 | + |
|
2158 | + if ($customKeyarray[$c] == 'post_city') { |
|
2159 | + $post_city = addslashes($buffer[$c]); |
|
2160 | + } |
|
2161 | + |
|
2162 | + if ($customKeyarray[$c] == 'post_region') { |
|
2163 | + $post_region = addslashes($buffer[$c]); |
|
2164 | + } |
|
2165 | + |
|
2166 | + if ($customKeyarray[$c] == 'post_country') { |
|
2167 | + $post_country = addslashes($buffer[$c]); |
|
2168 | + } |
|
2169 | + |
|
2170 | + if ($customKeyarray[$c] == 'post_latitude') { |
|
2171 | + $post_latitude = addslashes($buffer[$c]); |
|
2172 | + } |
|
2173 | + |
|
2174 | + if ($customKeyarray[$c] == 'post_longitude') { |
|
2175 | + $post_longitude = addslashes($buffer[$c]); |
|
2176 | + } |
|
2177 | 2177 | |
2178 | 2178 | // Post status |
2179 | 2179 | if ($customKeyarray[$c] == 'post_status') { |
2180 | - $post_status = sanitize_key( $buffer[$c] ); |
|
2181 | - } |
|
2182 | - } |
|
2183 | - |
|
2184 | - /* ================ before array create ============== */ |
|
2185 | - $location_result = geodir_get_default_location(); |
|
2186 | - 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'] == '')) { |
|
2187 | - $blank_address++; |
|
2188 | - continue; |
|
2189 | - } else if ($location_result->location_id == 0) { |
|
2190 | - 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))) { |
|
2191 | - $address_invalid++; |
|
2192 | - continue; |
|
2193 | - } |
|
2194 | - } |
|
2180 | + $post_status = sanitize_key( $buffer[$c] ); |
|
2181 | + } |
|
2182 | + } |
|
2183 | + |
|
2184 | + /* ================ before array create ============== */ |
|
2185 | + $location_result = geodir_get_default_location(); |
|
2186 | + 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'] == '')) { |
|
2187 | + $blank_address++; |
|
2188 | + continue; |
|
2189 | + } else if ($location_result->location_id == 0) { |
|
2190 | + 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))) { |
|
2191 | + $address_invalid++; |
|
2192 | + continue; |
|
2193 | + } |
|
2194 | + } |
|
2195 | 2195 | |
2196 | 2196 | // Default post status |
2197 | 2197 | $default_status = 'publish'; |
2198 | 2198 | $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
2199 | 2199 | $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
2200 | 2200 | |
2201 | - $my_post['post_title'] = $post_title; |
|
2202 | - $my_post['post_content'] = $post_desc; |
|
2203 | - $my_post['post_type'] = addslashes($buffer[5]); |
|
2204 | - $my_post['post_author'] = $current_post_author; |
|
2205 | - $my_post['post_status'] = $post_status; |
|
2206 | - $my_post['post_category'] = $catids_arr; |
|
2207 | - $my_post['post_tags'] = $tag_arr; |
|
2208 | - |
|
2209 | - $gd_post_info['post_tags'] = $tag_arr; |
|
2210 | - $gd_post_info['post_title'] = $post_title; |
|
2211 | - $gd_post_info['post_status'] = $post_status; |
|
2212 | - $gd_post_info['submit_time'] = time(); |
|
2213 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
2214 | - |
|
2215 | - $last_postid = wp_insert_post($my_post); |
|
2216 | - $countpost++; |
|
2217 | - |
|
2218 | - // Check if we need to save post location as new location |
|
2219 | - if ($location_result->location_id > 0) { |
|
2220 | - if (isset($post_city) && isset($post_region)) { |
|
2221 | - $request_info['post_location'] = array( |
|
2222 | - 'city' => $post_city, |
|
2223 | - 'region' => $post_region, |
|
2224 | - 'country' => $post_country, |
|
2225 | - 'geo_lat' => $post_latitude, |
|
2226 | - 'geo_lng' => $post_longitude |
|
2227 | - ); |
|
2228 | - |
|
2229 | - $post_location_info = $request_info['post_location']; |
|
2230 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
2231 | - $post_location_id = $location_id; |
|
2232 | - } else { |
|
2233 | - $post_location_id = 0; |
|
2234 | - } |
|
2235 | - } else { |
|
2236 | - $post_location_id = 0; |
|
2237 | - } |
|
2238 | - |
|
2239 | - /* ------- get default package info ----- */ |
|
2240 | - $payment_info = array(); |
|
2241 | - $package_info = array(); |
|
2242 | - |
|
2243 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
2244 | - $package_id = ''; |
|
2245 | - if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { |
|
2246 | - $package_id = $gd_post_info['package_id']; |
|
2247 | - } |
|
2248 | - |
|
2249 | - if (!empty($package_info)) { |
|
2250 | - $payment_info['package_id'] = $package_info['pid']; |
|
2251 | - |
|
2252 | - if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { |
|
2253 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); |
|
2254 | - } else { |
|
2255 | - $payment_info['expire_date'] = 'Never'; |
|
2256 | - } |
|
2257 | - |
|
2258 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
2259 | - } |
|
2260 | - |
|
2261 | - $gd_post_info['post_location_id'] = $post_location_id; |
|
2262 | - |
|
2263 | - $post_type = get_post_type($last_postid); |
|
2264 | - |
|
2265 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2266 | - |
|
2267 | - geodir_save_post_info($last_postid, $gd_post_info); |
|
2268 | - |
|
2269 | - if (!empty($image_names)) { |
|
2270 | - $upload_files++; |
|
2271 | - $menu_order = 1; |
|
2272 | - |
|
2273 | - foreach ($image_names as $image_name) { |
|
2274 | - $img_name_arr = explode('.', $image_name); |
|
2275 | - |
|
2276 | - $uploads = wp_upload_dir(); |
|
2277 | - $sub_dir = $uploads['subdir']; |
|
2278 | - |
|
2279 | - $arr_file_type = wp_check_filetype($image_name); |
|
2280 | - $uploaded_file_type = $arr_file_type['type']; |
|
2281 | - |
|
2282 | - $attachment = array(); |
|
2283 | - $attachment['post_id'] = $last_postid; |
|
2284 | - $attachment['title'] = $img_name_arr[0]; |
|
2285 | - $attachment['content'] = ''; |
|
2286 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
2287 | - $attachment['mime_type'] = $uploaded_file_type; |
|
2288 | - $attachment['menu_order'] = $menu_order; |
|
2289 | - $attachment['is_featured'] = 0; |
|
2290 | - |
|
2291 | - $attachment_set = ''; |
|
2292 | - |
|
2293 | - foreach ($attachment as $key => $val) { |
|
2294 | - if ($val != '') |
|
2295 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
2296 | - } |
|
2297 | - $attachment_set = trim($attachment_set, ", "); |
|
2298 | - |
|
2299 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
2300 | - |
|
2301 | - if ($menu_order == 1) { |
|
2302 | - $post_type = get_post_type($last_postid); |
|
2303 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); |
|
2304 | - } |
|
2305 | - $menu_order++; |
|
2306 | - } |
|
2307 | - } |
|
2308 | - |
|
2309 | - $gd_post_info['package_id'] = $package_id; |
|
2310 | - |
|
2311 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
2312 | - do_action('geodir_after_save_listing', $last_postid, $gd_post_info); |
|
2313 | - |
|
2314 | - if (!empty($buffer[5])) { |
|
2315 | - if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2316 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
2317 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
2318 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
2319 | - |
|
2320 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
2321 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
2322 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
2323 | - } |
|
2324 | - } |
|
2325 | - } else { |
|
2326 | - $invalid_title++; |
|
2327 | - } |
|
2328 | - } |
|
2329 | - } |
|
2330 | - } |
|
2331 | - $return['rowcount'] = $countpost; |
|
2332 | - $return['invalidcount'] = $address_invalid; |
|
2333 | - $return['blank_address'] = $blank_address; |
|
2334 | - $return['upload_files'] = $upload_files; |
|
2335 | - $return['invalid_post_type'] = $invalid_post_type; |
|
2336 | - $return['invalid_title'] = $invalid_title; |
|
2337 | - $return['total_records'] = $total_records; |
|
2338 | - |
|
2339 | - echo json_encode($return); |
|
2340 | - exit; |
|
2201 | + $my_post['post_title'] = $post_title; |
|
2202 | + $my_post['post_content'] = $post_desc; |
|
2203 | + $my_post['post_type'] = addslashes($buffer[5]); |
|
2204 | + $my_post['post_author'] = $current_post_author; |
|
2205 | + $my_post['post_status'] = $post_status; |
|
2206 | + $my_post['post_category'] = $catids_arr; |
|
2207 | + $my_post['post_tags'] = $tag_arr; |
|
2208 | + |
|
2209 | + $gd_post_info['post_tags'] = $tag_arr; |
|
2210 | + $gd_post_info['post_title'] = $post_title; |
|
2211 | + $gd_post_info['post_status'] = $post_status; |
|
2212 | + $gd_post_info['submit_time'] = time(); |
|
2213 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
2214 | + |
|
2215 | + $last_postid = wp_insert_post($my_post); |
|
2216 | + $countpost++; |
|
2217 | + |
|
2218 | + // Check if we need to save post location as new location |
|
2219 | + if ($location_result->location_id > 0) { |
|
2220 | + if (isset($post_city) && isset($post_region)) { |
|
2221 | + $request_info['post_location'] = array( |
|
2222 | + 'city' => $post_city, |
|
2223 | + 'region' => $post_region, |
|
2224 | + 'country' => $post_country, |
|
2225 | + 'geo_lat' => $post_latitude, |
|
2226 | + 'geo_lng' => $post_longitude |
|
2227 | + ); |
|
2228 | + |
|
2229 | + $post_location_info = $request_info['post_location']; |
|
2230 | + if ($location_id = geodir_add_new_location($post_location_info)) |
|
2231 | + $post_location_id = $location_id; |
|
2232 | + } else { |
|
2233 | + $post_location_id = 0; |
|
2234 | + } |
|
2235 | + } else { |
|
2236 | + $post_location_id = 0; |
|
2237 | + } |
|
2238 | + |
|
2239 | + /* ------- get default package info ----- */ |
|
2240 | + $payment_info = array(); |
|
2241 | + $package_info = array(); |
|
2242 | + |
|
2243 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
2244 | + $package_id = ''; |
|
2245 | + if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { |
|
2246 | + $package_id = $gd_post_info['package_id']; |
|
2247 | + } |
|
2248 | + |
|
2249 | + if (!empty($package_info)) { |
|
2250 | + $payment_info['package_id'] = $package_info['pid']; |
|
2251 | + |
|
2252 | + if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { |
|
2253 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); |
|
2254 | + } else { |
|
2255 | + $payment_info['expire_date'] = 'Never'; |
|
2256 | + } |
|
2257 | + |
|
2258 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
2259 | + } |
|
2260 | + |
|
2261 | + $gd_post_info['post_location_id'] = $post_location_id; |
|
2262 | + |
|
2263 | + $post_type = get_post_type($last_postid); |
|
2264 | + |
|
2265 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2266 | + |
|
2267 | + geodir_save_post_info($last_postid, $gd_post_info); |
|
2268 | + |
|
2269 | + if (!empty($image_names)) { |
|
2270 | + $upload_files++; |
|
2271 | + $menu_order = 1; |
|
2272 | + |
|
2273 | + foreach ($image_names as $image_name) { |
|
2274 | + $img_name_arr = explode('.', $image_name); |
|
2275 | + |
|
2276 | + $uploads = wp_upload_dir(); |
|
2277 | + $sub_dir = $uploads['subdir']; |
|
2278 | + |
|
2279 | + $arr_file_type = wp_check_filetype($image_name); |
|
2280 | + $uploaded_file_type = $arr_file_type['type']; |
|
2281 | + |
|
2282 | + $attachment = array(); |
|
2283 | + $attachment['post_id'] = $last_postid; |
|
2284 | + $attachment['title'] = $img_name_arr[0]; |
|
2285 | + $attachment['content'] = ''; |
|
2286 | + $attachment['file'] = $sub_dir . '/' . $image_name; |
|
2287 | + $attachment['mime_type'] = $uploaded_file_type; |
|
2288 | + $attachment['menu_order'] = $menu_order; |
|
2289 | + $attachment['is_featured'] = 0; |
|
2290 | + |
|
2291 | + $attachment_set = ''; |
|
2292 | + |
|
2293 | + foreach ($attachment as $key => $val) { |
|
2294 | + if ($val != '') |
|
2295 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
2296 | + } |
|
2297 | + $attachment_set = trim($attachment_set, ", "); |
|
2298 | + |
|
2299 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
2300 | + |
|
2301 | + if ($menu_order == 1) { |
|
2302 | + $post_type = get_post_type($last_postid); |
|
2303 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); |
|
2304 | + } |
|
2305 | + $menu_order++; |
|
2306 | + } |
|
2307 | + } |
|
2308 | + |
|
2309 | + $gd_post_info['package_id'] = $package_id; |
|
2310 | + |
|
2311 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
2312 | + do_action('geodir_after_save_listing', $last_postid, $gd_post_info); |
|
2313 | + |
|
2314 | + if (!empty($buffer[5])) { |
|
2315 | + if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2316 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
2317 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
2318 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
2319 | + |
|
2320 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
2321 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
2322 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
2323 | + } |
|
2324 | + } |
|
2325 | + } else { |
|
2326 | + $invalid_title++; |
|
2327 | + } |
|
2328 | + } |
|
2329 | + } |
|
2330 | + } |
|
2331 | + $return['rowcount'] = $countpost; |
|
2332 | + $return['invalidcount'] = $address_invalid; |
|
2333 | + $return['blank_address'] = $blank_address; |
|
2334 | + $return['upload_files'] = $upload_files; |
|
2335 | + $return['invalid_post_type'] = $invalid_post_type; |
|
2336 | + $return['invalid_title'] = $invalid_title; |
|
2337 | + $return['total_records'] = $total_records; |
|
2338 | + |
|
2339 | + echo json_encode($return); |
|
2340 | + exit; |
|
2341 | 2341 | } |
2342 | 2342 | |
2343 | 2343 | // Add the tab in left sidebar menu fro import & export page. |
@@ -2357,9 +2357,9 @@ discard block |
||
2357 | 2357 | * @param $post object $post The post object of the post being saved. |
2358 | 2358 | */ |
2359 | 2359 | function geodir_update_location_prefix($post_id,$post){ |
2360 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){ |
|
2361 | - update_option('geodir_location_prefix',$post->post_name); |
|
2362 | - } |
|
2360 | + if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){ |
|
2361 | + update_option('geodir_location_prefix',$post->post_name); |
|
2362 | + } |
|
2363 | 2363 | |
2364 | 2364 | } |
2365 | 2365 | |
@@ -2370,50 +2370,50 @@ discard block |
||
2370 | 2370 | function geodir_ga_callback(){ |
2371 | 2371 | |
2372 | 2372 | if(isset($_REQUEST['code']) && $_REQUEST['code']) { |
2373 | - $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
2374 | - $code = "code=".$_REQUEST['code']; |
|
2375 | - $grant_type = "&grant_type=authorization_code"; |
|
2376 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
2377 | - $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
2378 | - $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
|
2373 | + $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
2374 | + $code = "code=".$_REQUEST['code']; |
|
2375 | + $grant_type = "&grant_type=authorization_code"; |
|
2376 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
2377 | + $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
2378 | + $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
|
2379 | 2379 | |
2380 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
2380 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
2381 | 2381 | |
2382 | - $response = wp_remote_post($auth_url, array('timeout' => 15)); |
|
2382 | + $response = wp_remote_post($auth_url, array('timeout' => 15)); |
|
2383 | 2383 | |
2384 | - //print_r($response); |
|
2384 | + //print_r($response); |
|
2385 | 2385 | |
2386 | - $error_msg = __('Something went wrong','geodirectory'); |
|
2387 | - if(!empty($response['response']['code']) && $response['response']['code']==200){ |
|
2386 | + $error_msg = __('Something went wrong','geodirectory'); |
|
2387 | + if(!empty($response['response']['code']) && $response['response']['code']==200){ |
|
2388 | 2388 | |
2389 | - $parts = json_decode($response['body']); |
|
2390 | - //print_r($parts); |
|
2391 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2392 | - else{ |
|
2389 | + $parts = json_decode($response['body']); |
|
2390 | + //print_r($parts); |
|
2391 | + if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2392 | + else{ |
|
2393 | 2393 | |
2394 | - update_option('gd_ga_access_token', $parts->access_token); |
|
2395 | - update_option('gd_ga_refresh_token', $parts->refresh_token); |
|
2396 | - ?><script>window.close();</script><?php |
|
2397 | - } |
|
2394 | + update_option('gd_ga_access_token', $parts->access_token); |
|
2395 | + update_option('gd_ga_refresh_token', $parts->refresh_token); |
|
2396 | + ?><script>window.close();</script><?php |
|
2397 | + } |
|
2398 | 2398 | |
2399 | 2399 | |
2400 | - } |
|
2401 | - elseif(!empty($response['response']['code'])) { |
|
2402 | - $parts = json_decode($response['body']); |
|
2400 | + } |
|
2401 | + elseif(!empty($response['response']['code'])) { |
|
2402 | + $parts = json_decode($response['body']); |
|
2403 | 2403 | |
2404 | - if(isset($parts->error)){ |
|
2405 | - echo $parts->error.": ".$parts->error_description;exit; |
|
2406 | - }else{ |
|
2407 | - echo $error_msg." - #2";exit; |
|
2408 | - } |
|
2404 | + if(isset($parts->error)){ |
|
2405 | + echo $parts->error.": ".$parts->error_description;exit; |
|
2406 | + }else{ |
|
2407 | + echo $error_msg." - #2";exit; |
|
2408 | + } |
|
2409 | 2409 | |
2410 | - }else{ |
|
2410 | + }else{ |
|
2411 | 2411 | |
2412 | - echo $error_msg." - #3";exit; |
|
2412 | + echo $error_msg." - #3";exit; |
|
2413 | 2413 | |
2414 | - } |
|
2414 | + } |
|
2415 | 2415 | } |
2416 | - exit; |
|
2416 | + exit; |
|
2417 | 2417 | } |
2418 | 2418 | |
2419 | 2419 | if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') { |
@@ -2429,45 +2429,45 @@ discard block |
||
2429 | 2429 | * @return array Array of settings. |
2430 | 2430 | */ |
2431 | 2431 | function geodir_uninstall_settings($general_settings) { |
2432 | - $settings = array(); |
|
2433 | - $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory')); |
|
2434 | - $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' )); |
|
2432 | + $settings = array(); |
|
2433 | + $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory')); |
|
2434 | + $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' )); |
|
2435 | 2435 | |
2436 | - $plugins = get_plugins(); |
|
2437 | - $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array()); |
|
2436 | + $plugins = get_plugins(); |
|
2437 | + $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array()); |
|
2438 | 2438 | |
2439 | - if (!empty($plugins) && !empty($un_plugins)) { |
|
2440 | - foreach ($plugins as $plugin => $data) { |
|
2441 | - $plugin_name = plugin_basename(dirname($plugin)); |
|
2439 | + if (!empty($plugins) && !empty($un_plugins)) { |
|
2440 | + foreach ($plugins as $plugin => $data) { |
|
2441 | + $plugin_name = plugin_basename(dirname($plugin)); |
|
2442 | 2442 | |
2443 | - if (in_array($plugin_name, $un_plugins)) { |
|
2444 | - $settings[] = array( |
|
2445 | - 'type' => 'checkbox', |
|
2446 | - 'id' => 'geodir_un_' . $plugin_name, |
|
2447 | - 'name' => $data['Name'], |
|
2448 | - 'desc' => __('Remove all data when deleted?', 'geodirectory'), |
|
2449 | - 'std' => '0' |
|
2450 | - ); |
|
2451 | - } |
|
2452 | - } |
|
2453 | - } |
|
2443 | + if (in_array($plugin_name, $un_plugins)) { |
|
2444 | + $settings[] = array( |
|
2445 | + 'type' => 'checkbox', |
|
2446 | + 'id' => 'geodir_un_' . $plugin_name, |
|
2447 | + 'name' => $data['Name'], |
|
2448 | + 'desc' => __('Remove all data when deleted?', 'geodirectory'), |
|
2449 | + 'std' => '0' |
|
2450 | + ); |
|
2451 | + } |
|
2452 | + } |
|
2453 | + } |
|
2454 | 2454 | |
2455 | - $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main'); |
|
2455 | + $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main'); |
|
2456 | 2456 | |
2457 | - /** |
|
2458 | - * Filter the uninstall settings array. |
|
2459 | - * |
|
2460 | - * @since 1.6.9 |
|
2461 | - * |
|
2462 | - * @param array $settings The settings array. |
|
2463 | - */ |
|
2464 | - $settings = apply_filters('geodir_uninstall_settings', $settings); |
|
2457 | + /** |
|
2458 | + * Filter the uninstall settings array. |
|
2459 | + * |
|
2460 | + * @since 1.6.9 |
|
2461 | + * |
|
2462 | + * @param array $settings The settings array. |
|
2463 | + */ |
|
2464 | + $settings = apply_filters('geodir_uninstall_settings', $settings); |
|
2465 | 2465 | |
2466 | - if (!empty($settings) && count($settings) > 3) { |
|
2467 | - return array_merge($general_settings, $settings); |
|
2468 | - } |
|
2466 | + if (!empty($settings) && count($settings) > 3) { |
|
2467 | + return array_merge($general_settings, $settings); |
|
2468 | + } |
|
2469 | 2469 | |
2470 | - return $general_settings; |
|
2470 | + return $general_settings; |
|
2471 | 2471 | } |
2472 | 2472 | add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1); |
2473 | 2473 | |
@@ -2477,7 +2477,7 @@ discard block |
||
2477 | 2477 | * @since 1.6.9 |
2478 | 2478 | */ |
2479 | 2479 | function geodir_uninstall_settings_desc() { |
2480 | - echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>'; |
|
2480 | + echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>'; |
|
2481 | 2481 | } |
2482 | 2482 | add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc'); |
2483 | 2483 | |
@@ -2493,18 +2493,18 @@ discard block |
||
2493 | 2493 | * @return array The settings array. |
2494 | 2494 | */ |
2495 | 2495 | function geodir_resave_settings($settings = array()) { |
2496 | - if (!empty($settings) && is_array($settings)) { |
|
2497 | - $c = 0; |
|
2496 | + if (!empty($settings) && is_array($settings)) { |
|
2497 | + $c = 0; |
|
2498 | 2498 | |
2499 | - foreach ($settings as $setting) { |
|
2500 | - if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) { |
|
2501 | - $settings[$c]['std'] = $value; |
|
2502 | - } |
|
2503 | - $c++; |
|
2504 | - } |
|
2505 | - } |
|
2506 | - |
|
2507 | - return $settings; |
|
2499 | + foreach ($settings as $setting) { |
|
2500 | + if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) { |
|
2501 | + $settings[$c]['std'] = $value; |
|
2502 | + } |
|
2503 | + $c++; |
|
2504 | + } |
|
2505 | + } |
|
2506 | + |
|
2507 | + return $settings; |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | /** |
@@ -2516,9 +2516,9 @@ discard block |
||
2516 | 2516 | * @return array The modified settings. |
2517 | 2517 | */ |
2518 | 2518 | function geodir_core_uninstall_settings($settings) { |
2519 | - $settings[] = plugin_basename(dirname(dirname(__FILE__))); |
|
2519 | + $settings[] = plugin_basename(dirname(dirname(__FILE__))); |
|
2520 | 2520 | |
2521 | - return $settings; |
|
2521 | + return $settings; |
|
2522 | 2522 | } |
2523 | 2523 | add_filter('geodir_plugins_uninstall_settings', 'geodir_core_uninstall_settings', 10, 1); |
2524 | 2524 | |
@@ -2532,34 +2532,34 @@ discard block |
||
2532 | 2532 | */ |
2533 | 2533 | function geodir_diagnose_reload_db_countries() |
2534 | 2534 | { |
2535 | - global $wpdb, $plugin_prefix; |
|
2536 | - |
|
2537 | - $is_error_during_diagnose = false; |
|
2538 | - $output_str = ''; |
|
2539 | - |
|
2540 | - $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE); |
|
2541 | - |
|
2542 | - |
|
2543 | - if ($delete) { |
|
2544 | - $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>"; |
|
2545 | - ob_start(); |
|
2546 | - geodir_diagnose_version_clear(); |
|
2547 | - ob_end_clean(); |
|
2548 | - }else{ |
|
2549 | - $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>"; |
|
2550 | - } |
|
2551 | - |
|
2552 | - if ($is_error_during_diagnose) { |
|
2553 | - $info_div_class = "geodir_problem_info"; |
|
2554 | - $fix_button_txt = ""; |
|
2555 | - } else { |
|
2556 | - $info_div_class = "geodir_noproblem_info"; |
|
2557 | - $fix_button_txt = ''; |
|
2558 | - } |
|
2559 | - echo "<ul class='$info_div_class'>"; |
|
2560 | - echo $output_str; |
|
2561 | - echo $fix_button_txt; |
|
2562 | - echo "</ul>"; |
|
2535 | + global $wpdb, $plugin_prefix; |
|
2536 | + |
|
2537 | + $is_error_during_diagnose = false; |
|
2538 | + $output_str = ''; |
|
2539 | + |
|
2540 | + $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE); |
|
2541 | + |
|
2542 | + |
|
2543 | + if ($delete) { |
|
2544 | + $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>"; |
|
2545 | + ob_start(); |
|
2546 | + geodir_diagnose_version_clear(); |
|
2547 | + ob_end_clean(); |
|
2548 | + }else{ |
|
2549 | + $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>"; |
|
2550 | + } |
|
2551 | + |
|
2552 | + if ($is_error_during_diagnose) { |
|
2553 | + $info_div_class = "geodir_problem_info"; |
|
2554 | + $fix_button_txt = ""; |
|
2555 | + } else { |
|
2556 | + $info_div_class = "geodir_noproblem_info"; |
|
2557 | + $fix_button_txt = ''; |
|
2558 | + } |
|
2559 | + echo "<ul class='$info_div_class'>"; |
|
2560 | + echo $output_str; |
|
2561 | + echo $fix_button_txt; |
|
2562 | + echo "</ul>"; |
|
2563 | 2563 | } |
2564 | 2564 | |
2565 | 2565 | /** |
@@ -2572,11 +2572,11 @@ discard block |
||
2572 | 2572 | * @return array Filtered actions. |
2573 | 2573 | */ |
2574 | 2574 | function geodir_disable_quick_edit( $actions = array(), $row = null ) { |
2575 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
2576 | - unset( $actions['inline hide-if-no-js'] ); |
|
2577 | - } |
|
2575 | + if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
2576 | + unset( $actions['inline hide-if-no-js'] ); |
|
2577 | + } |
|
2578 | 2578 | |
2579 | - return $actions; |
|
2579 | + return $actions; |
|
2580 | 2580 | } |
2581 | 2581 | |
2582 | 2582 | /** |
@@ -2590,26 +2590,26 @@ discard block |
||
2590 | 2590 | * @global bool $gd_cpt_screen True if current scrrrn has GD post type. |
2591 | 2591 | */ |
2592 | 2592 | function geodir_check_quick_edit() { |
2593 | - global $pagenow, $current_screen, $gd_cpt_screen; |
|
2594 | - |
|
2595 | - if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) { |
|
2596 | - if ( empty( $gd_cpt_screen ) ) { |
|
2597 | - if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) { |
|
2598 | - $gd_cpt_screen = 'y'; |
|
2599 | - } else { |
|
2600 | - $gd_cpt_screen = 'n'; |
|
2601 | - } |
|
2602 | - } |
|
2603 | - |
|
2604 | - if ( $gd_cpt_screen == 'y' ) { |
|
2605 | - if ( $pagenow == 'edit.php' ) { |
|
2606 | - add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2607 | - add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2608 | - } elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) { |
|
2609 | - add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2610 | - } |
|
2611 | - } |
|
2612 | - } |
|
2593 | + global $pagenow, $current_screen, $gd_cpt_screen; |
|
2594 | + |
|
2595 | + if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) { |
|
2596 | + if ( empty( $gd_cpt_screen ) ) { |
|
2597 | + if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) { |
|
2598 | + $gd_cpt_screen = 'y'; |
|
2599 | + } else { |
|
2600 | + $gd_cpt_screen = 'n'; |
|
2601 | + } |
|
2602 | + } |
|
2603 | + |
|
2604 | + if ( $gd_cpt_screen == 'y' ) { |
|
2605 | + if ( $pagenow == 'edit.php' ) { |
|
2606 | + add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2607 | + add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2608 | + } elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) { |
|
2609 | + add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2610 | + } |
|
2611 | + } |
|
2612 | + } |
|
2613 | 2613 | } |
2614 | 2614 | add_action( 'admin_head', 'geodir_check_quick_edit', 10 ); |
2615 | 2615 | |
@@ -2623,11 +2623,11 @@ discard block |
||
2623 | 2623 | * @return array Filtered bulk actions. |
2624 | 2624 | */ |
2625 | 2625 | function geodir_filter_bulk_actions( $actions ) { |
2626 | - if ( isset( $actions['edit'] ) ) { |
|
2627 | - unset( $actions['edit'] ); |
|
2628 | - } |
|
2626 | + if ( isset( $actions['edit'] ) ) { |
|
2627 | + unset( $actions['edit'] ); |
|
2628 | + } |
|
2629 | 2629 | |
2630 | - return $actions; |
|
2630 | + return $actions; |
|
2631 | 2631 | } |
2632 | 2632 | |
2633 | 2633 | /** |
@@ -62,7 +62,7 @@ discard block |
||
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 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings'); |
71 | 71 | add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit'); |
72 | 72 | add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php |
73 | -add_action('geodir_before_update_options', 'geodir_before_update_options',10,2); |
|
73 | +add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2); |
|
74 | 74 | |
75 | 75 | //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header'); |
76 | 76 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | // Disable VC editor for GD post types. |
101 | 101 | if (class_exists('Vc_Role_Access_Controller')) { |
102 | - add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 ); |
|
102 | + add_filter('vc_role_access_with_post_types_can', '__return_false', 100); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | add_action('admin_panel_init', 'geodir_admin_list_columns', 2); |
127 | 127 | |
128 | 128 | /* --- insert dummy post action ---*/ |
129 | -add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1,3); |
|
130 | -add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1,3); |
|
129 | +add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1, 3); |
|
130 | +add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1, 3); |
|
131 | 131 | |
132 | 132 | |
133 | 133 | /** |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | |
241 | 241 | // Filter-Payment-Manager |
242 | 242 | |
243 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
243 | + add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
244 | 244 | |
245 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
245 | + add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
246 | 246 | |
247 | 247 | // no need of this box as all fields moved to main information box |
248 | 248 | //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' ); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | } |
253 | 253 | |
254 | -add_action('save_post', 'geodir_post_information_save',10,2); |
|
254 | +add_action('save_post', 'geodir_post_information_save', 10, 2); |
|
255 | 255 | |
256 | 256 | |
257 | 257 | |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | |
279 | 279 | $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
280 | 280 | |
281 | - if(!empty($gd_taxonomy)) { |
|
281 | + if (!empty($gd_taxonomy)) { |
|
282 | 282 | foreach ($gd_taxonomy as $tax) { |
283 | 283 | |
284 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
284 | + remove_meta_box($tax.'div', $geodir_post_type, 'normal'); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | } |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined'); |
368 | 368 | add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom'); |
369 | 369 | |
370 | -function geodir_manage_available_fields_predefined($sub_tab){ |
|
371 | - if($sub_tab=='custom_fields'){ |
|
370 | +function geodir_manage_available_fields_predefined($sub_tab) { |
|
371 | + if ($sub_tab == 'custom_fields') { |
|
372 | 372 | geodir_custom_available_fields('predefined'); |
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | -function geodir_manage_available_fields_custom($sub_tab){ |
|
377 | - if($sub_tab=='custom_fields'){ |
|
376 | +function geodir_manage_available_fields_custom($sub_tab) { |
|
377 | + if ($sub_tab == 'custom_fields') { |
|
378 | 378 | geodir_custom_available_fields('custom'); |
379 | 379 | } |
380 | 380 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | global $wpdb; |
445 | 445 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
446 | 446 | ?> |
447 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
447 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
448 | 448 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
449 | 449 | <ul> |
450 | 450 | <?php |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | |
456 | 456 | $check_html_variable = $wpdb->get_var( |
457 | 457 | $wpdb->prepare( |
458 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
458 | + "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
459 | 459 | array($val['htmlvar_name'], $listing_type, $val['field_type']) |
460 | 460 | ) |
461 | 461 | ); |
@@ -463,23 +463,23 @@ discard block |
||
463 | 463 | $display = $check_html_variable ? ' style="display:none;"' : ''; |
464 | 464 | ?> |
465 | 465 | |
466 | - <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> |
|
466 | + <li class="gd-cf-tooltip-wrap" <?php echo $display; ?>> |
|
467 | 467 | <?php |
468 | - if(isset($val['description']) && $val['description']){ |
|
468 | + if (isset($val['description']) && $val['description']) { |
|
469 | 469 | echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
470 | 470 | }?> |
471 | 471 | |
472 | - <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>" data-field-type="<?php echo $val['field_type'];?>" |
|
473 | - title="<?php echo $val['site_title'];?>" |
|
474 | - class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
|
472 | + <a id="gd-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" data-field-type-key="<?php echo $val['htmlvar_name']; ?>" data-field-type="<?php echo $val['field_type']; ?>" |
|
473 | + title="<?php echo $val['site_title']; ?>" |
|
474 | + class="gd-draggable-form-items gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);"> |
|
475 | 475 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], ' fa-') !== false) { |
476 | 476 | echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
477 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
477 | + }elseif (isset($val['field_icon']) && $val['field_icon']) { |
|
478 | 478 | echo '<b class="gd-cf-icon" style="background-image: url(\''.$val['field_icon'].'\')"></b>'; |
479 | - }else{ |
|
479 | + } else { |
|
480 | 480 | echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
481 | 481 | }?> |
482 | - <?php echo (! empty( $val['admin_title'] ) ? $val['admin_title'] : $val['site_title'] );?> |
|
482 | + <?php echo (!empty($val['admin_title']) ? $val['admin_title'] : $val['site_title']); ?> |
|
483 | 483 | </a> |
484 | 484 | </li> |
485 | 485 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | <?php |
508 | 508 | global $wpdb; |
509 | 509 | |
510 | - $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))); |
|
510 | + $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))); |
|
511 | 511 | |
512 | 512 | if (!empty($fields)) { |
513 | 513 | foreach ($fields as $field) { |
@@ -532,14 +532,14 @@ discard block |
||
532 | 532 | * @since 1.6.9 |
533 | 533 | * @package GeoDirectory |
534 | 534 | */ |
535 | -function geodir_custom_fields_custom($post_type=''){ |
|
535 | +function geodir_custom_fields_custom($post_type = '') { |
|
536 | 536 | |
537 | 537 | $custom_fields = array(); |
538 | 538 | |
539 | 539 | /** |
540 | 540 | * @see `geodir_custom_fields` |
541 | 541 | */ |
542 | - return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type); |
|
542 | + return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @since 1.6.6 |
551 | 551 | * @package GeoDirectory |
552 | 552 | */ |
553 | -function geodir_custom_fields($post_type=''){ |
|
553 | +function geodir_custom_fields($post_type = '') { |
|
554 | 554 | |
555 | 555 | $custom_fields = array( |
556 | 556 | 'text' => array( |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * } |
686 | 686 | * @param string $post_type The post type requested. |
687 | 687 | */ |
688 | - return apply_filters('geodir_custom_fields',$custom_fields,$post_type); |
|
688 | + return apply_filters('geodir_custom_fields', $custom_fields, $post_type); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -696,25 +696,25 @@ discard block |
||
696 | 696 | * @param string $type The custom field type, predefined, custom or blank for default |
697 | 697 | * @package GeoDirectory |
698 | 698 | */ |
699 | -function geodir_custom_available_fields($type='') |
|
699 | +function geodir_custom_available_fields($type = '') |
|
700 | 700 | { |
701 | 701 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
702 | 702 | ?> |
703 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
703 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
704 | 704 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> |
705 | 705 | |
706 | 706 | <?php |
707 | - if($type=='predefined'){ |
|
707 | + if ($type == 'predefined') { |
|
708 | 708 | $cfs = geodir_custom_fields_predefined($listing_type); |
709 | - }elseif($type=='custom'){ |
|
709 | + }elseif ($type == 'custom') { |
|
710 | 710 | $cfs = geodir_custom_fields_custom($listing_type); |
711 | - }else{ |
|
711 | + } else { |
|
712 | 712 | $cfs = geodir_custom_fields($listing_type); |
713 | 713 | ?> |
714 | 714 | <ul class="full gd-cf-tooltip-wrap"> |
715 | 715 | <li> |
716 | 716 | <div class="gdcf-tooltip"> |
717 | - <?php _e('This adds a section separator with a title.', 'geodirectory');?> |
|
717 | + <?php _e('This adds a section separator with a title.', 'geodirectory'); ?> |
|
718 | 718 | </div> |
719 | 719 | <a id="gt-fieldset" |
720 | 720 | class="gd-draggable-form-items gt-fieldset" |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | |
726 | 726 | <i class="fas fa-long-arrow-alt-left " aria-hidden="true"></i> |
727 | 727 | <i class="fas fa-long-arrow-alt-right " aria-hidden="true"></i> |
728 | - <?php _e('Fieldset (section separator)', 'geodirectory');?> |
|
728 | + <?php _e('Fieldset (section separator)', 'geodirectory'); ?> |
|
729 | 729 | </a> |
730 | 730 | </li> |
731 | 731 | </ul> |
@@ -733,15 +733,15 @@ discard block |
||
733 | 733 | <?php |
734 | 734 | } |
735 | 735 | |
736 | - if(!empty($cfs)) { |
|
736 | + if (!empty($cfs)) { |
|
737 | 737 | echo '<ul>'; |
738 | - foreach ( $cfs as $id => $cf ) { |
|
738 | + foreach ($cfs as $id => $cf) { |
|
739 | 739 | ?> |
740 | 740 | |
741 | 741 | <li class="gd-cf-tooltip-wrap"> |
742 | 742 | <?php |
743 | - if ( isset( $cf['description'] ) && $cf['description'] ) { |
|
744 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
743 | + if (isset($cf['description']) && $cf['description']) { |
|
744 | + echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>'; |
|
745 | 745 | } ?> |
746 | 746 | |
747 | 747 | <a id="gd-<?php echo $id; ?>" |
@@ -751,10 +751,10 @@ discard block |
||
751 | 751 | class="gd-draggable-form-items <?php echo $cf['class']; ?>" |
752 | 752 | href="javascript:void(0);"> |
753 | 753 | |
754 | - <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], ' fa-' ) !== false ) { |
|
755 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
756 | - } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) { |
|
757 | - echo '<b class="gd-cf-icon" style="background-image: url(\'' . $cf['icon'] . '\')"></b>'; |
|
754 | + <?php if (isset($cf['icon']) && strpos($cf['icon'], ' fa-') !== false) { |
|
755 | + echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>'; |
|
756 | + } elseif (isset($cf['icon']) && $cf['icon']) { |
|
757 | + echo '<b class="gd-cf-icon" style="background-image: url(\''.$cf['icon'].'\')"></b>'; |
|
758 | 758 | } else { |
759 | 759 | echo '<i class="fas fa-cog" aria-hidden="true"></i>'; |
760 | 760 | } ?> |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | </li> |
764 | 764 | <?php |
765 | 765 | } |
766 | - }else{ |
|
766 | + } else { |
|
767 | 767 | _e('There are no custom fields here yet.', 'geodirectory'); |
768 | 768 | } |
769 | 769 | ?> |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | <ul class="core"> |
792 | 792 | <?php |
793 | 793 | global $wpdb; |
794 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
794 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
795 | 795 | |
796 | 796 | if (!empty($fields)) { |
797 | 797 | foreach ($fields as $field) { |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | $field_type_key = $field->field_type_key; |
802 | 802 | $field_ins_upd = 'display'; |
803 | 803 | |
804 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
804 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key); |
|
805 | 805 | } |
806 | 806 | } |
807 | 807 | ?></ul> |
@@ -960,8 +960,8 @@ discard block |
||
960 | 960 | |
961 | 961 | if (!get_option('geodir_remove_unnecessary_fields')) { |
962 | 962 | |
963 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
964 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
963 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'")) |
|
964 | + $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`"); |
|
965 | 965 | |
966 | 966 | update_option('geodir_remove_unnecessary_fields', '1'); |
967 | 967 | |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | case 'diagnosis' : |
991 | 991 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
992 | 992 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
993 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
993 | + call_user_func('geodir_diagnose_'.$diagnose_this); |
|
994 | 994 | |
995 | 995 | } |
996 | 996 | exit(); |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | case 'diagnosis-fix' : |
1000 | 1000 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
1001 | 1001 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
1002 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
1002 | + call_user_func('geodir_diagnose_'.$diagnose_this); |
|
1003 | 1003 | exit(); |
1004 | 1004 | break; |
1005 | 1005 | } |
@@ -1024,50 +1024,50 @@ discard block |
||
1024 | 1024 | { |
1025 | 1025 | global $wpdb; |
1026 | 1026 | //$filter_arr['output_str'] .='###'.$table.'###'; |
1027 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) { |
|
1028 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>"; |
|
1027 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) { |
|
1028 | + $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>"; |
|
1029 | 1029 | $filter_arr['is_error_during_diagnose'] = true; |
1030 | 1030 | |
1031 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1032 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1031 | + } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) { |
|
1032 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>"; |
|
1033 | 1033 | $filter_arr['is_error_during_diagnose'] = true; |
1034 | - $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>"; |
|
1034 | + $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>"; |
|
1035 | 1035 | $filter_arr['is_error_during_diagnose'] = true; |
1036 | 1036 | |
1037 | 1037 | if ($fix) { |
1038 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count |
|
1039 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count |
|
1038 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count |
|
1039 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count |
|
1040 | 1040 | |
1041 | 1041 | if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2 |
1042 | 1042 | //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ; |
1043 | 1043 | |
1044 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table |
|
1044 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table |
|
1045 | 1045 | |
1046 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1047 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>"; |
|
1046 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) { |
|
1047 | + $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>"; |
|
1048 | 1048 | } else { |
1049 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1049 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>"; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it |
1053 | 1053 | |
1054 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2 |
|
1055 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table |
|
1054 | + $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2 |
|
1055 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table |
|
1056 | 1056 | |
1057 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1058 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>"; |
|
1057 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1058 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>"; |
|
1059 | 1059 | } else { |
1060 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1060 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>"; |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors |
1064 | 1064 | |
1065 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2 |
|
1065 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2 |
|
1066 | 1066 | |
1067 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1068 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>"; |
|
1067 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) { |
|
1068 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>"; |
|
1069 | 1069 | } else { |
1070 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1070 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>"; |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | } |
@@ -1075,54 +1075,54 @@ discard block |
||
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | |
1078 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1079 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1078 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) { |
|
1079 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>"; |
|
1080 | 1080 | $filter_arr['is_error_during_diagnose'] = true; |
1081 | 1081 | |
1082 | 1082 | if ($fix) { |
1083 | 1083 | if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it |
1084 | 1084 | if ($wpdb->query("DROP TABLE IF EXISTS $table")) { |
1085 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>"; |
|
1085 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>"; |
|
1086 | 1086 | } else { |
1087 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>"; |
|
1087 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>"; |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | - } 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 |
|
1091 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) { |
|
1092 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1090 | + } 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 |
|
1091 | + if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) { |
|
1092 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>"; |
|
1093 | 1093 | } else { |
1094 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1094 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>"; |
|
1095 | 1095 | } |
1096 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1097 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1096 | + if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1097 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>"; |
|
1098 | 1098 | } else { |
1099 | - $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>"; |
|
1099 | + $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>"; |
|
1100 | 1100 | } |
1101 | 1101 | } else {// else rename the original table to _ms_bak |
1102 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1103 | - $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>"; |
|
1102 | + if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1103 | + $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>"; |
|
1104 | 1104 | } else { |
1105 | - $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>"; |
|
1105 | + $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>"; |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | } |
1109 | 1109 | |
1110 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1111 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>"; |
|
1110 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) { |
|
1111 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>"; |
|
1112 | 1112 | $filter_arr['is_error_during_diagnose'] = true; |
1113 | 1113 | |
1114 | 1114 | if ($fix) { |
1115 | 1115 | // if original table exists but new does not, rename |
1116 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1117 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1116 | + if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1117 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>"; |
|
1118 | 1118 | } else { |
1119 | - $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>"; |
|
1119 | + $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>"; |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | } |
1123 | 1123 | |
1124 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1125 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>"; |
|
1124 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) { |
|
1125 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>"; |
|
1126 | 1126 | $filter_arr['is_error_during_diagnose'] = true; |
1127 | 1127 | |
1128 | 1128 | if ($fix) { |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | delete_option('geodir_custom_posts_db_version'); |
1137 | 1137 | delete_option('geodir_reviewratings_db_version'); |
1138 | 1138 | delete_option('geodiradvancesearch_db_version'); |
1139 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>"; |
|
1139 | + $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>"; |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | } else { |
1143 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>"; |
|
1143 | + $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>"; |
|
1144 | 1144 | } |
1145 | 1145 | return $filter_arr; |
1146 | 1146 | } |
@@ -1181,21 +1181,21 @@ discard block |
||
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | if ($stepped_process) { |
1184 | - $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset ); |
|
1185 | - $posts = $wpdb->get_results( $sql ); |
|
1184 | + $sql = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."geodir_".$ptype."_detail LIMIT %d OFFSET %d", $step_max_items, $offset); |
|
1185 | + $posts = $wpdb->get_results($sql); |
|
1186 | 1186 | |
1187 | 1187 | if (!empty($posts)) { |
1188 | 1188 | |
1189 | 1189 | foreach ($posts as $p) { |
1190 | 1190 | $p->post_type = $ptype; |
1191 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1191 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names')); |
|
1192 | 1192 | if (empty($raw_tags)) { |
1193 | 1193 | $post_tags = ''; |
1194 | 1194 | } else { |
1195 | 1195 | $post_tags = implode(",", $raw_tags); |
1196 | 1196 | } |
1197 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1198 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1197 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
1198 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1199 | 1199 | |
1200 | 1200 | } |
1201 | 1201 | if ($step >= $max_step) { |
@@ -1211,23 +1211,23 @@ discard block |
||
1211 | 1211 | if (!empty($all_postypes)) { |
1212 | 1212 | foreach ($all_postypes as $key) { |
1213 | 1213 | // update each GD CPT |
1214 | - $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1214 | + $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail"); |
|
1215 | 1215 | |
1216 | 1216 | if (!empty($posts)) { |
1217 | 1217 | |
1218 | 1218 | foreach ($posts as $p) { |
1219 | 1219 | $p->post_type = $key; |
1220 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1220 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names')); |
|
1221 | 1221 | if (empty($raw_tags)) { |
1222 | 1222 | $post_tags = ''; |
1223 | 1223 | } else { |
1224 | 1224 | $post_tags = implode(",", $raw_tags); |
1225 | 1225 | } |
1226 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1227 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1226 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
1227 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1228 | 1228 | |
1229 | 1229 | } |
1230 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1230 | + $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>"; |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | } |
@@ -1238,14 +1238,14 @@ discard block |
||
1238 | 1238 | |
1239 | 1239 | if ($is_error_during_diagnose) { |
1240 | 1240 | $info_div_class = "geodir_problem_info"; |
1241 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1241 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1242 | 1242 | } else { |
1243 | 1243 | $info_div_class = "geodir_noproblem_info"; |
1244 | 1244 | $fix_button_txt = ''; |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | if ($stepped_process) { |
1248 | - $percent = ($step/$max_step) * 100; |
|
1248 | + $percent = ($step / $max_step) * 100; |
|
1249 | 1249 | if ($output_str == 'done') { |
1250 | 1250 | echo $output_str; |
1251 | 1251 | } else { |
@@ -1288,29 +1288,29 @@ discard block |
||
1288 | 1288 | if (!empty($all_postypes)) { |
1289 | 1289 | foreach ($all_postypes as $key) { |
1290 | 1290 | // update each GD CTP |
1291 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' "); |
|
1291 | + $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' "); |
|
1292 | 1292 | |
1293 | 1293 | if (!empty($posts)) { |
1294 | 1294 | |
1295 | 1295 | foreach ($posts as $p) { |
1296 | 1296 | $p->post_type = $key; |
1297 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids')); |
|
1297 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids')); |
|
1298 | 1298 | |
1299 | 1299 | if (empty($raw_cats)) { |
1300 | 1300 | $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
1301 | 1301 | |
1302 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) { |
|
1303 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']); |
|
1304 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) { |
|
1302 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) { |
|
1303 | + $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']); |
|
1304 | + foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) { |
|
1305 | 1305 | if (is_numeric($cat_part)) { |
1306 | - $raw_cats[] = (int)$cat_part; |
|
1306 | + $raw_cats[] = (int) $cat_part; |
|
1307 | 1307 | } |
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | if (!empty($raw_cats)) { |
1313 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
1313 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category'); |
|
1314 | 1314 | |
1315 | 1315 | } |
1316 | 1316 | |
@@ -1320,14 +1320,14 @@ discard block |
||
1320 | 1320 | if (empty($raw_cats)) { |
1321 | 1321 | $post_cats = ''; |
1322 | 1322 | } else { |
1323 | - $post_cats = ',' . implode(",", $raw_cats) . ','; |
|
1323 | + $post_cats = ','.implode(",", $raw_cats).','; |
|
1324 | 1324 | } |
1325 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1326 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1325 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
1326 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | } |
1330 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1330 | + $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>"; |
|
1331 | 1331 | |
1332 | 1332 | } |
1333 | 1333 | |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | |
1336 | 1336 | if ($is_error_during_diagnose) { |
1337 | 1337 | $info_div_class = "geodir_problem_info"; |
1338 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1338 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1339 | 1339 | } else { |
1340 | 1340 | $info_div_class = "geodir_noproblem_info"; |
1341 | 1341 | $fix_button_txt = ''; |
@@ -1388,15 +1388,15 @@ discard block |
||
1388 | 1388 | if (!empty($ver_arr)) { |
1389 | 1389 | foreach ($ver_arr as $key => $val) { |
1390 | 1390 | if (delete_option($val)) { |
1391 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>"; |
|
1391 | + $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>"; |
|
1392 | 1392 | } else { |
1393 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>"; |
|
1393 | + $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>"; |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | if ($output_str) { |
1399 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>"; |
|
1399 | + $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>"; |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | } |
@@ -1435,55 +1435,55 @@ discard block |
||
1435 | 1435 | $gd_post_types = geodir_get_posttypes(); |
1436 | 1436 | |
1437 | 1437 | $skip_post_types = array(); |
1438 | - if ( ! empty( $gd_post_types ) ) { |
|
1439 | - foreach ( $gd_post_types as $post_type ) { |
|
1440 | - $location_allowed = $post_type && function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
1441 | - if ( $location_allowed ) { |
|
1438 | + if (!empty($gd_post_types)) { |
|
1439 | + foreach ($gd_post_types as $post_type) { |
|
1440 | + $location_allowed = $post_type && function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true; |
|
1441 | + if ($location_allowed) { |
|
1442 | 1442 | continue; |
1443 | 1443 | } |
1444 | 1444 | $skip_post_types[] = $post_type; |
1445 | 1445 | } |
1446 | 1446 | } |
1447 | - $skip_post_types_where = ! empty( $skip_post_types ) ? " AND post_type NOT IN( '" . implode( "','", $skip_post_types ) . "' )" : ''; |
|
1447 | + $skip_post_types_where = !empty($skip_post_types) ? " AND post_type NOT IN( '".implode("','", $skip_post_types)."' )" : ''; |
|
1448 | 1448 | |
1449 | 1449 | // check review locations |
1450 | - if ($wpdb->get_var("SELECT COUNT(*) FROM " . GEODIR_REVIEW_TABLE . " WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) { |
|
1451 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; |
|
1450 | + if ($wpdb->get_var("SELECT COUNT(*) FROM ".GEODIR_REVIEW_TABLE." WHERE ( post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL ) {$skip_post_types_where}")) { |
|
1451 | + $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>"; |
|
1452 | 1452 | $is_error_during_diagnose = true; |
1453 | 1453 | |
1454 | 1454 | if ($fix) { |
1455 | 1455 | if (geodir_fix_review_location()) { |
1456 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; |
|
1456 | + $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>"; |
|
1457 | 1457 | } else { |
1458 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; |
|
1458 | + $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>"; |
|
1459 | 1459 | } |
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | } else { |
1463 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; |
|
1463 | + $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>"; |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | // check review content |
1467 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { |
|
1468 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; |
|
1467 | + if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) { |
|
1468 | + $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>"; |
|
1469 | 1469 | $is_error_during_diagnose = true; |
1470 | 1470 | |
1471 | 1471 | if ($fix) { |
1472 | 1472 | if (geodir_fix_review_content()) { |
1473 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; |
|
1473 | + $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>"; |
|
1474 | 1474 | } else { |
1475 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; |
|
1475 | + $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>"; |
|
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | } else { |
1480 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; |
|
1480 | + $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>"; |
|
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | |
1484 | 1484 | if ($is_error_during_diagnose) { |
1485 | 1485 | $info_div_class = "geodir_problem_info"; |
1486 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1486 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1487 | 1487 | } else { |
1488 | 1488 | $info_div_class = "geodir_noproblem_info"; |
1489 | 1489 | $fix_button_txt = ''; |
@@ -1547,7 +1547,7 @@ discard block |
||
1547 | 1547 | |
1548 | 1548 | if ($is_error_during_diagnose) { |
1549 | 1549 | $info_div_class = "geodir_problem_info"; |
1550 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1550 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1551 | 1551 | } else { |
1552 | 1552 | $info_div_class = "geodir_noproblem_info"; |
1553 | 1553 | $fix_button_txt = ''; |
@@ -1581,7 +1581,7 @@ discard block |
||
1581 | 1581 | else { |
1582 | 1582 | $page_found = $wpdb->get_var( |
1583 | 1583 | $wpdb->prepare( |
1584 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
1584 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", |
|
1585 | 1585 | array($slug) |
1586 | 1586 | ) |
1587 | 1587 | ); |
@@ -1627,18 +1627,18 @@ discard block |
||
1627 | 1627 | ////////////////////////////////// |
1628 | 1628 | $option_value = get_option('geodir_home_page'); |
1629 | 1629 | $page = get_post($option_value); |
1630 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1630 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1631 | 1631 | |
1632 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1633 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1632 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1633 | + $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>"; |
|
1634 | 1634 | else { |
1635 | 1635 | $is_error_during_diagnose = true; |
1636 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
|
1636 | + $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>"; |
|
1637 | 1637 | if ($fix) { |
1638 | 1638 | if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { |
1639 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; |
|
1639 | + $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>"; |
|
1640 | 1640 | } else { |
1641 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; |
|
1641 | + $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>"; |
|
1642 | 1642 | } |
1643 | 1643 | } |
1644 | 1644 | } |
@@ -1652,18 +1652,18 @@ discard block |
||
1652 | 1652 | ////////////////////////////////// |
1653 | 1653 | $option_value = get_option('geodir_add_listing_page'); |
1654 | 1654 | $page = get_post($option_value); |
1655 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1655 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1656 | 1656 | |
1657 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1658 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1657 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1658 | + $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>"; |
|
1659 | 1659 | else { |
1660 | 1660 | $is_error_during_diagnose = true; |
1661 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
|
1661 | + $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>"; |
|
1662 | 1662 | if ($fix) { |
1663 | 1663 | if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { |
1664 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; |
|
1664 | + $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>"; |
|
1665 | 1665 | } else { |
1666 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; |
|
1666 | + $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>"; |
|
1667 | 1667 | } |
1668 | 1668 | } |
1669 | 1669 | } |
@@ -1678,18 +1678,18 @@ discard block |
||
1678 | 1678 | ////////////////////////////////// |
1679 | 1679 | $option_value = get_option('geodir_preview_page'); |
1680 | 1680 | $page = get_post($option_value); |
1681 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1681 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1682 | 1682 | |
1683 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1684 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1683 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1684 | + $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>"; |
|
1685 | 1685 | else { |
1686 | 1686 | $is_error_during_diagnose = true; |
1687 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
|
1687 | + $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>"; |
|
1688 | 1688 | if ($fix) { |
1689 | 1689 | if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { |
1690 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; |
|
1690 | + $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>"; |
|
1691 | 1691 | } else { |
1692 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; |
|
1692 | + $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>"; |
|
1693 | 1693 | } |
1694 | 1694 | } |
1695 | 1695 | } |
@@ -1703,18 +1703,18 @@ discard block |
||
1703 | 1703 | ////////////////////////////////// |
1704 | 1704 | $option_value = get_option('geodir_success_page'); |
1705 | 1705 | $page = get_post($option_value); |
1706 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1706 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1707 | 1707 | |
1708 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1709 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1708 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1709 | + $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>"; |
|
1710 | 1710 | else { |
1711 | 1711 | $is_error_during_diagnose = true; |
1712 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
|
1712 | + $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>"; |
|
1713 | 1713 | if ($fix) { |
1714 | 1714 | if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { |
1715 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; |
|
1715 | + $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>"; |
|
1716 | 1716 | } else { |
1717 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; |
|
1717 | + $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>"; |
|
1718 | 1718 | } |
1719 | 1719 | } |
1720 | 1720 | } |
@@ -1728,18 +1728,18 @@ discard block |
||
1728 | 1728 | ////////////////////////////////// |
1729 | 1729 | $option_value = get_option('geodir_info_page'); |
1730 | 1730 | $page = get_post($option_value); |
1731 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1731 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1732 | 1732 | |
1733 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1734 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1733 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1734 | + $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>"; |
|
1735 | 1735 | else { |
1736 | 1736 | $is_error_during_diagnose = true; |
1737 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
|
1737 | + $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>"; |
|
1738 | 1738 | if ($fix) { |
1739 | 1739 | if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { |
1740 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; |
|
1740 | + $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>"; |
|
1741 | 1741 | } else { |
1742 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; |
|
1742 | + $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>"; |
|
1743 | 1743 | } |
1744 | 1744 | } |
1745 | 1745 | } |
@@ -1753,18 +1753,18 @@ discard block |
||
1753 | 1753 | ////////////////////////////////// |
1754 | 1754 | $option_value = get_option('geodir_login_page'); |
1755 | 1755 | $page = get_post($option_value); |
1756 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1756 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1757 | 1757 | |
1758 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1759 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1758 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1759 | + $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>"; |
|
1760 | 1760 | else { |
1761 | 1761 | $is_error_during_diagnose = true; |
1762 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
|
1762 | + $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>"; |
|
1763 | 1763 | if ($fix) { |
1764 | 1764 | if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { |
1765 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; |
|
1765 | + $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>"; |
|
1766 | 1766 | } else { |
1767 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; |
|
1767 | + $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>"; |
|
1768 | 1768 | } |
1769 | 1769 | } |
1770 | 1770 | } |
@@ -1778,18 +1778,18 @@ discard block |
||
1778 | 1778 | ////////////////////////////////// |
1779 | 1779 | $option_value = get_option('geodir_location_page'); |
1780 | 1780 | $page = get_post($option_value); |
1781 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1781 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1782 | 1782 | |
1783 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1784 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1783 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1784 | + $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>"; |
|
1785 | 1785 | else { |
1786 | 1786 | $is_error_during_diagnose = true; |
1787 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
|
1787 | + $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>"; |
|
1788 | 1788 | if ($fix) { |
1789 | 1789 | if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { |
1790 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; |
|
1790 | + $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>"; |
|
1791 | 1791 | } else { |
1792 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; |
|
1792 | + $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>"; |
|
1793 | 1793 | } |
1794 | 1794 | } |
1795 | 1795 | } |
@@ -1798,13 +1798,13 @@ discard block |
||
1798 | 1798 | /* Diagnose Location Page Ends */ |
1799 | 1799 | //////////////////////////////// |
1800 | 1800 | |
1801 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose ); |
|
1801 | + $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose); |
|
1802 | 1802 | /** |
1803 | 1803 | * This action is called at the end of the GD Tools page check function. |
1804 | 1804 | * |
1805 | 1805 | * @since 1.5.2 |
1806 | 1806 | */ |
1807 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr); |
|
1807 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr); |
|
1808 | 1808 | |
1809 | 1809 | $output_str = $page_chk_arr['output_str']; |
1810 | 1810 | $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
@@ -1814,7 +1814,7 @@ discard block |
||
1814 | 1814 | flush_rewrite_rules(); |
1815 | 1815 | } |
1816 | 1816 | $info_div_class = "geodir_problem_info"; |
1817 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1817 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1818 | 1818 | } else { |
1819 | 1819 | $info_div_class = "geodir_noproblem_info"; |
1820 | 1820 | $fix_button_txt = ''; |
@@ -1842,10 +1842,10 @@ discard block |
||
1842 | 1842 | $fix_button_txt = ''; |
1843 | 1843 | |
1844 | 1844 | if ($is_error_during_diagnose) { |
1845 | - $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>"; |
|
1845 | + $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>"; |
|
1846 | 1846 | $info_div_class = "geodir_problem_info"; |
1847 | 1847 | } else { |
1848 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>"; |
|
1848 | + $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>"; |
|
1849 | 1849 | $info_div_class = "geodir_noproblem_info"; |
1850 | 1850 | $fix_button_txt = ''; |
1851 | 1851 | } |
@@ -1887,17 +1887,17 @@ discard block |
||
1887 | 1887 | global $wpdb, $wp_query, $plugin_prefix; |
1888 | 1888 | |
1889 | 1889 | 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'])) { |
1890 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
1890 | + $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail'; |
|
1891 | 1891 | |
1892 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
1892 | + $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)'; |
|
1893 | 1893 | $clauses['join'] = $join; |
1894 | 1894 | |
1895 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
1895 | + $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : ''; |
|
1896 | 1896 | $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'; |
1897 | 1897 | $clauses['fields'] = $fields; |
1898 | 1898 | |
1899 | 1899 | $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
1900 | - $orderby = 'gd_expire ' . $order; |
|
1900 | + $orderby = 'gd_expire '.$order; |
|
1901 | 1901 | $clauses['orderby'] = $orderby; |
1902 | 1902 | } |
1903 | 1903 | return $clauses; |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | global $current_user; |
1941 | 1941 | $upload_dir = wp_upload_dir(); |
1942 | 1942 | |
1943 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
1943 | + $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv'; |
|
1944 | 1944 | $handle = fopen($file, 'w'); |
1945 | 1945 | |
1946 | 1946 | fwrite($handle, $input); |
@@ -1985,7 +1985,7 @@ discard block |
||
1985 | 1985 | $uploads_dir = $uploads['path']; |
1986 | 1986 | $image_name_arr = explode('/', $filename); |
1987 | 1987 | $filename = end($image_name_arr); |
1988 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1988 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; |
|
1989 | 1989 | $return = array(); |
1990 | 1990 | $return['file'] = $uploadedFile; |
1991 | 1991 | $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); |
@@ -2002,8 +2002,8 @@ discard block |
||
2002 | 2002 | |
2003 | 2003 | if (($handle = fopen($target_path, "r")) !== FALSE) { |
2004 | 2004 | while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
2005 | - if(is_array($data) && !empty($data)) { |
|
2006 | - $file[] = '"' . implode('","', $data) . '"'; |
|
2005 | + if (is_array($data) && !empty($data)) { |
|
2006 | + $file[] = '"'.implode('","', $data).'"'; |
|
2007 | 2007 | } |
2008 | 2008 | } |
2009 | 2009 | fclose($handle); |
@@ -2120,10 +2120,10 @@ discard block |
||
2120 | 2120 | $tag_arr = explode(',', $post_tags); |
2121 | 2121 | } |
2122 | 2122 | |
2123 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
2123 | + $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database |
|
2124 | 2124 | |
2125 | 2125 | $error = ''; |
2126 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { |
|
2126 | + if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) { |
|
2127 | 2127 | $invalid_post_type++; |
2128 | 2128 | continue; |
2129 | 2129 | } |
@@ -2149,7 +2149,7 @@ discard block |
||
2149 | 2149 | if ($buffer[$c] != '0' && $buffer[$c] != '') { |
2150 | 2150 | $submitdata = date('Y-m-d'); |
2151 | 2151 | |
2152 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); |
|
2152 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days")); |
|
2153 | 2153 | } else { |
2154 | 2154 | $gd_post_info['expire_date'] = 'Never'; |
2155 | 2155 | } |
@@ -2177,7 +2177,7 @@ discard block |
||
2177 | 2177 | |
2178 | 2178 | // Post status |
2179 | 2179 | if ($customKeyarray[$c] == 'post_status') { |
2180 | - $post_status = sanitize_key( $buffer[$c] ); |
|
2180 | + $post_status = sanitize_key($buffer[$c]); |
|
2181 | 2181 | } |
2182 | 2182 | } |
2183 | 2183 | |
@@ -2195,8 +2195,8 @@ discard block |
||
2195 | 2195 | |
2196 | 2196 | // Default post status |
2197 | 2197 | $default_status = 'publish'; |
2198 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
2199 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
2198 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
2199 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
2200 | 2200 | |
2201 | 2201 | $my_post['post_title'] = $post_title; |
2202 | 2202 | $my_post['post_content'] = $post_desc; |
@@ -2240,7 +2240,7 @@ discard block |
||
2240 | 2240 | $payment_info = array(); |
2241 | 2241 | $package_info = array(); |
2242 | 2242 | |
2243 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
2243 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); |
|
2244 | 2244 | $package_id = ''; |
2245 | 2245 | if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { |
2246 | 2246 | $package_id = $gd_post_info['package_id']; |
@@ -2250,7 +2250,7 @@ discard block |
||
2250 | 2250 | $payment_info['package_id'] = $package_info['pid']; |
2251 | 2251 | |
2252 | 2252 | if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { |
2253 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); |
|
2253 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days")); |
|
2254 | 2254 | } else { |
2255 | 2255 | $payment_info['expire_date'] = 'Never'; |
2256 | 2256 | } |
@@ -2262,7 +2262,7 @@ discard block |
||
2262 | 2262 | |
2263 | 2263 | $post_type = get_post_type($last_postid); |
2264 | 2264 | |
2265 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2265 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
2266 | 2266 | |
2267 | 2267 | geodir_save_post_info($last_postid, $gd_post_info); |
2268 | 2268 | |
@@ -2283,7 +2283,7 @@ discard block |
||
2283 | 2283 | $attachment['post_id'] = $last_postid; |
2284 | 2284 | $attachment['title'] = $img_name_arr[0]; |
2285 | 2285 | $attachment['content'] = ''; |
2286 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
2286 | + $attachment['file'] = $sub_dir.'/'.$image_name; |
|
2287 | 2287 | $attachment['mime_type'] = $uploaded_file_type; |
2288 | 2288 | $attachment['menu_order'] = $menu_order; |
2289 | 2289 | $attachment['is_featured'] = 0; |
@@ -2292,15 +2292,15 @@ discard block |
||
2292 | 2292 | |
2293 | 2293 | foreach ($attachment as $key => $val) { |
2294 | 2294 | if ($val != '') |
2295 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
2295 | + $attachment_set .= $key." = '".$val."', "; |
|
2296 | 2296 | } |
2297 | 2297 | $attachment_set = trim($attachment_set, ", "); |
2298 | 2298 | |
2299 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
2299 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set); |
|
2300 | 2300 | |
2301 | 2301 | if ($menu_order == 1) { |
2302 | 2302 | $post_type = get_post_type($last_postid); |
2303 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); |
|
2303 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid))); |
|
2304 | 2304 | } |
2305 | 2305 | $menu_order++; |
2306 | 2306 | } |
@@ -2341,11 +2341,11 @@ discard block |
||
2341 | 2341 | } |
2342 | 2342 | |
2343 | 2343 | // Add the tab in left sidebar menu fro import & export page. |
2344 | -add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 ); |
|
2344 | +add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94); |
|
2345 | 2345 | |
2346 | 2346 | // Handle ajax request for import/export. |
2347 | -add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' ); |
|
2348 | -add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' ); |
|
2347 | +add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export'); |
|
2348 | +add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export'); |
|
2349 | 2349 | |
2350 | 2350 | |
2351 | 2351 | /** |
@@ -2356,40 +2356,40 @@ discard block |
||
2356 | 2356 | * @param $post_id int $post_id The post ID of the post being saved. |
2357 | 2357 | * @param $post object $post The post object of the post being saved. |
2358 | 2358 | */ |
2359 | -function geodir_update_location_prefix($post_id,$post){ |
|
2360 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){ |
|
2361 | - update_option('geodir_location_prefix',$post->post_name); |
|
2359 | +function geodir_update_location_prefix($post_id, $post) { |
|
2360 | + if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) { |
|
2361 | + update_option('geodir_location_prefix', $post->post_name); |
|
2362 | 2362 | } |
2363 | 2363 | |
2364 | 2364 | } |
2365 | 2365 | |
2366 | -add_action('save_post', 'geodir_update_location_prefix',10,2); |
|
2366 | +add_action('save_post', 'geodir_update_location_prefix', 10, 2); |
|
2367 | 2367 | |
2368 | -add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' ); |
|
2368 | +add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback'); |
|
2369 | 2369 | |
2370 | -function geodir_ga_callback(){ |
|
2370 | +function geodir_ga_callback() { |
|
2371 | 2371 | |
2372 | -if(isset($_REQUEST['code']) && $_REQUEST['code']) { |
|
2372 | +if (isset($_REQUEST['code']) && $_REQUEST['code']) { |
|
2373 | 2373 | $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
2374 | 2374 | $code = "code=".$_REQUEST['code']; |
2375 | 2375 | $grant_type = "&grant_type=authorization_code"; |
2376 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
2376 | + $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback"; |
|
2377 | 2377 | $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
2378 | 2378 | $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
2379 | 2379 | |
2380 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
2380 | + $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret; |
|
2381 | 2381 | |
2382 | 2382 | $response = wp_remote_post($auth_url, array('timeout' => 15)); |
2383 | 2383 | |
2384 | 2384 | //print_r($response); |
2385 | 2385 | |
2386 | - $error_msg = __('Something went wrong','geodirectory'); |
|
2387 | - if(!empty($response['response']['code']) && $response['response']['code']==200){ |
|
2386 | + $error_msg = __('Something went wrong', 'geodirectory'); |
|
2387 | + if (!empty($response['response']['code']) && $response['response']['code'] == 200) { |
|
2388 | 2388 | |
2389 | 2389 | $parts = json_decode($response['body']); |
2390 | 2390 | //print_r($parts); |
2391 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2392 | - else{ |
|
2391 | + if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; } |
|
2392 | + else { |
|
2393 | 2393 | |
2394 | 2394 | update_option('gd_ga_access_token', $parts->access_token); |
2395 | 2395 | update_option('gd_ga_refresh_token', $parts->refresh_token); |
@@ -2398,18 +2398,18 @@ discard block |
||
2398 | 2398 | |
2399 | 2399 | |
2400 | 2400 | } |
2401 | - elseif(!empty($response['response']['code'])) { |
|
2401 | + elseif (!empty($response['response']['code'])) { |
|
2402 | 2402 | $parts = json_decode($response['body']); |
2403 | 2403 | |
2404 | - if(isset($parts->error)){ |
|
2405 | - echo $parts->error.": ".$parts->error_description;exit; |
|
2406 | - }else{ |
|
2407 | - echo $error_msg." - #2";exit; |
|
2404 | + if (isset($parts->error)) { |
|
2405 | + echo $parts->error.": ".$parts->error_description; exit; |
|
2406 | + } else { |
|
2407 | + echo $error_msg." - #2"; exit; |
|
2408 | 2408 | } |
2409 | 2409 | |
2410 | - }else{ |
|
2410 | + } else { |
|
2411 | 2411 | |
2412 | - echo $error_msg." - #3";exit; |
|
2412 | + echo $error_msg." - #3"; exit; |
|
2413 | 2413 | |
2414 | 2414 | } |
2415 | 2415 | } |
@@ -2431,7 +2431,7 @@ discard block |
||
2431 | 2431 | function geodir_uninstall_settings($general_settings) { |
2432 | 2432 | $settings = array(); |
2433 | 2433 | $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory')); |
2434 | - $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' )); |
|
2434 | + $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory')); |
|
2435 | 2435 | |
2436 | 2436 | $plugins = get_plugins(); |
2437 | 2437 | $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array()); |
@@ -2443,7 +2443,7 @@ discard block |
||
2443 | 2443 | if (in_array($plugin_name, $un_plugins)) { |
2444 | 2444 | $settings[] = array( |
2445 | 2445 | 'type' => 'checkbox', |
2446 | - 'id' => 'geodir_un_' . $plugin_name, |
|
2446 | + 'id' => 'geodir_un_'.$plugin_name, |
|
2447 | 2447 | 'name' => $data['Name'], |
2448 | 2448 | 'desc' => __('Remove all data when deleted?', 'geodirectory'), |
2449 | 2449 | 'std' => '0' |
@@ -2477,7 +2477,7 @@ discard block |
||
2477 | 2477 | * @since 1.6.9 |
2478 | 2478 | */ |
2479 | 2479 | function geodir_uninstall_settings_desc() { |
2480 | - echo '<p class="gd-un-settings-desc">' . __('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory') . '</p>'; |
|
2480 | + echo '<p class="gd-un-settings-desc">'.__('Select the plugin(s) for which all data should be completely removed when the plugin is deleted.', 'geodirectory').'</p>'; |
|
2481 | 2481 | } |
2482 | 2482 | add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc'); |
2483 | 2483 | |
@@ -2541,12 +2541,12 @@ discard block |
||
2541 | 2541 | |
2542 | 2542 | |
2543 | 2543 | if ($delete) { |
2544 | - $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>"; |
|
2544 | + $output_str .= "<li><strong>".__('Table dropped, refresh page to reinstall.', 'geodirectory')."</strong></li>"; |
|
2545 | 2545 | ob_start(); |
2546 | 2546 | geodir_diagnose_version_clear(); |
2547 | 2547 | ob_end_clean(); |
2548 | - }else{ |
|
2549 | - $output_str .= "<li><strong>" . __('Something went wrong.', 'geodirectory') . "</strong></li>"; |
|
2548 | + } else { |
|
2549 | + $output_str .= "<li><strong>".__('Something went wrong.', 'geodirectory')."</strong></li>"; |
|
2550 | 2550 | } |
2551 | 2551 | |
2552 | 2552 | if ($is_error_during_diagnose) { |
@@ -2571,9 +2571,9 @@ discard block |
||
2571 | 2571 | * @param object $row The post|taxonomy object. |
2572 | 2572 | * @return array Filtered actions. |
2573 | 2573 | */ |
2574 | -function geodir_disable_quick_edit( $actions = array(), $row = null ) { |
|
2575 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
2576 | - unset( $actions['inline hide-if-no-js'] ); |
|
2574 | +function geodir_disable_quick_edit($actions = array(), $row = null) { |
|
2575 | + if (isset($actions['inline hide-if-no-js'])) { |
|
2576 | + unset($actions['inline hide-if-no-js']); |
|
2577 | 2577 | } |
2578 | 2578 | |
2579 | 2579 | return $actions; |
@@ -2592,26 +2592,26 @@ discard block |
||
2592 | 2592 | function geodir_check_quick_edit() { |
2593 | 2593 | global $pagenow, $current_screen, $gd_cpt_screen; |
2594 | 2594 | |
2595 | - if ( ( $pagenow == 'edit.php' || $pagenow == 'edit-tags.php' ) && !empty( $current_screen->post_type ) ) { |
|
2596 | - if ( empty( $gd_cpt_screen ) ) { |
|
2597 | - if ( in_array( $current_screen->post_type, geodir_get_posttypes() ) ) { |
|
2595 | + if (($pagenow == 'edit.php' || $pagenow == 'edit-tags.php') && !empty($current_screen->post_type)) { |
|
2596 | + if (empty($gd_cpt_screen)) { |
|
2597 | + if (in_array($current_screen->post_type, geodir_get_posttypes())) { |
|
2598 | 2598 | $gd_cpt_screen = 'y'; |
2599 | 2599 | } else { |
2600 | 2600 | $gd_cpt_screen = 'n'; |
2601 | 2601 | } |
2602 | 2602 | } |
2603 | 2603 | |
2604 | - if ( $gd_cpt_screen == 'y' ) { |
|
2605 | - if ( $pagenow == 'edit.php' ) { |
|
2606 | - add_filter( 'post_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2607 | - add_filter( 'page_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2608 | - } elseif ( $pagenow == 'edit-tags.php' && !empty( $current_screen->taxonomy ) ) { |
|
2609 | - add_filter( $current_screen->taxonomy . '_row_actions', 'geodir_disable_quick_edit', 10, 2 ); |
|
2604 | + if ($gd_cpt_screen == 'y') { |
|
2605 | + if ($pagenow == 'edit.php') { |
|
2606 | + add_filter('post_row_actions', 'geodir_disable_quick_edit', 10, 2); |
|
2607 | + add_filter('page_row_actions', 'geodir_disable_quick_edit', 10, 2); |
|
2608 | + } elseif ($pagenow == 'edit-tags.php' && !empty($current_screen->taxonomy)) { |
|
2609 | + add_filter($current_screen->taxonomy.'_row_actions', 'geodir_disable_quick_edit', 10, 2); |
|
2610 | 2610 | } |
2611 | 2611 | } |
2612 | 2612 | } |
2613 | 2613 | } |
2614 | -add_action( 'admin_head', 'geodir_check_quick_edit', 10 ); |
|
2614 | +add_action('admin_head', 'geodir_check_quick_edit', 10); |
|
2615 | 2615 | |
2616 | 2616 | /** |
2617 | 2617 | * Filter the bulk actions for GD CPT. |
@@ -2622,9 +2622,9 @@ discard block |
||
2622 | 2622 | * @param array $actions An array of the available bulk actions. |
2623 | 2623 | * @return array Filtered bulk actions. |
2624 | 2624 | */ |
2625 | -function geodir_filter_bulk_actions( $actions ) { |
|
2626 | - if ( isset( $actions['edit'] ) ) { |
|
2627 | - unset( $actions['edit'] ); |
|
2625 | +function geodir_filter_bulk_actions($actions) { |
|
2626 | + if (isset($actions['edit'])) { |
|
2627 | + unset($actions['edit']); |
|
2628 | 2628 | } |
2629 | 2629 | |
2630 | 2630 | return $actions; |
@@ -2637,15 +2637,15 @@ discard block |
||
2637 | 2637 | * |
2638 | 2638 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference |
2639 | 2639 | */ |
2640 | -function geodir_admin_bar_menu_set_post( $wp_admin_bar ) { |
|
2640 | +function geodir_admin_bar_menu_set_post($wp_admin_bar) { |
|
2641 | 2641 | global $post, $gd_admin_bar_post, $pagenow; |
2642 | 2642 | |
2643 | - if ( $pagenow == 'post.php' && ! empty( $post ) && is_object( $post ) && ! empty( $post->ID ) && ! is_a( $post, 'WP_Post' ) && isset( $post->post_id ) ) { |
|
2643 | + if ($pagenow == 'post.php' && !empty($post) && is_object($post) && !empty($post->ID) && !is_a($post, 'WP_Post') && isset($post->post_id)) { |
|
2644 | 2644 | $gd_admin_bar_post = $post; |
2645 | - $post = get_post( $post->ID ); |
|
2645 | + $post = get_post($post->ID); |
|
2646 | 2646 | } |
2647 | 2647 | } |
2648 | -add_action( 'admin_bar_menu', 'geodir_admin_bar_menu_set_post', 94, 1 ); |
|
2648 | +add_action('admin_bar_menu', 'geodir_admin_bar_menu_set_post', 94, 1); |
|
2649 | 2649 | |
2650 | 2650 | /** |
2651 | 2651 | * Reset $post to original. |
@@ -2655,9 +2655,9 @@ discard block |
||
2655 | 2655 | function geodir_admin_bar_menu_reset_post() { |
2656 | 2656 | global $post, $gd_admin_bar_post; |
2657 | 2657 | |
2658 | - if ( ! empty( $gd_admin_bar_post ) && ! empty( $post ) ) { |
|
2658 | + if (!empty($gd_admin_bar_post) && !empty($post)) { |
|
2659 | 2659 | $post = $gd_admin_bar_post; |
2660 | 2660 | $gd_admin_bar_post = NULL; |
2661 | 2661 | } |
2662 | 2662 | } |
2663 | -add_action( 'wp_after_admin_bar_render', 'geodir_admin_bar_menu_reset_post', 9999 ); |
|
2664 | 2663 | \ No newline at end of file |
2664 | +add_action('wp_after_admin_bar_render', 'geodir_admin_bar_menu_reset_post', 9999); |
|
2665 | 2665 | \ No newline at end of file |