PluginProbe
Booking Calendar / 10.11.3
Booking Calendar v10.11.3
11.8.3 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 All 203 releases
booking / includes / ui_modal__shortcodes / tiny-button-popup.php

tiny-button-popup.php in Booking Calendar 10.11.3, at includes/ui_modal__shortcodes/tiny-button-popup.php

332 lines 14.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Files Loading
6 * @category Bookings
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 29.09.2015
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17 // FixIn: 9.9.0.15.
18
19 class WPBC_TinyMCE_Buttons {
20
21 // <editor-fold defaultstate="collapsed" desc=" I n i t + H o o k s" >
22 private $settings = array();
23
24 public function __construct( $params ) {
25
26 $this->settings = array(
27 'tiny_prefix' => 'wpbc_tiny',
28 'tiny_icon_url' => '', // WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'.
29 'tiny_js_plugin' => WPBC_PLUGIN_URL . '/js/wpbc_tinymce_btn.js',
30 'tiny_js_function' => 'wpbc_init_tinymce_buttons', // This function NAME exist inside of this JS file: ['tiny_js_plugin'].
31 'tiny_btn_row' => 1,
32 'pages_where_insert' => array(), // FixIn: 10.6.5.1.
33 'buttons' => array(), // FixIn: 10.6.5.1.
34 );
35
36 $this->settings = wp_parse_args( $params, $this->settings );
37
38 add_action( 'init', array( $this, 'define_init_hooks' ) ); // Define init hooks.
39 }
40
41 /** Init all hooks for showing Button in Tiny Toolbar */
42 public function define_init_hooks() {
43
44 if ( wpbc_can_i_load_on_this_page__shortcode_config() ) {
45
46 // FixIn: 10.6.5.1.
47 $this->settings['buttons'] = array(
48 'booking_insert' => array(
49 'hint' => __('Insert WP Booking Calendar' ,'booking')
50 , 'title' => __('Booking calendar' ,'booking')
51 , 'img' => ''//WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'
52 , 'class' => 'bookig_buttons'
53 , 'js_func_name_click' => 'wpbc_tiny_btn_click'
54 , 'bookmark' => 'booking'
55 , 'is_close_bookmark' => 0
56 )
57 );
58
59 // Load JS file - TinyMCE plugin
60 add_filter( 'mce_external_plugins', array( $this, 'load_tiny_js_plugin' ) );
61
62 // Add the custom TinyMCE buttons
63 if ( 1 === $this->settings['tiny_btn_row'] ) {
64 add_filter( 'mce_buttons', array( $this, 'add_tiny_button' ) );
65 } else {
66 add_filter( 'mce_buttons_' . $this->settings['tiny_btn_row'], array( $this, 'add_tiny_button' ) );
67 }
68
69 // Add the old style button to the non-TinyMCE editor views //Fix: 8.4.2.10 - compatibility with Gutenberg 4.1- 4.3 ( or newer ) at edit post page.
70 add_action( 'edit_page_form', array( $this, 'add_html_button' ) );
71 add_action( 'admin_head', array( $this, 'insert_button') ); // Tiny Button
72 add_action( 'admin_footer', array( $this, 'modal_content' ) ); // Modal Content
73
74 // JS & CSS
75 wpbc_load_js__required_for_modals();
76
77 add_action( 'customize_controls_print_footer_scripts', array( $this, 'add_html_button' ) ); // FixIn: 8.8.2.12.
78 add_action( 'customize_controls_print_footer_scripts', array( $this, 'insert_button' ) );
79 add_action( 'customize_controls_print_footer_scripts', array( $this, 'modal_content' ) ); // Modal Content
80 }
81 }
82 // </editor-fold>
83
84
85 // <editor-fold defaultstate="collapsed" desc=" TinyMCE - Add Button " >
86
87 /**
88 * Load JS file - TinyMCE plugin
89 *
90 * @param array $plugins
91 *
92 * @return array
93 */
94 public function load_tiny_js_plugin( $plugins ) {
95
96 $plugins[ $this->settings['tiny_prefix'] . '_quicktags' ] = $this->settings['tiny_js_plugin'];
97
98 return $plugins;
99 }
100
101
102 /**
103 * Add the custom TinyMCE buttons
104 *
105 * @param array $buttons
106 *
107 * @return array
108 */
109 public function add_tiny_button( $buttons ) {
110
111 array_push( $buttons, 'separator' );
112
113 foreach ( $this->settings['buttons'] as $type => $strings ) {
114 array_push( $buttons, $this->settings['tiny_prefix'] . '_' . $type );
115 }
116
117 return $buttons;
118 }
119
120
121 /** Add the old style button to the non-TinyMCE editor views */
122 public function add_html_button() {
123
124 $buttonshtml = '';
125 $datajs = '';
126
127 foreach ( $this->settings['buttons'] as $type => $props ) {
128
129 $buttonshtml .= '<input type="button" class="ed_button button button-small" onclick="' . $props['js_func_name_click'] . '(\'' . $type . '\')" title="' . $props['hint'] . '" value="' . $props['title'] . '" />';
130
131 $datajs .= " wpbc_tiny_btn_data['$type'] = {\n";
132 $datajs .= ' title: "' . esc_js( $props['title'] ) . '",' . "\n";
133 $datajs .= ' tag: "' . esc_js( $props['bookmark'] ) . '",' . "\n";
134 $datajs .= ' tag_close: "' . esc_js( $props['is_close_bookmark'] ) . '",' . "\n";
135 $datajs .= ' cal_count: "' . get_bk_option( 'booking_client_cal_count' ) . '"' . "\n";
136 $datajs .= "\n };\n";
137 }
138
139 ?>
140 <script type="text/javascript">
141 // <![CDATA[
142 function wpbc_add_html_button_to_toolbar() { // Add buttons ( HTML view ).
143 if ( jQuery( '#ed_toolbar' ).length == 0 )
144 setTimeout( 'wpbc_add_html_button_to_toolbar()', 100 );
145 else {
146 jQuery( "#ed_toolbar" ).append( '<?php
147 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
148 echo wp_specialchars_decode( esc_js( $buttonshtml ), ENT_COMPAT ); ?>' );
149 }
150 }
151
152 jQuery( document ).ready( function () {
153 setTimeout( 'wpbc_add_html_button_to_toolbar()', 100 );
154 } );
155
156 var selected_booking_shortcode = 'bookingform';
157 var wpbc_tiny_btn_data = {};
158 <?php
159 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
160 echo $datajs; ?>
161 // ]]>
162 </script>
163 <?php
164
165 }
166
167
168 public function insert_button() {
169
170 $script = '';
171
172 // // calendar3-range https://icons.getbootstrap.com/icons/calendar3-range/
173 // $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar3-range" viewBox="-2 -1 20 20">'
174 // . '<path d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z"/>'
175 // . '<path d="M7 10a1 1 0 0 0 0-2H1v2h6zm2-3h6V5H9a1 1 0 0 0 0 2z"/>'
176 // . '</svg>';
177 // $mune_icon_url = sprintf( 'data:image/svg+xml;base64,%s', base64_encode( $svg_icon_integarted ) );
178
179 // FixIn: 10.11.3.3.
180 $mune_icon_url = wpbc_get_svg_logo_for_background( '#000', '#aaa', '0.3' ); // '#aaa', '#aaa', '0.2' .
181
182 if ( ! empty( $this->settings['buttons'] ) ){
183
184 $script .= '<script type="text/javascript">';
185
186 $script .= ' function '. $this->settings['tiny_js_function'] . '(ed, url) {';
187
188 foreach ( $this->settings['buttons'] as $type => $props ) {
189
190 $script .= " if ( typeof ".$props['js_func_name_click']." == 'undefined' ) return; ";
191 $script .= " ed.addButton('". $this->settings['tiny_prefix'] . '_' . $type ."', {";
192 $script .= " title : '". $props['hint'] ."',";
193 //$script .= " image : '". $props['img'] ."',";
194 $script .= " image : '" . $mune_icon_url . "',";
195 $script .= " onclick : function() {";
196 $script .= " ". $props['js_func_name_click'] ."('". $type ."');";
197 $script .= " }";
198 $script .= " });";
199 }
200 $script .= ' }';
201
202 $script .= '</script>';
203
204 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
205 echo $script;
206 }
207 }
208
209 // </editor-fold>
210
211
212 // <editor-fold defaultstate="collapsed" desc=" M o d a l C o n t e n t " >
213 public function modal_content() {
214
215 ?><span class="wpdevelop wpbc_page"><div class="visibility_container clearfix-height" style="display:block;"><?php
216 ?><div id="wpbc_tiny_modal" class="modal wpbc_popup_modal wpbc_tiny_modal" tabindex="-1" role="dialog">
217 <div class="modal-dialog modal-lg">
218 <div class="modal-content">
219 <div class="modal-header">
220 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
221 <h4 class="modal-title">
222 <span>WP Booking Calendar</span>
223 <span style="padding: 0 1em;"> / </span>
224 <span> <?php esc_html_e( 'Shortcode Configuration', 'booking' ); ?></span></h4>
225 </div>
226 <div class="modal-body">
227
228 <div class="wpbc_settings_flex_container">
229
230 <div class="wpbc_settings_flex_container_left" style="flex: 1 1 150px;">
231 <?php
232 wpbc_shortcode_config__navigation_panel();
233 ?>
234 </div>
235 <div class="wpbc_settings_flex_container_right">
236 <div class="wpbc_sc_container__all_shortcodes">
237 <input name="wpbc_shortcode_type" id="wpbc_shortcode_type" value="booking" autocomplete="off" type="hidden" />
238 <?php
239
240 // [booking ... ] ------------------------------------------------------------------
241 wpbc_shortcode_config__content__booking();
242
243 // [bookingcalendar ... ] ----------------------------------------------------------
244 wpbc_shortcode_config__content__bookingcalendar();
245
246 // [bookingselect ... ] ------------------------------------------------------------
247 wpbc_shortcode_config__content__bookingselect();
248
249 // [bookingtimeline ... ] ----------------------------------------------------------
250 wpbc_shortcode_config__content__bookingtimeline();
251
252 // [bookingsearch searchresults='https://servcer.com/search-form/' searchresultstitle='{searchresults} Result(s) Found' noresultstitle='Nothing Found']
253 wpbc_shortcode_config__content__bookingsearch();
254
255 // [bookingform type=1 selected_dates='03.03.2024'] --------------------------------
256 wpbc_shortcode_config__content__bookingform();
257
258 // [bookingedit] , [bookingcustomerlisting] , [bookingresource type=6 show='capacity'] , [booking_confirm]
259 wpbc_shortcode_config__content__bookingother();
260
261 // Booking Import of .ics feed shortcode
262 wpbc_shortcode_config__content__booking_ics_import();
263
264 // Booking Listing of .ics feed shortcode
265 wpbc_shortcode_config__content__booking_ics_listing();
266
267 ?>
268 </div>
269 <div style="display: flex;flex-flow: row wrap;justify-content: flex-start;align-items: baseline;" for="wpbc_text_put_in_shortcode">
270 <input name="wpbc_text_put_in_shortcode" id="wpbc_text_put_in_shortcode" class="put-in" readonly="readonly" onfocus="this.select()" type="text"
271 style="width: auto;flex: 1;" />
272 </div>
273 <input name="wpbc_text_gettenberg_section_id" id="wpbc_text_gettenberg_section_id" type="text" style="display: none;" />
274 </div>
275 </div>
276
277 </div>
278 <div class="modal-footer" style="text-align:center;">
279 <div class="wpbc_shortcode_config_content_toolbar__container">
280 <div class="wpbc_shortcode_config_content_toolbar__reset">
281 <a href="javascript:void(0)" class="button button-primary wpbc_tiny_button__reset_to_resource wpbc_ui_button_danger"
282 onclick="javascript:wpbc_shortcode_config__reset( jQuery('#wpbc_shortcode_type').val().trim() );" ><?php esc_html_e( 'Reset', 'booking' ); ?></a>
283 </div>
284 <div class="wpbc_shortcode_config_content_toolbar__insert">
285 <a href="javascript:void(0)" class="button button-primary wpbc_tiny_button__insert_to_editor" style="float:none;"
286 onclick="javascript:wpbc_send_text_to_editor( jQuery('#wpbc_text_put_in_shortcode').val().trim() );wpbc_tiny_close();"><?php esc_html_e( 'Insert', 'booking' ); ?></a>
287 <a href="javascript:void(0)" class="button button-primary wpbc_tiny_button__insert_to_resource" style="float:none;display:none;"
288 onclick="javascript:wpbc_send_text_to_resource( jQuery('#wpbc_text_put_in_shortcode').val().trim() );wpbc_tiny_close();" ><?php esc_html_e( 'Insert', 'booking' ); ?></a>
289 <!--a href="javascript:void(0)" class="button" style="float:none;" data-dismiss="modal"><?php esc_html_e('Close' ,'booking'); ?></a-->
290 </div>
291 </div>
292 </div>
293 </div><!-- /.modal-content -->
294 </div><!-- /.modal-dialog -->
295 </div><!-- /.modal -->
296 <?php
297 ?></div></span><?php
298
299 }
300 // </editor-fold>
301
302 }
303
304
305 function wpbc_get_pages_where_insert_tiny_mce_buttons() {
306 return array(
307 'post-new.php',
308 'page-new.php',
309 'post.php',
310 'page.php',
311 'widgets.php',
312 'customize.php',
313 ); // FixIn: 8.8.2.11 // FixIn: 8.8.2.12.
314 }
315
316
317 if (
318 ( in_array( basename( $_SERVER['PHP_SELF'] ), wpbc_get_pages_where_insert_tiny_mce_buttons() ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
319 || ( ( isset( $_REQUEST['page'] ) && ( 'wpbc-resources' === $_REQUEST['page'] ) ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
320 || wpbc_is_setup_wizard_page() // || wpbc_is_bookings_page() // FixIn: 10.6.6.2.
321 ) {
322 // FixIn: 10.6.5.1.
323 new WPBC_TinyMCE_Buttons( array(
324 'tiny_prefix' => 'wpbc_tiny',
325 'tiny_icon_url' => '', // WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'.
326 'tiny_js_plugin' => WPBC_PLUGIN_URL . '/js/wpbc_tinymce_btn.js',
327 'tiny_js_function' => 'wpbc_init_tinymce_buttons', // This function NAME exist inside of this file: ['tiny_js_plugin'].
328 'tiny_btn_row' => 1,
329 'pages_where_insert' => wpbc_get_pages_where_insert_tiny_mce_buttons(),
330 ) );
331 }
332