PluginProbe
Booking Calendar / 10.15.7
Booking Calendar v10.15.7
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 / admin / page-new.php

page-new.php in Booking Calendar 10.15.7, at core/admin/page-new.php

162 lines 8.0 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 Content of Add New Booking
5 * @author wpdevelop
6 *
7 * @web-site https://wpbookingcalendar.com/
8 * @email info@wpbookingcalendar.com
9 *
10 * @modified 2015-10-31
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15
16 /**
17 * Show Content
18 * Update Content
19 * Define Slug
20 * Define where to show
21 */
22 class WPBC_Page_AddNewBooking extends WPBC_Page_Structure {
23
24
25 public function in_page() {
26 return 'wpbc-new';
27 }
28
29 public function tabs() {
30
31 $tabs = array();
32 $tabs['add-booking'] = array(
33 'is_show_top_path' => false, // true | false. By default value is: false.
34 'left_navigation__default_view_mode' => 'min', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
35 'page_title' => __( 'Add New Booking', 'booking' ), // Header - Title. If false, than hidden.
36 'page_description' => __( 'Manually add new bookings from the Admin Panel.', 'booking' ), // Header - Title Description. If false, than hidden.
37 'title' => __( 'Add booking', 'booking' ), // Title of TAB.
38 'hint' => __( 'Add booking', 'booking' ), // Hint.
39 'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link.
40 'position' => '', // Can be: 'left' | 'right' | ''.
41 'css_classes' => '', // this is CSS class(es).
42 'icon' => '', // Icon - link to the real PNG img.
43 'font_icon' => 'wpbc-bi-plus', // CSS definition of forn Icon.
44 'default' => true, // Is this tab activated by default or not: true || false.
45 'disabled' => false, // Is this tab disbaled: true || false.
46 'hided' => true, // Is this tab hided: true || false.
47 'subtabs' => array(),
48 );
49
50 return $tabs;
51 }
52
53
54 public function content() {
55
56 do_action( 'wpbc_hook_add_booking_page_header', 'add_booking' ); // Define Notices Section and show some static messages, if needed.
57
58 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) {
59 return false; // Check if MU user activated, otherwise show Warning message.
60 }
61
62 if ( ! wpbc_set_default_resource_to__get() ) {
63 return false; // Define default booking resources for $_ GET and check if booking resource belong to user.
64 }
65
66 ?><span class="wpdevelop"><?php // BS UI CSS Class.
67
68 wpbc_js_for_bookings_page(); // JavaScript functions.
69
70 // T o o l b a r s.
71 wpbc_add_new_booking_toolbar();
72
73 ?></span><!-- wpdevelop class --><?php
74
75 ?><div class="clear" style="height:40px;"></div><?php
76
77 ?><div class="add_booking_page_content" style="width:100%;margin-bottom:100px;"><?php
78
79 // Previously we defined booking resources to $_GET.
80 $resource_id = isset( $_GET['booking_type'] ) ? intval( $_GET['booking_type'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
81
82 $saved_user_calendar_params = $this->get_saved_user_calendar_options();
83
84 // ---------------------------------------------------------------------
85 // Normalize 'custom booking form' from GET. Flow: Shortcode_Attr -> $_GET -> Default.
86 // ---------------------------------------------------------------------
87 // If non empty, then use sanitized $_GET, otherwise use 'custom_booking_form' attr.
88 $custom_booking_form = WPBC_GET_Request::has_non_empty_get( 'booking_form' ) ? WPBC_GET_Request::get_sanitized( 'booking_form' ) : 'standard';
89
90 WPBC_FE_Render::render_booking_form(
91 array(
92 'resource_id' => $resource_id,
93 'cal_count' => intval( $saved_user_calendar_params['months_number'] ),
94 'is_echo' => 1,
95 'custom_booking_form' => $custom_booking_form,
96 'selected_dates_without_calendar' => '',
97 'start_month_calendar' => false,
98 'shortcode_param__options' => '{calendar' . $saved_user_calendar_params['options_param'] . '}',
99 )
100 );
101
102 ?></div><?php
103
104
105 ?><hr /><?php
106 wpbc_toolbar_is_send_emails_btn_duplicated();
107
108
109 wpbc_bs_javascript_popover(); // JS Popover
110
111 do_action( 'wpbc_hook_add_booking_page_footer', 'add_booking' );
112 }
113
114
115 /**
116 * Get Calendar Options of specific User
117 *
118 * @return array (number of months, options parameter
119 */
120 function get_saved_user_calendar_options() {
121
122 // Get possible saved previous "Custom User Calendar data"
123 $user_calendar_options = get_user_option( 'booking_custom_' . 'add_booking_calendar_options', wpbc_get_current_user_id() );
124
125 if ( $user_calendar_options === false ) { // Default, if no saved previously.
126 $user_calendar_options = array();
127 $user_calendar_options['calendar_months_count'] = 1;
128 $user_calendar_options['calendar_months_num_in_1_row'] = 0 ;
129 $user_calendar_options['calendar_width'] = '';
130 $user_calendar_options['calendar_widthunits'] = 'px';
131 $user_calendar_options['calendar_cell_height'] = '';
132 $user_calendar_options['calendar_cell_heightunits'] = 'px';
133 } else {
134 $user_calendar_options = maybe_unserialize( $user_calendar_options );
135 }
136
137 if ( ! empty( $user_calendar_options['calendar_months_count'] ) )
138 $selected_calendar_months_count = intval ( $user_calendar_options['calendar_months_count'] );
139 else $selected_calendar_months_count = 1;
140
141 if ( ! empty( $user_calendar_options['calendar_months_num_in_1_row'] ) )
142 $option_months_num_in_row = ' months_num_in_row=' . intval ( $user_calendar_options['calendar_months_num_in_1_row'] );
143 else $option_months_num_in_row = '';
144
145 if ( ! empty( $user_calendar_options['calendar_width'] ) ) {
146 $unit_value = ( esc_attr( $user_calendar_options['calendar_widthunits'] ) == 'percent' ) ? '%' : esc_attr( $user_calendar_options['calendar_widthunits'] );
147 $option_width = ' width=' . intval( $user_calendar_options['calendar_width'] ) . $unit_value;
148 $option_width .= ' strong_width=' . intval( $user_calendar_options['calendar_width'] ) . $unit_value; // FixIn: 9.3.1.6.
149 } else $option_width = '';
150
151 if ( ! empty( $user_calendar_options['calendar_cell_height'] ) ) {
152 $unit_value = ( esc_attr( $user_calendar_options['calendar_cell_heightunits'] ) == 'percent' ) ? '%' : esc_attr( $user_calendar_options['calendar_cell_heightunits'] );
153 $option_cell_height = ' cell_height=' . intval( $user_calendar_options['calendar_cell_height'] ) . $unit_value;
154 } else $option_cell_height = '';
155
156
157 return array( 'months_number'=> $selected_calendar_months_count, 'options_param' => $option_months_num_in_row . $option_width . $option_cell_height );
158 }
159
160 }
161 add_action('wpbc_menu_created', array( new WPBC_Page_AddNewBooking() , '__construct') ); // Executed after creation of Menu
162