PluginProbe
Booking Calendar / 10.11.2
Booking Calendar v10.11.2
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
booking / core / admin / page-ics-general.php

page-ics-general.php in Booking Calendar 10.11.2, at core/admin/page-ics-general.php

698 lines 31.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @menu Booking > Settings > (Sync) General page
5 * @category Settings API
6 * @author wpdevelop
7 *
8 * @web-site https://wpbookingcalendar.com/
9 * @email info@wpbookingcalendar.com
10 * @modified 2017-12-18
11 *
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16 // FixIn: 8.1.1.10.
17 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19
20
21 /** API for Settings Page */
22 class WPBC_API_SettingsGeneralSync extends WPBC_Settings_API {
23
24 /**
25 * Settings API Constructor
26 * During creation, system try to load values from DB, if exist.
27 *
28 * @param type $id - "Pure Name"
29 */
30 public function __construct( $id, $init_fields_values = array(), $options = array() ) {
31
32 // This configuration meaning that options will be saved separately, without $id of this CLASS, just by using names of fields -- update_bk_option( $this->options['db_prefix_option'] . $field_name , $field_value );
33 $default_options = array(
34 'db_prefix_option' => ''
35 , 'db_saving_type' => 'separate'
36 );
37 // separate_prefix: update_bk_option( $this->options['db_prefix_option'] . $settings_id . '_' . $field_name , $value );
38 $options = wp_parse_args( $options, $default_options );
39
40 /**
41 * Activation and deactivation of these options already done at the wpbc-gcal.php file
42
43 // add_bk_action( 'wpbc_other_versions_activation', array( $this, 'activate' ) ); // Activate
44 // add_bk_action( 'wpbc_other_versions_deactivation', array( $this, 'deactivate' ) ); // Deactivate
45 */
46
47 parent::__construct( $id, $options, $init_fields_values ); // Define ID of Setting page and options
48 }
49
50
51
52 /** Define settings Fields */
53 public function init_settings_fields() {
54
55 $this->fields = array();
56
57 // TODO:
58 // add_bk_option( 'booking_gcal_events_form_fields', 'a:3:{s:5:"title";s:9:"text^name";s:11:"description";s:12:"text^details";s:5:"where";s:5:"text^";}');
59
60 // Problem with email^email field, previously its was text^email and problem with textarea^details field, previously its was text^details
61
62
63 ////////////////////////////////////////////////////////////////////////
64 // Get form fields from different forms in the paid versions
65 ////////////////////////////////////////////////////////////////////////
66 $options = array();
67 $options[ 'text^' ] = __('None' ,'booking');
68
69 $booking_forms = wpbc_get__in_all_forms__field_names_arr();
70
71 foreach ( $booking_forms as $single_booking_form ) {
72
73 //OPTGROUP - Open
74 $options[ $single_booking_form['name'] ] = array(
75 'title' => ucfirst( trim( $single_booking_form['name'] ) )
76 , 'optgroup' => true
77 , 'close' => false );
78
79 $field_listing = $single_booking_form['listing'];
80 for ( $i = 0; $i < $single_booking_form['num']; $i++ ) {
81 $options[ ( ( trim( $single_booking_form['name'] ) != 'standard' ) ? trim( $single_booking_form['name'] ) . '^' : '' ) .
82 trim( $single_booking_form['listing']['fields_type'][$i] ). '^' . trim( $single_booking_form['listing']['fields'][$i] )
83 ] = ( trim( $single_booking_form['listing']['labels'][$i] ) );
84 }
85
86 //OPTGROUP - Close
87 $options[ $single_booking_form['name'] . '_close' ] = array(
88 'title' => $single_booking_form['name'] // ucfirst( trim( $option_group_name ) )
89 , 'optgroup' => true
90 , 'close' => true );
91 }
92 ////////////////////////////////////////////////////////////////////////
93
94
95
96 // booking_gcal_events_form_fields - !!! real name of option to save. This option have to be skipped during saving and during loading need some actions.
97 $this->fields['booking_gcal_events_form_fields_title'] = array(
98 'type' => 'select'
99 , 'default' => ''
100 , 'title' => __('Event Title', 'booking')
101 /* translators: 1: Open HTML strong symbol, 2: Close HTML strong symbol. */
102 , 'description' => sprintf( __( 'Select field for assigning to %1$sevent property%2$s' ,'booking'), '<b>', '</b>' )
103 , 'description_tag' => 'span'
104 , 'css' => ''
105 , 'options' => $options
106 , 'group' => 'events_fields'
107 );
108 $this->fields['booking_gcal_events_form_fields_description'] = array(
109 'type' => 'select'
110 , 'default' => ''
111 , 'title' => __('Event Description (optional field)' ,'booking')
112 /* translators: 1: Open HTML strong symbol, 2: Close HTML strong symbol. */
113 , 'description' => sprintf( __( 'Select field for assigning to %1$sevent property%2$s' ,'booking'), '<b>', '</b>' )
114 , 'description_tag' => 'span'
115 , 'css' => ''
116 , 'options' => $options
117 , 'group' => 'events_fields'
118 );
119 $this->fields['booking_gcal_events_form_fields_where'] = array(
120 'type' => 'select'
121 , 'default' => ''
122 , 'title' => __('Location' ,'booking')
123 /* translators: 1: Open HTML strong symbol, 2: Close HTML strong symbol. */
124 , 'description' => sprintf( __( 'Select field for assigning to %1$sevent property%2$s' ,'booking'), '<b>', '</b>' )
125 , 'description_tag' => 'span'
126 , 'css' => ''
127 , 'options' => $options
128 , 'group' => 'events_fields'
129 );
130 ////////////////////////////////////////////////////////////////////////
131
132
133 $options = array();
134 $options[''] = __('Default' ,'booking');
135
136 // structure: $wpbc_booking_region_cities_list["Pacific"]["Fiji"] = "Fiji";
137 $wpbc_booking_region_cities_list = wpbc_get_booking_region_cities_list(); // FixIn: 8.9.4.9.
138
139 foreach ( $wpbc_booking_region_cities_list as $region => $region_cities) {
140
141 //OPTGROUP - Open
142 $options[ $region ] = array(
143 'title' => ucfirst( trim( $region ) )
144 , 'optgroup' => true
145 , 'close' => false );
146
147 foreach ($region_cities as $city_key => $city_title) {
148
149 $options[ trim( $region .'/'. $city_key ) ] = ( trim( $city_title ) );
150 }
151
152 //OPTGROUP - Close
153 $options[ $region . '_close' ] = array(
154 'title' => $region // ucfirst( trim( $option_group_name ) )
155 , 'optgroup' => true
156 , 'close' => true );
157 }
158 $this->fields['booking_gcal_timezone'] = array(
159 'type' => 'select'
160 , 'default' => ''
161 , 'title' => __('Timezone', 'booking')
162 , 'description' => __('Select a city in your required timezone, if you are having problems with dates and times.' ,'booking')
163 , 'description_tag' => 'p'
164 , 'css' => ''
165 , 'options' => $options
166 , 'group' => 'general'
167 );
168
169 // FixIn: 9.5.4.1.
170 $this->fields['booking_ics_import_append_checkout_day'] = array(
171 'type' => 'checkbox'
172 , 'default' => 'On'
173 , 'title' => __('Append check out day', 'booking')
174 , 'label' => __('Append one check out day, during import .ics feeds' ,'booking')
175 , 'description' => ''
176 , 'group' => 'import_advanced'
177 );
178
179 if ( class_exists( 'wpdev_bk_biz_s' ) ) {
180 // FixIn: 8.1.3.29.
181 $this->fields['booking_ics_import_add_change_over_time'] = array(
182 'type' => 'checkbox'
183 , 'default' => 'On'
184 , 'title' => __('Use check in/out time', 'booking')
185 , 'label' => __('Use check in/out time of plugin, during import .ics feeds' ,'booking')
186 , 'description' => ''
187 , 'group' => 'import_advanced'
188 );
189 // FixIn: 8.5.2.3.
190 $this->fields['booking_is_ics_export_only_approved'] = array(
191 'type' => 'checkbox'
192 , 'default' => 'Off'
193 , 'title' => __('Export only approved bookings', 'booking')
194 , 'label' => __('Enable of export only approved bookings in .ics feeds' ,'booking')
195 , 'description' => ''
196 , 'group' => 'export_advanced'
197 );
198
199 // FixIn: 8.8.3.19.
200 $this->fields['booking_is_ics_export_imported_bookings'] = array(
201 'type' => 'select'
202 , 'default' => ''
203 , 'title' => __('Export bookings type', 'booking')
204 , 'description' => __('Select which type of bookings to export' ,'booking')
205 , 'description_tag' => 'p'
206 , 'css' => ''
207 , 'options' => array (
208 '' => __('All bookings','booking'),
209 'plugin' => __('Bookings created in Booking Calendar','booking'),
210 'imported' => __('Imported bookings','booking'),
211 )
212 , 'group' => 'export_advanced'
213 );
214 }
215 // FixIn: 10.3.0.1.
216 $this->fields['booking_g_cal_export_no_data'] = array(
217 'type' => 'checkbox'
218 , 'default' => 'Off'
219 , 'title' => __('Remove Details in Google Calendar Export', 'booking')
220 , 'label' => __('Enable this option to exclude booking summary details when exporting to Google Calendar using the \'Add to Google Calendar\' button.' ,'booking')
221 , 'description' => ''
222 , 'group' => 'export_advanced'
223 );
224
225 // FixIn: 8.5.1.1.
226 /*
227 // FixIn: 8.4.7.1.
228 $this->fields['booking_ics_force_import'] = array(
229 'type' => 'checkbox'
230 , 'default' => 'Off'
231 , 'title' => __('Force import', 'booking')
232 , 'label' => __('Import bookings without checking, if such bookings already have been imported.' ,'booking')
233 , 'description' => ''
234 , 'group' => 'import_advanced'
235 );
236 /**/
237 //FixIn: 8.4.7.12 //FixIn: // FixIn: 9.1.2.6.
238 $this->fields['booking_ics_force_trash_before_import'] = array(
239 'type' => 'select'
240 , 'default' => 'Off'
241 , 'title' => __('Trash / delete all imported bookings before new import', 'booking')
242 , 'description' => __('Move all previously imported bookings to trash or permanently delete before new import bookings. Its can resolve issue of updating deleted and edited events in external sources. Its work only, if you are using one source (.ics feed) for importing into specific booking resource!' ,'booking')
243 , 'description_tag' => 'p'
244 , 'css' => ''
245 , 'options' => array ( // FixIn: 9.7.3.9.
246 'Off' => __( 'Do nothing', 'booking' ),
247 'On' => __( 'Trash imported bookings', 'booking' ),
248 'delete' => __( 'Permanently delete', 'booking' )
249 )
250 , 'group' => 'import_advanced'
251 );
252
253
254 $this->fields['booking_condition_import_only_new'] = array(
255 'type' => 'checkbox'
256 , 'default' => 'Off'
257 , 'title' => __( 'Import conditions', 'booking' )//__('Import only new events', 'booking')
258 , 'label' => '<strong>' . esc_html__( 'Import Only New Events', 'booking' ) . '</strong> - ' . __( 'Import only if the event has not been imported before.', 'booking' )
259 , 'description' => ''
260 , 'group' => 'import_advanced'
261 );
262 $this->fields['booking_condition_import_if_available'] = array(
263 'type' => 'checkbox'
264 , 'default' => 'Off'
265 , 'title' => ''//__('Import if dates available', 'booking')
266 , 'label' => '<strong>' . esc_html__( 'Import if Dates Available', 'booking' ) . '</strong> - ' . esc_html__( 'Import only if dates are available in the source calendar.', 'booking' )
267 , 'description' => ''
268 , 'group' => 'import_advanced'
269 );
270
271
272 ////////////////////////////////////////////////////////////////////////
273
274 }
275
276 }
277
278
279 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
280 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
281
282
283 /**
284 * Show Content
285 * Update Content
286 * Define Slug
287 * Define where to show
288 */
289 class WPBC_Page_SettingsGeneralSync extends WPBC_Page_Structure {
290
291 public $settings_api = false;
292
293
294 /**
295 * API - for Fields of this Settings Page
296 *
297 * @param array $init_fields_values - array of init form fields data - this array can ovveride "default" fields and loaded data.
298 * @return object API
299 */
300 public function get_api( $init_fields_values = array() ){
301
302 if ( $this->settings_api === false ) {
303 $this->settings_api = new WPBC_API_SettingsGeneralSync( 'general_sync' , $init_fields_values );
304 }
305 return $this->settings_api;
306 }
307
308
309 public function in_page() {
310 return 'wpbc-settings';
311 }
312
313
314 public function tabs() {
315
316 $tabs = array();
317
318 $tabs[ 'sync' ] = array(
319 'title' => __( 'Sync', 'booking') // Title of TAB
320 , 'page_title'=> __( 'Sync', 'booking') // Title of Page
321 , 'hint' => __('Import' ,'booking') . ' / ' . __('Export' ,'booking')
322 //, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
323 //, 'position' => '' // 'left' || 'right' || ''
324 //, 'css_classes'=> '' // CSS class(es)
325 //, 'icon' => '' // Icon - link to the real PNG img
326 , 'font_icon' => 'wpbc_icn_sync_alt' // CSS definition of forn Icon
327 //, 'default' => false // Is this tab activated by default or not: true || false.
328 //, 'disabled' => false // Is this tab disbaled: true || false.
329 //, 'hided' => false // Is this tab hided: true || false.
330 , 'subtabs' => array()
331 );
332
333
334 $subtabs = array();
335
336 $subtabs[ 'general' ] = array(
337 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
338 , 'title' => __( 'Sync Options', 'booking' ) // Title of TAB
339 , 'page_title' => __( 'Sync Options', 'booking' ) // Title of Page
340 , 'hint' => __( 'Configure import/export rules, timezones, and which fields to include in sync operations.', 'booking' ) // Hint.
341 , 'link' => '' // link
342 , 'position' => '' // 'left' || 'right' || ''
343 , 'css_classes' => '' // CSS class(es)
344 //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
345 , 'font_icon' => 'wpbc_icn_cloud_sync'
346 , 'default' => true // Is this sub tab activated by default or not: true || false.
347 , 'disabled' => false // Is this sub tab deactivated: true || false.
348 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
349 , 'content' => 'content' // Function to load as conten of this TAB
350
351 );
352
353 $tabs[ 'sync' ]['subtabs'] = $subtabs;
354
355
356 return $tabs;
357 }
358
359
360 /** Show Content of Settings page */
361 public function content() {
362
363 $this->css();
364
365 ////////////////////////////////////////////////////////////////////////
366 // Checking
367 ////////////////////////////////////////////////////////////////////////
368
369 do_action( 'wpbc_hook_settings_page_header', 'ics_general_settings' ); // Define Notices Section and show some static messages, if needed
370
371 if ( ! wpbc_is_mu_user_can_be_here('activated_user') ) return false; // Check if MU user activated, otherwise show Warning message.
372
373 // if ( ! wpbc_is_mu_user_can_be_here('only_super_admin') ) return false; // User is not Super admin, so exit. Basically its was already checked at the bottom of the PHP file, just in case.
374
375
376
377 ////////////////////////////////////////////////////////////////////////
378 // Load Data
379 ////////////////////////////////////////////////////////////////////////
380
381 $this->get_api(); // Load fields Data from DB
382
383 /**
384 * O v e r l o a d some values for our pseudo options - during normal opening of page
385 * if we making saving, so we need to overload these options
386 * one more time
387 */
388 $booking_gcal_events_form_fields = get_bk_option( 'booking_gcal_events_form_fields');
389 $booking_gcal_events_form_fields = maybe_unserialize( $booking_gcal_events_form_fields );
390
391 if (isset($booking_gcal_events_form_fields['title']))
392 $this->get_api()->set_field_value( 'booking_gcal_events_form_fields_title', $booking_gcal_events_form_fields['title'] );
393
394 if (isset($booking_gcal_events_form_fields['description']))
395 $this->get_api()->set_field_value( 'booking_gcal_events_form_fields_description', $booking_gcal_events_form_fields['description'] );
396
397 if (isset($booking_gcal_events_form_fields['where']))
398 $this->get_api()->set_field_value( 'booking_gcal_events_form_fields_where', $booking_gcal_events_form_fields['where'] );
399
400 $this->get_api()->set_values_to_fields();
401
402
403 ////////////////////////////////////////////////////////////////////////
404 // S u b m i t Main Form
405 ////////////////////////////////////////////////////////////////////////
406
407 $submit_form_name = 'wpbc_general_sync'; // Define form name
408
409 // $this->get_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields (like required field) before submit.
410
411 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
412 if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) {
413
414 // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
415 $nonce_gen_time = check_admin_referer( 'wpbc_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page
416
417 // Save Changes
418 $this->update();
419 }
420
421 ////////////////////////////////////////////////////////////////////////
422 // JavaScript: Tooltips, Popover, Datepick (js & css)
423 ////////////////////////////////////////////////////////////////////////
424
425 echo '<span class="wpdevelop">';
426
427 wpbc_js_for_bookings_page();
428
429 echo '</span>';
430
431 ?><div class="clear" style="margin-bottom:0px;"></div><?php
432
433
434 ////////////////////////////////////////////////////////////////////////
435 // Content ////////////////////////////////////////////////////////////
436 ?>
437 <div class="clear" style="margin-bottom:0px;"></div>
438 <span class="metabox-holder">
439 <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" autocomplete="off">
440 <?php
441 // N o n c e field, and key for checking S u b m i t
442 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
443 ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" /><?php
444 ?><div class="clear"></div><?php
445
446 ?><div class="clear" style="height:10px;"></div><?php
447
448
449 wpbc_open_meta_box_section( 'wpbc_settings_general_sync_events_general', __('General Settings' ,'booking') );
450
451 $this->get_api()->show( 'general' );
452
453 wpbc_close_meta_box_section();
454
455
456 wpbc_open_meta_box_section( 'wpbc_settings_general_sync_events_fields', __('Import' ,'booking') . ' > ' . __('Assign events fields to specific booking form field' ,'booking') );
457
458 $this->get_api()->show( 'events_fields' );
459
460 wpbc_close_meta_box_section();
461
462 // FixIn: 8.5.1.1.
463 // if ( class_exists( 'wpdev_bk_biz_s' ) ) {
464
465 wpbc_open_meta_box_section( 'wpbc_settings_general_sync_import', __( 'Import', 'booking' ) . ' ' . __( 'Advanced', 'booking' ) );
466
467 $this->get_api()->show( 'import_advanced' );
468
469 wpbc_close_meta_box_section();
470
471
472 wpbc_open_meta_box_section( 'wpbc_settings_general_sync_export', __( 'Export', 'booking' ) . ' ' . __( 'Advanced', 'booking' ) );
473
474 $this->get_api()->show( 'export_advanced' );
475
476 wpbc_close_meta_box_section();
477 // }
478 ?>
479
480 <div class="clear"></div>
481
482 <input type="submit" value="<?php esc_attr_e('Save Changes','booking'); ?>" class="button button-primary wpbc_submit_button" />
483 <?php
484
485 ?>
486 </form>
487 </span>
488 <?php
489
490 do_action( 'wpbc_hook_settings_page_footer', 'ics_general_settings' );
491
492 $this->enqueue_js();
493
494 }
495
496
497 /** Save Chanages */
498 public function update() {
499 // if ( function_exists( 'wpbc_general_sync__update') )
500 // wpbc_general_sync__update();
501
502 // Get Validated Email fields
503 $validated_fields = $this->get_api()->validate_post();
504
505 $validated_fields = apply_filters( 'wpbc_fields_before_saving_to_db__general_sync', $validated_fields ); //Hook for validated fields.
506
507 //debuge($validated_fields);
508
509 $this->get_api()->save_to_db( $validated_fields );
510
511 wpbc_show_changes_saved_message();
512 }
513
514
515 // <editor-fold defaultstate="collapsed" desc=" CSS & JS " >
516
517 /** CSS for this page */
518 private function css() {
519 ?>
520 <style type="text/css">
521 .wpbc_import_ics_bar .wpbc_import_btn,
522 .wpbc_import_ics_bar .wpbc_upload_btn{
523 float:left;
524 margin:9px 5px 10px 1px;
525
526 }
527 .wpbc_import_ics_bar .wpbc_import_div {
528 float:left;
529 width:70%;
530 }
531 .wpbc_import_ics_bar .wpbc_import_br_selection,
532 .wpbc_import_ics_bar .wpbc_import_url {
533 float:left;
534 width:28%;
535 height: 2em;
536 padding: 2px;
537 border-radius: 0;
538 margin:10px 5px 10px 1px;
539 }
540 .wpbc_import_ics_bar .wpbc_import_url {
541 width:70%;
542 padding: 2px 5px;
543 }
544 .wpbc_system_info_log {
545 font-size: 11px;
546 line-height: 1.5em;
547 border: 2px dashed #e85;
548 padding: 5px 20px;
549 display: none;
550 }
551 /**********************************************************************************************************/
552 .wpbc-help-message {
553 border:none;
554 }
555 /* toolbar fix */
556 .wpdevelop .visibility_container .control-group {
557 margin: 2px 8px 3px 0; /* margin: 0 8px 5px 0; */ /* FixIn: 9.5.4.8 */
558 }
559 /* Selectbox element in toolbar */
560 .visibility_container select optgroup{
561 color:#999;
562 vertical-align: middle;
563 font-style: italic;
564 font-weight: 400;
565 }
566 .visibility_container select option {
567 padding:5px;
568 font-weight: 600;
569 }
570 .visibility_container select optgroup option{
571 padding: 5px 20px;
572 color:#555;
573 font-weight: 600;
574 }
575 #wpbc_create_new_custom_form_name_fields {
576 width: 360px;
577 display:none;
578 }
579 @media (max-width: 782px) {
580 .wpbc_import_ics_bar .wpbc_import_br_selection,
581 .wpbc_import_ics_bar .wpbc_import_div {
582 float:none;
583 width:100%;
584 }
585 }
586 @media (max-width: 399px) {
587 #wpbc_create_new_custom_form_name_fields {
588 width: 100%;
589 }
590 }
591 </style>
592 <?php
593 }
594
595
596
597 /**
598 * Add Custon JavaScript - for some specific settings options
599 * Executed After post content, after initial definition of settings, and possible definition after POST request.
600 *
601 * @param type $menu_slug
602 */
603 private function enqueue_js(){
604
605 // JavaScript //////////////////////////////////////////////////////////////
606
607 $js_script = '';
608
609 // //Show|Hide grayed section
610 // $js_script .= "
611 // if ( ! jQuery('#ics_general_booking_gcal_auto_import_is_active').is(':checked') ) {
612 // jQuery('.wpbc_tr_auto_import').addClass('hidden_items');
613 // }
614 // ";
615
616 // // Hide|Show on Click Radion
617 // $js_script .= " jQuery('input[name=\"paypal_pro_hosted_solution\"]').on( 'change', function(){
618 // jQuery('.wpbc_sub_settings_paypal_account_type').addClass('hidden_items');
619 // if ( jQuery('#paypal_type_standard').is(':checked') ) {
620 // jQuery('.wpbc_sub_settings_paypal_standard').removeClass('hidden_items');
621 // } else {
622 // jQuery('.wpbc_sub_settings_paypal_pro_hosted').removeClass('hidden_items');
623 // }
624 // } ); ";
625
626 ////////////////////////////////////////////////////////////////////////
627
628
629 // Eneque JS to the footer of the page
630 wpbc_enqueue_js( $js_script );
631 }
632
633 // </editor-fold>
634
635 }
636 add_action('wpbc_menu_created', array( new WPBC_Page_SettingsGeneralSync() , '__construct') ); // Executed after creation of Menu
637
638
639 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
640 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
641
642
643 /**
644 * Validate some fields during saving to DB
645 * Skip saving some pseudo options, instead of that creare new real option.
646 *
647 * @param array $validated_fields
648 * @return type
649 */
650 function wpbc_fields_before_saving_to_db__general_sync( $validated_fields ) {
651
652 // Set new option based on pseudo options
653 $validated_fields['booking_gcal_events_form_fields'] = array(
654 'title' => $validated_fields['booking_gcal_events_form_fields_title']
655 , 'description' => $validated_fields['booking_gcal_events_form_fields_description']
656 , 'where' => $validated_fields['booking_gcal_events_form_fields_where']
657 );
658 // Unset several pseudo options.
659 unset( $validated_fields['booking_gcal_events_form_fields_title'] );
660 unset( $validated_fields['booking_gcal_events_form_fields_description'] );
661 unset( $validated_fields['booking_gcal_events_form_fields_where'] );
662
663 return $validated_fields;
664 }
665 add_filter('wpbc_fields_before_saving_to_db__general_sync', 'wpbc_fields_before_saving_to_db__general_sync');
666
667
668
669 /**
670 * Override fields array of Settings page, AFTER saving to DB. Some fields have to have different Values.
671 * Set here values for our pseudo-options, after saving to DB
672 * Because they was not overloading during this saving
673 *
674 * @param array $fields
675 * @param string $page_id
676 * @return array - fields
677 */
678 function wpbc_fields_after_saving_to_db__general_sync( $fields, $page_id ) {
679
680 if ( $page_id == 'general_sync' ) { // Check our API ID relative saving of this settings page
681
682 $booking_gcal_events_form_fields = get_bk_option( 'booking_gcal_events_form_fields');
683 $booking_gcal_events_form_fields = maybe_unserialize( $booking_gcal_events_form_fields );
684
685 if (isset($booking_gcal_events_form_fields['title']))
686 $fields[ 'booking_gcal_events_form_fields_title' ]['value'] = $booking_gcal_events_form_fields['title'];
687
688 if (isset($booking_gcal_events_form_fields['description']))
689 $fields[ 'booking_gcal_events_form_fields_description' ]['value'] = $booking_gcal_events_form_fields['description'];
690
691 if (isset($booking_gcal_events_form_fields['where']))
692 $fields[ 'booking_gcal_events_form_fields_where' ]['value'] = $booking_gcal_events_form_fields['where'];
693
694 }
695 return $fields;
696 }
697 add_filter('wpbc_fields_after_saving_to_db', 'wpbc_fields_after_saving_to_db__general_sync', 10, 2);
698