@@ -1844,6 +1844,7 @@ discard block |
||
1844 | 1844 | * @since 1.0.0 |
1845 | 1845 | * @package GeoDirectory |
1846 | 1846 | * @global object $current_user Current user object. |
1847 | + * @param string|null $input |
|
1847 | 1848 | * @return array Returns parsed data as array. |
1848 | 1849 | */ |
1849 | 1850 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") |
@@ -2373,7 +2374,6 @@ discard block |
||
2373 | 2374 | * |
2374 | 2375 | * @since 1.6.9 |
2375 | 2376 | * |
2376 | - * @param array $settings Array of GeoDirectory general settings. |
|
2377 | 2377 | * @return array Array of settings. |
2378 | 2378 | */ |
2379 | 2379 | function geodir_uninstall_settings($general_settings) { |
@@ -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 | |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function geodir_admin_list_columns() |
158 | 158 | { |
159 | - if ($post_types = geodir_get_posttypes()) { |
|
159 | + if ($post_types = geodir_get_posttypes()) { |
|
160 | 160 | |
161 | - foreach ($post_types as $post_type): |
|
162 | - add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100); |
|
163 | - //Filter-Payment-Manager to show Package |
|
164 | - add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2); |
|
161 | + foreach ($post_types as $post_type): |
|
162 | + add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100); |
|
163 | + //Filter-Payment-Manager to show Package |
|
164 | + add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2); |
|
165 | 165 | |
166 | - add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns'); |
|
167 | - endforeach; |
|
168 | - } |
|
166 | + add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns'); |
|
167 | + endforeach; |
|
168 | + } |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | */ |
179 | 179 | function geodir_default_admin_main_tabs($tabs) |
180 | 180 | { |
181 | - return $tabs = array( |
|
182 | - 'general_settings' => array('label' => __('General', 'geodirectory')), |
|
183 | - 'design_settings' => array('label' => __('Design', 'geodirectory')), |
|
184 | - 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')), |
|
185 | - 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')), |
|
186 | - 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')), |
|
187 | - 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')), |
|
188 | - |
|
189 | - ); |
|
181 | + return $tabs = array( |
|
182 | + 'general_settings' => array('label' => __('General', 'geodirectory')), |
|
183 | + 'design_settings' => array('label' => __('Design', 'geodirectory')), |
|
184 | + 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')), |
|
185 | + 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')), |
|
186 | + 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')), |
|
187 | + 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')), |
|
188 | + |
|
189 | + ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | add_action('do_meta_boxes', 'geodir_remove_image_box'); |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | */ |
200 | 200 | function geodir_remove_image_box() |
201 | 201 | { |
202 | - global $post; |
|
202 | + global $post; |
|
203 | 203 | |
204 | - $geodir_posttypes = geodir_get_posttypes(); |
|
204 | + $geodir_posttypes = geodir_get_posttypes(); |
|
205 | 205 | |
206 | - if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
206 | + if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
207 | 207 | |
208 | - remove_meta_box('postimagediv', $post->post_type, 'side'); |
|
209 | - remove_meta_box('revisionsdiv', $post->post_type, 'normal'); |
|
208 | + remove_meta_box('postimagediv', $post->post_type, 'side'); |
|
209 | + remove_meta_box('revisionsdiv', $post->post_type, 'normal'); |
|
210 | 210 | |
211 | - endif; |
|
211 | + endif; |
|
212 | 212 | |
213 | 213 | } |
214 | 214 | |
@@ -223,27 +223,27 @@ discard block |
||
223 | 223 | */ |
224 | 224 | function geodir_meta_box_add() |
225 | 225 | { |
226 | - global $post; |
|
226 | + global $post; |
|
227 | 227 | |
228 | - $geodir_post_types = geodir_get_posttypes('array'); |
|
229 | - $geodir_posttypes = array_keys($geodir_post_types); |
|
228 | + $geodir_post_types = geodir_get_posttypes('array'); |
|
229 | + $geodir_posttypes = array_keys($geodir_post_types); |
|
230 | 230 | |
231 | - if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
231 | + if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
232 | 232 | |
233 | - $geodir_posttype = $post->post_type; |
|
234 | - $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory'); |
|
235 | - $post_typename = geodir_ucwords($post_typename); |
|
233 | + $geodir_posttype = $post->post_type; |
|
234 | + $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory'); |
|
235 | + $post_typename = geodir_ucwords($post_typename); |
|
236 | 236 | |
237 | - // Filter-Payment-Manager |
|
237 | + // Filter-Payment-Manager |
|
238 | 238 | |
239 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
239 | + add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
240 | 240 | |
241 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
241 | + add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
242 | 242 | |
243 | - // no need of this box as all fields moved to main information box |
|
244 | - //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' ); |
|
243 | + // no need of this box as all fields moved to main information box |
|
244 | + //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' ); |
|
245 | 245 | |
246 | - endif; |
|
246 | + endif; |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | |
@@ -267,23 +267,23 @@ discard block |
||
267 | 267 | function geodir_hide_post_taxonomy_meta_boxes() |
268 | 268 | { |
269 | 269 | |
270 | - $geodir_post_types = get_option('geodir_post_types'); |
|
270 | + $geodir_post_types = get_option('geodir_post_types'); |
|
271 | 271 | |
272 | - if (!empty($geodir_post_types)) { |
|
273 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) { |
|
272 | + if (!empty($geodir_post_types)) { |
|
273 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) { |
|
274 | 274 | |
275 | - $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
275 | + $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
276 | 276 | |
277 | - if(!empty($gd_taxonomy)) { |
|
278 | - foreach ($gd_taxonomy as $tax) { |
|
277 | + if(!empty($gd_taxonomy)) { |
|
278 | + foreach ($gd_taxonomy as $tax) { |
|
279 | 279 | |
280 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
280 | + remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
281 | 281 | |
282 | - } |
|
283 | - } |
|
282 | + } |
|
283 | + } |
|
284 | 284 | |
285 | - } |
|
286 | - } |
|
285 | + } |
|
286 | + } |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict'); |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | */ |
298 | 298 | function geodir_add_listing_map_restrict($map_restirct) |
299 | 299 | { |
300 | - if (is_admin()) { |
|
301 | - if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') { |
|
302 | - $map_restirct = false; |
|
303 | - } |
|
304 | - } |
|
305 | - return $map_restirct; |
|
300 | + if (is_admin()) { |
|
301 | + if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') { |
|
302 | + $map_restirct = false; |
|
303 | + } |
|
304 | + } |
|
305 | + return $map_restirct; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -321,16 +321,16 @@ discard block |
||
321 | 321 | function geodir_enable_editor_on_notifications($notification) |
322 | 322 | { |
323 | 323 | |
324 | - if (!empty($notification) && get_option('geodir_tiny_editor') == '1') { |
|
324 | + if (!empty($notification) && get_option('geodir_tiny_editor') == '1') { |
|
325 | 325 | |
326 | - foreach ($notification as $key => $value) { |
|
327 | - if ($value['type'] == 'textarea') |
|
328 | - $notification[$key]['type'] = 'editor'; |
|
329 | - } |
|
326 | + foreach ($notification as $key => $value) { |
|
327 | + if ($value['type'] == 'textarea') |
|
328 | + $notification[$key]['type'] = 'editor'; |
|
329 | + } |
|
330 | 330 | |
331 | - } |
|
331 | + } |
|
332 | 332 | |
333 | - return $notification; |
|
333 | + return $notification; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -347,16 +347,16 @@ discard block |
||
347 | 347 | function geodir_enable_editor_on_design_settings($design_setting) |
348 | 348 | { |
349 | 349 | |
350 | - if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') { |
|
350 | + if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') { |
|
351 | 351 | |
352 | - foreach ($design_setting as $key => $value) { |
|
353 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
354 | - $design_setting[$key]['type'] = 'editor'; |
|
355 | - } |
|
352 | + foreach ($design_setting as $key => $value) { |
|
353 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
354 | + $design_setting[$key]['type'] = 'editor'; |
|
355 | + } |
|
356 | 356 | |
357 | - } |
|
357 | + } |
|
358 | 358 | |
359 | - return $design_setting; |
|
359 | + return $design_setting; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /* ----------- START MANAGE CUSTOM FIELDS ---------------- */ |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom'); |
365 | 365 | |
366 | 366 | function geodir_manage_available_fields_predefined($sub_tab){ |
367 | - if($sub_tab=='custom_fields'){ |
|
368 | - geodir_custom_available_fields('predefined'); |
|
369 | - } |
|
367 | + if($sub_tab=='custom_fields'){ |
|
368 | + geodir_custom_available_fields('predefined'); |
|
369 | + } |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | function geodir_manage_available_fields_custom($sub_tab){ |
373 | - if($sub_tab=='custom_fields'){ |
|
374 | - geodir_custom_available_fields('custom'); |
|
375 | - } |
|
373 | + if($sub_tab=='custom_fields'){ |
|
374 | + geodir_custom_available_fields('custom'); |
|
375 | + } |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -391,16 +391,16 @@ discard block |
||
391 | 391 | function geodir_manage_available_fields($sub_tab) |
392 | 392 | { |
393 | 393 | |
394 | - switch ($sub_tab) { |
|
395 | - case 'custom_fields': |
|
396 | - geodir_custom_available_fields(); |
|
397 | - break; |
|
394 | + switch ($sub_tab) { |
|
395 | + case 'custom_fields': |
|
396 | + geodir_custom_available_fields(); |
|
397 | + break; |
|
398 | 398 | |
399 | - case 'sorting_options': |
|
400 | - geodir_sorting_options_available_fields(); |
|
401 | - break; |
|
399 | + case 'sorting_options': |
|
400 | + geodir_sorting_options_available_fields(); |
|
401 | + break; |
|
402 | 402 | |
403 | - } |
|
403 | + } |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -416,16 +416,16 @@ discard block |
||
416 | 416 | function geodir_manage_selected_fields($sub_tab) |
417 | 417 | { |
418 | 418 | |
419 | - switch ($sub_tab) { |
|
420 | - case 'custom_fields': |
|
421 | - geodir_custom_selected_fields(); |
|
422 | - break; |
|
419 | + switch ($sub_tab) { |
|
420 | + case 'custom_fields': |
|
421 | + geodir_custom_selected_fields(); |
|
422 | + break; |
|
423 | 423 | |
424 | - case 'sorting_options': |
|
425 | - geodir_sorting_options_selected_fields(); |
|
426 | - break; |
|
424 | + case 'sorting_options': |
|
425 | + geodir_sorting_options_selected_fields(); |
|
426 | + break; |
|
427 | 427 | |
428 | - } |
|
428 | + } |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -437,52 +437,52 @@ discard block |
||
437 | 437 | */ |
438 | 438 | function geodir_sorting_options_available_fields() |
439 | 439 | { |
440 | - global $wpdb; |
|
441 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
442 | - ?> |
|
440 | + global $wpdb; |
|
441 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
442 | + ?> |
|
443 | 443 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
444 | 444 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
445 | 445 | <ul> |
446 | 446 | <?php |
447 | - $sort_options = geodir_get_custom_sort_options($listing_type); |
|
447 | + $sort_options = geodir_get_custom_sort_options($listing_type); |
|
448 | 448 | |
449 | - foreach ($sort_options as $key => $val) { |
|
450 | - $val = stripslashes_deep($val); // strip slashes |
|
451 | - |
|
452 | - $check_html_variable = $wpdb->get_var( |
|
453 | - $wpdb->prepare( |
|
454 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
455 | - array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
456 | - ) |
|
457 | - ); |
|
449 | + foreach ($sort_options as $key => $val) { |
|
450 | + $val = stripslashes_deep($val); // strip slashes |
|
451 | + |
|
452 | + $check_html_variable = $wpdb->get_var( |
|
453 | + $wpdb->prepare( |
|
454 | + "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
455 | + array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
456 | + ) |
|
457 | + ); |
|
458 | 458 | |
459 | - $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
460 | - ?> |
|
459 | + $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
460 | + ?> |
|
461 | 461 | |
462 | 462 | <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> |
463 | 463 | <?php |
464 | - if(isset($val['description']) && $val['description']){ |
|
465 | - echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
|
466 | - }?> |
|
464 | + if(isset($val['description']) && $val['description']){ |
|
465 | + echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
|
466 | + }?> |
|
467 | 467 | |
468 | 468 | <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'];?>" |
469 | 469 | title="<?php echo $val['site_title'];?>" |
470 | 470 | class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
471 | 471 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) { |
472 | - echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
|
473 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
474 | - echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>'; |
|
475 | - }else{ |
|
476 | - echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
477 | - }?> |
|
472 | + echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
|
473 | + }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
474 | + echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>'; |
|
475 | + }else{ |
|
476 | + echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
477 | + }?> |
|
478 | 478 | <?php echo $val['site_title'];?> |
479 | 479 | </a> |
480 | 480 | </li> |
481 | 481 | |
482 | 482 | |
483 | 483 | <?php |
484 | - } |
|
485 | - ?> |
|
484 | + } |
|
485 | + ?> |
|
486 | 486 | </ul> |
487 | 487 | <?php |
488 | 488 | } |
@@ -496,28 +496,28 @@ discard block |
||
496 | 496 | */ |
497 | 497 | function geodir_sorting_options_selected_fields() |
498 | 498 | { |
499 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
500 | - ?> |
|
499 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
500 | + ?> |
|
501 | 501 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
502 | 502 | <ul class="core"> |
503 | 503 | <?php |
504 | - global $wpdb; |
|
504 | + global $wpdb; |
|
505 | 505 | |
506 | - $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))); |
|
506 | + $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))); |
|
507 | 507 | |
508 | - if (!empty($fields)) { |
|
509 | - foreach ($fields as $field) { |
|
510 | - //$result_str = $field->id; |
|
511 | - $result_str = $field; |
|
512 | - $field_type = $field->field_type; |
|
513 | - $field_ins_upd = 'display'; |
|
508 | + if (!empty($fields)) { |
|
509 | + foreach ($fields as $field) { |
|
510 | + //$result_str = $field->id; |
|
511 | + $result_str = $field; |
|
512 | + $field_type = $field->field_type; |
|
513 | + $field_ins_upd = 'display'; |
|
514 | 514 | |
515 | - $default = false; |
|
515 | + $default = false; |
|
516 | 516 | |
517 | - geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
518 | - } |
|
519 | - } |
|
520 | - ?> |
|
517 | + geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
518 | + } |
|
519 | + } |
|
520 | + ?> |
|
521 | 521 | </ul> |
522 | 522 | <?php |
523 | 523 | } |
@@ -530,12 +530,12 @@ discard block |
||
530 | 530 | */ |
531 | 531 | function geodir_custom_fields_custom($post_type=''){ |
532 | 532 | |
533 | - $custom_fields = array(); |
|
533 | + $custom_fields = array(); |
|
534 | 534 | |
535 | - /** |
|
536 | - * @see `geodir_custom_fields` |
|
537 | - */ |
|
538 | - return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type); |
|
535 | + /** |
|
536 | + * @see `geodir_custom_fields` |
|
537 | + */ |
|
538 | + return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -548,140 +548,140 @@ discard block |
||
548 | 548 | */ |
549 | 549 | function geodir_custom_fields($post_type=''){ |
550 | 550 | |
551 | - $custom_fields = array( |
|
552 | - 'text' => array( |
|
553 | - 'field_type' => 'text', |
|
554 | - 'class' => 'gd-text', |
|
555 | - 'icon' => 'fa fa-minus', |
|
556 | - 'name' => __('Text', 'geodirectory'), |
|
557 | - 'description' => __('Add any sort of text field, text or numbers', 'geodirectory') |
|
558 | - ), |
|
559 | - 'datepicker' => array( |
|
560 | - 'field_type' => 'datepicker', |
|
561 | - 'class' => 'gd-datepicker', |
|
562 | - 'icon' => 'fa fa-calendar', |
|
563 | - 'name' => __('Date', 'geodirectory'), |
|
564 | - 'description' => __('Adds a date picker.', 'geodirectory') |
|
565 | - ), |
|
566 | - 'textarea' => array( |
|
567 | - 'field_type' => 'textarea', |
|
568 | - 'class' => 'gd-textarea', |
|
569 | - 'icon' => 'fa fa-bars', |
|
570 | - 'name' => __('Textarea', 'geodirectory'), |
|
571 | - 'description' => __('Adds a textarea', 'geodirectory') |
|
572 | - ), |
|
573 | - 'time' => array( |
|
574 | - 'field_type' => 'time', |
|
575 | - 'class' => 'gd-time', |
|
576 | - 'icon' => 'fa fa-clock-o', |
|
577 | - 'name' => __('Time', 'geodirectory'), |
|
578 | - 'description' => __('Adds a time picker', 'geodirectory') |
|
579 | - ), |
|
580 | - 'checkbox' => array( |
|
581 | - 'field_type' => 'checkbox', |
|
582 | - 'class' => 'gd-checkbox', |
|
583 | - 'icon' => 'fa fa-check-square-o', |
|
584 | - 'name' => __('Checkbox', 'geodirectory'), |
|
585 | - 'description' => __('Adds a checkbox', 'geodirectory') |
|
586 | - ), |
|
587 | - 'phone' => array( |
|
588 | - 'field_type' => 'phone', |
|
589 | - 'class' => 'gd-phone', |
|
590 | - 'icon' => 'fa fa-phone', |
|
591 | - 'name' => __('Phone', 'geodirectory'), |
|
592 | - 'description' => __('Adds a phone input', 'geodirectory') |
|
593 | - ), |
|
594 | - 'radio' => array( |
|
595 | - 'field_type' => 'radio', |
|
596 | - 'class' => 'gd-radio', |
|
597 | - 'icon' => 'fa fa-dot-circle-o', |
|
598 | - 'name' => __('Radio', 'geodirectory'), |
|
599 | - 'description' => __('Adds a radio input', 'geodirectory') |
|
600 | - ), |
|
601 | - 'email' => array( |
|
602 | - 'field_type' => 'email', |
|
603 | - 'class' => 'gd-email', |
|
604 | - 'icon' => 'fa fa-envelope-o', |
|
605 | - 'name' => __('Email', 'geodirectory'), |
|
606 | - 'description' => __('Adds a email input', 'geodirectory') |
|
607 | - ), |
|
608 | - 'select' => array( |
|
609 | - 'field_type' => 'select', |
|
610 | - 'class' => 'gd-select', |
|
611 | - 'icon' => 'fa fa-caret-square-o-down', |
|
612 | - 'name' => __('Select', 'geodirectory'), |
|
613 | - 'description' => __('Adds a select input', 'geodirectory') |
|
614 | - ), |
|
615 | - 'multiselect' => array( |
|
616 | - 'field_type' => 'multiselect', |
|
617 | - 'class' => 'gd-multiselect', |
|
618 | - 'icon' => 'fa fa-caret-square-o-down', |
|
619 | - 'name' => __('Multi Select', 'geodirectory'), |
|
620 | - 'description' => __('Adds a multiselect input', 'geodirectory') |
|
621 | - ), |
|
622 | - 'url' => array( |
|
623 | - 'field_type' => 'url', |
|
624 | - 'class' => 'gd-url', |
|
625 | - 'icon' => 'fa fa-link', |
|
626 | - 'name' => __('URL', 'geodirectory'), |
|
627 | - 'description' => __('Adds a url input', 'geodirectory') |
|
628 | - ), |
|
629 | - 'html' => array( |
|
630 | - 'field_type' => 'html', |
|
631 | - 'class' => 'gd-html', |
|
632 | - 'icon' => 'fa fa-code', |
|
633 | - 'name' => __('HTML', 'geodirectory'), |
|
634 | - 'description' => __('Adds a html input textarea', 'geodirectory') |
|
635 | - ), |
|
636 | - 'file' => array( |
|
637 | - 'field_type' => 'file', |
|
638 | - 'class' => 'gd-file', |
|
639 | - 'icon' => 'fa fa-file', |
|
640 | - 'name' => __('File Upload', 'geodirectory'), |
|
641 | - 'description' => __('Adds a file input', 'geodirectory') |
|
642 | - ) |
|
643 | - ); |
|
644 | - |
|
645 | - /** |
|
646 | - * Filter the custom fields array to be able to add or remove items. |
|
647 | - * |
|
648 | - * @since 1.6.6 |
|
649 | - * |
|
650 | - * @param array $custom_fields { |
|
651 | - * The custom fields array to be filtered. |
|
652 | - * |
|
653 | - * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. |
|
654 | - * @type string $class The class for the field in backend. |
|
655 | - * @type string $icon Can be font-awesome class name or icon image url. |
|
656 | - * @type string $name The name of the field. |
|
657 | - * @type string $description A short description about the field. |
|
658 | - * @type array $defaults { |
|
659 | - * Optional. Used to set the default value of the field. |
|
660 | - * |
|
661 | - * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE |
|
662 | - * @type int decimal_point limit if using FLOAT data_type |
|
663 | - * @type string admin_title The admin title for the field. |
|
664 | - * @type string site_title This will be the title for the field on the frontend. |
|
665 | - * @type string admin_desc This will be shown below the field on the add listing form. |
|
666 | - * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. |
|
667 | - * @type bool is_active If false the field will not be displayed anywhere. |
|
668 | - * @type bool for_admin_use If true then only site admin can see and edit this field. |
|
669 | - * @type string default_value The default value for the input on the add listing page. |
|
670 | - * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] |
|
671 | - * @type bool is_required If true the field will be required on the add listing page. |
|
672 | - * @type string option_values The option values for select and multiselect only |
|
673 | - * @type string validation_pattern HTML5 validation pattern (text input only by default). |
|
674 | - * @type string validation_msg HTML5 validation message (text input only by default). |
|
675 | - * @type string required_msg Required warning message. |
|
676 | - * @type string field_icon Icon url or font awesome class. |
|
677 | - * @type string css_class Field custom css class for field custom style. |
|
678 | - * @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. |
|
679 | - * @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) |
|
680 | - * } |
|
681 | - * } |
|
682 | - * @param string $post_type The post type requested. |
|
683 | - */ |
|
684 | - return apply_filters('geodir_custom_fields',$custom_fields,$post_type); |
|
551 | + $custom_fields = array( |
|
552 | + 'text' => array( |
|
553 | + 'field_type' => 'text', |
|
554 | + 'class' => 'gd-text', |
|
555 | + 'icon' => 'fa fa-minus', |
|
556 | + 'name' => __('Text', 'geodirectory'), |
|
557 | + 'description' => __('Add any sort of text field, text or numbers', 'geodirectory') |
|
558 | + ), |
|
559 | + 'datepicker' => array( |
|
560 | + 'field_type' => 'datepicker', |
|
561 | + 'class' => 'gd-datepicker', |
|
562 | + 'icon' => 'fa fa-calendar', |
|
563 | + 'name' => __('Date', 'geodirectory'), |
|
564 | + 'description' => __('Adds a date picker.', 'geodirectory') |
|
565 | + ), |
|
566 | + 'textarea' => array( |
|
567 | + 'field_type' => 'textarea', |
|
568 | + 'class' => 'gd-textarea', |
|
569 | + 'icon' => 'fa fa-bars', |
|
570 | + 'name' => __('Textarea', 'geodirectory'), |
|
571 | + 'description' => __('Adds a textarea', 'geodirectory') |
|
572 | + ), |
|
573 | + 'time' => array( |
|
574 | + 'field_type' => 'time', |
|
575 | + 'class' => 'gd-time', |
|
576 | + 'icon' => 'fa fa-clock-o', |
|
577 | + 'name' => __('Time', 'geodirectory'), |
|
578 | + 'description' => __('Adds a time picker', 'geodirectory') |
|
579 | + ), |
|
580 | + 'checkbox' => array( |
|
581 | + 'field_type' => 'checkbox', |
|
582 | + 'class' => 'gd-checkbox', |
|
583 | + 'icon' => 'fa fa-check-square-o', |
|
584 | + 'name' => __('Checkbox', 'geodirectory'), |
|
585 | + 'description' => __('Adds a checkbox', 'geodirectory') |
|
586 | + ), |
|
587 | + 'phone' => array( |
|
588 | + 'field_type' => 'phone', |
|
589 | + 'class' => 'gd-phone', |
|
590 | + 'icon' => 'fa fa-phone', |
|
591 | + 'name' => __('Phone', 'geodirectory'), |
|
592 | + 'description' => __('Adds a phone input', 'geodirectory') |
|
593 | + ), |
|
594 | + 'radio' => array( |
|
595 | + 'field_type' => 'radio', |
|
596 | + 'class' => 'gd-radio', |
|
597 | + 'icon' => 'fa fa-dot-circle-o', |
|
598 | + 'name' => __('Radio', 'geodirectory'), |
|
599 | + 'description' => __('Adds a radio input', 'geodirectory') |
|
600 | + ), |
|
601 | + 'email' => array( |
|
602 | + 'field_type' => 'email', |
|
603 | + 'class' => 'gd-email', |
|
604 | + 'icon' => 'fa fa-envelope-o', |
|
605 | + 'name' => __('Email', 'geodirectory'), |
|
606 | + 'description' => __('Adds a email input', 'geodirectory') |
|
607 | + ), |
|
608 | + 'select' => array( |
|
609 | + 'field_type' => 'select', |
|
610 | + 'class' => 'gd-select', |
|
611 | + 'icon' => 'fa fa-caret-square-o-down', |
|
612 | + 'name' => __('Select', 'geodirectory'), |
|
613 | + 'description' => __('Adds a select input', 'geodirectory') |
|
614 | + ), |
|
615 | + 'multiselect' => array( |
|
616 | + 'field_type' => 'multiselect', |
|
617 | + 'class' => 'gd-multiselect', |
|
618 | + 'icon' => 'fa fa-caret-square-o-down', |
|
619 | + 'name' => __('Multi Select', 'geodirectory'), |
|
620 | + 'description' => __('Adds a multiselect input', 'geodirectory') |
|
621 | + ), |
|
622 | + 'url' => array( |
|
623 | + 'field_type' => 'url', |
|
624 | + 'class' => 'gd-url', |
|
625 | + 'icon' => 'fa fa-link', |
|
626 | + 'name' => __('URL', 'geodirectory'), |
|
627 | + 'description' => __('Adds a url input', 'geodirectory') |
|
628 | + ), |
|
629 | + 'html' => array( |
|
630 | + 'field_type' => 'html', |
|
631 | + 'class' => 'gd-html', |
|
632 | + 'icon' => 'fa fa-code', |
|
633 | + 'name' => __('HTML', 'geodirectory'), |
|
634 | + 'description' => __('Adds a html input textarea', 'geodirectory') |
|
635 | + ), |
|
636 | + 'file' => array( |
|
637 | + 'field_type' => 'file', |
|
638 | + 'class' => 'gd-file', |
|
639 | + 'icon' => 'fa fa-file', |
|
640 | + 'name' => __('File Upload', 'geodirectory'), |
|
641 | + 'description' => __('Adds a file input', 'geodirectory') |
|
642 | + ) |
|
643 | + ); |
|
644 | + |
|
645 | + /** |
|
646 | + * Filter the custom fields array to be able to add or remove items. |
|
647 | + * |
|
648 | + * @since 1.6.6 |
|
649 | + * |
|
650 | + * @param array $custom_fields { |
|
651 | + * The custom fields array to be filtered. |
|
652 | + * |
|
653 | + * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. |
|
654 | + * @type string $class The class for the field in backend. |
|
655 | + * @type string $icon Can be font-awesome class name or icon image url. |
|
656 | + * @type string $name The name of the field. |
|
657 | + * @type string $description A short description about the field. |
|
658 | + * @type array $defaults { |
|
659 | + * Optional. Used to set the default value of the field. |
|
660 | + * |
|
661 | + * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE |
|
662 | + * @type int decimal_point limit if using FLOAT data_type |
|
663 | + * @type string admin_title The admin title for the field. |
|
664 | + * @type string site_title This will be the title for the field on the frontend. |
|
665 | + * @type string admin_desc This will be shown below the field on the add listing form. |
|
666 | + * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. |
|
667 | + * @type bool is_active If false the field will not be displayed anywhere. |
|
668 | + * @type bool for_admin_use If true then only site admin can see and edit this field. |
|
669 | + * @type string default_value The default value for the input on the add listing page. |
|
670 | + * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] |
|
671 | + * @type bool is_required If true the field will be required on the add listing page. |
|
672 | + * @type string option_values The option values for select and multiselect only |
|
673 | + * @type string validation_pattern HTML5 validation pattern (text input only by default). |
|
674 | + * @type string validation_msg HTML5 validation message (text input only by default). |
|
675 | + * @type string required_msg Required warning message. |
|
676 | + * @type string field_icon Icon url or font awesome class. |
|
677 | + * @type string css_class Field custom css class for field custom style. |
|
678 | + * @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. |
|
679 | + * @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) |
|
680 | + * } |
|
681 | + * } |
|
682 | + * @param string $post_type The post type requested. |
|
683 | + */ |
|
684 | + return apply_filters('geodir_custom_fields',$custom_fields,$post_type); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
@@ -694,19 +694,19 @@ discard block |
||
694 | 694 | */ |
695 | 695 | function geodir_custom_available_fields($type='') |
696 | 696 | { |
697 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
698 | - ?> |
|
697 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
698 | + ?> |
|
699 | 699 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
700 | 700 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> |
701 | 701 | |
702 | 702 | <?php |
703 | - if($type=='predefined'){ |
|
704 | - $cfs = geodir_custom_fields_predefined($listing_type); |
|
705 | - }elseif($type=='custom'){ |
|
706 | - $cfs = geodir_custom_fields_custom($listing_type); |
|
707 | - }else{ |
|
708 | - $cfs = geodir_custom_fields($listing_type); |
|
709 | - ?> |
|
703 | + if($type=='predefined'){ |
|
704 | + $cfs = geodir_custom_fields_predefined($listing_type); |
|
705 | + }elseif($type=='custom'){ |
|
706 | + $cfs = geodir_custom_fields_custom($listing_type); |
|
707 | + }else{ |
|
708 | + $cfs = geodir_custom_fields($listing_type); |
|
709 | + ?> |
|
710 | 710 | <ul class="full gd-cf-tooltip-wrap"> |
711 | 711 | <li> |
712 | 712 | <div class="gdcf-tooltip"> |
@@ -727,18 +727,18 @@ discard block |
||
727 | 727 | </ul> |
728 | 728 | |
729 | 729 | <?php |
730 | - } |
|
730 | + } |
|
731 | 731 | |
732 | - if(!empty($cfs)) { |
|
733 | - echo '<ul>'; |
|
734 | - foreach ( $cfs as $id => $cf ) { |
|
735 | - ?> |
|
732 | + if(!empty($cfs)) { |
|
733 | + echo '<ul>'; |
|
734 | + foreach ( $cfs as $id => $cf ) { |
|
735 | + ?> |
|
736 | 736 | |
737 | 737 | <li class="gd-cf-tooltip-wrap"> |
738 | 738 | <?php |
739 | - if ( isset( $cf['description'] ) && $cf['description'] ) { |
|
740 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
741 | - } ?> |
|
739 | + if ( isset( $cf['description'] ) && $cf['description'] ) { |
|
740 | + echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
741 | + } ?> |
|
742 | 742 | |
743 | 743 | <a id="gd-<?php echo $id; ?>" |
744 | 744 | data-field-custom-type="<?php echo $type; ?>" |
@@ -748,21 +748,21 @@ discard block |
||
748 | 748 | href="javascript:void(0);"> |
749 | 749 | |
750 | 750 | <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) { |
751 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
752 | - } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) { |
|
753 | - echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>'; |
|
754 | - } else { |
|
755 | - echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
756 | - } ?> |
|
751 | + echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
752 | + } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) { |
|
753 | + echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>'; |
|
754 | + } else { |
|
755 | + echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
756 | + } ?> |
|
757 | 757 | <?php echo $cf['name']; ?> |
758 | 758 | </a> |
759 | 759 | </li> |
760 | 760 | <?php |
761 | - } |
|
762 | - }else{ |
|
763 | - _e('There are no custom fields here yet.', 'geodirectory'); |
|
764 | - } |
|
765 | - ?> |
|
761 | + } |
|
762 | + }else{ |
|
763 | + _e('There are no custom fields here yet.', 'geodirectory'); |
|
764 | + } |
|
765 | + ?> |
|
766 | 766 | |
767 | 767 | |
768 | 768 | </ul> |
@@ -781,26 +781,26 @@ discard block |
||
781 | 781 | */ |
782 | 782 | function geodir_custom_selected_fields() |
783 | 783 | { |
784 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
785 | - ?> |
|
784 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
785 | + ?> |
|
786 | 786 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
787 | 787 | <ul class="core"> |
788 | 788 | <?php |
789 | - global $wpdb; |
|
790 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
791 | - |
|
792 | - if (!empty($fields)) { |
|
793 | - foreach ($fields as $field) { |
|
794 | - //$result_str = $field->id; |
|
795 | - $result_str = $field; |
|
796 | - $field_type = $field->field_type; |
|
797 | - $field_type_key = $field->field_type_key; |
|
798 | - $field_ins_upd = 'display'; |
|
799 | - |
|
800 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
801 | - } |
|
802 | - } |
|
803 | - ?></ul> |
|
789 | + global $wpdb; |
|
790 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
791 | + |
|
792 | + if (!empty($fields)) { |
|
793 | + foreach ($fields as $field) { |
|
794 | + //$result_str = $field->id; |
|
795 | + $result_str = $field; |
|
796 | + $field_type = $field->field_type; |
|
797 | + $field_type_key = $field->field_type_key; |
|
798 | + $field_ins_upd = 'display'; |
|
799 | + |
|
800 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
801 | + } |
|
802 | + } |
|
803 | + ?></ul> |
|
804 | 804 | <?php |
805 | 805 | |
806 | 806 | } |
@@ -819,16 +819,16 @@ discard block |
||
819 | 819 | function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type) |
820 | 820 | { |
821 | 821 | |
822 | - switch ($sub_tab) { |
|
823 | - case 'custom_fields': |
|
824 | - $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
825 | - break; |
|
822 | + switch ($sub_tab) { |
|
823 | + case 'custom_fields': |
|
824 | + $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
825 | + break; |
|
826 | 826 | |
827 | - case 'sorting_options': |
|
828 | - $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
829 | - break; |
|
830 | - } |
|
831 | - return $heading; |
|
827 | + case 'sorting_options': |
|
828 | + $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
829 | + break; |
|
830 | + } |
|
831 | + return $heading; |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | |
@@ -846,16 +846,16 @@ discard block |
||
846 | 846 | function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type) |
847 | 847 | { |
848 | 848 | |
849 | - switch ($sub_tab) { |
|
850 | - case 'custom_fields': |
|
851 | - $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
852 | - break; |
|
849 | + switch ($sub_tab) { |
|
850 | + case 'custom_fields': |
|
851 | + $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
852 | + break; |
|
853 | 853 | |
854 | - case 'sorting_options': |
|
855 | - $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
856 | - break; |
|
857 | - } |
|
858 | - return $heading; |
|
854 | + case 'sorting_options': |
|
855 | + $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
856 | + break; |
|
857 | + } |
|
858 | + return $heading; |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
@@ -873,16 +873,16 @@ discard block |
||
873 | 873 | function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type) |
874 | 874 | { |
875 | 875 | |
876 | - switch ($sub_tab) { |
|
877 | - case 'custom_fields': |
|
878 | - $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)); |
|
879 | - break; |
|
876 | + switch ($sub_tab) { |
|
877 | + case 'custom_fields': |
|
878 | + $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)); |
|
879 | + break; |
|
880 | 880 | |
881 | - case 'sorting_options': |
|
882 | - $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
883 | - break; |
|
884 | - } |
|
885 | - return $note; |
|
881 | + case 'sorting_options': |
|
882 | + $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
883 | + break; |
|
884 | + } |
|
885 | + return $note; |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | |
@@ -900,16 +900,16 @@ discard block |
||
900 | 900 | function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type) |
901 | 901 | { |
902 | 902 | |
903 | - switch ($sub_tab) { |
|
904 | - case 'custom_fields': |
|
905 | - $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
906 | - break; |
|
903 | + switch ($sub_tab) { |
|
904 | + case 'custom_fields': |
|
905 | + $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
906 | + break; |
|
907 | 907 | |
908 | - case 'sorting_options': |
|
909 | - $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)); |
|
910 | - break; |
|
911 | - } |
|
912 | - return $heading; |
|
908 | + case 'sorting_options': |
|
909 | + $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)); |
|
910 | + break; |
|
911 | + } |
|
912 | + return $heading; |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | |
@@ -927,16 +927,16 @@ discard block |
||
927 | 927 | function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type) |
928 | 928 | { |
929 | 929 | |
930 | - switch ($sub_tab) { |
|
931 | - case 'custom_fields': |
|
932 | - $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)); |
|
933 | - break; |
|
930 | + switch ($sub_tab) { |
|
931 | + case 'custom_fields': |
|
932 | + $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)); |
|
933 | + break; |
|
934 | 934 | |
935 | - case 'sorting_options': |
|
936 | - $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
937 | - break; |
|
938 | - } |
|
939 | - return $note; |
|
935 | + case 'sorting_options': |
|
936 | + $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true)); |
|
937 | + break; |
|
938 | + } |
|
939 | + return $note; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | |
@@ -952,16 +952,16 @@ discard block |
||
952 | 952 | */ |
953 | 953 | function geodir_remove_unnecessary_fields() |
954 | 954 | { |
955 | - global $wpdb, $plugin_prefix; |
|
955 | + global $wpdb, $plugin_prefix; |
|
956 | 956 | |
957 | - if (!get_option('geodir_remove_unnecessary_fields')) { |
|
957 | + if (!get_option('geodir_remove_unnecessary_fields')) { |
|
958 | 958 | |
959 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
960 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
959 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
960 | + $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
961 | 961 | |
962 | - update_option('geodir_remove_unnecessary_fields', '1'); |
|
962 | + update_option('geodir_remove_unnecessary_fields', '1'); |
|
963 | 963 | |
964 | - } |
|
964 | + } |
|
965 | 965 | |
966 | 966 | } |
967 | 967 | |
@@ -979,28 +979,28 @@ discard block |
||
979 | 979 | */ |
980 | 980 | function geodir_admin_ajax_handler() |
981 | 981 | { |
982 | - if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') { |
|
983 | - $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
984 | - $diagnose_this = ""; |
|
985 | - switch ($geodir_admin_ajax_action) { |
|
986 | - case 'diagnosis' : |
|
987 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
988 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
989 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
990 | - |
|
991 | - } |
|
992 | - exit(); |
|
993 | - break; |
|
994 | - |
|
995 | - case 'diagnosis-fix' : |
|
996 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
997 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
998 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
999 | - exit(); |
|
1000 | - break; |
|
1001 | - } |
|
1002 | - } |
|
1003 | - exit(); |
|
982 | + if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') { |
|
983 | + $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
984 | + $diagnose_this = ""; |
|
985 | + switch ($geodir_admin_ajax_action) { |
|
986 | + case 'diagnosis' : |
|
987 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
988 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
989 | + call_user_func('geodir_diagnose_' . $diagnose_this); |
|
990 | + |
|
991 | + } |
|
992 | + exit(); |
|
993 | + break; |
|
994 | + |
|
995 | + case 'diagnosis-fix' : |
|
996 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
997 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
998 | + call_user_func('geodir_diagnose_' . $diagnose_this); |
|
999 | + exit(); |
|
1000 | + break; |
|
1001 | + } |
|
1002 | + } |
|
1003 | + exit(); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
@@ -1018,127 +1018,127 @@ discard block |
||
1018 | 1018 | */ |
1019 | 1019 | function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix) |
1020 | 1020 | { |
1021 | - global $wpdb; |
|
1022 | - //$filter_arr['output_str'] .='###'.$table.'###'; |
|
1023 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) { |
|
1024 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>"; |
|
1025 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1026 | - |
|
1027 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1028 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1029 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1030 | - $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>"; |
|
1031 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1032 | - |
|
1033 | - if ($fix) { |
|
1034 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count |
|
1035 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count |
|
1036 | - |
|
1037 | - if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2 |
|
1038 | - //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ; |
|
1039 | - |
|
1040 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table |
|
1041 | - |
|
1042 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1043 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>"; |
|
1044 | - } else { |
|
1045 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1046 | - } |
|
1047 | - |
|
1048 | - } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it |
|
1049 | - |
|
1050 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2 |
|
1051 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table |
|
1052 | - |
|
1053 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1054 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>"; |
|
1055 | - } else { |
|
1056 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1057 | - } |
|
1058 | - |
|
1059 | - } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors |
|
1060 | - |
|
1061 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2 |
|
1062 | - |
|
1063 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1064 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>"; |
|
1065 | - } else { |
|
1066 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1067 | - } |
|
1068 | - |
|
1069 | - } |
|
1070 | - |
|
1071 | - } |
|
1072 | - |
|
1073 | - |
|
1074 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1075 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1076 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1077 | - |
|
1078 | - if ($fix) { |
|
1079 | - if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it |
|
1080 | - if ($wpdb->query("DROP TABLE IF EXISTS $table")) { |
|
1081 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>"; |
|
1082 | - } else { |
|
1083 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>"; |
|
1084 | - } |
|
1085 | - |
|
1086 | - } 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 |
|
1087 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) { |
|
1088 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1089 | - } else { |
|
1090 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1091 | - } |
|
1092 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1093 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1094 | - } else { |
|
1095 | - $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>"; |
|
1096 | - } |
|
1097 | - } else {// else rename the original table to _ms_bak |
|
1098 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1099 | - $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>"; |
|
1100 | - } else { |
|
1101 | - $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>"; |
|
1102 | - } |
|
1103 | - } |
|
1104 | - } |
|
1105 | - |
|
1106 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1107 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>"; |
|
1108 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1109 | - |
|
1110 | - if ($fix) { |
|
1111 | - // if original table exists but new does not, rename |
|
1112 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1113 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1114 | - } else { |
|
1115 | - $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>"; |
|
1116 | - } |
|
1117 | - |
|
1118 | - } |
|
1119 | - |
|
1120 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1121 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>"; |
|
1122 | - $filter_arr['is_error_during_diagnose'] = true; |
|
1123 | - |
|
1124 | - if ($fix) { |
|
1125 | - // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
1126 | - delete_option('geodirlocation_db_version'); |
|
1127 | - delete_option('geodirevents_db_version'); |
|
1128 | - delete_option('geodir_reviewrating_db_version'); |
|
1129 | - delete_option('gdevents_db_version'); |
|
1130 | - delete_option('geodirectory_db_version'); |
|
1131 | - delete_option('geodirclaim_db_version'); |
|
1132 | - delete_option('geodir_custom_posts_db_version'); |
|
1133 | - delete_option('geodir_reviewratings_db_version'); |
|
1134 | - delete_option('geodiradvancesearch_db_version'); |
|
1135 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>"; |
|
1136 | - } |
|
1137 | - |
|
1138 | - } else { |
|
1139 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>"; |
|
1140 | - } |
|
1141 | - return $filter_arr; |
|
1021 | + global $wpdb; |
|
1022 | + //$filter_arr['output_str'] .='###'.$table.'###'; |
|
1023 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) { |
|
1024 | + $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>"; |
|
1025 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1026 | + |
|
1027 | + } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1028 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1029 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1030 | + $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>"; |
|
1031 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1032 | + |
|
1033 | + if ($fix) { |
|
1034 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count |
|
1035 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count |
|
1036 | + |
|
1037 | + if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2 |
|
1038 | + //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ; |
|
1039 | + |
|
1040 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table |
|
1041 | + |
|
1042 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1043 | + $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>"; |
|
1044 | + } else { |
|
1045 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1046 | + } |
|
1047 | + |
|
1048 | + } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it |
|
1049 | + |
|
1050 | + $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2 |
|
1051 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table |
|
1052 | + |
|
1053 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1054 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>"; |
|
1055 | + } else { |
|
1056 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1057 | + } |
|
1058 | + |
|
1059 | + } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors |
|
1060 | + |
|
1061 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2 |
|
1062 | + |
|
1063 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1064 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>"; |
|
1065 | + } else { |
|
1066 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1067 | + } |
|
1068 | + |
|
1069 | + } |
|
1070 | + |
|
1071 | + } |
|
1072 | + |
|
1073 | + |
|
1074 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1075 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1076 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1077 | + |
|
1078 | + if ($fix) { |
|
1079 | + if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it |
|
1080 | + if ($wpdb->query("DROP TABLE IF EXISTS $table")) { |
|
1081 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>"; |
|
1082 | + } else { |
|
1083 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>"; |
|
1084 | + } |
|
1085 | + |
|
1086 | + } 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 |
|
1087 | + if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) { |
|
1088 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1089 | + } else { |
|
1090 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1091 | + } |
|
1092 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1093 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1094 | + } else { |
|
1095 | + $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>"; |
|
1096 | + } |
|
1097 | + } else {// else rename the original table to _ms_bak |
|
1098 | + if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1099 | + $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>"; |
|
1100 | + } else { |
|
1101 | + $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>"; |
|
1102 | + } |
|
1103 | + } |
|
1104 | + } |
|
1105 | + |
|
1106 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1107 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>"; |
|
1108 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1109 | + |
|
1110 | + if ($fix) { |
|
1111 | + // if original table exists but new does not, rename |
|
1112 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1113 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1114 | + } else { |
|
1115 | + $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>"; |
|
1116 | + } |
|
1117 | + |
|
1118 | + } |
|
1119 | + |
|
1120 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1121 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>"; |
|
1122 | + $filter_arr['is_error_during_diagnose'] = true; |
|
1123 | + |
|
1124 | + if ($fix) { |
|
1125 | + // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
1126 | + delete_option('geodirlocation_db_version'); |
|
1127 | + delete_option('geodirevents_db_version'); |
|
1128 | + delete_option('geodir_reviewrating_db_version'); |
|
1129 | + delete_option('gdevents_db_version'); |
|
1130 | + delete_option('geodirectory_db_version'); |
|
1131 | + delete_option('geodirclaim_db_version'); |
|
1132 | + delete_option('geodir_custom_posts_db_version'); |
|
1133 | + delete_option('geodir_reviewratings_db_version'); |
|
1134 | + delete_option('geodiradvancesearch_db_version'); |
|
1135 | + $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>"; |
|
1136 | + } |
|
1137 | + |
|
1138 | + } else { |
|
1139 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>"; |
|
1140 | + } |
|
1141 | + return $filter_arr; |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | |
@@ -1152,111 +1152,111 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | function geodir_diagnose_tags_sync() |
1154 | 1154 | { |
1155 | - global $wpdb, $plugin_prefix; |
|
1156 | - $fix = isset($_POST['fix']) ? true : false; |
|
1157 | - $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0; |
|
1158 | - $step_max_items = geodir_get_diagnose_step_max_items(); |
|
1159 | - $offset = (int) $step * $step_max_items; |
|
1160 | - $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false; |
|
1161 | - |
|
1162 | - $total_listings = geodir_total_listings_count(); |
|
1163 | - $total_ptype_listings = 0; |
|
1164 | - if ($ptype) { |
|
1165 | - $total_ptype_listings = geodir_total_listings_count($ptype); |
|
1166 | - } |
|
1167 | - $max_step = ceil($total_ptype_listings / $step_max_items) - 1; |
|
1155 | + global $wpdb, $plugin_prefix; |
|
1156 | + $fix = isset($_POST['fix']) ? true : false; |
|
1157 | + $step = isset($_POST['step']) ? strip_tags(esc_sql($_POST['step'])) : 0; |
|
1158 | + $step_max_items = geodir_get_diagnose_step_max_items(); |
|
1159 | + $offset = (int) $step * $step_max_items; |
|
1160 | + $ptype = isset($_POST['ptype']) ? strip_tags(esc_sql($_POST['ptype'])) : false; |
|
1161 | + |
|
1162 | + $total_listings = geodir_total_listings_count(); |
|
1163 | + $total_ptype_listings = 0; |
|
1164 | + if ($ptype) { |
|
1165 | + $total_ptype_listings = geodir_total_listings_count($ptype); |
|
1166 | + } |
|
1167 | + $max_step = ceil($total_ptype_listings / $step_max_items) - 1; |
|
1168 | 1168 | |
1169 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1170 | - $is_error_during_diagnose = false; |
|
1171 | - $output_str = ''; |
|
1169 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1170 | + $is_error_during_diagnose = false; |
|
1171 | + $output_str = ''; |
|
1172 | 1172 | |
1173 | - if ($ptype && !empty($ptype) && $total_listings > $step_max_items) { |
|
1174 | - $stepped_process = true; |
|
1175 | - } else { |
|
1176 | - $stepped_process = false; |
|
1177 | - } |
|
1178 | - |
|
1179 | - if ($stepped_process) { |
|
1180 | - $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset ); |
|
1181 | - $posts = $wpdb->get_results( $sql ); |
|
1182 | - |
|
1183 | - if (!empty($posts)) { |
|
1184 | - |
|
1185 | - foreach ($posts as $p) { |
|
1186 | - $p->post_type = $ptype; |
|
1187 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1188 | - if (empty($raw_tags)) { |
|
1189 | - $post_tags = ''; |
|
1190 | - } else { |
|
1191 | - $post_tags = implode(",", $raw_tags); |
|
1192 | - } |
|
1193 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1194 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1195 | - |
|
1196 | - } |
|
1197 | - if ($step >= $max_step) { |
|
1198 | - $output_str = "done"; |
|
1199 | - } else { |
|
1200 | - $output_str = $step + 1; |
|
1201 | - } |
|
1202 | - } |
|
1203 | - |
|
1204 | - } else { |
|
1205 | - $all_postypes = geodir_get_posttypes(); |
|
1206 | - |
|
1207 | - if (!empty($all_postypes)) { |
|
1208 | - foreach ($all_postypes as $key) { |
|
1209 | - // update each GD CPT |
|
1210 | - $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1211 | - |
|
1212 | - if (!empty($posts)) { |
|
1213 | - |
|
1214 | - foreach ($posts as $p) { |
|
1215 | - $p->post_type = $key; |
|
1216 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1217 | - if (empty($raw_tags)) { |
|
1218 | - $post_tags = ''; |
|
1219 | - } else { |
|
1220 | - $post_tags = implode(",", $raw_tags); |
|
1221 | - } |
|
1222 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1223 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1224 | - |
|
1225 | - } |
|
1226 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1227 | - } |
|
1228 | - |
|
1229 | - } |
|
1230 | - |
|
1231 | - } |
|
1232 | - } |
|
1233 | - |
|
1234 | - |
|
1235 | - if ($is_error_during_diagnose) { |
|
1236 | - $info_div_class = "geodir_problem_info"; |
|
1237 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1238 | - } else { |
|
1239 | - $info_div_class = "geodir_noproblem_info"; |
|
1240 | - $fix_button_txt = ''; |
|
1241 | - } |
|
1242 | - |
|
1243 | - if ($stepped_process) { |
|
1244 | - $percent = ($step/$max_step) * 100; |
|
1245 | - if ($output_str == 'done') { |
|
1246 | - echo $output_str; |
|
1247 | - } else { |
|
1248 | - $output = array( |
|
1249 | - 'step' => $output_str, |
|
1250 | - 'percent' => $percent |
|
1251 | - ); |
|
1252 | - echo json_encode($output); |
|
1253 | - } |
|
1254 | - } else { |
|
1255 | - echo "<ul class='$info_div_class'>"; |
|
1256 | - echo $output_str; |
|
1257 | - echo $fix_button_txt; |
|
1258 | - echo "</ul>"; |
|
1259 | - } |
|
1173 | + if ($ptype && !empty($ptype) && $total_listings > $step_max_items) { |
|
1174 | + $stepped_process = true; |
|
1175 | + } else { |
|
1176 | + $stepped_process = false; |
|
1177 | + } |
|
1178 | + |
|
1179 | + if ($stepped_process) { |
|
1180 | + $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset ); |
|
1181 | + $posts = $wpdb->get_results( $sql ); |
|
1182 | + |
|
1183 | + if (!empty($posts)) { |
|
1184 | + |
|
1185 | + foreach ($posts as $p) { |
|
1186 | + $p->post_type = $ptype; |
|
1187 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1188 | + if (empty($raw_tags)) { |
|
1189 | + $post_tags = ''; |
|
1190 | + } else { |
|
1191 | + $post_tags = implode(",", $raw_tags); |
|
1192 | + } |
|
1193 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1194 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1195 | + |
|
1196 | + } |
|
1197 | + if ($step >= $max_step) { |
|
1198 | + $output_str = "done"; |
|
1199 | + } else { |
|
1200 | + $output_str = $step + 1; |
|
1201 | + } |
|
1202 | + } |
|
1203 | + |
|
1204 | + } else { |
|
1205 | + $all_postypes = geodir_get_posttypes(); |
|
1206 | + |
|
1207 | + if (!empty($all_postypes)) { |
|
1208 | + foreach ($all_postypes as $key) { |
|
1209 | + // update each GD CPT |
|
1210 | + $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1211 | + |
|
1212 | + if (!empty($posts)) { |
|
1213 | + |
|
1214 | + foreach ($posts as $p) { |
|
1215 | + $p->post_type = $key; |
|
1216 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1217 | + if (empty($raw_tags)) { |
|
1218 | + $post_tags = ''; |
|
1219 | + } else { |
|
1220 | + $post_tags = implode(",", $raw_tags); |
|
1221 | + } |
|
1222 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1223 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1224 | + |
|
1225 | + } |
|
1226 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1227 | + } |
|
1228 | + |
|
1229 | + } |
|
1230 | + |
|
1231 | + } |
|
1232 | + } |
|
1233 | + |
|
1234 | + |
|
1235 | + if ($is_error_during_diagnose) { |
|
1236 | + $info_div_class = "geodir_problem_info"; |
|
1237 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1238 | + } else { |
|
1239 | + $info_div_class = "geodir_noproblem_info"; |
|
1240 | + $fix_button_txt = ''; |
|
1241 | + } |
|
1242 | + |
|
1243 | + if ($stepped_process) { |
|
1244 | + $percent = ($step/$max_step) * 100; |
|
1245 | + if ($output_str == 'done') { |
|
1246 | + echo $output_str; |
|
1247 | + } else { |
|
1248 | + $output = array( |
|
1249 | + 'step' => $output_str, |
|
1250 | + 'percent' => $percent |
|
1251 | + ); |
|
1252 | + echo json_encode($output); |
|
1253 | + } |
|
1254 | + } else { |
|
1255 | + echo "<ul class='$info_div_class'>"; |
|
1256 | + echo $output_str; |
|
1257 | + echo $fix_button_txt; |
|
1258 | + echo "</ul>"; |
|
1259 | + } |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | /** |
@@ -1271,75 +1271,75 @@ discard block |
||
1271 | 1271 | */ |
1272 | 1272 | function geodir_diagnose_cats_sync() |
1273 | 1273 | { |
1274 | - global $wpdb, $plugin_prefix; |
|
1275 | - $fix = isset($_POST['fix']) ? true : false; |
|
1274 | + global $wpdb, $plugin_prefix; |
|
1275 | + $fix = isset($_POST['fix']) ? true : false; |
|
1276 | 1276 | |
1277 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1278 | - $is_error_during_diagnose = false; |
|
1279 | - $output_str = ''; |
|
1277 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1278 | + $is_error_during_diagnose = false; |
|
1279 | + $output_str = ''; |
|
1280 | 1280 | |
1281 | 1281 | |
1282 | - $all_postypes = geodir_get_posttypes(); |
|
1282 | + $all_postypes = geodir_get_posttypes(); |
|
1283 | 1283 | |
1284 | - if (!empty($all_postypes)) { |
|
1285 | - foreach ($all_postypes as $key) { |
|
1286 | - // update each GD CTP |
|
1287 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' "); |
|
1284 | + if (!empty($all_postypes)) { |
|
1285 | + foreach ($all_postypes as $key) { |
|
1286 | + // update each GD CTP |
|
1287 | + $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' "); |
|
1288 | 1288 | |
1289 | - if (!empty($posts)) { |
|
1289 | + if (!empty($posts)) { |
|
1290 | 1290 | |
1291 | - foreach ($posts as $p) { |
|
1292 | - $p->post_type = $key; |
|
1293 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids')); |
|
1291 | + foreach ($posts as $p) { |
|
1292 | + $p->post_type = $key; |
|
1293 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids')); |
|
1294 | 1294 | |
1295 | - if (empty($raw_cats)) { |
|
1296 | - $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
1295 | + if (empty($raw_cats)) { |
|
1296 | + $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
1297 | 1297 | |
1298 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) { |
|
1299 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']); |
|
1300 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) { |
|
1301 | - if (is_numeric($cat_part)) { |
|
1302 | - $raw_cats[] = (int)$cat_part; |
|
1303 | - } |
|
1304 | - } |
|
1298 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) { |
|
1299 | + $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']); |
|
1300 | + foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) { |
|
1301 | + if (is_numeric($cat_part)) { |
|
1302 | + $raw_cats[] = (int)$cat_part; |
|
1303 | + } |
|
1304 | + } |
|
1305 | 1305 | |
1306 | - } |
|
1306 | + } |
|
1307 | 1307 | |
1308 | - if (!empty($raw_cats)) { |
|
1309 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
1308 | + if (!empty($raw_cats)) { |
|
1309 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
1310 | 1310 | |
1311 | - } |
|
1311 | + } |
|
1312 | 1312 | |
1313 | - } |
|
1313 | + } |
|
1314 | 1314 | |
1315 | 1315 | |
1316 | - if (empty($raw_cats)) { |
|
1317 | - $post_cats = ''; |
|
1318 | - } else { |
|
1319 | - $post_cats = ',' . implode(",", $raw_cats) . ','; |
|
1320 | - } |
|
1321 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1322 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1323 | - } |
|
1316 | + if (empty($raw_cats)) { |
|
1317 | + $post_cats = ''; |
|
1318 | + } else { |
|
1319 | + $post_cats = ',' . implode(",", $raw_cats) . ','; |
|
1320 | + } |
|
1321 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1322 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1323 | + } |
|
1324 | 1324 | |
1325 | - } |
|
1326 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1325 | + } |
|
1326 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1327 | 1327 | |
1328 | - } |
|
1328 | + } |
|
1329 | 1329 | |
1330 | - } |
|
1330 | + } |
|
1331 | 1331 | |
1332 | - if ($is_error_during_diagnose) { |
|
1333 | - $info_div_class = "geodir_problem_info"; |
|
1334 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1335 | - } else { |
|
1336 | - $info_div_class = "geodir_noproblem_info"; |
|
1337 | - $fix_button_txt = ''; |
|
1338 | - } |
|
1339 | - echo "<ul class='$info_div_class'>"; |
|
1340 | - echo $output_str; |
|
1341 | - echo $fix_button_txt; |
|
1342 | - echo "</ul>"; |
|
1332 | + if ($is_error_during_diagnose) { |
|
1333 | + $info_div_class = "geodir_problem_info"; |
|
1334 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1335 | + } else { |
|
1336 | + $info_div_class = "geodir_noproblem_info"; |
|
1337 | + $fix_button_txt = ''; |
|
1338 | + } |
|
1339 | + echo "<ul class='$info_div_class'>"; |
|
1340 | + echo $output_str; |
|
1341 | + echo $fix_button_txt; |
|
1342 | + echo "</ul>"; |
|
1343 | 1343 | |
1344 | 1344 | } |
1345 | 1345 | |
@@ -1353,61 +1353,61 @@ discard block |
||
1353 | 1353 | */ |
1354 | 1354 | function geodir_diagnose_version_clear() |
1355 | 1355 | { |
1356 | - global $wpdb, $plugin_prefix; |
|
1357 | - $fix = isset($_POST['fix']) ? true : false; |
|
1358 | - |
|
1359 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1360 | - $is_error_during_diagnose = false; |
|
1361 | - $output_str = ''; |
|
1362 | - |
|
1363 | - |
|
1364 | - $gd_arr = array('GeoDirectory' => 'geodirectory_db_version', |
|
1365 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
1366 | - 'GeoDirectory Framework' => 'gdf_db_version', |
|
1367 | - 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
1368 | - 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
1369 | - 'Claim Manager' => 'geodirclaim_db_version', |
|
1370 | - 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
1371 | - 'Location Manager' => 'geodirlocation_db_version', |
|
1372 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
1373 | - 'Events Manager' => 'geodirevents_db_version', |
|
1374 | - ); |
|
1375 | - |
|
1376 | - /** |
|
1377 | - * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
1378 | - * |
|
1379 | - * @since 1.0.0 |
|
1380 | - * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',... |
|
1381 | - */ |
|
1382 | - $ver_arr = apply_filters('geodir_db_version_name', $gd_arr); |
|
1383 | - |
|
1384 | - if (!empty($ver_arr)) { |
|
1385 | - foreach ($ver_arr as $key => $val) { |
|
1386 | - if (delete_option($val)) { |
|
1387 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>"; |
|
1388 | - } else { |
|
1389 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>"; |
|
1390 | - } |
|
1391 | - |
|
1392 | - } |
|
1393 | - |
|
1394 | - if ($output_str) { |
|
1395 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>"; |
|
1396 | - } |
|
1397 | - |
|
1398 | - } |
|
1399 | - |
|
1400 | - if ($is_error_during_diagnose) { |
|
1401 | - $info_div_class = "geodir_problem_info"; |
|
1402 | - $fix_button_txt = ""; |
|
1403 | - } else { |
|
1404 | - $info_div_class = "geodir_noproblem_info"; |
|
1405 | - $fix_button_txt = ''; |
|
1406 | - } |
|
1407 | - echo "<ul class='$info_div_class'>"; |
|
1408 | - echo $output_str; |
|
1409 | - echo $fix_button_txt; |
|
1410 | - echo "</ul>"; |
|
1356 | + global $wpdb, $plugin_prefix; |
|
1357 | + $fix = isset($_POST['fix']) ? true : false; |
|
1358 | + |
|
1359 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1360 | + $is_error_during_diagnose = false; |
|
1361 | + $output_str = ''; |
|
1362 | + |
|
1363 | + |
|
1364 | + $gd_arr = array('GeoDirectory' => 'geodirectory_db_version', |
|
1365 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
1366 | + 'GeoDirectory Framework' => 'gdf_db_version', |
|
1367 | + 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
1368 | + 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
1369 | + 'Claim Manager' => 'geodirclaim_db_version', |
|
1370 | + 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
1371 | + 'Location Manager' => 'geodirlocation_db_version', |
|
1372 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
1373 | + 'Events Manager' => 'geodirevents_db_version', |
|
1374 | + ); |
|
1375 | + |
|
1376 | + /** |
|
1377 | + * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
1378 | + * |
|
1379 | + * @since 1.0.0 |
|
1380 | + * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',... |
|
1381 | + */ |
|
1382 | + $ver_arr = apply_filters('geodir_db_version_name', $gd_arr); |
|
1383 | + |
|
1384 | + if (!empty($ver_arr)) { |
|
1385 | + foreach ($ver_arr as $key => $val) { |
|
1386 | + if (delete_option($val)) { |
|
1387 | + $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>"; |
|
1388 | + } else { |
|
1389 | + $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>"; |
|
1390 | + } |
|
1391 | + |
|
1392 | + } |
|
1393 | + |
|
1394 | + if ($output_str) { |
|
1395 | + $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>"; |
|
1396 | + } |
|
1397 | + |
|
1398 | + } |
|
1399 | + |
|
1400 | + if ($is_error_during_diagnose) { |
|
1401 | + $info_div_class = "geodir_problem_info"; |
|
1402 | + $fix_button_txt = ""; |
|
1403 | + } else { |
|
1404 | + $info_div_class = "geodir_noproblem_info"; |
|
1405 | + $fix_button_txt = ''; |
|
1406 | + } |
|
1407 | + echo "<ul class='$info_div_class'>"; |
|
1408 | + echo $output_str; |
|
1409 | + echo $fix_button_txt; |
|
1410 | + echo "</ul>"; |
|
1411 | 1411 | |
1412 | 1412 | } |
1413 | 1413 | |
@@ -1421,59 +1421,59 @@ discard block |
||
1421 | 1421 | */ |
1422 | 1422 | function geodir_diagnose_ratings() |
1423 | 1423 | { |
1424 | - global $wpdb; |
|
1425 | - $fix = isset($_POST['fix']) ? true : false; |
|
1426 | - |
|
1427 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1428 | - $is_error_during_diagnose = false; |
|
1429 | - $output_str = ''; |
|
1430 | - |
|
1431 | - // check review locations |
|
1432 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) { |
|
1433 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; |
|
1434 | - $is_error_during_diagnose = true; |
|
1435 | - |
|
1436 | - if ($fix) { |
|
1437 | - if (geodir_fix_review_location()) { |
|
1438 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; |
|
1439 | - } else { |
|
1440 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; |
|
1441 | - } |
|
1442 | - } |
|
1443 | - |
|
1444 | - } else { |
|
1445 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; |
|
1446 | - } |
|
1447 | - |
|
1448 | - // check review content |
|
1449 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { |
|
1450 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; |
|
1451 | - $is_error_during_diagnose = true; |
|
1452 | - |
|
1453 | - if ($fix) { |
|
1454 | - if (geodir_fix_review_content()) { |
|
1455 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; |
|
1456 | - } else { |
|
1457 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; |
|
1458 | - } |
|
1459 | - } |
|
1460 | - |
|
1461 | - } else { |
|
1462 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; |
|
1463 | - } |
|
1464 | - |
|
1465 | - |
|
1466 | - if ($is_error_during_diagnose) { |
|
1467 | - $info_div_class = "geodir_problem_info"; |
|
1468 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1469 | - } else { |
|
1470 | - $info_div_class = "geodir_noproblem_info"; |
|
1471 | - $fix_button_txt = ''; |
|
1472 | - } |
|
1473 | - echo "<ul class='$info_div_class'>"; |
|
1474 | - echo $output_str; |
|
1475 | - echo $fix_button_txt; |
|
1476 | - echo "</ul>"; |
|
1424 | + global $wpdb; |
|
1425 | + $fix = isset($_POST['fix']) ? true : false; |
|
1426 | + |
|
1427 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1428 | + $is_error_during_diagnose = false; |
|
1429 | + $output_str = ''; |
|
1430 | + |
|
1431 | + // check review locations |
|
1432 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) { |
|
1433 | + $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; |
|
1434 | + $is_error_during_diagnose = true; |
|
1435 | + |
|
1436 | + if ($fix) { |
|
1437 | + if (geodir_fix_review_location()) { |
|
1438 | + $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; |
|
1439 | + } else { |
|
1440 | + $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; |
|
1441 | + } |
|
1442 | + } |
|
1443 | + |
|
1444 | + } else { |
|
1445 | + $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; |
|
1446 | + } |
|
1447 | + |
|
1448 | + // check review content |
|
1449 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { |
|
1450 | + $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; |
|
1451 | + $is_error_during_diagnose = true; |
|
1452 | + |
|
1453 | + if ($fix) { |
|
1454 | + if (geodir_fix_review_content()) { |
|
1455 | + $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; |
|
1456 | + } else { |
|
1457 | + $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; |
|
1458 | + } |
|
1459 | + } |
|
1460 | + |
|
1461 | + } else { |
|
1462 | + $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; |
|
1463 | + } |
|
1464 | + |
|
1465 | + |
|
1466 | + if ($is_error_during_diagnose) { |
|
1467 | + $info_div_class = "geodir_problem_info"; |
|
1468 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1469 | + } else { |
|
1470 | + $info_div_class = "geodir_noproblem_info"; |
|
1471 | + $fix_button_txt = ''; |
|
1472 | + } |
|
1473 | + echo "<ul class='$info_div_class'>"; |
|
1474 | + echo $output_str; |
|
1475 | + echo $fix_button_txt; |
|
1476 | + echo "</ul>"; |
|
1477 | 1477 | |
1478 | 1478 | } |
1479 | 1479 | |
@@ -1487,57 +1487,57 @@ discard block |
||
1487 | 1487 | */ |
1488 | 1488 | function geodir_diagnose_multisite_conversion() |
1489 | 1489 | { |
1490 | - global $wpdb; |
|
1491 | - $fix = isset($_POST['fix']) ? true : false; |
|
1492 | - //if($fix){echo 'true';}else{echo 'false';} |
|
1493 | - $is_error_during_diagnose = false; |
|
1494 | - $output_str = ''; |
|
1495 | - |
|
1496 | - $filter_arr = array(); |
|
1497 | - $filter_arr['output_str'] = $output_str; |
|
1498 | - $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
1499 | - $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'), |
|
1500 | - 'geodir_custom_fields' => __('Custom fields', 'geodirectory'), |
|
1501 | - 'geodir_post_icon' => __('Post icon', 'geodirectory'), |
|
1502 | - 'geodir_attachments' => __('Attachments', 'geodirectory'), |
|
1503 | - 'geodir_post_review' => __('Reviews', 'geodirectory'), |
|
1504 | - 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'), |
|
1505 | - 'geodir_gd_place_detail' => __('Place detail', 'geodirectory') |
|
1506 | - ); |
|
1507 | - |
|
1508 | - // allow other addons to hook in and add their checks |
|
1509 | - |
|
1510 | - /** |
|
1511 | - * Filter the array of tables. |
|
1512 | - * |
|
1513 | - * 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. |
|
1514 | - * |
|
1515 | - * @since 1.0.0 |
|
1516 | - * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),... |
|
1517 | - */ |
|
1518 | - $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr); |
|
1519 | - |
|
1520 | - foreach ($table_arr as $table => $table_name) { |
|
1521 | - // Diagnose table |
|
1522 | - $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
1523 | - } |
|
1524 | - |
|
1525 | - |
|
1526 | - $output_str = $filter_arr['output_str']; |
|
1527 | - $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
1528 | - |
|
1529 | - |
|
1530 | - if ($is_error_during_diagnose) { |
|
1531 | - $info_div_class = "geodir_problem_info"; |
|
1532 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1533 | - } else { |
|
1534 | - $info_div_class = "geodir_noproblem_info"; |
|
1535 | - $fix_button_txt = ''; |
|
1536 | - } |
|
1537 | - echo "<ul class='$info_div_class'>"; |
|
1538 | - echo $output_str; |
|
1539 | - echo $fix_button_txt; |
|
1540 | - echo "</ul>"; |
|
1490 | + global $wpdb; |
|
1491 | + $fix = isset($_POST['fix']) ? true : false; |
|
1492 | + //if($fix){echo 'true';}else{echo 'false';} |
|
1493 | + $is_error_during_diagnose = false; |
|
1494 | + $output_str = ''; |
|
1495 | + |
|
1496 | + $filter_arr = array(); |
|
1497 | + $filter_arr['output_str'] = $output_str; |
|
1498 | + $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
1499 | + $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'), |
|
1500 | + 'geodir_custom_fields' => __('Custom fields', 'geodirectory'), |
|
1501 | + 'geodir_post_icon' => __('Post icon', 'geodirectory'), |
|
1502 | + 'geodir_attachments' => __('Attachments', 'geodirectory'), |
|
1503 | + 'geodir_post_review' => __('Reviews', 'geodirectory'), |
|
1504 | + 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'), |
|
1505 | + 'geodir_gd_place_detail' => __('Place detail', 'geodirectory') |
|
1506 | + ); |
|
1507 | + |
|
1508 | + // allow other addons to hook in and add their checks |
|
1509 | + |
|
1510 | + /** |
|
1511 | + * Filter the array of tables. |
|
1512 | + * |
|
1513 | + * 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. |
|
1514 | + * |
|
1515 | + * @since 1.0.0 |
|
1516 | + * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),... |
|
1517 | + */ |
|
1518 | + $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr); |
|
1519 | + |
|
1520 | + foreach ($table_arr as $table => $table_name) { |
|
1521 | + // Diagnose table |
|
1522 | + $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
1523 | + } |
|
1524 | + |
|
1525 | + |
|
1526 | + $output_str = $filter_arr['output_str']; |
|
1527 | + $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
1528 | + |
|
1529 | + |
|
1530 | + if ($is_error_during_diagnose) { |
|
1531 | + $info_div_class = "geodir_problem_info"; |
|
1532 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1533 | + } else { |
|
1534 | + $info_div_class = "geodir_noproblem_info"; |
|
1535 | + $fix_button_txt = ''; |
|
1536 | + } |
|
1537 | + echo "<ul class='$info_div_class'>"; |
|
1538 | + echo $output_str; |
|
1539 | + echo $fix_button_txt; |
|
1540 | + echo "</ul>"; |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | /** |
@@ -1555,39 +1555,39 @@ discard block |
||
1555 | 1555 | */ |
1556 | 1556 | function geodir_fix_virtual_page($slug, $page_title, $old_id, $option) |
1557 | 1557 | { |
1558 | - global $wpdb, $current_user; |
|
1559 | - |
|
1560 | - if (!empty($old_id)) { |
|
1561 | - wp_delete_post($old_id, true); |
|
1562 | - }//delete post if already there |
|
1563 | - else { |
|
1564 | - $page_found = $wpdb->get_var( |
|
1565 | - $wpdb->prepare( |
|
1566 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
1567 | - array($slug) |
|
1568 | - ) |
|
1569 | - ); |
|
1570 | - wp_delete_post($page_found, true); |
|
1571 | - |
|
1572 | - } |
|
1573 | - |
|
1574 | - $page_data = array( |
|
1575 | - 'post_status' => 'publish', |
|
1576 | - 'post_type' => 'page', |
|
1577 | - 'post_author' => $current_user->ID, |
|
1578 | - 'post_name' => $slug, |
|
1579 | - 'post_title' => $page_title, |
|
1580 | - 'post_content' => '', |
|
1581 | - 'post_parent' => 0, |
|
1582 | - 'comment_status' => 'closed' |
|
1583 | - ); |
|
1584 | - $page_id = wp_insert_post($page_data); |
|
1585 | - update_option($option, $page_id); |
|
1586 | - if ($page_id) { |
|
1587 | - return true; |
|
1588 | - } else { |
|
1589 | - return false; |
|
1590 | - } |
|
1558 | + global $wpdb, $current_user; |
|
1559 | + |
|
1560 | + if (!empty($old_id)) { |
|
1561 | + wp_delete_post($old_id, true); |
|
1562 | + }//delete post if already there |
|
1563 | + else { |
|
1564 | + $page_found = $wpdb->get_var( |
|
1565 | + $wpdb->prepare( |
|
1566 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
1567 | + array($slug) |
|
1568 | + ) |
|
1569 | + ); |
|
1570 | + wp_delete_post($page_found, true); |
|
1571 | + |
|
1572 | + } |
|
1573 | + |
|
1574 | + $page_data = array( |
|
1575 | + 'post_status' => 'publish', |
|
1576 | + 'post_type' => 'page', |
|
1577 | + 'post_author' => $current_user->ID, |
|
1578 | + 'post_name' => $slug, |
|
1579 | + 'post_title' => $page_title, |
|
1580 | + 'post_content' => '', |
|
1581 | + 'post_parent' => 0, |
|
1582 | + 'comment_status' => 'closed' |
|
1583 | + ); |
|
1584 | + $page_id = wp_insert_post($page_data); |
|
1585 | + update_option($option, $page_id); |
|
1586 | + if ($page_id) { |
|
1587 | + return true; |
|
1588 | + } else { |
|
1589 | + return false; |
|
1590 | + } |
|
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | /** |
@@ -1599,212 +1599,212 @@ discard block |
||
1599 | 1599 | */ |
1600 | 1600 | function geodir_diagnose_default_pages() |
1601 | 1601 | { |
1602 | - global $wpdb; |
|
1603 | - $is_error_during_diagnose = false; |
|
1604 | - $output_str = ''; |
|
1605 | - $fix = isset($_POST['fix']) ? true : false; |
|
1606 | - |
|
1607 | - ////////////////////////////////// |
|
1608 | - /* Diagnose GD Home Page Starts */ |
|
1609 | - ////////////////////////////////// |
|
1610 | - $option_value = get_option('geodir_home_page'); |
|
1611 | - $page = get_post($option_value); |
|
1612 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1613 | - |
|
1614 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1615 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1616 | - else { |
|
1617 | - $is_error_during_diagnose = true; |
|
1618 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
|
1619 | - if ($fix) { |
|
1620 | - if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { |
|
1621 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; |
|
1622 | - } else { |
|
1623 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; |
|
1624 | - } |
|
1625 | - } |
|
1626 | - } |
|
1627 | - |
|
1628 | - //////////////////////////////// |
|
1629 | - /* Diagnose GD Home Page Ends */ |
|
1630 | - //////////////////////////////// |
|
1631 | - |
|
1632 | - ////////////////////////////////// |
|
1633 | - /* Diagnose Add Listing Page Starts */ |
|
1634 | - ////////////////////////////////// |
|
1635 | - $option_value = get_option('geodir_add_listing_page'); |
|
1636 | - $page = get_post($option_value); |
|
1637 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1638 | - |
|
1639 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1640 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1641 | - else { |
|
1642 | - $is_error_during_diagnose = true; |
|
1643 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
|
1644 | - if ($fix) { |
|
1645 | - if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { |
|
1646 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; |
|
1647 | - } else { |
|
1648 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; |
|
1649 | - } |
|
1650 | - } |
|
1651 | - } |
|
1652 | - |
|
1653 | - //////////////////////////////// |
|
1654 | - /* Diagnose Add Listing Page Ends */ |
|
1655 | - //////////////////////////////// |
|
1656 | - |
|
1657 | - |
|
1658 | - ////////////////////////////////// |
|
1659 | - /* Diagnose Listing Preview Page Starts */ |
|
1660 | - ////////////////////////////////// |
|
1661 | - $option_value = get_option('geodir_preview_page'); |
|
1662 | - $page = get_post($option_value); |
|
1663 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1664 | - |
|
1665 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1666 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1667 | - else { |
|
1668 | - $is_error_during_diagnose = true; |
|
1669 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
|
1670 | - if ($fix) { |
|
1671 | - if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { |
|
1672 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; |
|
1673 | - } else { |
|
1674 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; |
|
1675 | - } |
|
1676 | - } |
|
1677 | - } |
|
1678 | - |
|
1679 | - //////////////////////////////// |
|
1680 | - /* Diagnose Listing Preview Page Ends */ |
|
1681 | - //////////////////////////////// |
|
1682 | - |
|
1683 | - ////////////////////////////////// |
|
1684 | - /* Diagnose Listing Success Page Starts */ |
|
1685 | - ////////////////////////////////// |
|
1686 | - $option_value = get_option('geodir_success_page'); |
|
1687 | - $page = get_post($option_value); |
|
1688 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1689 | - |
|
1690 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1691 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1692 | - else { |
|
1693 | - $is_error_during_diagnose = true; |
|
1694 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
|
1695 | - if ($fix) { |
|
1696 | - if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { |
|
1697 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; |
|
1698 | - } else { |
|
1699 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; |
|
1700 | - } |
|
1701 | - } |
|
1702 | - } |
|
1703 | - |
|
1704 | - //////////////////////////////// |
|
1705 | - /* Diagnose Listing Sucess Page Ends */ |
|
1706 | - //////////////////////////////// |
|
1707 | - |
|
1708 | - ////////////////////////////////// |
|
1709 | - /* Diagnose Info Page Starts */ |
|
1710 | - ////////////////////////////////// |
|
1711 | - $option_value = get_option('geodir_info_page'); |
|
1712 | - $page = get_post($option_value); |
|
1713 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1714 | - |
|
1715 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1716 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1717 | - else { |
|
1718 | - $is_error_during_diagnose = true; |
|
1719 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
|
1720 | - if ($fix) { |
|
1721 | - if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { |
|
1722 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; |
|
1723 | - } else { |
|
1724 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; |
|
1725 | - } |
|
1726 | - } |
|
1727 | - } |
|
1728 | - |
|
1729 | - //////////////////////////////// |
|
1730 | - /* Diagnose Info Page Ends */ |
|
1731 | - //////////////////////////////// |
|
1732 | - |
|
1733 | - ////////////////////////////////// |
|
1734 | - /* Diagnose Login Page Starts */ |
|
1735 | - ////////////////////////////////// |
|
1736 | - $option_value = get_option('geodir_login_page'); |
|
1737 | - $page = get_post($option_value); |
|
1738 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1739 | - |
|
1740 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1741 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1742 | - else { |
|
1743 | - $is_error_during_diagnose = true; |
|
1744 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
|
1745 | - if ($fix) { |
|
1746 | - if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { |
|
1747 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; |
|
1748 | - } else { |
|
1749 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; |
|
1750 | - } |
|
1751 | - } |
|
1752 | - } |
|
1753 | - |
|
1754 | - //////////////////////////////// |
|
1755 | - /* Diagnose Info Page Ends */ |
|
1756 | - //////////////////////////////// |
|
1757 | - |
|
1758 | - ////////////////////////////////// |
|
1759 | - /* Diagnose Location Page Starts */ |
|
1760 | - ////////////////////////////////// |
|
1761 | - $option_value = get_option('geodir_location_page'); |
|
1762 | - $page = get_post($option_value); |
|
1763 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1764 | - |
|
1765 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1766 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1767 | - else { |
|
1768 | - $is_error_during_diagnose = true; |
|
1769 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
|
1770 | - if ($fix) { |
|
1771 | - if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { |
|
1772 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; |
|
1773 | - } else { |
|
1774 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; |
|
1775 | - } |
|
1776 | - } |
|
1777 | - } |
|
1778 | - |
|
1779 | - //////////////////////////////// |
|
1780 | - /* Diagnose Location Page Ends */ |
|
1781 | - //////////////////////////////// |
|
1782 | - |
|
1783 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose ); |
|
1784 | - /** |
|
1785 | - * This action is called at the end of the GD Tools page check function. |
|
1786 | - * |
|
1787 | - * @since 1.5.2 |
|
1788 | - */ |
|
1789 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr); |
|
1790 | - |
|
1791 | - $output_str = $page_chk_arr['output_str']; |
|
1792 | - $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
1793 | - |
|
1794 | - if ($is_error_during_diagnose) { |
|
1795 | - if ($fix) { |
|
1796 | - flush_rewrite_rules(); |
|
1797 | - } |
|
1798 | - $info_div_class = "geodir_problem_info"; |
|
1799 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1800 | - } else { |
|
1801 | - $info_div_class = "geodir_noproblem_info"; |
|
1802 | - $fix_button_txt = ''; |
|
1803 | - } |
|
1804 | - echo "<ul class='$info_div_class'>"; |
|
1805 | - echo $output_str; |
|
1806 | - echo $fix_button_txt; |
|
1807 | - echo "</ul>"; |
|
1602 | + global $wpdb; |
|
1603 | + $is_error_during_diagnose = false; |
|
1604 | + $output_str = ''; |
|
1605 | + $fix = isset($_POST['fix']) ? true : false; |
|
1606 | + |
|
1607 | + ////////////////////////////////// |
|
1608 | + /* Diagnose GD Home Page Starts */ |
|
1609 | + ////////////////////////////////// |
|
1610 | + $option_value = get_option('geodir_home_page'); |
|
1611 | + $page = get_post($option_value); |
|
1612 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1613 | + |
|
1614 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1615 | + $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1616 | + else { |
|
1617 | + $is_error_during_diagnose = true; |
|
1618 | + $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
|
1619 | + if ($fix) { |
|
1620 | + if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { |
|
1621 | + $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; |
|
1622 | + } else { |
|
1623 | + $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; |
|
1624 | + } |
|
1625 | + } |
|
1626 | + } |
|
1627 | + |
|
1628 | + //////////////////////////////// |
|
1629 | + /* Diagnose GD Home Page Ends */ |
|
1630 | + //////////////////////////////// |
|
1631 | + |
|
1632 | + ////////////////////////////////// |
|
1633 | + /* Diagnose Add Listing Page Starts */ |
|
1634 | + ////////////////////////////////// |
|
1635 | + $option_value = get_option('geodir_add_listing_page'); |
|
1636 | + $page = get_post($option_value); |
|
1637 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1638 | + |
|
1639 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1640 | + $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1641 | + else { |
|
1642 | + $is_error_during_diagnose = true; |
|
1643 | + $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
|
1644 | + if ($fix) { |
|
1645 | + if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { |
|
1646 | + $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; |
|
1647 | + } else { |
|
1648 | + $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; |
|
1649 | + } |
|
1650 | + } |
|
1651 | + } |
|
1652 | + |
|
1653 | + //////////////////////////////// |
|
1654 | + /* Diagnose Add Listing Page Ends */ |
|
1655 | + //////////////////////////////// |
|
1656 | + |
|
1657 | + |
|
1658 | + ////////////////////////////////// |
|
1659 | + /* Diagnose Listing Preview Page Starts */ |
|
1660 | + ////////////////////////////////// |
|
1661 | + $option_value = get_option('geodir_preview_page'); |
|
1662 | + $page = get_post($option_value); |
|
1663 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1664 | + |
|
1665 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1666 | + $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1667 | + else { |
|
1668 | + $is_error_during_diagnose = true; |
|
1669 | + $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
|
1670 | + if ($fix) { |
|
1671 | + if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { |
|
1672 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; |
|
1673 | + } else { |
|
1674 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; |
|
1675 | + } |
|
1676 | + } |
|
1677 | + } |
|
1678 | + |
|
1679 | + //////////////////////////////// |
|
1680 | + /* Diagnose Listing Preview Page Ends */ |
|
1681 | + //////////////////////////////// |
|
1682 | + |
|
1683 | + ////////////////////////////////// |
|
1684 | + /* Diagnose Listing Success Page Starts */ |
|
1685 | + ////////////////////////////////// |
|
1686 | + $option_value = get_option('geodir_success_page'); |
|
1687 | + $page = get_post($option_value); |
|
1688 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1689 | + |
|
1690 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1691 | + $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1692 | + else { |
|
1693 | + $is_error_during_diagnose = true; |
|
1694 | + $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
|
1695 | + if ($fix) { |
|
1696 | + if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { |
|
1697 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; |
|
1698 | + } else { |
|
1699 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; |
|
1700 | + } |
|
1701 | + } |
|
1702 | + } |
|
1703 | + |
|
1704 | + //////////////////////////////// |
|
1705 | + /* Diagnose Listing Sucess Page Ends */ |
|
1706 | + //////////////////////////////// |
|
1707 | + |
|
1708 | + ////////////////////////////////// |
|
1709 | + /* Diagnose Info Page Starts */ |
|
1710 | + ////////////////////////////////// |
|
1711 | + $option_value = get_option('geodir_info_page'); |
|
1712 | + $page = get_post($option_value); |
|
1713 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1714 | + |
|
1715 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1716 | + $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1717 | + else { |
|
1718 | + $is_error_during_diagnose = true; |
|
1719 | + $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
|
1720 | + if ($fix) { |
|
1721 | + if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { |
|
1722 | + $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; |
|
1723 | + } else { |
|
1724 | + $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; |
|
1725 | + } |
|
1726 | + } |
|
1727 | + } |
|
1728 | + |
|
1729 | + //////////////////////////////// |
|
1730 | + /* Diagnose Info Page Ends */ |
|
1731 | + //////////////////////////////// |
|
1732 | + |
|
1733 | + ////////////////////////////////// |
|
1734 | + /* Diagnose Login Page Starts */ |
|
1735 | + ////////////////////////////////// |
|
1736 | + $option_value = get_option('geodir_login_page'); |
|
1737 | + $page = get_post($option_value); |
|
1738 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1739 | + |
|
1740 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1741 | + $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1742 | + else { |
|
1743 | + $is_error_during_diagnose = true; |
|
1744 | + $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
|
1745 | + if ($fix) { |
|
1746 | + if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { |
|
1747 | + $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; |
|
1748 | + } else { |
|
1749 | + $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; |
|
1750 | + } |
|
1751 | + } |
|
1752 | + } |
|
1753 | + |
|
1754 | + //////////////////////////////// |
|
1755 | + /* Diagnose Info Page Ends */ |
|
1756 | + //////////////////////////////// |
|
1757 | + |
|
1758 | + ////////////////////////////////// |
|
1759 | + /* Diagnose Location Page Starts */ |
|
1760 | + ////////////////////////////////// |
|
1761 | + $option_value = get_option('geodir_location_page'); |
|
1762 | + $page = get_post($option_value); |
|
1763 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1764 | + |
|
1765 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1766 | + $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1767 | + else { |
|
1768 | + $is_error_during_diagnose = true; |
|
1769 | + $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
|
1770 | + if ($fix) { |
|
1771 | + if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { |
|
1772 | + $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; |
|
1773 | + } else { |
|
1774 | + $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; |
|
1775 | + } |
|
1776 | + } |
|
1777 | + } |
|
1778 | + |
|
1779 | + //////////////////////////////// |
|
1780 | + /* Diagnose Location Page Ends */ |
|
1781 | + //////////////////////////////// |
|
1782 | + |
|
1783 | + $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose ); |
|
1784 | + /** |
|
1785 | + * This action is called at the end of the GD Tools page check function. |
|
1786 | + * |
|
1787 | + * @since 1.5.2 |
|
1788 | + */ |
|
1789 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr); |
|
1790 | + |
|
1791 | + $output_str = $page_chk_arr['output_str']; |
|
1792 | + $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
1793 | + |
|
1794 | + if ($is_error_during_diagnose) { |
|
1795 | + if ($fix) { |
|
1796 | + flush_rewrite_rules(); |
|
1797 | + } |
|
1798 | + $info_div_class = "geodir_problem_info"; |
|
1799 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1800 | + } else { |
|
1801 | + $info_div_class = "geodir_noproblem_info"; |
|
1802 | + $fix_button_txt = ''; |
|
1803 | + } |
|
1804 | + echo "<ul class='$info_div_class'>"; |
|
1805 | + echo $output_str; |
|
1806 | + echo $fix_button_txt; |
|
1807 | + echo "</ul>"; |
|
1808 | 1808 | |
1809 | 1809 | } |
1810 | 1810 | |
@@ -1816,26 +1816,26 @@ discard block |
||
1816 | 1816 | * @global object $wpdb WordPress Database object. |
1817 | 1817 | */ |
1818 | 1818 | function geodir_diagnose_load_db_language() { |
1819 | - global $wpdb; |
|
1819 | + global $wpdb; |
|
1820 | 1820 | |
1821 | 1821 | $is_error_during_diagnose = geodirectory_load_db_language(); |
1822 | 1822 | |
1823 | - $output_str = ''; |
|
1824 | - $fix_button_txt = ''; |
|
1823 | + $output_str = ''; |
|
1824 | + $fix_button_txt = ''; |
|
1825 | 1825 | |
1826 | - if ($is_error_during_diagnose) { |
|
1827 | - $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>"; |
|
1826 | + if ($is_error_during_diagnose) { |
|
1827 | + $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>"; |
|
1828 | 1828 | $info_div_class = "geodir_problem_info"; |
1829 | - } else { |
|
1830 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>"; |
|
1829 | + } else { |
|
1830 | + $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>"; |
|
1831 | 1831 | $info_div_class = "geodir_noproblem_info"; |
1832 | - $fix_button_txt = ''; |
|
1833 | - } |
|
1832 | + $fix_button_txt = ''; |
|
1833 | + } |
|
1834 | 1834 | |
1835 | 1835 | echo "<ul class='$info_div_class'>"; |
1836 | - echo $output_str; |
|
1837 | - echo $fix_button_txt; |
|
1838 | - echo "</ul>"; |
|
1836 | + echo $output_str; |
|
1837 | + echo $fix_button_txt; |
|
1838 | + echo "</ul>"; |
|
1839 | 1839 | |
1840 | 1840 | } |
1841 | 1841 | |
@@ -1866,23 +1866,23 @@ discard block |
||
1866 | 1866 | */ |
1867 | 1867 | function geodir_posts_clauses_request($clauses) |
1868 | 1868 | { |
1869 | - global $wpdb, $wp_query, $plugin_prefix; |
|
1869 | + global $wpdb, $wp_query, $plugin_prefix; |
|
1870 | 1870 | |
1871 | - 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'])) { |
|
1872 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
1871 | + 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'])) { |
|
1872 | + $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
1873 | 1873 | |
1874 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
1875 | - $clauses['join'] = $join; |
|
1874 | + $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
1875 | + $clauses['join'] = $join; |
|
1876 | 1876 | |
1877 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
1878 | - $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'; |
|
1879 | - $clauses['fields'] = $fields; |
|
1877 | + $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
1878 | + $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'; |
|
1879 | + $clauses['fields'] = $fields; |
|
1880 | 1880 | |
1881 | - $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
1882 | - $orderby = 'gd_expire ' . $order; |
|
1883 | - $clauses['orderby'] = $orderby; |
|
1884 | - } |
|
1885 | - return $clauses; |
|
1881 | + $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
1882 | + $orderby = 'gd_expire ' . $order; |
|
1883 | + $clauses['orderby'] = $orderby; |
|
1884 | + } |
|
1885 | + return $clauses; |
|
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | |
@@ -1903,7 +1903,7 @@ discard block |
||
1903 | 1903 | */ |
1904 | 1904 | function gd_theme_switch_compat_check() |
1905 | 1905 | { |
1906 | - gd_set_theme_compat(); |
|
1906 | + gd_set_theme_compat(); |
|
1907 | 1907 | } |
1908 | 1908 | |
1909 | 1909 | /** |
@@ -1916,27 +1916,27 @@ discard block |
||
1916 | 1916 | */ |
1917 | 1917 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") |
1918 | 1918 | { |
1919 | - if (function_exists('str_getcsv')) { |
|
1920 | - $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
1921 | - } else { |
|
1922 | - global $current_user; |
|
1923 | - $upload_dir = wp_upload_dir(); |
|
1924 | - |
|
1925 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
1926 | - $handle = fopen($file, 'w'); |
|
1927 | - |
|
1928 | - fwrite($handle, $input); |
|
1929 | - fclose($handle); |
|
1930 | - |
|
1931 | - $handle = fopen($file, 'rt'); |
|
1932 | - if (PHP_VERSION >= '5.3.0') { |
|
1933 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
1934 | - } else { |
|
1935 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
1936 | - } |
|
1937 | - fclose($handle); |
|
1938 | - } |
|
1939 | - return $fgetcsv; |
|
1919 | + if (function_exists('str_getcsv')) { |
|
1920 | + $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
1921 | + } else { |
|
1922 | + global $current_user; |
|
1923 | + $upload_dir = wp_upload_dir(); |
|
1924 | + |
|
1925 | + $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
1926 | + $handle = fopen($file, 'w'); |
|
1927 | + |
|
1928 | + fwrite($handle, $input); |
|
1929 | + fclose($handle); |
|
1930 | + |
|
1931 | + $handle = fopen($file, 'rt'); |
|
1932 | + if (PHP_VERSION >= '5.3.0') { |
|
1933 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
1934 | + } else { |
|
1935 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
1936 | + } |
|
1937 | + fclose($handle); |
|
1938 | + } |
|
1939 | + return $fgetcsv; |
|
1940 | 1940 | } |
1941 | 1941 | |
1942 | 1942 | add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv'); |
@@ -1951,375 +1951,375 @@ discard block |
||
1951 | 1951 | */ |
1952 | 1952 | function geodir_ajax_import_csv() |
1953 | 1953 | { |
1954 | - error_reporting(0); // hide error to get clean json response |
|
1954 | + error_reporting(0); // hide error to get clean json response |
|
1955 | 1955 | |
1956 | - global $wpdb, $plugin_prefix, $current_user; |
|
1957 | - $uploads = wp_upload_dir(); |
|
1958 | - ini_set('auto_detect_line_endings', true); |
|
1956 | + global $wpdb, $plugin_prefix, $current_user; |
|
1957 | + $uploads = wp_upload_dir(); |
|
1958 | + ini_set('auto_detect_line_endings', true); |
|
1959 | 1959 | |
1960 | 1960 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
1961 | 1961 | |
1962 | - $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
1963 | - $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
1964 | - $filename = $uploadedFile; |
|
1965 | - |
|
1966 | - $uploads = wp_upload_dir(); |
|
1967 | - $uploads_dir = $uploads['path']; |
|
1968 | - $image_name_arr = explode('/', $filename); |
|
1969 | - $filename = end($image_name_arr); |
|
1970 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1971 | - $return = array(); |
|
1972 | - $return['file'] = $uploadedFile; |
|
1973 | - $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); |
|
1974 | - |
|
1975 | - if (is_file($target_path) && file_exists($target_path) && $uploadedFile) { |
|
1976 | - $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
1977 | - |
|
1978 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
1979 | - $return['error'] = NULL; |
|
1980 | - |
|
1981 | - $return['rows'] = 0; |
|
1982 | - |
|
1983 | - |
|
1984 | - |
|
1985 | - if (($handle = fopen($target_path, "r")) !== FALSE) { |
|
1986 | - while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
|
1987 | - if(is_array($data) && !empty($data)) { |
|
1988 | - $file[] = '"' . implode('","', $data) . '"'; |
|
1989 | - } |
|
1990 | - } |
|
1991 | - fclose($handle); |
|
1992 | - $file = $file; |
|
1993 | - } |
|
1994 | - |
|
1995 | - |
|
1996 | - |
|
1997 | - $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
1998 | - |
|
1999 | - |
|
2000 | - if (!$return['rows'] > 0) { |
|
2001 | - $return['error'] = __('No data found in csv file.', 'geodirectory'); |
|
2002 | - } |
|
2003 | - } |
|
2004 | - } |
|
2005 | - if ($task == 'prepare' || !empty($return['error'])) { |
|
2006 | - echo json_encode($return); |
|
2007 | - exit; |
|
2008 | - } |
|
2009 | - |
|
2010 | - $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
2011 | - $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
2012 | - $count = $importlimit; |
|
2013 | - $requested_limit = $importlimit; |
|
2014 | - $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
2015 | - |
|
2016 | - if ($count < $totRecords) { |
|
2017 | - $count = $tmpCnt + $count; |
|
2018 | - if ($count > $totRecords) { |
|
2019 | - $count = $totRecords; |
|
2020 | - } |
|
2021 | - } else { |
|
2022 | - $count = $totRecords; |
|
2023 | - } |
|
2024 | - |
|
2025 | - $total_records = 0; |
|
2026 | - $rowcount = 0; |
|
2027 | - $address_invalid = 0; |
|
2028 | - $blank_address = 0; |
|
2029 | - $upload_files = 0; |
|
2030 | - $invalid_post_type = 0; |
|
2031 | - $invalid_title = 0; |
|
2032 | - $customKeyarray = array(); |
|
2033 | - $gd_post_info = array(); |
|
2034 | - $post_location = array(); |
|
2035 | - $countpost = 0; |
|
2036 | - |
|
2037 | - if (!empty($file)) { |
|
2038 | - $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
2039 | - $customKeyarray = $columns; |
|
2040 | - |
|
2041 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
2042 | - $return['error'] = CSV_INVAILD_FILE; |
|
2043 | - echo json_encode($return); |
|
2044 | - exit; |
|
2045 | - } |
|
2046 | - |
|
2047 | - for ($i = 1; $i <= $importlimit; $i++) { |
|
2048 | - $current_index = $tmpCnt + $i; |
|
2049 | - if (isset($file[$current_index])) { |
|
2050 | - $total_records++; |
|
2051 | - |
|
2052 | - $buffer = geodir_str_getcsv($file[$current_index]); |
|
2053 | - $post_title = addslashes($buffer[0]); |
|
2054 | - $current_post_author = $buffer[1]; |
|
2055 | - $post_desc = addslashes($buffer[2]); |
|
2056 | - $post_cat = array(); |
|
2057 | - $catids_arr = array(); |
|
2058 | - $post_cat = trim($buffer[3]); // comma seperated category name |
|
2059 | - |
|
2060 | - if ($post_cat) { |
|
2061 | - $post_cat_arr = explode(',', $post_cat); |
|
2062 | - |
|
2063 | - for ($c = 0; $c < count($post_cat_arr); $c++) { |
|
2064 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
2065 | - |
|
2066 | - if (!empty($buffer[5])) { |
|
2067 | - if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2068 | - |
|
2069 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
2070 | - |
|
2071 | - if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2072 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2073 | - $catids_arr[] = $cat->slug; |
|
2074 | - } else if (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2075 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2076 | - $catids_arr[] = $cat->slug; |
|
2077 | - } else { |
|
2078 | - $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
2079 | - if ($ret && !is_wp_error($ret)) { |
|
2080 | - if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2081 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2082 | - $catids_arr[] = $cat->slug; |
|
2083 | - } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2084 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2085 | - $catids_arr[] = $cat->slug; |
|
2086 | - } |
|
2087 | - } |
|
2088 | - } |
|
2089 | - } |
|
2090 | - } |
|
2091 | - } |
|
2092 | - } |
|
2093 | - |
|
2094 | - if (!$catids_arr) { |
|
2095 | - $catids_arr[] = 1; |
|
2096 | - } |
|
2097 | - |
|
2098 | - $post_tags = trim($buffer[4]); // comma seperated tags |
|
2099 | - |
|
2100 | - $tag_arr = ''; |
|
2101 | - if ($post_tags) { |
|
2102 | - $tag_arr = explode(',', $post_tags); |
|
2103 | - } |
|
2104 | - |
|
2105 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
2106 | - |
|
2107 | - $error = ''; |
|
2108 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { |
|
2109 | - $invalid_post_type++; |
|
2110 | - continue; |
|
2111 | - } |
|
2112 | - |
|
2113 | - if ($post_title != '') { |
|
2114 | - $menu_order = 0; |
|
2115 | - $image_folder_name = 'uplaod/'; |
|
2116 | - |
|
2117 | - $image_names = array(); |
|
2118 | - |
|
2119 | - for ($c = 5; $c < count($customKeyarray); $c++) { |
|
2120 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
2121 | - |
|
2122 | - if ($customKeyarray[$c] == 'IMAGE') { |
|
2123 | - $buffer[$c] = trim($buffer[$c]); |
|
2124 | - |
|
2125 | - if (!empty($buffer[$c])) { |
|
2126 | - $image_names[] = $buffer[$c]; |
|
2127 | - } |
|
2128 | - } |
|
2129 | - |
|
2130 | - if ($customKeyarray[$c] == 'alive_days') { |
|
2131 | - if ($buffer[$c] != '0' && $buffer[$c] != '') { |
|
2132 | - $submitdata = date('Y-m-d'); |
|
2133 | - |
|
2134 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); |
|
2135 | - } else { |
|
2136 | - $gd_post_info['expire_date'] = 'Never'; |
|
2137 | - } |
|
2138 | - } |
|
2139 | - |
|
2140 | - if ($customKeyarray[$c] == 'post_city') { |
|
2141 | - $post_city = addslashes($buffer[$c]); |
|
2142 | - } |
|
2143 | - |
|
2144 | - if ($customKeyarray[$c] == 'post_region') { |
|
2145 | - $post_region = addslashes($buffer[$c]); |
|
2146 | - } |
|
2147 | - |
|
2148 | - if ($customKeyarray[$c] == 'post_country') { |
|
2149 | - $post_country = addslashes($buffer[$c]); |
|
2150 | - } |
|
2151 | - |
|
2152 | - if ($customKeyarray[$c] == 'post_latitude') { |
|
2153 | - $post_latitude = addslashes($buffer[$c]); |
|
2154 | - } |
|
2155 | - |
|
2156 | - if ($customKeyarray[$c] == 'post_longitude') { |
|
2157 | - $post_longitude = addslashes($buffer[$c]); |
|
2158 | - } |
|
1962 | + $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
1963 | + $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
1964 | + $filename = $uploadedFile; |
|
1965 | + |
|
1966 | + $uploads = wp_upload_dir(); |
|
1967 | + $uploads_dir = $uploads['path']; |
|
1968 | + $image_name_arr = explode('/', $filename); |
|
1969 | + $filename = end($image_name_arr); |
|
1970 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1971 | + $return = array(); |
|
1972 | + $return['file'] = $uploadedFile; |
|
1973 | + $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); |
|
1974 | + |
|
1975 | + if (is_file($target_path) && file_exists($target_path) && $uploadedFile) { |
|
1976 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
1977 | + |
|
1978 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
1979 | + $return['error'] = NULL; |
|
1980 | + |
|
1981 | + $return['rows'] = 0; |
|
1982 | + |
|
1983 | + |
|
1984 | + |
|
1985 | + if (($handle = fopen($target_path, "r")) !== FALSE) { |
|
1986 | + while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
|
1987 | + if(is_array($data) && !empty($data)) { |
|
1988 | + $file[] = '"' . implode('","', $data) . '"'; |
|
1989 | + } |
|
1990 | + } |
|
1991 | + fclose($handle); |
|
1992 | + $file = $file; |
|
1993 | + } |
|
1994 | + |
|
1995 | + |
|
1996 | + |
|
1997 | + $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
1998 | + |
|
1999 | + |
|
2000 | + if (!$return['rows'] > 0) { |
|
2001 | + $return['error'] = __('No data found in csv file.', 'geodirectory'); |
|
2002 | + } |
|
2003 | + } |
|
2004 | + } |
|
2005 | + if ($task == 'prepare' || !empty($return['error'])) { |
|
2006 | + echo json_encode($return); |
|
2007 | + exit; |
|
2008 | + } |
|
2009 | + |
|
2010 | + $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
2011 | + $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
2012 | + $count = $importlimit; |
|
2013 | + $requested_limit = $importlimit; |
|
2014 | + $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
2015 | + |
|
2016 | + if ($count < $totRecords) { |
|
2017 | + $count = $tmpCnt + $count; |
|
2018 | + if ($count > $totRecords) { |
|
2019 | + $count = $totRecords; |
|
2020 | + } |
|
2021 | + } else { |
|
2022 | + $count = $totRecords; |
|
2023 | + } |
|
2024 | + |
|
2025 | + $total_records = 0; |
|
2026 | + $rowcount = 0; |
|
2027 | + $address_invalid = 0; |
|
2028 | + $blank_address = 0; |
|
2029 | + $upload_files = 0; |
|
2030 | + $invalid_post_type = 0; |
|
2031 | + $invalid_title = 0; |
|
2032 | + $customKeyarray = array(); |
|
2033 | + $gd_post_info = array(); |
|
2034 | + $post_location = array(); |
|
2035 | + $countpost = 0; |
|
2036 | + |
|
2037 | + if (!empty($file)) { |
|
2038 | + $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
2039 | + $customKeyarray = $columns; |
|
2040 | + |
|
2041 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
2042 | + $return['error'] = CSV_INVAILD_FILE; |
|
2043 | + echo json_encode($return); |
|
2044 | + exit; |
|
2045 | + } |
|
2046 | + |
|
2047 | + for ($i = 1; $i <= $importlimit; $i++) { |
|
2048 | + $current_index = $tmpCnt + $i; |
|
2049 | + if (isset($file[$current_index])) { |
|
2050 | + $total_records++; |
|
2051 | + |
|
2052 | + $buffer = geodir_str_getcsv($file[$current_index]); |
|
2053 | + $post_title = addslashes($buffer[0]); |
|
2054 | + $current_post_author = $buffer[1]; |
|
2055 | + $post_desc = addslashes($buffer[2]); |
|
2056 | + $post_cat = array(); |
|
2057 | + $catids_arr = array(); |
|
2058 | + $post_cat = trim($buffer[3]); // comma seperated category name |
|
2059 | + |
|
2060 | + if ($post_cat) { |
|
2061 | + $post_cat_arr = explode(',', $post_cat); |
|
2062 | + |
|
2063 | + for ($c = 0; $c < count($post_cat_arr); $c++) { |
|
2064 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
2065 | + |
|
2066 | + if (!empty($buffer[5])) { |
|
2067 | + if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2068 | + |
|
2069 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
2070 | + |
|
2071 | + if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2072 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2073 | + $catids_arr[] = $cat->slug; |
|
2074 | + } else if (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2075 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2076 | + $catids_arr[] = $cat->slug; |
|
2077 | + } else { |
|
2078 | + $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
2079 | + if ($ret && !is_wp_error($ret)) { |
|
2080 | + if (get_term_by('name', $catid, $p_taxonomy[0])) { |
|
2081 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]); |
|
2082 | + $catids_arr[] = $cat->slug; |
|
2083 | + } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) { |
|
2084 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]); |
|
2085 | + $catids_arr[] = $cat->slug; |
|
2086 | + } |
|
2087 | + } |
|
2088 | + } |
|
2089 | + } |
|
2090 | + } |
|
2091 | + } |
|
2092 | + } |
|
2093 | + |
|
2094 | + if (!$catids_arr) { |
|
2095 | + $catids_arr[] = 1; |
|
2096 | + } |
|
2097 | + |
|
2098 | + $post_tags = trim($buffer[4]); // comma seperated tags |
|
2099 | + |
|
2100 | + $tag_arr = ''; |
|
2101 | + if ($post_tags) { |
|
2102 | + $tag_arr = explode(',', $post_tags); |
|
2103 | + } |
|
2104 | + |
|
2105 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
2106 | + |
|
2107 | + $error = ''; |
|
2108 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { |
|
2109 | + $invalid_post_type++; |
|
2110 | + continue; |
|
2111 | + } |
|
2112 | + |
|
2113 | + if ($post_title != '') { |
|
2114 | + $menu_order = 0; |
|
2115 | + $image_folder_name = 'uplaod/'; |
|
2116 | + |
|
2117 | + $image_names = array(); |
|
2118 | + |
|
2119 | + for ($c = 5; $c < count($customKeyarray); $c++) { |
|
2120 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
2121 | + |
|
2122 | + if ($customKeyarray[$c] == 'IMAGE') { |
|
2123 | + $buffer[$c] = trim($buffer[$c]); |
|
2124 | + |
|
2125 | + if (!empty($buffer[$c])) { |
|
2126 | + $image_names[] = $buffer[$c]; |
|
2127 | + } |
|
2128 | + } |
|
2129 | + |
|
2130 | + if ($customKeyarray[$c] == 'alive_days') { |
|
2131 | + if ($buffer[$c] != '0' && $buffer[$c] != '') { |
|
2132 | + $submitdata = date('Y-m-d'); |
|
2133 | + |
|
2134 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); |
|
2135 | + } else { |
|
2136 | + $gd_post_info['expire_date'] = 'Never'; |
|
2137 | + } |
|
2138 | + } |
|
2139 | + |
|
2140 | + if ($customKeyarray[$c] == 'post_city') { |
|
2141 | + $post_city = addslashes($buffer[$c]); |
|
2142 | + } |
|
2143 | + |
|
2144 | + if ($customKeyarray[$c] == 'post_region') { |
|
2145 | + $post_region = addslashes($buffer[$c]); |
|
2146 | + } |
|
2147 | + |
|
2148 | + if ($customKeyarray[$c] == 'post_country') { |
|
2149 | + $post_country = addslashes($buffer[$c]); |
|
2150 | + } |
|
2151 | + |
|
2152 | + if ($customKeyarray[$c] == 'post_latitude') { |
|
2153 | + $post_latitude = addslashes($buffer[$c]); |
|
2154 | + } |
|
2155 | + |
|
2156 | + if ($customKeyarray[$c] == 'post_longitude') { |
|
2157 | + $post_longitude = addslashes($buffer[$c]); |
|
2158 | + } |
|
2159 | 2159 | |
2160 | 2160 | // Post status |
2161 | 2161 | if ($customKeyarray[$c] == 'post_status') { |
2162 | - $post_status = sanitize_key( $buffer[$c] ); |
|
2163 | - } |
|
2164 | - } |
|
2165 | - |
|
2166 | - /* ================ before array create ============== */ |
|
2167 | - $location_result = geodir_get_default_location(); |
|
2168 | - 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'] == '')) { |
|
2169 | - $blank_address++; |
|
2170 | - continue; |
|
2171 | - } else if ($location_result->location_id == 0) { |
|
2172 | - 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))) { |
|
2173 | - $address_invalid++; |
|
2174 | - continue; |
|
2175 | - } |
|
2176 | - } |
|
2162 | + $post_status = sanitize_key( $buffer[$c] ); |
|
2163 | + } |
|
2164 | + } |
|
2165 | + |
|
2166 | + /* ================ before array create ============== */ |
|
2167 | + $location_result = geodir_get_default_location(); |
|
2168 | + 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'] == '')) { |
|
2169 | + $blank_address++; |
|
2170 | + continue; |
|
2171 | + } else if ($location_result->location_id == 0) { |
|
2172 | + 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))) { |
|
2173 | + $address_invalid++; |
|
2174 | + continue; |
|
2175 | + } |
|
2176 | + } |
|
2177 | 2177 | |
2178 | 2178 | // Default post status |
2179 | 2179 | $default_status = 'publish'; |
2180 | 2180 | $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
2181 | 2181 | $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
2182 | 2182 | |
2183 | - $my_post['post_title'] = $post_title; |
|
2184 | - $my_post['post_content'] = $post_desc; |
|
2185 | - $my_post['post_type'] = addslashes($buffer[5]); |
|
2186 | - $my_post['post_author'] = $current_post_author; |
|
2187 | - $my_post['post_status'] = $post_status; |
|
2188 | - $my_post['post_category'] = $catids_arr; |
|
2189 | - $my_post['post_tags'] = $tag_arr; |
|
2190 | - |
|
2191 | - $gd_post_info['post_tags'] = $tag_arr; |
|
2192 | - $gd_post_info['post_title'] = $post_title; |
|
2193 | - $gd_post_info['post_status'] = $post_status; |
|
2194 | - $gd_post_info['submit_time'] = time(); |
|
2195 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
2196 | - |
|
2197 | - $last_postid = wp_insert_post($my_post); |
|
2198 | - $countpost++; |
|
2199 | - |
|
2200 | - // Check if we need to save post location as new location |
|
2201 | - if ($location_result->location_id > 0) { |
|
2202 | - if (isset($post_city) && isset($post_region)) { |
|
2203 | - $request_info['post_location'] = array( |
|
2204 | - 'city' => $post_city, |
|
2205 | - 'region' => $post_region, |
|
2206 | - 'country' => $post_country, |
|
2207 | - 'geo_lat' => $post_latitude, |
|
2208 | - 'geo_lng' => $post_longitude |
|
2209 | - ); |
|
2210 | - |
|
2211 | - $post_location_info = $request_info['post_location']; |
|
2212 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
2213 | - $post_location_id = $location_id; |
|
2214 | - } else { |
|
2215 | - $post_location_id = 0; |
|
2216 | - } |
|
2217 | - } else { |
|
2218 | - $post_location_id = 0; |
|
2219 | - } |
|
2220 | - |
|
2221 | - /* ------- get default package info ----- */ |
|
2222 | - $payment_info = array(); |
|
2223 | - $package_info = array(); |
|
2224 | - |
|
2225 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
2226 | - $package_id = ''; |
|
2227 | - if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { |
|
2228 | - $package_id = $gd_post_info['package_id']; |
|
2229 | - } |
|
2230 | - |
|
2231 | - if (!empty($package_info)) { |
|
2232 | - $payment_info['package_id'] = $package_info['pid']; |
|
2233 | - |
|
2234 | - if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { |
|
2235 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); |
|
2236 | - } else { |
|
2237 | - $payment_info['expire_date'] = 'Never'; |
|
2238 | - } |
|
2239 | - |
|
2240 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
2241 | - } |
|
2242 | - |
|
2243 | - $gd_post_info['post_location_id'] = $post_location_id; |
|
2244 | - |
|
2245 | - $post_type = get_post_type($last_postid); |
|
2246 | - |
|
2247 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2248 | - |
|
2249 | - geodir_save_post_info($last_postid, $gd_post_info); |
|
2250 | - |
|
2251 | - if (!empty($image_names)) { |
|
2252 | - $upload_files++; |
|
2253 | - $menu_order = 1; |
|
2254 | - |
|
2255 | - foreach ($image_names as $image_name) { |
|
2256 | - $img_name_arr = explode('.', $image_name); |
|
2257 | - |
|
2258 | - $uploads = wp_upload_dir(); |
|
2259 | - $sub_dir = $uploads['subdir']; |
|
2260 | - |
|
2261 | - $arr_file_type = wp_check_filetype($image_name); |
|
2262 | - $uploaded_file_type = $arr_file_type['type']; |
|
2263 | - |
|
2264 | - $attachment = array(); |
|
2265 | - $attachment['post_id'] = $last_postid; |
|
2266 | - $attachment['title'] = $img_name_arr[0]; |
|
2267 | - $attachment['content'] = ''; |
|
2268 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
2269 | - $attachment['mime_type'] = $uploaded_file_type; |
|
2270 | - $attachment['menu_order'] = $menu_order; |
|
2271 | - $attachment['is_featured'] = 0; |
|
2272 | - |
|
2273 | - $attachment_set = ''; |
|
2274 | - |
|
2275 | - foreach ($attachment as $key => $val) { |
|
2276 | - if ($val != '') |
|
2277 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
2278 | - } |
|
2279 | - $attachment_set = trim($attachment_set, ", "); |
|
2280 | - |
|
2281 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
2282 | - |
|
2283 | - if ($menu_order == 1) { |
|
2284 | - $post_type = get_post_type($last_postid); |
|
2285 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); |
|
2286 | - } |
|
2287 | - $menu_order++; |
|
2288 | - } |
|
2289 | - } |
|
2290 | - |
|
2291 | - $gd_post_info['package_id'] = $package_id; |
|
2292 | - |
|
2293 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
2294 | - do_action('geodir_after_save_listing', $last_postid, $gd_post_info); |
|
2295 | - |
|
2296 | - if (!empty($buffer[5])) { |
|
2297 | - if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2298 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
2299 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
2300 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
2301 | - |
|
2302 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
2303 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
2304 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
2305 | - } |
|
2306 | - } |
|
2307 | - } else { |
|
2308 | - $invalid_title++; |
|
2309 | - } |
|
2310 | - } |
|
2311 | - } |
|
2312 | - } |
|
2313 | - $return['rowcount'] = $countpost; |
|
2314 | - $return['invalidcount'] = $address_invalid; |
|
2315 | - $return['blank_address'] = $blank_address; |
|
2316 | - $return['upload_files'] = $upload_files; |
|
2317 | - $return['invalid_post_type'] = $invalid_post_type; |
|
2318 | - $return['invalid_title'] = $invalid_title; |
|
2319 | - $return['total_records'] = $total_records; |
|
2320 | - |
|
2321 | - echo json_encode($return); |
|
2322 | - exit; |
|
2183 | + $my_post['post_title'] = $post_title; |
|
2184 | + $my_post['post_content'] = $post_desc; |
|
2185 | + $my_post['post_type'] = addslashes($buffer[5]); |
|
2186 | + $my_post['post_author'] = $current_post_author; |
|
2187 | + $my_post['post_status'] = $post_status; |
|
2188 | + $my_post['post_category'] = $catids_arr; |
|
2189 | + $my_post['post_tags'] = $tag_arr; |
|
2190 | + |
|
2191 | + $gd_post_info['post_tags'] = $tag_arr; |
|
2192 | + $gd_post_info['post_title'] = $post_title; |
|
2193 | + $gd_post_info['post_status'] = $post_status; |
|
2194 | + $gd_post_info['submit_time'] = time(); |
|
2195 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
2196 | + |
|
2197 | + $last_postid = wp_insert_post($my_post); |
|
2198 | + $countpost++; |
|
2199 | + |
|
2200 | + // Check if we need to save post location as new location |
|
2201 | + if ($location_result->location_id > 0) { |
|
2202 | + if (isset($post_city) && isset($post_region)) { |
|
2203 | + $request_info['post_location'] = array( |
|
2204 | + 'city' => $post_city, |
|
2205 | + 'region' => $post_region, |
|
2206 | + 'country' => $post_country, |
|
2207 | + 'geo_lat' => $post_latitude, |
|
2208 | + 'geo_lng' => $post_longitude |
|
2209 | + ); |
|
2210 | + |
|
2211 | + $post_location_info = $request_info['post_location']; |
|
2212 | + if ($location_id = geodir_add_new_location($post_location_info)) |
|
2213 | + $post_location_id = $location_id; |
|
2214 | + } else { |
|
2215 | + $post_location_id = 0; |
|
2216 | + } |
|
2217 | + } else { |
|
2218 | + $post_location_id = 0; |
|
2219 | + } |
|
2220 | + |
|
2221 | + /* ------- get default package info ----- */ |
|
2222 | + $payment_info = array(); |
|
2223 | + $package_info = array(); |
|
2224 | + |
|
2225 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
2226 | + $package_id = ''; |
|
2227 | + if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { |
|
2228 | + $package_id = $gd_post_info['package_id']; |
|
2229 | + } |
|
2230 | + |
|
2231 | + if (!empty($package_info)) { |
|
2232 | + $payment_info['package_id'] = $package_info['pid']; |
|
2233 | + |
|
2234 | + if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { |
|
2235 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); |
|
2236 | + } else { |
|
2237 | + $payment_info['expire_date'] = 'Never'; |
|
2238 | + } |
|
2239 | + |
|
2240 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
2241 | + } |
|
2242 | + |
|
2243 | + $gd_post_info['post_location_id'] = $post_location_id; |
|
2244 | + |
|
2245 | + $post_type = get_post_type($last_postid); |
|
2246 | + |
|
2247 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
2248 | + |
|
2249 | + geodir_save_post_info($last_postid, $gd_post_info); |
|
2250 | + |
|
2251 | + if (!empty($image_names)) { |
|
2252 | + $upload_files++; |
|
2253 | + $menu_order = 1; |
|
2254 | + |
|
2255 | + foreach ($image_names as $image_name) { |
|
2256 | + $img_name_arr = explode('.', $image_name); |
|
2257 | + |
|
2258 | + $uploads = wp_upload_dir(); |
|
2259 | + $sub_dir = $uploads['subdir']; |
|
2260 | + |
|
2261 | + $arr_file_type = wp_check_filetype($image_name); |
|
2262 | + $uploaded_file_type = $arr_file_type['type']; |
|
2263 | + |
|
2264 | + $attachment = array(); |
|
2265 | + $attachment['post_id'] = $last_postid; |
|
2266 | + $attachment['title'] = $img_name_arr[0]; |
|
2267 | + $attachment['content'] = ''; |
|
2268 | + $attachment['file'] = $sub_dir . '/' . $image_name; |
|
2269 | + $attachment['mime_type'] = $uploaded_file_type; |
|
2270 | + $attachment['menu_order'] = $menu_order; |
|
2271 | + $attachment['is_featured'] = 0; |
|
2272 | + |
|
2273 | + $attachment_set = ''; |
|
2274 | + |
|
2275 | + foreach ($attachment as $key => $val) { |
|
2276 | + if ($val != '') |
|
2277 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
2278 | + } |
|
2279 | + $attachment_set = trim($attachment_set, ", "); |
|
2280 | + |
|
2281 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
2282 | + |
|
2283 | + if ($menu_order == 1) { |
|
2284 | + $post_type = get_post_type($last_postid); |
|
2285 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); |
|
2286 | + } |
|
2287 | + $menu_order++; |
|
2288 | + } |
|
2289 | + } |
|
2290 | + |
|
2291 | + $gd_post_info['package_id'] = $package_id; |
|
2292 | + |
|
2293 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
2294 | + do_action('geodir_after_save_listing', $last_postid, $gd_post_info); |
|
2295 | + |
|
2296 | + if (!empty($buffer[5])) { |
|
2297 | + if (in_array($buffer[5], geodir_get_posttypes())) { |
|
2298 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
2299 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
2300 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
2301 | + |
|
2302 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
2303 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
2304 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
2305 | + } |
|
2306 | + } |
|
2307 | + } else { |
|
2308 | + $invalid_title++; |
|
2309 | + } |
|
2310 | + } |
|
2311 | + } |
|
2312 | + } |
|
2313 | + $return['rowcount'] = $countpost; |
|
2314 | + $return['invalidcount'] = $address_invalid; |
|
2315 | + $return['blank_address'] = $blank_address; |
|
2316 | + $return['upload_files'] = $upload_files; |
|
2317 | + $return['invalid_post_type'] = $invalid_post_type; |
|
2318 | + $return['invalid_title'] = $invalid_title; |
|
2319 | + $return['total_records'] = $total_records; |
|
2320 | + |
|
2321 | + echo json_encode($return); |
|
2322 | + exit; |
|
2323 | 2323 | } |
2324 | 2324 | |
2325 | 2325 | // Add the tab in left sidebar menu fro import & export page. |
@@ -2339,9 +2339,9 @@ discard block |
||
2339 | 2339 | * @param $post object $post The post object of the post being saved. |
2340 | 2340 | */ |
2341 | 2341 | function geodir_update_location_prefix($post_id,$post){ |
2342 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){ |
|
2343 | - update_option('geodir_location_prefix',$post->post_name); |
|
2344 | - } |
|
2342 | + if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){ |
|
2343 | + update_option('geodir_location_prefix',$post->post_name); |
|
2344 | + } |
|
2345 | 2345 | |
2346 | 2346 | } |
2347 | 2347 | |
@@ -2352,50 +2352,50 @@ discard block |
||
2352 | 2352 | function geodir_ga_callback(){ |
2353 | 2353 | |
2354 | 2354 | if(isset($_REQUEST['code']) && $_REQUEST['code']) { |
2355 | - $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
2356 | - $code = "code=".$_REQUEST['code']; |
|
2357 | - $grant_type = "&grant_type=authorization_code"; |
|
2358 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
2359 | - $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
2360 | - $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
|
2355 | + $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
2356 | + $code = "code=".$_REQUEST['code']; |
|
2357 | + $grant_type = "&grant_type=authorization_code"; |
|
2358 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
2359 | + $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
2360 | + $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
|
2361 | 2361 | |
2362 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
2362 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
2363 | 2363 | |
2364 | - $response = wp_remote_post($auth_url, array('timeout' => 15)); |
|
2364 | + $response = wp_remote_post($auth_url, array('timeout' => 15)); |
|
2365 | 2365 | |
2366 | - //print_r($response); |
|
2366 | + //print_r($response); |
|
2367 | 2367 | |
2368 | - $error_msg = __('Something went wrong','geodirectory'); |
|
2369 | - if(!empty($response['response']['code']) && $response['response']['code']==200){ |
|
2368 | + $error_msg = __('Something went wrong','geodirectory'); |
|
2369 | + if(!empty($response['response']['code']) && $response['response']['code']==200){ |
|
2370 | 2370 | |
2371 | - $parts = json_decode($response['body']); |
|
2372 | - //print_r($parts); |
|
2373 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2374 | - else{ |
|
2371 | + $parts = json_decode($response['body']); |
|
2372 | + //print_r($parts); |
|
2373 | + if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2374 | + else{ |
|
2375 | 2375 | |
2376 | - update_option('gd_ga_access_token', $parts->access_token); |
|
2377 | - update_option('gd_ga_refresh_token', $parts->refresh_token); |
|
2378 | - ?><script>window.close();</script><?php |
|
2379 | - } |
|
2376 | + update_option('gd_ga_access_token', $parts->access_token); |
|
2377 | + update_option('gd_ga_refresh_token', $parts->refresh_token); |
|
2378 | + ?><script>window.close();</script><?php |
|
2379 | + } |
|
2380 | 2380 | |
2381 | 2381 | |
2382 | - } |
|
2383 | - elseif(!empty($response['response']['code'])) { |
|
2384 | - $parts = json_decode($response['body']); |
|
2382 | + } |
|
2383 | + elseif(!empty($response['response']['code'])) { |
|
2384 | + $parts = json_decode($response['body']); |
|
2385 | 2385 | |
2386 | - if(isset($parts->error)){ |
|
2387 | - echo $parts->error.": ".$parts->error_description;exit; |
|
2388 | - }else{ |
|
2389 | - echo $error_msg." - #2";exit; |
|
2390 | - } |
|
2386 | + if(isset($parts->error)){ |
|
2387 | + echo $parts->error.": ".$parts->error_description;exit; |
|
2388 | + }else{ |
|
2389 | + echo $error_msg." - #2";exit; |
|
2390 | + } |
|
2391 | 2391 | |
2392 | - }else{ |
|
2392 | + }else{ |
|
2393 | 2393 | |
2394 | - echo $error_msg." - #3";exit; |
|
2394 | + echo $error_msg." - #3";exit; |
|
2395 | 2395 | |
2396 | - } |
|
2396 | + } |
|
2397 | 2397 | } |
2398 | - exit; |
|
2398 | + exit; |
|
2399 | 2399 | } |
2400 | 2400 | |
2401 | 2401 | if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') { |
@@ -2411,45 +2411,45 @@ discard block |
||
2411 | 2411 | * @return array Array of settings. |
2412 | 2412 | */ |
2413 | 2413 | function geodir_uninstall_settings($general_settings) { |
2414 | - $settings = array(); |
|
2415 | - $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory')); |
|
2416 | - $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' )); |
|
2414 | + $settings = array(); |
|
2415 | + $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory')); |
|
2416 | + $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' )); |
|
2417 | 2417 | |
2418 | - $plugins = get_plugins(); |
|
2419 | - $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array()); |
|
2418 | + $plugins = get_plugins(); |
|
2419 | + $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array()); |
|
2420 | 2420 | |
2421 | - if (!empty($plugins) && !empty($un_plugins)) { |
|
2422 | - foreach ($plugins as $plugin => $data) { |
|
2423 | - $plugin_name = plugin_basename(dirname($plugin)); |
|
2421 | + if (!empty($plugins) && !empty($un_plugins)) { |
|
2422 | + foreach ($plugins as $plugin => $data) { |
|
2423 | + $plugin_name = plugin_basename(dirname($plugin)); |
|
2424 | 2424 | |
2425 | - if (in_array($plugin_name, $un_plugins)) { |
|
2426 | - $settings[] = array( |
|
2427 | - 'type' => 'checkbox', |
|
2428 | - 'id' => 'geodir_un_' . $plugin_name, |
|
2429 | - 'name' => $data['Name'], |
|
2430 | - 'desc' => __('Remove all data when deleted?', 'geodirectory'), |
|
2431 | - 'std' => '0' |
|
2432 | - ); |
|
2433 | - } |
|
2434 | - } |
|
2435 | - } |
|
2425 | + if (in_array($plugin_name, $un_plugins)) { |
|
2426 | + $settings[] = array( |
|
2427 | + 'type' => 'checkbox', |
|
2428 | + 'id' => 'geodir_un_' . $plugin_name, |
|
2429 | + 'name' => $data['Name'], |
|
2430 | + 'desc' => __('Remove all data when deleted?', 'geodirectory'), |
|
2431 | + 'std' => '0' |
|
2432 | + ); |
|
2433 | + } |
|
2434 | + } |
|
2435 | + } |
|
2436 | 2436 | |
2437 | - $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main'); |
|
2437 | + $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main'); |
|
2438 | 2438 | |
2439 | - /** |
|
2440 | - * Filter the uninstall settings array. |
|
2441 | - * |
|
2442 | - * @since 1.6.9 |
|
2443 | - * |
|
2444 | - * @param array $settings The settings array. |
|
2445 | - */ |
|
2446 | - $settings = apply_filters('geodir_uninstall_settings', $settings); |
|
2439 | + /** |
|
2440 | + * Filter the uninstall settings array. |
|
2441 | + * |
|
2442 | + * @since 1.6.9 |
|
2443 | + * |
|
2444 | + * @param array $settings The settings array. |
|
2445 | + */ |
|
2446 | + $settings = apply_filters('geodir_uninstall_settings', $settings); |
|
2447 | 2447 | |
2448 | - if (!empty($settings) && count($settings) > 3) { |
|
2449 | - return array_merge($general_settings, $settings); |
|
2450 | - } |
|
2448 | + if (!empty($settings) && count($settings) > 3) { |
|
2449 | + return array_merge($general_settings, $settings); |
|
2450 | + } |
|
2451 | 2451 | |
2452 | - return $general_settings; |
|
2452 | + return $general_settings; |
|
2453 | 2453 | } |
2454 | 2454 | add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1); |
2455 | 2455 | |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | * @since 1.6.9 |
2460 | 2460 | */ |
2461 | 2461 | function geodir_uninstall_settings_desc() { |
2462 | - echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>'; |
|
2462 | + echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>'; |
|
2463 | 2463 | } |
2464 | 2464 | add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc'); |
2465 | 2465 | |
@@ -2475,18 +2475,18 @@ discard block |
||
2475 | 2475 | * @return array The settings array. |
2476 | 2476 | */ |
2477 | 2477 | function geodir_resave_settings($settings = array()) { |
2478 | - if (!empty($settings) && is_array($settings)) { |
|
2479 | - $c = 0; |
|
2478 | + if (!empty($settings) && is_array($settings)) { |
|
2479 | + $c = 0; |
|
2480 | 2480 | |
2481 | - foreach ($settings as $setting) { |
|
2482 | - if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) { |
|
2483 | - $settings[$c]['std'] = $value; |
|
2484 | - } |
|
2485 | - $c++; |
|
2486 | - } |
|
2487 | - } |
|
2488 | - |
|
2489 | - return $settings; |
|
2481 | + foreach ($settings as $setting) { |
|
2482 | + if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) { |
|
2483 | + $settings[$c]['std'] = $value; |
|
2484 | + } |
|
2485 | + $c++; |
|
2486 | + } |
|
2487 | + } |
|
2488 | + |
|
2489 | + return $settings; |
|
2490 | 2490 | } |
2491 | 2491 | |
2492 | 2492 | /** |
@@ -2498,9 +2498,9 @@ discard block |
||
2498 | 2498 | * @return array The modified settings. |
2499 | 2499 | */ |
2500 | 2500 | function geodir_core_uninstall_settings($settings) { |
2501 | - $settings[] = plugin_basename(dirname(dirname(__FILE__))); |
|
2501 | + $settings[] = plugin_basename(dirname(dirname(__FILE__))); |
|
2502 | 2502 | |
2503 | - return $settings; |
|
2503 | + return $settings; |
|
2504 | 2504 | } |
2505 | 2505 | add_filter('geodir_plugins_uninstall_settings', 'geodir_core_uninstall_settings', 10, 1); |
2506 | 2506 | |
@@ -2514,32 +2514,32 @@ discard block |
||
2514 | 2514 | */ |
2515 | 2515 | function geodir_diagnose_reload_db_countries() |
2516 | 2516 | { |
2517 | - global $wpdb, $plugin_prefix; |
|
2518 | - |
|
2519 | - $is_error_during_diagnose = false; |
|
2520 | - $output_str = ''; |
|
2521 | - |
|
2522 | - $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE); |
|
2523 | - |
|
2524 | - |
|
2525 | - if ($delete) { |
|
2526 | - $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>"; |
|
2527 | - ob_start(); |
|
2528 | - geodir_diagnose_version_clear(); |
|
2529 | - ob_end_clean(); |
|
2530 | - }else{ |
|
2531 | - $output_str .= "<li><strong>" . __('Seomething went wrong.', 'geodirectory') . "</strong></li>"; |
|
2532 | - } |
|
2533 | - |
|
2534 | - if ($is_error_during_diagnose) { |
|
2535 | - $info_div_class = "geodir_problem_info"; |
|
2536 | - $fix_button_txt = ""; |
|
2537 | - } else { |
|
2538 | - $info_div_class = "geodir_noproblem_info"; |
|
2539 | - $fix_button_txt = ''; |
|
2540 | - } |
|
2541 | - echo "<ul class='$info_div_class'>"; |
|
2542 | - echo $output_str; |
|
2543 | - echo $fix_button_txt; |
|
2544 | - echo "</ul>"; |
|
2517 | + global $wpdb, $plugin_prefix; |
|
2518 | + |
|
2519 | + $is_error_during_diagnose = false; |
|
2520 | + $output_str = ''; |
|
2521 | + |
|
2522 | + $delete = $wpdb->query("TRUNCATE TABLE ".GEODIR_COUNTRIES_TABLE); |
|
2523 | + |
|
2524 | + |
|
2525 | + if ($delete) { |
|
2526 | + $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>"; |
|
2527 | + ob_start(); |
|
2528 | + geodir_diagnose_version_clear(); |
|
2529 | + ob_end_clean(); |
|
2530 | + }else{ |
|
2531 | + $output_str .= "<li><strong>" . __('Seomething went wrong.', 'geodirectory') . "</strong></li>"; |
|
2532 | + } |
|
2533 | + |
|
2534 | + if ($is_error_during_diagnose) { |
|
2535 | + $info_div_class = "geodir_problem_info"; |
|
2536 | + $fix_button_txt = ""; |
|
2537 | + } else { |
|
2538 | + $info_div_class = "geodir_noproblem_info"; |
|
2539 | + $fix_button_txt = ''; |
|
2540 | + } |
|
2541 | + echo "<ul class='$info_div_class'>"; |
|
2542 | + echo $output_str; |
|
2543 | + echo $fix_button_txt; |
|
2544 | + echo "</ul>"; |
|
2545 | 2545 | } |
2546 | 2546 | \ No newline at end of file |
@@ -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 | /** |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | |
237 | 237 | // Filter-Payment-Manager |
238 | 238 | |
239 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
239 | + add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side'); |
|
240 | 240 | |
241 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
241 | + add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high'); |
|
242 | 242 | |
243 | 243 | // no need of this box as all fields moved to main information box |
244 | 244 | //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' ); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | |
248 | 248 | } |
249 | 249 | |
250 | -add_action('save_post', 'geodir_post_information_save',10,2); |
|
250 | +add_action('save_post', 'geodir_post_information_save', 10, 2); |
|
251 | 251 | |
252 | 252 | |
253 | 253 | |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | |
275 | 275 | $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
276 | 276 | |
277 | - if(!empty($gd_taxonomy)) { |
|
277 | + if (!empty($gd_taxonomy)) { |
|
278 | 278 | foreach ($gd_taxonomy as $tax) { |
279 | 279 | |
280 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
280 | + remove_meta_box($tax.'div', $geodir_post_type, 'normal'); |
|
281 | 281 | |
282 | 282 | } |
283 | 283 | } |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined'); |
364 | 364 | add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom'); |
365 | 365 | |
366 | -function geodir_manage_available_fields_predefined($sub_tab){ |
|
367 | - if($sub_tab=='custom_fields'){ |
|
366 | +function geodir_manage_available_fields_predefined($sub_tab) { |
|
367 | + if ($sub_tab == 'custom_fields') { |
|
368 | 368 | geodir_custom_available_fields('predefined'); |
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | -function geodir_manage_available_fields_custom($sub_tab){ |
|
373 | - if($sub_tab=='custom_fields'){ |
|
372 | +function geodir_manage_available_fields_custom($sub_tab) { |
|
373 | + if ($sub_tab == 'custom_fields') { |
|
374 | 374 | geodir_custom_available_fields('custom'); |
375 | 375 | } |
376 | 376 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | global $wpdb; |
441 | 441 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
442 | 442 | ?> |
443 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
443 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
444 | 444 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
445 | 445 | <ul> |
446 | 446 | <?php |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | |
452 | 452 | $check_html_variable = $wpdb->get_var( |
453 | 453 | $wpdb->prepare( |
454 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
454 | + "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
455 | 455 | array($val['htmlvar_name'], $listing_type, $val['field_type']) |
456 | 456 | ) |
457 | 457 | ); |
@@ -459,23 +459,23 @@ discard block |
||
459 | 459 | $display = $check_html_variable ? ' style="display:none;"' : ''; |
460 | 460 | ?> |
461 | 461 | |
462 | - <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> |
|
462 | + <li class="gd-cf-tooltip-wrap" <?php echo $display; ?>> |
|
463 | 463 | <?php |
464 | - if(isset($val['description']) && $val['description']){ |
|
464 | + if (isset($val['description']) && $val['description']) { |
|
465 | 465 | echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
466 | 466 | }?> |
467 | 467 | |
468 | - <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'];?>" |
|
469 | - title="<?php echo $val['site_title'];?>" |
|
470 | - class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
|
468 | + <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']; ?>" |
|
469 | + title="<?php echo $val['site_title']; ?>" |
|
470 | + class="gd-draggable-form-items gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);"> |
|
471 | 471 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) { |
472 | 472 | echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
473 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
473 | + }elseif (isset($val['field_icon']) && $val['field_icon']) { |
|
474 | 474 | echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>'; |
475 | - }else{ |
|
475 | + } else { |
|
476 | 476 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
477 | 477 | }?> |
478 | - <?php echo $val['site_title'];?> |
|
478 | + <?php echo $val['site_title']; ?> |
|
479 | 479 | </a> |
480 | 480 | </li> |
481 | 481 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | <?php |
504 | 504 | global $wpdb; |
505 | 505 | |
506 | - $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))); |
|
506 | + $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))); |
|
507 | 507 | |
508 | 508 | if (!empty($fields)) { |
509 | 509 | foreach ($fields as $field) { |
@@ -528,14 +528,14 @@ discard block |
||
528 | 528 | * @since 1.6.9 |
529 | 529 | * @package GeoDirectory |
530 | 530 | */ |
531 | -function geodir_custom_fields_custom($post_type=''){ |
|
531 | +function geodir_custom_fields_custom($post_type = '') { |
|
532 | 532 | |
533 | 533 | $custom_fields = array(); |
534 | 534 | |
535 | 535 | /** |
536 | 536 | * @see `geodir_custom_fields` |
537 | 537 | */ |
538 | - return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type); |
|
538 | + return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @since 1.6.6 |
547 | 547 | * @package GeoDirectory |
548 | 548 | */ |
549 | -function geodir_custom_fields($post_type=''){ |
|
549 | +function geodir_custom_fields($post_type = '') { |
|
550 | 550 | |
551 | 551 | $custom_fields = array( |
552 | 552 | 'text' => array( |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * } |
682 | 682 | * @param string $post_type The post type requested. |
683 | 683 | */ |
684 | - return apply_filters('geodir_custom_fields',$custom_fields,$post_type); |
|
684 | + return apply_filters('geodir_custom_fields', $custom_fields, $post_type); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
@@ -692,25 +692,25 @@ discard block |
||
692 | 692 | * @param string $type The custom field type, predefined, custom or blank for default |
693 | 693 | * @package GeoDirectory |
694 | 694 | */ |
695 | -function geodir_custom_available_fields($type='') |
|
695 | +function geodir_custom_available_fields($type = '') |
|
696 | 696 | { |
697 | 697 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
698 | 698 | ?> |
699 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
699 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
700 | 700 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> |
701 | 701 | |
702 | 702 | <?php |
703 | - if($type=='predefined'){ |
|
703 | + if ($type == 'predefined') { |
|
704 | 704 | $cfs = geodir_custom_fields_predefined($listing_type); |
705 | - }elseif($type=='custom'){ |
|
705 | + }elseif ($type == 'custom') { |
|
706 | 706 | $cfs = geodir_custom_fields_custom($listing_type); |
707 | - }else{ |
|
707 | + } else { |
|
708 | 708 | $cfs = geodir_custom_fields($listing_type); |
709 | 709 | ?> |
710 | 710 | <ul class="full gd-cf-tooltip-wrap"> |
711 | 711 | <li> |
712 | 712 | <div class="gdcf-tooltip"> |
713 | - <?php _e('This adds a section separator with a title.', 'geodirectory');?> |
|
713 | + <?php _e('This adds a section separator with a title.', 'geodirectory'); ?> |
|
714 | 714 | </div> |
715 | 715 | <a id="gt-fieldset" |
716 | 716 | class="gd-draggable-form-items gt-fieldset" |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | |
722 | 722 | <i class="fa fa-long-arrow-left " aria-hidden="true"></i> |
723 | 723 | <i class="fa fa-long-arrow-right " aria-hidden="true"></i> |
724 | - <?php _e('Fieldset (section separator)', 'geodirectory');?> |
|
724 | + <?php _e('Fieldset (section separator)', 'geodirectory'); ?> |
|
725 | 725 | </a> |
726 | 726 | </li> |
727 | 727 | </ul> |
@@ -729,15 +729,15 @@ discard block |
||
729 | 729 | <?php |
730 | 730 | } |
731 | 731 | |
732 | - if(!empty($cfs)) { |
|
732 | + if (!empty($cfs)) { |
|
733 | 733 | echo '<ul>'; |
734 | - foreach ( $cfs as $id => $cf ) { |
|
734 | + foreach ($cfs as $id => $cf) { |
|
735 | 735 | ?> |
736 | 736 | |
737 | 737 | <li class="gd-cf-tooltip-wrap"> |
738 | 738 | <?php |
739 | - if ( isset( $cf['description'] ) && $cf['description'] ) { |
|
740 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
739 | + if (isset($cf['description']) && $cf['description']) { |
|
740 | + echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>'; |
|
741 | 741 | } ?> |
742 | 742 | |
743 | 743 | <a id="gd-<?php echo $id; ?>" |
@@ -747,10 +747,10 @@ discard block |
||
747 | 747 | class="gd-draggable-form-items <?php echo $cf['class']; ?>" |
748 | 748 | href="javascript:void(0);"> |
749 | 749 | |
750 | - <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) { |
|
751 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
752 | - } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) { |
|
753 | - echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>'; |
|
750 | + <?php if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) { |
|
751 | + echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>'; |
|
752 | + } elseif (isset($cf['icon']) && $cf['icon']) { |
|
753 | + echo '<b style="background-image: url("'.$cf['icon'].'")"></b>'; |
|
754 | 754 | } else { |
755 | 755 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
756 | 756 | } ?> |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | </li> |
760 | 760 | <?php |
761 | 761 | } |
762 | - }else{ |
|
762 | + } else { |
|
763 | 763 | _e('There are no custom fields here yet.', 'geodirectory'); |
764 | 764 | } |
765 | 765 | ?> |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | <ul class="core"> |
788 | 788 | <?php |
789 | 789 | global $wpdb; |
790 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
790 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type))); |
|
791 | 791 | |
792 | 792 | if (!empty($fields)) { |
793 | 793 | foreach ($fields as $field) { |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | $field_type_key = $field->field_type_key; |
798 | 798 | $field_ins_upd = 'display'; |
799 | 799 | |
800 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
800 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key); |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | ?></ul> |
@@ -956,8 +956,8 @@ discard block |
||
956 | 956 | |
957 | 957 | if (!get_option('geodir_remove_unnecessary_fields')) { |
958 | 958 | |
959 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
960 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
959 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'")) |
|
960 | + $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`"); |
|
961 | 961 | |
962 | 962 | update_option('geodir_remove_unnecessary_fields', '1'); |
963 | 963 | |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | case 'diagnosis' : |
987 | 987 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
988 | 988 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
989 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
989 | + call_user_func('geodir_diagnose_'.$diagnose_this); |
|
990 | 990 | |
991 | 991 | } |
992 | 992 | exit(); |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | case 'diagnosis-fix' : |
996 | 996 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
997 | 997 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
998 | - call_user_func('geodir_diagnose_' . $diagnose_this); |
|
998 | + call_user_func('geodir_diagnose_'.$diagnose_this); |
|
999 | 999 | exit(); |
1000 | 1000 | break; |
1001 | 1001 | } |
@@ -1020,50 +1020,50 @@ discard block |
||
1020 | 1020 | { |
1021 | 1021 | global $wpdb; |
1022 | 1022 | //$filter_arr['output_str'] .='###'.$table.'###'; |
1023 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) { |
|
1024 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>"; |
|
1023 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) { |
|
1024 | + $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>"; |
|
1025 | 1025 | $filter_arr['is_error_during_diagnose'] = true; |
1026 | 1026 | |
1027 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1028 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1027 | + } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) { |
|
1028 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>"; |
|
1029 | 1029 | $filter_arr['is_error_during_diagnose'] = true; |
1030 | - $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>"; |
|
1030 | + $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>"; |
|
1031 | 1031 | $filter_arr['is_error_during_diagnose'] = true; |
1032 | 1032 | |
1033 | 1033 | if ($fix) { |
1034 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count |
|
1035 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count |
|
1034 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count |
|
1035 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count |
|
1036 | 1036 | |
1037 | 1037 | if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2 |
1038 | 1038 | //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ; |
1039 | 1039 | |
1040 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table |
|
1040 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table |
|
1041 | 1041 | |
1042 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1043 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>"; |
|
1042 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) { |
|
1043 | + $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>"; |
|
1044 | 1044 | } else { |
1045 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1045 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>"; |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it |
1049 | 1049 | |
1050 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2 |
|
1051 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table |
|
1050 | + $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2 |
|
1051 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table |
|
1052 | 1052 | |
1053 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1054 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>"; |
|
1053 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1054 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>"; |
|
1055 | 1055 | } else { |
1056 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1056 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>"; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors |
1060 | 1060 | |
1061 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2 |
|
1061 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2 |
|
1062 | 1062 | |
1063 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) { |
|
1064 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>"; |
|
1063 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) { |
|
1064 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>"; |
|
1065 | 1065 | } else { |
1066 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>"; |
|
1066 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>"; |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | } |
@@ -1071,54 +1071,54 @@ discard block |
||
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | |
1074 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) { |
|
1075 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>"; |
|
1074 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) { |
|
1075 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>"; |
|
1076 | 1076 | $filter_arr['is_error_during_diagnose'] = true; |
1077 | 1077 | |
1078 | 1078 | if ($fix) { |
1079 | 1079 | if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it |
1080 | 1080 | if ($wpdb->query("DROP TABLE IF EXISTS $table")) { |
1081 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>"; |
|
1081 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>"; |
|
1082 | 1082 | } else { |
1083 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>"; |
|
1083 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>"; |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | - } 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 |
|
1087 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) { |
|
1088 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1086 | + } 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 |
|
1087 | + if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) { |
|
1088 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>"; |
|
1089 | 1089 | } else { |
1090 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>"; |
|
1090 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>"; |
|
1091 | 1091 | } |
1092 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1093 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1092 | + if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1093 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>"; |
|
1094 | 1094 | } else { |
1095 | - $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>"; |
|
1095 | + $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>"; |
|
1096 | 1096 | } |
1097 | 1097 | } else {// else rename the original table to _ms_bak |
1098 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1099 | - $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>"; |
|
1098 | + if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1099 | + $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>"; |
|
1100 | 1100 | } else { |
1101 | - $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>"; |
|
1101 | + $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>"; |
|
1102 | 1102 | } |
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | |
1106 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1107 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>"; |
|
1106 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) { |
|
1107 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>"; |
|
1108 | 1108 | $filter_arr['is_error_during_diagnose'] = true; |
1109 | 1109 | |
1110 | 1110 | if ($fix) { |
1111 | 1111 | // if original table exists but new does not, rename |
1112 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1113 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>"; |
|
1112 | + if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) { |
|
1113 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>"; |
|
1114 | 1114 | } else { |
1115 | - $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>"; |
|
1115 | + $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>"; |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | } |
1119 | 1119 | |
1120 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) { |
|
1121 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>"; |
|
1120 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) { |
|
1121 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>"; |
|
1122 | 1122 | $filter_arr['is_error_during_diagnose'] = true; |
1123 | 1123 | |
1124 | 1124 | if ($fix) { |
@@ -1132,11 +1132,11 @@ discard block |
||
1132 | 1132 | delete_option('geodir_custom_posts_db_version'); |
1133 | 1133 | delete_option('geodir_reviewratings_db_version'); |
1134 | 1134 | delete_option('geodiradvancesearch_db_version'); |
1135 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>"; |
|
1135 | + $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>"; |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | } else { |
1139 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>"; |
|
1139 | + $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>"; |
|
1140 | 1140 | } |
1141 | 1141 | return $filter_arr; |
1142 | 1142 | } |
@@ -1177,21 +1177,21 @@ discard block |
||
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | if ($stepped_process) { |
1180 | - $sql = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $ptype . "_detail LIMIT %d OFFSET %d", $step_max_items, $offset ); |
|
1181 | - $posts = $wpdb->get_results( $sql ); |
|
1180 | + $sql = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."geodir_".$ptype."_detail LIMIT %d OFFSET %d", $step_max_items, $offset); |
|
1181 | + $posts = $wpdb->get_results($sql); |
|
1182 | 1182 | |
1183 | 1183 | if (!empty($posts)) { |
1184 | 1184 | |
1185 | 1185 | foreach ($posts as $p) { |
1186 | 1186 | $p->post_type = $ptype; |
1187 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1187 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names')); |
|
1188 | 1188 | if (empty($raw_tags)) { |
1189 | 1189 | $post_tags = ''; |
1190 | 1190 | } else { |
1191 | 1191 | $post_tags = implode(",", $raw_tags); |
1192 | 1192 | } |
1193 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1194 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1193 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
1194 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1195 | 1195 | |
1196 | 1196 | } |
1197 | 1197 | if ($step >= $max_step) { |
@@ -1207,23 +1207,23 @@ discard block |
||
1207 | 1207 | if (!empty($all_postypes)) { |
1208 | 1208 | foreach ($all_postypes as $key) { |
1209 | 1209 | // update each GD CPT |
1210 | - $posts = $wpdb->get_results( "SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1210 | + $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail"); |
|
1211 | 1211 | |
1212 | 1212 | if (!empty($posts)) { |
1213 | 1213 | |
1214 | 1214 | foreach ($posts as $p) { |
1215 | 1215 | $p->post_type = $key; |
1216 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names')); |
|
1216 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names')); |
|
1217 | 1217 | if (empty($raw_tags)) { |
1218 | 1218 | $post_tags = ''; |
1219 | 1219 | } else { |
1220 | 1220 | $post_tags = implode(",", $raw_tags); |
1221 | 1221 | } |
1222 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1223 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1222 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
1223 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id)); |
|
1224 | 1224 | |
1225 | 1225 | } |
1226 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1226 | + $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>"; |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | } |
@@ -1234,14 +1234,14 @@ discard block |
||
1234 | 1234 | |
1235 | 1235 | if ($is_error_during_diagnose) { |
1236 | 1236 | $info_div_class = "geodir_problem_info"; |
1237 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1237 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1238 | 1238 | } else { |
1239 | 1239 | $info_div_class = "geodir_noproblem_info"; |
1240 | 1240 | $fix_button_txt = ''; |
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | if ($stepped_process) { |
1244 | - $percent = ($step/$max_step) * 100; |
|
1244 | + $percent = ($step / $max_step) * 100; |
|
1245 | 1245 | if ($output_str == 'done') { |
1246 | 1246 | echo $output_str; |
1247 | 1247 | } else { |
@@ -1284,29 +1284,29 @@ discard block |
||
1284 | 1284 | if (!empty($all_postypes)) { |
1285 | 1285 | foreach ($all_postypes as $key) { |
1286 | 1286 | // update each GD CTP |
1287 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' "); |
|
1287 | + $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' "); |
|
1288 | 1288 | |
1289 | 1289 | if (!empty($posts)) { |
1290 | 1290 | |
1291 | 1291 | foreach ($posts as $p) { |
1292 | 1292 | $p->post_type = $key; |
1293 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids')); |
|
1293 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids')); |
|
1294 | 1294 | |
1295 | 1295 | if (empty($raw_cats)) { |
1296 | 1296 | $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
1297 | 1297 | |
1298 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) { |
|
1299 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']); |
|
1300 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) { |
|
1298 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) { |
|
1299 | + $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']); |
|
1300 | + foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) { |
|
1301 | 1301 | if (is_numeric($cat_part)) { |
1302 | - $raw_cats[] = (int)$cat_part; |
|
1302 | + $raw_cats[] = (int) $cat_part; |
|
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | if (!empty($raw_cats)) { |
1309 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
1309 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category'); |
|
1310 | 1310 | |
1311 | 1311 | } |
1312 | 1312 | |
@@ -1316,14 +1316,14 @@ discard block |
||
1316 | 1316 | if (empty($raw_cats)) { |
1317 | 1317 | $post_cats = ''; |
1318 | 1318 | } else { |
1319 | - $post_cats = ',' . implode(",", $raw_cats) . ','; |
|
1319 | + $post_cats = ','.implode(",", $raw_cats).','; |
|
1320 | 1320 | } |
1321 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
1322 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1321 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
1322 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id)); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | } |
1326 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>"; |
|
1326 | + $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>"; |
|
1327 | 1327 | |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | |
1332 | 1332 | if ($is_error_during_diagnose) { |
1333 | 1333 | $info_div_class = "geodir_problem_info"; |
1334 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1334 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1335 | 1335 | } else { |
1336 | 1336 | $info_div_class = "geodir_noproblem_info"; |
1337 | 1337 | $fix_button_txt = ''; |
@@ -1384,15 +1384,15 @@ discard block |
||
1384 | 1384 | if (!empty($ver_arr)) { |
1385 | 1385 | foreach ($ver_arr as $key => $val) { |
1386 | 1386 | if (delete_option($val)) { |
1387 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>"; |
|
1387 | + $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>"; |
|
1388 | 1388 | } else { |
1389 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>"; |
|
1389 | + $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>"; |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | if ($output_str) { |
1395 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>"; |
|
1395 | + $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>"; |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | } |
@@ -1429,43 +1429,43 @@ discard block |
||
1429 | 1429 | $output_str = ''; |
1430 | 1430 | |
1431 | 1431 | // check review locations |
1432 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) { |
|
1433 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; |
|
1432 | + if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) { |
|
1433 | + $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>"; |
|
1434 | 1434 | $is_error_during_diagnose = true; |
1435 | 1435 | |
1436 | 1436 | if ($fix) { |
1437 | 1437 | if (geodir_fix_review_location()) { |
1438 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; |
|
1438 | + $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>"; |
|
1439 | 1439 | } else { |
1440 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; |
|
1440 | + $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>"; |
|
1441 | 1441 | } |
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | } else { |
1445 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; |
|
1445 | + $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>"; |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | // check review content |
1449 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { |
|
1450 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; |
|
1449 | + if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) { |
|
1450 | + $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>"; |
|
1451 | 1451 | $is_error_during_diagnose = true; |
1452 | 1452 | |
1453 | 1453 | if ($fix) { |
1454 | 1454 | if (geodir_fix_review_content()) { |
1455 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; |
|
1455 | + $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>"; |
|
1456 | 1456 | } else { |
1457 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; |
|
1457 | + $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>"; |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | |
1461 | 1461 | } else { |
1462 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; |
|
1462 | + $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>"; |
|
1463 | 1463 | } |
1464 | 1464 | |
1465 | 1465 | |
1466 | 1466 | if ($is_error_during_diagnose) { |
1467 | 1467 | $info_div_class = "geodir_problem_info"; |
1468 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1468 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; |
|
1469 | 1469 | } else { |
1470 | 1470 | $info_div_class = "geodir_noproblem_info"; |
1471 | 1471 | $fix_button_txt = ''; |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | |
1530 | 1530 | if ($is_error_during_diagnose) { |
1531 | 1531 | $info_div_class = "geodir_problem_info"; |
1532 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1532 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />"; |
|
1533 | 1533 | } else { |
1534 | 1534 | $info_div_class = "geodir_noproblem_info"; |
1535 | 1535 | $fix_button_txt = ''; |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | else { |
1564 | 1564 | $page_found = $wpdb->get_var( |
1565 | 1565 | $wpdb->prepare( |
1566 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
1566 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", |
|
1567 | 1567 | array($slug) |
1568 | 1568 | ) |
1569 | 1569 | ); |
@@ -1609,18 +1609,18 @@ discard block |
||
1609 | 1609 | ////////////////////////////////// |
1610 | 1610 | $option_value = get_option('geodir_home_page'); |
1611 | 1611 | $page = get_post($option_value); |
1612 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1612 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1613 | 1613 | |
1614 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1615 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1614 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1615 | + $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>"; |
|
1616 | 1616 | else { |
1617 | 1617 | $is_error_during_diagnose = true; |
1618 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
|
1618 | + $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>"; |
|
1619 | 1619 | if ($fix) { |
1620 | 1620 | if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { |
1621 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; |
|
1621 | + $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>"; |
|
1622 | 1622 | } else { |
1623 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; |
|
1623 | + $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>"; |
|
1624 | 1624 | } |
1625 | 1625 | } |
1626 | 1626 | } |
@@ -1634,18 +1634,18 @@ discard block |
||
1634 | 1634 | ////////////////////////////////// |
1635 | 1635 | $option_value = get_option('geodir_add_listing_page'); |
1636 | 1636 | $page = get_post($option_value); |
1637 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1637 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1638 | 1638 | |
1639 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1640 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1639 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1640 | + $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>"; |
|
1641 | 1641 | else { |
1642 | 1642 | $is_error_during_diagnose = true; |
1643 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
|
1643 | + $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>"; |
|
1644 | 1644 | if ($fix) { |
1645 | 1645 | if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { |
1646 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; |
|
1646 | + $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>"; |
|
1647 | 1647 | } else { |
1648 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; |
|
1648 | + $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>"; |
|
1649 | 1649 | } |
1650 | 1650 | } |
1651 | 1651 | } |
@@ -1660,18 +1660,18 @@ discard block |
||
1660 | 1660 | ////////////////////////////////// |
1661 | 1661 | $option_value = get_option('geodir_preview_page'); |
1662 | 1662 | $page = get_post($option_value); |
1663 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1663 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1664 | 1664 | |
1665 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1666 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1665 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1666 | + $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>"; |
|
1667 | 1667 | else { |
1668 | 1668 | $is_error_during_diagnose = true; |
1669 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
|
1669 | + $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>"; |
|
1670 | 1670 | if ($fix) { |
1671 | 1671 | if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { |
1672 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; |
|
1672 | + $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>"; |
|
1673 | 1673 | } else { |
1674 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; |
|
1674 | + $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>"; |
|
1675 | 1675 | } |
1676 | 1676 | } |
1677 | 1677 | } |
@@ -1685,18 +1685,18 @@ discard block |
||
1685 | 1685 | ////////////////////////////////// |
1686 | 1686 | $option_value = get_option('geodir_success_page'); |
1687 | 1687 | $page = get_post($option_value); |
1688 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1688 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1689 | 1689 | |
1690 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1691 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1690 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1691 | + $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>"; |
|
1692 | 1692 | else { |
1693 | 1693 | $is_error_during_diagnose = true; |
1694 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
|
1694 | + $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>"; |
|
1695 | 1695 | if ($fix) { |
1696 | 1696 | if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { |
1697 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; |
|
1697 | + $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>"; |
|
1698 | 1698 | } else { |
1699 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; |
|
1699 | + $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>"; |
|
1700 | 1700 | } |
1701 | 1701 | } |
1702 | 1702 | } |
@@ -1710,18 +1710,18 @@ discard block |
||
1710 | 1710 | ////////////////////////////////// |
1711 | 1711 | $option_value = get_option('geodir_info_page'); |
1712 | 1712 | $page = get_post($option_value); |
1713 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1713 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1714 | 1714 | |
1715 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1716 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1715 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1716 | + $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>"; |
|
1717 | 1717 | else { |
1718 | 1718 | $is_error_during_diagnose = true; |
1719 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
|
1719 | + $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>"; |
|
1720 | 1720 | if ($fix) { |
1721 | 1721 | if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { |
1722 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; |
|
1722 | + $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>"; |
|
1723 | 1723 | } else { |
1724 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; |
|
1724 | + $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>"; |
|
1725 | 1725 | } |
1726 | 1726 | } |
1727 | 1727 | } |
@@ -1735,18 +1735,18 @@ discard block |
||
1735 | 1735 | ////////////////////////////////// |
1736 | 1736 | $option_value = get_option('geodir_login_page'); |
1737 | 1737 | $page = get_post($option_value); |
1738 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1738 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1739 | 1739 | |
1740 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1741 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1740 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1741 | + $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>"; |
|
1742 | 1742 | else { |
1743 | 1743 | $is_error_during_diagnose = true; |
1744 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
|
1744 | + $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>"; |
|
1745 | 1745 | if ($fix) { |
1746 | 1746 | if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { |
1747 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; |
|
1747 | + $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>"; |
|
1748 | 1748 | } else { |
1749 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; |
|
1749 | + $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>"; |
|
1750 | 1750 | } |
1751 | 1751 | } |
1752 | 1752 | } |
@@ -1760,18 +1760,18 @@ discard block |
||
1760 | 1760 | ////////////////////////////////// |
1761 | 1761 | $option_value = get_option('geodir_location_page'); |
1762 | 1762 | $page = get_post($option_value); |
1763 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1763 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; } |
|
1764 | 1764 | |
1765 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1766 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1765 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
1766 | + $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>"; |
|
1767 | 1767 | else { |
1768 | 1768 | $is_error_during_diagnose = true; |
1769 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
|
1769 | + $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>"; |
|
1770 | 1770 | if ($fix) { |
1771 | 1771 | if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { |
1772 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; |
|
1772 | + $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>"; |
|
1773 | 1773 | } else { |
1774 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; |
|
1774 | + $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>"; |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | } |
@@ -1780,13 +1780,13 @@ discard block |
||
1780 | 1780 | /* Diagnose Location Page Ends */ |
1781 | 1781 | //////////////////////////////// |
1782 | 1782 | |
1783 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose ); |
|
1783 | + $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose); |
|
1784 | 1784 | /** |
1785 | 1785 | * This action is called at the end of the GD Tools page check function. |
1786 | 1786 | * |
1787 | 1787 | * @since 1.5.2 |
1788 | 1788 | */ |
1789 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr); |
|
1789 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr); |
|
1790 | 1790 | |
1791 | 1791 | $output_str = $page_chk_arr['output_str']; |
1792 | 1792 | $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
@@ -1796,7 +1796,7 @@ discard block |
||
1796 | 1796 | flush_rewrite_rules(); |
1797 | 1797 | } |
1798 | 1798 | $info_div_class = "geodir_problem_info"; |
1799 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1799 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; |
|
1800 | 1800 | } else { |
1801 | 1801 | $info_div_class = "geodir_noproblem_info"; |
1802 | 1802 | $fix_button_txt = ''; |
@@ -1824,10 +1824,10 @@ discard block |
||
1824 | 1824 | $fix_button_txt = ''; |
1825 | 1825 | |
1826 | 1826 | if ($is_error_during_diagnose) { |
1827 | - $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>"; |
|
1827 | + $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>"; |
|
1828 | 1828 | $info_div_class = "geodir_problem_info"; |
1829 | 1829 | } else { |
1830 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>"; |
|
1830 | + $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>"; |
|
1831 | 1831 | $info_div_class = "geodir_noproblem_info"; |
1832 | 1832 | $fix_button_txt = ''; |
1833 | 1833 | } |
@@ -1869,17 +1869,17 @@ discard block |
||
1869 | 1869 | global $wpdb, $wp_query, $plugin_prefix; |
1870 | 1870 | |
1871 | 1871 | 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'])) { |
1872 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
1872 | + $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail'; |
|
1873 | 1873 | |
1874 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
1874 | + $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)'; |
|
1875 | 1875 | $clauses['join'] = $join; |
1876 | 1876 | |
1877 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
1877 | + $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : ''; |
|
1878 | 1878 | $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'; |
1879 | 1879 | $clauses['fields'] = $fields; |
1880 | 1880 | |
1881 | 1881 | $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
1882 | - $orderby = 'gd_expire ' . $order; |
|
1882 | + $orderby = 'gd_expire '.$order; |
|
1883 | 1883 | $clauses['orderby'] = $orderby; |
1884 | 1884 | } |
1885 | 1885 | return $clauses; |
@@ -1922,7 +1922,7 @@ discard block |
||
1922 | 1922 | global $current_user; |
1923 | 1923 | $upload_dir = wp_upload_dir(); |
1924 | 1924 | |
1925 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
1925 | + $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv'; |
|
1926 | 1926 | $handle = fopen($file, 'w'); |
1927 | 1927 | |
1928 | 1928 | fwrite($handle, $input); |
@@ -1967,7 +1967,7 @@ discard block |
||
1967 | 1967 | $uploads_dir = $uploads['path']; |
1968 | 1968 | $image_name_arr = explode('/', $filename); |
1969 | 1969 | $filename = end($image_name_arr); |
1970 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
1970 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; |
|
1971 | 1971 | $return = array(); |
1972 | 1972 | $return['file'] = $uploadedFile; |
1973 | 1973 | $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory'); |
@@ -1984,8 +1984,8 @@ discard block |
||
1984 | 1984 | |
1985 | 1985 | if (($handle = fopen($target_path, "r")) !== FALSE) { |
1986 | 1986 | while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { |
1987 | - if(is_array($data) && !empty($data)) { |
|
1988 | - $file[] = '"' . implode('","', $data) . '"'; |
|
1987 | + if (is_array($data) && !empty($data)) { |
|
1988 | + $file[] = '"'.implode('","', $data).'"'; |
|
1989 | 1989 | } |
1990 | 1990 | } |
1991 | 1991 | fclose($handle); |
@@ -2102,10 +2102,10 @@ discard block |
||
2102 | 2102 | $tag_arr = explode(',', $post_tags); |
2103 | 2103 | } |
2104 | 2104 | |
2105 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
2105 | + $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database |
|
2106 | 2106 | |
2107 | 2107 | $error = ''; |
2108 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) { |
|
2108 | + if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) { |
|
2109 | 2109 | $invalid_post_type++; |
2110 | 2110 | continue; |
2111 | 2111 | } |
@@ -2131,7 +2131,7 @@ discard block |
||
2131 | 2131 | if ($buffer[$c] != '0' && $buffer[$c] != '') { |
2132 | 2132 | $submitdata = date('Y-m-d'); |
2133 | 2133 | |
2134 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days")); |
|
2134 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days")); |
|
2135 | 2135 | } else { |
2136 | 2136 | $gd_post_info['expire_date'] = 'Never'; |
2137 | 2137 | } |
@@ -2159,7 +2159,7 @@ discard block |
||
2159 | 2159 | |
2160 | 2160 | // Post status |
2161 | 2161 | if ($customKeyarray[$c] == 'post_status') { |
2162 | - $post_status = sanitize_key( $buffer[$c] ); |
|
2162 | + $post_status = sanitize_key($buffer[$c]); |
|
2163 | 2163 | } |
2164 | 2164 | } |
2165 | 2165 | |
@@ -2177,8 +2177,8 @@ discard block |
||
2177 | 2177 | |
2178 | 2178 | // Default post status |
2179 | 2179 | $default_status = 'publish'; |
2180 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
2181 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
2180 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
2181 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
2182 | 2182 | |
2183 | 2183 | $my_post['post_title'] = $post_title; |
2184 | 2184 | $my_post['post_content'] = $post_desc; |
@@ -2222,7 +2222,7 @@ discard block |
||
2222 | 2222 | $payment_info = array(); |
2223 | 2223 | $package_info = array(); |
2224 | 2224 | |
2225 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
2225 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); |
|
2226 | 2226 | $package_id = ''; |
2227 | 2227 | if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') { |
2228 | 2228 | $package_id = $gd_post_info['package_id']; |
@@ -2232,7 +2232,7 @@ discard block |
||
2232 | 2232 | $payment_info['package_id'] = $package_info['pid']; |
2233 | 2233 | |
2234 | 2234 | if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) { |
2235 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days")); |
|
2235 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days")); |
|
2236 | 2236 | } else { |
2237 | 2237 | $payment_info['expire_date'] = 'Never'; |
2238 | 2238 | } |
@@ -2244,7 +2244,7 @@ discard block |
||
2244 | 2244 | |
2245 | 2245 | $post_type = get_post_type($last_postid); |
2246 | 2246 | |
2247 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
2247 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
2248 | 2248 | |
2249 | 2249 | geodir_save_post_info($last_postid, $gd_post_info); |
2250 | 2250 | |
@@ -2265,7 +2265,7 @@ discard block |
||
2265 | 2265 | $attachment['post_id'] = $last_postid; |
2266 | 2266 | $attachment['title'] = $img_name_arr[0]; |
2267 | 2267 | $attachment['content'] = ''; |
2268 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
2268 | + $attachment['file'] = $sub_dir.'/'.$image_name; |
|
2269 | 2269 | $attachment['mime_type'] = $uploaded_file_type; |
2270 | 2270 | $attachment['menu_order'] = $menu_order; |
2271 | 2271 | $attachment['is_featured'] = 0; |
@@ -2274,15 +2274,15 @@ discard block |
||
2274 | 2274 | |
2275 | 2275 | foreach ($attachment as $key => $val) { |
2276 | 2276 | if ($val != '') |
2277 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
2277 | + $attachment_set .= $key." = '".$val."', "; |
|
2278 | 2278 | } |
2279 | 2279 | $attachment_set = trim($attachment_set, ", "); |
2280 | 2280 | |
2281 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set); |
|
2281 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set); |
|
2282 | 2282 | |
2283 | 2283 | if ($menu_order == 1) { |
2284 | 2284 | $post_type = get_post_type($last_postid); |
2285 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid))); |
|
2285 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid))); |
|
2286 | 2286 | } |
2287 | 2287 | $menu_order++; |
2288 | 2288 | } |
@@ -2323,11 +2323,11 @@ discard block |
||
2323 | 2323 | } |
2324 | 2324 | |
2325 | 2325 | // Add the tab in left sidebar menu fro import & export page. |
2326 | -add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 ); |
|
2326 | +add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94); |
|
2327 | 2327 | |
2328 | 2328 | // Handle ajax request for import/export. |
2329 | -add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' ); |
|
2330 | -add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' ); |
|
2329 | +add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export'); |
|
2330 | +add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export'); |
|
2331 | 2331 | |
2332 | 2332 | |
2333 | 2333 | /** |
@@ -2338,40 +2338,40 @@ discard block |
||
2338 | 2338 | * @param $post_id int $post_id The post ID of the post being saved. |
2339 | 2339 | * @param $post object $post The post object of the post being saved. |
2340 | 2340 | */ |
2341 | -function geodir_update_location_prefix($post_id,$post){ |
|
2342 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){ |
|
2343 | - update_option('geodir_location_prefix',$post->post_name); |
|
2341 | +function geodir_update_location_prefix($post_id, $post) { |
|
2342 | + if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) { |
|
2343 | + update_option('geodir_location_prefix', $post->post_name); |
|
2344 | 2344 | } |
2345 | 2345 | |
2346 | 2346 | } |
2347 | 2347 | |
2348 | -add_action('save_post', 'geodir_update_location_prefix',10,2); |
|
2348 | +add_action('save_post', 'geodir_update_location_prefix', 10, 2); |
|
2349 | 2349 | |
2350 | -add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' ); |
|
2350 | +add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback'); |
|
2351 | 2351 | |
2352 | -function geodir_ga_callback(){ |
|
2352 | +function geodir_ga_callback() { |
|
2353 | 2353 | |
2354 | -if(isset($_REQUEST['code']) && $_REQUEST['code']) { |
|
2354 | +if (isset($_REQUEST['code']) && $_REQUEST['code']) { |
|
2355 | 2355 | $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
2356 | 2356 | $code = "code=".$_REQUEST['code']; |
2357 | 2357 | $grant_type = "&grant_type=authorization_code"; |
2358 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
2358 | + $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback"; |
|
2359 | 2359 | $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
2360 | 2360 | $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
2361 | 2361 | |
2362 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
2362 | + $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret; |
|
2363 | 2363 | |
2364 | 2364 | $response = wp_remote_post($auth_url, array('timeout' => 15)); |
2365 | 2365 | |
2366 | 2366 | //print_r($response); |
2367 | 2367 | |
2368 | - $error_msg = __('Something went wrong','geodirectory'); |
|
2369 | - if(!empty($response['response']['code']) && $response['response']['code']==200){ |
|
2368 | + $error_msg = __('Something went wrong', 'geodirectory'); |
|
2369 | + if (!empty($response['response']['code']) && $response['response']['code'] == 200) { |
|
2370 | 2370 | |
2371 | 2371 | $parts = json_decode($response['body']); |
2372 | 2372 | //print_r($parts); |
2373 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2374 | - else{ |
|
2373 | + if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; } |
|
2374 | + else { |
|
2375 | 2375 | |
2376 | 2376 | update_option('gd_ga_access_token', $parts->access_token); |
2377 | 2377 | update_option('gd_ga_refresh_token', $parts->refresh_token); |
@@ -2380,18 +2380,18 @@ discard block |
||
2380 | 2380 | |
2381 | 2381 | |
2382 | 2382 | } |
2383 | - elseif(!empty($response['response']['code'])) { |
|
2383 | + elseif (!empty($response['response']['code'])) { |
|
2384 | 2384 | $parts = json_decode($response['body']); |
2385 | 2385 | |
2386 | - if(isset($parts->error)){ |
|
2387 | - echo $parts->error.": ".$parts->error_description;exit; |
|
2388 | - }else{ |
|
2389 | - echo $error_msg." - #2";exit; |
|
2386 | + if (isset($parts->error)) { |
|
2387 | + echo $parts->error.": ".$parts->error_description; exit; |
|
2388 | + } else { |
|
2389 | + echo $error_msg." - #2"; exit; |
|
2390 | 2390 | } |
2391 | 2391 | |
2392 | - }else{ |
|
2392 | + } else { |
|
2393 | 2393 | |
2394 | - echo $error_msg." - #3";exit; |
|
2394 | + echo $error_msg." - #3"; exit; |
|
2395 | 2395 | |
2396 | 2396 | } |
2397 | 2397 | } |
@@ -2413,7 +2413,7 @@ discard block |
||
2413 | 2413 | function geodir_uninstall_settings($general_settings) { |
2414 | 2414 | $settings = array(); |
2415 | 2415 | $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory')); |
2416 | - $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' )); |
|
2416 | + $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory')); |
|
2417 | 2417 | |
2418 | 2418 | $plugins = get_plugins(); |
2419 | 2419 | $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array()); |
@@ -2425,7 +2425,7 @@ discard block |
||
2425 | 2425 | if (in_array($plugin_name, $un_plugins)) { |
2426 | 2426 | $settings[] = array( |
2427 | 2427 | 'type' => 'checkbox', |
2428 | - 'id' => 'geodir_un_' . $plugin_name, |
|
2428 | + 'id' => 'geodir_un_'.$plugin_name, |
|
2429 | 2429 | 'name' => $data['Name'], |
2430 | 2430 | 'desc' => __('Remove all data when deleted?', 'geodirectory'), |
2431 | 2431 | 'std' => '0' |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | * @since 1.6.9 |
2460 | 2460 | */ |
2461 | 2461 | function geodir_uninstall_settings_desc() { |
2462 | - echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>'; |
|
2462 | + echo '<p class="gd-un-settings-desc">'.__('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory').'</p>'; |
|
2463 | 2463 | } |
2464 | 2464 | add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc'); |
2465 | 2465 | |
@@ -2523,12 +2523,12 @@ discard block |
||
2523 | 2523 | |
2524 | 2524 | |
2525 | 2525 | if ($delete) { |
2526 | - $output_str .= "<li><strong>" . __('Table dropped, refresh page to reinstall.', 'geodirectory') . "</strong></li>"; |
|
2526 | + $output_str .= "<li><strong>".__('Table dropped, refresh page to reinstall.', 'geodirectory')."</strong></li>"; |
|
2527 | 2527 | ob_start(); |
2528 | 2528 | geodir_diagnose_version_clear(); |
2529 | 2529 | ob_end_clean(); |
2530 | - }else{ |
|
2531 | - $output_str .= "<li><strong>" . __('Seomething went wrong.', 'geodirectory') . "</strong></li>"; |
|
2530 | + } else { |
|
2531 | + $output_str .= "<li><strong>".__('Seomething went wrong.', 'geodirectory')."</strong></li>"; |
|
2532 | 2532 | } |
2533 | 2533 | |
2534 | 2534 | if ($is_error_during_diagnose) { |
@@ -24,8 +24,11 @@ discard block |
||
24 | 24 | global $current_tab; |
25 | 25 | geodir_redirect_to_admin_panel_on_installed(); |
26 | 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 |
|
27 | + if (!(isset($_REQUEST['action']))) { |
|
28 | + // this will avoid Ajax requests |
|
29 | + geodir_handle_option_form_submit($current_tab); |
|
30 | + } |
|
31 | + // located in admin function.php |
|
29 | 32 | /** |
30 | 33 | * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. |
31 | 34 | * |
@@ -324,8 +327,9 @@ discard block |
||
324 | 327 | if (!empty($notification) && get_option('geodir_tiny_editor') == '1') { |
325 | 328 | |
326 | 329 | foreach ($notification as $key => $value) { |
327 | - if ($value['type'] == 'textarea') |
|
328 | - $notification[$key]['type'] = 'editor'; |
|
330 | + if ($value['type'] == 'textarea') { |
|
331 | + $notification[$key]['type'] = 'editor'; |
|
332 | + } |
|
329 | 333 | } |
330 | 334 | |
331 | 335 | } |
@@ -350,8 +354,9 @@ discard block |
||
350 | 354 | if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') { |
351 | 355 | |
352 | 356 | foreach ($design_setting as $key => $value) { |
353 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
354 | - $design_setting[$key]['type'] = 'editor'; |
|
357 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') { |
|
358 | + $design_setting[$key]['type'] = 'editor'; |
|
359 | + } |
|
355 | 360 | } |
356 | 361 | |
357 | 362 | } |
@@ -470,9 +475,9 @@ discard block |
||
470 | 475 | class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
471 | 476 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) { |
472 | 477 | echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
473 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
478 | + } elseif(isset($val['field_icon']) && $val['field_icon'] ){ |
|
474 | 479 | echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>'; |
475 | - }else{ |
|
480 | + } else{ |
|
476 | 481 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
477 | 482 | }?> |
478 | 483 | <?php echo $val['site_title'];?> |
@@ -702,9 +707,9 @@ discard block |
||
702 | 707 | <?php |
703 | 708 | if($type=='predefined'){ |
704 | 709 | $cfs = geodir_custom_fields_predefined($listing_type); |
705 | - }elseif($type=='custom'){ |
|
710 | + } elseif($type=='custom'){ |
|
706 | 711 | $cfs = geodir_custom_fields_custom($listing_type); |
707 | - }else{ |
|
712 | + } else{ |
|
708 | 713 | $cfs = geodir_custom_fields($listing_type); |
709 | 714 | ?> |
710 | 715 | <ul class="full gd-cf-tooltip-wrap"> |
@@ -759,7 +764,7 @@ discard block |
||
759 | 764 | </li> |
760 | 765 | <?php |
761 | 766 | } |
762 | - }else{ |
|
767 | + } else{ |
|
763 | 768 | _e('There are no custom fields here yet.', 'geodirectory'); |
764 | 769 | } |
765 | 770 | ?> |
@@ -956,8 +961,9 @@ discard block |
||
956 | 961 | |
957 | 962 | if (!get_option('geodir_remove_unnecessary_fields')) { |
958 | 963 | |
959 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) |
|
960 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
964 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) { |
|
965 | + $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
966 | + } |
|
961 | 967 | |
962 | 968 | update_option('geodir_remove_unnecessary_fields', '1'); |
963 | 969 | |
@@ -993,8 +999,9 @@ discard block |
||
993 | 999 | break; |
994 | 1000 | |
995 | 1001 | case 'diagnosis-fix' : |
996 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
997 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
1002 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
1003 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
1004 | + } |
|
998 | 1005 | call_user_func('geodir_diagnose_' . $diagnose_this); |
999 | 1006 | exit(); |
1000 | 1007 | break; |
@@ -1609,11 +1616,11 @@ discard block |
||
1609 | 1616 | ////////////////////////////////// |
1610 | 1617 | $option_value = get_option('geodir_home_page'); |
1611 | 1618 | $page = get_post($option_value); |
1612 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1619 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1613 | 1620 | |
1614 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1615 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1616 | - else { |
|
1621 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1622 | + $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1623 | + } else { |
|
1617 | 1624 | $is_error_during_diagnose = true; |
1618 | 1625 | $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; |
1619 | 1626 | if ($fix) { |
@@ -1634,11 +1641,11 @@ discard block |
||
1634 | 1641 | ////////////////////////////////// |
1635 | 1642 | $option_value = get_option('geodir_add_listing_page'); |
1636 | 1643 | $page = get_post($option_value); |
1637 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1644 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1638 | 1645 | |
1639 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1640 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1641 | - else { |
|
1646 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1647 | + $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1648 | + } else { |
|
1642 | 1649 | $is_error_during_diagnose = true; |
1643 | 1650 | $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; |
1644 | 1651 | if ($fix) { |
@@ -1660,11 +1667,11 @@ discard block |
||
1660 | 1667 | ////////////////////////////////// |
1661 | 1668 | $option_value = get_option('geodir_preview_page'); |
1662 | 1669 | $page = get_post($option_value); |
1663 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1670 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1664 | 1671 | |
1665 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1666 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1667 | - else { |
|
1672 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1673 | + $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1674 | + } else { |
|
1668 | 1675 | $is_error_during_diagnose = true; |
1669 | 1676 | $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; |
1670 | 1677 | if ($fix) { |
@@ -1685,11 +1692,11 @@ discard block |
||
1685 | 1692 | ////////////////////////////////// |
1686 | 1693 | $option_value = get_option('geodir_success_page'); |
1687 | 1694 | $page = get_post($option_value); |
1688 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1695 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1689 | 1696 | |
1690 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1691 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1692 | - else { |
|
1697 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1698 | + $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1699 | + } else { |
|
1693 | 1700 | $is_error_during_diagnose = true; |
1694 | 1701 | $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; |
1695 | 1702 | if ($fix) { |
@@ -1710,11 +1717,11 @@ discard block |
||
1710 | 1717 | ////////////////////////////////// |
1711 | 1718 | $option_value = get_option('geodir_info_page'); |
1712 | 1719 | $page = get_post($option_value); |
1713 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1720 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1714 | 1721 | |
1715 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1716 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1717 | - else { |
|
1722 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1723 | + $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1724 | + } else { |
|
1718 | 1725 | $is_error_during_diagnose = true; |
1719 | 1726 | $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; |
1720 | 1727 | if ($fix) { |
@@ -1735,11 +1742,11 @@ discard block |
||
1735 | 1742 | ////////////////////////////////// |
1736 | 1743 | $option_value = get_option('geodir_login_page'); |
1737 | 1744 | $page = get_post($option_value); |
1738 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1745 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1739 | 1746 | |
1740 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1741 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1742 | - else { |
|
1747 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1748 | + $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1749 | + } else { |
|
1743 | 1750 | $is_error_during_diagnose = true; |
1744 | 1751 | $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; |
1745 | 1752 | if ($fix) { |
@@ -1760,11 +1767,11 @@ discard block |
||
1760 | 1767 | ////////////////////////////////// |
1761 | 1768 | $option_value = get_option('geodir_location_page'); |
1762 | 1769 | $page = get_post($option_value); |
1763 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';} |
|
1770 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';} |
|
1764 | 1771 | |
1765 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
1766 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1767 | - else { |
|
1772 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
1773 | + $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
1774 | + } else { |
|
1768 | 1775 | $is_error_during_diagnose = true; |
1769 | 1776 | $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; |
1770 | 1777 | if ($fix) { |
@@ -2209,8 +2216,9 @@ discard block |
||
2209 | 2216 | ); |
2210 | 2217 | |
2211 | 2218 | $post_location_info = $request_info['post_location']; |
2212 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
2213 | - $post_location_id = $location_id; |
|
2219 | + if ($location_id = geodir_add_new_location($post_location_info)) { |
|
2220 | + $post_location_id = $location_id; |
|
2221 | + } |
|
2214 | 2222 | } else { |
2215 | 2223 | $post_location_id = 0; |
2216 | 2224 | } |
@@ -2273,8 +2281,9 @@ discard block |
||
2273 | 2281 | $attachment_set = ''; |
2274 | 2282 | |
2275 | 2283 | foreach ($attachment as $key => $val) { |
2276 | - if ($val != '') |
|
2277 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
2284 | + if ($val != '') { |
|
2285 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
2286 | + } |
|
2278 | 2287 | } |
2279 | 2288 | $attachment_set = trim($attachment_set, ", "); |
2280 | 2289 | |
@@ -2370,8 +2379,7 @@ discard block |
||
2370 | 2379 | |
2371 | 2380 | $parts = json_decode($response['body']); |
2372 | 2381 | //print_r($parts); |
2373 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} |
|
2374 | - else{ |
|
2382 | + if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{ |
|
2375 | 2383 | |
2376 | 2384 | update_option('gd_ga_access_token', $parts->access_token); |
2377 | 2385 | update_option('gd_ga_refresh_token', $parts->refresh_token); |
@@ -2379,17 +2387,16 @@ discard block |
||
2379 | 2387 | } |
2380 | 2388 | |
2381 | 2389 | |
2382 | - } |
|
2383 | - elseif(!empty($response['response']['code'])) { |
|
2390 | + } elseif(!empty($response['response']['code'])) { |
|
2384 | 2391 | $parts = json_decode($response['body']); |
2385 | 2392 | |
2386 | 2393 | if(isset($parts->error)){ |
2387 | 2394 | echo $parts->error.": ".$parts->error_description;exit; |
2388 | - }else{ |
|
2395 | + } else{ |
|
2389 | 2396 | echo $error_msg." - #2";exit; |
2390 | 2397 | } |
2391 | 2398 | |
2392 | - }else{ |
|
2399 | + } else{ |
|
2393 | 2400 | |
2394 | 2401 | echo $error_msg." - #3";exit; |
2395 | 2402 | |
@@ -2527,7 +2534,7 @@ discard block |
||
2527 | 2534 | ob_start(); |
2528 | 2535 | geodir_diagnose_version_clear(); |
2529 | 2536 | ob_end_clean(); |
2530 | - }else{ |
|
2537 | + } else{ |
|
2531 | 2538 | $output_str .= "<li><strong>" . __('Seomething went wrong.', 'geodirectory') . "</strong></li>"; |
2532 | 2539 | } |
2533 | 2540 |
@@ -10,21 +10,21 @@ |
||
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | 12 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
13 | - exit; |
|
13 | + exit; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | global $wpdb; |
17 | 17 | |
18 | 18 | if (get_option('geodir_un_geodirectory')) { |
19 | - $wpdb->hide_errors(); |
|
19 | + $wpdb->hide_errors(); |
|
20 | 20 | |
21 | - /* |
|
21 | + /* |
|
22 | 22 | if (!defined('GEODIRECTORY_VERSION')) { |
23 | 23 | // Load plugin file. |
24 | 24 | include_once('geodirectory.php'); |
25 | 25 | } |
26 | 26 | */ |
27 | 27 | |
28 | - // Delete default data. |
|
29 | - delete_option('geodir_default_data_installed'); |
|
28 | + // Delete default data. |
|
29 | + delete_option('geodir_default_data_installed'); |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -9,7 +9,7 @@ |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 |
@@ -15,296 +15,296 @@ discard block |
||
15 | 15 | */ |
16 | 16 | function geodir_register_sidebar() |
17 | 17 | { |
18 | - global $geodir_sidebars; |
|
19 | - |
|
20 | - if (function_exists('register_sidebar')) { |
|
21 | - /*===========================*/ |
|
22 | - /* Home page sidebars start*/ |
|
23 | - /*===========================*/ |
|
24 | - |
|
25 | - /** |
|
26 | - * Filter the `$before_widget` widget opening HTML tag. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * @param string $var The HTML string to filter. Default = '<section id="%1$s" class="widget geodir-widget %2$s">'. |
|
30 | - * @see 'geodir_after_widget' |
|
31 | - */ |
|
32 | - $before_widget = apply_filters('geodir_before_widget', '<section id="%1$s" class="widget geodir-widget %2$s">'); |
|
33 | - /** |
|
34 | - * Filter the `$after_widget` widget closing HTML tag. |
|
35 | - * |
|
36 | - * @since 1.0.0 |
|
37 | - * @param string $var The HTML string to filter. Default = '</section>'. |
|
38 | - * @see 'geodir_before_widget' |
|
39 | - */ |
|
40 | - $after_widget = apply_filters('geodir_after_widget', '</section>'); |
|
41 | - /** |
|
42 | - * Filter the `$before_title` widget title opening HTML tag. |
|
43 | - * |
|
44 | - * @since 1.0.0 |
|
45 | - * @param string $var The HTML string to filter. Default = '<h3 class="widget-title">'. |
|
46 | - * @see 'geodir_after_title' |
|
47 | - */ |
|
48 | - $before_title = apply_filters('geodir_before_title', '<h3 class="widget-title">'); |
|
49 | - /** |
|
50 | - * Filter the `$after_title` widget title closing HTML tag. |
|
51 | - * |
|
52 | - * @since 1.0.0 |
|
53 | - * @param string $var The HTML string to filter. Default = '</h3>'. |
|
54 | - * @see 'geodir_before_title' |
|
55 | - */ |
|
56 | - $after_title = apply_filters('geodir_after_title', '</h3>'); |
|
57 | - |
|
58 | - if (get_option('geodir_show_home_top_section')) { |
|
59 | - register_sidebars(1, array('id' => 'geodir_home_top', 'name' => __('GD Home Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
60 | - |
|
61 | - $geodir_sidebars[] = 'geodir_home_top'; |
|
62 | - } |
|
63 | - |
|
64 | - if (get_option('geodir_show_home_contant_section')) { |
|
65 | - register_sidebars(1, array('id' => 'geodir_home_content', 'name' => __('GD Home Content Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
18 | + global $geodir_sidebars; |
|
66 | 19 | |
67 | - $geodir_sidebars[] = 'geodir_home_content'; |
|
68 | - } |
|
20 | + if (function_exists('register_sidebar')) { |
|
21 | + /*===========================*/ |
|
22 | + /* Home page sidebars start*/ |
|
23 | + /*===========================*/ |
|
69 | 24 | |
70 | - if (get_option('geodir_show_home_right_section')) { |
|
71 | - register_sidebars(1, array('id' => 'geodir_home_right', 'name' => __('GD Home Right Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
25 | + /** |
|
26 | + * Filter the `$before_widget` widget opening HTML tag. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * @param string $var The HTML string to filter. Default = '<section id="%1$s" class="widget geodir-widget %2$s">'. |
|
30 | + * @see 'geodir_after_widget' |
|
31 | + */ |
|
32 | + $before_widget = apply_filters('geodir_before_widget', '<section id="%1$s" class="widget geodir-widget %2$s">'); |
|
33 | + /** |
|
34 | + * Filter the `$after_widget` widget closing HTML tag. |
|
35 | + * |
|
36 | + * @since 1.0.0 |
|
37 | + * @param string $var The HTML string to filter. Default = '</section>'. |
|
38 | + * @see 'geodir_before_widget' |
|
39 | + */ |
|
40 | + $after_widget = apply_filters('geodir_after_widget', '</section>'); |
|
41 | + /** |
|
42 | + * Filter the `$before_title` widget title opening HTML tag. |
|
43 | + * |
|
44 | + * @since 1.0.0 |
|
45 | + * @param string $var The HTML string to filter. Default = '<h3 class="widget-title">'. |
|
46 | + * @see 'geodir_after_title' |
|
47 | + */ |
|
48 | + $before_title = apply_filters('geodir_before_title', '<h3 class="widget-title">'); |
|
49 | + /** |
|
50 | + * Filter the `$after_title` widget title closing HTML tag. |
|
51 | + * |
|
52 | + * @since 1.0.0 |
|
53 | + * @param string $var The HTML string to filter. Default = '</h3>'. |
|
54 | + * @see 'geodir_before_title' |
|
55 | + */ |
|
56 | + $after_title = apply_filters('geodir_after_title', '</h3>'); |
|
57 | + |
|
58 | + if (get_option('geodir_show_home_top_section')) { |
|
59 | + register_sidebars(1, array('id' => 'geodir_home_top', 'name' => __('GD Home Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
72 | 60 | |
73 | - $geodir_sidebars[] = 'geodir_home_right'; |
|
74 | - } |
|
61 | + $geodir_sidebars[] = 'geodir_home_top'; |
|
62 | + } |
|
75 | 63 | |
76 | - if (get_option('geodir_show_home_left_section')) { |
|
77 | - register_sidebars(1, array('id' => 'geodir_home_left', 'name' => __('GD Home Left Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
64 | + if (get_option('geodir_show_home_contant_section')) { |
|
65 | + register_sidebars(1, array('id' => 'geodir_home_content', 'name' => __('GD Home Content Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
78 | 66 | |
79 | - $geodir_sidebars[] = 'geodir_home_left'; |
|
80 | - } |
|
67 | + $geodir_sidebars[] = 'geodir_home_content'; |
|
68 | + } |
|
81 | 69 | |
82 | - if (get_option('geodir_show_home_bottom_section')) { |
|
83 | - register_sidebars(1, array('id' => 'geodir_home_bottom', 'name' => __('GD Home Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
70 | + if (get_option('geodir_show_home_right_section')) { |
|
71 | + register_sidebars(1, array('id' => 'geodir_home_right', 'name' => __('GD Home Right Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
84 | 72 | |
85 | - $geodir_sidebars[] = 'geodir_home_bottom'; |
|
86 | - } |
|
73 | + $geodir_sidebars[] = 'geodir_home_right'; |
|
74 | + } |
|
87 | 75 | |
88 | - /*===========================*/ |
|
89 | - /* Home page sidebars end*/ |
|
90 | - /*===========================*/ |
|
76 | + if (get_option('geodir_show_home_left_section')) { |
|
77 | + register_sidebars(1, array('id' => 'geodir_home_left', 'name' => __('GD Home Left Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
91 | 78 | |
92 | - /*===========================*/ |
|
93 | - /* Listing page sidebars start*/ |
|
94 | - /*===========================*/ |
|
79 | + $geodir_sidebars[] = 'geodir_home_left'; |
|
80 | + } |
|
95 | 81 | |
96 | - if (get_option('geodir_show_listing_top_section')) { |
|
97 | - register_sidebars(1, array('id' => 'geodir_listing_top', 'name' => __('GD Listing Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
82 | + if (get_option('geodir_show_home_bottom_section')) { |
|
83 | + register_sidebars(1, array('id' => 'geodir_home_bottom', 'name' => __('GD Home Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
98 | 84 | |
99 | - $geodir_sidebars[] = 'geodir_listing_top'; |
|
100 | - } |
|
85 | + $geodir_sidebars[] = 'geodir_home_bottom'; |
|
86 | + } |
|
101 | 87 | |
102 | - if (get_option('geodir_show_listing_left_section')) { |
|
103 | - register_sidebars(1, array('id' => 'geodir_listing_left_sidebar', 'name' => __('GD Listing Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
88 | + /*===========================*/ |
|
89 | + /* Home page sidebars end*/ |
|
90 | + /*===========================*/ |
|
104 | 91 | |
105 | - $geodir_sidebars[] = 'geodir_listing_left_sidebar'; |
|
106 | - } |
|
92 | + /*===========================*/ |
|
93 | + /* Listing page sidebars start*/ |
|
94 | + /*===========================*/ |
|
107 | 95 | |
108 | - if (get_option('geodir_show_listing_right_section')) { |
|
109 | - register_sidebars(1, array('id' => 'geodir_listing_right_sidebar', 'name' => __('GD Listing Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
96 | + if (get_option('geodir_show_listing_top_section')) { |
|
97 | + register_sidebars(1, array('id' => 'geodir_listing_top', 'name' => __('GD Listing Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
110 | 98 | |
111 | - $geodir_sidebars[] = 'geodir_listing_right_sidebar'; |
|
112 | - } |
|
99 | + $geodir_sidebars[] = 'geodir_listing_top'; |
|
100 | + } |
|
113 | 101 | |
114 | - if (get_option('geodir_show_listing_bottom_section')) { |
|
115 | - register_sidebars(1, array('id' => 'geodir_listing_bottom', 'name' => __('GD Listing Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
102 | + if (get_option('geodir_show_listing_left_section')) { |
|
103 | + register_sidebars(1, array('id' => 'geodir_listing_left_sidebar', 'name' => __('GD Listing Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
116 | 104 | |
117 | - $geodir_sidebars[] = 'geodir_listing_bottom'; |
|
118 | - } |
|
105 | + $geodir_sidebars[] = 'geodir_listing_left_sidebar'; |
|
106 | + } |
|
119 | 107 | |
120 | - /*===========================*/ |
|
121 | - /* Listing page sidebars start*/ |
|
122 | - /*===========================*/ |
|
108 | + if (get_option('geodir_show_listing_right_section')) { |
|
109 | + register_sidebars(1, array('id' => 'geodir_listing_right_sidebar', 'name' => __('GD Listing Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
123 | 110 | |
124 | - /*===========================*/ |
|
125 | - /* Search page sidebars start*/ |
|
126 | - /*===========================*/ |
|
111 | + $geodir_sidebars[] = 'geodir_listing_right_sidebar'; |
|
112 | + } |
|
127 | 113 | |
128 | - if (get_option('geodir_show_search_top_section')) { |
|
129 | - register_sidebars(1, array('id' => 'geodir_search_top', 'name' => __('GD Search Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
114 | + if (get_option('geodir_show_listing_bottom_section')) { |
|
115 | + register_sidebars(1, array('id' => 'geodir_listing_bottom', 'name' => __('GD Listing Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
130 | 116 | |
131 | - $geodir_sidebars[] = 'geodir_search_top'; |
|
132 | - } |
|
117 | + $geodir_sidebars[] = 'geodir_listing_bottom'; |
|
118 | + } |
|
133 | 119 | |
134 | - if (get_option('geodir_show_search_left_section')) { |
|
135 | - register_sidebars(1, array('id' => 'geodir_search_left_sidebar', 'name' => __('GD Search Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
120 | + /*===========================*/ |
|
121 | + /* Listing page sidebars start*/ |
|
122 | + /*===========================*/ |
|
136 | 123 | |
137 | - $geodir_sidebars[] = 'geodir_search_left_sidebar'; |
|
138 | - } |
|
124 | + /*===========================*/ |
|
125 | + /* Search page sidebars start*/ |
|
126 | + /*===========================*/ |
|
139 | 127 | |
140 | - if (get_option('geodir_show_search_right_section')) { |
|
141 | - register_sidebars(1, array('id' => 'geodir_search_right_sidebar', 'name' => __('GD Search Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
128 | + if (get_option('geodir_show_search_top_section')) { |
|
129 | + register_sidebars(1, array('id' => 'geodir_search_top', 'name' => __('GD Search Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
142 | 130 | |
143 | - $geodir_sidebars[] = 'geodir_search_right_sidebar'; |
|
144 | - } |
|
131 | + $geodir_sidebars[] = 'geodir_search_top'; |
|
132 | + } |
|
145 | 133 | |
146 | - if (get_option('geodir_show_search_bottom_section')) { |
|
147 | - register_sidebars(1, array('id' => 'geodir_search_bottom', 'name' => __('GD Search Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
134 | + if (get_option('geodir_show_search_left_section')) { |
|
135 | + register_sidebars(1, array('id' => 'geodir_search_left_sidebar', 'name' => __('GD Search Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
148 | 136 | |
149 | - $geodir_sidebars[] = 'geodir_search_bottom'; |
|
150 | - } |
|
137 | + $geodir_sidebars[] = 'geodir_search_left_sidebar'; |
|
138 | + } |
|
151 | 139 | |
152 | - /*===========================*/ |
|
153 | - /* Search page sidebars end*/ |
|
154 | - /*===========================*/ |
|
140 | + if (get_option('geodir_show_search_right_section')) { |
|
141 | + register_sidebars(1, array('id' => 'geodir_search_right_sidebar', 'name' => __('GD Search Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
155 | 142 | |
156 | - /*==================================*/ |
|
157 | - /* Detail/Single page sidebars start*/ |
|
158 | - /*==================================*/ |
|
159 | - if (get_option('geodir_show_detail_top_section')) { |
|
160 | - register_sidebars(1, array('id' => 'geodir_detail_top', 'name' => __('GD Detail Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
143 | + $geodir_sidebars[] = 'geodir_search_right_sidebar'; |
|
144 | + } |
|
161 | 145 | |
162 | - $geodir_sidebars[] = 'geodir_detail_top'; |
|
163 | - } |
|
146 | + if (get_option('geodir_show_search_bottom_section')) { |
|
147 | + register_sidebars(1, array('id' => 'geodir_search_bottom', 'name' => __('GD Search Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
164 | 148 | |
165 | - register_sidebars(1, array('id' => 'geodir_detail_sidebar', 'name' => __('GD Detail Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
149 | + $geodir_sidebars[] = 'geodir_search_bottom'; |
|
150 | + } |
|
166 | 151 | |
167 | - $geodir_sidebars[] = 'geodir_detail_sidebar'; |
|
152 | + /*===========================*/ |
|
153 | + /* Search page sidebars end*/ |
|
154 | + /*===========================*/ |
|
168 | 155 | |
169 | - if (get_option('geodir_show_detail_bottom_section')) { |
|
170 | - register_sidebars(1, array('id' => 'geodir_detail_bottom', 'name' => __('GD Detail Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
156 | + /*==================================*/ |
|
157 | + /* Detail/Single page sidebars start*/ |
|
158 | + /*==================================*/ |
|
159 | + if (get_option('geodir_show_detail_top_section')) { |
|
160 | + register_sidebars(1, array('id' => 'geodir_detail_top', 'name' => __('GD Detail Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
171 | 161 | |
172 | - $geodir_sidebars[] = 'geodir_detail_bottom'; |
|
173 | - } |
|
162 | + $geodir_sidebars[] = 'geodir_detail_top'; |
|
163 | + } |
|
174 | 164 | |
175 | - /*==================================*/ |
|
176 | - /* Detail/Single page sidebars end*/ |
|
177 | - /*==================================*/ |
|
165 | + register_sidebars(1, array('id' => 'geodir_detail_sidebar', 'name' => __('GD Detail Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
178 | 166 | |
179 | - /*==================================*/ |
|
180 | - /* Author page sidebars start */ |
|
181 | - /*==================================*/ |
|
167 | + $geodir_sidebars[] = 'geodir_detail_sidebar'; |
|
182 | 168 | |
183 | - if (get_option('geodir_show_author_top_section')) { |
|
184 | - register_sidebars(1, array('id' => 'geodir_author_top', 'name' => __('GD Author Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
169 | + if (get_option('geodir_show_detail_bottom_section')) { |
|
170 | + register_sidebars(1, array('id' => 'geodir_detail_bottom', 'name' => __('GD Detail Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
185 | 171 | |
186 | - $geodir_sidebars[] = 'geodir_author_top'; |
|
187 | - } |
|
172 | + $geodir_sidebars[] = 'geodir_detail_bottom'; |
|
173 | + } |
|
188 | 174 | |
189 | - if (get_option('geodir_show_author_left_section')) { |
|
190 | - register_sidebars(1, array('id' => 'geodir_author_left_sidebar', 'name' => __('GD Author Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
175 | + /*==================================*/ |
|
176 | + /* Detail/Single page sidebars end*/ |
|
177 | + /*==================================*/ |
|
191 | 178 | |
192 | - $geodir_sidebars[] = 'geodir_author_left_sidebar'; |
|
193 | - } |
|
179 | + /*==================================*/ |
|
180 | + /* Author page sidebars start */ |
|
181 | + /*==================================*/ |
|
194 | 182 | |
195 | - if (get_option('geodir_show_author_right_section')) { |
|
196 | - register_sidebars(1, array('id' => 'geodir_author_right_sidebar', 'name' => __('GD Author Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
183 | + if (get_option('geodir_show_author_top_section')) { |
|
184 | + register_sidebars(1, array('id' => 'geodir_author_top', 'name' => __('GD Author Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
197 | 185 | |
198 | - $geodir_sidebars[] = 'geodir_author_right_sidebar'; |
|
199 | - } |
|
186 | + $geodir_sidebars[] = 'geodir_author_top'; |
|
187 | + } |
|
200 | 188 | |
201 | - if (get_option('geodir_show_author_bottom_section')) { |
|
202 | - register_sidebars(1, array('id' => 'geodir_author_bottom', 'name' => __('GD Author Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
189 | + if (get_option('geodir_show_author_left_section')) { |
|
190 | + register_sidebars(1, array('id' => 'geodir_author_left_sidebar', 'name' => __('GD Author Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
203 | 191 | |
204 | - $geodir_sidebars[] = 'geodir_author_bottom'; |
|
205 | - } |
|
192 | + $geodir_sidebars[] = 'geodir_author_left_sidebar'; |
|
193 | + } |
|
206 | 194 | |
207 | - /*==================================*/ |
|
208 | - /* Author page sidebars end */ |
|
209 | - /*==================================*/ |
|
195 | + if (get_option('geodir_show_author_right_section')) { |
|
196 | + register_sidebars(1, array('id' => 'geodir_author_right_sidebar', 'name' => __('GD Author Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
210 | 197 | |
211 | - /*==================================*/ |
|
212 | - /* Add listing page sidebars start */ |
|
213 | - /*==================================*/ |
|
198 | + $geodir_sidebars[] = 'geodir_author_right_sidebar'; |
|
199 | + } |
|
214 | 200 | |
215 | - register_sidebars(1, array('id' => 'geodir_add_listing_sidebar', 'name' => __('GD Add Listing Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
201 | + if (get_option('geodir_show_author_bottom_section')) { |
|
202 | + register_sidebars(1, array('id' => 'geodir_author_bottom', 'name' => __('GD Author Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
216 | 203 | |
217 | - $geodir_sidebars[] = 'geodir_add_listing_sidebar'; |
|
204 | + $geodir_sidebars[] = 'geodir_author_bottom'; |
|
205 | + } |
|
218 | 206 | |
219 | - /*==================================*/ |
|
220 | - /* Add listing page sidebars end */ |
|
221 | - /*==================================*/ |
|
207 | + /*==================================*/ |
|
208 | + /* Author page sidebars end */ |
|
209 | + /*==================================*/ |
|
222 | 210 | |
223 | - } |
|
211 | + /*==================================*/ |
|
212 | + /* Add listing page sidebars start */ |
|
213 | + /*==================================*/ |
|
214 | + |
|
215 | + register_sidebars(1, array('id' => 'geodir_add_listing_sidebar', 'name' => __('GD Add Listing Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title)); |
|
216 | + |
|
217 | + $geodir_sidebars[] = 'geodir_add_listing_sidebar'; |
|
218 | + |
|
219 | + /*==================================*/ |
|
220 | + /* Add listing page sidebars end */ |
|
221 | + /*==================================*/ |
|
222 | + |
|
223 | + } |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | 227 | if (!function_exists('register_geodir_widgets')) { |
228 | - /** |
|
229 | - * Registers all Widgets. |
|
230 | - * |
|
231 | - * @since 1.0.0 |
|
232 | - * @package GeoDirectory |
|
233 | - */ |
|
234 | - function register_geodir_widgets() |
|
235 | - { |
|
236 | - /** |
|
237 | - * Login Widget. |
|
238 | - * |
|
239 | - * @since 1.0.0 |
|
240 | - */ |
|
241 | - class geodir_loginwidget extends WP_Widget |
|
242 | - { |
|
243 | - /** |
|
244 | - * Register the login widget with WordPress. |
|
245 | - * |
|
246 | - * @since 1.0.0 |
|
247 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
248 | - */ |
|
249 | - public function __construct() { |
|
250 | - $widget_ops = array('classname' => 'geodir_loginbox', 'description' => __('Geodirectory Loginbox Widget', 'geodirectory')); |
|
251 | - parent::__construct( |
|
252 | - 'geodir_loginbox', // Base ID |
|
253 | - __('GD > Loginbox', 'geodirectory'), // Name |
|
254 | - $widget_ops// Args |
|
255 | - ); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Front-end display content for login widget. |
|
260 | - * |
|
261 | - * @since 1.0.0 |
|
262 | - * @since 1.5.1 Declare function public. |
|
263 | - * |
|
264 | - * @param array $args Widget arguments. |
|
265 | - * @param array $instance Saved values from database. |
|
266 | - */ |
|
267 | - public function widget($args, $instance) |
|
268 | - { |
|
269 | - geodir_loginwidget_output($args, $instance); |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Sanitize login widget form values as they are saved. |
|
274 | - * |
|
275 | - * @since 1.0.0 |
|
276 | - * @since 1.5.1 Declare function public. |
|
277 | - * |
|
278 | - * @param array $new_instance Values just sent to be saved. |
|
279 | - * @param array $old_instance Previously saved values from database. |
|
280 | - * |
|
281 | - * @return array Updated safe values to be saved. |
|
282 | - */ |
|
283 | - public function update($new_instance, $old_instance) |
|
284 | - { |
|
285 | - //save the widget |
|
286 | - $instance = $old_instance; |
|
287 | - $instance['title'] = strip_tags($new_instance['title']); |
|
288 | - |
|
289 | - return $instance; |
|
290 | - } |
|
291 | - |
|
292 | - /** |
|
293 | - * Back-end login widget settings form. |
|
294 | - * |
|
295 | - * @since 1.0.0 |
|
296 | - * @since 1.5.1 Declare function public. |
|
297 | - * |
|
298 | - * @param array $instance Previously saved values from database. |
|
299 | - * @return string|void |
|
300 | - */ |
|
301 | - public function form($instance) |
|
302 | - { |
|
303 | - //widgetform in backend |
|
304 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
305 | - $title = strip_tags($instance['title']); |
|
306 | - |
|
307 | - ?> |
|
228 | + /** |
|
229 | + * Registers all Widgets. |
|
230 | + * |
|
231 | + * @since 1.0.0 |
|
232 | + * @package GeoDirectory |
|
233 | + */ |
|
234 | + function register_geodir_widgets() |
|
235 | + { |
|
236 | + /** |
|
237 | + * Login Widget. |
|
238 | + * |
|
239 | + * @since 1.0.0 |
|
240 | + */ |
|
241 | + class geodir_loginwidget extends WP_Widget |
|
242 | + { |
|
243 | + /** |
|
244 | + * Register the login widget with WordPress. |
|
245 | + * |
|
246 | + * @since 1.0.0 |
|
247 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
248 | + */ |
|
249 | + public function __construct() { |
|
250 | + $widget_ops = array('classname' => 'geodir_loginbox', 'description' => __('Geodirectory Loginbox Widget', 'geodirectory')); |
|
251 | + parent::__construct( |
|
252 | + 'geodir_loginbox', // Base ID |
|
253 | + __('GD > Loginbox', 'geodirectory'), // Name |
|
254 | + $widget_ops// Args |
|
255 | + ); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Front-end display content for login widget. |
|
260 | + * |
|
261 | + * @since 1.0.0 |
|
262 | + * @since 1.5.1 Declare function public. |
|
263 | + * |
|
264 | + * @param array $args Widget arguments. |
|
265 | + * @param array $instance Saved values from database. |
|
266 | + */ |
|
267 | + public function widget($args, $instance) |
|
268 | + { |
|
269 | + geodir_loginwidget_output($args, $instance); |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Sanitize login widget form values as they are saved. |
|
274 | + * |
|
275 | + * @since 1.0.0 |
|
276 | + * @since 1.5.1 Declare function public. |
|
277 | + * |
|
278 | + * @param array $new_instance Values just sent to be saved. |
|
279 | + * @param array $old_instance Previously saved values from database. |
|
280 | + * |
|
281 | + * @return array Updated safe values to be saved. |
|
282 | + */ |
|
283 | + public function update($new_instance, $old_instance) |
|
284 | + { |
|
285 | + //save the widget |
|
286 | + $instance = $old_instance; |
|
287 | + $instance['title'] = strip_tags($new_instance['title']); |
|
288 | + |
|
289 | + return $instance; |
|
290 | + } |
|
291 | + |
|
292 | + /** |
|
293 | + * Back-end login widget settings form. |
|
294 | + * |
|
295 | + * @since 1.0.0 |
|
296 | + * @since 1.5.1 Declare function public. |
|
297 | + * |
|
298 | + * @param array $instance Previously saved values from database. |
|
299 | + * @return string|void |
|
300 | + */ |
|
301 | + public function form($instance) |
|
302 | + { |
|
303 | + //widgetform in backend |
|
304 | + $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
305 | + $title = strip_tags($instance['title']); |
|
306 | + |
|
307 | + ?> |
|
308 | 308 | <p><label |
309 | 309 | for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'geodirectory'); ?> |
310 | 310 | : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" |
@@ -313,64 +313,64 @@ discard block |
||
313 | 313 | |
314 | 314 | |
315 | 315 | <?php |
316 | - } |
|
317 | - } |
|
318 | - |
|
319 | - register_widget('geodir_loginwidget'); |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * GeoDirectory Social Like Widget. |
|
324 | - * |
|
325 | - * @since 1.0.0 |
|
326 | - */ |
|
327 | - class geodir_social_like_widget extends WP_Widget |
|
328 | - { |
|
329 | - |
|
330 | - /** |
|
331 | - * Register the social like widget with WordPress. |
|
332 | - * |
|
333 | - * @since 1.0.0 |
|
334 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
335 | - */ |
|
336 | - public function __construct() { |
|
337 | - $widget_ops = array('classname' => 'geodir_social_like_widget', 'description' => __('GD > Twitter,Facebook and Google+ buttons', 'geodirectory')); |
|
338 | - parent::__construct( |
|
339 | - 'social_like_widget', // Base ID |
|
340 | - __('GD > Social Like', 'geodirectory'), // Name |
|
341 | - $widget_ops// Args |
|
342 | - ); |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * Front-end display content for social like widget. |
|
347 | - * |
|
348 | - * @since 1.0.0 |
|
349 | - * @since 1.5.1 Declare function public. |
|
350 | - * |
|
351 | - * @param array $args Widget arguments. |
|
352 | - * @param array $instance Saved values from database. |
|
353 | - */ |
|
354 | - public function widget($args, $instance) |
|
355 | - { |
|
356 | - // prints the widget |
|
357 | - extract($args, EXTR_SKIP); |
|
358 | - |
|
359 | - /** |
|
360 | - * Filter the widget title text. |
|
361 | - * |
|
362 | - * @since 1.0.0 |
|
363 | - * @global object $current_user Current user object. |
|
364 | - * @param string $title The widget title text. |
|
365 | - */ |
|
366 | - $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); |
|
367 | - |
|
368 | - global $current_user, $post; |
|
369 | - echo $before_widget; |
|
370 | - ?> |
|
316 | + } |
|
317 | + } |
|
318 | + |
|
319 | + register_widget('geodir_loginwidget'); |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * GeoDirectory Social Like Widget. |
|
324 | + * |
|
325 | + * @since 1.0.0 |
|
326 | + */ |
|
327 | + class geodir_social_like_widget extends WP_Widget |
|
328 | + { |
|
329 | + |
|
330 | + /** |
|
331 | + * Register the social like widget with WordPress. |
|
332 | + * |
|
333 | + * @since 1.0.0 |
|
334 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
335 | + */ |
|
336 | + public function __construct() { |
|
337 | + $widget_ops = array('classname' => 'geodir_social_like_widget', 'description' => __('GD > Twitter,Facebook and Google+ buttons', 'geodirectory')); |
|
338 | + parent::__construct( |
|
339 | + 'social_like_widget', // Base ID |
|
340 | + __('GD > Social Like', 'geodirectory'), // Name |
|
341 | + $widget_ops// Args |
|
342 | + ); |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * Front-end display content for social like widget. |
|
347 | + * |
|
348 | + * @since 1.0.0 |
|
349 | + * @since 1.5.1 Declare function public. |
|
350 | + * |
|
351 | + * @param array $args Widget arguments. |
|
352 | + * @param array $instance Saved values from database. |
|
353 | + */ |
|
354 | + public function widget($args, $instance) |
|
355 | + { |
|
356 | + // prints the widget |
|
357 | + extract($args, EXTR_SKIP); |
|
358 | + |
|
359 | + /** |
|
360 | + * Filter the widget title text. |
|
361 | + * |
|
362 | + * @since 1.0.0 |
|
363 | + * @global object $current_user Current user object. |
|
364 | + * @param string $title The widget title text. |
|
365 | + */ |
|
366 | + $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); |
|
367 | + |
|
368 | + global $current_user, $post; |
|
369 | + echo $before_widget; |
|
370 | + ?> |
|
371 | 371 | |
372 | 372 | <?php //if ( get_option('gd_tweet_button') ) { |
373 | - ?> |
|
373 | + ?> |
|
374 | 374 | |
375 | 375 | <a href="http://twitter.com/share" |
376 | 376 | class="twitter-share-button"><?php _e('Tweet', 'geodirectory');?></a> |
@@ -378,23 +378,23 @@ discard block |
||
378 | 378 | <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> |
379 | 379 | |
380 | 380 | <?php //} |
381 | - ?> |
|
381 | + ?> |
|
382 | 382 | |
383 | 383 | <?php // if ( get_option('gd_facebook_button') ) { |
384 | - ?> |
|
384 | + ?> |
|
385 | 385 | |
386 | 386 | <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) { |
387 | - echo 'allowtransparency="true"'; |
|
388 | - }?> class="facebook" |
|
387 | + echo 'allowtransparency="true"'; |
|
388 | + }?> class="facebook" |
|
389 | 389 | src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(geodir_curPageURL()); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" |
390 | 390 | style="border:none; overflow:hidden; width:100px; height:20px"></iframe> |
391 | 391 | |
392 | 392 | |
393 | 393 | <?php //} |
394 | - ?> |
|
394 | + ?> |
|
395 | 395 | |
396 | 396 | <?php //if ( get_option('gd_google_button') ) { |
397 | - ?> |
|
397 | + ?> |
|
398 | 398 | <script> |
399 | 399 | window.___gcfg = { |
400 | 400 | parsetags: 'explicit' |
@@ -408,118 +408,118 @@ discard block |
||
408 | 408 | "count": "true" |
409 | 409 | });</script> |
410 | 410 | <?php //} |
411 | - echo $after_widget; |
|
412 | - |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * Sanitize social like widget form values as they are saved. |
|
417 | - * |
|
418 | - * @since 1.0.0 |
|
419 | - * @since 1.5.1 Declare function public. |
|
420 | - * |
|
421 | - * @param array $new_instance Values just sent to be saved. |
|
422 | - * @param array $old_instance Previously saved values from database. |
|
423 | - * |
|
424 | - * @return array Updated safe values to be saved. |
|
425 | - */ |
|
426 | - public function update($new_instance, $old_instance) |
|
427 | - { |
|
428 | - //save the widget |
|
429 | - $instance = $old_instance; |
|
430 | - $instance['title'] = strip_tags($new_instance['title']); |
|
431 | - return $instance; |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Back-end social like widget settings form. |
|
436 | - * |
|
437 | - * @since 1.0.0 |
|
438 | - * @since 1.5.1 Declare function public. |
|
439 | - * |
|
440 | - * @param array $instance Previously saved values from database. |
|
441 | - * @return string|void |
|
442 | - */ |
|
443 | - public function form($instance) |
|
444 | - { |
|
445 | - //widgetform in backend |
|
446 | - $instance = wp_parse_args((array)$instance, array('title' => '')); |
|
447 | - $title = strip_tags($instance['title']); |
|
448 | - ?> |
|
411 | + echo $after_widget; |
|
412 | + |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * Sanitize social like widget form values as they are saved. |
|
417 | + * |
|
418 | + * @since 1.0.0 |
|
419 | + * @since 1.5.1 Declare function public. |
|
420 | + * |
|
421 | + * @param array $new_instance Values just sent to be saved. |
|
422 | + * @param array $old_instance Previously saved values from database. |
|
423 | + * |
|
424 | + * @return array Updated safe values to be saved. |
|
425 | + */ |
|
426 | + public function update($new_instance, $old_instance) |
|
427 | + { |
|
428 | + //save the widget |
|
429 | + $instance = $old_instance; |
|
430 | + $instance['title'] = strip_tags($new_instance['title']); |
|
431 | + return $instance; |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Back-end social like widget settings form. |
|
436 | + * |
|
437 | + * @since 1.0.0 |
|
438 | + * @since 1.5.1 Declare function public. |
|
439 | + * |
|
440 | + * @param array $instance Previously saved values from database. |
|
441 | + * @return string|void |
|
442 | + */ |
|
443 | + public function form($instance) |
|
444 | + { |
|
445 | + //widgetform in backend |
|
446 | + $instance = wp_parse_args((array)$instance, array('title' => '')); |
|
447 | + $title = strip_tags($instance['title']); |
|
448 | + ?> |
|
449 | 449 | <p>No settings for this widget</p> |
450 | 450 | |
451 | 451 | |
452 | 452 | <?php |
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - register_widget('geodir_social_like_widget'); |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * GeoDirectory Feedburner Subscribe widget. |
|
461 | - * |
|
462 | - * @since 1.0.0 |
|
463 | - */ |
|
464 | - class geodirsubscribeWidget extends WP_Widget |
|
465 | - { |
|
466 | - |
|
467 | - /** |
|
468 | - * Register the feedburner subscribe widget with WordPress. |
|
469 | - * |
|
470 | - * @since 1.0.0 |
|
471 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
472 | - */ |
|
473 | - public function __construct() { |
|
474 | - $widget_ops = array('classname' => 'geodir-subscribe', 'description' => __('GD > Google Feedburner Subscribe', 'geodirectory')); |
|
475 | - parent::__construct( |
|
476 | - 'widget_subscribeWidget', // Base ID |
|
477 | - __('GD > Subscribe', 'geodirectory'), // Name |
|
478 | - $widget_ops// Args |
|
479 | - ); |
|
480 | - } |
|
481 | - |
|
482 | - /** |
|
483 | - * Front-end display content for feedburner subscribe widget. |
|
484 | - * |
|
485 | - * @since 1.0.0 |
|
486 | - * @since 1.5.1 Declare function public. |
|
487 | - * |
|
488 | - * @param array $args Widget arguments. |
|
489 | - * @param array $instance Saved values from database. |
|
490 | - */ |
|
491 | - public function widget($args, $instance) |
|
492 | - { |
|
493 | - // prints the widget |
|
494 | - extract($args, EXTR_SKIP); |
|
495 | - |
|
496 | - /** |
|
497 | - * Filter the widget instance id. |
|
498 | - * |
|
499 | - * @since 1.0.0 |
|
500 | - * @param string $id The widget instance id. |
|
501 | - */ |
|
502 | - $id = empty($instance['id']) ? '' : apply_filters('widget_id', $instance['id']); |
|
503 | - |
|
504 | - /** This filter is documented in geodirectory_widgets.php */ |
|
505 | - $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory')); |
|
506 | - |
|
507 | - /** |
|
508 | - * Filter the widget text. |
|
509 | - * |
|
510 | - * @since 1.0.0 |
|
511 | - * @param string $text The widget text. |
|
512 | - */ |
|
513 | - $text = empty($instance['text']) ? '' : apply_filters('widget_text', $instance['text']); |
|
514 | - |
|
515 | - echo $before_widget; |
|
516 | - ?> |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + register_widget('geodir_social_like_widget'); |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * GeoDirectory Feedburner Subscribe widget. |
|
461 | + * |
|
462 | + * @since 1.0.0 |
|
463 | + */ |
|
464 | + class geodirsubscribeWidget extends WP_Widget |
|
465 | + { |
|
466 | + |
|
467 | + /** |
|
468 | + * Register the feedburner subscribe widget with WordPress. |
|
469 | + * |
|
470 | + * @since 1.0.0 |
|
471 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
472 | + */ |
|
473 | + public function __construct() { |
|
474 | + $widget_ops = array('classname' => 'geodir-subscribe', 'description' => __('GD > Google Feedburner Subscribe', 'geodirectory')); |
|
475 | + parent::__construct( |
|
476 | + 'widget_subscribeWidget', // Base ID |
|
477 | + __('GD > Subscribe', 'geodirectory'), // Name |
|
478 | + $widget_ops// Args |
|
479 | + ); |
|
480 | + } |
|
481 | + |
|
482 | + /** |
|
483 | + * Front-end display content for feedburner subscribe widget. |
|
484 | + * |
|
485 | + * @since 1.0.0 |
|
486 | + * @since 1.5.1 Declare function public. |
|
487 | + * |
|
488 | + * @param array $args Widget arguments. |
|
489 | + * @param array $instance Saved values from database. |
|
490 | + */ |
|
491 | + public function widget($args, $instance) |
|
492 | + { |
|
493 | + // prints the widget |
|
494 | + extract($args, EXTR_SKIP); |
|
495 | + |
|
496 | + /** |
|
497 | + * Filter the widget instance id. |
|
498 | + * |
|
499 | + * @since 1.0.0 |
|
500 | + * @param string $id The widget instance id. |
|
501 | + */ |
|
502 | + $id = empty($instance['id']) ? '' : apply_filters('widget_id', $instance['id']); |
|
503 | + |
|
504 | + /** This filter is documented in geodirectory_widgets.php */ |
|
505 | + $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory')); |
|
506 | + |
|
507 | + /** |
|
508 | + * Filter the widget text. |
|
509 | + * |
|
510 | + * @since 1.0.0 |
|
511 | + * @param string $text The widget text. |
|
512 | + */ |
|
513 | + $text = empty($instance['text']) ? '' : apply_filters('widget_text', $instance['text']); |
|
514 | + |
|
515 | + echo $before_widget; |
|
516 | + ?> |
|
517 | 517 | |
518 | 518 | <?php echo $before_title . $title; ?> <a href="<?php if ($id) { |
519 | - echo 'http://feeds2.feedburner.com/' . $id; |
|
520 | - } else { |
|
521 | - bloginfo('rss_url'); |
|
522 | - } ?>"><i class="fa fa-rss-square"></i> </a><?php echo $after_title;?> |
|
519 | + echo 'http://feeds2.feedburner.com/' . $id; |
|
520 | + } else { |
|
521 | + bloginfo('rss_url'); |
|
522 | + } ?>"><i class="fa fa-rss-square"></i> </a><?php echo $after_title;?> |
|
523 | 523 | |
524 | 524 | <?php if ($text <> "") { ?> |
525 | 525 | |
@@ -544,57 +544,57 @@ discard block |
||
544 | 544 | </form> |
545 | 545 | |
546 | 546 | <?php |
547 | - echo $after_widget; |
|
547 | + echo $after_widget; |
|
548 | 548 | |
549 | - } |
|
549 | + } |
|
550 | 550 | |
551 | - /** |
|
552 | - * Sanitize feedburner subscribe widget form values as they are saved. |
|
553 | - * |
|
554 | - * @since 1.0.0 |
|
555 | - * @since 1.5.1 Declare function public. |
|
556 | - * |
|
557 | - * @param array $new_instance Values just sent to be saved. |
|
558 | - * @param array $old_instance Previously saved values from database. |
|
559 | - * |
|
560 | - * @return array Updated safe values to be saved. |
|
561 | - */ |
|
562 | - public function update($new_instance, $old_instance) |
|
563 | - { |
|
551 | + /** |
|
552 | + * Sanitize feedburner subscribe widget form values as they are saved. |
|
553 | + * |
|
554 | + * @since 1.0.0 |
|
555 | + * @since 1.5.1 Declare function public. |
|
556 | + * |
|
557 | + * @param array $new_instance Values just sent to be saved. |
|
558 | + * @param array $old_instance Previously saved values from database. |
|
559 | + * |
|
560 | + * @return array Updated safe values to be saved. |
|
561 | + */ |
|
562 | + public function update($new_instance, $old_instance) |
|
563 | + { |
|
564 | 564 | |
565 | - //save the widget |
|
566 | - $instance = $old_instance; |
|
567 | - $instance['id'] = strip_tags($new_instance['id']); |
|
568 | - $instance['title'] = ($new_instance['title']); |
|
569 | - $instance['text'] = ($new_instance['text']); |
|
565 | + //save the widget |
|
566 | + $instance = $old_instance; |
|
567 | + $instance['id'] = strip_tags($new_instance['id']); |
|
568 | + $instance['title'] = ($new_instance['title']); |
|
569 | + $instance['text'] = ($new_instance['text']); |
|
570 | 570 | |
571 | 571 | |
572 | - return $instance; |
|
573 | - } |
|
572 | + return $instance; |
|
573 | + } |
|
574 | 574 | |
575 | - /** |
|
576 | - * Back-end feedburner subscribe widget settings form. |
|
577 | - * |
|
578 | - * @since 1.0.0 |
|
579 | - * @since 1.5.1 Declare function public. |
|
580 | - * |
|
581 | - * @param array $instance Previously saved values from database. |
|
582 | - * @return string|void |
|
583 | - */ |
|
584 | - public function form($instance) |
|
585 | - { |
|
586 | - //widgetform in backend |
|
587 | - $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'advt1' => '', 'text' => '', 'twitter' => '', 'facebook' => '', 'digg' => '', 'myspace' => '')); |
|
575 | + /** |
|
576 | + * Back-end feedburner subscribe widget settings form. |
|
577 | + * |
|
578 | + * @since 1.0.0 |
|
579 | + * @since 1.5.1 Declare function public. |
|
580 | + * |
|
581 | + * @param array $instance Previously saved values from database. |
|
582 | + * @return string|void |
|
583 | + */ |
|
584 | + public function form($instance) |
|
585 | + { |
|
586 | + //widgetform in backend |
|
587 | + $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'advt1' => '', 'text' => '', 'twitter' => '', 'facebook' => '', 'digg' => '', 'myspace' => '')); |
|
588 | 588 | |
589 | - $id = strip_tags($instance['id']); |
|
589 | + $id = strip_tags($instance['id']); |
|
590 | 590 | |
591 | - $title = strip_tags($instance['title']); |
|
591 | + $title = strip_tags($instance['title']); |
|
592 | 592 | |
593 | - $text = strip_tags($instance['text']); |
|
593 | + $text = strip_tags($instance['text']); |
|
594 | 594 | |
595 | 595 | |
596 | 596 | |
597 | - ?> |
|
597 | + ?> |
|
598 | 598 | <p><label |
599 | 599 | for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'geodirectory');?>: |
600 | 600 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" |
@@ -613,101 +613,101 @@ discard block |
||
613 | 613 | name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_attr($text); ?></textarea></label> |
614 | 614 | </p> |
615 | 615 | <?php |
616 | - } |
|
617 | - } |
|
618 | - |
|
619 | - register_widget('geodirsubscribeWidget'); |
|
620 | - |
|
621 | - /** |
|
622 | - * GeoDirectory advertise widget. |
|
623 | - * |
|
624 | - * @since 1.0.0 |
|
625 | - */ |
|
626 | - class geodiradvtwidget extends WP_Widget |
|
627 | - { |
|
628 | - |
|
629 | - /** |
|
630 | - * Register the advertise widget with WordPress. |
|
631 | - * |
|
632 | - * @since 1.0.0 |
|
633 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
634 | - */ |
|
635 | - public function __construct() { |
|
636 | - $widget_ops = array('classname' => 'GeoDirectory Advertise', 'description' => __('GD > common advertise widget in sidebar, bottom section', 'geodirectory')); |
|
637 | - parent::__construct( |
|
638 | - 'advtwidget', // Base ID |
|
639 | - __('GD > Advertise', 'geodirectory'), // Name |
|
640 | - $widget_ops// Args |
|
641 | - ); |
|
642 | - } |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * Front-end display content for advertise widget. |
|
647 | - * |
|
648 | - * @since 1.0.0 |
|
649 | - * @since 1.5.1 Declare function public. |
|
650 | - * |
|
651 | - * @param array $args Widget arguments. |
|
652 | - * @param array $instance Saved values from database. |
|
653 | - */ |
|
654 | - public function widget($args, $instance) |
|
655 | - { |
|
656 | - |
|
657 | - // prints the widget |
|
658 | - |
|
659 | - extract($args, EXTR_SKIP); |
|
660 | - |
|
661 | - /** |
|
662 | - * Filter the description text. |
|
663 | - * |
|
664 | - * @since 1.0.0 |
|
665 | - * @param string $desc1 The widget description text. |
|
666 | - */ |
|
667 | - $desc1 = empty($instance['desc1']) ? ' ' : apply_filters('widget_desc1', $instance['desc1']); |
|
668 | - echo $before_widget; |
|
669 | - ?> |
|
616 | + } |
|
617 | + } |
|
618 | + |
|
619 | + register_widget('geodirsubscribeWidget'); |
|
620 | + |
|
621 | + /** |
|
622 | + * GeoDirectory advertise widget. |
|
623 | + * |
|
624 | + * @since 1.0.0 |
|
625 | + */ |
|
626 | + class geodiradvtwidget extends WP_Widget |
|
627 | + { |
|
628 | + |
|
629 | + /** |
|
630 | + * Register the advertise widget with WordPress. |
|
631 | + * |
|
632 | + * @since 1.0.0 |
|
633 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
634 | + */ |
|
635 | + public function __construct() { |
|
636 | + $widget_ops = array('classname' => 'GeoDirectory Advertise', 'description' => __('GD > common advertise widget in sidebar, bottom section', 'geodirectory')); |
|
637 | + parent::__construct( |
|
638 | + 'advtwidget', // Base ID |
|
639 | + __('GD > Advertise', 'geodirectory'), // Name |
|
640 | + $widget_ops// Args |
|
641 | + ); |
|
642 | + } |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * Front-end display content for advertise widget. |
|
647 | + * |
|
648 | + * @since 1.0.0 |
|
649 | + * @since 1.5.1 Declare function public. |
|
650 | + * |
|
651 | + * @param array $args Widget arguments. |
|
652 | + * @param array $instance Saved values from database. |
|
653 | + */ |
|
654 | + public function widget($args, $instance) |
|
655 | + { |
|
656 | + |
|
657 | + // prints the widget |
|
658 | + |
|
659 | + extract($args, EXTR_SKIP); |
|
660 | + |
|
661 | + /** |
|
662 | + * Filter the description text. |
|
663 | + * |
|
664 | + * @since 1.0.0 |
|
665 | + * @param string $desc1 The widget description text. |
|
666 | + */ |
|
667 | + $desc1 = empty($instance['desc1']) ? ' ' : apply_filters('widget_desc1', $instance['desc1']); |
|
668 | + echo $before_widget; |
|
669 | + ?> |
|
670 | 670 | <?php if ($desc1 <> "") { ?> |
671 | 671 | <?php echo $desc1; ?> |
672 | 672 | <?php } |
673 | - echo $after_widget; |
|
674 | - } |
|
675 | - |
|
676 | - /** |
|
677 | - * Sanitize advertise widget form values as they are saved. |
|
678 | - * |
|
679 | - * @since 1.0.0 |
|
680 | - * @since 1.5.1 Declare function public. |
|
681 | - * |
|
682 | - * @param array $new_instance Values just sent to be saved. |
|
683 | - * @param array $old_instance Previously saved values from database. |
|
684 | - * |
|
685 | - * @return array Updated safe values to be saved. |
|
686 | - */ |
|
687 | - public function update($new_instance, $old_instance) |
|
688 | - { |
|
689 | - //save the widget |
|
690 | - $instance = $old_instance; |
|
691 | - $instance['desc1'] = ($new_instance['desc1']); |
|
692 | - return $instance; |
|
693 | - } |
|
694 | - |
|
695 | - /** |
|
696 | - * Back-end advertise widget settings form. |
|
697 | - * |
|
698 | - * @since 1.0.0 |
|
699 | - * @since 1.5.1 Declare function public. |
|
700 | - * |
|
701 | - * @param array $instance Previously saved values from database. |
|
702 | - * @return string|void |
|
703 | - */ |
|
704 | - public function form($instance) |
|
705 | - { |
|
706 | - //widgetform in backend |
|
707 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
708 | - |
|
709 | - $desc1 = ($instance['desc1']); |
|
710 | - ?> |
|
673 | + echo $after_widget; |
|
674 | + } |
|
675 | + |
|
676 | + /** |
|
677 | + * Sanitize advertise widget form values as they are saved. |
|
678 | + * |
|
679 | + * @since 1.0.0 |
|
680 | + * @since 1.5.1 Declare function public. |
|
681 | + * |
|
682 | + * @param array $new_instance Values just sent to be saved. |
|
683 | + * @param array $old_instance Previously saved values from database. |
|
684 | + * |
|
685 | + * @return array Updated safe values to be saved. |
|
686 | + */ |
|
687 | + public function update($new_instance, $old_instance) |
|
688 | + { |
|
689 | + //save the widget |
|
690 | + $instance = $old_instance; |
|
691 | + $instance['desc1'] = ($new_instance['desc1']); |
|
692 | + return $instance; |
|
693 | + } |
|
694 | + |
|
695 | + /** |
|
696 | + * Back-end advertise widget settings form. |
|
697 | + * |
|
698 | + * @since 1.0.0 |
|
699 | + * @since 1.5.1 Declare function public. |
|
700 | + * |
|
701 | + * @param array $instance Previously saved values from database. |
|
702 | + * @return string|void |
|
703 | + */ |
|
704 | + public function form($instance) |
|
705 | + { |
|
706 | + //widgetform in backend |
|
707 | + $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
708 | + |
|
709 | + $desc1 = ($instance['desc1']); |
|
710 | + ?> |
|
711 | 711 | <p><label |
712 | 712 | for="<?php echo $this->get_field_id('desc1'); ?>"><?php _e('Your Advt code (ex.google adsense, etc.)', 'geodirectory');?> |
713 | 713 | <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('desc1'); ?>" |
@@ -715,65 +715,65 @@ discard block |
||
715 | 715 | </p> |
716 | 716 | |
717 | 717 | <?php |
718 | - } |
|
719 | - } |
|
720 | - |
|
721 | - register_widget('geodiradvtwidget'); |
|
722 | - |
|
723 | - /** |
|
724 | - * GeoDirectory Flickr widget. |
|
725 | - * |
|
726 | - * @since 1.0.0 |
|
727 | - */ |
|
728 | - class GeodirFlickrWidget extends WP_Widget |
|
729 | - { |
|
730 | - |
|
731 | - /** |
|
732 | - * Register the flickr widget with WordPress. |
|
733 | - * |
|
734 | - * @since 1.0.0 |
|
735 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
736 | - */ |
|
737 | - public function __construct() { |
|
738 | - $widget_ops = array('classname' => 'Geo Dir Flickr Photos ', 'description' => __('GD > Flickr Photos', 'geodirectory')); |
|
739 | - parent::__construct( |
|
740 | - 'widget_flickrwidget', // Base ID |
|
741 | - __('GD > Flickr Photos', 'geodirectory'), // Name |
|
742 | - $widget_ops// Args |
|
743 | - ); |
|
744 | - } |
|
745 | - |
|
746 | - /** |
|
747 | - * Front-end display content for flickr widget. |
|
748 | - * |
|
749 | - * @since 1.0.0 |
|
750 | - * @since 1.5.1 Declare function public. |
|
751 | - * |
|
752 | - * @param array $args Widget arguments. |
|
753 | - * @param array $instance Saved values from database. |
|
754 | - */ |
|
755 | - public function widget($args, $instance) |
|
756 | - { |
|
757 | - |
|
758 | - // prints the widget |
|
759 | - extract($args, EXTR_SKIP); |
|
760 | - |
|
761 | - echo $before_widget; |
|
762 | - |
|
763 | - /** This filter is documented in geodirectory_widgets.php */ |
|
764 | - $id = empty($instance['id']) ? ' ' : apply_filters('widget_id', $instance['id']); |
|
765 | - |
|
766 | - /** |
|
767 | - * Filter the widget number. |
|
768 | - * |
|
769 | - * This is used in the flicker widget to show how many images to show. |
|
770 | - * |
|
771 | - * @since 1.0.0 |
|
772 | - * @param string $number The image count. |
|
773 | - */ |
|
774 | - $number = empty($instance['number']) ? ' ' : apply_filters('widget_number', $instance['number']); |
|
775 | - echo $before_title . __('Photo Gallery', 'geodirectory') . $after_title; |
|
776 | - ?> |
|
718 | + } |
|
719 | + } |
|
720 | + |
|
721 | + register_widget('geodiradvtwidget'); |
|
722 | + |
|
723 | + /** |
|
724 | + * GeoDirectory Flickr widget. |
|
725 | + * |
|
726 | + * @since 1.0.0 |
|
727 | + */ |
|
728 | + class GeodirFlickrWidget extends WP_Widget |
|
729 | + { |
|
730 | + |
|
731 | + /** |
|
732 | + * Register the flickr widget with WordPress. |
|
733 | + * |
|
734 | + * @since 1.0.0 |
|
735 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
736 | + */ |
|
737 | + public function __construct() { |
|
738 | + $widget_ops = array('classname' => 'Geo Dir Flickr Photos ', 'description' => __('GD > Flickr Photos', 'geodirectory')); |
|
739 | + parent::__construct( |
|
740 | + 'widget_flickrwidget', // Base ID |
|
741 | + __('GD > Flickr Photos', 'geodirectory'), // Name |
|
742 | + $widget_ops// Args |
|
743 | + ); |
|
744 | + } |
|
745 | + |
|
746 | + /** |
|
747 | + * Front-end display content for flickr widget. |
|
748 | + * |
|
749 | + * @since 1.0.0 |
|
750 | + * @since 1.5.1 Declare function public. |
|
751 | + * |
|
752 | + * @param array $args Widget arguments. |
|
753 | + * @param array $instance Saved values from database. |
|
754 | + */ |
|
755 | + public function widget($args, $instance) |
|
756 | + { |
|
757 | + |
|
758 | + // prints the widget |
|
759 | + extract($args, EXTR_SKIP); |
|
760 | + |
|
761 | + echo $before_widget; |
|
762 | + |
|
763 | + /** This filter is documented in geodirectory_widgets.php */ |
|
764 | + $id = empty($instance['id']) ? ' ' : apply_filters('widget_id', $instance['id']); |
|
765 | + |
|
766 | + /** |
|
767 | + * Filter the widget number. |
|
768 | + * |
|
769 | + * This is used in the flicker widget to show how many images to show. |
|
770 | + * |
|
771 | + * @since 1.0.0 |
|
772 | + * @param string $number The image count. |
|
773 | + */ |
|
774 | + $number = empty($instance['number']) ? ' ' : apply_filters('widget_number', $instance['number']); |
|
775 | + echo $before_title . __('Photo Gallery', 'geodirectory') . $after_title; |
|
776 | + ?> |
|
777 | 777 | |
778 | 778 | <div class="geodir-flickr clearfix"> |
779 | 779 | |
@@ -784,45 +784,45 @@ discard block |
||
784 | 784 | |
785 | 785 | |
786 | 786 | <?php echo $after_widget; |
787 | - } |
|
788 | - |
|
789 | - /** |
|
790 | - * Sanitize flickr widget form values as they are saved. |
|
791 | - * |
|
792 | - * @since 1.0.0 |
|
793 | - * @since 1.5.1 Declare function public. |
|
794 | - * |
|
795 | - * @param array $new_instance Values just sent to be saved. |
|
796 | - * @param array $old_instance Previously saved values from database. |
|
797 | - * |
|
798 | - * @return array Updated safe values to be saved. |
|
799 | - */ |
|
800 | - public function update($new_instance, $old_instance) |
|
801 | - { |
|
802 | - //save the widget |
|
803 | - $instance = $old_instance; |
|
804 | - $instance['id'] = strip_tags($new_instance['id']); |
|
805 | - $instance['number'] = strip_tags($new_instance['number']); |
|
806 | - return $instance; |
|
807 | - } |
|
808 | - |
|
809 | - /** |
|
810 | - * Back-end flickr widget settings form. |
|
811 | - * |
|
812 | - * @since 1.0.0 |
|
813 | - * @since 1.5.1 Declare function public. |
|
814 | - * |
|
815 | - * @param array $instance Previously saved values from database. |
|
816 | - * @return string|void |
|
817 | - */ |
|
818 | - public function form($instance) |
|
819 | - { |
|
820 | - |
|
821 | - //widgetform in backend |
|
822 | - $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'number' => '')); |
|
823 | - $id = strip_tags($instance['id']); |
|
824 | - $number = strip_tags($instance['number']); |
|
825 | - ?> |
|
787 | + } |
|
788 | + |
|
789 | + /** |
|
790 | + * Sanitize flickr widget form values as they are saved. |
|
791 | + * |
|
792 | + * @since 1.0.0 |
|
793 | + * @since 1.5.1 Declare function public. |
|
794 | + * |
|
795 | + * @param array $new_instance Values just sent to be saved. |
|
796 | + * @param array $old_instance Previously saved values from database. |
|
797 | + * |
|
798 | + * @return array Updated safe values to be saved. |
|
799 | + */ |
|
800 | + public function update($new_instance, $old_instance) |
|
801 | + { |
|
802 | + //save the widget |
|
803 | + $instance = $old_instance; |
|
804 | + $instance['id'] = strip_tags($new_instance['id']); |
|
805 | + $instance['number'] = strip_tags($new_instance['number']); |
|
806 | + return $instance; |
|
807 | + } |
|
808 | + |
|
809 | + /** |
|
810 | + * Back-end flickr widget settings form. |
|
811 | + * |
|
812 | + * @since 1.0.0 |
|
813 | + * @since 1.5.1 Declare function public. |
|
814 | + * |
|
815 | + * @param array $instance Previously saved values from database. |
|
816 | + * @return string|void |
|
817 | + */ |
|
818 | + public function form($instance) |
|
819 | + { |
|
820 | + |
|
821 | + //widgetform in backend |
|
822 | + $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'number' => '')); |
|
823 | + $id = strip_tags($instance['id']); |
|
824 | + $number = strip_tags($instance['number']); |
|
825 | + ?> |
|
826 | 826 | |
827 | 827 | <p> |
828 | 828 | <label |
@@ -843,99 +843,99 @@ discard block |
||
843 | 843 | </label> |
844 | 844 | </p> |
845 | 845 | <?php |
846 | - } |
|
847 | - } |
|
848 | - |
|
849 | - register_widget('GeodirFlickrWidget'); |
|
850 | - |
|
851 | - /** |
|
852 | - * GeoDirectory Twitter widget. |
|
853 | - * |
|
854 | - * @since 1.0.0 |
|
855 | - */ |
|
856 | - class geodir_twitter extends WP_Widget |
|
857 | - { |
|
858 | - /** |
|
859 | - * Register the Twitter widget with WordPress. |
|
860 | - * |
|
861 | - * @since 1.0.0 |
|
862 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
863 | - */ |
|
864 | - public function __construct() { |
|
865 | - $widget_ops = array('classname' => 'Twitter', 'description' => __('GD > Twitter Feed', 'geodirectory')); |
|
866 | - parent::__construct( |
|
867 | - 'widget_Twidget', // Base ID |
|
868 | - __('GD > Twitter', 'geodirectory'), // Name |
|
869 | - $widget_ops// Args |
|
870 | - ); |
|
871 | - } |
|
872 | - |
|
873 | - |
|
874 | - /** |
|
875 | - * Front-end display content for Twitter widget. |
|
876 | - * |
|
877 | - * @since 1.0.0 |
|
878 | - * @since 1.5.1 Declare function public. |
|
879 | - * |
|
880 | - * @param array $args Widget arguments. |
|
881 | - * @param array $instance Saved values from database. |
|
882 | - */ |
|
883 | - public function widget($args, $instance) |
|
884 | - { |
|
885 | - |
|
886 | - // prints the widget |
|
887 | - |
|
888 | - extract($args, EXTR_SKIP); |
|
889 | - |
|
890 | - /** |
|
891 | - * Filter the twitter widget description text. |
|
892 | - * |
|
893 | - * @since 1.0.0 |
|
894 | - * @param string $desc1 The widget description text. |
|
895 | - */ |
|
896 | - $desc1 = empty($instance['gd_tw_desc1']) ? ' ' : apply_filters('gd_tw_widget_desc1', $instance['gd_tw_desc1']); |
|
897 | - echo $before_widget; |
|
898 | - if ($desc1 <> "") { |
|
899 | - echo $desc1; |
|
900 | - } |
|
901 | - echo $after_widget; |
|
902 | - } |
|
903 | - |
|
904 | - /** |
|
905 | - * Sanitize twitter widget form values as they are saved. |
|
906 | - * |
|
907 | - * @since 1.0.0 |
|
908 | - * @since 1.5.1 Declare function public. |
|
909 | - * |
|
910 | - * @param array $new_instance Values just sent to be saved. |
|
911 | - * @param array $old_instance Previously saved values from database. |
|
912 | - * |
|
913 | - * @return array Updated safe values to be saved. |
|
914 | - */ |
|
915 | - public function update($new_instance, $old_instance) |
|
916 | - { |
|
917 | - //save the widget |
|
918 | - $instance = $old_instance; |
|
919 | - $instance['gd_tw_desc1'] = ($new_instance['gd_tw_desc1']); |
|
920 | - return $instance; |
|
921 | - } |
|
922 | - |
|
923 | - /** |
|
924 | - * Back-end twitter widget settings form. |
|
925 | - * |
|
926 | - * @since 1.0.0 |
|
927 | - * @since 1.5.1 Declare function public. |
|
928 | - * |
|
929 | - * @param array $instance Previously saved values from database. |
|
930 | - * @return string|void |
|
931 | - */ |
|
932 | - public function form($instance) |
|
933 | - { |
|
934 | - //widgetform in backend |
|
935 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'gd_tw_desc1' => '')); |
|
936 | - |
|
937 | - $desc1 = ($instance['gd_tw_desc1']); |
|
938 | - ?> |
|
846 | + } |
|
847 | + } |
|
848 | + |
|
849 | + register_widget('GeodirFlickrWidget'); |
|
850 | + |
|
851 | + /** |
|
852 | + * GeoDirectory Twitter widget. |
|
853 | + * |
|
854 | + * @since 1.0.0 |
|
855 | + */ |
|
856 | + class geodir_twitter extends WP_Widget |
|
857 | + { |
|
858 | + /** |
|
859 | + * Register the Twitter widget with WordPress. |
|
860 | + * |
|
861 | + * @since 1.0.0 |
|
862 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
863 | + */ |
|
864 | + public function __construct() { |
|
865 | + $widget_ops = array('classname' => 'Twitter', 'description' => __('GD > Twitter Feed', 'geodirectory')); |
|
866 | + parent::__construct( |
|
867 | + 'widget_Twidget', // Base ID |
|
868 | + __('GD > Twitter', 'geodirectory'), // Name |
|
869 | + $widget_ops// Args |
|
870 | + ); |
|
871 | + } |
|
872 | + |
|
873 | + |
|
874 | + /** |
|
875 | + * Front-end display content for Twitter widget. |
|
876 | + * |
|
877 | + * @since 1.0.0 |
|
878 | + * @since 1.5.1 Declare function public. |
|
879 | + * |
|
880 | + * @param array $args Widget arguments. |
|
881 | + * @param array $instance Saved values from database. |
|
882 | + */ |
|
883 | + public function widget($args, $instance) |
|
884 | + { |
|
885 | + |
|
886 | + // prints the widget |
|
887 | + |
|
888 | + extract($args, EXTR_SKIP); |
|
889 | + |
|
890 | + /** |
|
891 | + * Filter the twitter widget description text. |
|
892 | + * |
|
893 | + * @since 1.0.0 |
|
894 | + * @param string $desc1 The widget description text. |
|
895 | + */ |
|
896 | + $desc1 = empty($instance['gd_tw_desc1']) ? ' ' : apply_filters('gd_tw_widget_desc1', $instance['gd_tw_desc1']); |
|
897 | + echo $before_widget; |
|
898 | + if ($desc1 <> "") { |
|
899 | + echo $desc1; |
|
900 | + } |
|
901 | + echo $after_widget; |
|
902 | + } |
|
903 | + |
|
904 | + /** |
|
905 | + * Sanitize twitter widget form values as they are saved. |
|
906 | + * |
|
907 | + * @since 1.0.0 |
|
908 | + * @since 1.5.1 Declare function public. |
|
909 | + * |
|
910 | + * @param array $new_instance Values just sent to be saved. |
|
911 | + * @param array $old_instance Previously saved values from database. |
|
912 | + * |
|
913 | + * @return array Updated safe values to be saved. |
|
914 | + */ |
|
915 | + public function update($new_instance, $old_instance) |
|
916 | + { |
|
917 | + //save the widget |
|
918 | + $instance = $old_instance; |
|
919 | + $instance['gd_tw_desc1'] = ($new_instance['gd_tw_desc1']); |
|
920 | + return $instance; |
|
921 | + } |
|
922 | + |
|
923 | + /** |
|
924 | + * Back-end twitter widget settings form. |
|
925 | + * |
|
926 | + * @since 1.0.0 |
|
927 | + * @since 1.5.1 Declare function public. |
|
928 | + * |
|
929 | + * @param array $instance Previously saved values from database. |
|
930 | + * @return string|void |
|
931 | + */ |
|
932 | + public function form($instance) |
|
933 | + { |
|
934 | + //widgetform in backend |
|
935 | + $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'gd_tw_desc1' => '')); |
|
936 | + |
|
937 | + $desc1 = ($instance['gd_tw_desc1']); |
|
938 | + ?> |
|
939 | 939 | <p><label |
940 | 940 | for="<?php echo $this->get_field_id('gd_tw_desc1'); ?>"><?php _e('Your twitter code', 'geodirectory');?> |
941 | 941 | <textarea class="widefat" rows="6" cols="20" |
@@ -944,179 +944,179 @@ discard block |
||
944 | 944 | </p> |
945 | 945 | |
946 | 946 | <?php |
947 | - } |
|
948 | - } |
|
949 | - |
|
950 | - register_widget('geodir_twitter'); |
|
951 | - |
|
952 | - /** |
|
953 | - * GeoDirectory Advanced Search widget. |
|
954 | - * |
|
955 | - * @since 1.0.0 |
|
956 | - */ |
|
957 | - class geodir_advance_search_widget extends WP_Widget |
|
958 | - { |
|
959 | - /** |
|
960 | - * Register the advanced search widget with WordPress. |
|
961 | - * |
|
962 | - * @since 1.0.0 |
|
963 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
964 | - */ |
|
965 | - public function __construct() { |
|
966 | - $widget_ops = array('classname' => 'geodir_advance_search_widget', 'description' => __('GD > Search', 'geodirectory'),'post_type'=>''); |
|
967 | - parent::__construct( |
|
968 | - 'geodir_advance_search', // Base ID |
|
969 | - __('GD > Search', 'geodirectory'), // Name |
|
970 | - $widget_ops// Args |
|
971 | - ); |
|
972 | - } |
|
973 | - |
|
974 | - |
|
975 | - /** |
|
976 | - * Front-end display content for advanced search widget. |
|
977 | - * |
|
978 | - * @since 1.0.0 |
|
979 | - * @since 1.5.1 Declare function public. |
|
980 | - * |
|
981 | - * @param array $args Widget arguments. |
|
982 | - * @param array $instance Saved values from database. |
|
983 | - */ |
|
984 | - public function widget($args, $instance) |
|
985 | - { |
|
986 | - /** |
|
987 | - * Filter the search widget arguments. |
|
988 | - * |
|
989 | - * @since 1.5.7 |
|
990 | - * @param array $args The widget arguments. |
|
991 | - * @param array $instance The widget instance. |
|
992 | - */ |
|
993 | - $args = apply_filters('widget_geodir_advance_search_args',$args,$instance); |
|
994 | - |
|
995 | - // prints the widget |
|
996 | - extract($args, EXTR_SKIP); |
|
997 | - |
|
998 | - if(isset($post_type) && $post_type){ |
|
999 | - geodir_get_search_post_type($post_type);// set the post type |
|
1000 | - }else{ |
|
1001 | - geodir_get_search_post_type();// set the post type |
|
1002 | - } |
|
1003 | - |
|
1004 | - echo $before_widget; |
|
1005 | - |
|
1006 | - /** This filter is documented in geodirectory_widgets.php */ |
|
1007 | - $title = empty($instance['title']) ? __('Search', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory')); |
|
1008 | - |
|
1009 | - geodir_get_template_part('listing', 'filter-form'); |
|
1010 | - |
|
1011 | - echo $after_widget; |
|
1012 | - |
|
1013 | - // after outputing the search reset the CPT |
|
1014 | - global $geodir_search_post_type; |
|
1015 | - $geodir_search_post_type = ''; |
|
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * Sanitize advanced search widget form values as they are saved. |
|
1020 | - * |
|
1021 | - * @since 1.0.0 |
|
1022 | - * @since 1.5.1 Declare function public. |
|
1023 | - * |
|
1024 | - * @param array $new_instance Values just sent to be saved. |
|
1025 | - * @param array $old_instance Previously saved values from database. |
|
1026 | - * |
|
1027 | - * @return array Updated safe values to be saved. |
|
1028 | - */ |
|
1029 | - public function update($new_instance, $old_instance) |
|
1030 | - { |
|
1031 | - //save the widget |
|
1032 | - //Nothing to save |
|
1033 | - return isset($instance) ? $instance : array(); |
|
1034 | - } |
|
1035 | - |
|
1036 | - /** |
|
1037 | - * Back-end advanced search widget settings form. |
|
1038 | - * |
|
1039 | - * @since 1.0.0 |
|
1040 | - * @since 1.5.1 Declare function public. |
|
1041 | - * |
|
1042 | - * @param array $instance Previously saved values from database. |
|
1043 | - * @return string|void |
|
1044 | - */ |
|
1045 | - public function form($instance) |
|
1046 | - { |
|
1047 | - //widgetform in backend |
|
1048 | - echo __("This is a search widget to show advance search for gedodirectory listings.", 'geodirectory'); |
|
1049 | - } |
|
1050 | - } |
|
1051 | - |
|
1052 | - register_widget('geodir_advance_search_widget'); |
|
1053 | - |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * Contains all functions for popular widget. |
|
1057 | - * |
|
1058 | - * @since 1.0.0 |
|
1059 | - * @package GeoDirectory |
|
1060 | - */ |
|
1061 | - include_once('geodirectory-widgets/geodirectory_popular_widget.php'); |
|
1062 | - /** |
|
1063 | - * Contains all functions for listing slider widget. |
|
1064 | - * |
|
1065 | - * @since 1.0.0 |
|
1066 | - * @package GeoDirectory |
|
1067 | - */ |
|
1068 | - include_once('geodirectory-widgets/geodirectory_listing_slider_widget.php'); |
|
1069 | - /** |
|
1070 | - * Contains all functions for home map widget. |
|
1071 | - * |
|
1072 | - * @since 1.0.0 |
|
1073 | - * @package GeoDirectory |
|
1074 | - */ |
|
1075 | - include_once('geodirectory-widgets/home_map_widget.php'); |
|
1076 | - /** |
|
1077 | - * Contains all functions for listing map widget. |
|
1078 | - * |
|
1079 | - * @since 1.0.0 |
|
1080 | - * @package GeoDirectory |
|
1081 | - */ |
|
1082 | - include_once('geodirectory-widgets/listing_map_widget.php'); |
|
1083 | - /** |
|
1084 | - * Contains all functions for reviews widget. |
|
1085 | - * |
|
1086 | - * @since 1.0.0 |
|
1087 | - * @package GeoDirectory |
|
1088 | - */ |
|
1089 | - include_once('geodirectory-widgets/geodirectory_reviews_widget.php'); |
|
1090 | - /** |
|
1091 | - * Contains all functions for related listing widget. |
|
1092 | - * |
|
1093 | - * @since 1.0.0 |
|
1094 | - * @package GeoDirectory |
|
1095 | - */ |
|
1096 | - include_once('geodirectory-widgets/geodirectory_related_listing_widget.php'); |
|
1097 | - /** |
|
1098 | - * Contains all functions for bestof widget. |
|
1099 | - * |
|
1100 | - * @since 1.0.0 |
|
1101 | - * @package GeoDirectory |
|
1102 | - */ |
|
1103 | - include_once('geodirectory-widgets/geodirectory_bestof_widget.php'); |
|
947 | + } |
|
948 | + } |
|
949 | + |
|
950 | + register_widget('geodir_twitter'); |
|
951 | + |
|
952 | + /** |
|
953 | + * GeoDirectory Advanced Search widget. |
|
954 | + * |
|
955 | + * @since 1.0.0 |
|
956 | + */ |
|
957 | + class geodir_advance_search_widget extends WP_Widget |
|
958 | + { |
|
959 | + /** |
|
960 | + * Register the advanced search widget with WordPress. |
|
961 | + * |
|
962 | + * @since 1.0.0 |
|
963 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
964 | + */ |
|
965 | + public function __construct() { |
|
966 | + $widget_ops = array('classname' => 'geodir_advance_search_widget', 'description' => __('GD > Search', 'geodirectory'),'post_type'=>''); |
|
967 | + parent::__construct( |
|
968 | + 'geodir_advance_search', // Base ID |
|
969 | + __('GD > Search', 'geodirectory'), // Name |
|
970 | + $widget_ops// Args |
|
971 | + ); |
|
972 | + } |
|
973 | + |
|
974 | + |
|
975 | + /** |
|
976 | + * Front-end display content for advanced search widget. |
|
977 | + * |
|
978 | + * @since 1.0.0 |
|
979 | + * @since 1.5.1 Declare function public. |
|
980 | + * |
|
981 | + * @param array $args Widget arguments. |
|
982 | + * @param array $instance Saved values from database. |
|
983 | + */ |
|
984 | + public function widget($args, $instance) |
|
985 | + { |
|
986 | + /** |
|
987 | + * Filter the search widget arguments. |
|
988 | + * |
|
989 | + * @since 1.5.7 |
|
990 | + * @param array $args The widget arguments. |
|
991 | + * @param array $instance The widget instance. |
|
992 | + */ |
|
993 | + $args = apply_filters('widget_geodir_advance_search_args',$args,$instance); |
|
994 | + |
|
995 | + // prints the widget |
|
996 | + extract($args, EXTR_SKIP); |
|
997 | + |
|
998 | + if(isset($post_type) && $post_type){ |
|
999 | + geodir_get_search_post_type($post_type);// set the post type |
|
1000 | + }else{ |
|
1001 | + geodir_get_search_post_type();// set the post type |
|
1002 | + } |
|
1003 | + |
|
1004 | + echo $before_widget; |
|
1005 | + |
|
1006 | + /** This filter is documented in geodirectory_widgets.php */ |
|
1007 | + $title = empty($instance['title']) ? __('Search', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory')); |
|
1008 | + |
|
1009 | + geodir_get_template_part('listing', 'filter-form'); |
|
1010 | + |
|
1011 | + echo $after_widget; |
|
1012 | + |
|
1013 | + // after outputing the search reset the CPT |
|
1014 | + global $geodir_search_post_type; |
|
1015 | + $geodir_search_post_type = ''; |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * Sanitize advanced search widget form values as they are saved. |
|
1020 | + * |
|
1021 | + * @since 1.0.0 |
|
1022 | + * @since 1.5.1 Declare function public. |
|
1023 | + * |
|
1024 | + * @param array $new_instance Values just sent to be saved. |
|
1025 | + * @param array $old_instance Previously saved values from database. |
|
1026 | + * |
|
1027 | + * @return array Updated safe values to be saved. |
|
1028 | + */ |
|
1029 | + public function update($new_instance, $old_instance) |
|
1030 | + { |
|
1031 | + //save the widget |
|
1032 | + //Nothing to save |
|
1033 | + return isset($instance) ? $instance : array(); |
|
1034 | + } |
|
1035 | + |
|
1036 | + /** |
|
1037 | + * Back-end advanced search widget settings form. |
|
1038 | + * |
|
1039 | + * @since 1.0.0 |
|
1040 | + * @since 1.5.1 Declare function public. |
|
1041 | + * |
|
1042 | + * @param array $instance Previously saved values from database. |
|
1043 | + * @return string|void |
|
1044 | + */ |
|
1045 | + public function form($instance) |
|
1046 | + { |
|
1047 | + //widgetform in backend |
|
1048 | + echo __("This is a search widget to show advance search for gedodirectory listings.", 'geodirectory'); |
|
1049 | + } |
|
1050 | + } |
|
1051 | + |
|
1052 | + register_widget('geodir_advance_search_widget'); |
|
1053 | + |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * Contains all functions for popular widget. |
|
1057 | + * |
|
1058 | + * @since 1.0.0 |
|
1059 | + * @package GeoDirectory |
|
1060 | + */ |
|
1061 | + include_once('geodirectory-widgets/geodirectory_popular_widget.php'); |
|
1062 | + /** |
|
1063 | + * Contains all functions for listing slider widget. |
|
1064 | + * |
|
1065 | + * @since 1.0.0 |
|
1066 | + * @package GeoDirectory |
|
1067 | + */ |
|
1068 | + include_once('geodirectory-widgets/geodirectory_listing_slider_widget.php'); |
|
1069 | + /** |
|
1070 | + * Contains all functions for home map widget. |
|
1071 | + * |
|
1072 | + * @since 1.0.0 |
|
1073 | + * @package GeoDirectory |
|
1074 | + */ |
|
1075 | + include_once('geodirectory-widgets/home_map_widget.php'); |
|
1076 | + /** |
|
1077 | + * Contains all functions for listing map widget. |
|
1078 | + * |
|
1079 | + * @since 1.0.0 |
|
1080 | + * @package GeoDirectory |
|
1081 | + */ |
|
1082 | + include_once('geodirectory-widgets/listing_map_widget.php'); |
|
1083 | + /** |
|
1084 | + * Contains all functions for reviews widget. |
|
1085 | + * |
|
1086 | + * @since 1.0.0 |
|
1087 | + * @package GeoDirectory |
|
1088 | + */ |
|
1089 | + include_once('geodirectory-widgets/geodirectory_reviews_widget.php'); |
|
1090 | + /** |
|
1091 | + * Contains all functions for related listing widget. |
|
1092 | + * |
|
1093 | + * @since 1.0.0 |
|
1094 | + * @package GeoDirectory |
|
1095 | + */ |
|
1096 | + include_once('geodirectory-widgets/geodirectory_related_listing_widget.php'); |
|
1097 | + /** |
|
1098 | + * Contains all functions for bestof widget. |
|
1099 | + * |
|
1100 | + * @since 1.0.0 |
|
1101 | + * @package GeoDirectory |
|
1102 | + */ |
|
1103 | + include_once('geodirectory-widgets/geodirectory_bestof_widget.php'); |
|
1104 | + /** |
|
1105 | + * Contains all functions for cpt categories widget. |
|
1106 | + * |
|
1107 | + * @since 1.5.4 |
|
1108 | + * @package GeoDirectory |
|
1109 | + */ |
|
1110 | + include_once('geodirectory-widgets/geodirectory_cpt_categories_widget.php'); |
|
1104 | 1111 | /** |
1105 | - * Contains all functions for cpt categories widget. |
|
1106 | - * |
|
1107 | - * @since 1.5.4 |
|
1108 | - * @package GeoDirectory |
|
1109 | - */ |
|
1110 | - include_once('geodirectory-widgets/geodirectory_cpt_categories_widget.php'); |
|
1111 | - /** |
|
1112 | - * Contains all functions for features widget. |
|
1113 | - * |
|
1114 | - * @since 1.5.6 |
|
1115 | - * @package GeoDirectory |
|
1116 | - * @todo make the image field recurring |
|
1117 | - */ |
|
1118 | - include_once('geodirectory-widgets/geodirectory_features_widget.php'); |
|
1119 | - } |
|
1112 | + * Contains all functions for features widget. |
|
1113 | + * |
|
1114 | + * @since 1.5.6 |
|
1115 | + * @package GeoDirectory |
|
1116 | + * @todo make the image field recurring |
|
1117 | + */ |
|
1118 | + include_once('geodirectory-widgets/geodirectory_features_widget.php'); |
|
1119 | + } |
|
1120 | 1120 | |
1121 | 1121 | } |
1122 | 1122 |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | public function form($instance) |
302 | 302 | { |
303 | 303 | //widgetform in backend |
304 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
304 | + $instance = wp_parse_args((array) $instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
305 | 305 | $title = strip_tags($instance['title']); |
306 | 306 | |
307 | 307 | ?> |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | ?> |
374 | 374 | |
375 | 375 | <a href="http://twitter.com/share" |
376 | - class="twitter-share-button"><?php _e('Tweet', 'geodirectory');?></a> |
|
376 | + class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a> |
|
377 | 377 | |
378 | 378 | <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> |
379 | 379 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | public function form($instance) |
444 | 444 | { |
445 | 445 | //widgetform in backend |
446 | - $instance = wp_parse_args((array)$instance, array('title' => '')); |
|
446 | + $instance = wp_parse_args((array) $instance, array('title' => '')); |
|
447 | 447 | $title = strip_tags($instance['title']); |
448 | 448 | ?> |
449 | 449 | <p>No settings for this widget</p> |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | echo $before_widget; |
516 | 516 | ?> |
517 | 517 | |
518 | - <?php echo $before_title . $title; ?> <a href="<?php if ($id) { |
|
519 | - echo 'http://feeds2.feedburner.com/' . $id; |
|
518 | + <?php echo $before_title.$title; ?> <a href="<?php if ($id) { |
|
519 | + echo 'http://feeds2.feedburner.com/'.$id; |
|
520 | 520 | } else { |
521 | 521 | bloginfo('rss_url'); |
522 | - } ?>"><i class="fa fa-rss-square"></i> </a><?php echo $after_title;?> |
|
522 | + } ?>"><i class="fa fa-rss-square"></i> </a><?php echo $after_title; ?> |
|
523 | 523 | |
524 | 524 | <?php if ($text <> "") { ?> |
525 | 525 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | public function form($instance) |
585 | 585 | { |
586 | 586 | //widgetform in backend |
587 | - $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'advt1' => '', 'text' => '', 'twitter' => '', 'facebook' => '', 'digg' => '', 'myspace' => '')); |
|
587 | + $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => '', 'advt1' => '', 'text' => '', 'twitter' => '', 'facebook' => '', 'digg' => '', 'myspace' => '')); |
|
588 | 588 | |
589 | 589 | $id = strip_tags($instance['id']); |
590 | 590 | |
@@ -596,19 +596,19 @@ discard block |
||
596 | 596 | |
597 | 597 | ?> |
598 | 598 | <p><label |
599 | - for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'geodirectory');?>: |
|
599 | + for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'geodirectory'); ?>: |
|
600 | 600 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" |
601 | 601 | name="<?php echo $this->get_field_name('title'); ?>" type="text" |
602 | 602 | value="<?php echo esc_attr($title); ?>"/></label></p> |
603 | 603 | |
604 | 604 | <p><label |
605 | - for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Feedburner ID (ex :- geotheme)', 'geodirectory');?> |
|
605 | + for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Feedburner ID (ex :- geotheme)', 'geodirectory'); ?> |
|
606 | 606 | : <input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" |
607 | 607 | name="<?php echo $this->get_field_name('id'); ?>" type="text" |
608 | 608 | value="<?php echo esc_attr($id); ?>"/></label></p> |
609 | 609 | |
610 | 610 | <p><label |
611 | - for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Short Description', 'geodirectory');?> |
|
611 | + for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Short Description', 'geodirectory'); ?> |
|
612 | 612 | <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('text'); ?>" |
613 | 613 | name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_attr($text); ?></textarea></label> |
614 | 614 | </p> |
@@ -704,12 +704,12 @@ discard block |
||
704 | 704 | public function form($instance) |
705 | 705 | { |
706 | 706 | //widgetform in backend |
707 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
707 | + $instance = wp_parse_args((array) $instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => '')); |
|
708 | 708 | |
709 | 709 | $desc1 = ($instance['desc1']); |
710 | 710 | ?> |
711 | 711 | <p><label |
712 | - for="<?php echo $this->get_field_id('desc1'); ?>"><?php _e('Your Advt code (ex.google adsense, etc.)', 'geodirectory');?> |
|
712 | + for="<?php echo $this->get_field_id('desc1'); ?>"><?php _e('Your Advt code (ex.google adsense, etc.)', 'geodirectory'); ?> |
|
713 | 713 | <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('desc1'); ?>" |
714 | 714 | name="<?php echo $this->get_field_name('desc1'); ?>"><?php echo esc_attr($desc1); ?></textarea></label> |
715 | 715 | </p> |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | * @param string $number The image count. |
773 | 773 | */ |
774 | 774 | $number = empty($instance['number']) ? ' ' : apply_filters('widget_number', $instance['number']); |
775 | - echo $before_title . __('Photo Gallery', 'geodirectory') . $after_title; |
|
775 | + echo $before_title.__('Photo Gallery', 'geodirectory').$after_title; |
|
776 | 776 | ?> |
777 | 777 | |
778 | 778 | <div class="geodir-flickr clearfix"> |
@@ -819,14 +819,14 @@ discard block |
||
819 | 819 | { |
820 | 820 | |
821 | 821 | //widgetform in backend |
822 | - $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'number' => '')); |
|
822 | + $instance = wp_parse_args((array) $instance, array('title' => '', 'id' => '', 'number' => '')); |
|
823 | 823 | $id = strip_tags($instance['id']); |
824 | 824 | $number = strip_tags($instance['number']); |
825 | 825 | ?> |
826 | 826 | |
827 | 827 | <p> |
828 | 828 | <label |
829 | - for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Flickr ID', 'geodirectory');?> |
|
829 | + for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Flickr ID', 'geodirectory'); ?> |
|
830 | 830 | (<a href="http://www.idgettr.com">idGettr</a>): |
831 | 831 | <input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" |
832 | 832 | name="<?php echo $this->get_field_name('id'); ?>" type="text" |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | |
837 | 837 | <p> |
838 | 838 | <label |
839 | - for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of photos:', 'geodirectory');?> |
|
839 | + for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of photos:', 'geodirectory'); ?> |
|
840 | 840 | <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" |
841 | 841 | name="<?php echo $this->get_field_name('number'); ?>" type="text" |
842 | 842 | value="<?php echo esc_attr($number); ?>"/> |
@@ -932,12 +932,12 @@ discard block |
||
932 | 932 | public function form($instance) |
933 | 933 | { |
934 | 934 | //widgetform in backend |
935 | - $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'gd_tw_desc1' => '')); |
|
935 | + $instance = wp_parse_args((array) $instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'gd_tw_desc1' => '')); |
|
936 | 936 | |
937 | 937 | $desc1 = ($instance['gd_tw_desc1']); |
938 | 938 | ?> |
939 | 939 | <p><label |
940 | - for="<?php echo $this->get_field_id('gd_tw_desc1'); ?>"><?php _e('Your twitter code', 'geodirectory');?> |
|
940 | + for="<?php echo $this->get_field_id('gd_tw_desc1'); ?>"><?php _e('Your twitter code', 'geodirectory'); ?> |
|
941 | 941 | <textarea class="widefat" rows="6" cols="20" |
942 | 942 | id="<?php echo $this->get_field_id('gd_tw_desc1'); ?>" |
943 | 943 | name="<?php echo $this->get_field_name('gd_tw_desc1'); ?>"><?php echo esc_attr($desc1); ?></textarea></label> |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
964 | 964 | */ |
965 | 965 | public function __construct() { |
966 | - $widget_ops = array('classname' => 'geodir_advance_search_widget', 'description' => __('GD > Search', 'geodirectory'),'post_type'=>''); |
|
966 | + $widget_ops = array('classname' => 'geodir_advance_search_widget', 'description' => __('GD > Search', 'geodirectory'), 'post_type'=>''); |
|
967 | 967 | parent::__construct( |
968 | 968 | 'geodir_advance_search', // Base ID |
969 | 969 | __('GD > Search', 'geodirectory'), // Name |
@@ -990,15 +990,15 @@ discard block |
||
990 | 990 | * @param array $args The widget arguments. |
991 | 991 | * @param array $instance The widget instance. |
992 | 992 | */ |
993 | - $args = apply_filters('widget_geodir_advance_search_args',$args,$instance); |
|
993 | + $args = apply_filters('widget_geodir_advance_search_args', $args, $instance); |
|
994 | 994 | |
995 | 995 | // prints the widget |
996 | 996 | extract($args, EXTR_SKIP); |
997 | 997 | |
998 | - if(isset($post_type) && $post_type){ |
|
999 | - geodir_get_search_post_type($post_type);// set the post type |
|
1000 | - }else{ |
|
1001 | - geodir_get_search_post_type();// set the post type |
|
998 | + if (isset($post_type) && $post_type) { |
|
999 | + geodir_get_search_post_type($post_type); // set the post type |
|
1000 | + } else { |
|
1001 | + geodir_get_search_post_type(); // set the post type |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | echo $before_widget; |
@@ -997,7 +997,7 @@ |
||
997 | 997 | |
998 | 998 | if(isset($post_type) && $post_type){ |
999 | 999 | geodir_get_search_post_type($post_type);// set the post type |
1000 | - }else{ |
|
1000 | + } else{ |
|
1001 | 1001 | geodir_get_search_post_type();// set the post type |
1002 | 1002 | } |
1003 | 1003 |
@@ -17,26 +17,26 @@ discard block |
||
17 | 17 | function gd_compat_php_genesis() |
18 | 18 | { |
19 | 19 | // REPLACE GENESIS BREADCRUMBS WITH GD BREADCRUMBS |
20 | - remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); |
|
21 | - remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); |
|
22 | - remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); |
|
23 | - remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); |
|
24 | - remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); |
|
25 | - remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); |
|
20 | + remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20); |
|
21 | + remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20); |
|
22 | + remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20); |
|
23 | + remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20); |
|
24 | + remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20); |
|
25 | + remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20); |
|
26 | 26 | |
27 | 27 | |
28 | - // make top section wide |
|
29 | - remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); |
|
30 | - remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); |
|
31 | - remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); |
|
32 | - remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); |
|
33 | - remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); |
|
34 | - remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); |
|
28 | + // make top section wide |
|
29 | + remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); |
|
30 | + remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10); |
|
31 | + remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10); |
|
32 | + remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10); |
|
33 | + remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10); |
|
34 | + remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10); |
|
35 | 35 | |
36 | - // REMOVE PAGE TITLES |
|
37 | - remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); |
|
38 | - remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); |
|
39 | - remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); |
|
36 | + // REMOVE PAGE TITLES |
|
37 | + remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10); |
|
38 | + remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10); |
|
39 | + remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | } |
@@ -53,25 +53,25 @@ discard block |
||
53 | 53 | function gd_genesis_compat_left_sidebars() |
54 | 54 | { |
55 | 55 | |
56 | - if (is_page_geodir_home()) { |
|
57 | - remove_action('geodir_home_sidebar_left', 'geodir_action_home_sidebar_left', 10); |
|
58 | - add_action('geodir_wrapper_close', 'geodir_action_home_sidebar_left', 11); |
|
59 | - } elseif (geodir_is_page('location')) { |
|
60 | - remove_action('geodir_location_sidebar_left', 'geodir_action_home_sidebar_left', 10); |
|
61 | - add_action('geodir_wrapper_close', 'geodir_action_home_sidebar_left', 11); |
|
62 | - } elseif (geodir_is_page('listing')) { |
|
63 | - remove_action('geodir_listings_sidebar_left', 'geodir_action_listings_sidebar_left', 10); |
|
64 | - add_action('geodir_wrapper_close', 'geodir_action_listings_sidebar_left', 11); |
|
65 | - } elseif (geodir_is_page('detail') && get_option('geodir_detail_sidebar_left_section')) { |
|
66 | - //remove_action( 'geodir_detail_sidebar', 'geodir_action_details_sidebar', 10 ); |
|
67 | - //add_action( 'geodir_wrapper_close', 'geodir_action_details_sidebar', 11 ); |
|
68 | - } elseif (geodir_is_page('search')) { |
|
69 | - remove_action('geodir_search_sidebar_left', 'geodir_action_search_sidebar_left', 10); |
|
70 | - add_action('geodir_wrapper_close', 'geodir_action_search_sidebar_left', 11); |
|
71 | - } elseif (geodir_is_page('author')) { |
|
72 | - remove_action('geodir_author_sidebar_left', 'geodir_action_author_sidebar_left', 10); |
|
73 | - add_action('geodir_wrapper_close', 'geodir_action_author_sidebar_left', 11); |
|
74 | - } |
|
56 | + if (is_page_geodir_home()) { |
|
57 | + remove_action('geodir_home_sidebar_left', 'geodir_action_home_sidebar_left', 10); |
|
58 | + add_action('geodir_wrapper_close', 'geodir_action_home_sidebar_left', 11); |
|
59 | + } elseif (geodir_is_page('location')) { |
|
60 | + remove_action('geodir_location_sidebar_left', 'geodir_action_home_sidebar_left', 10); |
|
61 | + add_action('geodir_wrapper_close', 'geodir_action_home_sidebar_left', 11); |
|
62 | + } elseif (geodir_is_page('listing')) { |
|
63 | + remove_action('geodir_listings_sidebar_left', 'geodir_action_listings_sidebar_left', 10); |
|
64 | + add_action('geodir_wrapper_close', 'geodir_action_listings_sidebar_left', 11); |
|
65 | + } elseif (geodir_is_page('detail') && get_option('geodir_detail_sidebar_left_section')) { |
|
66 | + //remove_action( 'geodir_detail_sidebar', 'geodir_action_details_sidebar', 10 ); |
|
67 | + //add_action( 'geodir_wrapper_close', 'geodir_action_details_sidebar', 11 ); |
|
68 | + } elseif (geodir_is_page('search')) { |
|
69 | + remove_action('geodir_search_sidebar_left', 'geodir_action_search_sidebar_left', 10); |
|
70 | + add_action('geodir_wrapper_close', 'geodir_action_search_sidebar_left', 11); |
|
71 | + } elseif (geodir_is_page('author')) { |
|
72 | + remove_action('geodir_author_sidebar_left', 'geodir_action_author_sidebar_left', 10); |
|
73 | + add_action('geodir_wrapper_close', 'geodir_action_author_sidebar_left', 11); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | 77 | } |
@@ -88,65 +88,65 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function geodir_set_body_scs($classes) |
90 | 90 | { |
91 | - $remove_class = false; |
|
92 | - $new_class = ''; |
|
93 | - if (is_page_geodir_home() || geodir_is_page('location')) { |
|
94 | - $remove_class = true; |
|
95 | - if (get_option('geodir_show_home_left_section')) { |
|
96 | - $new_class .= 'sidebar-'; |
|
97 | - } |
|
98 | - if (get_option('geodir_show_home_contant_section')) { |
|
99 | - $new_class .= 'content'; |
|
100 | - } |
|
101 | - if (get_option('geodir_show_home_right_section')) { |
|
102 | - $new_class .= '-sidebar'; |
|
103 | - } |
|
104 | - } elseif (geodir_is_page('listing')) { |
|
105 | - $remove_class = true; |
|
106 | - if (get_option('geodir_show_listing_left_section')) { |
|
107 | - $new_class .= 'sidebar-'; |
|
108 | - } |
|
109 | - $new_class .= 'content'; |
|
110 | - if (get_option('geodir_show_listing_right_section')) { |
|
111 | - $new_class .= '-sidebar'; |
|
112 | - } |
|
113 | - } elseif (geodir_is_page('detail')) { |
|
114 | - $remove_class = true; |
|
115 | - if (get_option('geodir_detail_sidebar_left_section')) { |
|
116 | - $new_class .= 'sidebar-content gd-details-sidebar-left'; |
|
117 | - } else { |
|
118 | - $new_class .= 'content-sidebar'; |
|
119 | - } |
|
120 | - } elseif (geodir_is_page('search')) { |
|
121 | - $remove_class = true; |
|
122 | - if (get_option('geodir_show_search_left_section')) { |
|
123 | - $new_class .= 'sidebar-'; |
|
124 | - } |
|
125 | - $new_class .= 'content'; |
|
126 | - if (get_option('geodir_show_search_right_section')) { |
|
127 | - $new_class .= '-sidebar'; |
|
128 | - } |
|
129 | - } elseif (geodir_is_page('author')) { |
|
130 | - $remove_class = true; |
|
131 | - if (get_option('geodir_show_author_left_section')) { |
|
132 | - $new_class .= 'sidebar-'; |
|
133 | - } |
|
134 | - $new_class .= 'content'; |
|
135 | - if (get_option('geodir_show_author_right_section')) { |
|
136 | - $new_class .= '-sidebar'; |
|
137 | - } |
|
138 | - } elseif (geodir_is_page('add-listing')) { |
|
139 | - $remove_class = true; |
|
140 | - $new_class .= 'content-sidebar'; |
|
141 | - } |
|
142 | - |
|
143 | - if ($remove_class) { |
|
144 | - $classes = array_diff($classes, array('content-sidebar', 'sidebar-content', 'content-sidebar-sidebar', 'sidebar-sidebar-content', 'sidebar-content-sidebar', 'full-width-content')); |
|
145 | - //str_replace(array('content-sidebar','sidebar-content','content-sidebar-sidebar','sidebar-sidebar-content','sidebar-content-sidebar','full-width-content'),array('','','','','',''),$classes); |
|
146 | - $classes[] = $new_class; |
|
147 | - } |
|
148 | - |
|
149 | - return $classes; |
|
91 | + $remove_class = false; |
|
92 | + $new_class = ''; |
|
93 | + if (is_page_geodir_home() || geodir_is_page('location')) { |
|
94 | + $remove_class = true; |
|
95 | + if (get_option('geodir_show_home_left_section')) { |
|
96 | + $new_class .= 'sidebar-'; |
|
97 | + } |
|
98 | + if (get_option('geodir_show_home_contant_section')) { |
|
99 | + $new_class .= 'content'; |
|
100 | + } |
|
101 | + if (get_option('geodir_show_home_right_section')) { |
|
102 | + $new_class .= '-sidebar'; |
|
103 | + } |
|
104 | + } elseif (geodir_is_page('listing')) { |
|
105 | + $remove_class = true; |
|
106 | + if (get_option('geodir_show_listing_left_section')) { |
|
107 | + $new_class .= 'sidebar-'; |
|
108 | + } |
|
109 | + $new_class .= 'content'; |
|
110 | + if (get_option('geodir_show_listing_right_section')) { |
|
111 | + $new_class .= '-sidebar'; |
|
112 | + } |
|
113 | + } elseif (geodir_is_page('detail')) { |
|
114 | + $remove_class = true; |
|
115 | + if (get_option('geodir_detail_sidebar_left_section')) { |
|
116 | + $new_class .= 'sidebar-content gd-details-sidebar-left'; |
|
117 | + } else { |
|
118 | + $new_class .= 'content-sidebar'; |
|
119 | + } |
|
120 | + } elseif (geodir_is_page('search')) { |
|
121 | + $remove_class = true; |
|
122 | + if (get_option('geodir_show_search_left_section')) { |
|
123 | + $new_class .= 'sidebar-'; |
|
124 | + } |
|
125 | + $new_class .= 'content'; |
|
126 | + if (get_option('geodir_show_search_right_section')) { |
|
127 | + $new_class .= '-sidebar'; |
|
128 | + } |
|
129 | + } elseif (geodir_is_page('author')) { |
|
130 | + $remove_class = true; |
|
131 | + if (get_option('geodir_show_author_left_section')) { |
|
132 | + $new_class .= 'sidebar-'; |
|
133 | + } |
|
134 | + $new_class .= 'content'; |
|
135 | + if (get_option('geodir_show_author_right_section')) { |
|
136 | + $new_class .= '-sidebar'; |
|
137 | + } |
|
138 | + } elseif (geodir_is_page('add-listing')) { |
|
139 | + $remove_class = true; |
|
140 | + $new_class .= 'content-sidebar'; |
|
141 | + } |
|
142 | + |
|
143 | + if ($remove_class) { |
|
144 | + $classes = array_diff($classes, array('content-sidebar', 'sidebar-content', 'content-sidebar-sidebar', 'sidebar-sidebar-content', 'sidebar-content-sidebar', 'full-width-content')); |
|
145 | + //str_replace(array('content-sidebar','sidebar-content','content-sidebar-sidebar','sidebar-sidebar-content','sidebar-content-sidebar','full-width-content'),array('','','','','',''),$classes); |
|
146 | + $classes[] = $new_class; |
|
147 | + } |
|
148 | + |
|
149 | + return $classes; |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | function gd_genesis_compat_add_top_section_back() |
161 | 161 | { |
162 | 162 | |
163 | - if (is_page_geodir_home() || geodir_is_page('location')) { |
|
164 | - geodir_action_geodir_sidebar_home_top(); |
|
165 | - } elseif (geodir_is_page('listing')) { |
|
166 | - geodir_action_geodir_sidebar_listings_top(); |
|
167 | - } elseif (geodir_is_page('detail')) { |
|
168 | - geodir_action_geodir_sidebar_detail_top(); |
|
169 | - } elseif (geodir_is_page('search')) { |
|
170 | - geodir_action_geodir_sidebar_search_top(); |
|
171 | - } elseif (geodir_is_page('author')) { |
|
172 | - geodir_action_geodir_sidebar_author_top(); |
|
173 | - } |
|
163 | + if (is_page_geodir_home() || geodir_is_page('location')) { |
|
164 | + geodir_action_geodir_sidebar_home_top(); |
|
165 | + } elseif (geodir_is_page('listing')) { |
|
166 | + geodir_action_geodir_sidebar_listings_top(); |
|
167 | + } elseif (geodir_is_page('detail')) { |
|
168 | + geodir_action_geodir_sidebar_detail_top(); |
|
169 | + } elseif (geodir_is_page('search')) { |
|
170 | + geodir_action_geodir_sidebar_search_top(); |
|
171 | + } elseif (geodir_is_page('author')) { |
|
172 | + geodir_action_geodir_sidebar_author_top(); |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | 176 | } |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function geodir_replace_breadcrumb() |
185 | 185 | { |
186 | - if (is_front_page() && geodir_is_page('home') && !geodir_is_page('login')) { |
|
187 | - } else { |
|
188 | - echo '<div class="geodir-breadcrumb-bar"><div class="wrap">'; |
|
189 | - geodir_breadcrumb(); |
|
190 | - echo '</div></div>'; |
|
191 | - } |
|
186 | + if (is_front_page() && geodir_is_page('home') && !geodir_is_page('login')) { |
|
187 | + } else { |
|
188 | + echo '<div class="geodir-breadcrumb-bar"><div class="wrap">'; |
|
189 | + geodir_breadcrumb(); |
|
190 | + echo '</div></div>'; |
|
191 | + } |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | // Force Full Width on signup page |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | */ |
202 | 202 | function geodir_genesis_meta() |
203 | 203 | { |
204 | - if (geodir_is_page('login')) { |
|
205 | - add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content'); |
|
206 | - } |
|
204 | + if (geodir_is_page('login')) { |
|
205 | + add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content'); |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | add_action('geodir_add_listing_page_title', 'geodir_add_listing_page_title_genesis_before', 8); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | function geodir_add_listing_page_title_genesis_before() |
217 | 217 | { |
218 | 218 | |
219 | - echo "<div class='entry' >"; |
|
219 | + echo "<div class='entry' >"; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | function geodir_add_listing_form_genesis_after() |
231 | 231 | { |
232 | 232 | |
233 | - echo "</div>"; |
|
233 | + echo "</div>"; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -249,38 +249,38 @@ discard block |
||
249 | 249 | { |
250 | 250 | |
251 | 251 | |
252 | - $title = ''; |
|
253 | - $subtitle = ''; |
|
254 | - |
|
255 | - if (geodir_is_page('listing')) { |
|
256 | - echo '<div class="wrap gd-title-wrap">'; |
|
257 | - geodir_action_listings_title(); |
|
258 | - echo '</div>'; |
|
259 | - } |
|
260 | - |
|
261 | - if (geodir_is_page('add-listing')) { |
|
262 | - echo '<div class="wrap gd-title-wrap">'; |
|
263 | - geodir_action_add_listing_page_title(); |
|
264 | - echo '</div>'; |
|
265 | - } |
|
266 | - |
|
267 | - if (geodir_is_page('author')) { |
|
268 | - echo '<div class="wrap gd-title-wrap">'; |
|
269 | - geodir_action_author_page_title(); |
|
270 | - echo '</div>'; |
|
271 | - } |
|
272 | - |
|
273 | - if (geodir_is_page('detail') || geodir_is_page('preview')) { |
|
274 | - echo '<div class="wrap gd-title-wrap">'; |
|
275 | - echo get_the_title(); |
|
276 | - echo '</div>'; |
|
277 | - } |
|
278 | - |
|
279 | - if (geodir_is_page('search')) { |
|
280 | - echo '<div class="wrap gd-title-wrap">'; |
|
281 | - geodir_action_search_page_title(); |
|
282 | - echo '</div>'; |
|
283 | - } |
|
252 | + $title = ''; |
|
253 | + $subtitle = ''; |
|
254 | + |
|
255 | + if (geodir_is_page('listing')) { |
|
256 | + echo '<div class="wrap gd-title-wrap">'; |
|
257 | + geodir_action_listings_title(); |
|
258 | + echo '</div>'; |
|
259 | + } |
|
260 | + |
|
261 | + if (geodir_is_page('add-listing')) { |
|
262 | + echo '<div class="wrap gd-title-wrap">'; |
|
263 | + geodir_action_add_listing_page_title(); |
|
264 | + echo '</div>'; |
|
265 | + } |
|
266 | + |
|
267 | + if (geodir_is_page('author')) { |
|
268 | + echo '<div class="wrap gd-title-wrap">'; |
|
269 | + geodir_action_author_page_title(); |
|
270 | + echo '</div>'; |
|
271 | + } |
|
272 | + |
|
273 | + if (geodir_is_page('detail') || geodir_is_page('preview')) { |
|
274 | + echo '<div class="wrap gd-title-wrap">'; |
|
275 | + echo get_the_title(); |
|
276 | + echo '</div>'; |
|
277 | + } |
|
278 | + |
|
279 | + if (geodir_is_page('search')) { |
|
280 | + echo '<div class="wrap gd-title-wrap">'; |
|
281 | + geodir_action_search_page_title(); |
|
282 | + echo '</div>'; |
|
283 | + } |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | */ |
294 | 294 | function gd_genesis_listing_page_title_bar() |
295 | 295 | { |
296 | - geodir_action_listings_title(); |
|
297 | - //geodir_action_listings_description(); |
|
296 | + geodir_action_listings_title(); |
|
297 | + //geodir_action_listings_description(); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -307,19 +307,19 @@ discard block |
||
307 | 307 | */ |
308 | 308 | function gd_compat_php_genesis_geo_1280_fix() |
309 | 309 | { |
310 | - if (function_exists('geo1280_search_bar')) { |
|
311 | - remove_action('genesis_after_header', 'geo1280_search_bar', 20); |
|
312 | - add_action('genesis_after_header', 'geo1280_search_bar_fix', 4); |
|
310 | + if (function_exists('geo1280_search_bar')) { |
|
311 | + remove_action('genesis_after_header', 'geo1280_search_bar', 20); |
|
312 | + add_action('genesis_after_header', 'geo1280_search_bar_fix', 4); |
|
313 | 313 | |
314 | - // |
|
314 | + // |
|
315 | 315 | |
316 | - remove_action('genesis_after_header', 'geodir_replace_breadcrumb', 20); |
|
317 | - remove_action('genesis_before_content_sidebar_wrap', 'geodir_replace_breadcrumb', 20); |
|
318 | - add_action('geodir_wrapper_open', 'geodir_replace_breadcrumb', 105); |
|
316 | + remove_action('genesis_after_header', 'geodir_replace_breadcrumb', 20); |
|
317 | + remove_action('genesis_before_content_sidebar_wrap', 'geodir_replace_breadcrumb', 20); |
|
318 | + add_action('geodir_wrapper_open', 'geodir_replace_breadcrumb', 105); |
|
319 | 319 | |
320 | - remove_action('genesis_before_content_sidebar_wrap', 'geo1280_page_title', 10); |
|
321 | - add_action('geodir_wrapper_open', 'geo1280_page_title', 101); |
|
322 | - } |
|
320 | + remove_action('genesis_before_content_sidebar_wrap', 'geo1280_page_title', 10); |
|
321 | + add_action('geodir_wrapper_open', 'geo1280_page_title', 101); |
|
322 | + } |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | function geo1280_search_bar_fix() |
332 | 332 | { |
333 | 333 | |
334 | - echo '<div class="geo1280-placeholder"></div>'; |
|
335 | - if (is_active_sidebar('search-bar')) { |
|
336 | - genesis_widget_area('search-bar', array( |
|
337 | - 'before' => '<div class="search-bar widget-area"><div class="wrap">', |
|
338 | - 'after' => '</div></div>', |
|
339 | - )); |
|
340 | - } |
|
334 | + echo '<div class="geo1280-placeholder"></div>'; |
|
335 | + if (is_active_sidebar('search-bar')) { |
|
336 | + genesis_widget_area('search-bar', array( |
|
337 | + 'before' => '<div class="search-bar widget-area"><div class="wrap">', |
|
338 | + 'after' => '</div></div>', |
|
339 | + )); |
|
340 | + } |
|
341 | 341 | } |
@@ -12,27 +12,27 @@ |
||
12 | 12 | <div class="clearfix"> |
13 | 13 | <div id="geodir_content"> |
14 | 14 | <?php |
15 | - /** This action is documented in geodirectory-templates/geodir-home.php */ |
|
16 | - do_action('geodir_add_page_content', 'before', 'info-page'); |
|
17 | - global $information; |
|
18 | - echo '<h5 class="geodir_information">'; |
|
19 | - echo $information; |
|
20 | - echo '</h5>'; |
|
21 | - /** This action is documented in geodirectory-templates/geodir-home.php */ |
|
22 | - do_action('geodir_add_page_content', 'after', 'info-page'); |
|
23 | - ?> |
|
15 | + /** This action is documented in geodirectory-templates/geodir-home.php */ |
|
16 | + do_action('geodir_add_page_content', 'before', 'info-page'); |
|
17 | + global $information; |
|
18 | + echo '<h5 class="geodir_information">'; |
|
19 | + echo $information; |
|
20 | + echo '</h5>'; |
|
21 | + /** This action is documented in geodirectory-templates/geodir-home.php */ |
|
22 | + do_action('geodir_add_page_content', 'after', 'info-page'); |
|
23 | + ?> |
|
24 | 24 | </div> |
25 | 25 | <!-- geodir_content ends here--> |
26 | 26 | <div id="gd-sidebar-wrapper"> |
27 | 27 | <div class="geodir-sidebar-main"> |
28 | 28 | <div class="geodir-gd-sidebar"> |
29 | 29 | <?php |
30 | - /** |
|
31 | - * Calls the author sidebar. |
|
32 | - * |
|
33 | - * @since 1.6.11 |
|
34 | - */ |
|
35 | - dynamic_sidebar('geodir_author_right_sidebar'); ?> |
|
30 | + /** |
|
31 | + * Calls the author sidebar. |
|
32 | + * |
|
33 | + * @since 1.6.11 |
|
34 | + */ |
|
35 | + dynamic_sidebar('geodir_author_right_sidebar'); ?> |
|
36 | 36 | </div> |
37 | 37 | </div> |
38 | 38 | </div> |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | global $sitepress; |
246 | 246 | $default_lang = $sitepress->get_default_language(); |
247 | 247 | $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | $term_id = $cat_term->term_id; |
250 | 250 | } |
251 | 251 | if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) { |
@@ -273,8 +273,9 @@ discard block |
||
273 | 273 | |
274 | 274 | return $out; |
275 | 275 | } else { |
276 | - if ($cat_parent == 0) |
|
277 | - return _e('No category', 'geodirectory'); |
|
276 | + if ($cat_parent == 0) { |
|
277 | + return _e('No category', 'geodirectory'); |
|
278 | + } |
|
278 | 279 | } |
279 | 280 | return; |
280 | 281 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | */ |
16 | 16 | function geodir_init_map_jason() |
17 | 17 | { |
18 | - global $map_jason; |
|
19 | - $map_jason = array(); |
|
18 | + global $map_jason; |
|
19 | + $map_jason = array(); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function geodir_init_map_canvas_array() |
30 | 30 | { |
31 | - global $map_canvas_arr; |
|
32 | - $map_canvas_arr = array(); |
|
31 | + global $map_canvas_arr; |
|
32 | + $map_canvas_arr = array(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -50,56 +50,56 @@ discard block |
||
50 | 50 | */ |
51 | 51 | function create_marker_jason_of_posts($post) |
52 | 52 | { |
53 | - global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; |
|
53 | + global $wpdb, $map_jason, $add_post_in_marker_array, $geodir_cat_icons, $gd_marker_sizes; |
|
54 | 54 | |
55 | - if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') { |
|
55 | + if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') { |
|
56 | 56 | |
57 | - if(isset($map_jason[$post->ID])){return null;} |
|
57 | + if(isset($map_jason[$post->ID])){return null;} |
|
58 | 58 | |
59 | - $srcharr = array("'", "/", "-", '"', '\\'); |
|
60 | - $replarr = array("′", "⁄", "–", "“", ''); |
|
59 | + $srcharr = array("'", "/", "-", '"', '\\'); |
|
60 | + $replarr = array("′", "⁄", "–", "“", ''); |
|
61 | 61 | |
62 | 62 | |
63 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
64 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; |
|
63 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
64 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$post->default_category]) ? $geodir_cat_icons[$post->default_category] : ''; |
|
65 | 65 | |
66 | - $post_title = $post->post_title; |
|
67 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
66 | + $post_title = $post->post_title; |
|
67 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
68 | 68 | |
69 | - if (is_ssl()) { |
|
70 | - $icon = str_replace("http:","https:",$icon ); |
|
71 | - } |
|
69 | + if (is_ssl()) { |
|
70 | + $icon = str_replace("http:","https:",$icon ); |
|
71 | + } |
|
72 | 72 | |
73 | - if ($icon != '') { |
|
74 | - $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
73 | + if ($icon != '') { |
|
74 | + $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
75 | 75 | |
76 | - if (isset($gd_marker_sizes[$icon])) { |
|
77 | - $icon_size = $gd_marker_sizes[$icon]; |
|
78 | - } else { |
|
79 | - $icon_size = geodir_get_marker_size($icon); |
|
80 | - $gd_marker_sizes[$icon] = $icon_size; |
|
81 | - } |
|
82 | - } else { |
|
83 | - $icon_size = array('w' => 36, 'h' => 45); |
|
84 | - } |
|
85 | - |
|
86 | - $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}'; |
|
87 | - |
|
88 | - /** |
|
89 | - * Filter the json data when creating output for post json marker.. |
|
90 | - * |
|
91 | - * @since 1.5.7 |
|
92 | - * @param string $post_json JSON representation of the post marker info. |
|
93 | - * @param object $post The post object. |
|
94 | - */ |
|
95 | - $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post); |
|
96 | - |
|
97 | - // only assign it if it has a value |
|
98 | - if($post_map_json){ |
|
99 | - $map_jason[$post->ID] = $post_map_json; |
|
100 | - } |
|
101 | - |
|
102 | - } |
|
76 | + if (isset($gd_marker_sizes[$icon])) { |
|
77 | + $icon_size = $gd_marker_sizes[$icon]; |
|
78 | + } else { |
|
79 | + $icon_size = geodir_get_marker_size($icon); |
|
80 | + $gd_marker_sizes[$icon] = $icon_size; |
|
81 | + } |
|
82 | + } else { |
|
83 | + $icon_size = array('w' => 36, 'h' => 45); |
|
84 | + } |
|
85 | + |
|
86 | + $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}'; |
|
87 | + |
|
88 | + /** |
|
89 | + * Filter the json data when creating output for post json marker.. |
|
90 | + * |
|
91 | + * @since 1.5.7 |
|
92 | + * @param string $post_json JSON representation of the post marker info. |
|
93 | + * @param object $post The post object. |
|
94 | + */ |
|
95 | + $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post); |
|
96 | + |
|
97 | + // only assign it if it has a value |
|
98 | + if($post_map_json){ |
|
99 | + $map_jason[$post->ID] = $post_map_json; |
|
100 | + } |
|
101 | + |
|
102 | + } |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -112,67 +112,67 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function send_marker_jason_to_js() |
114 | 114 | { |
115 | - global $map_jason, $map_canvas_arr; |
|
116 | - |
|
117 | - if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) { |
|
118 | - foreach ($map_canvas_arr as $canvas => $jason) { |
|
119 | - if (is_array($map_jason) && !empty($map_jason)) { |
|
120 | - |
|
121 | - // on details page only show the main marker on the map |
|
122 | - if(geodir_is_page('detail')){ |
|
123 | - global $post; |
|
124 | - if(isset($map_jason[$post->ID])){ |
|
125 | - $map_jason = array($map_jason[$post->ID]); |
|
126 | - } |
|
127 | - } |
|
128 | - $canvas_jason = $canvas . "_jason"; |
|
129 | - $map_canvas_arr[$canvas] = array_unique($map_jason); |
|
130 | - unset($cat_content_info); |
|
131 | - $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]); |
|
132 | - $totalcount = count(array_unique($map_jason)); |
|
133 | - if (!empty($cat_content_info)) { |
|
134 | - $json_content = substr(implode(',', $cat_content_info), 1); |
|
135 | - $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016 |
|
136 | - $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
137 | - $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']'; |
|
138 | - } else { |
|
139 | - $canvas_jason = '[{"totalcount":"0"}]'; |
|
140 | - } |
|
141 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
142 | - |
|
143 | - /** |
|
144 | - * Filter the send_marker_jason_to_js() function map canvas json args. |
|
145 | - * |
|
146 | - * You can use this filter to modify map canvas json args. |
|
147 | - * |
|
148 | - * @since 1.0.0 |
|
149 | - * @package GeoDirectory |
|
150 | - * @param string $canvas Map canvas array key. |
|
151 | - * @param array $map_canvas_jason_args Map canvas args. |
|
152 | - */ |
|
153 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args); |
|
154 | - |
|
155 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args); |
|
156 | - } else { |
|
157 | - $canvas_jason = '[{"totalcount":"0"}]'; |
|
158 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
159 | - |
|
160 | - /** |
|
161 | - * Filter the send_marker_jason_to_js() function map canvas json args. |
|
162 | - * |
|
163 | - * You can use this filter to modify map canvas json args. |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - * @package GeoDirectory |
|
167 | - * @param string $canvas Map canvas array key. |
|
168 | - * @param array $map_canvas_jason_args Map canvas args. |
|
169 | - */ |
|
170 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args); |
|
171 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - } |
|
115 | + global $map_jason, $map_canvas_arr; |
|
116 | + |
|
117 | + if (is_array($map_canvas_arr) && !empty($map_canvas_arr)) { |
|
118 | + foreach ($map_canvas_arr as $canvas => $jason) { |
|
119 | + if (is_array($map_jason) && !empty($map_jason)) { |
|
120 | + |
|
121 | + // on details page only show the main marker on the map |
|
122 | + if(geodir_is_page('detail')){ |
|
123 | + global $post; |
|
124 | + if(isset($map_jason[$post->ID])){ |
|
125 | + $map_jason = array($map_jason[$post->ID]); |
|
126 | + } |
|
127 | + } |
|
128 | + $canvas_jason = $canvas . "_jason"; |
|
129 | + $map_canvas_arr[$canvas] = array_unique($map_jason); |
|
130 | + unset($cat_content_info); |
|
131 | + $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]); |
|
132 | + $totalcount = count(array_unique($map_jason)); |
|
133 | + if (!empty($cat_content_info)) { |
|
134 | + $json_content = substr(implode(',', $cat_content_info), 1); |
|
135 | + $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016 |
|
136 | + $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
137 | + $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']'; |
|
138 | + } else { |
|
139 | + $canvas_jason = '[{"totalcount":"0"}]'; |
|
140 | + } |
|
141 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
142 | + |
|
143 | + /** |
|
144 | + * Filter the send_marker_jason_to_js() function map canvas json args. |
|
145 | + * |
|
146 | + * You can use this filter to modify map canvas json args. |
|
147 | + * |
|
148 | + * @since 1.0.0 |
|
149 | + * @package GeoDirectory |
|
150 | + * @param string $canvas Map canvas array key. |
|
151 | + * @param array $map_canvas_jason_args Map canvas args. |
|
152 | + */ |
|
153 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args); |
|
154 | + |
|
155 | + wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args); |
|
156 | + } else { |
|
157 | + $canvas_jason = '[{"totalcount":"0"}]'; |
|
158 | + $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
159 | + |
|
160 | + /** |
|
161 | + * Filter the send_marker_jason_to_js() function map canvas json args. |
|
162 | + * |
|
163 | + * You can use this filter to modify map canvas json args. |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + * @package GeoDirectory |
|
167 | + * @param string $canvas Map canvas array key. |
|
168 | + * @param array $map_canvas_jason_args Map canvas args. |
|
169 | + */ |
|
170 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args); |
|
171 | + wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -195,99 +195,99 @@ discard block |
||
195 | 195 | */ |
196 | 196 | function home_map_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = true, $pading = 0, $map_canvas_name = '', $child_collapse, $is_home_map = false) |
197 | 197 | { |
198 | - global $cat_count, $geodir_cat_icons, $gd_session; |
|
198 | + global $cat_count, $geodir_cat_icons, $gd_session; |
|
199 | 199 | |
200 | - $exclude_categories = get_option('geodir_exclude_cat_on_map'); |
|
201 | - $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade'); |
|
200 | + $exclude_categories = get_option('geodir_exclude_cat_on_map'); |
|
201 | + $exclude_categories_new = get_option('geodir_exclude_cat_on_map_upgrade'); |
|
202 | 202 | |
203 | - // check if exclude categories saved before fix of categories identical names |
|
204 | - if ($exclude_categories_new) { |
|
205 | - $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; |
|
206 | - $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); |
|
207 | - } |
|
203 | + // check if exclude categories saved before fix of categories identical names |
|
204 | + if ($exclude_categories_new) { |
|
205 | + $gd_cat_taxonomy = isset($cat_taxonomy[0]) ? $cat_taxonomy[0] : ''; |
|
206 | + $exclude_categories = !empty($exclude_categories[$gd_cat_taxonomy]) && is_array($exclude_categories[$gd_cat_taxonomy]) ? array_unique($exclude_categories[$gd_cat_taxonomy]) : array(); |
|
207 | + } |
|
208 | 208 | |
209 | - $exclude_cat_str = implode(',', $exclude_categories); |
|
209 | + $exclude_cat_str = implode(',', $exclude_categories); |
|
210 | 210 | |
211 | - if ($exclude_cat_str == '') { |
|
212 | - $exclude_cat_str = '0'; |
|
213 | - } |
|
211 | + if ($exclude_cat_str == '') { |
|
212 | + $exclude_cat_str = '0'; |
|
213 | + } |
|
214 | 214 | |
215 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty)); |
|
215 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'exclude' => $exclude_cat_str, 'hide_empty ' => $hide_empty)); |
|
216 | 216 | |
217 | - if ($hide_empty) { |
|
218 | - $cat_terms = geodir_filter_empty_terms($cat_terms); |
|
219 | - } |
|
217 | + if ($hide_empty) { |
|
218 | + $cat_terms = geodir_filter_empty_terms($cat_terms); |
|
219 | + } |
|
220 | 220 | |
221 | - $main_list_class = ''; |
|
222 | - //If there are terms, start displaying |
|
223 | - if (count($cat_terms) > 0) { |
|
224 | - //Displaying as a list |
|
225 | - $p = $pading * 15; |
|
226 | - $pading++; |
|
221 | + $main_list_class = ''; |
|
222 | + //If there are terms, start displaying |
|
223 | + if (count($cat_terms) > 0) { |
|
224 | + //Displaying as a list |
|
225 | + $p = $pading * 15; |
|
226 | + $pading++; |
|
227 | 227 | |
228 | - if ($cat_parent == 0) { |
|
229 | - $list_class = 'main_list'; |
|
230 | - $display = ''; |
|
231 | - } else { |
|
232 | - $list_class = 'sub_list'; |
|
233 | - $display = !$child_collapse ? '' : 'display:none'; |
|
234 | - } |
|
228 | + if ($cat_parent == 0) { |
|
229 | + $list_class = 'main_list'; |
|
230 | + $display = ''; |
|
231 | + } else { |
|
232 | + $list_class = 'sub_list'; |
|
233 | + $display = !$child_collapse ? '' : 'display:none'; |
|
234 | + } |
|
235 | 235 | |
236 | - $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
236 | + $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
237 | 237 | |
238 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
238 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
239 | 239 | |
240 | - $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place'; |
|
241 | - if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) { |
|
242 | - $geodir_default_map_search_pt = $homemap_catlist_ptype; |
|
243 | - } |
|
244 | - $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt); |
|
240 | + $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place'; |
|
241 | + if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) { |
|
242 | + $geodir_default_map_search_pt = $homemap_catlist_ptype; |
|
243 | + } |
|
244 | + $post_type = isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : $geodir_default_map_search_pt); |
|
245 | 245 | |
246 | - foreach ($cat_terms as $cat_term): |
|
247 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; |
|
248 | - |
|
249 | - if (!in_array($cat_term->term_id, $exclude_categories)): |
|
250 | - //Secret sauce. Function calls itself to display child elements, if any |
|
251 | - $checked = 'checked="checked"'; |
|
252 | - |
|
253 | - // Untick the category by default on home map |
|
254 | - if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) { |
|
255 | - if (function_exists('icl_object_id')) { // if WPML |
|
256 | - global $sitepress; |
|
257 | - $default_lang = $sitepress->get_default_language(); |
|
258 | - $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
|
259 | - }else{ |
|
260 | - $term_id = $cat_term->term_id; |
|
261 | - } |
|
262 | - if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) { |
|
263 | - $checked = ''; |
|
264 | - } |
|
265 | - } |
|
266 | - |
|
267 | - $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
268 | - $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
269 | - $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
270 | - $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
271 | - $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
272 | - |
|
273 | - endif; |
|
274 | - |
|
275 | - |
|
276 | - // get sub category by recursion |
|
277 | - $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); |
|
278 | - |
|
279 | - $out .= '</li>'; |
|
280 | - |
|
281 | - endforeach; |
|
282 | - |
|
283 | - $out .= '</ul>'; |
|
284 | - |
|
285 | - return $out; |
|
286 | - } else { |
|
287 | - if ($cat_parent == 0) |
|
288 | - return _e('No category', 'geodirectory'); |
|
289 | - } |
|
290 | - return; |
|
246 | + foreach ($cat_terms as $cat_term): |
|
247 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$cat_term->term_id]) ? $geodir_cat_icons[$cat_term->term_id] : ''; |
|
248 | + |
|
249 | + if (!in_array($cat_term->term_id, $exclude_categories)): |
|
250 | + //Secret sauce. Function calls itself to display child elements, if any |
|
251 | + $checked = 'checked="checked"'; |
|
252 | + |
|
253 | + // Untick the category by default on home map |
|
254 | + if ($is_home_map && $geodir_home_map_untick = get_option('geodir_home_map_untick')) { |
|
255 | + if (function_exists('icl_object_id')) { // if WPML |
|
256 | + global $sitepress; |
|
257 | + $default_lang = $sitepress->get_default_language(); |
|
258 | + $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
|
259 | + }else{ |
|
260 | + $term_id = $cat_term->term_id; |
|
261 | + } |
|
262 | + if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) { |
|
263 | + $checked = ''; |
|
264 | + } |
|
265 | + } |
|
266 | + |
|
267 | + $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
268 | + $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
269 | + $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
270 | + $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
271 | + $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
272 | + |
|
273 | + endif; |
|
274 | + |
|
275 | + |
|
276 | + // get sub category by recursion |
|
277 | + $out .= home_map_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading, $map_canvas_name, $child_collapse, $is_home_map); |
|
278 | + |
|
279 | + $out .= '</li>'; |
|
280 | + |
|
281 | + endforeach; |
|
282 | + |
|
283 | + $out .= '</ul>'; |
|
284 | + |
|
285 | + return $out; |
|
286 | + } else { |
|
287 | + if ($cat_parent == 0) |
|
288 | + return _e('No category', 'geodirectory'); |
|
289 | + } |
|
290 | + return; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -299,19 +299,19 @@ discard block |
||
299 | 299 | * @return string The map API provider name. |
300 | 300 | */ |
301 | 301 | function geodir_map_name() { |
302 | - $geodir_map_name = get_option('geodir_load_map', 'google'); |
|
302 | + $geodir_map_name = get_option('geodir_load_map', 'google'); |
|
303 | 303 | |
304 | - if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) { |
|
305 | - $geodir_map_name = 'auto'; |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Filter the map JS API provider name. |
|
310 | - * |
|
311 | - * @since 1.6.1 |
|
312 | - * @param string $geodir_map_name The map API provider name. |
|
313 | - */ |
|
314 | - return apply_filters('geodir_map_name', $geodir_map_name); |
|
304 | + if (!in_array($geodir_map_name, array('none', 'auto', 'google', 'osm'))) { |
|
305 | + $geodir_map_name = 'auto'; |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Filter the map JS API provider name. |
|
310 | + * |
|
311 | + * @since 1.6.1 |
|
312 | + * @param string $geodir_map_name The map API provider name. |
|
313 | + */ |
|
314 | + return apply_filters('geodir_map_name', $geodir_map_name); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -327,48 +327,48 @@ discard block |
||
327 | 327 | * @return array The icon size. |
328 | 328 | */ |
329 | 329 | function geodir_get_marker_size($icon, $default_size = array('w' => 36, 'h' => 45)) { |
330 | - global $gd_marker_sizes; |
|
330 | + global $gd_marker_sizes; |
|
331 | 331 | |
332 | - if (empty($gd_marker_sizes)) { |
|
333 | - $gd_marker_sizes = array(); |
|
334 | - } |
|
332 | + if (empty($gd_marker_sizes)) { |
|
333 | + $gd_marker_sizes = array(); |
|
334 | + } |
|
335 | 335 | |
336 | - if (!empty($gd_marker_sizes[$icon])) { |
|
337 | - return $gd_marker_sizes[$icon]; |
|
338 | - } |
|
336 | + if (!empty($gd_marker_sizes[$icon])) { |
|
337 | + return $gd_marker_sizes[$icon]; |
|
338 | + } |
|
339 | 339 | |
340 | - if (empty($icon)) { |
|
341 | - $gd_marker_sizes[$icon] = $default_size; |
|
340 | + if (empty($icon)) { |
|
341 | + $gd_marker_sizes[$icon] = $default_size; |
|
342 | 342 | |
343 | - return $default_size; |
|
344 | - } |
|
343 | + return $default_size; |
|
344 | + } |
|
345 | 345 | |
346 | - $icon_url = $icon; |
|
346 | + $icon_url = $icon; |
|
347 | 347 | |
348 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
348 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
349 | 349 | |
350 | - if (!path_is_absolute($icon)) { |
|
351 | - $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); |
|
352 | - } |
|
350 | + if (!path_is_absolute($icon)) { |
|
351 | + $icon = str_replace($uploads['baseurl'], $uploads['basedir'], $icon); |
|
352 | + } |
|
353 | 353 | |
354 | - if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) { |
|
355 | - $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); |
|
356 | - } |
|
354 | + if (!path_is_absolute($icon) && strpos($icon, WP_CONTENT_URL) !== false) { |
|
355 | + $icon = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $icon); |
|
356 | + } |
|
357 | 357 | |
358 | - $sizes = array(); |
|
359 | - if (is_file($icon) && file_exists($icon)) { |
|
360 | - $size = getimagesize(trim($icon)); |
|
358 | + $sizes = array(); |
|
359 | + if (is_file($icon) && file_exists($icon)) { |
|
360 | + $size = getimagesize(trim($icon)); |
|
361 | 361 | |
362 | - if (!empty($size[0]) && !empty($size[1])) { |
|
363 | - $sizes = array('w' => $size[0], 'h' => $size[1]); |
|
364 | - } |
|
365 | - } |
|
362 | + if (!empty($size[0]) && !empty($size[1])) { |
|
363 | + $sizes = array('w' => $size[0], 'h' => $size[1]); |
|
364 | + } |
|
365 | + } |
|
366 | 366 | |
367 | - $sizes = !empty($sizes) ? $sizes : $default_size; |
|
367 | + $sizes = !empty($sizes) ? $sizes : $default_size; |
|
368 | 368 | |
369 | - $gd_marker_sizes[$icon_url] = $sizes; |
|
369 | + $gd_marker_sizes[$icon_url] = $sizes; |
|
370 | 370 | |
371 | - return $sizes; |
|
371 | + return $sizes; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | add_action('wp_footer', 'geodir_map_load_script', 10); |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | * @package GeoDirectory |
381 | 381 | */ |
382 | 382 | function geodir_map_load_script() { |
383 | - if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) { |
|
384 | - $plugin_url = geodir_plugin_url(); |
|
383 | + if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) { |
|
384 | + $plugin_url = geodir_plugin_url(); |
|
385 | 385 | ?> |
386 | 386 | <script type="text/javascript"> |
387 | 387 | if (!(window.google && typeof google.maps !== 'undefined')) { |
@@ -395,5 +395,5 @@ discard block |
||
395 | 395 | } |
396 | 396 | </script> |
397 | 397 | <?php |
398 | - } |
|
398 | + } |
|
399 | 399 | } |
400 | 400 | \ No newline at end of file |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | if (!empty($post) && isset($post->ID) && $post->ID > 0 && (is_main_query() || $add_post_in_marker_array) && $post->marker_json != '') { |
56 | 56 | |
57 | - if(isset($map_jason[$post->ID])){return null;} |
|
57 | + if (isset($map_jason[$post->ID])) {return null; } |
|
58 | 58 | |
59 | 59 | $srcharr = array("'", "/", "-", '"', '\\'); |
60 | 60 | $replarr = array("′", "⁄", "–", "“", ''); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $title = str_replace($srcharr, $replarr, $post_title); |
68 | 68 | |
69 | 69 | if (is_ssl()) { |
70 | - $icon = str_replace("http:","https:",$icon ); |
|
70 | + $icon = str_replace("http:", "https:", $icon); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | if ($icon != '') { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $icon_size = array('w' => 36, 'h' => 45); |
84 | 84 | } |
85 | 85 | |
86 | - $post_json = '{"id":"' . $post->ID . '","t": "' . $title . '","lt": "' . $post->post_latitude . '","ln": "' . $post->post_longitude . '","mk_id":"' . $post->ID . '_' . $post->default_category . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"}'; |
|
86 | + $post_json = '{"id":"'.$post->ID.'","t": "'.$title.'","lt": "'.$post->post_latitude.'","ln": "'.$post->post_longitude.'","mk_id":"'.$post->ID.'_'.$post->default_category.'","i":"'.$icon.'","w":"'.$icon_size['w'].'","h":"'.$icon_size['h'].'"}'; |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Filter the json data when creating output for post json marker.. |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * @param string $post_json JSON representation of the post marker info. |
93 | 93 | * @param object $post The post object. |
94 | 94 | */ |
95 | - $post_map_json = apply_filters('geodir_create_marker_jason_of_posts',$post_json, $post); |
|
95 | + $post_map_json = apply_filters('geodir_create_marker_jason_of_posts', $post_json, $post); |
|
96 | 96 | |
97 | 97 | // only assign it if it has a value |
98 | - if($post_map_json){ |
|
98 | + if ($post_map_json) { |
|
99 | 99 | $map_jason[$post->ID] = $post_map_json; |
100 | 100 | } |
101 | 101 | |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | if (is_array($map_jason) && !empty($map_jason)) { |
120 | 120 | |
121 | 121 | // on details page only show the main marker on the map |
122 | - if(geodir_is_page('detail')){ |
|
122 | + if (geodir_is_page('detail')) { |
|
123 | 123 | global $post; |
124 | - if(isset($map_jason[$post->ID])){ |
|
124 | + if (isset($map_jason[$post->ID])) { |
|
125 | 125 | $map_jason = array($map_jason[$post->ID]); |
126 | 126 | } |
127 | 127 | } |
128 | - $canvas_jason = $canvas . "_jason"; |
|
128 | + $canvas_jason = $canvas."_jason"; |
|
129 | 129 | $map_canvas_arr[$canvas] = array_unique($map_jason); |
130 | 130 | unset($cat_content_info); |
131 | 131 | $cat_content_info[] = implode(',', $map_canvas_arr[$canvas]); |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | $json_content = substr(implode(',', $cat_content_info), 1); |
135 | 135 | $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016 |
136 | 136 | $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
137 | - $canvas_jason = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']'; |
|
137 | + $canvas_jason = '[{"totalcount":"'.$totalcount.'",'.$json_content.']'; |
|
138 | 138 | } else { |
139 | 139 | $canvas_jason = '[{"totalcount":"0"}]'; |
140 | 140 | } |
141 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
141 | + $map_canvas_jason_args = array($canvas.'_jason' => $canvas_jason); |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Filter the send_marker_jason_to_js() function map canvas json args. |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | * @param string $canvas Map canvas array key. |
151 | 151 | * @param array $map_canvas_jason_args Map canvas args. |
152 | 152 | */ |
153 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args); |
|
153 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_'.$canvas, $map_canvas_jason_args); |
|
154 | 154 | |
155 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args); |
|
155 | + wp_localize_script('geodir-map-widget', $canvas.'_jason_args', $map_canvas_jason_args); |
|
156 | 156 | } else { |
157 | 157 | $canvas_jason = '[{"totalcount":"0"}]'; |
158 | - $map_canvas_jason_args = array($canvas . '_jason' => $canvas_jason); |
|
158 | + $map_canvas_jason_args = array($canvas.'_jason' => $canvas_jason); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Filter the send_marker_jason_to_js() function map canvas json args. |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param string $canvas Map canvas array key. |
168 | 168 | * @param array $map_canvas_jason_args Map canvas args. |
169 | 169 | */ |
170 | - $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_' . $canvas, $map_canvas_jason_args); |
|
171 | - wp_localize_script('geodir-map-widget', $canvas . '_jason_args', $map_canvas_jason_args); |
|
170 | + $map_canvas_jason_args = apply_filters('geodir_map_canvas_jason_'.$canvas, $map_canvas_jason_args); |
|
171 | + wp_localize_script('geodir-map-widget', $canvas.'_jason_args', $map_canvas_jason_args); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $display = !$child_collapse ? '' : 'display:none'; |
234 | 234 | } |
235 | 235 | |
236 | - $out = '<ul class="treeview ' . $list_class . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
236 | + $out = '<ul class="treeview '.$list_class.'" style="margin-left:'.$p.'px;'.$display.';">'; |
|
237 | 237 | |
238 | 238 | $geodir_cat_icons = geodir_get_term_icon(); |
239 | 239 | |
240 | - $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place'; |
|
240 | + $geodir_default_map_search_pt = (get_option('geodir_default_map_search_pt')) ? get_option('geodir_default_map_search_pt') : 'gd_place'; |
|
241 | 241 | if ($is_home_map && $homemap_catlist_ptype = $gd_session->get('homemap_catlist_ptype')) { |
242 | 242 | $geodir_default_map_search_pt = $homemap_catlist_ptype; |
243 | 243 | } |
@@ -256,19 +256,19 @@ discard block |
||
256 | 256 | global $sitepress; |
257 | 257 | $default_lang = $sitepress->get_default_language(); |
258 | 258 | $term_id = icl_object_id($cat_term->term_id, $post_type.'category', true, $default_lang); |
259 | - }else{ |
|
259 | + } else { |
|
260 | 260 | $term_id = $cat_term->term_id; |
261 | 261 | } |
262 | - if (!empty($geodir_home_map_untick) && in_array($post_type . '_' . $term_id, $geodir_home_map_untick)) { |
|
262 | + if (!empty($geodir_home_map_untick) && in_array($post_type.'_'.$term_id, $geodir_home_map_untick)) { |
|
263 | 263 | $checked = ''; |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | - $term_check = '<input type="checkbox" ' . $checked . ' id="' .$map_canvas_name.'_tick_cat_'. $cat_term->term_id . '" class="group_selector ' . $main_list_class . '"'; |
|
268 | - $term_check .= ' name="' . $map_canvas_name . '_cat[]" '; |
|
269 | - $term_check .= ' title="' . esc_attr(geodir_utf8_ucfirst($cat_term->name)) . '" value="' . $cat_term->term_id . '" onclick="javascript:build_map_ajax_search_param(\'' . $map_canvas_name . '\',false, this)">'; |
|
270 | - $term_img = '<img height="15" width="15" alt="' . $cat_term->taxonomy . '" src="' . $icon . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '"/>'; |
|
271 | - $out .= '<li>' . $term_check . '<label for="' . $map_canvas_name.'_tick_cat_'. $cat_term->term_id . '">' . $term_img . geodir_utf8_ucfirst($cat_term->name) . '</label><i class="fa fa-long-arrow-down"></i>'; |
|
267 | + $term_check = '<input type="checkbox" '.$checked.' id="'.$map_canvas_name.'_tick_cat_'.$cat_term->term_id.'" class="group_selector '.$main_list_class.'"'; |
|
268 | + $term_check .= ' name="'.$map_canvas_name.'_cat[]" '; |
|
269 | + $term_check .= ' title="'.esc_attr(geodir_utf8_ucfirst($cat_term->name)).'" value="'.$cat_term->term_id.'" onclick="javascript:build_map_ajax_search_param(\''.$map_canvas_name.'\',false, this)">'; |
|
270 | + $term_img = '<img height="15" width="15" alt="'.$cat_term->taxonomy.'" src="'.$icon.'" title="'.geodir_utf8_ucfirst($cat_term->name).'"/>'; |
|
271 | + $out .= '<li>'.$term_check.'<label for="'.$map_canvas_name.'_tick_cat_'.$cat_term->term_id.'">'.$term_img.geodir_utf8_ucfirst($cat_term->name).'</label><i class="fa fa-long-arrow-down"></i>'; |
|
272 | 272 | |
273 | 273 | endif; |
274 | 274 | |
@@ -380,19 +380,19 @@ discard block |
||
380 | 380 | * @package GeoDirectory |
381 | 381 | */ |
382 | 382 | function geodir_map_load_script() { |
383 | - if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is( 'geodirectory-googlemap-script', 'done')) { |
|
383 | + if (in_array(geodir_map_name(), array('auto', 'google')) && wp_script_is('geodirectory-googlemap-script', 'done')) { |
|
384 | 384 | $plugin_url = geodir_plugin_url(); |
385 | 385 | ?> |
386 | 386 | <script type="text/javascript"> |
387 | 387 | if (!(window.google && typeof google.maps !== 'undefined')) { |
388 | - var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-style-css");css.setAttribute("href","<?php echo $plugin_url;?>/geodirectory-assets/leaflet/leaflet.css?ver=<?php echo GEODIRECTORY_VERSION;?>"); |
|
388 | + var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-style-css");css.setAttribute("href","<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/leaflet.css?ver=<?php echo GEODIRECTORY_VERSION; ?>"); |
|
389 | 389 | document.getElementsByTagName("head")[0].appendChild(css); |
390 | - var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-routing-style");css.setAttribute("href","<?php echo $plugin_url;?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css?ver=<?php echo GEODIRECTORY_VERSION;?>"); |
|
390 | + var css = document.createElement("link");css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");css.setAttribute("media","all");css.setAttribute("id","geodirectory-leaflet-routing-style");css.setAttribute("href","<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css?ver=<?php echo GEODIRECTORY_VERSION; ?>"); |
|
391 | 391 | document.getElementsByTagName("head")[0].appendChild(css); |
392 | - document.write('<' + 'script id="geodirectory-leaflet-script" src="<?php echo $plugin_url;?>/geodirectory-assets/leaflet/leaflet.min.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>'); |
|
393 | - document.write('<' + 'script id="geodirectory-leaflet-geo-script" src="<?php echo $plugin_url;?>/geodirectory-assets/leaflet/osm.geocode.min.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>'); |
|
394 | - document.write('<' + 'script id="geodirectory-leaflet-routing-script" src="<?php echo $plugin_url;?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>'); |
|
395 | - document.write('<' + 'script id="geodirectory-o-overlappingmarker-script" src="<?php echo $plugin_url;?>/geodirectory-assets/jawj/oms-leaflet.min.js?ver=<?php echo GEODIRECTORY_VERSION;?>" type="text/javascript"><' + '/script>'); |
|
392 | + document.write('<' + 'script id="geodirectory-leaflet-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/leaflet.min.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>'); |
|
393 | + document.write('<' + 'script id="geodirectory-leaflet-geo-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/osm.geocode.min.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>'); |
|
394 | + document.write('<' + 'script id="geodirectory-leaflet-routing-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>'); |
|
395 | + document.write('<' + 'script id="geodirectory-o-overlappingmarker-script" src="<?php echo $plugin_url; ?>/geodirectory-assets/jawj/oms-leaflet.min.js?ver=<?php echo GEODIRECTORY_VERSION; ?>" type="text/javascript"><' + '/script>'); |
|
396 | 396 | } |
397 | 397 | </script> |
398 | 398 | <?php |
@@ -42,10 +42,11 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - if (geodir_dummy_folder_exists()) |
|
46 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
47 | - else |
|
48 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
45 | + if (geodir_dummy_folder_exists()) { |
|
46 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
47 | + } else { |
|
48 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
49 | + } |
|
49 | 50 | |
50 | 51 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
51 | 52 | |
@@ -86,10 +87,11 @@ discard block |
||
86 | 87 | if (!term_exists($catname, $post_type.'category')) { |
87 | 88 | $last_catid = wp_insert_term($catname, $post_type.'category'); |
88 | 89 | |
89 | - if (geodir_dummy_folder_exists()) |
|
90 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
91 | - else |
|
92 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
90 | + if (geodir_dummy_folder_exists()) { |
|
91 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
92 | + } else { |
|
93 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
94 | + } |
|
93 | 95 | |
94 | 96 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
95 | 97 | |
@@ -218,7 +220,7 @@ discard block |
||
218 | 220 | * @package GeoDirectory |
219 | 221 | */ |
220 | 222 | include_once( 'dummy-data/standard_places.php' ); |
221 | - }elseif($key=='property_sale'){ |
|
223 | + } elseif($key=='property_sale'){ |
|
222 | 224 | /** |
223 | 225 | * Contains dummy property for sale post content. |
224 | 226 | * |
@@ -226,7 +228,7 @@ discard block |
||
226 | 228 | * @package GeoDirectory |
227 | 229 | */ |
228 | 230 | include_once( 'dummy-data/property_sale.php' ); |
229 | - }elseif($key=='property_rent'){ |
|
231 | + } elseif($key=='property_rent'){ |
|
230 | 232 | /** |
231 | 233 | * Contains dummy property for sale post content. |
232 | 234 | * |
@@ -330,7 +332,7 @@ discard block |
||
330 | 332 | |
331 | 333 | if($post_counts > 0){ |
332 | 334 | echo '<td><input type="button" value="'.__('Remove data','geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
333 | - }else{ |
|
335 | + } else{ |
|
334 | 336 | echo '<td><input type="button" value="'.__('Insert data','geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
335 | 337 | } |
336 | 338 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @global object $wpdb WordPress Database object. |
19 | 19 | * @global string $dummy_image_path The dummy image path. |
20 | 20 | */ |
21 | -function geodir_dummy_data_taxonomies($post_type,$category_array) { |
|
21 | +function geodir_dummy_data_taxonomies($post_type, $category_array) { |
|
22 | 22 | global $wpdb, $dummy_image_path; |
23 | 23 | |
24 | 24 | |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | |
44 | 44 | |
45 | 45 | if (geodir_dummy_folder_exists()) |
46 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
46 | + $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon"; |
|
47 | 47 | else |
48 | 48 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
49 | 49 | |
50 | 50 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
51 | 51 | |
52 | 52 | $catname = str_replace(' ', '_', $catname); |
53 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png"); |
|
53 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png"); |
|
54 | 54 | |
55 | 55 | if (empty($uploaded['error'])) { |
56 | 56 | $new_path = $uploaded['file']; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $wp_filetype = wp_check_filetype(basename($new_path), null); |
61 | 61 | |
62 | 62 | $attachment = array( |
63 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
63 | + 'guid' => $uploads['baseurl'].'/'.basename($new_path), |
|
64 | 64 | 'post_mime_type' => $wp_filetype['type'], |
65 | 65 | 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)), |
66 | 66 | 'post_content' => '', |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | // you must first include the image.php file |
72 | 72 | // for the function wp_generate_attachment_metadata() to work |
73 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
73 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
74 | 74 | $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
75 | 75 | wp_update_attachment_metadata($attach_id, $attach_data); |
76 | 76 | |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $last_catid = wp_insert_term($catname, $post_type.'category'); |
88 | 88 | |
89 | 89 | if (geodir_dummy_folder_exists()) |
90 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
90 | + $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon"; |
|
91 | 91 | else |
92 | 92 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
93 | 93 | |
94 | 94 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
95 | 95 | |
96 | 96 | $catname = str_replace(' ', '_', $catname); |
97 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png"); |
|
97 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png"); |
|
98 | 98 | |
99 | 99 | if (empty($uploaded['error'])) { |
100 | 100 | $new_path = $uploaded['file']; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $wp_filetype = wp_check_filetype(basename($new_path), null); |
105 | 105 | |
106 | 106 | $attachment = array( |
107 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
107 | + 'guid' => $uploads['baseurl'].'/'.basename($new_path), |
|
108 | 108 | 'post_mime_type' => $wp_filetype['type'], |
109 | 109 | 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)), |
110 | 110 | 'post_content' => '', |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | // you must first include the image.php file |
118 | 118 | // for the function wp_generate_attachment_metadata() to work |
119 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
119 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
120 | 120 | $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
121 | 121 | wp_update_attachment_metadata($attach_id, $attach_data); |
122 | 122 | |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | -function geodir_dummy_data_types(){ |
|
134 | - $data = array( |
|
133 | +function geodir_dummy_data_types() { |
|
134 | + $data = array( |
|
135 | 135 | 'standard_places' => array( |
136 | - 'name'=>__('Default','geodirectory'), |
|
136 | + 'name'=>__('Default', 'geodirectory'), |
|
137 | 137 | 'count'=> 30 |
138 | 138 | ), |
139 | 139 | 'property_sale' => array( |
140 | - 'name'=>__('Property for sale','geodirectory'), |
|
140 | + 'name'=>__('Property for sale', 'geodirectory'), |
|
141 | 141 | 'count'=> 10 |
142 | 142 | ), |
143 | 143 | 'property_rent' => array( |
144 | - 'name'=>__('Property for rent','geodirectory'), |
|
144 | + 'name'=>__('Property for rent', 'geodirectory'), |
|
145 | 145 | 'count'=> 10 |
146 | 146 | ) |
147 | 147 | ); |
148 | 148 | |
149 | - return apply_filters('geodir_dummy_data_types',$data ); |
|
149 | + return apply_filters('geodir_dummy_data_types', $data); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * @global object $wpdb WordPress Database object. |
175 | 175 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
176 | 176 | */ |
177 | -function geodir_delete_dummy_posts($post_type,$data_type) |
|
177 | +function geodir_delete_dummy_posts($post_type, $data_type) |
|
178 | 178 | { |
179 | 179 | global $wpdb, $plugin_prefix; |
180 | 180 | |
181 | 181 | |
182 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . $post_type."_detail WHERE post_dummy='1'"); |
|
182 | + $post_ids = $wpdb->get_results("SELECT post_id FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'"); |
|
183 | 183 | |
184 | 184 | |
185 | 185 | foreach ($post_ids as $post_ids_obj) { |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | //double check posts are deleted |
190 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . $post_type. "_detail WHERE post_dummy='1'"); |
|
190 | + $wpdb->get_results("DELETE FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'"); |
|
191 | 191 | |
192 | - update_option($post_type.'_dummy_data_type',''); |
|
192 | + update_option($post_type.'_dummy_data_type', ''); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @global object $wpdb WordPress Database object. |
201 | 201 | * @global object $current_user Current user object. |
202 | 202 | */ |
203 | -function geodir_insert_dummy_posts($post_type,$data_type,$item_index) |
|
203 | +function geodir_insert_dummy_posts($post_type, $data_type, $item_index) |
|
204 | 204 | { |
205 | 205 | |
206 | 206 | ini_set('max_execution_time', 999999); //300 seconds = 5 minutes |
@@ -209,45 +209,45 @@ discard block |
||
209 | 209 | $total_count = 0; |
210 | 210 | global $dummy_post_index; |
211 | 211 | $dummy_post_index = $item_index; |
212 | - foreach( $data_types as $key=>$val){ |
|
213 | - if($key==$data_type){ |
|
212 | + foreach ($data_types as $key=>$val) { |
|
213 | + if ($key == $data_type) { |
|
214 | 214 | $total_count = $val['count']; |
215 | - if($key=='standard_places'){ |
|
215 | + if ($key == 'standard_places') { |
|
216 | 216 | /** |
217 | 217 | * Contains dummy post content. |
218 | 218 | * |
219 | 219 | * @since 1.0.0 |
220 | 220 | * @package GeoDirectory |
221 | 221 | */ |
222 | - include_once( 'dummy-data/standard_places.php' ); |
|
223 | - }elseif($key=='property_sale'){ |
|
222 | + include_once('dummy-data/standard_places.php'); |
|
223 | + }elseif ($key == 'property_sale') { |
|
224 | 224 | /** |
225 | 225 | * Contains dummy property for sale post content. |
226 | 226 | * |
227 | 227 | * @since 1.6.11 |
228 | 228 | * @package GeoDirectory |
229 | 229 | */ |
230 | - include_once( 'dummy-data/property_sale.php' ); |
|
231 | - }elseif($key=='property_rent'){ |
|
230 | + include_once('dummy-data/property_sale.php'); |
|
231 | + }elseif ($key == 'property_rent') { |
|
232 | 232 | /** |
233 | 233 | * Contains dummy property for sale post content. |
234 | 234 | * |
235 | 235 | * @since 1.6.11 |
236 | 236 | * @package GeoDirectory |
237 | 237 | */ |
238 | - include_once( 'dummy-data/property_rent.php' ); |
|
238 | + include_once('dummy-data/property_rent.php'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
242 | 242 | |
243 | - do_action('geodir_insert_dummy_data_loop',$post_type,$data_type,$item_index); |
|
243 | + do_action('geodir_insert_dummy_data_loop', $post_type, $data_type, $item_index); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
247 | 247 | |
248 | 248 | // delete image cache on last entry |
249 | - if($total_count == $item_index){ |
|
250 | - delete_transient( 'cached_dummy_images' ); |
|
249 | + if ($total_count == $item_index) { |
|
250 | + delete_transient('cached_dummy_images'); |
|
251 | 251 | flush_rewrite_rules(); |
252 | 252 | } |
253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | |
258 | -if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) { |
|
258 | +if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined('GD_TESTING_MODE'))) { |
|
259 | 259 | /** |
260 | 260 | * GeoDirectory dummy data installation. |
261 | 261 | * |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | global $wpdb, $plugin_prefix; |
272 | 272 | |
273 | 273 | if (!geodir_is_default_location_set()) { |
274 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
274 | + echo '<div class="updated fade"><p><strong>'.sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=default_location_settings').'\'>', '</a>').'</strong></p></div>'; |
|
275 | 275 | } else { |
276 | 276 | |
277 | 277 | ?> |
278 | - <span class="gd-dummy-hint"><small><?php _e('*Hint*: Installing our Advanced Search addon FIRST will add extra search fields to non-default data types.','geodirectory');?></small></span> |
|
278 | + <span class="gd-dummy-hint"><small><?php _e('*Hint*: Installing our Advanced Search addon FIRST will add extra search fields to non-default data types.', 'geodirectory'); ?></small></span> |
|
279 | 279 | <table class="form-table gd-dummy-table"> |
280 | 280 | <tbody> |
281 | 281 | <tr> |
282 | - <td><strong><?php _e('CPT','geodirectory');?></strong></td> |
|
283 | - <td><strong><?php _e('Data Type','geodirectory');?></strong></td> |
|
284 | - <td><strong><?php _e('Action','geodirectory');?></strong></td> |
|
282 | + <td><strong><?php _e('CPT', 'geodirectory'); ?></strong></td> |
|
283 | + <td><strong><?php _e('Data Type', 'geodirectory'); ?></strong></td> |
|
284 | + <td><strong><?php _e('Action', 'geodirectory'); ?></strong></td> |
|
285 | 285 | </tr> |
286 | 286 | |
287 | 287 | <?php |
@@ -292,18 +292,18 @@ discard block |
||
292 | 292 | |
293 | 293 | $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename'); |
294 | 294 | |
295 | - foreach($cpts as $post_type=>$cpt){ |
|
295 | + foreach ($cpts as $post_type=>$cpt) { |
|
296 | 296 | |
297 | - $data_types_for = apply_filters('geodir_dummy_date_types_for',$data_types,$post_type); |
|
297 | + $data_types_for = apply_filters('geodir_dummy_date_types_for', $data_types, $post_type); |
|
298 | 298 | |
299 | 299 | |
300 | 300 | $set_dt = get_option($post_type.'_dummy_data_type'); |
301 | 301 | |
302 | 302 | $count = 30; |
303 | 303 | |
304 | - geodir_add_column_if_not_exist($plugin_prefix . $post_type. "_detail", 'post_dummy', "enum( '1', '0' ) NULL DEFAULT '0'"); |
|
304 | + geodir_add_column_if_not_exist($plugin_prefix.$post_type."_detail", 'post_dummy', "enum( '1', '0' ) NULL DEFAULT '0'"); |
|
305 | 305 | |
306 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'"); |
|
306 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'"); |
|
307 | 307 | |
308 | 308 | echo "<tr>"; |
309 | 309 | echo "<td><strong>".$cpt['labels']['name']."</strong></td>"; |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | echo "<td>"; |
314 | 314 | echo "<select id='".$post_type."_data_type' onchange='geodir_dummy_set_count(this,\"$post_type\");' $select_disabled>"; |
315 | 315 | |
316 | - foreach($data_types_for as $key=>$val){ |
|
317 | - $selected = ($key==$set_dt) ? "selected='selected'" : ''; |
|
318 | - if($selected || count($data_types_for)==1){$count = $val['count'];} |
|
316 | + foreach ($data_types_for as $key=>$val) { |
|
317 | + $selected = ($key == $set_dt) ? "selected='selected'" : ''; |
|
318 | + if ($selected || count($data_types_for) == 1) {$count = $val['count']; } |
|
319 | 319 | echo "<option $selected value='$key' data-count='".$val['count']."'>".$val['name']."</option>"; |
320 | 320 | } |
321 | 321 | echo "</select>"; |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | $select_display = $post_counts > 0 ? 'display:none;' : ''; |
324 | 324 | echo "<select id='".$post_type."_data_type_count' style='$select_display' >"; |
325 | 325 | $x = 1; |
326 | - while($x <= $count){ |
|
327 | - $selected = ($x==$count) ? "selected='selected'" : ''; |
|
326 | + while ($x <= $count) { |
|
327 | + $selected = ($x == $count) ? "selected='selected'" : ''; |
|
328 | 328 | echo "<option $selected value='$x'>".$x."</option>"; |
329 | 329 | $x++; |
330 | 330 | } |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | |
336 | 336 | |
337 | 337 | |
338 | - if($post_counts > 0){ |
|
339 | - echo '<td><input type="button" value="'.__('Remove data','geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
|
340 | - }else{ |
|
341 | - echo '<td><input type="button" value="'.__('Insert data','geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
|
338 | + if ($post_counts > 0) { |
|
339 | + echo '<td><input type="button" value="'.__('Remove data', 'geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\''.$nonce.'\',\''.$post_type.'\'); return false;" ></td>'; |
|
340 | + } else { |
|
341 | + echo '<td><input type="button" value="'.__('Insert data', 'geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\''.$nonce.'\',\''.$post_type.'\'); return false;" ></td>'; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | echo "</tr>"; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | |
375 | 375 | } |
376 | 376 | |
377 | - var CITY_ADDRESS = '<?php echo addslashes( $city . ',' . $region . ',' . $country );?>'; |
|
377 | + var CITY_ADDRESS = '<?php echo addslashes($city.','.$region.','.$country); ?>'; |
|
378 | 378 | var bound_lat_lng; |
379 | 379 | var latlng = ['<?php echo $city_latitude; ?>', <?php echo $city_longitude; ?>]; |
380 | 380 | var lat = <?php echo $city_latitude; ?>; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | return x.replace(" ", ''); |
408 | 408 | }); // remove spaces from lat/lon |
409 | 409 | } else { |
410 | - alert("<?php _e( 'Geocode was not successful for the following reason:', 'geodirectory' );?> " + status); |
|
410 | + alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status); |
|
411 | 411 | } |
412 | 412 | }); |
413 | 413 | } else if (window.gdMaps == 'osm') { |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | var dummy_post_index = 1; |
432 | 432 | |
433 | 433 | function gdRemoveDummyData(obj, nonce, posttype){ |
434 | - if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) { |
|
434 | + if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) { |
|
435 | 435 | jQuery(obj).prop('disabled', true); |
436 | 436 | jQuery('.gd-dummy-data-results-' + posttype).remove(); |
437 | 437 | jQuery('<tr class="gd-dummy-data-results gd-dummy-data-results-' + posttype + '" >'+ |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | |
447 | 447 | jQuery('.gd_progressbar_'+posttype).progressbar({value: 0}); |
448 | 448 | |
449 | - gd_progressbar('.gd_progressbar_container_'+posttype, 0, '<i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Removing data...', 'geodirlocation'));?>'); |
|
449 | + gd_progressbar('.gd_progressbar_container_'+posttype, 0, '<i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Removing data...', 'geodirlocation')); ?>'); |
|
450 | 450 | |
451 | 451 | |
452 | 452 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=geodir_dummy_delete&posttype=' + posttype + '&_wpnonce=' + nonce, |
453 | 453 | function (data) { |
454 | - gd_progressbar('.gd_progressbar_container_'+posttype, 100, '<i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirlocation'));?>'); |
|
454 | + gd_progressbar('.gd_progressbar_container_'+posttype, 100, '<i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirlocation')); ?>'); |
|
455 | 455 | jQuery(obj).removeClass('gd-remove-data'); |
456 | - jQuery(obj).val('<?php _e('Insert data','geodirectory');?>'); |
|
456 | + jQuery(obj).val('<?php _e('Insert data', 'geodirectory'); ?>'); |
|
457 | 457 | jQuery(obj).prop('disabled', false); |
458 | 458 | jQuery('#'+posttype+'_data_type_count').show(); |
459 | 459 | jQuery('#'+posttype+'_data_type').prop('disabled', false); |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | jQuery('.gd_progressbar_'+posttype).progressbar({value: 0}); |
498 | 498 | |
499 | - gd_progressbar('.gd_progressbar_container_'+posttype, 0, '0% (0 / ' + dateTypeCount + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Creating categories and custom fields...', 'geodirlocation'));?>'); |
|
499 | + gd_progressbar('.gd_progressbar_container_'+posttype, 0, '0% (0 / ' + dateTypeCount + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Creating categories and custom fields...', 'geodirlocation')); ?>'); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | if (!(typeof bound_lat_lng == 'object' && bound_lat_lng.length == 4)) { |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | percentage = percentage > 100 ? 100 : percentage; |
517 | 517 | |
518 | 518 | |
519 | - gd_progressbar('.gd_progressbar_container_'+posttype, percentage, percentage + '% ('+insertedCount+' / ' + dateTypeCount + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Inserting data...', 'geodirlocation'));?>'); |
|
519 | + gd_progressbar('.gd_progressbar_container_'+posttype, percentage, percentage + '% ('+insertedCount+' / ' + dateTypeCount + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Inserting data...', 'geodirlocation')); ?>'); |
|
520 | 520 | |
521 | 521 | gdInstallDummyData(obj, nonce, posttype,insertedCount); |
522 | 522 | } |
523 | 523 | else { |
524 | 524 | percentage = 100; |
525 | - gd_progressbar('.gd_progressbar_container_'+posttype, percentage, percentage + '% ('+insertedCount+' / ' + dateTypeCount + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirlocation'));?>'); |
|
525 | + gd_progressbar('.gd_progressbar_container_'+posttype, percentage, percentage + '% ('+insertedCount+' / ' + dateTypeCount + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirlocation')); ?>'); |
|
526 | 526 | jQuery(obj).addClass('gd-remove-data'); |
527 | - jQuery(obj).val('<?php _e('Remove data','geodirectory');?>'); |
|
527 | + jQuery(obj).val('<?php _e('Remove data', 'geodirectory'); ?>'); |
|
528 | 528 | jQuery(obj).prop('disabled', false); |
529 | 529 | |
530 | 530 | } |
@@ -19,151 +19,151 @@ discard block |
||
19 | 19 | * @global string $dummy_image_path The dummy image path. |
20 | 20 | */ |
21 | 21 | function geodir_dummy_data_taxonomies($post_type,$category_array) { |
22 | - global $wpdb, $dummy_image_path; |
|
22 | + global $wpdb, $dummy_image_path; |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - $last_catid = ''; |
|
26 | + $last_catid = ''; |
|
27 | 27 | |
28 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
28 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
29 | 29 | |
30 | - for ($i = 0; $i < count($category_array); $i++) { |
|
31 | - $parent_catid = 0; |
|
32 | - if (is_array($category_array[$i])) { |
|
33 | - $cat_name_arr = $category_array[$i]; |
|
34 | - for ($j = 0; $j < count($cat_name_arr); $j++) { |
|
35 | - $catname = $cat_name_arr[$j]; |
|
30 | + for ($i = 0; $i < count($category_array); $i++) { |
|
31 | + $parent_catid = 0; |
|
32 | + if (is_array($category_array[$i])) { |
|
33 | + $cat_name_arr = $category_array[$i]; |
|
34 | + for ($j = 0; $j < count($cat_name_arr); $j++) { |
|
35 | + $catname = $cat_name_arr[$j]; |
|
36 | 36 | |
37 | - if (!term_exists($catname, $post_type.'category')) { |
|
38 | - $last_catid = wp_insert_term($catname, $post_type.'category', $args = array('parent' => $parent_catid)); |
|
37 | + if (!term_exists($catname, $post_type.'category')) { |
|
38 | + $last_catid = wp_insert_term($catname, $post_type.'category', $args = array('parent' => $parent_catid)); |
|
39 | 39 | |
40 | - if ($j == 0) { |
|
41 | - $parent_catid = $last_catid; |
|
42 | - } |
|
40 | + if ($j == 0) { |
|
41 | + $parent_catid = $last_catid; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - if (geodir_dummy_folder_exists()) |
|
46 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
47 | - else |
|
48 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
45 | + if (geodir_dummy_folder_exists()) |
|
46 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
47 | + else |
|
48 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
49 | 49 | |
50 | - $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
|
50 | + $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
|
51 | 51 | |
52 | - $catname = str_replace(' ', '_', $catname); |
|
53 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png"); |
|
52 | + $catname = str_replace(' ', '_', $catname); |
|
53 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png"); |
|
54 | 54 | |
55 | - if (empty($uploaded['error'])) { |
|
56 | - $new_path = $uploaded['file']; |
|
57 | - $new_url = $uploaded['url']; |
|
58 | - } |
|
55 | + if (empty($uploaded['error'])) { |
|
56 | + $new_path = $uploaded['file']; |
|
57 | + $new_url = $uploaded['url']; |
|
58 | + } |
|
59 | 59 | |
60 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
61 | - |
|
62 | - $attachment = array( |
|
63 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
64 | - 'post_mime_type' => $wp_filetype['type'], |
|
65 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)), |
|
66 | - 'post_content' => '', |
|
67 | - 'post_status' => 'inherit' |
|
68 | - ); |
|
69 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
70 | - |
|
71 | - // you must first include the image.php file |
|
72 | - // for the function wp_generate_attachment_metadata() to work |
|
73 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
74 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
75 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
76 | - |
|
77 | - if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) { |
|
78 | - geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), $post_type); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
60 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
82 | 61 | |
83 | - } else { |
|
84 | - $catname = $category_array[$i]; |
|
62 | + $attachment = array( |
|
63 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
64 | + 'post_mime_type' => $wp_filetype['type'], |
|
65 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)), |
|
66 | + 'post_content' => '', |
|
67 | + 'post_status' => 'inherit' |
|
68 | + ); |
|
69 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
85 | 70 | |
86 | - if (!term_exists($catname, $post_type.'category')) { |
|
87 | - $last_catid = wp_insert_term($catname, $post_type.'category'); |
|
71 | + // you must first include the image.php file |
|
72 | + // for the function wp_generate_attachment_metadata() to work |
|
73 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
74 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
75 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
88 | 76 | |
89 | - if (geodir_dummy_folder_exists()) |
|
90 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
91 | - else |
|
92 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
77 | + if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) { |
|
78 | + geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), $post_type); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
93 | 82 | |
94 | - $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
|
83 | + } else { |
|
84 | + $catname = $category_array[$i]; |
|
95 | 85 | |
96 | - $catname = str_replace(' ', '_', $catname); |
|
97 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png"); |
|
86 | + if (!term_exists($catname, $post_type.'category')) { |
|
87 | + $last_catid = wp_insert_term($catname, $post_type.'category'); |
|
98 | 88 | |
99 | - if (empty($uploaded['error'])) { |
|
100 | - $new_path = $uploaded['file']; |
|
101 | - $new_url = $uploaded['url']; |
|
102 | - } |
|
89 | + if (geodir_dummy_folder_exists()) |
|
90 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
91 | + else |
|
92 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
103 | 93 | |
104 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
94 | + $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url); |
|
105 | 95 | |
106 | - $attachment = array( |
|
107 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
108 | - 'post_mime_type' => $wp_filetype['type'], |
|
109 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)), |
|
110 | - 'post_content' => '', |
|
111 | - 'post_status' => 'inherit' |
|
112 | - ); |
|
96 | + $catname = str_replace(' ', '_', $catname); |
|
97 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png"); |
|
113 | 98 | |
114 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
99 | + if (empty($uploaded['error'])) { |
|
100 | + $new_path = $uploaded['file']; |
|
101 | + $new_url = $uploaded['url']; |
|
102 | + } |
|
115 | 103 | |
104 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
116 | 105 | |
117 | - // you must first include the image.php file |
|
118 | - // for the function wp_generate_attachment_metadata() to work |
|
119 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
120 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
121 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
106 | + $attachment = array( |
|
107 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
108 | + 'post_mime_type' => $wp_filetype['type'], |
|
109 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)), |
|
110 | + 'post_content' => '', |
|
111 | + 'post_status' => 'inherit' |
|
112 | + ); |
|
113 | + |
|
114 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
122 | 115 | |
123 | - if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) { |
|
124 | - geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), $post_type); |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
128 | 116 | |
129 | - } |
|
117 | + // you must first include the image.php file |
|
118 | + // for the function wp_generate_attachment_metadata() to work |
|
119 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
120 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
121 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
122 | + |
|
123 | + if (!geodir_get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, $post_type)) { |
|
124 | + geodir_update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), $post_type); |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + } |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | 133 | function geodir_dummy_data_types(){ |
134 | - $data = array( |
|
135 | - 'standard_places' => array( |
|
136 | - 'name'=>__('Default','geodirectory'), |
|
137 | - 'count'=> 30 |
|
138 | - ), |
|
139 | - 'property_sale' => array( |
|
140 | - 'name'=>__('Property for sale','geodirectory'), |
|
141 | - 'count'=> 10 |
|
142 | - ), |
|
143 | - 'property_rent' => array( |
|
144 | - 'name'=>__('Property for rent','geodirectory'), |
|
145 | - 'count'=> 10 |
|
146 | - ) |
|
147 | - ); |
|
148 | - |
|
149 | - return apply_filters('geodir_dummy_data_types',$data ); |
|
134 | + $data = array( |
|
135 | + 'standard_places' => array( |
|
136 | + 'name'=>__('Default','geodirectory'), |
|
137 | + 'count'=> 30 |
|
138 | + ), |
|
139 | + 'property_sale' => array( |
|
140 | + 'name'=>__('Property for sale','geodirectory'), |
|
141 | + 'count'=> 10 |
|
142 | + ), |
|
143 | + 'property_rent' => array( |
|
144 | + 'name'=>__('Property for rent','geodirectory'), |
|
145 | + 'count'=> 10 |
|
146 | + ) |
|
147 | + ); |
|
148 | + |
|
149 | + return apply_filters('geodir_dummy_data_types',$data ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | 153 | function geodir_create_dummy_fields($fields) |
154 | 154 | { |
155 | 155 | |
156 | - /** |
|
157 | - * Filter the array of default custom fields DB table data. |
|
158 | - * |
|
159 | - * @since 1.0.0 |
|
160 | - * @param string $fields The default custom fields as an array. |
|
161 | - */ |
|
162 | - $fields = apply_filters('geodir_before_dummy_custom_fields_saved', $fields); |
|
163 | - foreach ($fields as $field_index => $field) { |
|
164 | - geodir_custom_field_save($field); |
|
165 | - |
|
166 | - } |
|
156 | + /** |
|
157 | + * Filter the array of default custom fields DB table data. |
|
158 | + * |
|
159 | + * @since 1.0.0 |
|
160 | + * @param string $fields The default custom fields as an array. |
|
161 | + */ |
|
162 | + $fields = apply_filters('geodir_before_dummy_custom_fields_saved', $fields); |
|
163 | + foreach ($fields as $field_index => $field) { |
|
164 | + geodir_custom_field_save($field); |
|
165 | + |
|
166 | + } |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | */ |
177 | 177 | function geodir_delete_dummy_posts($post_type,$data_type) |
178 | 178 | { |
179 | - global $wpdb, $plugin_prefix; |
|
179 | + global $wpdb, $plugin_prefix; |
|
180 | 180 | |
181 | 181 | |
182 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . $post_type."_detail WHERE post_dummy='1'"); |
|
182 | + $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . $post_type."_detail WHERE post_dummy='1'"); |
|
183 | 183 | |
184 | 184 | |
185 | - foreach ($post_ids as $post_ids_obj) { |
|
186 | - wp_delete_post($post_ids_obj->post_id); |
|
187 | - } |
|
185 | + foreach ($post_ids as $post_ids_obj) { |
|
186 | + wp_delete_post($post_ids_obj->post_id); |
|
187 | + } |
|
188 | 188 | |
189 | - //double check posts are deleted |
|
190 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . $post_type. "_detail WHERE post_dummy='1'"); |
|
189 | + //double check posts are deleted |
|
190 | + $wpdb->get_results("DELETE FROM " . $plugin_prefix . $post_type. "_detail WHERE post_dummy='1'"); |
|
191 | 191 | |
192 | - update_option($post_type.'_dummy_data_type',''); |
|
192 | + update_option($post_type.'_dummy_data_type',''); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -203,78 +203,78 @@ discard block |
||
203 | 203 | function geodir_insert_dummy_posts($post_type,$data_type,$item_index) |
204 | 204 | { |
205 | 205 | |
206 | - ini_set('max_execution_time', 999999); //300 seconds = 5 minutes |
|
207 | - $data_types = geodir_dummy_data_types(); |
|
208 | - |
|
209 | - $total_count = 0; |
|
210 | - global $dummy_post_index; |
|
211 | - $dummy_post_index = $item_index; |
|
212 | - foreach( $data_types as $key=>$val){ |
|
213 | - if($key==$data_type){ |
|
214 | - $total_count = $val['count']; |
|
215 | - if($key=='standard_places'){ |
|
216 | - /** |
|
217 | - * Contains dummy post content. |
|
218 | - * |
|
219 | - * @since 1.0.0 |
|
220 | - * @package GeoDirectory |
|
221 | - */ |
|
222 | - include_once( 'dummy-data/standard_places.php' ); |
|
223 | - }elseif($key=='property_sale'){ |
|
224 | - /** |
|
225 | - * Contains dummy property for sale post content. |
|
226 | - * |
|
227 | - * @since 1.6.11 |
|
228 | - * @package GeoDirectory |
|
229 | - */ |
|
230 | - include_once( 'dummy-data/property_sale.php' ); |
|
231 | - }elseif($key=='property_rent'){ |
|
232 | - /** |
|
233 | - * Contains dummy property for sale post content. |
|
234 | - * |
|
235 | - * @since 1.6.11 |
|
236 | - * @package GeoDirectory |
|
237 | - */ |
|
238 | - include_once( 'dummy-data/property_rent.php' ); |
|
239 | - } |
|
240 | - |
|
241 | - } |
|
242 | - |
|
243 | - do_action('geodir_insert_dummy_data_loop',$post_type,$data_type,$item_index); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - // delete image cache on last entry |
|
249 | - if($total_count == $item_index){ |
|
250 | - delete_transient( 'cached_dummy_images' ); |
|
251 | - flush_rewrite_rules(); |
|
252 | - } |
|
206 | + ini_set('max_execution_time', 999999); //300 seconds = 5 minutes |
|
207 | + $data_types = geodir_dummy_data_types(); |
|
208 | + |
|
209 | + $total_count = 0; |
|
210 | + global $dummy_post_index; |
|
211 | + $dummy_post_index = $item_index; |
|
212 | + foreach( $data_types as $key=>$val){ |
|
213 | + if($key==$data_type){ |
|
214 | + $total_count = $val['count']; |
|
215 | + if($key=='standard_places'){ |
|
216 | + /** |
|
217 | + * Contains dummy post content. |
|
218 | + * |
|
219 | + * @since 1.0.0 |
|
220 | + * @package GeoDirectory |
|
221 | + */ |
|
222 | + include_once( 'dummy-data/standard_places.php' ); |
|
223 | + }elseif($key=='property_sale'){ |
|
224 | + /** |
|
225 | + * Contains dummy property for sale post content. |
|
226 | + * |
|
227 | + * @since 1.6.11 |
|
228 | + * @package GeoDirectory |
|
229 | + */ |
|
230 | + include_once( 'dummy-data/property_sale.php' ); |
|
231 | + }elseif($key=='property_rent'){ |
|
232 | + /** |
|
233 | + * Contains dummy property for sale post content. |
|
234 | + * |
|
235 | + * @since 1.6.11 |
|
236 | + * @package GeoDirectory |
|
237 | + */ |
|
238 | + include_once( 'dummy-data/property_rent.php' ); |
|
239 | + } |
|
240 | + |
|
241 | + } |
|
242 | + |
|
243 | + do_action('geodir_insert_dummy_data_loop',$post_type,$data_type,$item_index); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + // delete image cache on last entry |
|
249 | + if($total_count == $item_index){ |
|
250 | + delete_transient( 'cached_dummy_images' ); |
|
251 | + flush_rewrite_rules(); |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | 255 | } |
256 | 256 | |
257 | 257 | |
258 | 258 | if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) { |
259 | - /** |
|
260 | - * GeoDirectory dummy data installation. |
|
261 | - * |
|
262 | - * @since 1.0.0 |
|
263 | - * @package GeoDirectory |
|
264 | - * @global object $wpdb WordPress Database object. |
|
265 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
266 | - * @param string $post_type The post type. |
|
267 | - */ |
|
268 | - function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
269 | - { |
|
270 | - |
|
271 | - global $wpdb, $plugin_prefix; |
|
272 | - |
|
273 | - if (!geodir_is_default_location_set()) { |
|
274 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
275 | - } else { |
|
276 | - |
|
277 | - ?> |
|
259 | + /** |
|
260 | + * GeoDirectory dummy data installation. |
|
261 | + * |
|
262 | + * @since 1.0.0 |
|
263 | + * @package GeoDirectory |
|
264 | + * @global object $wpdb WordPress Database object. |
|
265 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
266 | + * @param string $post_type The post type. |
|
267 | + */ |
|
268 | + function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
269 | + { |
|
270 | + |
|
271 | + global $wpdb, $plugin_prefix; |
|
272 | + |
|
273 | + if (!geodir_is_default_location_set()) { |
|
274 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
275 | + } else { |
|
276 | + |
|
277 | + ?> |
|
278 | 278 | <span class="gd-dummy-hint"><small><?php _e('*Hint*: Installing our Advanced Search addon FIRST will add extra search fields to non-default data types.','geodirectory');?></small></span> |
279 | 279 | <table class="form-table gd-dummy-table"> |
280 | 280 | <tbody> |
@@ -286,78 +286,78 @@ discard block |
||
286 | 286 | |
287 | 287 | <?php |
288 | 288 | |
289 | - $cpts = geodir_get_posttypes('array'); |
|
289 | + $cpts = geodir_get_posttypes('array'); |
|
290 | 290 | |
291 | - $data_types = geodir_dummy_data_types(); |
|
291 | + $data_types = geodir_dummy_data_types(); |
|
292 | 292 | |
293 | - $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename'); |
|
293 | + $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename'); |
|
294 | 294 | |
295 | - foreach($cpts as $post_type=>$cpt){ |
|
295 | + foreach($cpts as $post_type=>$cpt){ |
|
296 | 296 | |
297 | - $data_types_for = apply_filters('geodir_dummy_date_types_for',$data_types,$post_type); |
|
297 | + $data_types_for = apply_filters('geodir_dummy_date_types_for',$data_types,$post_type); |
|
298 | 298 | |
299 | 299 | |
300 | - $set_dt = get_option($post_type.'_dummy_data_type'); |
|
300 | + $set_dt = get_option($post_type.'_dummy_data_type'); |
|
301 | 301 | |
302 | - $count = 30; |
|
302 | + $count = 30; |
|
303 | 303 | |
304 | - geodir_add_column_if_not_exist($plugin_prefix . $post_type. "_detail", 'post_dummy', "enum( '1', '0' ) NULL DEFAULT '0'"); |
|
304 | + geodir_add_column_if_not_exist($plugin_prefix . $post_type. "_detail", 'post_dummy', "enum( '1', '0' ) NULL DEFAULT '0'"); |
|
305 | 305 | |
306 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'"); |
|
306 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'"); |
|
307 | 307 | |
308 | - echo "<tr>"; |
|
309 | - echo "<td><strong>".$cpt['labels']['name']."</strong></td>"; |
|
308 | + echo "<tr>"; |
|
309 | + echo "<td><strong>".$cpt['labels']['name']."</strong></td>"; |
|
310 | 310 | |
311 | 311 | |
312 | - $select_disabled = $post_counts > 0 ? 'disabled' : ''; |
|
313 | - echo "<td>"; |
|
314 | - echo "<select id='".$post_type."_data_type' onchange='geodir_dummy_set_count(this,\"$post_type\");' $select_disabled>"; |
|
312 | + $select_disabled = $post_counts > 0 ? 'disabled' : ''; |
|
313 | + echo "<td>"; |
|
314 | + echo "<select id='".$post_type."_data_type' onchange='geodir_dummy_set_count(this,\"$post_type\");' $select_disabled>"; |
|
315 | 315 | |
316 | - foreach($data_types_for as $key=>$val){ |
|
317 | - $selected = ($key==$set_dt) ? "selected='selected'" : ''; |
|
318 | - if($selected || count($data_types_for)==1){$count = $val['count'];} |
|
319 | - echo "<option $selected value='$key' data-count='".$val['count']."'>".$val['name']."</option>"; |
|
320 | - } |
|
321 | - echo "</select>"; |
|
322 | - |
|
323 | - $select_display = $post_counts > 0 ? 'display:none;' : ''; |
|
324 | - echo "<select id='".$post_type."_data_type_count' style='$select_display' >"; |
|
325 | - $x = 1; |
|
326 | - while($x <= $count){ |
|
327 | - $selected = ($x==$count) ? "selected='selected'" : ''; |
|
328 | - echo "<option $selected value='$x'>".$x."</option>"; |
|
329 | - $x++; |
|
330 | - } |
|
331 | - echo "</select>"; |
|
332 | - echo "</td>"; |
|
316 | + foreach($data_types_for as $key=>$val){ |
|
317 | + $selected = ($key==$set_dt) ? "selected='selected'" : ''; |
|
318 | + if($selected || count($data_types_for)==1){$count = $val['count'];} |
|
319 | + echo "<option $selected value='$key' data-count='".$val['count']."'>".$val['name']."</option>"; |
|
320 | + } |
|
321 | + echo "</select>"; |
|
333 | 322 | |
323 | + $select_display = $post_counts > 0 ? 'display:none;' : ''; |
|
324 | + echo "<select id='".$post_type."_data_type_count' style='$select_display' >"; |
|
325 | + $x = 1; |
|
326 | + while($x <= $count){ |
|
327 | + $selected = ($x==$count) ? "selected='selected'" : ''; |
|
328 | + echo "<option $selected value='$x'>".$x."</option>"; |
|
329 | + $x++; |
|
330 | + } |
|
331 | + echo "</select>"; |
|
332 | + echo "</td>"; |
|
334 | 333 | |
335 | 334 | |
336 | 335 | |
337 | 336 | |
338 | - if($post_counts > 0){ |
|
339 | - echo '<td><input type="button" value="'.__('Remove data','geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
|
340 | - }else{ |
|
341 | - echo '<td><input type="button" value="'.__('Insert data','geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
|
342 | - } |
|
343 | 337 | |
344 | - echo "</tr>"; |
|
345 | - //print_r($cpt); |
|
346 | - } |
|
338 | + if($post_counts > 0){ |
|
339 | + echo '<td><input type="button" value="'.__('Remove data','geodirectory').'" class="button-primary geodir_dummy_button gd-remove-data" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
|
340 | + }else{ |
|
341 | + echo '<td><input type="button" value="'.__('Insert data','geodirectory').'" class="button-primary geodir_dummy_button" onclick="gdInstallDummyData(this,\'' . $nonce . '\',\'' . $post_type . '\'); return false;" ></td>'; |
|
342 | + } |
|
343 | + |
|
344 | + echo "</tr>"; |
|
345 | + //print_r($cpt); |
|
346 | + } |
|
347 | 347 | |
348 | - ?> |
|
348 | + ?> |
|
349 | 349 | </tbody> |
350 | 350 | </table> |
351 | 351 | <?php |
352 | 352 | |
353 | 353 | |
354 | - $default_location = geodir_get_default_location(); |
|
355 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
356 | - $region = isset($default_location->region) ? $default_location->region : ''; |
|
357 | - $country = isset($default_location->country) ? $default_location->country : ''; |
|
358 | - $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
359 | - $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
360 | - ?> |
|
354 | + $default_location = geodir_get_default_location(); |
|
355 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
356 | + $region = isset($default_location->region) ? $default_location->region : ''; |
|
357 | + $country = isset($default_location->country) ? $default_location->country : ''; |
|
358 | + $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
359 | + $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
360 | + ?> |
|
361 | 361 | <script type="text/javascript"> |
362 | 362 | |
363 | 363 | function geodir_dummy_set_count(data,cpt){ |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | } |
534 | 534 | </script> |
535 | 535 | <?php |
536 | - } |
|
537 | - } |
|
536 | + } |
|
537 | + } |
|
538 | 538 | } |
539 | 539 |
@@ -223,6 +223,9 @@ |
||
223 | 223 | * @param filter - the property to filter on |
224 | 224 | * @param limit - the number of items to get |
225 | 225 | * @param realtime - if the realtime api should be used |
226 | + * @param string $metric |
|
227 | + * @param string $startDate |
|
228 | + * @param string $endDate |
|
226 | 229 | * @return the specific metrics in array form |
227 | 230 | **/ |
228 | 231 | function getMetrics($metric, $startDate, $endDate, $dimensions = false, $sort = false, $filter = false, $limit = false, $realtime = false) |
@@ -30,135 +30,135 @@ discard block |
||
30 | 30 | // Include the Google Service API |
31 | 31 | include_once('google-api-php-client/src/Google/autoload.php'); |
32 | 32 | |
33 | - $this->client = new Google_Client(); |
|
34 | - $this->client->setApprovalPrompt("force"); |
|
35 | - $this->client->setAccessType('offline'); |
|
36 | - $this->client->setClientId(GEODIR_GA_CLIENTID); |
|
37 | - $this->client->setClientSecret(GEODIR_GA_CLIENTSECRET); |
|
38 | - $this->client->setRedirectUri(GEODIR_GA_REDIRECT); |
|
33 | + $this->client = new Google_Client(); |
|
34 | + $this->client->setApprovalPrompt("force"); |
|
35 | + $this->client->setAccessType('offline'); |
|
36 | + $this->client->setClientId(GEODIR_GA_CLIENTID); |
|
37 | + $this->client->setClientSecret(GEODIR_GA_CLIENTSECRET); |
|
38 | + $this->client->setRedirectUri(GEODIR_GA_REDIRECT); |
|
39 | 39 | |
40 | - $this->client->setScopes(array("https://www.googleapis.com/auth/analytics")); |
|
41 | - |
|
42 | - try { |
|
43 | - $this->analytics = new Google_Service_Analytics($this->client); |
|
44 | - } |
|
45 | - catch (Google_ServiceException $e) |
|
46 | - { |
|
47 | - print '(cas:48) There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); |
|
40 | + $this->client->setScopes(array("https://www.googleapis.com/auth/analytics")); |
|
41 | + |
|
42 | + try { |
|
43 | + $this->analytics = new Google_Service_Analytics($this->client); |
|
44 | + } |
|
45 | + catch (Google_ServiceException $e) |
|
46 | + { |
|
47 | + print '(cas:48) There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); |
|
48 | 48 | return false; |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function checkLogin() |
53 | 53 | { |
54 | - $ga_google_authtoken = get_option('geodir_ga_auth_token'); |
|
54 | + $ga_google_authtoken = get_option('geodir_ga_auth_token'); |
|
55 | 55 | |
56 | - if (!empty($ga_google_authtoken)) |
|
57 | - { |
|
56 | + if (!empty($ga_google_authtoken)) |
|
57 | + { |
|
58 | 58 | try |
59 | - { |
|
60 | - $this->client->setAccessToken($ga_google_authtoken); |
|
59 | + { |
|
60 | + $this->client->setAccessToken($ga_google_authtoken); |
|
61 | 61 | } |
62 | 62 | catch( Google_AuthException $e ) |
63 | - { |
|
64 | - print '(cas:72) GeoDirectory was unable to authenticate you with |
|
63 | + { |
|
64 | + print '(cas:72) GeoDirectory was unable to authenticate you with |
|
65 | 65 | Google using the Auth Token you pasted into the input box on the previous step. <br><br> |
66 | 66 | This could mean either you pasted the token wrong, or the time/date on your server is wrong, |
67 | 67 | or an SSL issue preventing Google from Authenticating. <br><br> |
68 | 68 | <br><br><strong>Tech Info </strong> ' . $e->getCode() . ':' . $e->getMessage(); |
69 | 69 | |
70 | - return false; |
|
71 | - } |
|
72 | - } |
|
73 | - else |
|
74 | - { |
|
75 | - $authCode = get_option('geodir_ga_auth_code'); |
|
76 | - |
|
77 | - if (empty($authCode)) return false; |
|
78 | - |
|
79 | - try |
|
80 | - { |
|
81 | - $accessToken = $this->client->authenticate($authCode); |
|
82 | - } |
|
83 | - catch( Exception $e ) |
|
84 | - { |
|
85 | - print '(cas:72) GeoDirectory was unable to authenticate you with |
|
70 | + return false; |
|
71 | + } |
|
72 | + } |
|
73 | + else |
|
74 | + { |
|
75 | + $authCode = get_option('geodir_ga_auth_code'); |
|
76 | + |
|
77 | + if (empty($authCode)) return false; |
|
78 | + |
|
79 | + try |
|
80 | + { |
|
81 | + $accessToken = $this->client->authenticate($authCode); |
|
82 | + } |
|
83 | + catch( Exception $e ) |
|
84 | + { |
|
85 | + print '(cas:72) GeoDirectory was unable to authenticate you with |
|
86 | 86 | Google using the Auth Token you pasted into the input box on the previous step. <br><br> |
87 | 87 | This could mean either you pasted the token wrong, or the time/date on your server is wrong, |
88 | 88 | or an SSL issue preventing Google from Authenticating. <br><br> |
89 | 89 | <br><br><strong>Tech Info </strong> ' . $e->getCode() . ':' . $e->getMessage(); |
90 | 90 | |
91 | - return false; |
|
92 | - } |
|
93 | - |
|
94 | - if($accessToken) |
|
95 | - { |
|
96 | - $this->client->setAccessToken($accessToken); |
|
97 | - update_option('geodir_ga_auth_token', $accessToken); |
|
98 | - } |
|
99 | - else |
|
100 | - { |
|
101 | - return false; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - $this->token = $this->client->getAccessToken(); |
|
106 | - return true; |
|
91 | + return false; |
|
92 | + } |
|
93 | + |
|
94 | + if($accessToken) |
|
95 | + { |
|
96 | + $this->client->setAccessToken($accessToken); |
|
97 | + update_option('geodir_ga_auth_token', $accessToken); |
|
98 | + } |
|
99 | + else |
|
100 | + { |
|
101 | + return false; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + $this->token = $this->client->getAccessToken(); |
|
106 | + return true; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | function deauthorize() |
110 | 110 | { |
111 | - update_option('geodir_ga_auth_code', ''); |
|
112 | - update_option('geodir_ga_auth_token', ''); |
|
111 | + update_option('geodir_ga_auth_code', ''); |
|
112 | + update_option('geodir_ga_auth_token', ''); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | function getSingleProfile() |
116 | 116 | { |
117 | - $webproperty_id = get_option('geodir_ga_account_id'); |
|
118 | - list($pre, $account_id, $post) = explode('-',$webproperty_id); |
|
119 | - |
|
120 | - if (empty($webproperty_id)) return false; |
|
121 | - |
|
122 | - try { |
|
123 | - $profiles = $this->analytics->management_profiles->listManagementProfiles($account_id, $webproperty_id); |
|
124 | - } |
|
125 | - catch (Google_ServiceException $e) |
|
126 | - { |
|
127 | - print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
|
128 | - return false; |
|
129 | - } |
|
130 | - |
|
131 | - $profile_id = $profiles->items[0]->id; |
|
132 | - if (empty($profile_id)) return false; |
|
133 | - |
|
134 | - $account_array = array(); |
|
135 | - array_push($account_array, array('id'=>$profile_id, 'ga:webPropertyId'=>$webproperty_id)); |
|
136 | - return $account_array; |
|
117 | + $webproperty_id = get_option('geodir_ga_account_id'); |
|
118 | + list($pre, $account_id, $post) = explode('-',$webproperty_id); |
|
119 | + |
|
120 | + if (empty($webproperty_id)) return false; |
|
121 | + |
|
122 | + try { |
|
123 | + $profiles = $this->analytics->management_profiles->listManagementProfiles($account_id, $webproperty_id); |
|
124 | + } |
|
125 | + catch (Google_ServiceException $e) |
|
126 | + { |
|
127 | + print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
|
128 | + return false; |
|
129 | + } |
|
130 | + |
|
131 | + $profile_id = $profiles->items[0]->id; |
|
132 | + if (empty($profile_id)) return false; |
|
133 | + |
|
134 | + $account_array = array(); |
|
135 | + array_push($account_array, array('id'=>$profile_id, 'ga:webPropertyId'=>$webproperty_id)); |
|
136 | + return $account_array; |
|
137 | 137 | } |
138 | 138 | |
139 | - function getAllProfiles() |
|
140 | - { |
|
141 | - $profile_array = array(); |
|
139 | + function getAllProfiles() |
|
140 | + { |
|
141 | + $profile_array = array(); |
|
142 | 142 | |
143 | - try { |
|
144 | - $profiles = $this->analytics->management_webproperties->listManagementWebproperties('~all'); |
|
145 | - } |
|
146 | - catch (Google_ServiceException $e) |
|
147 | - { |
|
148 | - print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - if( !empty( $profiles->items ) ) |
|
153 | - { |
|
154 | - foreach( $profiles->items as $profile ) |
|
155 | - { |
|
156 | - $profile_array[ $profile->id ] = str_replace('http://','',$profile->name ); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - return $profile_array; |
|
161 | - } |
|
143 | + try { |
|
144 | + $profiles = $this->analytics->management_webproperties->listManagementWebproperties('~all'); |
|
145 | + } |
|
146 | + catch (Google_ServiceException $e) |
|
147 | + { |
|
148 | + print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + if( !empty( $profiles->items ) ) |
|
153 | + { |
|
154 | + foreach( $profiles->items as $profile ) |
|
155 | + { |
|
156 | + $profile_array[ $profile->id ] = str_replace('http://','',$profile->name ); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + return $profile_array; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | function getAnalyticsAccounts() |
164 | 164 | { |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $params['max-results'] = $limit; |
242 | 242 | } |
243 | 243 | |
244 | - // Just incase, the ga: is still used in the account id, strip it out to prevent it breaking |
|
245 | - $filtered_id = str_replace( 'ga:', '', $this->accountId ); |
|
244 | + // Just incase, the ga: is still used in the account id, strip it out to prevent it breaking |
|
245 | + $filtered_id = str_replace( 'ga:', '', $this->accountId ); |
|
246 | 246 | |
247 | - if(!$filtered_id){ |
|
248 | - echo 'Error - Account ID is blank'; |
|
249 | - return false; |
|
250 | - } |
|
247 | + if(!$filtered_id){ |
|
248 | + echo 'Error - Account ID is blank'; |
|
249 | + return false; |
|
250 | + } |
|
251 | 251 | |
252 | 252 | if($realtime){ |
253 | 253 | return $analytics->data_realtime->get( |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | catch (Google_ServiceException $e) |
46 | 46 | { |
47 | - print '(cas:48) There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); |
|
47 | + print '(cas:48) There was an Analytics API service error '.$e->getCode().':'.$e->getMessage(); |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | } |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | { |
60 | 60 | $this->client->setAccessToken($ga_google_authtoken); |
61 | 61 | } |
62 | - catch( Google_AuthException $e ) |
|
62 | + catch (Google_AuthException $e) |
|
63 | 63 | { |
64 | 64 | print '(cas:72) GeoDirectory was unable to authenticate you with |
65 | 65 | Google using the Auth Token you pasted into the input box on the previous step. <br><br> |
66 | 66 | This could mean either you pasted the token wrong, or the time/date on your server is wrong, |
67 | 67 | or an SSL issue preventing Google from Authenticating. <br><br> |
68 | - <br><br><strong>Tech Info </strong> ' . $e->getCode() . ':' . $e->getMessage(); |
|
68 | + <br><br><strong>Tech Info </strong> ' . $e->getCode().':'.$e->getMessage(); |
|
69 | 69 | |
70 | 70 | return false; |
71 | 71 | } |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | { |
81 | 81 | $accessToken = $this->client->authenticate($authCode); |
82 | 82 | } |
83 | - catch( Exception $e ) |
|
83 | + catch (Exception $e) |
|
84 | 84 | { |
85 | 85 | print '(cas:72) GeoDirectory was unable to authenticate you with |
86 | 86 | Google using the Auth Token you pasted into the input box on the previous step. <br><br> |
87 | 87 | This could mean either you pasted the token wrong, or the time/date on your server is wrong, |
88 | 88 | or an SSL issue preventing Google from Authenticating. <br><br> |
89 | - <br><br><strong>Tech Info </strong> ' . $e->getCode() . ':' . $e->getMessage(); |
|
89 | + <br><br><strong>Tech Info </strong> ' . $e->getCode().':'.$e->getMessage(); |
|
90 | 90 | |
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | - if($accessToken) |
|
94 | + if ($accessToken) |
|
95 | 95 | { |
96 | 96 | $this->client->setAccessToken($accessToken); |
97 | 97 | update_option('geodir_ga_auth_token', $accessToken); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - $this->token = $this->client->getAccessToken(); |
|
105 | + $this->token = $this->client->getAccessToken(); |
|
106 | 106 | return true; |
107 | 107 | } |
108 | 108 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | function getSingleProfile() |
116 | 116 | { |
117 | 117 | $webproperty_id = get_option('geodir_ga_account_id'); |
118 | - list($pre, $account_id, $post) = explode('-',$webproperty_id); |
|
118 | + list($pre, $account_id, $post) = explode('-', $webproperty_id); |
|
119 | 119 | |
120 | 120 | if (empty($webproperty_id)) return false; |
121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | catch (Google_ServiceException $e) |
126 | 126 | { |
127 | - print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
|
127 | + print 'There was an Analytics API service error '.$e->getCode().': '.$e->getMessage(); |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | } |
146 | 146 | catch (Google_ServiceException $e) |
147 | 147 | { |
148 | - print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
|
148 | + print 'There was an Analytics API service error '.$e->getCode().': '.$e->getMessage(); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | - if( !empty( $profiles->items ) ) |
|
152 | + if (!empty($profiles->items)) |
|
153 | 153 | { |
154 | - foreach( $profiles->items as $profile ) |
|
154 | + foreach ($profiles->items as $profile) |
|
155 | 155 | { |
156 | - $profile_array[ $profile->id ] = str_replace('http://','',$profile->name ); |
|
156 | + $profile_array[$profile->id] = str_replace('http://', '', $profile->name); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | // Just incase, the ga: is still used in the account id, strip it out to prevent it breaking |
245 | - $filtered_id = str_replace( 'ga:', '', $this->accountId ); |
|
245 | + $filtered_id = str_replace('ga:', '', $this->accountId); |
|
246 | 246 | |
247 | - if(!$filtered_id){ |
|
247 | + if (!$filtered_id) { |
|
248 | 248 | echo 'Error - Account ID is blank'; |
249 | 249 | return false; |
250 | 250 | } |
251 | 251 | |
252 | - if($realtime){ |
|
252 | + if ($realtime) { |
|
253 | 253 | return $analytics->data_realtime->get( |
254 | 254 | 'ga:'.$filtered_id, |
255 | 255 | $metric, |
256 | 256 | $params |
257 | 257 | ); |
258 | - }else{ |
|
258 | + } else { |
|
259 | 259 | return $analytics->data_ga->get( |
260 | 260 | 'ga:'.$filtered_id, |
261 | 261 | $startDate, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | **/ |
280 | 280 | function verifyStartDate($date) |
281 | 281 | { |
282 | - if ( strtotime($date) > strtotime('2005-01-01') ) |
|
282 | + if (strtotime($date) > strtotime('2005-01-01')) |
|
283 | 283 | return $date; |
284 | 284 | else |
285 | 285 | return '2005-01-01'; |
@@ -41,8 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | try { |
43 | 43 | $this->analytics = new Google_Service_Analytics($this->client); |
44 | - } |
|
45 | - catch (Google_ServiceException $e) |
|
44 | + } catch (Google_ServiceException $e) |
|
46 | 45 | { |
47 | 46 | print '(cas:48) There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); |
48 | 47 | return false; |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | try |
59 | 58 | { |
60 | 59 | $this->client->setAccessToken($ga_google_authtoken); |
61 | - } |
|
62 | - catch( Google_AuthException $e ) |
|
60 | + } catch( Google_AuthException $e ) |
|
63 | 61 | { |
64 | 62 | print '(cas:72) GeoDirectory was unable to authenticate you with |
65 | 63 | Google using the Auth Token you pasted into the input box on the previous step. <br><br> |
@@ -69,18 +67,18 @@ discard block |
||
69 | 67 | |
70 | 68 | return false; |
71 | 69 | } |
72 | - } |
|
73 | - else |
|
70 | + } else |
|
74 | 71 | { |
75 | 72 | $authCode = get_option('geodir_ga_auth_code'); |
76 | 73 | |
77 | - if (empty($authCode)) return false; |
|
74 | + if (empty($authCode)) { |
|
75 | + return false; |
|
76 | + } |
|
78 | 77 | |
79 | 78 | try |
80 | 79 | { |
81 | 80 | $accessToken = $this->client->authenticate($authCode); |
82 | - } |
|
83 | - catch( Exception $e ) |
|
81 | + } catch( Exception $e ) |
|
84 | 82 | { |
85 | 83 | print '(cas:72) GeoDirectory was unable to authenticate you with |
86 | 84 | Google using the Auth Token you pasted into the input box on the previous step. <br><br> |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | { |
96 | 94 | $this->client->setAccessToken($accessToken); |
97 | 95 | update_option('geodir_ga_auth_token', $accessToken); |
98 | - } |
|
99 | - else |
|
96 | + } else |
|
100 | 97 | { |
101 | 98 | return false; |
102 | 99 | } |
@@ -117,19 +114,22 @@ discard block |
||
117 | 114 | $webproperty_id = get_option('geodir_ga_account_id'); |
118 | 115 | list($pre, $account_id, $post) = explode('-',$webproperty_id); |
119 | 116 | |
120 | - if (empty($webproperty_id)) return false; |
|
117 | + if (empty($webproperty_id)) { |
|
118 | + return false; |
|
119 | + } |
|
121 | 120 | |
122 | 121 | try { |
123 | 122 | $profiles = $this->analytics->management_profiles->listManagementProfiles($account_id, $webproperty_id); |
124 | - } |
|
125 | - catch (Google_ServiceException $e) |
|
123 | + } catch (Google_ServiceException $e) |
|
126 | 124 | { |
127 | 125 | print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
128 | 126 | return false; |
129 | 127 | } |
130 | 128 | |
131 | 129 | $profile_id = $profiles->items[0]->id; |
132 | - if (empty($profile_id)) return false; |
|
130 | + if (empty($profile_id)) { |
|
131 | + return false; |
|
132 | + } |
|
133 | 133 | |
134 | 134 | $account_array = array(); |
135 | 135 | array_push($account_array, array('id'=>$profile_id, 'ga:webPropertyId'=>$webproperty_id)); |
@@ -142,8 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | try { |
144 | 144 | $profiles = $this->analytics->management_webproperties->listManagementWebproperties('~all'); |
145 | - } |
|
146 | - catch (Google_ServiceException $e) |
|
145 | + } catch (Google_ServiceException $e) |
|
147 | 146 | { |
148 | 147 | print 'There was an Analytics API service error ' . $e->getCode() . ': ' . $e->getMessage(); |
149 | 148 | } |
@@ -255,7 +254,7 @@ discard block |
||
255 | 254 | $metric, |
256 | 255 | $params |
257 | 256 | ); |
258 | - }else{ |
|
257 | + } else{ |
|
259 | 258 | return $analytics->data_ga->get( |
260 | 259 | 'ga:'.$filtered_id, |
261 | 260 | $startDate, |
@@ -279,10 +278,11 @@ discard block |
||
279 | 278 | **/ |
280 | 279 | function verifyStartDate($date) |
281 | 280 | { |
282 | - if ( strtotime($date) > strtotime('2005-01-01') ) |
|
283 | - return $date; |
|
284 | - else |
|
285 | - return '2005-01-01'; |
|
281 | + if ( strtotime($date) > strtotime('2005-01-01') ) { |
|
282 | + return $date; |
|
283 | + } else { |
|
284 | + return '2005-01-01'; |
|
285 | + } |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | } // END class |
289 | 289 | \ No newline at end of file |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * @param string $page Page url to use in analytics filters. |
56 | 56 | * @param bool $ga_start The start date of the data to include in YYYY-MM-DD format. |
57 | 57 | * @param bool $ga_end The end date of the data to include in YYYY-MM-DD format. |
58 | - * @return string Html text content. |
|
58 | + * @return false|null Html text content. |
|
59 | 59 | */ |
60 | 60 | function geodir_getGoogleAnalytics($page, $ga_start, $ga_end) |
61 | 61 | { |
@@ -17,34 +17,34 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function geodir_sec2hms($sec, $padHours = false) |
19 | 19 | { |
20 | - // holds formatted string |
|
21 | - $hms = ""; |
|
22 | - // there are 3600 seconds in an hour, so if we |
|
23 | - // divide total seconds by 3600 and throw away |
|
24 | - // the remainder, we've got the number of hours |
|
25 | - $hours = intval(intval($sec) / 3600); |
|
26 | - |
|
27 | - // add to $hms, with a leading 0 if asked for |
|
28 | - $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':' : $hours . ':'; |
|
29 | - |
|
30 | - // dividing the total seconds by 60 will give us |
|
31 | - // the number of minutes, but we're interested in |
|
32 | - // minutes past the hour: to get that, we need to |
|
33 | - // divide by 60 again and keep the remainder |
|
34 | - $minutes = intval(($sec / 60) % 60); |
|
35 | - |
|
36 | - // then add to $hms (with a leading 0 if needed) |
|
37 | - $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':'; |
|
38 | - |
|
39 | - // seconds are simple - just divide the total |
|
40 | - // seconds by 60 and keep the remainder |
|
41 | - $seconds = intval($sec % 60); |
|
42 | - |
|
43 | - // add to $hms, again with a leading 0 if needed |
|
44 | - $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); |
|
45 | - |
|
46 | - // done! |
|
47 | - return $hms; |
|
20 | + // holds formatted string |
|
21 | + $hms = ""; |
|
22 | + // there are 3600 seconds in an hour, so if we |
|
23 | + // divide total seconds by 3600 and throw away |
|
24 | + // the remainder, we've got the number of hours |
|
25 | + $hours = intval(intval($sec) / 3600); |
|
26 | + |
|
27 | + // add to $hms, with a leading 0 if asked for |
|
28 | + $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':' : $hours . ':'; |
|
29 | + |
|
30 | + // dividing the total seconds by 60 will give us |
|
31 | + // the number of minutes, but we're interested in |
|
32 | + // minutes past the hour: to get that, we need to |
|
33 | + // divide by 60 again and keep the remainder |
|
34 | + $minutes = intval(($sec / 60) % 60); |
|
35 | + |
|
36 | + // then add to $hms (with a leading 0 if needed) |
|
37 | + $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':'; |
|
38 | + |
|
39 | + // seconds are simple - just divide the total |
|
40 | + // seconds by 60 and keep the remainder |
|
41 | + $seconds = intval($sec % 60); |
|
42 | + |
|
43 | + // add to $hms, again with a leading 0 if needed |
|
44 | + $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT); |
|
45 | + |
|
46 | + // done! |
|
47 | + return $hms; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -60,122 +60,122 @@ discard block |
||
60 | 60 | function geodir_getGoogleAnalytics($page, $ga_start, $ga_end) |
61 | 61 | { |
62 | 62 | |
63 | - // NEW ANALYTICS |
|
64 | - |
|
65 | - $start_date = ''; |
|
66 | - $end_date = ''; |
|
67 | - $dimensions = ''; |
|
68 | - $sort = ''; |
|
69 | - $filters = "ga:pagePath==".$page; |
|
70 | - $metrics = "ga:pageviews"; |
|
71 | - $realtime = false; |
|
72 | - $limit = false; |
|
73 | - if(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisweek'){ |
|
74 | - $start_date = date('Y-m-d', strtotime("-6 day")); |
|
75 | - $end_date = date('Y-m-d'); |
|
76 | - $dimensions = "ga:date,ga:nthDay"; |
|
77 | - }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastweek'){ |
|
78 | - $start_date = date('Y-m-d', strtotime("-13 day")); |
|
79 | - $end_date = date('Y-m-d', strtotime("-7 day")); |
|
80 | - $dimensions = "ga:date,ga:nthDay"; |
|
81 | - } |
|
82 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisyear'){ |
|
83 | - $start_date = date('Y')."-01-01"; |
|
84 | - $end_date = date('Y-m-d'); |
|
85 | - $dimensions = "ga:month,ga:nthMonth"; |
|
86 | - } |
|
87 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastyear'){ |
|
88 | - $start_date = date('Y', strtotime("-1 year"))."-01-01"; |
|
89 | - $end_date = date('Y', strtotime("-1 year"))."-12-31"; |
|
90 | - $dimensions = "ga:month,ga:nthMonth"; |
|
91 | - } |
|
92 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='country'){ |
|
93 | - $start_date = "14daysAgo"; |
|
94 | - $end_date = "yesterday"; |
|
95 | - $dimensions = "ga:country"; |
|
96 | - $sort = "ga:pageviews"; |
|
97 | - $limit = 5; |
|
98 | - }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='realtime'){ |
|
99 | - $metrics = "rt:activeUsers"; |
|
100 | - $realtime = true; |
|
101 | - } |
|
102 | - |
|
103 | - # Create a new Gdata call |
|
104 | - $gaApi = new GDGoogleAnalyticsStats(); |
|
105 | - |
|
106 | - # Check if Google sucessfully logged in |
|
107 | - if (!$gaApi->checkLogin()){ |
|
108 | - echo json_encode(array('error'=>__('Please check Google Analytics Settings','geodirectory'))); |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - $account = $gaApi->getSingleProfile(); |
|
113 | - |
|
114 | - if(!isset($account[0]['id'])){ |
|
115 | - echo json_encode(array('error'=>__('Please check Google Analytics Settings','geodirectory'))); |
|
116 | - return false; |
|
117 | - } |
|
118 | - |
|
119 | - $account = $account[0]['id']; |
|
120 | - |
|
121 | - # Set the account to the one requested |
|
122 | - $gaApi->setAccount($account); |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - # Get the metrics needed to build the visits graph; |
|
127 | - try { |
|
128 | - $stats = $gaApi->getMetrics($metrics, $start_date, $end_date, $dimensions, $sort, $filters, $limit , $realtime); |
|
129 | - } |
|
130 | - catch (Exception $e) { |
|
131 | - print 'GA Summary Widget - there was a service error ' . $e->getCode() . ':' . $e->getMessage(); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - //print_r($stats); |
|
136 | - echo json_encode($stats); |
|
137 | - exit; |
|
63 | + // NEW ANALYTICS |
|
64 | + |
|
65 | + $start_date = ''; |
|
66 | + $end_date = ''; |
|
67 | + $dimensions = ''; |
|
68 | + $sort = ''; |
|
69 | + $filters = "ga:pagePath==".$page; |
|
70 | + $metrics = "ga:pageviews"; |
|
71 | + $realtime = false; |
|
72 | + $limit = false; |
|
73 | + if(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisweek'){ |
|
74 | + $start_date = date('Y-m-d', strtotime("-6 day")); |
|
75 | + $end_date = date('Y-m-d'); |
|
76 | + $dimensions = "ga:date,ga:nthDay"; |
|
77 | + }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastweek'){ |
|
78 | + $start_date = date('Y-m-d', strtotime("-13 day")); |
|
79 | + $end_date = date('Y-m-d', strtotime("-7 day")); |
|
80 | + $dimensions = "ga:date,ga:nthDay"; |
|
81 | + } |
|
82 | + elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisyear'){ |
|
83 | + $start_date = date('Y')."-01-01"; |
|
84 | + $end_date = date('Y-m-d'); |
|
85 | + $dimensions = "ga:month,ga:nthMonth"; |
|
86 | + } |
|
87 | + elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastyear'){ |
|
88 | + $start_date = date('Y', strtotime("-1 year"))."-01-01"; |
|
89 | + $end_date = date('Y', strtotime("-1 year"))."-12-31"; |
|
90 | + $dimensions = "ga:month,ga:nthMonth"; |
|
91 | + } |
|
92 | + elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='country'){ |
|
93 | + $start_date = "14daysAgo"; |
|
94 | + $end_date = "yesterday"; |
|
95 | + $dimensions = "ga:country"; |
|
96 | + $sort = "ga:pageviews"; |
|
97 | + $limit = 5; |
|
98 | + }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='realtime'){ |
|
99 | + $metrics = "rt:activeUsers"; |
|
100 | + $realtime = true; |
|
101 | + } |
|
102 | + |
|
103 | + # Create a new Gdata call |
|
104 | + $gaApi = new GDGoogleAnalyticsStats(); |
|
105 | + |
|
106 | + # Check if Google sucessfully logged in |
|
107 | + if (!$gaApi->checkLogin()){ |
|
108 | + echo json_encode(array('error'=>__('Please check Google Analytics Settings','geodirectory'))); |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + $account = $gaApi->getSingleProfile(); |
|
113 | + |
|
114 | + if(!isset($account[0]['id'])){ |
|
115 | + echo json_encode(array('error'=>__('Please check Google Analytics Settings','geodirectory'))); |
|
116 | + return false; |
|
117 | + } |
|
118 | + |
|
119 | + $account = $account[0]['id']; |
|
120 | + |
|
121 | + # Set the account to the one requested |
|
122 | + $gaApi->setAccount($account); |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + # Get the metrics needed to build the visits graph; |
|
127 | + try { |
|
128 | + $stats = $gaApi->getMetrics($metrics, $start_date, $end_date, $dimensions, $sort, $filters, $limit , $realtime); |
|
129 | + } |
|
130 | + catch (Exception $e) { |
|
131 | + print 'GA Summary Widget - there was a service error ' . $e->getCode() . ':' . $e->getMessage(); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + //print_r($stats); |
|
136 | + echo json_encode($stats); |
|
137 | + exit; |
|
138 | 138 | |
139 | 139 | |
140 | 140 | }// end GA function |
141 | 141 | |
142 | 142 | |
143 | 143 | function geodir_ga_get_token(){ |
144 | - $at = get_option('gd_ga_access_token'); |
|
145 | - $use_url = "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=".$at; |
|
146 | - $response = wp_remote_get($use_url,array('timeout' => 15)); |
|
144 | + $at = get_option('gd_ga_access_token'); |
|
145 | + $use_url = "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=".$at; |
|
146 | + $response = wp_remote_get($use_url,array('timeout' => 15)); |
|
147 | 147 | |
148 | - if(!empty($response['response']['code']) && $response['response']['code']==200) {//access token is valid |
|
148 | + if(!empty($response['response']['code']) && $response['response']['code']==200) {//access token is valid |
|
149 | 149 | |
150 | - return $at; |
|
151 | - }else{//else get new access token |
|
150 | + return $at; |
|
151 | + }else{//else get new access token |
|
152 | 152 | |
153 | - $refresh_at = get_option('gd_ga_refresh_token'); |
|
154 | - if(!$refresh_at){ |
|
155 | - echo json_encode(array('error'=>__('Not authorized, please click authorized in GD > Google analytic settings.', 'geodirectory')));exit; |
|
156 | - } |
|
153 | + $refresh_at = get_option('gd_ga_refresh_token'); |
|
154 | + if(!$refresh_at){ |
|
155 | + echo json_encode(array('error'=>__('Not authorized, please click authorized in GD > Google analytic settings.', 'geodirectory')));exit; |
|
156 | + } |
|
157 | 157 | |
158 | - $rat_url = "https://www.googleapis.com/oauth2/v3/token?"; |
|
159 | - $client_id = "client_id=".get_option('geodir_ga_client_id'); |
|
160 | - $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
|
161 | - $refresh_token = "&refresh_token=".$refresh_at; |
|
162 | - $grant_type = "&grant_type=refresh_token"; |
|
158 | + $rat_url = "https://www.googleapis.com/oauth2/v3/token?"; |
|
159 | + $client_id = "client_id=".get_option('geodir_ga_client_id'); |
|
160 | + $client_secret = "&client_secret=".get_option('geodir_ga_client_secret'); |
|
161 | + $refresh_token = "&refresh_token=".$refresh_at; |
|
162 | + $grant_type = "&grant_type=refresh_token"; |
|
163 | 163 | |
164 | - $rat_url_use = $rat_url.$client_id.$client_secret.$refresh_token.$grant_type; |
|
164 | + $rat_url_use = $rat_url.$client_id.$client_secret.$refresh_token.$grant_type; |
|
165 | 165 | |
166 | - $rat_response = wp_remote_post($rat_url_use,array('timeout' => 15)); |
|
167 | - if(!empty($rat_response['response']['code']) && $rat_response['response']['code']==200) { |
|
168 | - $parts = json_decode($rat_response['body']); |
|
166 | + $rat_response = wp_remote_post($rat_url_use,array('timeout' => 15)); |
|
167 | + if(!empty($rat_response['response']['code']) && $rat_response['response']['code']==200) { |
|
168 | + $parts = json_decode($rat_response['body']); |
|
169 | 169 | |
170 | 170 | |
171 | - update_option('gd_ga_access_token', $parts->access_token); |
|
172 | - return $parts->access_token; |
|
171 | + update_option('gd_ga_access_token', $parts->access_token); |
|
172 | + return $parts->access_token; |
|
173 | 173 | |
174 | - }else{ |
|
175 | - echo json_encode(array('error'=>__('Login failed', 'geodirectory')));exit; |
|
176 | - } |
|
174 | + }else{ |
|
175 | + echo json_encode(array('error'=>__('Login failed', 'geodirectory')));exit; |
|
176 | + } |
|
177 | 177 | |
178 | 178 | |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $hours = intval(intval($sec) / 3600); |
26 | 26 | |
27 | 27 | // add to $hms, with a leading 0 if asked for |
28 | - $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':' : $hours . ':'; |
|
28 | + $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT).':' : $hours.':'; |
|
29 | 29 | |
30 | 30 | // dividing the total seconds by 60 will give us |
31 | 31 | // the number of minutes, but we're interested in |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $minutes = intval(($sec / 60) % 60); |
35 | 35 | |
36 | 36 | // then add to $hms (with a leading 0 if needed) |
37 | - $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':'; |
|
37 | + $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT).':'; |
|
38 | 38 | |
39 | 39 | // seconds are simple - just divide the total |
40 | 40 | // seconds by 60 and keep the remainder |
@@ -70,32 +70,32 @@ discard block |
||
70 | 70 | $metrics = "ga:pageviews"; |
71 | 71 | $realtime = false; |
72 | 72 | $limit = false; |
73 | - if(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisweek'){ |
|
73 | + if (isset($_REQUEST['ga_type']) && $_REQUEST['ga_type'] == 'thisweek') { |
|
74 | 74 | $start_date = date('Y-m-d', strtotime("-6 day")); |
75 | 75 | $end_date = date('Y-m-d'); |
76 | 76 | $dimensions = "ga:date,ga:nthDay"; |
77 | - }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastweek'){ |
|
77 | + }elseif (isset($_REQUEST['ga_type']) && $_REQUEST['ga_type'] == 'lastweek') { |
|
78 | 78 | $start_date = date('Y-m-d', strtotime("-13 day")); |
79 | 79 | $end_date = date('Y-m-d', strtotime("-7 day")); |
80 | 80 | $dimensions = "ga:date,ga:nthDay"; |
81 | 81 | } |
82 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisyear'){ |
|
82 | + elseif (isset($_REQUEST['ga_type']) && $_REQUEST['ga_type'] == 'thisyear') { |
|
83 | 83 | $start_date = date('Y')."-01-01"; |
84 | 84 | $end_date = date('Y-m-d'); |
85 | 85 | $dimensions = "ga:month,ga:nthMonth"; |
86 | 86 | } |
87 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastyear'){ |
|
87 | + elseif (isset($_REQUEST['ga_type']) && $_REQUEST['ga_type'] == 'lastyear') { |
|
88 | 88 | $start_date = date('Y', strtotime("-1 year"))."-01-01"; |
89 | 89 | $end_date = date('Y', strtotime("-1 year"))."-12-31"; |
90 | 90 | $dimensions = "ga:month,ga:nthMonth"; |
91 | 91 | } |
92 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='country'){ |
|
92 | + elseif (isset($_REQUEST['ga_type']) && $_REQUEST['ga_type'] == 'country') { |
|
93 | 93 | $start_date = "14daysAgo"; |
94 | 94 | $end_date = "yesterday"; |
95 | 95 | $dimensions = "ga:country"; |
96 | 96 | $sort = "ga:pageviews"; |
97 | - $limit = 5; |
|
98 | - }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='realtime'){ |
|
97 | + $limit = 5; |
|
98 | + }elseif (isset($_REQUEST['ga_type']) && $_REQUEST['ga_type'] == 'realtime') { |
|
99 | 99 | $metrics = "rt:activeUsers"; |
100 | 100 | $realtime = true; |
101 | 101 | } |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | $gaApi = new GDGoogleAnalyticsStats(); |
105 | 105 | |
106 | 106 | # Check if Google sucessfully logged in |
107 | - if (!$gaApi->checkLogin()){ |
|
108 | - echo json_encode(array('error'=>__('Please check Google Analytics Settings','geodirectory'))); |
|
107 | + if (!$gaApi->checkLogin()) { |
|
108 | + echo json_encode(array('error'=>__('Please check Google Analytics Settings', 'geodirectory'))); |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | 112 | $account = $gaApi->getSingleProfile(); |
113 | 113 | |
114 | - if(!isset($account[0]['id'])){ |
|
115 | - echo json_encode(array('error'=>__('Please check Google Analytics Settings','geodirectory'))); |
|
114 | + if (!isset($account[0]['id'])) { |
|
115 | + echo json_encode(array('error'=>__('Please check Google Analytics Settings', 'geodirectory'))); |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | |
126 | 126 | # Get the metrics needed to build the visits graph; |
127 | 127 | try { |
128 | - $stats = $gaApi->getMetrics($metrics, $start_date, $end_date, $dimensions, $sort, $filters, $limit , $realtime); |
|
128 | + $stats = $gaApi->getMetrics($metrics, $start_date, $end_date, $dimensions, $sort, $filters, $limit, $realtime); |
|
129 | 129 | } |
130 | 130 | catch (Exception $e) { |
131 | - print 'GA Summary Widget - there was a service error ' . $e->getCode() . ':' . $e->getMessage(); |
|
131 | + print 'GA Summary Widget - there was a service error '.$e->getCode().':'.$e->getMessage(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | }// end GA function |
141 | 141 | |
142 | 142 | |
143 | -function geodir_ga_get_token(){ |
|
143 | +function geodir_ga_get_token() { |
|
144 | 144 | $at = get_option('gd_ga_access_token'); |
145 | 145 | $use_url = "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=".$at; |
146 | - $response = wp_remote_get($use_url,array('timeout' => 15)); |
|
146 | + $response = wp_remote_get($use_url, array('timeout' => 15)); |
|
147 | 147 | |
148 | - if(!empty($response['response']['code']) && $response['response']['code']==200) {//access token is valid |
|
148 | + if (!empty($response['response']['code']) && $response['response']['code'] == 200) {//access token is valid |
|
149 | 149 | |
150 | 150 | return $at; |
151 | - }else{//else get new access token |
|
151 | + } else {//else get new access token |
|
152 | 152 | |
153 | 153 | $refresh_at = get_option('gd_ga_refresh_token'); |
154 | - if(!$refresh_at){ |
|
155 | - echo json_encode(array('error'=>__('Not authorized, please click authorized in GD > Google analytic settings.', 'geodirectory')));exit; |
|
154 | + if (!$refresh_at) { |
|
155 | + echo json_encode(array('error'=>__('Not authorized, please click authorized in GD > Google analytic settings.', 'geodirectory'))); exit; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $rat_url = "https://www.googleapis.com/oauth2/v3/token?"; |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | |
164 | 164 | $rat_url_use = $rat_url.$client_id.$client_secret.$refresh_token.$grant_type; |
165 | 165 | |
166 | - $rat_response = wp_remote_post($rat_url_use,array('timeout' => 15)); |
|
167 | - if(!empty($rat_response['response']['code']) && $rat_response['response']['code']==200) { |
|
166 | + $rat_response = wp_remote_post($rat_url_use, array('timeout' => 15)); |
|
167 | + if (!empty($rat_response['response']['code']) && $rat_response['response']['code'] == 200) { |
|
168 | 168 | $parts = json_decode($rat_response['body']); |
169 | 169 | |
170 | 170 | |
171 | 171 | update_option('gd_ga_access_token', $parts->access_token); |
172 | 172 | return $parts->access_token; |
173 | 173 | |
174 | - }else{ |
|
175 | - echo json_encode(array('error'=>__('Login failed', 'geodirectory')));exit; |
|
174 | + } else { |
|
175 | + echo json_encode(array('error'=>__('Login failed', 'geodirectory'))); exit; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 |
@@ -74,28 +74,25 @@ discard block |
||
74 | 74 | $start_date = date('Y-m-d', strtotime("-6 day")); |
75 | 75 | $end_date = date('Y-m-d'); |
76 | 76 | $dimensions = "ga:date,ga:nthDay"; |
77 | - }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastweek'){ |
|
77 | + } elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastweek'){ |
|
78 | 78 | $start_date = date('Y-m-d', strtotime("-13 day")); |
79 | 79 | $end_date = date('Y-m-d', strtotime("-7 day")); |
80 | 80 | $dimensions = "ga:date,ga:nthDay"; |
81 | - } |
|
82 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisyear'){ |
|
81 | + } elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='thisyear'){ |
|
83 | 82 | $start_date = date('Y')."-01-01"; |
84 | 83 | $end_date = date('Y-m-d'); |
85 | 84 | $dimensions = "ga:month,ga:nthMonth"; |
86 | - } |
|
87 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastyear'){ |
|
85 | + } elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='lastyear'){ |
|
88 | 86 | $start_date = date('Y', strtotime("-1 year"))."-01-01"; |
89 | 87 | $end_date = date('Y', strtotime("-1 year"))."-12-31"; |
90 | 88 | $dimensions = "ga:month,ga:nthMonth"; |
91 | - } |
|
92 | - elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='country'){ |
|
89 | + } elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='country'){ |
|
93 | 90 | $start_date = "14daysAgo"; |
94 | 91 | $end_date = "yesterday"; |
95 | 92 | $dimensions = "ga:country"; |
96 | 93 | $sort = "ga:pageviews"; |
97 | 94 | $limit = 5; |
98 | - }elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='realtime'){ |
|
95 | + } elseif(isset($_REQUEST['ga_type']) && $_REQUEST['ga_type']=='realtime'){ |
|
99 | 96 | $metrics = "rt:activeUsers"; |
100 | 97 | $realtime = true; |
101 | 98 | } |
@@ -126,8 +123,7 @@ discard block |
||
126 | 123 | # Get the metrics needed to build the visits graph; |
127 | 124 | try { |
128 | 125 | $stats = $gaApi->getMetrics($metrics, $start_date, $end_date, $dimensions, $sort, $filters, $limit , $realtime); |
129 | - } |
|
130 | - catch (Exception $e) { |
|
126 | + } catch (Exception $e) { |
|
131 | 127 | print 'GA Summary Widget - there was a service error ' . $e->getCode() . ':' . $e->getMessage(); |
132 | 128 | } |
133 | 129 | |
@@ -148,7 +144,7 @@ discard block |
||
148 | 144 | if(!empty($response['response']['code']) && $response['response']['code']==200) {//access token is valid |
149 | 145 | |
150 | 146 | return $at; |
151 | - }else{//else get new access token |
|
147 | + } else{//else get new access token |
|
152 | 148 | |
153 | 149 | $refresh_at = get_option('gd_ga_refresh_token'); |
154 | 150 | if(!$refresh_at){ |
@@ -171,7 +167,7 @@ discard block |
||
171 | 167 | update_option('gd_ga_access_token', $parts->access_token); |
172 | 168 | return $parts->access_token; |
173 | 169 | |
174 | - }else{ |
|
170 | + } else{ |
|
175 | 171 | echo json_encode(array('error'=>__('Login failed', 'geodirectory')));exit; |
176 | 172 | } |
177 | 173 |