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 / includes / ui_modal__shortcodes / shortcode_tpl_js_loader.php

shortcode_tpl_js_loader.php in Booking Calendar 11.1, at includes/ui_modal__shortcodes/shortcode_tpl_js_loader.php

116 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Template Loader for Booking Calendar shortcodes config in Popup
5 * @subpackage Template Loader
6 * @category Templates
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2024-02-03
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // FixIn: 9.9.0.15.
16
17
18 // =====================================================================================================================
19 // Load JS files at specific pages only
20 // =====================================================================================================================
21
22 /**
23 * Load JS files.
24 *
25 * @param $hook 'post.php' | 'wp-booking-calendar3_page_wpbc-resources'
26 *
27 * @return void
28 */
29 function wpbc_register_js__shortcode_config( $hook ) {
30
31 if ( wpbc_can_i_load_on_this_page__shortcode_config() ) {
32
33 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.
34 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.
35 wp_enqueue_script( 'wpbc-admin-support', wpbc_plugin_url( '/core/any/js/admin-support.js' ), array( 'jquery' ), WP_BK_VERSION_NUM, array( 'in_footer' => WPBC_JS_IN_FOOTER ) ); //Needed for ability to send dismiss //2024-03-13 // FixIn: 9.9.0.42.
36 if ( wpbc_can_i_load_on__edit_new_post_page() ) {
37 do_action( 'wpbc_enqueue_js_files', 'admin' );
38 }
39 }
40 }
41 add_action( 'admin_enqueue_scripts', 'wpbc_register_js__shortcode_config' );
42
43
44
45
46 //TODO: delete these code:
47 // =====================================================================================================================
48 // Load wp Templates
49 // =====================================================================================================================
50
51 /**
52 * On WordPress Init, define load of "WP Util, that support wp.template" and define Templates at Footer
53 * @return void
54 */
55 function wpbc_templates__init_hook__shortcode_config(){
56
57 if ( wpbc_can_i_load_on_this_page__shortcode_config() ) {
58
59 // Load: WP Util, that support wp.template, based on underscore _.template system
60 wp_enqueue_script( 'wp-util' );
61
62 // Load: Templates
63 add_action( 'admin_footer', 'wpbc_templates__shortcode_config__write_templates', 10, 2 );
64 }
65 }
66 //add_action( 'init', 'wpbc_templates__init_hook__shortcode_config' ); // Define init hooks
67
68
69 /**
70 * Write all needed templates for shortcode config at the footer.
71 */
72 function wpbc_templates__shortcode_config__write_templates(){
73
74
75 }
76
77
78 // =====================================================================================================================
79 // Info: E X A M P L E of Template Usage
80 // =====================================================================================================================
81 // * Template(s), that loaded in Footer defined in wpbc_templates__init_hook__shortcode_config()
82 // *
83 // * add_action( 'admin_footer', 'wpbc__template__shortcode_config_booking__EXAMPLE', 10, 2 );
84 // *
85 // *
86 // * Help doc for use templates:
87 // * 1. JavaScript: <# console.log( 'JS from template' ); #>
88 // * 2. Escaped data: {{ data.shortcode_config_2 }}
89 // * 2. Not escaped - HTML data: {{{ data.shortcode_config_2 }}}
90 // *
91 if ( 0 ) {
92 function wpbc__template__shortcode_config_booking__EXAMPLE(){
93
94 // Templates here
95 ?><script type="text/html" id="tmpl-wpbc_shortcode_config__page_content"><?php
96
97 echo 'TADA :) Rally GOOD !:){{{ data.shortcode_config_2 }}}';
98
99 ?></script><?php
100
101 // JS to Load template into page DOM - HTML
102 ?>
103 <script type="text/javascript">
104 jQuery( document ).ready( function (){
105 // Toolbar ---------------------------------------------------------------------------------------------------------
106 var template__wpbc_shortcode_config__page_content = wp.template( 'wpbc_shortcode_config__page_content' );
107 jQuery( '#wpbc_shortcode_config__run_template' ).html( template__wpbc_shortcode_config__page_content( {
108 'shortcode_config_1': 1,
109 'shortcode_config_2': 'This is variable from <strong> JS</strong>',
110 'shortcode_config_3': 'no'
111 } ) );
112 });
113 </script>
114 <?php
115 }
116 }