PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0
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 2.0.22 All 55 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, at core/admin/api-settings.php

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