PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.20
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.20
2.1.22 2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 All 56 releases
booking-manager / core / admin / api-settings.php

api-settings.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.0.20, at core/admin/api-settings.php

673 lines 44.7 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 * @package General Settings API - Saving different options
5 * @category Settings API
6 * @author wpdevelop
7 *
8 * @web-site https://oplugins.com/
9 * @email [email protected]
10 * @modified 2016-02-24
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 // General Settings API - Saving different options
17 class WPBM_Settings_API_General extends WPBM_Settings_API {
18
19
20 /** Override Settings API Constructor
21 * During creation, system try to load values from DB, if exist.
22 *
23 * @param type $id - of Settings
24 */
25 public function __construct( $id = '' ){
26
27 $options = array(
28 'db_prefix_option' => '' // 'wpbm_'
29 , 'db_saving_type' => 'separate'
30 , 'id' => 'set_gen'
31 );
32
33 $id = empty($id) ? $options['id'] : $id;
34
35 parent::__construct( $id, $options ); // Define ID of Setting page and options
36
37 add_action( 'wpbm_after_settings_content', array($this, 'enqueue_js'), 10, 3 );
38 }
39
40
41 /** Init all fields rows for settings page */
42 public function init_settings_fields() {
43
44 $this->fields = array();
45
46 $default_options_values = wpbm_get_default_options();
47
48
49 // <editor-fold defaultstate="collapsed" desc=" G e n e r a l " >
50
51
52 // </editor-fold>
53
54
55 // <editor-fold defaultstate="collapsed" desc=" Miscellaneous " >
56
57
58 // Dates Format ////////////////////////////////////////////////////////
59
60 //FixIn: 2.0.12.3
61 $this->fields['wpbm_is_hide_details'] = array(
62 'type' => 'checkbox'
63 , 'default' => $default_options_values['wpbm_is_hide_details'] //'Off'
64 , 'title' => __('Remove booking details in exported .ics feed' , 'booking-manager')
65 , 'label' => __('Check this box to remove details (summary and description) from .ics feed during export process.' , 'booking-manager')
66 , 'description' => ''
67 , 'group' => 'wpbm_listing'
68 );
69
70
71 $this->fields['wpbm_start_day_weeek'] = array(
72 'type' => 'select'
73 , 'default' => $default_options_values[ 'wpbm_start_day_weeek' ] // '2'
74 // , 'value' => false
75 , 'title' => __('Start Day of the week', 'booking-manager')
76 , 'description' => __('Select your start day of the week' ,'booking-manager')
77 , 'options' => array(
78 '0' => __('Sunday' ,'booking-manager')
79 , '1' => __('Monday' ,'booking-manager')
80 , '2' => __('Tuesday' ,'booking-manager')
81 , '3' => __('Wednesday' ,'booking-manager')
82 , '4' => __('Thursday' ,'booking-manager')
83 , '5' => __('Friday' ,'booking-manager')
84 , '6' => __('Saturday' ,'booking-manager')
85 )
86 , 'group' => 'wpbm_listing'
87 );
88
89
90 $this->fields['wpbm_date_format_html_prefix'] = array(
91 'type' => 'pure_html'
92 , 'group' => 'wpbm_listing'
93 , 'html' => '<tr valign="top" class="wpbm_tr_set_gen_wpbm_date_format">
94 <th scope="row">'.
95 WPBM_Settings_API::label_static( 'set_gen_wpbm_date_format'
96 , array( 'title'=> __('Date Format' , 'booking-manager'), 'label_css' => 'margin: 0.25em 0 !important;vertical-align: middle;' ) )
97 .'</th>
98 <td><fieldset>'
99 );
100 $field_options = array();
101 foreach ( array( __('F j, Y'), 'Y/m/d', 'm/d/Y', 'd/m/Y' ) as $format ) {
102 $field_options[ esc_attr($format) ] = array( 'title' => date_i18n( $format ) );
103 }
104 $field_options['custom'] = array( 'title' => __('Custom' , 'booking-manager') . ':', 'attr' => array( 'id' => 'date_format_selection_custom' ) );
105
106 $this->fields['wpbm_date_format_selection'] = array(
107 'type' => 'radio'
108 , 'default' => get_option('date_format')
109 , 'options' => $field_options
110 , 'group' => 'wpbm_listing'
111 , 'only_field' => true
112 );
113
114 $wpbm_date_format = get_wpbm_option( 'wpbm_date_format');
115 $this->fields['wpbm_date_format'] = array(
116 'type' => 'text'
117 , 'default' => $default_options_values['wpbm_date_format'] //get_option('date_format')
118 , 'value' => htmlentities( $wpbm_date_format ) // Display value of this field in specific way
119 , 'group' => 'wpbm_listing'
120 , 'placeholder' => get_option('date_format')
121 , 'css' => 'width:10em;'
122 , 'only_field' => true
123 );
124
125 $this->fields['wpbm_date_format_html_sufix'] = array(
126 'type' => 'pure_html'
127 , 'group' => 'wpbm_listing'
128 , 'html' => ' <span class="description"><code>' . date_i18n( $wpbm_date_format ) . '</code></span>'
129 . '<p class="description">'
130 . sprintf(__('Type your date format for emails and the item table. %sDocumentation on date formatting%s' , 'booking-manager'),'<br/><a href="http://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">','</a>')
131 . ' </p>
132 </fieldset>
133 </td>
134 </tr>'
135 );
136
137 // Time Format
138 // $this->fields = apply_filters( 'wpbm_settings_wpbm_time_format', $this->fields, $default_options_values );
139
140 // Time Format /////////////////////////////////////////////////////////////
141 $this->fields['wpbm_time_format_html_prefix'] = array(
142 'type' => 'pure_html'
143 , 'group' => 'wpbm_listing'
144 , 'html' => '<tr valign="top" class="wpbc_tr_set_gen_wpbm_time_format">
145 <th scope="row">'.
146 WPBM_Settings_API::label_static( 'set_gen_wpbm_time_format'
147 , array( 'title'=> __('Time Format' ,'booking-manager'), 'label_css' => 'margin: 0.25em 0 !important;vertical-align: middle;' ) )
148 .'</th>
149 <td><fieldset>'
150 );
151 $field_options = array();
152 foreach ( array( 'g:i a', 'g:i A', 'H:i' ) as $format ) {
153 $field_options[ esc_attr($format) ] = array( 'title' => date_i18n( $format ) );
154 }
155 $field_options['custom'] = array( 'title' => __('Custom' ,'booking-manager') . ':', 'attr' => array( 'id' => 'time_format_selection_custom' ) );
156
157 $this->fields['wpbm_time_format_selection'] = array(
158 'type' => 'radio'
159 , 'default' => 'H:i'
160 , 'options' => $field_options
161 , 'group' => 'wpbm_listing'
162 , 'only_field' => true
163 );
164
165 $wpbm_time_format = get_wpbm_option( 'wpbm_time_format');
166 $this->fields['wpbm_time_format'] = array(
167 'type' => 'text'
168 , 'default' => $default_options_values['wpbm_time_format'] //'H:i'
169 , 'value' => htmlentities( $wpbm_time_format ) // Display value of this field in specific way
170 , 'group' => 'wpbm_listing'
171 , 'placeholder' => 'H:i'
172 , 'css' => 'width:5em;'
173 , 'only_field' => true
174 );
175
176 $this->fields['wpbm_time_format_html_sufix'] = array(
177 'type' => 'pure_html'
178 , 'group' => 'wpbm_listing'
179 , 'html' => ' <span class="description"><code>' . date_i18n( $wpbm_time_format ) . '</code></span>'
180 . '<p class="description">'
181 . sprintf(__('Type your time format for emails and listing. %sDocumentation on time formatting%s' ,'booking-manager'),'<br/><a href="http://php.net/manual/en/function.date.php" target="_blank">','</a>')
182 . ' </p>
183 </fieldset>
184 </td>
185 </tr>'
186 );
187
188 // </editor-fold>
189
190
191 // <editor-fold defaultstate="collapsed" desc=" Advanced " >
192
193
194 //Show | Hide links for Advanced JavaScript section
195 $this->fields['wpbm_advanced_js_loading_settings'] = array(
196 'type' => 'html'
197 , 'html' =>
198 '<a id="wpbm_show_advanced_section_link_show" class="wpbm_expand_section_link" href="javascript:void(0)">+ ' . __('Show advanced settings of JavaScript loading' , 'booking-manager') . '</a>'
199 . '<a id="wpbm_show_advanced_section_link_hide" class="wpbm_expand_section_link" href="javascript:void(0)" style="display:none;">- ' . __('Hide advanced settings of JavaScript loading' , 'booking-manager') . '</a>'
200 , 'cols' => 2
201 , 'group' => 'advanced'
202 );
203 /*
204 $this->fields['wpbm_is_not_load_bs_script_in_client'] = array(
205 'type' => 'checkbox'
206 , 'default' => $default_options_values['wpbm_is_not_load_bs_script_in_client'] //'Off'
207 , 'title' => __('Disable Bootstrap loading on Front-End' , 'booking-manager')
208 , 'label' => __(' If your theme or some other plugin is load the BootStrap JavaScripts, you can disable loading of this script by this plugin.' , 'booking-manager')
209 , 'description' => ''
210 , 'group' => 'advanced'
211 , 'tr_class' => 'wpbm_advanced_js_loading_settings wpbm_sub_settings_grayed hidden_items'
212 );
213 */
214 $this->fields['wpbm_is_not_load_bs_script_in_admin'] = array(
215 'type' => 'checkbox'
216 , 'default' => $default_options_values['wpbm_is_not_load_bs_script_in_admin'] //'Off'
217 , 'title' => __('Disable Bootstrap loading on Back-End' , 'booking-manager')
218 , 'label' => __(' If your theme or some other plugin is load the BootStrap JavaScripts, you can disable loading of this script by this plugin.' , 'booking-manager')
219 , 'description' => ''
220 , 'group' => 'advanced'
221 , 'tr_class' => 'wpbm_advanced_js_loading_settings wpbm_sub_settings_grayed hidden_items'
222 );
223 /*
224 $this->fields['hr_calendar_before_is_load_js_css_on_specific_pages'] = array( 'type' => 'hr', 'group' => 'advanced', 'tr_class' => 'wpbm_advanced_js_loading_settings wpbm_sub_settings_grayed hidden_items' );
225 $this->fields['wpbm_is_load_js_css_on_specific_pages'] = array(
226 'type' => 'checkbox'
227 , 'default' => $default_options_values['wpbm_is_load_js_css_on_specific_pages'] //'Off'
228 , 'title' => __('Load JS and CSS files only on specific pages' , 'booking-manager')
229 , 'label' => __('Activate loading of CSS and JavaScript files of plugin only at specific pages.' , 'booking-manager')
230 , 'description' => ''
231 , 'group' => 'advanced'
232 , 'tr_class' => 'wpbm_advanced_js_loading_settings wpbm_sub_settings_grayed hidden_items'
233 , 'is_demo_safe' => wpbm_is_this_demo()
234 );
235 $this->fields['wpbm_pages_for_load_js_css'] = array(
236 'type' => 'textarea'
237 , 'default' => $default_options_values['wpbm_pages_for_load_js_css'] //''
238 , 'placeholder' => '/wpbm-form/'
239 , 'title' => __('Relative URLs of pages, where to load plugin CSS and JS files' , 'booking-manager')
240 , 'description' => sprintf(__('Enter relative URLs of pages, where you have Booking Manager elements (item forms or availability calendars). Please enter one URL per line. Example: %s' , 'booking-manager'),'<code>/wpbm-form/</code>')
241 ,'description_tag' => 'p'
242 , 'css' => 'width:100%'
243 , 'rows' => 5
244 , 'group' => 'advanced'
245 , 'tr_class' => 'wpbm_advanced_js_loading_settings wpbm_is_load_js_css_on_specific_pages wpbm_sub_settings_grayed hidden_items'
246 , 'is_demo_safe' => wpbm_is_this_demo()
247 );
248 */
249 if ( wpbm_is_this_demo() )
250 $this->fields['wpbm_pages_for_load_js_css_demo'] = array( 'group' => 'advanced', 'type' => 'html', 'html' => wpbm_get_warning_text_in_demo_mode(), 'cols' => 2 , 'tr_class' => 'wpbm_advanced_js_loading_settings wpbm_sub_settings_grayed hidden_items' );
251
252
253 /*
254 // Show settings of powered by notice
255 $this->fields['wpbm_advanced_powered_by_notice_settings'] = array(
256 'type' => 'html'
257 , 'html' =>
258 '<a id="wpbm_powered_by_link_show" class="wpbm_expand_section_link" href="javascript:void(0)">+ ' . __('Show settings of powered by notice' , 'booking-manager') . '</a>'
259 . '<a id="wpbm_powered_by_link_hide" class="wpbm_expand_section_link" href="javascript:void(0)" style="display:none;">- ' . __('Hide settings of powered by notice' , 'booking-manager') . '</a>'
260 , 'cols' => 2
261 , 'group' => 'advanced'
262 );
263
264 $this->fields['wpbm_wpbm_copyright_adminpanel'] = array(
265 'type' => 'checkbox'
266 , 'default' => $default_options_values['wpbm_wpbm_copyright_adminpanel'] //'On'
267 , 'title' => __('Help and info notices' , 'booking-manager')
268 , 'label' => sprintf(__(' Turn On/Off version notice and help link to rate plugin at admin panel.' , 'booking-manager'),'oplugins.com')
269 , 'description' => ''
270 , 'group' => 'advanced'
271 , 'tr_class' => 'wpbm_is_show_powered_by_notice wpbm_sub_settings_grayed hidden_items'
272 );
273 */
274 if ( ( ! wpbm_is_this_demo() ) && ( current_user_can( 'activate_plugins' ) ) ) {
275
276
277 $this->fields['help_plugin_system_info'] = array(
278 'type' => 'help'
279 , 'value' => array() //FixIn: 2.0.1.4
280 , 'class' => ''
281 , 'css' => 'margin:0;padding:0;border:0;'
282 , 'description' => ''
283 , 'cols' => 2
284 , 'group' => 'advanced'
285 , 'tr_class' => ''
286 , 'description_tag' => 'p'
287 );
288
289 $this->fields['help_plugin_system_info']['value'][] =
290 '<div class="clear"></div><hr/><center><a class="button button" href="'
291 . wpbm_get_settings_url()
292 . '&system_info=show#wpbm_general_settings_system_info_metabox">'
293 . __('Plugin System Info' , 'booking-manager')
294 . '</a></center>';
295 }
296
297 // </editor-fold>
298
299
300 // <editor-fold defaultstate="collapsed" desc=" Information " >
301 if ( function_exists( 'wpbm_get_dashboard_info' ) ) {
302 $this->fields['wpbm_information'] = array(
303 'type' => 'html'
304 , 'html' => wpbm_get_dashboard_info()
305 , 'cols' => 2
306 , 'group' => 'information'
307 );
308 }
309 // </editor-fold>
310
311
312 // <editor-fold defaultstate="collapsed" desc=" User permissions for plugin menu pages " >
313
314
315 $this->fields['wpbm_menu_position'] = array(
316 'type' => 'select'
317 , 'default' => 'top'
318 , 'title' => __('Plugin menu position', 'booking-manager')
319 , 'description' => ''
320 , 'options' => array(
321 'top' => __('Top', 'booking-manager')
322 , 'middle' => __('Middle', 'booking-manager')
323 , 'bottom' => __('Bottom', 'booking-manager')
324 )
325 , 'group' => 'permissions'
326 , 'is_demo_safe' => wpbm_is_this_demo()
327 );
328
329 // $this->fields['wpbm_user_role_wpbm_header'] = array(
330 // 'type' => 'pure_html'
331 // , 'group' => 'permissions'
332 // , 'html' => '<tr valign="top">
333 // <th scope="row" colspan="2">
334 // <hr/><p><strong>' . wp_kses_post( __('User permissions for plugin menu pages' , 'booking-manager') ) . ':</strong></p>
335 // </th>
336 // </tr'
337 // );
338
339 $field_options = array();
340 $field_options['subscriber'] = translate_user_role('Subscriber');
341 $field_options['contributor'] = translate_user_role('Contributor');
342 $field_options['author'] = translate_user_role('Author');
343 $field_options['editor'] = translate_user_role('Editor');
344 $field_options['administrator'] = translate_user_role('Administrator');
345
346 $this->fields['wpbm_user_role_master'] = array(
347 'type' => 'select'
348 , 'default' => $default_options_values['wpbm_user_role_master'] //'editor'
349 , 'title' => __('Permission for plugin menu', 'booking-manager')
350 , 'description' => ''
351 , 'options' => $field_options
352 , 'group' => 'permissions'
353 , 'is_demo_safe' => wpbm_is_this_demo()
354 );
355 // $this->fields['wpbm_user_role_settings'] = array(
356 // 'type' => 'select'
357 // , 'default' => $default_options_values['wpbm_user_role_settings'] //'administrator'
358 // , 'title' => __('Settings', 'booking-manager')
359 // , 'description' => __('Select user access level for the menu pages of plugin' , 'booking-manager')
360 // , 'description_tag' => 'p'
361 // , 'options' => $field_options
362 // , 'group' => 'permissions'
363 // , 'is_demo_safe' => wpbm_is_this_demo()
364 // );
365
366 if ( wpbm_is_this_demo() )
367 $this->fields['wpbm_user_role_settings_demo'] = array( 'group' => 'permissions', 'type' => 'html', 'html' => wpbm_get_warning_text_in_demo_mode(), 'cols' => 2 );
368
369
370 // </editor-fold>
371
372
373 // <editor-fold defaultstate="collapsed" desc=" Uninstall " >
374 $this->fields['wpbm_is_delete_if_deactive'] = array(
375 'type' => 'checkbox'
376 , 'default' => $default_options_values['wpbm_is_delete_if_deactive'] //'Off'
377 , 'title' => __('Delete plugin settings, when plugin deactivated' , 'booking-manager')
378 , 'label' => __('Check this box to delete plugin settings options, when you uninstall this plugin.' , 'booking-manager')
379 , 'description' => ''
380 , 'group' => 'uninstall'
381 );
382 // </editor-fold>
383
384
385 //debuge($this->fields);die;
386 }
387
388
389 /** Add Custon JavaScript - for some specific settings options
390 * Need to executes after showing of entire settings page (on hook: wpbm_after_settings_content).
391 * After initial definition of settings, and possible definition after POST request.
392 *
393 * @param type $menu_slug
394 *
395 */
396 public function enqueue_js( $menu_slug, $active_page_tab, $active_page_subtab ) {
397
398 $js_script = '';
399
400 // Hide Legend items
401 $js_script .= "
402 if ( ! jQuery('#set_gen_wpbm_is_show_legend').is(':checked') ) {
403 jQuery('.wpbm_calendar_legend_items').addClass('hidden_items');
404 }
405 ";
406 // Hide or Show Legend items on click checkbox
407 $js_script .= " jQuery('#set_gen_wpbm_is_show_legend').on( 'change', function(){
408 if ( this.checked ) {
409 jQuery('.wpbm_calendar_legend_items').removeClass('hidden_items');
410 } else {
411 jQuery('.wpbm_calendar_legend_items').addClass('hidden_items');
412 }
413 } ); ";
414 // Thank you Message or Page
415 $js_script .= "
416 if ( jQuery('#type_of_thank_you_message_message').is(':checked') ) {
417 jQuery('.wpbm_calendar_thank_you_page').addClass('hidden_items');
418 }
419 if ( jQuery('#type_of_thank_you_message_page').is(':checked') ) {
420 jQuery('.wpbm_calendar_thank_you_message').addClass('hidden_items');
421 }
422 ";
423 $js_script .= " jQuery('input[name=\"set_gen_wpbm_type_of_thank_you_message\"]').on( 'change', function(){
424 if ( jQuery('#type_of_thank_you_message_message').is(':checked') ) {
425 jQuery('.wpbm_calendar_thank_you_message').removeClass('hidden_items');
426 jQuery('.wpbm_calendar_thank_you_page').addClass('hidden_items');
427 } else {
428 jQuery('.wpbm_calendar_thank_you_message').addClass('hidden_items');
429 jQuery('.wpbm_calendar_thank_you_page').removeClass('hidden_items');
430 }
431 } ); ";
432
433 // Default calendar view mode (Item Listing) - set active / inctive options depend from resource selection.
434 $js_script .= " jQuery('#set_gen_wpbm_view_days_num').on( 'focus', function(){
435 if ( jQuery('#set_gen_wpbm_default_wpbm_resource').length > 0 ) {
436 jQuery('#set_gen_wpbm_default_wpbm_resource').bind('change', function() {
437 jQuery('#set_gen_wpbm_view_days_num option:eq(2)').prop('selected', true);
438 });
439 if ( jQuery('#set_gen_wpbm_default_wpbm_resource').val() == '' ) {
440 jQuery('#set_gen_wpbm_view_days_num option:eq(0)').prop('disabled', false);
441 jQuery('#set_gen_wpbm_view_days_num option:eq(1)').prop('disabled', false);
442 jQuery('#set_gen_wpbm_view_days_num option:eq(2)').prop('disabled', false);
443 jQuery('#set_gen_wpbm_view_days_num option:eq(3)').prop('disabled', false);
444 jQuery('#set_gen_wpbm_view_days_num option:eq(4)').prop('disabled', true);
445 jQuery('#set_gen_wpbm_view_days_num option:eq(5)').prop('disabled', true);
446 } else {
447 jQuery('#set_gen_wpbm_view_days_num option:eq(0)').prop('disabled', true);
448 jQuery('#set_gen_wpbm_view_days_num option:eq(1)').prop('disabled', true);
449 jQuery('#set_gen_wpbm_view_days_num option:eq(2)').prop('disabled', false);
450 jQuery('#set_gen_wpbm_view_days_num option:eq(3)').prop('disabled', true);
451 jQuery('#set_gen_wpbm_view_days_num option:eq(4)').prop('disabled', false);
452 jQuery('#set_gen_wpbm_view_days_num option:eq(5)').prop('disabled', false);
453 }
454 }
455 } ); ";
456
457 ////////////////////////////////////////////////////////////////////////
458 // Set correct value for dates format, depend from selection of radio buttons
459 $wpbm_date_format = get_wpbm_option( 'wpbm_date_format');
460 // On initial Load set correct text value and correct radio button
461 $js_script .= "
462 // Select by default Custom value, later check all other predefined values
463 jQuery( '#date_format_selection_custom' ).prop('checked', true);
464
465 jQuery('input[name=\"set_gen_wpbm_date_format_selection\"]').each(function() {
466 var radio_button_value = jQuery( this ).val()
467 var encodedStr = radio_button_value.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
468 return '&#'+i.charCodeAt(0)+';';
469 });
470 if ( encodedStr == '". $wpbm_date_format ."' ) {
471 jQuery( this ).prop('checked', true);
472 }
473 });
474
475 jQuery('#set_gen_wpbm_date_format').val('". $wpbm_date_format ."');
476 ";
477 // On click Radio button "Date Format", - set value in custom Text field
478 $js_script .= " jQuery('input[name=\"set_gen_wpbm_date_format_selection\"]').on( 'change', function(){
479 if ( ( this.checked ) && ( jQuery(this).val() != 'custom' ) ){
480
481 jQuery('#set_gen_wpbm_date_format').val( jQuery(this).val().replace(/[\u00A0-\u9999<>\&]/gim,
482 function(i) {
483 return '&#'+i.charCodeAt(0)+';';
484 })
485 );
486 }
487 } ); ";
488 // If we edit custom "Date Format" Text field - select Custom Radio button.
489 $js_script .= " jQuery('#set_gen_wpbm_date_format').on( 'change', function(){
490 jQuery( '#date_format_selection_custom' ).prop('checked', true);
491 } ); ";
492
493
494
495
496 ////////////////////////////////////////////////////////////////////////
497 // Set correct value for Time Format, depend from selection of radio buttons
498 $wpbm_time_format = get_wpbm_option( 'wpbm_time_format');
499 // Function to load on initial stage of page loading, set correct value of text and select correct radio button.
500 $js_script .= "
501 // Select by default Custom value, later check all other predefined values
502 jQuery( '#time_format_selection_custom' ).prop('checked', true);
503
504 jQuery('input[name=\"set_gen_wpbm_time_format_selection\"]').each(function() {
505 var radio_button_value = jQuery( this ).val()
506 var encodedStr = radio_button_value.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
507 return '&#'+i.charCodeAt(0)+';';
508 });
509 if ( encodedStr == '". $wpbm_time_format ."' ) {
510 jQuery( this ).prop('checked', true);
511 }
512 });
513
514 jQuery('#set_gen_wpbm_time_format').val('". $wpbm_time_format ."');
515 ";
516 // On click Radio button "Time Format", - set value in custom Text field
517 $js_script .= " jQuery('input[name=\"set_gen_wpbm_time_format_selection\"]').on( 'change', function(){
518 if ( ( this.checked ) && ( jQuery(this).val() != 'custom' ) ){
519
520 jQuery('#set_gen_wpbm_time_format').val( jQuery(this).val().replace(/[\u00A0-\u9999<>\&]/gim,
521 function(i) {
522 return '&#'+i.charCodeAt(0)+';';
523 })
524 );
525 }
526 } ); ";
527 // If we edit custom "Time Format" Text field - select Custom Radio button.
528 $js_script .= " jQuery('#set_gen_wpbm_time_format').on( 'change', function(){
529 jQuery( '#time_format_selection_custom' ).prop('checked', true);
530 } ); ";
531
532
533 ////////////////////////////////////////////////////////////////////////
534 // Advanced section
535 ////////////////////////////////////////////////////////////////////////
536
537 // Click on "Allow unlimited items per same day(s)"
538 $js_script .= " jQuery('#set_gen_wpbm_is_days_always_available').on( 'change', function(){
539 if ( this.checked ) {
540 var answer = confirm('"
541 . esc_js( __( 'Warning', 'booking-manager') ) . '! '
542 . esc_js( __( 'You allow unlimited number of items per same dates, its can be a reason of double items on the same date. Do you really want to do this?', 'booking-manager') )
543 . "' );
544 if ( answer) {
545 this.checked = true;
546 jQuery('#set_gen_wpbm_check_on_server_if_dates_free').prop('checked', false );
547 jQuery('#set_gen_wpbm_is_show_pending_days_as_available').prop('checked', false );
548 jQuery('.wpbm_pending_days_as_available_sub_settings').addClass('hidden_items');
549 } else {
550 this.checked = false;
551 }
552 }
553 } ); ";
554 // Click on "Checking to prevent double item, during submitting item"
555 $js_script .= " jQuery('#set_gen_wpbm_check_on_server_if_dates_free').on( 'change', function(){
556 if ( this.checked ) {
557 var answer = confirm('"
558 . esc_js( __( 'Warning', 'booking-manager') ) . '! '
559 . esc_js( __( 'This feature can impact to speed of submitting item. Do you really want to do this?', 'booking-manager') )
560 . "' );
561 if ( answer) {
562 this.checked = true;
563 jQuery('#set_gen_wpbm_is_days_always_available').prop('checked', false );
564 } else {
565 this.checked = false;
566 }
567 }
568 } ); ";
569
570 // Click on Show Advanced JavaScript section link
571 $js_script .= " jQuery('#wpbm_show_advanced_section_link_show').on( 'click', function(){
572 jQuery('#wpbm_show_advanced_section_link_show').toggle(200);
573 jQuery('#wpbm_show_advanced_section_link_hide').animate( {opacity: 1}, 200 ).toggle(200);
574 jQuery('.wpbm_advanced_js_loading_settings').removeClass('hidden_items');
575
576 if ( ! jQuery('#set_gen_wpbm_is_load_js_css_on_specific_pages').is(':checked') ) {
577 jQuery('.wpbm_is_load_js_css_on_specific_pages').addClass('hidden_items');
578 }
579 } ); ";
580 $js_script .= " jQuery('#wpbm_show_advanced_section_link_hide').on( 'click', function(){
581 jQuery('#wpbm_show_advanced_section_link_hide').toggle(200);
582 jQuery('#wpbm_show_advanced_section_link_show').animate( {opacity: 1}, 200 ).toggle(200);
583 jQuery('.wpbm_advanced_js_loading_settings').addClass('hidden_items');
584 } ); ";
585 // Click on "is_not_load_bs_script_in_client"
586 $js_script .= " jQuery('#set_gen_wpbm_is_not_load_bs_script_in_client, #set_gen_wpbm_is_not_load_bs_script_in_admin').on( 'change', function(){
587 if ( this.checked ) {
588 var answer = confirm('"
589 . esc_js( __( 'Warning', 'booking-manager') ) . '! '
590 . esc_js( __( 'You are need to be sure what you are doing. You are disable of loading some JavaScripts Do you really want to do this?', 'booking-manager') )
591 . "' );
592 if ( answer) {
593 this.checked = true;
594 } else {
595 this.checked = false;
596 }
597 }
598 } ); ";
599 $js_script .= " jQuery('#set_gen_wpbm_is_load_js_css_on_specific_pages').on( 'change', function(){
600 if ( this.checked ) {
601 var answer = confirm('"
602 . esc_js( __( 'Warning', 'booking-manager') ) . '! '
603 . esc_js( __( 'You are need to be sure what you are doing. You are disable of loading some JavaScripts Do you really want to do this?', 'booking-manager') )
604 . "' );
605 if ( answer) {
606 this.checked = true;
607 jQuery('.wpbm_is_load_js_css_on_specific_pages').removeClass('hidden_items');
608 } else {
609 this.checked = false;
610 }
611 } else {
612 jQuery('.wpbm_is_load_js_css_on_specific_pages').addClass('hidden_items');
613 }
614 } );
615 ";
616
617
618 // Click on Powered by links
619 $js_script .= " jQuery('#wpbm_powered_by_link_show').on( 'click', function(){
620 jQuery('#wpbm_powered_by_link_show').toggle(200);
621 jQuery('#wpbm_powered_by_link_hide').animate( {opacity: 1}, 200 ).toggle(200);
622 jQuery('.wpbm_is_show_powered_by_notice').removeClass('hidden_items');
623 } ); ";
624 $js_script .= " jQuery('#wpbm_powered_by_link_hide').on( 'click', function(){
625 jQuery('#wpbm_powered_by_link_hide').toggle(200);
626 jQuery('#wpbm_powered_by_link_show').animate( {opacity: 1}, 200 ).toggle(200);
627 jQuery('.wpbm_is_show_powered_by_notice').addClass('hidden_items');
628 } ); ";
629
630
631 // Show confirmation window, if user activate this checkbox
632 $js_script .= " jQuery('#set_gen_wpbm_is_delete_if_deactive').on( 'change', function(){
633 if ( this.checked ) {
634 var answer = confirm('"
635 . esc_js( __( 'Warning', 'booking-manager') ) . '! '
636 . esc_js( __( 'If you check this option, all data will be deleted when you uninstall this plugin. Do you really want to do this?', 'booking-manager') )
637 . "' );
638 if ( answer) {
639 this.checked = true;
640 } else {
641 this.checked = false;
642 }
643 }
644 } );
645 ";
646
647 // Eneque JS to the footer of the page
648 wpbm_enqueue_js( $js_script );
649 }
650 }
651
652
653 /** Override VALIDATED fields BEFORE saving to DB
654 * Description:
655 * Check "Thank you page" URL
656 *
657 * @param array $validated_fields
658 */
659 function wpbm_settings_validate_fields_before_saving__all( $validated_fields ) {
660
661
662 // $validated_fields['wpbm_url_wrong_hash'] = wpbm_make_link_relative( $validated_fields['wpbm_url_wrong_hash'] );
663 // $validated_fields['wpbm_url_download_expired'] = wpbm_make_link_relative( $validated_fields['wpbm_url_download_expired'] );
664 // $validated_fields['wpbm_url_ip_not_valied'] = wpbm_make_link_relative( $validated_fields['wpbm_url_ip_not_valied'] );
665 // $validated_fields['wpbm_url_file_not_exist'] = wpbm_make_link_relative( $validated_fields['wpbm_url_file_not_exist'] );
666 // $validated_fields['wpbm_url_error_opening_file'] = wpbm_make_link_relative( $validated_fields['wpbm_url_error_opening_file'] );
667
668 unset( $validated_fields[ 'wpbm_date_format_selection' ] ); // We do not need to this field, because saving to DB only: "date_format" field
669 unset( $validated_fields[ 'wpbm_time_format_selection' ] ); // We do not need to this field, because saving to DB only: "time_format" field
670
671 return $validated_fields;
672 }
673 add_filter( 'wpbm_settings_validate_fields_before_saving', 'wpbm_settings_validate_fields_before_saving__all', 10, 1 ); // Hook for validated fields.