| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @category JavaScript files and varibales |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site https://wpbookingcalendar.com/ |
| 8 |
* @email info@wpbookingcalendar.com |
| 9 |
* |
| 10 |
* @modified 19.10.2015 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
class WPBC_JS extends WPBC_JS_CSS { |
| 16 |
|
| 17 |
public function define() { |
| 18 |
|
| 19 |
$this->setType('js'); |
| 20 |
|
| 21 |
/* |
| 22 |
$this->add( array( |
| 23 |
'handle' => 'wpbc-datepick', |
| 24 |
'src' => wpbc_plugin_url( '/js/datepick/jquery.datepick.js'), |
| 25 |
'deps' => array( 'wpbc_all' ), |
| 26 |
'version' => '1.1', |
| 27 |
'where_to_load' => array( 'admin', 'client' ), //Usage: array( 'admin', 'client' ) |
| 28 |
'condition' => false |
| 29 |
) ); |
| 30 |
*/ |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Enqueue Files and Varibales. |
| 35 |
* Useful in case, if we use get_options and current user functions... |
| 36 |
* |
| 37 |
* @param type $where_to_load |
| 38 |
*/ |
| 39 |
public function enqueue( $where_to_load ) { |
| 40 |
|
| 41 |
wpbc_remove_js_conflicts(); // FixIn: 9.5.4.2. |
| 42 |
|
| 43 |
wpbc_js_load_vars( $where_to_load ); |
| 44 |
do_action( 'wpbc_define_js_vars', $where_to_load ); // Define JavaScript variables in all other files |
| 45 |
|
| 46 |
wpbc_js_load_libs( $where_to_load ); |
| 47 |
wpbc_js_load_files( $where_to_load ); |
| 48 |
|
| 49 |
if ( wpbc_is_admin_page_with_frontend_booking_preview() ) { |
| 50 |
$where_to_load = 'both'; |
| 51 |
} |
| 52 |
|
| 53 |
// Load JavaScript files in all other versions |
| 54 |
do_action( 'wpbc_enqueue_js_files', $where_to_load ); |
| 55 |
|
| 56 |
/* |
| 57 |
* Remove `async` and `defer` ( check more here https://javascript.info/script-async-defer ) |
| 58 |
* for scripts registered or enqueued, that required for correct working of plugin, like |
| 59 |
* jquery and all Booking Calendar scripts |
| 60 |
* because inside content of the page can be something like jQuery( document ).ready( function(){ ...} which will |
| 61 |
* generate Uncaught ReferenceError: jQuery is not defined |
| 62 |
*/ |
| 63 |
add_filter( 'script_loader_tag', array( $this, 'filter_script_loader_tag' ), 9000000000 , 3 ); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
/** |
| 68 |
* Preserve the required execution order for Booking Calendar scripts. |
| 69 |
* |
| 70 |
* Removes asynchronous loading attributes and excludes the scripts from |
| 71 |
* Cloudflare Rocket Loader. The filter runs at a very late priority so these |
| 72 |
* protections remain present after other script-tag optimization filters. |
| 73 |
* |
| 74 |
* @param string $tag The script tag. |
| 75 |
* @param string $handle The registered script handle. |
| 76 |
* @param string $src The script source URL. |
| 77 |
* |
| 78 |
* @return string Filtered script HTML string. |
| 79 |
*/ |
| 80 |
public function filter_script_loader_tag( $tag, $handle, $src ) { |
| 81 |
$is_required_script = ( |
| 82 |
( 'jquery-core' === $handle ) |
| 83 |
|| ( 'jquery-migrate' === $handle ) |
| 84 |
|| ( false !== strpos( $handle, 'wpbc_' ) ) // Booking Calendar script wpbc_all.js // FixIn: 10.1.2.3. |
| 85 |
|| ( false !== strpos( $handle, 'wpbc-' ) ) // Booking Calendar scripts |
| 86 |
|| ( false !== strpos( $handle, 'wpdevelop-' ) ) |
| 87 |
|| ( false !== strpos( $handle, 'wpbm-' ) ) |
| 88 |
); |
| 89 |
|
| 90 |
if ( $is_required_script ) { |
| 91 |
foreach ( array( 'async', 'defer' ) as $attr ) { |
| 92 |
// Match only a standalone attribute, not the "async" part of data-cfasync. |
| 93 |
$pattern = '/\s+' . $attr . '(?:\s*=\s*(?:"[^"]*"|\'[^\']*\'|[^\s>]+))?/i'; |
| 94 |
$tag = preg_replace( $pattern, '', $tag ); |
| 95 |
} |
| 96 |
|
| 97 |
// Rocket Loader can otherwise execute dependent scripts before wpbc_all.js defines _wpbc. |
| 98 |
if ( false === strpos( $tag, 'data-cfasync=' ) ) { |
| 99 |
$tag = preg_replace( '/<script\b/i', '<script data-cfasync="false"', $tag, 1 ); |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
return $tag; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
/** |
| 108 |
* Deregister some conflict scripts from other plugins. |
| 109 |
* |
| 110 |
* @param type $where_to_load |
| 111 |
*/ |
| 112 |
public function remove_conflicts( $where_to_load ) { |
| 113 |
|
| 114 |
if ( wpbc_is_bookings_page() ) { |
| 115 |
if (function_exists('wp_dequeue_script')) { |
| 116 |
//wp_dequeue_script( 'jquery.cookie' ); |
| 117 |
//wp_dequeue_script( 'jquery-interdependencies' ); |
| 118 |
wp_dequeue_script( 'chosen' ); |
| 119 |
wp_dequeue_script( 'cs-framework' ); |
| 120 |
wp_dequeue_script( 'cgmp-jquery-tools-tooltip' ); // Remove this script jquery.tools.tooltip.min.js, which is load by the "Comprehensive Google Map Plugin" |
| 121 |
wp_dequeue_script( 'bootstrap-script' ); |
| 122 |
} |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
/** Define JavaScript Varibales */ |
| 129 |
function wpbc_js_load_vars( $where_to_load ) { |
| 130 |
|
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
/** Default JavaScripts Libraries */ |
| 136 |
function wpbc_js_load_libs( $where_to_load ) { |
| 137 |
|
| 138 |
wp_enqueue_script( 'jquery' ); // jQuery. |
| 139 |
|
| 140 |
// $src = ''; |
| 141 |
// $deps = ''; |
| 142 |
// $ver = false; |
| 143 |
// wp_enqueue_script( 'jquery', $src, $deps, $ver, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); |
| 144 |
|
| 145 |
// Default Admin Libs |
| 146 |
if ( 'admin' == $where_to_load ) { |
| 147 |
if ( wpbc_is_settings_page() ) { |
| 148 |
wp_enqueue_style( 'thickbox' ); // CSS Thickbox |
| 149 |
wp_enqueue_script( 'thickbox' ); // JS Thickbox |
| 150 |
wp_enqueue_media(); |
| 151 |
} |
| 152 |
wp_enqueue_style( 'wp-color-picker' ); // Color Picker |
| 153 |
wp_enqueue_script( 'wp-color-picker' ); |
| 154 |
wp_enqueue_script( 'jquery-ui-sortable' ); // UI Sortable |
| 155 |
} |
| 156 |
|
| 157 |
// WP Util, that support wp.template, based on underscore _.template system |
| 158 |
wp_enqueue_script( 'wp-util' ); //FixIn: TimeFreeGenerator // FixIn: 9.4.4.11. |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
/** Load JavaScript Files */ |
| 163 |
function wpbc_js_load_files( $where_to_load ) { |
| 164 |
|
| 165 |
wp_enqueue_script( 'wpbc_all', wpbc_plugin_url( '/_dist/all/_out/wpbc_all.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 9.8.6.1. |
| 166 |
|
| 167 |
/** |
| 168 |
* Popover functionality. |
| 169 |
* Popover based on Tippy.js ( https://atomiks.github.io/tippyjs/v6/all-props/#allowhtml ), which is based on popper.js ( https://popper.js.org/docs/v2/tutorial/ ) |
| 170 |
* Install Alt + F12 run |
| 171 |
* npm i @popperjs/core |
| 172 |
* npm i tippy.js |
| 173 |
* Copy ..\node_modules\@popperjs\core\dist\umd to ..\wp-content/plugins/booking/vendors/_custom/popper |
| 174 |
* Copy ..\node_modules\tippy.js\{dist && themes} to ..\wp-content/plugins/booking/vendors/_custom/tippy.js |
| 175 |
* In popper.js edit global.Popper to global.wpbc_Popper |
| 176 |
* In tippy-bundle.umd.js edit global.Popper to global.wpbc_Popper and global.tippy to global.wpbc_tippy |
| 177 |
*/ |
| 178 |
wp_enqueue_script( 'wpbc-popper', wpbc_plugin_url( '/vendors/_custom/popper/popper.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 9.0.1.1. |
| 179 |
wp_enqueue_script( 'wpbc-tipcy', wpbc_plugin_url( '/vendors/_custom/tippy.js/dist/tippy-bundle.umd.js' ), array( 'wpbc-popper' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); //FixIn: 9.8.1 |
| 180 |
|
| 181 |
if ( $where_to_load != 'client' ) { |
| 182 |
wp_enqueue_script( 'wpbc-modal', wpbc_plugin_url( '/vendors/_custom/dropdown_modal/_out/dropdown_modal.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); //FixIn: 9.8.1 |
| 183 |
} |
| 184 |
|
| 185 |
wp_enqueue_script( 'wpbc-datepick', wpbc_plugin_url( '/js/datepick/jquery.datepick.wpbc.9.0.js'), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); //FixIn: 9.8.1 |
| 186 |
$calendar_localization_url = wpbc_get_calendar_localization_url(); // Localization |
| 187 |
if ( ! empty( $calendar_localization_url ) ) { |
| 188 |
wp_enqueue_script( 'wpbc-datepick-localize', $calendar_localization_url, array( 'wpbc-datepick' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); //FixIn: 9.8.1 |
| 189 |
} |
| 190 |
|
| 191 |
if ( ( $where_to_load == 'client' ) || wpbc_is_admin_page_with_frontend_booking_preview() ) { |
| 192 |
|
| 193 |
wp_enqueue_script( 'wpbc-main-client', wpbc_plugin_url( '/js/client.js' ), array( 'wpbc-datepick' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // Client |
| 194 |
wp_enqueue_script( 'wpbc_capacity', wpbc_plugin_url( '/includes/_capacity/_out/create_booking.js' ), array( 'wpbc-main-client' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // Add new bookings // FixIn: 9.8.0.3. |
| 195 |
wp_enqueue_script( 'wpbc-times', wpbc_plugin_url( '/js/wpbc_times.js' ), array( 'wpbc-main-client' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: TimeFree 2 //UnComment it for Booking Calendar Free version |
| 196 |
// if ( ( 'On' === get_bk_option( 'booking_timeslot_picker' ) ) || ( wpbc_is_setup_wizard_page() ) ) { |
| 197 |
wp_enqueue_script( 'wpbc-time-selector', wpbc_plugin_url( '/js/wpbc_time-selector.js'), array( 'wpbc-times' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 8.7.11.10. |
| 198 |
// } |
| 199 |
wp_enqueue_script( 'wpbc-imask', wpbc_plugin_url( '/vendors/imask/dist/imask.js'), array( 'wpbc-main-client' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 10.12.4.10. |
| 200 |
$booking_is_use_phone_validation = get_bk_option( 'booking_is_use_phone_validation' ); |
| 201 |
if ( 'On' === $booking_is_use_phone_validation ) { |
| 202 |
wp_enqueue_script( 'wpbc-iphone-validator', wpbc_plugin_url( '/js/wpbc_phone_validator.js' ), array( 'wpbc-imask' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 10.12.4.10. |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
if ( 'admin' === $where_to_load ) { |
| 207 |
wp_enqueue_script( 'wpbc-js-print', wpbc_plugin_url( '/vendors/_custom/wpbc_js_print/wpbc_js_print.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 9.8.1 //FixIn: 9.2.1.6 // FixIn: 9.1.2.13. |
| 208 |
wp_enqueue_script( 'wpbc-admin-main', wpbc_plugin_url( '/js/admin.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // Admin. |
| 209 |
if ( wpbc_can_i_load_on_this_page__shortcode_config() ) { |
| 210 |
wp_enqueue_script( 'wpbc_shortcode_popup', wpbc_plugin_url( '/includes/ui_modal__shortcodes/_out/wpbc_shortcode_popup.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 9.8.6.1. |
| 211 |
} |
| 212 |
wp_enqueue_script( 'wpbc-admin-support', wpbc_plugin_url( '/core/any/js/admin-support.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); |
| 213 |
wp_enqueue_script( 'wpbc-chosen', wpbc_plugin_url( '/vendors/chosen/chosen.jquery.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // Chosen Library. |
| 214 |
|
| 215 |
// FixIn: 10.12.2.3. // docs: https://www.npmjs.com/package/simplebar#5-caveats . |
| 216 |
wp_enqueue_script( 'wpbc-simplebar', wpbc_plugin_url( '/vendors/simplebar/dist/simplebar.min.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // Chosen Library. |
| 217 |
wp_enqueue_style( 'wpbc-simplebar', wpbc_plugin_url( '/vendors/simplebar/dist/simplebar.min.css' ), array(), WP_BK_VERSION_NUM ); |
| 218 |
} |
| 219 |
if ( in_array( $where_to_load, array( 'admin', 'both' ), true ) ) { |
| 220 |
wp_enqueue_script( 'wpbc_all_admin', wpbc_plugin_url( '/_dist/all/_out/wpbc_all_admin.js' ), array( 'wpbc_all' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
/** |
| 226 |
* Remove JS libraries that conflict with Booking Calendar at the pages with booking forms. |
| 227 |
* |
| 228 |
* You can disable loading of all Booking Calendar JavaScript files at the Booking > Settings General page in "Advanced" section. |
| 229 |
* To do so, you can expand the "Show advanced settings of JavaScript loading" option and select the "Load JS and CSS files only on specific pages" checkbox. |
| 230 |
* You can then specify a list of pages in a textarea where you want the Booking Calendar to appear. |
| 231 |
* |
| 232 |
* @return void |
| 233 |
*/ |
| 234 |
function wpbc_remove_js_conflicts() { |
| 235 |
//if ( wp_script_is( 'script-ID', 'registered' ) ) { } |
| 236 |
wp_deregister_script( 'mphb-kbwood-datepick' ); |
| 237 |
} |
| 238 |
|
| 239 |
//////////////////////////////////////////////////////////////////////////////// |
| 240 |
// Support JavaScript functions |
| 241 |
//////////////////////////////////////////////////////////////////////////////// |
| 242 |
|
| 243 |
/** |
| 244 |
* Get URL Datepicker Localization JS File |
| 245 |
* |
| 246 |
* @return string - URL to calendar skin |
| 247 |
*/ |
| 248 |
function wpbc_get_calendar_localization_url() { |
| 249 |
// Datepicker Localization - translation for calendar. Example: $locale = 'fr_FR'; |
| 250 |
$locale = wpbc_get_maybe_reloaded_booking_locale(); |
| 251 |
|
| 252 |
$calendar_localization_url = false; |
| 253 |
|
| 254 |
if ( ! empty( $locale ) ) { |
| 255 |
|
| 256 |
$locale_lang = strtolower( substr( $locale, 0, 2 ) ); // 7.0.1.51 |
| 257 |
$locale_country = strtolower( substr( $locale, 3 ) ); |
| 258 |
|
| 259 |
if ( ( $locale_lang !== 'en') && ( wpbc_is_file_exist( '/js/datepick/jquery.datepick-' . $locale_lang . '.js' ) ) ) { |
| 260 |
|
| 261 |
$calendar_localization_url = wpbc_plugin_url( '/js/datepick/jquery.datepick-'. $locale_lang . '.js' ); |
| 262 |
|
| 263 |
} else if ( ( ! in_array( $locale, array( 'en_US', 'en_CA', 'en_GB', 'en_AU' ) ) ) // English Exceptions |
| 264 |
&& ( wpbc_is_file_exist( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ) ) |
| 265 |
) { |
| 266 |
|
| 267 |
$calendar_localization_url = wpbc_plugin_url( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
return $calendar_localization_url; |
| 272 |
} |
| 273 |
|
| 274 |
|
| 275 |
/** |
| 276 |
* Check if we activated loading of JS/CSS only on specific pages and then load or no it |
| 277 |
* |
| 278 |
* @param boolean $is_load_scripts - Default: true |
| 279 |
* @return boolean - true | false |
| 280 |
*/ |
| 281 |
function wpbc_is_load_css_js_on_client_page( $is_load_scripts ) { |
| 282 |
|
| 283 |
if ( ! is_admin() ) { // Check on Client side only |
| 284 |
|
| 285 |
$booking_is_load_js_css_on_specific_pages = get_bk_option( 'booking_is_load_js_css_on_specific_pages' ); |
| 286 |
if ( $booking_is_load_js_css_on_specific_pages == 'On' ) { |
| 287 |
|
| 288 |
$booking_pages_for_load_js_css = get_bk_option( 'booking_pages_for_load_js_css' ); |
| 289 |
|
| 290 |
$booking_pages_for_load_js_css = preg_split('/[\r\n]+/', $booking_pages_for_load_js_css, -1, PREG_SPLIT_NO_EMPTY); |
| 291 |
|
| 292 |
$server_request_uri = ( ( isset( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */ |
| 293 |
$request_uri = $server_request_uri; //FixIn:5.4.1 |
| 294 |
// FixIn: 8.4.5.8. |
| 295 |
if ( |
| 296 |
( strpos( $request_uri, 'booking_hash=') !== false ) |
| 297 |
|| ( strpos( $request_uri, 'check_in=') !== false ) |
| 298 |
) { |
| 299 |
$request_uri = wp_parse_url($request_uri); |
| 300 |
if ( ( ! empty($request_uri ) ) && ( isset($request_uri['path'] ) ) ){ |
| 301 |
$request_uri = $request_uri['path']; |
| 302 |
} else { |
| 303 |
$server_request_uri = ( ( isset( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */ |
| 304 |
$request_uri = $server_request_uri; |
| 305 |
} |
| 306 |
} |
| 307 |
|
| 308 |
if ( ( ! empty( $booking_pages_for_load_js_css ) ) && ( ! in_array( $request_uri, $booking_pages_for_load_js_css ) ) ) { |
| 309 |
|
| 310 |
wp_add_inline_script( 'jquery', "console.log( '== WPBC :: Loading of JS/CSS files disabled for this page at WP Booking Calendar > Settings General page in Advanced section ==' );" ); |
| 311 |
return false; |
| 312 |
} |
| 313 |
} |
| 314 |
} |
| 315 |
return true; |
| 316 |
} |
| 317 |
add_filter( 'wpbc_is_load_script_on_this_page', 'wpbc_is_load_css_js_on_client_page' ); |
| 318 |
|
| 319 |
/** |
| 320 |
* Load JS and CSS files for loading modals correctly |
| 321 |
* |
| 322 |
* @return void |
| 323 |
*/ |
| 324 |
function wpbc_load_js__required_for_modals() { |
| 325 |
|
| 326 |
// JS for opening Modals. |
| 327 |
wp_enqueue_script( 'wpbc-modal', wpbc_plugin_url( '/vendors/_custom/dropdown_modal/_out/dropdown_modal.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 9.8.1. |
| 328 |
|
| 329 |
// CSS. |
| 330 |
wp_enqueue_style( 'wpdevelop-bts', wpbc_plugin_url( '/vendors/_custom/bootstrap-css/css/bootstrap.css' ), array(), WP_BK_VERSION_NUM ); // FixIn: 9.8.1. |
| 331 |
wp_enqueue_style( 'wpdevelop-bts-theme', wpbc_plugin_url( '/vendors/_custom/bootstrap-css/css/bootstrap-theme.css' ), array(), WP_BK_VERSION_NUM ); // FixIn: 9.8.1. |
| 332 |
|
| 333 |
wp_enqueue_style( 'wpbc-admin-support', wpbc_plugin_url( '/core/any/css/admin-support.css' ), array(), WP_BK_VERSION_NUM ); |
| 334 |
wp_enqueue_style( 'wpbc-admin-menu', wpbc_plugin_url( '/core/any/css/admin-menu.css' ), array(), WP_BK_VERSION_NUM ); |
| 335 |
// wp_enqueue_style( 'wpbc-admin-toolbar', wpbc_plugin_url( '/core/any/css/admin-toolbar.css' ), array(), WP_BK_VERSION_NUM ); // . |
| 336 |
wp_enqueue_style( 'wpbc-flex-toolbar', wpbc_plugin_url( '/includes/_toolbar_ui/_out/toolbar_ui.css' ), array(), WP_BK_VERSION_NUM ); |
| 337 |
wp_enqueue_style( 'wpbc-admin-modal-popups', wpbc_plugin_url( '/css/modal.css' ), array(), WP_BK_VERSION_NUM ); |
| 338 |
wp_enqueue_style( 'wpbc-admin-pages', wpbc_plugin_url( '/css/admin.css' ), array(), WP_BK_VERSION_NUM ); |
| 339 |
wp_enqueue_style( 'wpbc-admin-skin', wpbc_plugin_url( '/css/admin-skin.css' ), array( 'wpbc-admin-pages' ), WP_BK_VERSION_NUM ); // FixIn: 8.0.2.4. |
| 340 |
} |
| 341 |
|
| 342 |
/** |
| 343 |
* Load only the modal assets required by front-end popup shortcodes. |
| 344 |
* |
| 345 |
* This intentionally avoids the broader admin helper above, because front-end |
| 346 |
* pages should not receive admin page/menu styles when only a modal booking |
| 347 |
* form is needed. |
| 348 |
* |
| 349 |
* @return void |
| 350 |
*/ |
| 351 |
function wpbc_load_js__required_for_front_end_modals() { |
| 352 |
|
| 353 |
// JS for opening modals. |
| 354 |
wp_enqueue_script( 'wpbc-modal', wpbc_plugin_url( '/vendors/_custom/dropdown_modal/_out/dropdown_modal.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); // FixIn: 9.8.1. |
| 355 |
|
| 356 |
// Base Bootstrap CSS is already loaded by Booking Calendar in normal front-end rendering. |
| 357 |
if ( ! wp_style_is( 'wpdevelop-bts', 'enqueued' ) && ! wp_style_is( 'wpdevelop-bts', 'done' ) ) { |
| 358 |
wp_enqueue_style( 'wpdevelop-bts', wpbc_plugin_url( '/vendors/_custom/bootstrap-css/css/bootstrap.css' ), array(), WP_BK_VERSION_NUM ); // FixIn: 9.8.1. |
| 359 |
} |
| 360 |
if ( ! wp_style_is( 'wpdevelop-bts-theme', 'enqueued' ) && ! wp_style_is( 'wpdevelop-bts-theme', 'done' ) ) { |
| 361 |
wp_enqueue_style( 'wpdevelop-bts-theme', wpbc_plugin_url( '/vendors/_custom/bootstrap-css/css/bootstrap-theme.css' ), array(), WP_BK_VERSION_NUM ); // FixIn: 9.8.1. |
| 362 |
} |
| 363 |
|
| 364 |
wp_enqueue_style( 'wpbc-admin-modal-popups', wpbc_plugin_url( '/css/modal.css' ), array(), WP_BK_VERSION_NUM ); |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
/** |
| 369 |
* Load JS and CSS files for opening Media Upload PopUp in Admin Panel |
| 370 |
* |
| 371 |
* @return void |
| 372 |
*/ |
| 373 |
function wpbc_load_js__required_for_media_upload(){ |
| 374 |
|
| 375 |
/** |
| 376 |
* Internal WordPress depending on: |
| 377 |
* 'wp-util' -> array( 'underscore', 'jquery' ) |
| 378 |
* 'wp-backbone' -> array( 'backbone', 'wp-util' ) |
| 379 |
* wp_enqueue_script( 'media-editor' ) -> 'wp-backbone' |
| 380 |
*/ |
| 381 |
if ( ! wpbc_is_this_demo() ) { |
| 382 |
wp_enqueue_media(); |
| 383 |
wp_enqueue_script( 'wpbc_ui__media_upload', wpbc_plugin_url( '/includes/_media_upload/_out/wpbc_ui__media_upload.js' ), array( |
| 384 |
'jquery', |
| 385 |
'media-editor' |
| 386 |
), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); |
| 387 |
} else { |
| 388 |
$script = "jQuery(document).ready(function() { "; |
| 389 |
$script .= " jQuery( '.wpbc_media_upload_button' ).on( 'click', function( event ) { "; |
| 390 |
$script .= " alert('Warning! This feature is restricted in the public live demo.' ); "; |
| 391 |
$script .= " }); "; |
| 392 |
$script .= "}); "; |
| 393 |
wp_add_inline_script( 'jquery', $script ); |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
/** |
| 399 |
* On jQuery(...).ready function Start |
| 400 |
* |
| 401 |
* @return string |
| 402 |
*/ |
| 403 |
function wpbc_jq_ready_start() { |
| 404 |
|
| 405 |
return "(function() { var a = setInterval( function() { if ( ( 'undefined' === typeof _wpbc ) || ( 'undefined' === typeof jQuery ) || ! window.jQuery ) { return; } clearInterval( a ); jQuery( document ).ready( function (){"; |
| 406 |
|
| 407 |
// Help description: |
| 408 |
?><script type="text/javascript"> |
| 409 |
(function (){ |
| 410 |
var a = setInterval( function (){ |
| 411 |
if ( ('undefined' === typeof jQuery) || !window.jQuery ){ |
| 412 |
return; |
| 413 |
} |
| 414 |
clearInterval( a ); |
| 415 |
// Here can be executed jQuery functions |
| 416 |
jQuery( document ).ready( function (){ |
| 417 |
// Here is my code start |
| 418 |
} ); |
| 419 |
}, 500 ); |
| 420 |
})(); |
| 421 |
</script><?php |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
/** |
| 426 |
* On jQuery(...).ready function end |
| 427 |
* @return string |
| 428 |
*/ |
| 429 |
function wpbc_jq_ready_end() { |
| 430 |
|
| 431 |
return "} ); }, 500 ); })();"; |
| 432 |
} |
| 433 |
|