PluginProbe
Booking Calendar / 11.1
Booking Calendar v11.1
11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 All 202 releases
booking / core / wpbc-js.php

wpbc-js.php in Booking Calendar 11.1, at core/wpbc-js.php

424 lines 20.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_new_booking_page() || wpbc_is_settings_form_page() || wpbc_is_settings_color_themes_page() || wpbc_is_setup_wizard_page() || ( function_exists( 'wpbc_is_add_booking_modal_on_booking_listing_page' ) && wpbc_is_add_booking_modal_on_booking_listing_page() ) ) {
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 * Remove `async` and `defer` ( check more here https://javascript.info/script-async-defer )
69 * for scripts registered or enqueued, that required for correct working of plugin, like
70 * jquery and all Booking Calendar scripts
71 *
72 * @param string $tag The script tag.
73 * @param string $handle The script handle.
74 *
75 * @return string Script HTML string.
76 *
77 */
78 public function filter_script_loader_tag( $tag, $handle, $src ) {
79
80 $script_handles_prevent_defer = array(
81 'jquery-core' // exact value
82 , 'jquery-migrate'
83 //, 'wpbc-' //starting from 'wpbc-' it's not the exact value
84 //, 'wpdevelop-'
85 );
86
87
88 // Remove defer and async attribute from the src.
89 if (
90 ( 'jquery-core' === $handle )
91 || ( 'jquery-migrate' === $handle )
92 || ( false !== strpos( $handle, 'wpbc_' ) ) // Booking Calendar script wpbc_all.js // FixIn: 10.1.2.3.
93 || ( false !== strpos( $handle, 'wpbc-' ) ) // Booking Calendar scripts
94 || ( false !== strpos( $handle, 'wpdevelop-' ) )
95 || ( false !== strpos( $handle, 'wpbm-' ) )
96 ) {
97
98 foreach ( array( 'async', 'defer' ) as $attr ) {
99
100 if ( preg_match( ":\s$attr(=|>|\s):", $tag ) ) {
101 $tag = str_replace($attr, '', $tag);
102 $tag = str_replace('=""', '', $tag);
103 $tag = str_replace("=''", '', $tag);
104
105 /*
106 * Test here https://regex101.com/
107 *
108 * Expression: \s+defer(\s*=\s*["']defer["'])?\s?
109 * Test string: <script type='text/javascript' defer = 'defer' defer="defer" src='http://beta/wp-content/plugins/booking-manager/js/wpbm_vars.js?ver=1.1' id='wpbm-global-vars-js'></script>
110 *
111 */
112 $pattern = ":\s+{$attr}(\s*=\s*[\"']{$attr}[\"'])?\s?:mi";
113 $replacement = ' ';
114 $tag = preg_replace($pattern, $replacement, $tag);
115 }
116 }
117 }
118
119 return $tag;
120 }
121
122
123 /**
124 * Deregister some conflict scripts from other plugins.
125 *
126 * @param type $where_to_load
127 */
128 public function remove_conflicts( $where_to_load ) {
129
130 if ( wpbc_is_bookings_page() ) {
131 if (function_exists('wp_dequeue_script')) {
132 //wp_dequeue_script( 'jquery.cookie' );
133 //wp_dequeue_script( 'jquery-interdependencies' );
134 wp_dequeue_script( 'chosen' );
135 wp_dequeue_script( 'cs-framework' );
136 wp_dequeue_script( 'cgmp-jquery-tools-tooltip' ); // Remove this script jquery.tools.tooltip.min.js, which is load by the "Comprehensive Google Map Plugin"
137 wp_dequeue_script( 'bootstrap-script' );
138 }
139 }
140 }
141 }
142
143
144 /** Define JavaScript Varibales */
145 function wpbc_js_load_vars( $where_to_load ) {
146
147
148 }
149
150
151 /** Default JavaScripts Libraries */
152 function wpbc_js_load_libs( $where_to_load ) {
153
154 wp_enqueue_script( 'jquery' ); // jQuery.
155
156 // $src = '';
157 // $deps = '';
158 // $ver = false;
159 // wp_enqueue_script( 'jquery', $src, $deps, $ver, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
160
161 // Default Admin Libs
162 if ( 'admin' == $where_to_load ) {
163 if ( wpbc_is_settings_page() ) {
164 wp_enqueue_style( 'thickbox' ); // CSS Thickbox
165 wp_enqueue_script( 'thickbox' ); // JS Thickbox
166 wp_enqueue_media();
167 }
168 wp_enqueue_style( 'wp-color-picker' ); // Color Picker
169 wp_enqueue_script( 'wp-color-picker' );
170 wp_enqueue_script( 'jquery-ui-sortable' ); // UI Sortable
171 }
172
173 // WP Util, that support wp.template, based on underscore _.template system
174 wp_enqueue_script( 'wp-util' ); //FixIn: TimeFreeGenerator // FixIn: 9.4.4.11.
175 }
176
177
178 /** Load JavaScript Files */
179 function wpbc_js_load_files( $where_to_load ) {
180
181 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.
182
183 /**
184 * Popover functionality.
185 * 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/ )
186 * Install Alt + F12 run
187 * npm i @popperjs/core
188 * npm i tippy.js
189 * Copy ..\node_modules\@popperjs\core\dist\umd to ..\wp-content/plugins/booking/vendors/_custom/popper
190 * Copy ..\node_modules\tippy.js\{dist && themes} to ..\wp-content/plugins/booking/vendors/_custom/tippy.js
191 * In popper.js edit global.Popper to global.wpbc_Popper
192 * In tippy-bundle.umd.js edit global.Popper to global.wpbc_Popper and global.tippy to global.wpbc_tippy
193 */
194 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.
195 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
196
197 if ( $where_to_load != 'client' ) {
198 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
199 }
200
201 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
202 $calendar_localization_url = wpbc_get_calendar_localization_url(); // Localization
203 if ( ! empty( $calendar_localization_url ) ) {
204 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
205 }
206
207 if ( ( $where_to_load == 'client' ) || ( wpbc_is_new_booking_page() ) || ( function_exists( 'wpbc_is_add_booking_modal_on_booking_listing_page' ) && wpbc_is_add_booking_modal_on_booking_listing_page() ) || ( wpbc_is_settings_form_page() || wpbc_is_settings_color_themes_page() || wpbc_is_setup_wizard_page() || wpbc_is_builder_booking_form_page() ) ) {
208
209 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
210 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.
211 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
212 // if ( ( 'On' === get_bk_option( 'booking_timeslot_picker' ) ) || ( wpbc_is_setup_wizard_page() ) ) {
213 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.
214 // }
215 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.
216 $booking_is_use_phone_validation = get_bk_option( 'booking_is_use_phone_validation' );
217 if ( 'On' === $booking_is_use_phone_validation ) {
218 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.
219 }
220 }
221
222 if ( 'admin' === $where_to_load ) {
223 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.
224 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.
225 if ( wpbc_can_i_load_on_this_page__shortcode_config() ) {
226 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.
227 }
228 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 ) );
229 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.
230
231 // FixIn: 10.12.2.3. // docs: https://www.npmjs.com/package/simplebar#5-caveats .
232 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.
233 wp_enqueue_style( 'wpbc-simplebar', wpbc_plugin_url( '/vendors/simplebar/dist/simplebar.min.css' ), array(), WP_BK_VERSION_NUM );
234 }
235 if ( in_array( $where_to_load, array( 'admin', 'both' ), true ) ) {
236 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 ) );
237 }
238 }
239
240
241 /**
242 * Remove JS libraries that conflict with Booking Calendar at the pages with booking forms.
243 *
244 * You can disable loading of all Booking Calendar JavaScript files at the Booking > Settings General page in "Advanced" section.
245 * 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.
246 * You can then specify a list of pages in a textarea where you want the Booking Calendar to appear.
247 *
248 * @return void
249 */
250 function wpbc_remove_js_conflicts() {
251 //if ( wp_script_is( 'script-ID', 'registered' ) ) { }
252 wp_deregister_script( 'mphb-kbwood-datepick' );
253 }
254
255 ////////////////////////////////////////////////////////////////////////////////
256 // Support JavaScript functions
257 ////////////////////////////////////////////////////////////////////////////////
258
259 /**
260 * Get URL Datepicker Localization JS File
261 *
262 * @return string - URL to calendar skin
263 */
264 function wpbc_get_calendar_localization_url() {
265 // Datepicker Localization - translation for calendar. Example: $locale = 'fr_FR';
266 $locale = wpbc_get_maybe_reloaded_booking_locale();
267
268 $calendar_localization_url = false;
269
270 if ( ! empty( $locale ) ) {
271
272 $locale_lang = strtolower( substr( $locale, 0, 2 ) ); // 7.0.1.51
273 $locale_country = strtolower( substr( $locale, 3 ) );
274
275 if ( ( $locale_lang !== 'en') && ( wpbc_is_file_exist( '/js/datepick/jquery.datepick-' . $locale_lang . '.js' ) ) ) {
276
277 $calendar_localization_url = wpbc_plugin_url( '/js/datepick/jquery.datepick-'. $locale_lang . '.js' );
278
279 } else if ( ( ! in_array( $locale, array( 'en_US', 'en_CA', 'en_GB', 'en_AU' ) ) ) // English Exceptions
280 && ( wpbc_is_file_exist( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ) )
281 ) {
282
283 $calendar_localization_url = wpbc_plugin_url( '/js/datepick/jquery.datepick-'. $locale_country . '.js' );
284 }
285 }
286
287 return $calendar_localization_url;
288 }
289
290
291 /**
292 * Check if we activated loading of JS/CSS only on specific pages and then load or no it
293 *
294 * @param boolean $is_load_scripts - Default: true
295 * @return boolean - true | false
296 */
297 function wpbc_is_load_css_js_on_client_page( $is_load_scripts ) {
298
299 if ( ! is_admin() ) { // Check on Client side only
300
301 $booking_is_load_js_css_on_specific_pages = get_bk_option( 'booking_is_load_js_css_on_specific_pages' );
302 if ( $booking_is_load_js_css_on_specific_pages == 'On' ) {
303
304 $booking_pages_for_load_js_css = get_bk_option( 'booking_pages_for_load_js_css' );
305
306 $booking_pages_for_load_js_css = preg_split('/[\r\n]+/', $booking_pages_for_load_js_css, -1, PREG_SPLIT_NO_EMPTY);
307
308 $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 */
309 $request_uri = $server_request_uri; //FixIn:5.4.1
310 // FixIn: 8.4.5.8.
311 if (
312 ( strpos( $request_uri, 'booking_hash=') !== false )
313 || ( strpos( $request_uri, 'check_in=') !== false )
314 ) {
315 $request_uri = wp_parse_url($request_uri);
316 if ( ( ! empty($request_uri ) ) && ( isset($request_uri['path'] ) ) ){
317 $request_uri = $request_uri['path'];
318 } else {
319 $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 */
320 $request_uri = $server_request_uri;
321 }
322 }
323
324 if ( ( ! empty( $booking_pages_for_load_js_css ) ) && ( ! in_array( $request_uri, $booking_pages_for_load_js_css ) ) ) {
325
326 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 ==' );" );
327 return false;
328 }
329 }
330 }
331 return true;
332 }
333 add_filter( 'wpbc_is_load_script_on_this_page', 'wpbc_is_load_css_js_on_client_page' );
334
335 /**
336 * Load JS and CSS files for loading modals correctly
337 *
338 * @return void
339 */
340 function wpbc_load_js__required_for_modals() {
341
342 // JS for opening Modals.
343 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.
344
345 // CSS.
346 wp_enqueue_style( 'wpdevelop-bts', wpbc_plugin_url( '/vendors/_custom/bootstrap-css/css/bootstrap.css' ), array(), WP_BK_VERSION_NUM ); // FixIn: 9.8.1.
347 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.
348
349 wp_enqueue_style( 'wpbc-admin-support', wpbc_plugin_url( '/core/any/css/admin-support.css' ), array(), WP_BK_VERSION_NUM );
350 wp_enqueue_style( 'wpbc-admin-menu', wpbc_plugin_url( '/core/any/css/admin-menu.css' ), array(), WP_BK_VERSION_NUM );
351 // wp_enqueue_style( 'wpbc-admin-toolbar', wpbc_plugin_url( '/core/any/css/admin-toolbar.css' ), array(), WP_BK_VERSION_NUM ); // .
352 wp_enqueue_style( 'wpbc-flex-toolbar', wpbc_plugin_url( '/includes/_toolbar_ui/_out/toolbar_ui.css' ), array(), WP_BK_VERSION_NUM );
353 wp_enqueue_style( 'wpbc-admin-modal-popups', wpbc_plugin_url( '/css/modal.css' ), array(), WP_BK_VERSION_NUM );
354 wp_enqueue_style( 'wpbc-admin-pages', wpbc_plugin_url( '/css/admin.css' ), array(), WP_BK_VERSION_NUM );
355 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.
356 }
357
358
359 /**
360 * Load JS and CSS files for opening Media Upload PopUp in Admin Panel
361 *
362 * @return void
363 */
364 function wpbc_load_js__required_for_media_upload(){
365
366 /**
367 * Internal WordPress depending on:
368 * 'wp-util' -> array( 'underscore', 'jquery' )
369 * 'wp-backbone' -> array( 'backbone', 'wp-util' )
370 * wp_enqueue_script( 'media-editor' ) -> 'wp-backbone'
371 */
372 if ( ! wpbc_is_this_demo() ) {
373 wp_enqueue_media();
374 wp_enqueue_script( 'wpbc_ui__media_upload', wpbc_plugin_url( '/includes/_media_upload/_out/wpbc_ui__media_upload.js' ), array(
375 'jquery',
376 'media-editor'
377 ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
378 } else {
379 $script = "jQuery(document).ready(function() { ";
380 $script .= " jQuery( '.wpbc_media_upload_button' ).on( 'click', function( event ) { ";
381 $script .= " alert('Warning! This feature is restricted in the public live demo.' ); ";
382 $script .= " }); ";
383 $script .= "}); ";
384 wp_add_inline_script( 'jquery', $script );
385 }
386 }
387
388
389 /**
390 * On jQuery(...).ready function Start
391 *
392 * @return string
393 */
394 function wpbc_jq_ready_start() {
395
396 return "(function() { var a = setInterval( function() { if ( ( 'undefined' === typeof _wpbc ) || ( 'undefined' === typeof jQuery ) || ! window.jQuery ) { return; } clearInterval( a ); jQuery( document ).ready( function (){";
397
398 // Help description:
399 ?><script type="text/javascript">
400 (function (){
401 var a = setInterval( function (){
402 if ( ('undefined' === typeof jQuery) || !window.jQuery ){
403 return;
404 }
405 clearInterval( a );
406 // Here can be executed jQuery functions
407 jQuery( document ).ready( function (){
408 // Here is my code start
409 } );
410 }, 500 );
411 })();
412 </script><?php
413 }
414
415
416 /**
417 * On jQuery(...).ready function end
418 * @return string
419 */
420 function wpbc_jq_ready_end() {
421
422 return "} ); }, 500 ); })();";
423 }
424