PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 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 All 204 releases
booking / includes / page-resource-free / page-resource-free.php

page-resource-free.php in Booking Calendar 11.8.4, at includes/page-resource-free/page-resource-free.php

479 lines 22.8 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 > Resource page
4 * @category Settings page
5 * @author wpdevelop
6 *
7 * @web-site https://wpbookingcalendar.com/
8 * @email info@wpbookingcalendar.com
9 *
10 * @modified 2023-12-29
11 *
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // FixIn: 9.8.15.7.
15
16
17 /**
18 * Show Content
19 * Update Content
20 * Define Slug
21 * Define where to show
22 */
23 class WPBC_Page_Settings__bresource extends WPBC_Page_Structure {
24
25 public function in_page() {
26 if (
27 class_exists( 'wpdev_bk_personal' )
28 || ( function_exists( 'wpbc_booking_resources_catalog_should_use_new_renderer' ) && wpbc_booking_resources_catalog_should_use_new_renderer() )
29 ) {
30 return (string) wp_rand( 100000, 1000000 );
31 }
32 return 'wpbc-resources';
33 }
34
35 public function tabs() {
36
37 $tabs = array();
38
39 $tabs[ 'resources' ] = array(
40 'title' => __('Resource','booking') // Title of TAB
41 , 'hint' => __('Create unique calendars with individual availability.', 'booking') // Hint
42 , 'page_title' => ucwords( __('Booking resource','booking') ) // Title of Page
43 //, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be external link
44 //, 'position' => 'left' // 'left' || 'right' || ''
45 //, 'css_classes'=> '' // CSS class(es)
46 //, 'icon' => '' // Icon - link to the real PNG img
47 , 'font_icon' => 'wpbc-bi-list 0wpbc_icn_checklist' // CSS definition of font Icon
48 , 'default' => ( ! class_exists( 'wpdev_bk_personal' ) ) // Is this tab activated by default or not: true || false.
49 //, 'disabled' => false // Is this tab disabled: true || false.
50 , 'hided' => true // Is this tab hided: true || false.
51 , 'subtabs' => array()
52 );
53 return $tabs;
54 }
55
56
57 /** Show Content of Settings page */
58 public function content() {
59 if ( function_exists( 'wpbc_booking_resources_catalog_get_request_renderer' ) && 'legacy' !== wpbc_booking_resources_catalog_get_request_renderer() ) {
60 return false;
61 }
62
63 $this->css();
64
65 ////////////////////////////////////////////////////////////////////////
66 // Checking
67 ////////////////////////////////////////////////////////////////////////
68
69 do_action( 'wpbc_hook_settings_page_header', 'resources'); // Define Notices Section and show some static messages, if needed
70
71 ////////////////////////////////////////////////////////////////////////
72 // S u b m i t Main Form
73 ////////////////////////////////////////////////////////////////////////
74
75 $submit_form_name = 'wpbc_bresources'; // Define form name
76 /*
77 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
78 if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) {
79 // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
80 $nonce_gen_time = check_admin_referer( 'wpbc_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page
81
82 // Save Changes
83 $this->update();
84 }
85 */
86 do_action('wpbc_bresources_check_submit_actions');
87
88 ////////////////////////////////////////////////////////////////////////
89 // JavaScript: Tooltips, Popover, Datepick (js & css)
90 ////////////////////////////////////////////////////////////////////////
91
92 echo '<span class="wpdevelop">';
93
94 wpbc_js_for_bookings_page();
95
96 // Toolbar
97 $this->toolbar();
98
99
100 echo '</span>';
101
102 ?><div class="clear" style="margin-bottom:5px;"></div><?php
103
104
105 // Scroll links ////////////////////////////////////////////////////////
106 if (0) {
107 ?>
108 <div class="wpdvlp-sub-tabs" style="background:none;border:none;box-shadow: none;padding:0;">
109 <span class="nav-tabs" style="text-align:right;">
110 <a href="javascript:void(0);" onclick="javascript:wpbc_scroll_to('#wpbc_booking_resource_table' );" original-title="" class="nav-tab go-to-link"><span><?php esc_html_e('Resource' ,'booking'); ?></span></a>
111 </span>
112 </div>
113 <div class="clear"></div>
114 <?php
115 }
116
117 do_action( 'wpbc_hook_settings_page_before_content_table', 'resources'); // Define Notices Section and show some static messages, if needed
118
119 ////////////////////////////////////////////////////////////////////////
120 // Content ////////////////////////////////////////////////////////////
121 ?>
122 <div class="clear"></div>
123 <span class="metabox-holder">
124 <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" autocomplete="off">
125 <?php
126 // N o n c e field, and key for checking S u b m i t
127 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
128 ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" /><?php
129 ?><div class="clear" style="margin-top:20px;"></div>
130 <div id="wpbc_booking_resource_table" class="wpbc_settings_row wpbc_settings_row_rightNO">
131 <?php
132 $this->wpbc_resources_table__show();
133 ?>
134 </div>
135 <div class="clear"></div>
136 </span>
137 <?php
138
139 do_action( 'wpbc_hook_settings_page_footer', 'resources' );
140
141 $this->enqueue_js();
142 }
143
144
145 // <editor-fold defaultstate="collapsed" desc=" CSS & JS " >
146
147 /** CSS for this page */
148 private function css() {
149 ?>
150 <style type="text/css">
151 .wpbc-help-message {
152 border:none;
153 }
154 /* Selectbox element in toolbar */
155 .visibility_container select optgroup{
156 color:#999;
157 vertical-align: middle;
158 font-style: italic;
159 font-weight: 400;
160 }
161 .visibility_container select option {
162 padding:5px;
163 font-weight: 600;
164 }
165 .visibility_container select optgroup option{
166 padding: 5px 20px;
167 color:#555;
168 font-weight: 600;
169 }
170 #wpbc_create_new_custom_form_name_fields {
171 width: 360px;
172 display:none;
173 }
174 @media (max-width: 399px) {
175 #wpbc_create_new_custom_form_name_fields {
176 width: 100%;
177 }
178 }
179 </style>
180 <?php
181 }
182
183
184
185 /**
186 * Add Custom JavaScript - for some specific settings options
187 * Executed After post content, after initial definition of settings, and possible definition after POST request.
188 *
189 * @param type $menu_slug
190 */
191 private function enqueue_js(){
192
193 // JavaScript //////////////////////////////////////////////////////////////
194
195 $js_script = '';
196
197 /*
198 // Hide|Show on Click Checkbox
199 $js_script .= " jQuery('#bresources_booking_gcal_auto_import_is_active').on( 'change', function(){
200 if ( this.checked ) {
201 jQuery('.wpbc_tr_auto_import').removeClass('hidden_items');
202 } else {
203 jQuery('.wpbc_tr_auto_import').addClass('hidden_items');
204 }
205 } ); ";
206 */
207
208 // Open the publish controls when this page is used as the Setup Wizard "Publish" step.
209 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
210 if ( isset( $_GET['wpbc_setup_step'] ) && ( 'wizard_publish' === sanitize_key( wp_unslash( $_GET['wpbc_setup_step'] ) ) ) ) {
211 $js_script .= "
212 jQuery( document ).ready( function() {
213 setTimeout( function() {
214 var publishSelector = '.ui_group__publish_btn:visible';
215 var tableSelector = '#wpbc_booking_resource_table:visible';
216 var \$publishTarget = jQuery( publishSelector ).first();
217 var targetSelector = \$publishTarget.length ? publishSelector : tableSelector;
218
219 if ( ! jQuery( targetSelector ).length ) {
220 return;
221 }
222
223 if ( 'function' === typeof wpbc_scroll_to ) {
224 wpbc_scroll_to( targetSelector );
225 } else {
226 jQuery( 'html, body' ).animate( { scrollTop: jQuery( targetSelector ).first().offset().top - 80 }, 300 );
227 }
228
229 if ( 'function' === typeof wpbc_blink_element ) {
230 wpbc_blink_element( targetSelector, 3, 300 );
231 }
232 }, 350 );
233 } );
234 ";
235 }
236
237 // Enqueue JS to the footer of the page
238 wpbc_enqueue_js( $js_script );
239 }
240
241 // </editor-fold>
242
243
244 // -----------------------------------------------------------------------------------------------------------------
245 // Toolbar
246 // -----------------------------------------------------------------------------------------------------------------
247 /** Show Toolbar - Add new booking resources */
248 private function toolbar() {
249
250 $wpbc_hidded_element_id = 'toolbar_booking_resources';
251 ob_start();
252 $is_panel_visible = wpbc_is_dismissed( $wpbc_hidded_element_id , array(
253 'title' => '<i class="menu_icon icon-1x wpbc_icn_close"></i> ',
254 'hint' => __( 'Dismiss', 'booking' ),
255 'class' => 'wpbc_panel_get_started_dismiss',
256 'css' => 'background: #fff;border-radius: 7px;margin-bottom: -100%;z-index: 4;position: relative;top: 12px;right: 13px;'
257 ));
258 ?><script type="text/javascript"> jQuery('#<?php echo esc_attr( $wpbc_hidded_element_id ); ?>').hide(); </script><?php
259 $dismiss_button_content = ob_get_clean();
260
261 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
262 echo $dismiss_button_content;
263
264 if ( $is_panel_visible ) {
265 ?>
266 <div id="toolbar_booking_resources" style="position:relative;margin-bottom: 5em;padding:1px;border:5px solid #fff;border-radius:5px;box-shadow: 0 3px 15px 0px #d4d4d4;">
267 <div class="wpdvlp-top-tabs wpbc_blur">
268 <div class="wpdvlp-tabs-wrapper">
269 <div class="nav-tabs">
270 <a href="javascript:void(0);" class="nav-tab nav-tab-active ">
271 <i class="menu_icon icon-1x wpbc_icn_add _circle_outline"></i>
272 <span class="nav-tab-text">&nbsp;&nbsp;<?php echo esc_html__('Add Resource', 'booking') . ' ( ' . esc_html__('Calendar', 'booking') . ' )'; ?></span>
273 </a>
274 <a href="javascript:void(0);" class="nav-tab ">
275 <i class="menu_icon icon-1x wpbc_icn_tune"></i>
276 <span class="nav-tab-text">&nbsp;&nbsp;<?php echo esc_html__('Options', 'booking'); ?></span>
277 </a>
278 </div><!-- nav-tabs -->
279 </div><!-- wpdvlp-tabs-wrapper -->
280 </div><!-- wpdvlp-top-tabs -->
281 <form name="wpbc_form_add_new_booking_resources" id="wpbc_form_add_new_booking_resources" action="" method="post" autocomplete="off">
282 <div id="booking_resources_toolbar_container" class="wpbc_ajx_toolbar wpbc_blur">
283 <div class="ui_container ui_container_toolbar ui_container_small ui_container_actions ui_container_actions_row_1" style="display: flex;">
284 <div class="ui_group">
285 <div class="ui_element">
286 <input type="text" id="booking_resource_name"
287 name="booking_resource_name" style="min-width:250px;"
288 class="wpbc_ui_control wpbc_ui_text "
289 placeholder="Enter name of booking resource" value=""
290 autocomplete="off" maxlength="200">
291 </div>
292 <div class="ui_element">
293 <a class="wpbc_ui_control wpbc_ui_button wpbc_ui_button_primary tooltip_top " id="ui_btn_erase_availability"
294 href="javascript:void(0);"
295 data-original-title="<?php esc_attr_e( 'Add New Booking Resource(s)' ,'booking'); ?>>"><span><?php esc_html_e('Add New', 'booking'); ?>&nbsp;&nbsp;&nbsp;</span><i
296 class="menu_icon icon-1x wpbc_icn_add _circle_outline"></i></a>
297 </div>
298 <div class="ui_element" style="margin-left:15px;">
299 <label for="resources_count"
300 class="wpbc_ui_control_label "
301 style=""><span style="font-weight:400"><?php esc_html_e('Resources count', 'booking'); ?> </span></label>
302 <select id="resources_count" name="resources_count" class="wpbc_ui_control wpbc_ui_select " style="max-width: 69px;" autocomplete="off">
303 <option value="1" class="" style="">1</option>
304 </select>
305 </div>
306 </div>
307 </div>
308 </div>
309 </form>
310 <div class="clear"></div>
311 <table style="width: 100%;/*! margin-top: 85px; */">
312 <tbody>
313 <tr>
314 <td colspan="2">
315 <div class="wpbc_widget_content" style="transform: translate(0) translateY(-4em);">
316 <div class="ui_container ui_container_toolbar ui_container_small" style="background: #fff;position: relative;">
317 <div class="ui_group ui_group__upgrade" style="/*! float: right; */">
318 <div class="wpbc_upgrade_note wpbc_upgrade_theme_green" style="margin-left: auto;right: 50px;transform: translate(0) translateY(-50%);width: Min(500px, 90%);">
319 <div>
320 This <a target="_blank" href="https://wpbookingcalendar.com/features/#personal">feature</a>
321 is available in the <strong>Pro versions</strong>.
322 <a target="_blank" href="https://wpbookingcalendar.com/prices/#bk_news_section">Upgrade to Pro</a>.
323 </div>
324 </div>
325 </div>
326 </div>
327 </div>
328 </td>
329 </tr>
330 </tbody>
331 </table>
332 </div>
333 <?php
334 }
335
336 }
337
338 // -----------------------------------------------------------------------------------------------------------------
339 // B o o k i n g R e s o u r c e s T a b l e
340 // -----------------------------------------------------------------------------------------------------------------
341 /** Show booking resources table */
342 public function wpbc_resources_table__show() {
343
344 ?>
345 <div id="wpbc_booking_resource_table" class="wpbc_settings_row wpbc_settings_row_rightNO">
346 <div class="wpdevelop wpbc_selectable_table wpbc_resources_table">
347 <table class="table table-striped widefat " cellspacing="0" cellpadding="0">
348 <thead class="wpbc_selectable_head">
349 <tr>
350 <th class="" style="width:5em;text-align: center;"><span href="javascript:void(0);">ID </span></th>
351 <th class="wpbc_hide_mobile"><span href="javascript:void(0);"><?php esc_html_e( 'Resource Name', 'booking' ); ?> </span></th>
352 <th class="" style="text-align:center;"><?php esc_html_e( 'Shortcode for page', 'booking' ); ?></th>
353 <th class="" style="text-align:center;"><?php esc_html_e( 'Actions', 'booking' ); ?></th>
354 </tr>
355 </thead>
356 <tbody class="wpbc_selectable_body">
357 <tr class="wpbc_row wpbc_resource_row" id="resource_1">
358 <td style="background: transparent;border: none;box-shadow: none;margin: 16px 0 0;padding: 0;display: flex;flex-flow: column;justify-content: center;align-items: center;width: 100%;"
359 class="wpbc_hide_mobile wpbc_flextable">
360 <div class="wpbc_flextable_col wpbc_flextable_col_id">
361 <div class="wpbc_listing_col wpbc_col_booking_labels wpbc_col_labels wpbc_label_resource_id_container">
362 <span class="wpbc_label wpbc_label_booking_id wpbc_label_resource_id">1</span>
363 </div>
364 </div>
365 </td>
366 <td class="wpbc_hide_mobile">
367 <input type="text" value="Default" id="booking_resource_1" name="booking_resource_1"
368 style="float:right;width:100%;font-weight:600;color: #aaa;height: 32px;" disabled="disabled"
369 class="large-text disabled">
370 </td>
371 <?php /* ?>
372 <td class="wpbc_hide_mobile">
373 <div class="wpbc_ajx_toolbar" style="display: flex;flex-flow: row wrap;justify-content: center;align-items: center;margin: 0;">
374 <div class="ui_container ui_container_toolbar ui_container_small ui_container_options ui_container_actions_row_1"
375 style="border: none;background: none;padding: 0;">
376 <div class="ui_group">
377 <div class="ui_element">
378 <a href="https://wpbookingcalendar.com/faq/#shortcodes" class="tooltip_top wpbc-bi-question-circle" style="line-height: 2.4em;"
379 title="<?php esc_attr_e( 'Learn how to integrate the booking form into a page using the shortcode.','booking'); ?>"></a>
380 </div>
381 <div class="ui_element">
382 <input type="text" value="[booking resource_id=1]" readonly="readonly" onfocus="this.select()"
383 id="booking_resource_shortcode_1" name="booking_resource_shortcode_1"
384 class="large-text put-in" style="width:auto;font-weight:600;border:1px solid #e1e1e1;text-align: center;cursor:pointer;" />
385 </div>
386 <!--div class="ui_element">
387 <a href="javascript:void(0)" onclick="javascript:wpbc_resource_page_btn_click(1);"
388 id="ui_btn_erase_availability" class="wpbc_ui_control wpbc_ui_button wpbc_ui_button_danger0 tooltip_top "
389 title="<?php esc_attr_e( 'Customize Booking Calendar shortcode','booking'); ?>" >
390 <span style="display: none;"><?php esc_html_e('Customize','booking'); ?>&nbsp;&nbsp;&nbsp;</span>
391 <i class="menu_icon icon-1x wpbc_icn_tune"></i>
392 </a>
393 </div-->
394 </div>
395 </div>
396 </div>
397 </td>
398 <td class="" style="text-align: center;">
399 <div class="ui_element" style="margin: 0 15px 0 0;">
400 <a href="javascript:void(0)" onclick="javascript:wpbc_resource_page_btn_click(1);"
401 id="ui_btn_erase_availability" class="wpbc_ui_control wpbc_ui_button wpbc_ui_button_danger0 tooltip_top "
402 title="<?php esc_attr_e( 'Customize Booking Calendar shortcode','booking'); ?>" >
403 <span style="display: none;"><?php esc_html_e('Customize','booking'); ?>&nbsp;&nbsp;&nbsp;</span>
404 <i class="menu_icon icon-1x wpbc_icn_tune"></i>
405 </a>
406 </div>
407 <a href="javascript:void(0);"
408 onclick="javascript: wpbc_modal_dialog__show__resource_publish( 1 );"
409 class="button button-primary tooltip_top"
410 title="<?php esc_attr_e('Embed your booking form into the page', 'booking'); ?>"
411 ><?php esc_html_e( 'Publish', 'booking' ); ?></a>
412 </td>
413 <?php */
414 // FixIn: 10.3.0.8.
415 ?>
416 <td colspan="2" class="wpbc_flextable_col">
417 <div class="wpbc_ajx_toolbar">
418 <div class="ui_container ui_container_small">
419 <div class="ui_group ui_group__shortcode">
420 <div class="ui_element" style="flex: 1 1 auto;margin: 0;">
421 <div id="div_booking_resource_shortcode_1" name="div_booking_resource_shortcode_1" class="shortcode_text_field large-text put-in">
422 [booking resource_id=1]
423 </div>
424 <input type="hidden" value="[booking resource_id=1]" id="booking_resource_shortcode_1" name="booking_resource_shortcode_1">
425 </div>
426 <div class="ui_element" style="margin-left: 0px;margin-right: 0px;">
427 <a href="https://wpbookingcalendar.com/faq/#shortcodes"
428 class="tooltip_top wpbc-bi-question-circle"
429 data-original-title="<?php echo esc_attr( __('Learn how to integrate the booking form into a page using the shortcode.','booking') ); ?>"></a>
430 </div>
431 </div>
432 <div class="ui_group ui_group__publish_btn">
433 <div class="ui_element" style="margin: 0 15px 0 0;">
434 <a href="javascript:void(0)" onclick="javascript:wpbc_resource_page_btn_click(1);"
435 id="ui_btn_erase_availability"
436 class="wpbc_ui_control wpbc_ui_button wpbc_ui_button_danger0 tooltip_top "
437 data-original-title="<?php echo esc_attr( __('Customize Booking Calendar shortcode','booking') ); ?>">
438 <span style="display: none;"><?php esc_html_e('Customize','booking'); ?>&nbsp;&nbsp;&nbsp;</span>
439 <i class="menu_icon icon-1x wpbc_icn_tune"></i>
440 </a>
441 </div>
442 <div class="ui_element" style="margin: 0 2px 0 0;">
443 <a class="wpbc_ui_control wpbc_ui_button wpbc_ui_button_primary tooltip_top "
444 href="javascript:void(0);"
445 onclick="javascript: wpbc_modal_dialog__show__resource_publish( 1 );"
446 data-original-title="<?php echo esc_attr( __('Embed your booking form into the page','booking') ); ?>">
447 <span><?php esc_html_e('Publish','booking'); ?></span>
448 <i class="menu_icon icon-1x wpbc_icn_tune" style="display: none;"></i>
449 </a>
450 </div>
451 </div>
452 </div>
453 </div>
454 </td>
455 </tr>
456 </tbody>
457 <tfoot class="wpbc_selectable_foot">
458 <tr>
459 <th colspan="5" style="text-align: center;"></th>
460 </tr>
461 </tfoot>
462 </table>
463 </div>
464 <div class="clear"></div>
465 <?php
466 echo '<a style="margin:0;" class="button button" href="' . esc_url( wpbc_get_settings_url() . '&system_info=show&_wpnonce='. wp_create_nonce( 'wpbc_settings_url_nonce' ) ) .'&restore_dismissed=On#wpbc_general_settings_restore_dismissed_metabox">' .
467 esc_html__( 'Restore all dismissed windows', 'booking' )
468 . '</a>';
469 ?>
470 </div>
471 <?php
472 }
473
474 }
475
476 if ( ! function_exists( 'wpbc_booking_resources_catalog_should_use_new_renderer' ) || ! wpbc_booking_resources_catalog_should_use_new_renderer() ) {
477 add_action( 'wpbc_menu_created', array( new WPBC_Page_Settings__bresource(), '__construct' ) ); // Executed after creation of Menu.
478 }
479