PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.2
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.2
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 / wpbm-toolbar-tiny.php

wpbm-toolbar-tiny.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.0.2, at core/admin/wpbm-toolbar-tiny.php

1,483 lines 69.1 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 Booking Manager
5 * @subpackage Files Loading
6 * @category Bookings
7 *
8 * @author wpdevelop
9 * @link http://oplugins.com/plugins/booking-manager/
10 * @email info@oplugins.com
11 *
12 * @modified 2017-08-01
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18 class WPBM_TinyMCE_Buttons {
19
20
21 // <editor-fold defaultstate="collapsed" desc=" I n i t + H o o k s" >
22
23 private $settings = array();
24
25 function __construct( $params ) {
26
27 $this->settings = array(
28 'tiny_prefix' => 'wpbm_tiny'
29 , 'tiny_icon_url' => WPBM_PLUGIN_URL . '/assets/img/icon-16x16.png'
30 , 'tiny_js_plugin' => WPBM_PLUGIN_URL . '/js/wpbm_tinymce_btn.js'
31 , 'tiny_js_function' => 'wpbm_init_tinymce_buttons' // This function NAME exist inside of this JS file: ['tiny_js_plugin']
32 , 'tiny_btn_row' => 1
33 , 'pages_where_insert' => array( 'post-new.php', 'page-new.php', 'post.php', 'page.php' )
34 , 'buttons' => array(
35 'wpbm_insert' => array(
36 'hint' => __('Insert Shortcode' , 'booking-manager' )
37 , 'title' => __('Insert Shortcode' , 'booking-manager' )
38 , 'js_func_name_click' => 'wpbm_tiny_btn_click'
39 , 'img' => WPBM_PLUGIN_URL . '/assets/img/icon-16x16.png'
40 )
41 )
42 );
43
44 $this->settings = wp_parse_args( $params, $this->settings );
45
46 add_action( 'init', array( $this, 'define_init_hooks' ) ); // Define init hooks
47
48 }
49
50 /** Init all hooks for showing Button in Tiny Toolbar */
51 public function define_init_hooks() {
52
53 // Don't bother doing this stuff if the current user lacks permissions
54 if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return;
55
56 if ( ( in_array( basename($_SERVER['PHP_SELF'] ), $this->settings['pages_where_insert'] ) )
57 // && ( get_user_option('rich_editing') == 'true' )
58 ) {
59
60 /////////////////////////////////////////////////////////////////////////////////////
61 // A D D I N G B u t t o n to toolbar
62 /////////////////////////////////////////////////////////////////////////////////////
63 // Load JS file - TinyMCE plugin
64 add_filter( 'mce_external_plugins', array( $this, 'load_tiny_js_plugin' ) );
65
66 // Add the custom TinyMCE buttons
67 if ( 1 === $this->settings['tiny_btn_row'] ) add_filter( 'mce_buttons', array( $this, 'add_tiny_button' ) );
68 else add_filter( 'mce_buttons_' . $this->settings['tiny_btn_row'] , array( $this, 'add_tiny_button' ) );
69
70 // Add the old style button to the non-TinyMCE editor views
71 add_action( 'edit_form_advanced', array( $this, 'add_html_button' ) ); // Fires after 'normal' context meta boxes have been output
72 add_action( 'edit_page_form', array( $this, 'add_html_button' ) );
73 add_action( 'admin_head', array( $this, 'insert_button') );
74 /////////////////////////////////////////////////////////////////////////////////////
75
76 // Modal Content
77 add_action( 'admin_footer', array( $this, 'modal_content' ) );
78
79 // JS
80 wp_enqueue_script( 'wpdevelop-bootstrap', wpbm_plugin_url( '/assets/libs/bootstrap/js/bootstrap.js' ), array( 'jquery' ), '3.3.5.1');
81
82 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
83 // M o d a l s - proxy wpbc_modal no conflict object - usage like jQuery('#wpbm_tiny_modal').wpbc_modal({
84 ////
85 // Because name "wpbc-wpdevelop-bootstrap" load this script only ONCE (in the Booking Calendar or in this plugin)
86 wp_enqueue_script( 'wpbc-wpdevelop-bootstrap', wpbm_plugin_url( '/js/wpbm_bs_no_conflict.js' ), array( 'wpdevelop-bootstrap' ), '1.0' );
87 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
88
89 // // Can not use this, because its start support only from WP 4.5 :(
90 // // wp_add_inline_script( 'wpdevelop-bootstrap', "var wpbc_modal = jQuery.fn.modal.noConflict(); jQuery.fn.wpbc_modal = wpbc_modal;" ); // Define proxy wpbm_model no conflict object - usage like jQuery('#wpbm_tiny_modal').wpbc_modal({
91
92 // wp_enqueue_script( 'jquery-ui-dialog' );
93
94
95 // CSS
96 wp_enqueue_style( 'wpdevelop-bts', wpbm_plugin_url( '/assets/libs/bootstrap/css/bootstrap.css' ), array(), '3.3.5.1');
97 wp_enqueue_style( 'wpdevelop-bts-theme', wpbm_plugin_url( '/assets/libs/bootstrap/css/bootstrap-theme.css' ), array(), '3.3.5.1');
98
99 wp_enqueue_style( 'wpbm-admin-support', wpbm_plugin_url( '/core/any/css/admin-support.css' ), array(), WPBM_VERSION_NUM);
100 wp_enqueue_style( 'wpbm-admin-modal-popups', wpbm_plugin_url( '/css/modal.css' ), array(), WPBM_VERSION_NUM);
101
102 wp_enqueue_style( 'wpbm-admin-pages', wpbm_plugin_url( '/css/admin.css' ), array(), WPBM_VERSION_NUM);
103 wp_enqueue_style( 'wpbm-admin-menu', wpbm_plugin_url( '/core/any/css/admin-menu.css' ), array(), WPBM_VERSION_NUM);
104 //wp_enqueue_style( 'wpbm-admin-toolbar', wpbm_plugin_url( '/core/any/css/admin-toolbar.css' ), array(), WPBM_VERSION_NUM);
105
106 add_action( 'admin_footer', array( $this, 'write_js' ) ); // Write JavaScript
107 add_action( 'admin_footer', array( $this, 'write_css' ) ); // Write CSS
108
109 }
110 }
111 // </editor-fold>
112
113
114 // <editor-fold defaultstate="collapsed" desc=" TinyMCE - Add Button " >
115
116 /** Load JS file - TinyMCE plugin
117 *
118 * @param array $plugins
119 * @return array
120 */
121 public function load_tiny_js_plugin( $plugins ){
122
123 $plugins[ $this->settings['tiny_prefix'] . '_quicktags'] = $this->settings['tiny_js_plugin'];
124
125 return $plugins;
126 }
127
128
129 /** Add the custom TinyMCE buttons
130 *
131 * @param array $buttons
132 * @return array
133 */
134 public function add_tiny_button( $buttons ) {
135
136 array_push( $buttons, "separator" );
137
138 foreach ( $this->settings['buttons'] as $type => $strings ) {
139 array_push( $buttons, $this->settings['tiny_prefix'] . '_' . $type );
140 }
141
142 return $buttons;
143 }
144
145
146 /** Add the old style button to the non-TinyMCE editor views */
147 public function add_html_button() {
148
149 $buttonshtml = '';
150
151 foreach ( $this->settings['buttons'] as $type => $props ) {
152
153 $buttonshtml .= '<input type="button" class="ed_button button button-small" onclick="'
154 .$props['js_func_name_click'].'(\'' . $type . '\')" title="' . $props['hint'] . '" value="' . $props['title'] . '" />';
155 }
156
157 ?><script type="text/javascript">
158 // <![CDATA[
159 function wpbm_add_html_button_to_toolbar(){ // Add buttons ( HTML view )
160 if ( jQuery( '#ed_toolbar' ).length == 0 )
161 setTimeout( 'wpbm_add_html_button_to_toolbar()' , 100 );
162 else
163 jQuery("#ed_toolbar").append( '<?php echo wp_specialchars_decode( esc_js( $buttonshtml ), ENT_COMPAT ); ?>' );
164 }
165 jQuery(document).ready(function(){
166 setTimeout( 'wpbm_add_html_button_to_toolbar()' , 100 );
167 });
168
169 // ]]>
170 </script><?php
171
172 }
173
174
175 public function insert_button() {
176
177 $script = '';
178
179 if ( ! empty( $this->settings['buttons'] ) ){
180
181 $script .= '<script type="text/javascript">';
182
183 $script .= ' function '. $this->settings['tiny_js_function'] . '(ed, url) {';
184
185 foreach ( $this->settings['buttons'] as $type => $props ) {
186
187 $script .= " if ( typeof ".$props['js_func_name_click']." == 'undefined' ) return; ";
188 $script .= " ed.addButton('". $this->settings['tiny_prefix'] . '_' . $type ."', {";
189 $script .= " title : '". $props['hint'] ."',";
190 $script .= " image : '". $props['img'] ."',";
191 $script .= " onclick : function() {";
192 $script .= " ". $props['js_func_name_click'] ."('". $type ."');";
193 $script .= " }";
194 $script .= " });";
195 }
196
197 $script .= ' }';
198
199 $script .= '</script>';
200
201 echo $script;
202 }
203 }
204
205 // </editor-fold>
206
207
208 // <editor-fold defaultstate="collapsed" desc=" M o d a l C o n t e n t S t r u c t u r e " >
209 public function modal_content() {
210
211 ?><span class="wpdevelop wpbm_page"><div class="visibility_container clearfix-height" style="display:block;"><?php
212 ?><div id="wpbm_tiny_modal" class="modal wpbm_popup_modal wpbm_tiny_modal" tabindex="-1" role="dialog">
213 <div class="modal-dialog modal-lg">
214 <div class="modal-content">
215 <div class="modal-header">
216 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
217 <h4 class="modal-title"><?php
218 _e( 'Insert Shortcode' , 'booking-manager' );
219 echo ' - <span class="wpbm_shortcode_title">';
220
221 foreach ( $this->settings['buttons'] as $type => $props ) {
222 echo $props['title'];
223 break;
224 }
225 echo '</span>';
226 ?></h4>
227 </div>
228 <div class="modal-body">
229 <div class="clear" style="height:5px;"></div>
230 <input name="wpbm_shortcode_type" id="wpbm_shortcode_type" value="<?php echo $this->get_default_shortcode(); ?>" autocomplete="off" type="hidden" />
231 <?php
232
233 // Tabs
234 wpbm_bs_toolbar_tabs_html_container_start();
235
236 $wpbm_tabs = $this->get_tiny_tabs();
237
238 foreach ( $wpbm_tabs as $key => $title ) {
239
240 wpbm_bs_display_tab( array(
241 'title' => $title
242 // , 'hint' => array( 'title' => __('Manage bookings' , 'booking-manager' ) , 'position' => 'top' )
243 , 'onclick' => "jQuery( '.wpbm_tiny_modal .visibility_container').hide();"
244 . "jQuery( '#wpbm_tiny_container_". $key ."' ).show();"
245 . "jQuery( '#wpbm_shortcode_type' ).val('" . $key . " ');"
246 . "jQuery( '.wpbm_tiny_modal .nav-tab').removeClass('nav-tab-active');"
247 . "jQuery( this ).addClass('nav-tab-active');"
248 . "jQuery( '.wpbm_tiny_modal .nav-tab i.icon-white').removeClass('icon-white');"
249 . "jQuery( '.wpbm_tiny_modal .nav-tab-active i').addClass('icon-white');"
250 . "wpbm_set_shortcode();"
251
252 , 'font_icon' => ''
253 , 'default' => ( $key == $this->get_default_shortcode() ) ? true : false
254 , 'checkbox' => false
255 ) );
256 }
257
258 wpbm_bs_toolbar_tabs_html_container_end();
259
260 wpbm_clear_div();
261
262 foreach ( $wpbm_tabs as $key => $title ) {
263
264 ?><div id="wpbm_tiny_container_<?php echo $key; ?>" class="visibility_container clearfix-height" style="<?php
265 echo ( ( $key == $this->get_default_shortcode() ) ? '' : 'display:none;' ); ?>"><?php
266
267 if ( function_exists( 'wpbm_shortcode_' . str_replace( '-', '_', $key ) ) ) {
268 // $this->{'shortcode_' . $key}( $key );
269 call_user_func( 'wpbm_shortcode_' . str_replace( '-', '_', $key ) , $key );
270 }
271
272 ?></div><?php
273 }
274
275 wpbm_clear_div();
276 ?>
277 <input name="wpbm_text_put_in_shortcode" id="wpbm_text_put_in_shortcode" class="put-in" readonly="readonly" onfocus="this.select()" type="text" />
278 </div>
279 <div class="modal-footer" style="text-align:center;">
280
281 <a href="javascript:void(0)" class="button button-primary" style="float:none;"
282 onclick="javascript:wpbm_send_text_to_editor( jQuery('#wpbm_text_put_in_shortcode').val().trim() );wpbm_tiny_close();"
283 ><?php _e( 'Insert into page' ); ?></a> <a href="javascript:void(0)" class="button" style="float:none;" data-dismiss="modal"><?php _e('Close' , 'booking-manager' ); ?></a>
284
285 </div>
286 </div><!-- /.modal-content -->
287 </div><!-- /.modal-dialog -->
288 </div><!-- /.modal -->
289 <?php
290 ?></div></span><?php
291 }
292 // </editor-fold>
293
294
295 // <editor-fold defaultstate="collapsed" desc=" Get Shortcode Tabs " >
296
297 function get_tiny_tabs() {
298
299 if ( function_exists( 'wpbm_get_tiny_tabs' ) )
300 return wpbm_get_tiny_tabs();
301 else
302 return array( 'Tabs_not_defined' => 'No Tabs :(' );
303 }
304
305
306 function get_default_shortcode() {
307
308 $shortcodes = $this->get_tiny_tabs();
309
310 reset( $shortcodes );
311
312 $first_key = key( $shortcodes );
313
314 return $first_key;
315 }
316
317 // </editor-fold>
318
319
320 // <editor-fold defaultstate="collapsed" desc=" J S / C S S " >
321
322 public function write_css() {
323 ?>
324 <!-- WPBM CSS -->
325 <style type="text/css">
326 .wpbm_offset_datetime_from,
327 .wpbm_offset_datetime_until {
328 display:none;
329 }
330 #wpbm_tiny_modal .wpbm_text_near_select {
331 width:7em;
332 height: 28px;
333 vertical-align:middle;
334 margin-right:5px;
335 }
336 #wpbm_tiny_modal .wpbm_select_near_text {
337 width:6em;
338 margin-right:5px;
339 }
340 /* Mobile *********************************************************************/
341 @media (max-width: 782px) {
342 #wpbm_tiny_modal .wpbm_select_near_text,
343 #wpbm_tiny_modal .wpbm_text_near_select {
344 width:100% !important;
345 height: auto;
346 vertical-align:middle;
347 margin:0 0 10px 0;
348 }
349 }
350 </style>
351 <!-- End WPBM CSS -->
352 <?php
353 }
354
355 public function write_js() {
356 ?>
357 <!-- WPBM JavaScript -->
358 <script type="text/javascript">
359 // Parse shortcode on initial opening
360 jQuery(document).ready(function(){
361
362 wpbm_set_shortcode();
363 });
364
365 // Shortcode Parsing - based on external JS
366 function wpbm_set_shortcode(){
367
368 jQuery( '#wpbm_text_put_in_shortcode' ).css( 'color', '#333' );
369
370 var wpbm_shortcode = '[';
371 var wpbm_shortcode_type = jQuery( '#wpbm_shortcode_type' ).val().trim();
372
373 ///////////////////////////////////////////////////////////////////////////////////////
374 if( typeof( check__wpbm_ics_listing ) == 'function' ) {
375 wpbm_shortcode = check__wpbm_ics_listing( wpbm_shortcode );
376 }
377 ///////////////////////////////////////////////////////////////////////////////////////
378 if( typeof( check__wpbm_ics_import ) == 'function' ) {
379 wpbm_shortcode = check__wpbm_ics_import( wpbm_shortcode );
380 }
381 ///////////////////////////////////////////////////////////////////////////////////////
382
383 wpbm_shortcode += ']';
384
385 jQuery( '#wpbm_text_put_in_shortcode' ).val( wpbm_shortcode );
386 }
387
388
389 // Open TinyMCE Modal
390 function wpbm_tiny_btn_click( tag ) {
391
392 jQuery('#wpbm_tiny_modal').wpbc_modal({
393 keyboard: false
394 , backdrop: true
395 , show: true
396 });
397 }
398
399
400 // Close TinyMCE Modal
401 function wpbm_tiny_close() {
402
403 jQuery('#wpbm_tiny_modal').wpbc_modal('hide');
404 }
405
406
407 // Send text to editor
408 function wpbm_send_text_to_editor( h ) {
409 var ed, mce = typeof(tinymce) != 'undefined', qt = typeof(QTags) != 'undefined';
410
411 if ( !wpActiveEditor ) {
412 if ( mce && tinymce.activeEditor ) {
413 ed = tinymce.activeEditor;
414 wpActiveEditor = ed.id;
415 } else if ( !qt ) {
416 return false;
417 }
418 } else if ( mce ) {
419 if ( tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
420 ed = tinymce.activeEditor;
421 else
422 ed = tinymce.get(wpActiveEditor);
423 }
424
425 if ( ed && !ed.isHidden() ) {
426 // restore caret position on IE
427 if ( tinymce.isIE && ed.windowManager.insertimagebookmark )
428 ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
429
430 if ( h.indexOf('[caption') !== -1 ) {
431 if ( ed.wpSetImgCaption )
432 h = ed.wpSetImgCaption(h);
433 } else if ( h.indexOf('[gallery') !== -1 ) {
434 if ( ed.plugins.wpgallery )
435 h = ed.plugins.wpgallery._do_gallery(h);
436 } else if ( h.indexOf('[embed') === 0 ) {
437 if ( ed.plugins.wordpress )
438 h = ed.plugins.wordpress._setEmbed(h);
439 }
440
441 ed.execCommand('mceInsertContent', false, h);
442 } else if ( qt ) {
443 QTags.insertContent(h);
444 } else {
445 document.getElementById(wpActiveEditor).value += h;
446 }
447
448 try{tb_remove();}catch(e){};
449 }
450
451 </script>
452 <!-- End WPBM JavaScript -->
453 <?php
454
455 }
456 // </editor-fold>
457 }
458
459
460 $wpbm_pages_where_insert_btn = array( 'post-new.php', 'page-new.php', 'post.php', 'page.php' );
461
462 if ( in_array( basename($_SERVER['PHP_SELF'] ), $wpbm_pages_where_insert_btn ) ) {
463
464 // Start Class for Tiny Toolbar
465 new WPBM_TinyMCE_Buttons(
466 array(
467 'tiny_prefix' => 'wpbm_tiny'
468 , 'tiny_icon_url' => WPBM_PLUGIN_URL . '/assets/img/icon-16x16.png'
469 , 'tiny_js_plugin' => WPBM_PLUGIN_URL . '/js/wpbm_tinymce_btn.js'
470 , 'tiny_js_function' => 'wpbm_init_tinymce_buttons' // This function NAME exist inside of this file: ['tiny_js_plugin']
471 , 'tiny_btn_row' => 1
472 , 'pages_where_insert' => $wpbm_pages_where_insert_btn
473 , 'buttons' => array(
474 'wpbm_insert' => array(
475 'hint' => __('Booking Manager Shortcodes' , 'booking-manager' )
476 , 'title' => __('Booking Manager' , 'booking-manager' )
477 , 'js_func_name_click' => 'wpbm_tiny_btn_click'
478 , 'img' => WPBM_PLUGIN_URL . '/assets/img/icon-16x16.png'
479 )
480 )
481 )
482 );
483 }
484
485
486
487 // <editor-fold defaultstate="collapsed" desc=" S u p p o r t " >
488 function wpbm_get_bk_resources_toolbar_tiny() {
489
490 if ( ! class_exists( 'wpdev_bk_personal' ) )
491 return array();
492
493 $resources_cache = wpbc_br_cache(); // Get booking resources from cache
494
495 $resource_objects = $resources_cache->get_resources();
496 // $resource_objects = $resources_cache->get_single_parent_resources();
497
498 //$resource_options = $params['resources'];
499
500 foreach ( $resource_objects as $br) {
501
502 $br_option = array();
503 $br_option['title'] = apply_bk_filter('wpdev_check_for_active_language', $br['title'] );
504
505 if ( (isset( $br['parent'] )) && ($br['parent'] == 0 ) && (isset( $br['count'] )) && ($br['count'] > 1 ) )
506 $br_option['title'] .= ' [' . __('parent resource', 'booking') . ']';
507
508 $br_option['attr'] = array();
509 $br_option['attr']['class'] = 'wpbc_single_resource';
510 if ( isset( $br['parent'] ) ) {
511 if ( $br['parent'] == 0 ) {
512 if ( ( isset( $br['count'] ) ) && ( $br['count'] > 1 ) )
513 $br_option['attr']['class'] = 'wpbc_parent_resource';
514 } else {
515 $br_option['attr']['class'] = 'wpbc_child_resource';
516 }
517 }
518
519 $sufix = '';
520
521 $resource_options[ $br['id'] . $sufix ] = $br_option;
522
523 if ( $resource_options[ $br['id'] ]['attr']['class'] === 'wpbc_child_resource' ) {
524 $resource_options[ $br['id'] ]['title'] = ' &nbsp;&nbsp;&nbsp; ' . $resource_options[ $br['id'] ]['title'];
525 }
526 }
527 return $resource_options;
528 }
529 // </editor-fold>
530
531
532 //////////////////////////////////////////////////////////////////////////////////////////
533 // Defining Shortcode Tabs [shortcodes]
534 //////////////////////////////////////////////////////////////////////////////////////////
535 function wpbm_get_tiny_tabs() {
536
537 $wpbm_tabs = array();
538
539 $wpbm_tabs[ 'booking-manager-listing' ] = __( 'Listing .ics feed' , 'booking-manager' );
540
541 if ( wpbm_is_wpbc_supported() )
542 $wpbm_tabs[ 'booking-manager-import' ] = __( 'Import .ics feed into' , 'booking-manager' ) . ' ' . '<strong>WPBC</strong>';
543
544 return $wpbm_tabs;
545 }
546
547
548
549 //////////////////////////////////////////////////////////////////////////////////////////
550 // L i s t i n g
551 //////////////////////////////////////////////////////////////////////////////////////////
552 function wpbm_shortcode_booking_manager_listing( $shortcode_section_key ) {
553
554 wpbm_shortcode_booking_manager_listing_js();
555
556 ?><table class="form-table booking_manager_listing"><tbody><?php
557
558 ////////////////////////////////////////////////////////////////////
559 // Feed URL
560 ////////////////////////////////////////////////////////////////////
561 WPBM_Settings_API::field_text_row_static( 'wpbm_ics_listing_url'
562 , array(
563 'type' => 'text'
564 , 'title' => __('URL', 'booking-manager' )
565 , 'placeholder' => str_replace( array( '"', "'" ), '', __('URL to .ics feed or file', 'booking-manager' ) )
566 , 'description' => ''//__('Enter', 'booking-manager' ) . ' ' . __('URL to .ics feed', 'booking-manager' )
567 , 'description_tag' => 'span'
568 , 'group' => $shortcode_section_key
569 , 'tr_class' => $shortcode_section_key . '_standard_section'
570 , 'class' => ''
571 , 'css' => 'width:100%;'
572 , 'only_field' => false
573 , 'attr' => array()
574 , 'value' => 'https://calendar.google.com/calendar/ical/CALENDAR_ID/public/basic.ics'
575 )
576 );
577
578 ////////////////////////////////////////////////////////////////////
579 // F r o m
580 ////////////////////////////////////////////////////////////////////
581
582 ?><tr valign="top" class="<?php echo $shortcode_section_key . '_standard_section wpbm_section_listing_from'; ?>">
583 <th scope="row" style="vertical-align: middle;font-weight:400;font-style: italic;">
584 <label for="wpbm_ics_listing_from" class="wpbm-form-text"><?php
585 echo __('From' , 'booking-manager' );
586 ?></label>
587 </th>
588 <td class=""><fieldset><?php
589
590 $wpbc_options = array(
591 'now' => __( 'Now', 'booking-manager' )
592 , 'today' => __( '00:00 Today', 'booking-manager' )
593 , 'week' => __( 'Start of current week', 'booking-manager' )
594 , 'month-start' => __( 'Start of current month', 'booking-manager' )
595 , 'month-end' => __( 'End of current month', 'booking-manager' )
596 , 'year-start' => __( 'Start of current year', 'booking-manager' )
597 , 'any' => __( 'The start of time', 'booking-manager' )
598 , 'date' => __( 'Specific date / time', 'booking-manager' )
599 );
600
601 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_listing_from'
602 , array(
603 'type' => 'select'
604 , 'title' => __('From', 'booking-manager' )
605 , 'description' => ''
606 , 'description_tag' => 'span'
607 , 'label' => ''
608 , 'multiple' => false
609 , 'group' => $shortcode_section_key
610 , 'tr_class' => $shortcode_section_key . '_standard_section'
611 , 'class' => ''
612 , 'css' => 'margin-right:10px;'
613 , 'only_field' => true
614 , 'attr' => array()
615 , 'value' => 'today'
616 , 'options' => $wpbc_options
617 )
618 );
619
620 ?><label for="wpbm_ics_listing_from_offset" class="wpbm-form-text wpbm_from_offset" style="font-weight:400;"><?php
621 echo __('Offset' , 'booking-manager' );
622 ?></label>
623 <label for="wpbm_ics_listing_from_offset" class="wpbm-form-text wpbm_from_date" style="font-weight:400;display:none;"><?php
624 echo __('Date' , 'booking-manager' );
625 ?></label><?php
626
627 WPBM_Settings_API::field_text_row_static( 'wpbm_ics_listing_from_offset'
628 , array(
629 'type' => 'text'
630 , 'title' => __('Offset', 'booking-manager' )
631 , 'placeholder' => ''
632 , 'description' => ''
633 , 'description_tag' => 'span'
634 , 'group' => $shortcode_section_key
635 , 'tr_class' => $shortcode_section_key . '_standard_section'
636 , 'class' => 'wpbm_text_near_select'
637 , 'css' => 'width:7em;'
638 , 'only_field' => true
639 , 'attr' => array()
640 , 'value' => ''
641 )
642 );
643 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_listing_from_offset_type'
644 , array(
645 'type' => 'select'
646 , 'title' => ''
647 , 'description' => ''
648 , 'description_tag' => 'span'
649 , 'label' => ''
650 , 'multiple' => false
651 , 'group' => $shortcode_section_key
652 , 'class' => 'wpbm_select_near_text wpbm_from_offset'
653 , 'css' => 'width:6em;'
654 , 'only_field' => true
655 , 'attr' => array()
656 , 'value' => date( 'Y' )
657 , 'options' => array(
658 'day' => __( 'days' ,'booking-manager' )
659 , 'hour' => __( 'hours' ,'booking-manager' )
660 , 'minute' => __( 'minutes' ,'booking-manager' )
661 , 'second' => __( 'seconds' ,'booking-manager' )
662 )
663 //, 'options' => array_combine( range( ( date('Y') - 1 ), ( date('Y') + 10 ) ), range( ( date('Y') - 1 ), ( date('Y') + 10 ) ) )
664 )
665 );
666 ?><span class="description wpbm_from_offset"> <?php _e('You can specify an optional offset from you chosen start point. The offset can be negative.', 'booking-manager' ); ?></span>
667 <span class="wpbm_from_date" style="display:none;">
668 <em><?php printf( __( 'Type your date in format %s. Example: %s', 'booking-manager' ), 'Y-m-d', '2017-08-02' ); ?></em>
669 </span>
670 </fieldset></td>
671 </tr><?php
672
673
674
675 ////////////////////////////////////////////////////////////////////
676 // U n t i l
677 ////////////////////////////////////////////////////////////////////
678
679 ?><tr valign="top" class="<?php echo $shortcode_section_key . '_standard_section wpbm_section_listing_until'; ?>">
680 <th scope="row" style="vertical-align: middle;font-weight:400;font-style: italic;">
681 <label for="wpbm_ics_listing_until" class="wpbm-form-text"><?php
682 echo __('Until' , 'booking-manager' );
683 ?></label>
684 </th>
685 <td class=""><fieldset><?php
686
687 $wpbc_options = array(
688 'now' => __( 'Now', 'booking-manager' )
689 , 'today' => __( '00:00 Today', 'booking-manager' )
690 , 'week' => __( 'End of current week', 'booking-manager' )
691 , 'month-start' => __( 'Start of current month', 'booking-manager' )
692 , 'month-end' => __( 'End of current month', 'booking-manager' )
693 , 'year-end' => __( 'End of current year', 'booking-manager' )
694 , 'any' => __( 'The end of time', 'booking-manager' )
695 , 'date' => __( 'Specific date / time', 'booking-manager' )
696 );
697
698 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_listing_until'
699 , array(
700 'type' => 'select'
701 , 'title' => __('Until', 'booking-manager' )
702 , 'description' => ''
703 , 'description_tag' => 'span'
704 , 'label' => ''
705 , 'multiple' => false
706 , 'group' => $shortcode_section_key
707 , 'tr_class' => $shortcode_section_key . '_standard_section'
708 , 'class' => ''
709 , 'css' => 'margin-right:10px;'
710 , 'only_field' => true
711 , 'attr' => array()
712 , 'value' => 'year-end'
713 , 'options' => $wpbc_options
714 )
715 );
716
717 ?><label for="wpbm_ics_listing_until_offset" class="wpbm-form-text wpbm_until_offset" style="font-weight:400;"><?php
718 echo __('Offset' , 'booking-manager' );
719 ?></label>
720 <label for="wpbm_ics_listing_until_offset" class="wpbm-form-text wpbm_until_date" style="font-weight:400;display:none;"><?php
721 echo __('Date' , 'booking-manager' );
722 ?></label><?php
723
724 WPBM_Settings_API::field_text_row_static( 'wpbm_ics_listing_until_offset'
725 , array(
726 'type' => 'text'
727 , 'title' => __('Offset', 'booking-manager' )
728 , 'placeholder' => ''
729 , 'description' => ''
730 , 'description_tag' => 'span'
731 , 'group' => $shortcode_section_key
732 , 'tr_class' => $shortcode_section_key . '_standard_section'
733 , 'class' => 'wpbm_text_near_select'
734 , 'css' => 'width:7em;'
735 , 'only_field' => true
736 , 'attr' => array()
737 , 'value' => ''
738 )
739 );
740 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_listing_until_offset_type'
741 , array(
742 'type' => 'select'
743 , 'title' => ''
744 , 'description' => ''
745 , 'description_tag' => 'span'
746 , 'label' => ''
747 , 'multiple' => false
748 , 'group' => $shortcode_section_key
749 , 'class' => 'wpbm_select_near_text wpbm_until_offset'
750 , 'css' => 'width:6em;'
751 , 'only_field' => true
752 , 'attr' => array()
753 , 'value' => date( 'Y' )
754 , 'options' => array(
755 'day' => __( 'days' ,'booking-manager' )
756 , 'hour' => __( 'hours' ,'booking-manager' )
757 , 'minute' => __( 'minutes' ,'booking-manager' )
758 , 'second' => __( 'seconds' ,'booking-manager' )
759 )
760 //, 'options' => array_combine( range( ( date('Y') - 1 ), ( date('Y') + 10 ) ), range( ( date('Y') - 1 ), ( date('Y') + 10 ) ) )
761 )
762 );
763 ?><span class="description wpbm_until_offset"> <?php _e('You can specify an optional offset from you chosen end point. The offset can be negative.', 'booking-manager' ); ?></span>
764 <span class="wpbm_until_date" style="display:none;">
765 <em><?php printf( __( 'Type your date in format %s. Example: %s', 'booking-manager' ), 'Y-m-d', '2017-08-02' ); ?></em>
766 </span>
767 </fieldset></td>
768 </tr><?php
769
770 ////////////////////////////////////////////////////////////////////
771 // Maximum number
772 ////////////////////////////////////////////////////////////////////
773 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_listing_max'
774 , array(
775 'type' => 'select'
776 , 'title' => __('Maximum number', 'booking-manager' )
777 , 'description' => __('You can specify the maximum number of events.' , 'booking-manager' )
778 , 'description_tag' => 'span'
779 , 'label' => ''
780 , 'multiple' => false
781 , 'group' => $shortcode_section_key
782 , 'tr_class' => $shortcode_section_key . '_standard_section'
783 , 'class' => ''
784 , 'css' => ''
785 , 'only_field' => false
786 , 'attr' => array()
787 , 'value' => 0
788 , 'options' => array_combine(
789 array_merge( array( '0' ), range( 500, 10 , 10 ) )
790 , array_merge( array( '&nbsp;-&nbsp;' ), range( 500, 10 , 10 ) )
791 )
792 )
793 );
794
795 WPBM_Settings_API::field_select_row_static( 'wpbm_listing_is_all_dates_in'
796 , array(
797 'type' => 'select'
798 , 'title' => __( 'Event condition', 'booking-manager')
799 , 'description' => __( 'Show event, if all dates or only some date(s) within conditional paramters from / untill', 'booking-manager' )
800 , 'description_tag' => 'span'
801 , 'label' => ''
802 , 'multiple' => false
803 , 'group' => $shortcode_section_key
804 , 'tr_class' => $shortcode_section_key . '_standard_section'
805 , 'class' => ''
806 , 'css' => 'margin-right:10px;'
807 , 'only_field' => false
808 , 'attr' => array()
809 , 'value' => '0'
810 , 'options' => array(
811 '0' => __( 'Some date(s) in conditional interval', 'booking-manager' )
812 , '1' => __( 'Strict. All dates in conditional interval', 'booking-manager' )
813 )
814 )
815 );
816
817 ?></tbody></table><?php
818
819 /*
820 echo "<pre style=''>
821 Example of shortcode usage:
822 [booking-manager-listing url='https://calendar.google.com/calendar/ical/CALENDAR_ID/public/basic.ics' from='2017-09-01' until='month-end']
823 </pre>";
824 */
825 }
826
827 function wpbm_shortcode_booking_manager_listing_js() {
828 ?>
829 <script type="text/javascript">
830
831 // // Show / Hide Offsets
832 // jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
833 // jQuery( '.wpbm_tr_wpbm_ics_listing_show_offset_until' ).on( 'click', '.show_link', function ( event ) { // This delegated event, can be run, when DOM element added after page loaded
834 // jQuery( this ).hide();
835 // });
836 // });
837
838 jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
839
840 jQuery( '#wpbm_ics_listing_url,#wpbm_ics_listing_from,#wpbm_ics_listing_from_offset,#wpbm_ics_listing_from_offset_type,'
841 + '#wpbm_ics_listing_until,#wpbm_ics_listing_until_offset,#wpbm_ics_listing_until_offset_type,#wpbm_ics_listing_max,#wpbm_listing_is_all_dates_in').on( 'change', function(){
842
843 wpbm_set_shortcode();
844 });
845 });
846
847 // [booking-manager-listing ... ]
848 function check__wpbm_ics_listing( wpbm_shortcode ){
849
850 //var wpbm_shortcode = '[';
851 var wpbm_shortcode_type = jQuery( '#wpbm_shortcode_type' ).val().trim();
852
853 ////////////////////////////////////////////////////////////////
854 // [booking-manager-listing]
855 ////////////////////////////////////////////////////////////////
856 if ( wpbm_shortcode_type == 'booking-manager-listing' ) {
857
858 wpbm_shortcode += 'booking-manager-listing';
859
860 ////////////////////////////////////////////////////////////////
861 // URL
862 ////////////////////////////////////////////////////////////////
863 if ( jQuery( '#wpbm_ics_listing_url' ).val().trim() != '' ) {
864 var wpbm_shortcode_url_temp = jQuery( '#wpbm_ics_listing_url' ).val().trim().replace(/'/gi, '');
865 wpbm_shortcode += ' url=\'' + wpbm_shortcode_url_temp + '\'';
866 } else {
867 wpbm_shortcode = '[ URL is required '
868 jQuery( '#wpbm_text_put_in_shortcode' ).css( 'color', '#F00' );
869 return wpbm_shortcode;
870 }
871
872
873 ////////////////////////////////////////////////////////////////
874 // FROM
875 ////////////////////////////////////////////////////////////////
876 var p_from = jQuery( '#wpbm_ics_listing_from' ).val().trim();
877 var p_from_offset = jQuery( '#wpbm_ics_listing_from_offset' ).val().trim();
878
879 // Hide | Show date/offset labels
880 if ( p_from == 'date' ) {
881 jQuery( '.booking_manager_listing .wpbm_from_offset' ).hide();
882 jQuery( '.booking_manager_listing .wpbm_from_date' ).show();
883 } else {
884 jQuery( '.booking_manager_listing .wpbm_from_offset' ).show();
885 jQuery( '.booking_manager_listing .wpbm_from_date' ).hide();
886 }
887 if ( p_from == 'any' ) {
888 jQuery( '.booking_manager_listing .wpbm_from_offset' ).hide();
889 jQuery( '.booking_manager_listing .wpbm_from_date, #wpbm_ics_listing_from_offset' ).hide();
890 } else {
891 jQuery( '#wpbm_ics_listing_from_offset' ).show();
892 }
893
894
895 if ( p_from != 'date' ){
896
897 wpbm_shortcode += ' from=\'' + p_from + '\'';
898
899 if ( ( p_from != 'any' ) && ( p_from_offset != '' ) ){
900 p_from_offset = parseInt( p_from_offset );
901 if ( ! isNaN( p_from_offset ) )
902 wpbm_shortcode += ' from_offset=\'' + p_from_offset
903 + jQuery( '#wpbm_ics_listing_from_offset_type' ).val().trim().charAt(0)
904 + '\'';
905 }
906
907 } else if ( ( p_from == 'date' ) && ( p_from_offset != '' ) ){ // If selected Date
908
909 wpbm_shortcode += ' from=\'' + p_from_offset + '\'';
910 }
911
912 ////////////////////////////////////////////////////////////////
913 // Until
914 ////////////////////////////////////////////////////////////////
915 var p_until = jQuery( '#wpbm_ics_listing_until' ).val().trim();
916 var p_until_offset = jQuery( '#wpbm_ics_listing_until_offset' ).val().trim();
917
918 // Hide | Show date/offset labels
919 if ( p_until == 'date' ) {
920 jQuery( '.booking_manager_listing .wpbm_until_offset' ).hide();
921 jQuery( '.booking_manager_listing .wpbm_until_date' ).show();
922 } else {
923 jQuery( '.booking_manager_listing .wpbm_until_offset' ).show();
924 jQuery( '.booking_manager_listing .wpbm_until_date' ).hide();
925 }
926 if ( p_until == 'any' ) {
927 jQuery( '.booking_manager_listing .wpbm_until_offset' ).hide();
928 jQuery( '.booking_manager_listing .wpbm_until_date, #wpbm_ics_listing_until_offset' ).hide();
929 } else {
930 jQuery( '#wpbm_ics_listing_until_offset' ).show();
931 }
932
933
934 if ( p_until != 'date' ){
935
936 wpbm_shortcode += ' until=\'' + p_until + '\'';
937
938 if ( ( p_until != 'any' ) && ( p_until_offset != '' ) ){
939 p_until_offset = parseInt( p_until_offset );
940 if ( ! isNaN( p_until_offset ) )
941 wpbm_shortcode += ' until_offset=\'' + p_until_offset
942 + jQuery( '#wpbm_ics_listing_until_offset_type' ).val().trim().charAt(0)
943 + '\'';
944 }
945
946 } else if ( ( p_until == 'date' ) && ( p_until_offset != '' ) ){ // If selected Date
947
948 wpbm_shortcode += ' until=\'' + p_until_offset + '\'';
949 }
950
951 ////////////////////////////////////////////////////////////////
952 // Max
953 ////////////////////////////////////////////////////////////////
954 var p_max = parseInt( jQuery( '#wpbm_ics_listing_max' ).val().trim() );
955 if ( p_max != 0 ) {
956 wpbm_shortcode += ' max=' + p_max;
957 }
958
959 ////////////////////////////////////////////////////////////////
960 // is_all_dates_in
961 ////////////////////////////////////////////////////////////////
962 var p_is_all_dates_in = parseInt( jQuery( '#wpbm_listing_is_all_dates_in' ).val().trim() );
963
964 if ( p_is_all_dates_in != 0 ) {
965 wpbm_shortcode += ' is_all_dates_in=' + p_is_all_dates_in;
966 }
967
968
969 }
970
971 return wpbm_shortcode;
972 }
973
974 </script>
975 <?php
976 }
977
978
979 //////////////////////////////////////////////////////////////////////////////////////////
980 // I m p o r t
981 //////////////////////////////////////////////////////////////////////////////////////////
982 function wpbm_shortcode_booking_manager_import( $shortcode_section_key ) {
983
984 wpbm_shortcode_booking_manager_import_js();
985
986 ?><table class="form-table booking_manager_import"><tbody><?php
987
988 ////////////////////////////////////////////////////////////////////
989 // Feed URL
990 ////////////////////////////////////////////////////////////////////
991 WPBM_Settings_API::field_text_row_static( 'wpbm_ics_import_url'
992 , array(
993 'type' => 'text'
994 , 'title' => __('URL', 'booking-manager' )
995 , 'placeholder' => str_replace( array( '"', "'" ), '', __('URL to .ics feed or file', 'booking-manager' ) )
996 , 'description' => ''//__('Enter', 'booking-manager' ) . ' ' . __('URL to .ics feed', 'booking-manager' )
997 , 'description_tag' => 'span'
998 , 'group' => $shortcode_section_key
999 , 'tr_class' => $shortcode_section_key . '_standard_section'
1000 , 'class' => ''
1001 , 'css' => 'width:100%;'
1002 , 'only_field' => false
1003 , 'attr' => array()
1004 , 'value' => 'https://calendar.google.com/calendar/ical/CALENDAR_ID/public/basic.ics'
1005 )
1006 );
1007
1008 ////////////////////////////////////////////////////////////////////
1009 // Booking Resources
1010 ////////////////////////////////////////////////////////////////////
1011 if ( class_exists( 'wpdev_bk_personal' ) ){
1012
1013 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_booking_resource'
1014 , array(
1015 'type' => 'select'
1016 , 'title' => __('Booking resource', 'booking-manager')
1017 , 'description' => __( 'Select booking resource, where event will be imported', 'booking-manager' )
1018 , 'description_tag' => 'span'
1019 , 'label' => ''
1020 , 'multiple' => false
1021 , 'group' => $shortcode_section_key
1022 , 'tr_class' => $shortcode_section_key . '_standard_section'
1023 , 'class' => ''
1024 , 'css' => 'margin-right:10px;'
1025 , 'only_field' => false
1026 , 'attr' => array()
1027 , 'value' => ''
1028 , 'options' => wpbm_get_bk_resources_toolbar_tiny()
1029 )
1030 );
1031 }
1032
1033 ////////////////////////////////////////////////////////////////////
1034 // import_conditions
1035 ////////////////////////////////////////////////////////////////////
1036 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_import_conditions'
1037 , array(
1038 'type' => 'select'
1039 , 'title' => __( 'Import condition', 'booking-manager')
1040 , 'description' => __( 'Whether import events for dates, that already booked in specific booking resource', 'booking-manager' )
1041 , 'description_tag' => 'span'
1042 , 'label' => ''
1043 , 'multiple' => false
1044 , 'group' => $shortcode_section_key
1045 , 'tr_class' => $shortcode_section_key . '_standard_section'
1046 , 'class' => ''
1047 , 'css' => 'margin-right:10px;'
1048 , 'only_field' => false
1049 , 'attr' => array()
1050 , 'value' => ''
1051 , 'options' => array(
1052 '' => __( 'Import in any case', 'booking-manager' )
1053 , 'if_dates_free' => __( 'Import only, if days are available', 'booking-manager' )
1054 )
1055 )
1056 );
1057
1058 ////////////////////////////////////////////////////////////////////
1059 // F r o m
1060 ////////////////////////////////////////////////////////////////////
1061
1062 ?><tr valign="top" class="<?php echo $shortcode_section_key . '_standard_section wpbm_section_import_from'; ?>">
1063 <th scope="row" style="vertical-align: middle;font-weight:400;font-style: italic;">
1064 <label for="wpbm_ics_import_from" class="wpbm-form-text"><?php
1065 echo __('From' , 'booking-manager' );
1066 ?></label>
1067 </th>
1068 <td class=""><fieldset><?php
1069
1070 $wpbc_options = array(
1071 'now' => __( 'Now', 'booking-manager' )
1072 , 'today' => __( '00:00 Today', 'booking-manager' )
1073 , 'week' => __( 'Start of current week', 'booking-manager' )
1074 , 'month-start' => __( 'Start of current month', 'booking-manager' )
1075 , 'month-end' => __( 'End of current month', 'booking-manager' )
1076 , 'year-start' => __( 'Start of current year', 'booking-manager' )
1077 , 'any' => __( 'The start of time', 'booking-manager' )
1078 , 'date' => __( 'Specific date / time', 'booking-manager' )
1079 );
1080
1081 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_from'
1082 , array(
1083 'type' => 'select'
1084 , 'title' => __('From', 'booking-manager' )
1085 , 'description' => ''
1086 , 'description_tag' => 'span'
1087 , 'label' => ''
1088 , 'multiple' => false
1089 , 'group' => $shortcode_section_key
1090 , 'tr_class' => $shortcode_section_key . '_standard_section'
1091 , 'class' => ''
1092 , 'css' => 'margin-right:10px;'
1093 , 'only_field' => true
1094 , 'attr' => array()
1095 , 'value' => 'today'
1096 , 'options' => $wpbc_options
1097 )
1098 );
1099
1100 ?><label for="wpbm_ics_import_from_offset" class="wpbm-form-text wpbm_from_offset" style="font-weight:400;"><?php
1101 echo __('Offset' , 'booking-manager' );
1102 ?></label>
1103 <label for="wpbm_ics_import_from_offset" class="wpbm-form-text wpbm_from_date" style="font-weight:400;display:none;"><?php
1104 echo __('Date' , 'booking-manager' );
1105 ?></label><?php
1106
1107 WPBM_Settings_API::field_text_row_static( 'wpbm_ics_import_from_offset'
1108 , array(
1109 'type' => 'text'
1110 , 'title' => __('Offset', 'booking-manager' )
1111 , 'placeholder' => ''
1112 , 'description' => ''
1113 , 'description_tag' => 'span'
1114 , 'group' => $shortcode_section_key
1115 , 'tr_class' => $shortcode_section_key . '_standard_section'
1116 , 'class' => 'wpbm_text_near_select'
1117 , 'css' => 'width:7em;'
1118 , 'only_field' => true
1119 , 'attr' => array()
1120 , 'value' => ''
1121 )
1122 );
1123 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_from_offset_type'
1124 , array(
1125 'type' => 'select'
1126 , 'title' => ''
1127 , 'description' => ''
1128 , 'description_tag' => 'span'
1129 , 'label' => ''
1130 , 'multiple' => false
1131 , 'group' => $shortcode_section_key
1132 , 'class' => 'wpbm_select_near_text wpbm_from_offset'
1133 , 'css' => 'width:6em;'
1134 , 'only_field' => true
1135 , 'attr' => array()
1136 , 'value' => 'day'
1137 , 'options' => array(
1138 'day' => __( 'days' ,'booking-manager' )
1139 , 'hour' => __( 'hours' ,'booking-manager' )
1140 , 'minute' => __( 'minutes' ,'booking-manager' )
1141 , 'second' => __( 'seconds' ,'booking-manager' )
1142 )
1143 //, 'options' => array_combine( range( ( date('Y') - 1 ), ( date('Y') + 10 ) ), range( ( date('Y') - 1 ), ( date('Y') + 10 ) ) )
1144 )
1145 );
1146 ?><span class="description wpbm_from_offset"> <?php _e('You can specify an optional offset from you chosen start point. The offset can be negative.', 'booking-manager' ); ?></span>
1147 <span class="wpbm_from_date" style="display:none;">
1148 <em><?php printf( __( 'Type your date in format %s. Example: %s', 'booking-manager' ), 'Y-m-d', '2017-08-02' ); ?></em>
1149 </span>
1150 </fieldset></td>
1151 </tr><?php
1152
1153
1154
1155 ////////////////////////////////////////////////////////////////////
1156 // U n t i l
1157 ////////////////////////////////////////////////////////////////////
1158
1159 ?><tr valign="top" class="<?php echo $shortcode_section_key . '_standard_section wpbm_section_import_until'; ?>">
1160 <th scope="row" style="vertical-align: middle;font-weight:400;font-style: italic;">
1161 <label for="wpbm_ics_import_until" class="wpbm-form-text"><?php
1162 echo __('Until' , 'booking-manager' );
1163 ?></label>
1164 </th>
1165 <td class=""><fieldset><?php
1166
1167 $wpbc_options = array(
1168 'now' => __( 'Now', 'booking-manager' )
1169 , 'today' => __( '00:00 Today', 'booking-manager' )
1170 , 'week' => __( 'End of current week', 'booking-manager' )
1171 , 'month-start' => __( 'Start of current month', 'booking-manager' )
1172 , 'month-end' => __( 'End of current month', 'booking-manager' )
1173 , 'year-end' => __( 'End of current year', 'booking-manager' )
1174 , 'any' => __( 'The end of time', 'booking-manager' )
1175 , 'date' => __( 'Specific date / time', 'booking-manager' )
1176 );
1177
1178 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_until'
1179 , array(
1180 'type' => 'select'
1181 , 'title' => __('Until', 'booking-manager' )
1182 , 'description' => ''
1183 , 'description_tag' => 'span'
1184 , 'label' => ''
1185 , 'multiple' => false
1186 , 'group' => $shortcode_section_key
1187 , 'tr_class' => $shortcode_section_key . '_standard_section'
1188 , 'class' => ''
1189 , 'css' => 'margin-right:10px;'
1190 , 'only_field' => true
1191 , 'attr' => array()
1192 , 'value' => 'year-end'
1193 , 'options' => $wpbc_options
1194 )
1195 );
1196
1197 ?><label for="wpbm_ics_import_until_offset" class="wpbm-form-text wpbm_until_offset" style="font-weight:400;"><?php
1198 echo __('Offset' , 'booking-manager' );
1199 ?></label>
1200 <label for="wpbm_ics_import_until_offset" class="wpbm-form-text wpbm_until_date" style="font-weight:400;display:none;"><?php
1201 echo __('Date' , 'booking-manager' );
1202 ?></label><?php
1203
1204 WPBM_Settings_API::field_text_row_static( 'wpbm_ics_import_until_offset'
1205 , array(
1206 'type' => 'text'
1207 , 'title' => __('Offset', 'booking-manager' )
1208 , 'placeholder' => ''
1209 , 'description' => ''
1210 , 'description_tag' => 'span'
1211 , 'group' => $shortcode_section_key
1212 , 'tr_class' => $shortcode_section_key . '_standard_section'
1213 , 'class' => 'wpbm_text_near_select'
1214 , 'css' => 'width:7em;'
1215 , 'only_field' => true
1216 , 'attr' => array()
1217 , 'value' => ''
1218 )
1219 );
1220 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_until_offset_type'
1221 , array(
1222 'type' => 'select'
1223 , 'title' => ''
1224 , 'description' => ''
1225 , 'description_tag' => 'span'
1226 , 'label' => ''
1227 , 'multiple' => false
1228 , 'group' => $shortcode_section_key
1229 , 'class' => 'wpbm_select_near_text wpbm_until_offset'
1230 , 'css' => 'width:6em;'
1231 , 'only_field' => true
1232 , 'attr' => array()
1233 , 'value' => 'day'
1234 , 'options' => array(
1235 'day' => __( 'days' ,'booking-manager' )
1236 , 'hour' => __( 'hours' ,'booking-manager' )
1237 , 'minute' => __( 'minutes' ,'booking-manager' )
1238 , 'second' => __( 'seconds' ,'booking-manager' )
1239 )
1240 //, 'options' => array_combine( range( ( date('Y') - 1 ), ( date('Y') + 10 ) ), range( ( date('Y') - 1 ), ( date('Y') + 10 ) ) )
1241 )
1242 );
1243 ?><span class="description wpbm_until_offset"> <?php _e('You can specify an optional offset from you chosen end point. The offset can be negative.', 'booking-manager' ); ?></span>
1244 <span class="wpbm_until_date" style="display:none;">
1245 <em><?php printf( __( 'Type your date in format %s. Example: %s', 'booking-manager' ), 'Y-m-d', '2017-08-02' ); ?></em>
1246 </span>
1247 </fieldset></td>
1248 </tr><?php
1249
1250 ////////////////////////////////////////////////////////////////////
1251 // Maximum number
1252 ////////////////////////////////////////////////////////////////////
1253 WPBM_Settings_API::field_select_row_static( 'wpbm_ics_import_max'
1254 , array(
1255 'type' => 'select'
1256 , 'title' => __('Maximum number', 'booking-manager' )
1257 , 'description' => __('You can specify the maximum number of events.' , 'booking-manager' )
1258 , 'description_tag' => 'span'
1259 , 'label' => ''
1260 , 'multiple' => false
1261 , 'group' => $shortcode_section_key
1262 , 'tr_class' => $shortcode_section_key . '_standard_section'
1263 , 'class' => ''
1264 , 'css' => ''
1265 , 'only_field' => false
1266 , 'attr' => array()
1267 , 'value' => 0
1268 , 'options' => array_combine(
1269 array_merge( array( '0' ), range( 500, 10 , 10 ) )
1270 , array_merge( array( '&nbsp;-&nbsp;' ), range( 500, 10 , 10 ) )
1271 )
1272 )
1273 );
1274
1275
1276 WPBM_Settings_API::field_select_row_static( 'wpbm_import_is_all_dates_in'
1277 , array(
1278 'type' => 'select'
1279 , 'title' => __( 'Event condition', 'booking-manager')
1280 , 'description' => __( 'Imort booking, if all dates or only some date(s) within conditional paramters from / untill', 'booking-manager' )
1281 , 'description_tag' => 'span'
1282 , 'label' => ''
1283 , 'multiple' => false
1284 , 'group' => $shortcode_section_key
1285 , 'tr_class' => $shortcode_section_key . '_standard_section'
1286 , 'class' => ''
1287 , 'css' => 'margin-right:10px;'
1288 , 'only_field' => false
1289 , 'attr' => array()
1290 , 'value' => '1'
1291 , 'options' => array(
1292 '0' => __( 'Some date(s) in conditional interval', 'booking-manager' )
1293 , '1' => __( 'Strict. All dates in conditional interval', 'booking-manager' )
1294 )
1295 )
1296 );
1297
1298 ?></tbody></table><?php
1299
1300
1301 }
1302
1303
1304 function wpbm_shortcode_booking_manager_import_js() {
1305 ?>
1306 <script type="text/javascript">
1307 // // Show / Hide Offsets
1308 // jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
1309 // jQuery( '.wpbm_tr_wpbm_ics_listing_show_offset_until' ).on( 'click', '.show_link', function ( event ) { // This delegated event, can be run, when DOM element added after page loaded
1310 // jQuery( this ).hide();
1311 // });
1312 // });
1313
1314 jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
1315
1316 jQuery( '#wpbm_ics_import_url,#wpbm_ics_import_from,#wpbm_ics_import_from_offset,#wpbm_ics_import_from_offset_type,'
1317 + '#wpbm_ics_import_until,#wpbm_ics_import_until_offset,#wpbm_ics_import_until_offset_type,#wpbm_ics_import_max,'
1318 + '#wpbm_ics_import_booking_resource,#wpbm_ics_import_import_conditions,#wpbm_import_is_all_dates_in').on( 'change', function(){
1319
1320 wpbm_set_shortcode();
1321 });
1322 });
1323
1324 // [booking-manager-import ... ]
1325 function check__wpbm_ics_import( wpbm_shortcode ){
1326
1327 //var wpbm_shortcode = '[';
1328 var wpbm_shortcode_type = jQuery( '#wpbm_shortcode_type' ).val().trim();
1329
1330 ////////////////////////////////////////////////////////////////
1331 // [booking-manager-import]
1332 ////////////////////////////////////////////////////////////////
1333 if ( wpbm_shortcode_type == 'booking-manager-import' ) {
1334
1335 wpbm_shortcode += 'booking-manager-import';
1336
1337 ////////////////////////////////////////////////////////////////
1338 // URL
1339 ////////////////////////////////////////////////////////////////
1340 if ( jQuery( '#wpbm_ics_import_url' ).val().trim() != '' ) {
1341 var wpbm_shortcode_url_temp = jQuery( '#wpbm_ics_import_url' ).val().trim().replace(/'/gi, '');
1342 wpbm_shortcode += ' url=\'' + wpbm_shortcode_url_temp + '\'';
1343 } else {
1344 wpbm_shortcode = '[ URL is required '
1345 jQuery( '#wpbm_text_put_in_shortcode' ).css( 'color', '#F00' );
1346 return wpbm_shortcode;
1347 }
1348
1349 ////////////////////////////////////////////////////////////////
1350 // Booking resource ID
1351 ////////////////////////////////////////////////////////////////
1352 if ( jQuery( '#wpbm_ics_import_booking_resource' ).length >0 ){ //FixIn: 2.0.3.1
1353 var p_br = parseInt( jQuery( '#wpbm_ics_import_booking_resource' ).val().trim() );
1354
1355 if ( p_br > 0 ){
1356 wpbm_shortcode += ' resource_id=' + p_br;
1357 }
1358 }
1359 ////////////////////////////////////////////////////////////////
1360 // FROM
1361 ////////////////////////////////////////////////////////////////
1362 var p_from = jQuery( '#wpbm_ics_import_from' ).val().trim();
1363 var p_from_offset = jQuery( '#wpbm_ics_import_from_offset' ).val().trim();
1364
1365 // Hide | Show date/offset labels
1366 if ( p_from == 'date' ) {
1367 jQuery( '.booking_manager_import .wpbm_from_offset' ).hide();
1368 jQuery( '.booking_manager_import .wpbm_from_date' ).show();
1369 } else {
1370 jQuery( '.booking_manager_import .wpbm_from_offset' ).show();
1371 jQuery( '.booking_manager_import .wpbm_from_date' ).hide();
1372 }
1373 if ( p_from == 'any' ) {
1374 jQuery( '.booking_manager_import .wpbm_from_offset' ).hide();
1375 jQuery( '.booking_manager_import .wpbm_from_date, #wpbm_ics_import_from_offset' ).hide();
1376 } else {
1377 jQuery( '#wpbm_ics_import_from_offset' ).show();
1378 }
1379
1380
1381 if ( p_from != 'date' ) {
1382
1383 wpbm_shortcode += ' from=\'' + p_from + '\'';
1384
1385 if ( ( p_from != 'any' ) && ( p_from_offset != '' ) ){
1386 p_from_offset = parseInt( p_from_offset );
1387 if ( ! isNaN( p_from_offset ) )
1388 wpbm_shortcode += ' from_offset=\'' + p_from_offset
1389 + jQuery( '#wpbm_ics_import_from_offset_type' ).val().trim().charAt(0)
1390 + '\'';
1391 }
1392
1393 } else if ( ( p_from == 'date' ) && ( p_from_offset != '' ) ){ // If selected Date
1394
1395 wpbm_shortcode += ' from=\'' + p_from_offset + '\'';
1396 }
1397
1398 ////////////////////////////////////////////////////////////////
1399 // Until
1400 ////////////////////////////////////////////////////////////////
1401 var p_until = jQuery( '#wpbm_ics_import_until' ).val().trim();
1402 var p_until_offset = jQuery( '#wpbm_ics_import_until_offset' ).val().trim();
1403
1404 // Hide | Show date/offset labels
1405 if ( p_until == 'date' ) {
1406 jQuery( '.booking_manager_import .wpbm_until_offset' ).hide();
1407 jQuery( '.booking_manager_import .wpbm_until_date' ).show();
1408 } else {
1409 jQuery( '.booking_manager_import .wpbm_until_offset' ).show();
1410 jQuery( '.booking_manager_import .wpbm_until_date' ).hide();
1411 }
1412 if ( p_until == 'any' ) {
1413 jQuery( '.booking_manager_import .wpbm_until_offset' ).hide();
1414 jQuery( '.booking_manager_import .wpbm_until_date, #wpbm_ics_import_until_offset' ).hide();
1415 } else {
1416 jQuery( '#wpbm_ics_import_until_offset' ).show();
1417 }
1418
1419
1420
1421
1422 if ( p_until != 'date' ){
1423
1424 wpbm_shortcode += ' until=\'' + p_until + '\'';
1425
1426 if ( ( p_until != 'any' ) && ( p_until_offset != '' ) ) {
1427 p_until_offset = parseInt( p_until_offset );
1428 if ( ! isNaN( p_until_offset ) )
1429 wpbm_shortcode += ' until_offset=\'' + p_until_offset
1430 + jQuery( '#wpbm_ics_import_until_offset_type' ).val().trim().charAt(0)
1431 + '\'';
1432 }
1433
1434 } else if ( ( p_until == 'date' ) && ( p_until_offset != '' ) ){ // If selected Date
1435
1436 wpbm_shortcode += ' until=\'' + p_until_offset + '\'';
1437 }
1438
1439 ////////////////////////////////////////////////////////////////
1440 // Max
1441 ////////////////////////////////////////////////////////////////
1442 var p_max = parseInt( jQuery( '#wpbm_ics_import_max' ).val().trim() );
1443
1444
1445 if ( p_max != 0 ) {
1446 wpbm_shortcode += ' max=' + p_max;
1447 }
1448
1449 ////////////////////////////////////////////////////////////////
1450 // import_conditions
1451 ////////////////////////////////////////////////////////////////
1452 var p_import_conditions = jQuery( '#wpbm_ics_import_import_conditions' ).val().trim();
1453
1454 if ( p_import_conditions != '' ) {
1455 wpbm_shortcode += ' import_conditions=\'' + p_import_conditions + '\'';
1456 }
1457
1458 ////////////////////////////////////////////////////////////////
1459 // is_all_dates_in
1460 ////////////////////////////////////////////////////////////////
1461 var p_is_all_dates_in = parseInt( jQuery( '#wpbm_import_is_all_dates_in' ).val().trim() );
1462
1463 if ( p_is_all_dates_in != 1 ) {
1464 wpbm_shortcode += ' is_all_dates_in=' + p_is_all_dates_in;
1465 }
1466
1467
1468 }
1469 return wpbm_shortcode;
1470 }
1471
1472 </script>
1473 <?php
1474 }
1475
1476
1477
1478 // Replace:
1479 // wpbm_ => opl
1480 // Booking Manager => Plugin Name
1481 // In "wpbm_get_tiny_tabs" => define shortcodes
1482 // Define func content wpbm_shortcode_ [ wpbm_ics_listing ]
1483