PluginProbe
Booking Calendar / 11.4
Booking Calendar v11.4
11.9 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 All 205 releases
booking / includes / page-resource-free / page-resource-free.php

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

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