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