PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.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 / page-customize / customize__page.php

customize__page.php in Booking Calendar 10.1.3, at includes/page-customize/customize__page.php

357 lines 18.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * @package: AJX_Customize_Plugin Page
4 * @category: Initial setup and plugin customization
5 * Author: wpdevelop, oplugins
6 * Version: 1.0
7 * @modified 2023-06-12
8 */
9 //FixIn: 9.8.0.1
10 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
12
13 /** Show Content
14 * Update Content
15 * Define Slug
16 * Define where to show
17 */
18 class WPBC_Page_AJX_Customize_Plugin extends WPBC_Page_Structure {
19
20
21 public function __construct() {
22
23 parent::__construct();
24
25 add_action( 'wpbc_toolbar_top_tabs_after', array( $this, 'wpbc_toolbar_toolbar_tabs' ) );
26 add_action( 'wpbc_toolbar_top_tabs_insert', array( $this, 'wpbc_toolbar_toolbar_tabs' ) );
27 }
28
29
30 public function in_page() {
31 return 'wpbc-customize_plugin';
32 }
33
34
35 public function tabs() {
36
37 $tabs = array();
38 $tabs[ 'customize_plugin' ] = array(
39 'title' => __( 'Customize', 'booking' ) // Title of TAB
40 , 'hint' => __( 'Customize', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
41 , 'page_title' => __( 'Configuration Wizard', 'booking' ) // Title of Page
42 , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
43 , 'position' => '' // 'left' || 'right' || ''
44 , 'css_classes' => '' // CSS class(es)
45 , 'icon' => '' // Icon - link to the real PNG img
46 , 'font_icon' => 'wpbc_icn_tune'//'wpbc_icn_free_cancellation' // CSS definition of forn Icon
47 , 'default' => true // Is this tab activated by default or not: true || false.
48 , 'disabled' => false // Is this tab disbaled: true || false.
49 , 'hided' => false // Is this tab hided: true || false.
50 , 'subtabs' => array()
51 );
52 // $subtabs = array();
53 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
54 return $tabs;
55 }
56
57
58 /**
59 * Show custom tabs for Toolbar at . - . R i g h t . s i d e.
60 *
61 * @param string $menu_in_page_tag - active page
62 */
63 public function wpbc_toolbar_toolbar_tabs( $menu_in_page_tag ) {
64
65 if ( $this->in_page() == $menu_in_page_tag ) {
66
67 // Just for get last saved default tab
68 $escaped_search_request_params = $this->get_cleaned_params__saved_requestvalue_default();
69
70 // Check if by some reason, user was saved request without this parameter, then get default value
71 if ( ! empty( $escaped_search_request_params['current_step'] ) ) {
72 $selected_tab = $escaped_search_request_params['current_step'];
73 } else {
74 $default_search_request_params = WPBC_AJX__Customize_Plugin__Ajax_Request::request_rules_structure();
75 $selected_tab = $default_search_request_params ['current_step']['default'];
76 }
77
78 $current_step_page = explode( '_', $selected_tab ); // 'calendar_skin', 'calendar_size', 'calendar_dates_selection', 'calendar_weekdays_availability', 'calendar_additional', 'form_structure', ...
79 wpbc_bs_toolbar_tabs_html_container_start();
80 wpbc_bs_display_tab( array(
81 'title' => '1. '. __( 'Calendar', 'booking' )
82 , 'hint' => array( 'title' => __('Customize' ,'booking') , 'position' => 'top' )
83 , 'onclick' => "jQuery('.ui_container_toolbar').hide();" . "jQuery('.ui_container_calendar_skin').show();" . "jQuery('.wpbc_customize_plugin_support_tabs').removeClass('nav-tab-active');" . "jQuery(this).addClass('nav-tab-active');" . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');" . "jQuery('.nav-tab-active i').addClass('icon-white');"
84 /**
85 * It will save such changes, and if we have selected bookings, then deselect them
86 */
87 . "wpbc_ajx_customize_plugin__send_request_with_params( { 'current_step': 'calendar_skin' });"
88 /**
89 * It will save changes with NEXT search request, but not immediately
90 * it is handy, in case if we have selected bookings,
91 * we will not lose selection.
92 */
93 // . "wpbc_ajx_customize_plugin.search_set_param( 'current_step', 'calendar_skin' );"
94 , 'font_icon' => 'wpbc-bi-calendar2-check'
95 , 'default' => ( 'calendar' == $current_step_page[0] ) ? true : false
96 //, 'position' => 'right'
97 , 'css_classes' => 'wpbc_customize_plugin_support_tabs'
98 ) );
99 wpbc_bs_display_tab( array(
100 'title' => '2. '. __('Booking Form', 'booking')
101 , 'hint' => array( 'title' => __('Customize' ,'booking') , 'position' => 'top' )
102 , 'onclick' => "jQuery('.ui_container_toolbar').hide();" . "jQuery('.ui_container_form_structure').show();" . "jQuery('.wpbc_customize_plugin_support_tabs').removeClass('nav-tab-active');" . "jQuery(this).addClass('nav-tab-active');" . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');" . "jQuery('.nav-tab-active i').addClass('icon-white');"
103 /**
104 * It will save such changes, and if we have selected bookings, then deselect them
105 */
106 . "wpbc_ajx_customize_plugin__send_request_with_params( { 'current_step': 'form_structure' });"
107 /**
108 * It will save changes with NEXT search request, but not immediately
109 * it is handy, in case if we have selected bookings,
110 * we will not lose selection.
111 */
112 // . "wpbc_ajx_customize_plugin.search_set_param( 'current_step', 'calendar_skin' );"
113 , 'font_icon' => 'wpbc_icn_dashboard _customize dashboard rtt draw'
114 , 'default' => ( 'form' == $current_step_page[0] ) ? true : false
115 //, 'position' => 'right'
116 , 'css_classes' => 'wpbc_customize_plugin_support_tabs'
117 ) );
118 wpbc_bs_display_tab( array(
119 'title' => '3. '. __('Emails', 'booking')
120 , 'hint' => array( 'title' => __('Customize' ,'booking') , 'position' => 'top' )
121 , 'onclick' => "jQuery('.ui_container_toolbar').hide();" . "jQuery('.ui_container_emails_active').show();" . "jQuery('.wpbc_customize_plugin_support_tabs').removeClass('nav-tab-active');" . "jQuery(this).addClass('nav-tab-active');" . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');" . "jQuery('.nav-tab-active i').addClass('icon-white');"
122 /**
123 * It will save such changes, and if we have selected bookings, then deselect them
124 */
125 . "wpbc_ajx_customize_plugin__send_request_with_params( { 'current_step': 'emails_active' });"
126 /**
127 * It will save changes with NEXT search request, but not immediately
128 * it is handy, in case if we have selected bookings,
129 * we will not lose selection.
130 */
131 // . "wpbc_ajx_customize_plugin.search_set_param( 'current_step', 'calendar_skin' );"
132 , 'font_icon' => 'wpbc_icn_mail_outline'
133 , 'default' => ( 'emails' == $current_step_page[0] ) ? true : false
134 //, 'position' => 'right'
135 , 'css_classes' => 'wpbc_customize_plugin_support_tabs'
136 ) );
137 wpbc_bs_display_tab( array(
138 'title' => '4. '. __('Payments', 'booking')
139 , 'hint' => array( 'title' => __('Customize' ,'booking') , 'position' => 'top' )
140 , 'onclick' => "jQuery('.ui_container_toolbar').hide();" . "jQuery('.ui_container_payments_active').show();" . "jQuery('.wpbc_customize_plugin_support_tabs').removeClass('nav-tab-active');" . "jQuery(this).addClass('nav-tab-active');" . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');" . "jQuery('.nav-tab-active i').addClass('icon-white');"
141 /**
142 * It will save such changes, and if we have selected bookings, then deselect them
143 */
144 . "wpbc_ajx_customize_plugin__send_request_with_params( { 'current_step': 'payments_active' });"
145 /**
146 * It will save changes with NEXT search request, but not immediately
147 * it is handy, in case if we have selected bookings,
148 * we will not lose selection.
149 */
150 // . "wpbc_ajx_customize_plugin.search_set_param( 'current_step', 'calendar_skin' );"
151 , 'font_icon' => 'wpbc_icn_payment'
152 , 'default' => ( 'payments' == $current_step_page[0] ) ? true : false
153 //, 'position' => 'right'
154 , 'css_classes' => 'wpbc_customize_plugin_support_tabs'
155 ) );
156 wpbc_bs_display_tab( array(
157 'title' => '5. '. __('Publish Resources', 'booking')
158 , 'hint' => array( 'title' => __('Customize' ,'booking') , 'position' => 'top' )
159 , 'onclick' => "jQuery('.ui_container_toolbar').hide();" . "jQuery('.ui_container_publish_resource').show();" . "jQuery('.wpbc_customize_plugin_support_tabs').removeClass('nav-tab-active');" . "jQuery(this).addClass('nav-tab-active');" . "jQuery('.nav-tab i.icon-white').removeClass('icon-white');" . "jQuery('.nav-tab-active i').addClass('icon-white');"
160 /**
161 * It will save such changes, and if we have selected bookings, then deselect them
162 */
163 . "wpbc_ajx_customize_plugin__send_request_with_params( { 'current_step': 'publish_resource' });"
164
165 /**
166 * It will save changes with NEXT search request, but not immediately
167 * it is handy, in case if we have selected bookings,
168 * we will not lose selection.
169 */
170 // . "wpbc_ajx_customize_plugin.search_set_param( 'current_step', 'calendar_skin' );"
171 , 'font_icon' => 'wpbc_icn_checklist'
172 , 'default' => ( 'publish' == $current_step_page[0] ) ? true : false
173 //, 'position' => 'right'
174 , 'css_classes' => 'wpbc_customize_plugin_support_tabs'
175 ) );
176 wpbc_bs_toolbar_tabs_html_container_end();
177
178 }
179 }
180
181
182 /**
183 * Get sanitised request parameters. :: Firstly check if user saved it. :: Otherwise, check $_REQUEST. :: Otherwise get default.
184 *
185 * @return array|false
186 */
187 public function get_cleaned_params__saved_requestvalue_default(){
188
189 $user_request = new WPBC_AJX__REQUEST( array(
190 'db_option_name' => 'booking_customize_plugin_request_params',
191 'user_id' => wpbc_get_current_user_id(),
192 'request_rules_structure' => WPBC_AJX__Customize_Plugin__Ajax_Request::request_rules_structure()
193 )
194 );
195 $escaped_request_params_arr = $user_request->get_sanitized__saved__user_request_params(); // Get Saved
196
197 if ( false === $escaped_request_params_arr ) { // This request was not saved before, then get sanitized direct parameters, like: $_REQUEST['resource_id']
198
199 $request_prefix = false;
200 $escaped_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id']
201 }
202
203
204 // Override parameters from DB by parameters from REQUEST! ----------------------------------------------
205 $request_key = 'current_step';
206 if ( isset( $_REQUEST[ $request_key ] ) ) {
207
208 // Get SANITIZED REQUEST parameters together with default values
209 $request_prefix = false;
210 $url_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id']
211
212 // Now get only SANITIZED values that exist in REQUEST
213 $url_request_params_only_arr = array_intersect_key( $url_request_params_arr, $_REQUEST );
214
215 // And now override our DB $escaped_request_params_arr by SANITIZED $_REQUEST values
216 $escaped_request_params_arr = wp_parse_args( $url_request_params_only_arr, $escaped_request_params_arr );
217 }
218 // ---------------------------------------------------------------------------------------------------------
219
220 //MU
221 if ( class_exists( 'wpdev_bk_multiuser' ) ) {
222
223 // Check if this MU user activated or superadmin, otherwise show warning
224 if ( ! wpbc_is_mu_user_can_be_here('activated_user') )
225 return false;
226
227 // Check if this MU user owner of this resource or superadmin, otherwise show warning
228 if ( ! wpbc_is_mu_user_can_be_here( 'resource_owner', $escaped_request_params_arr['resource_id'] ) ) {
229 $default_values = $user_request->get_request_rules__default();
230 $escaped_request_params_arr['resource_id'] = $default_values['resource_id'];
231 }
232
233 }
234
235
236
237 return $escaped_request_params_arr;
238 }
239
240
241 public function content() {
242
243 $this->css_fix();
244
245 do_action( 'wpbc_hook_settings_page_header', 'page_booking_customize_plugin'); // Define Notices Section and show some static messages, if needed.
246
247 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
248
249 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
250
251
252 // Get and escape request parameters ////////////////////////////////////////////////////////////////////////
253 $escaped_request_params_arr = $this->get_cleaned_params__saved_requestvalue_default();
254
255 // During initial load of the page, we need to reset 'dates_selection' value in our saved parameter
256 $escaped_request_params_arr['dates_selection'] = '';
257
258 // Submit /////////////////////////////////////////////////////////////
259 $submit_form_name = 'wpbc_ajx_customize_plugin_form'; // Define form name
260
261 ?><span class="wpdevelop"><?php // BS UI CSS Class
262
263 wpbc_js_for_bookings_page(); // JavaScript functions
264
265 ?><div id="toolbar_booking_customize_plugin" class="wpbc_ajx_toolbar"><?php
266 ?><div class="wpbc_ajx_customize_plugin_toolbar_container"></div><?php //This Div Required for bottom border radius in container
267 ?></div><?php
268
269 // wpbc_ajx_customize_plugin__toolbar( $escaped_request_params_arr );
270
271 ?></span><?php
272
273 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
274
275 // Content ////////////////////////////////////////////////////////////
276 ?>
277 <div class="clear" style="margin-bottom:10px;"></div>
278 <span class="metabox-holder">
279 <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" >
280 <?php
281 // N o n c e field, and key for checking S u b m i t
282 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
283 ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /><?php
284
285 //wpbc_ajx_booking_modify_container_show(); // Container for showing Edit ajx_booking and define Edit and Delete ajx_booking JavaScript vars.
286
287 wpbc_clear_div();
288
289 $this->ajx_customize_plugin_container__show( $escaped_request_params_arr );
290
291 wpbc_clear_div();
292
293 ?></form>
294 </span>
295 <?php
296
297 //wpbc_show_wpbc_footer(); // Rating
298
299 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_customize_plugin' );
300 }
301
302 private function ajx_customize_plugin_container__show( $escaped_request_params_arr ) {
303
304 $is_show_resource_unavailable_stripes = ( !true ) ? ' wpbc_ajx_availability_container' : '';
305 ?>
306 <div id="ajx_nonce_calendar_section"></div>
307 <div class="wpbc_listing_container wpbc_selectable_table wpbc_ajx_customize_plugin_container wpdevelop<?php echo $is_show_resource_unavailable_stripes; ?>" wpbc_loaded="first_time">
308 <style type="text/css">
309 .wpbc_calendar_loading .wpbc_icn_autorenew::before{
310 font-size: 1.2em;
311 }
312 .wpbc_calendar_loading {
313 width:95%;
314 text-align: center;
315 margin:2em 0;
316 font-size: 1.2em;
317 font-weight: 600;
318 }
319 </style>
320 <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php _e( 'Loading', 'booking' ); ?>...</span>
321 </div>
322 </div>
323 <script type="text/javascript">
324 jQuery( document ).ready( function (){
325
326 // Set Security - Nonce for Ajax - Listing
327 wpbc_ajx_customize_plugin.set_secure_param( 'nonce', '<?php echo wp_create_nonce( 'wpbc_ajx_customize_plugin_ajx' . '_wpbcnonce' ) ?>' );
328 wpbc_ajx_customize_plugin.set_secure_param( 'user_id', '<?php echo wpbc_get_current_user_id(); ?>' );
329 wpbc_ajx_customize_plugin.set_secure_param( 'locale', '<?php echo get_user_locale(); ?>' );
330
331 // Set other parameters
332 wpbc_ajx_customize_plugin.set_other_param( 'listing_container', '.wpbc_ajx_customize_plugin_container' );
333 wpbc_ajx_customize_plugin.set_other_param( 'toolbar_container', '.wpbc_ajx_customize_plugin_toolbar_container' );
334
335 // Send Ajax request and show listing after this.
336 wpbc_ajx_customize_plugin__send_request_with_params( <?php echo wp_json_encode( $escaped_request_params_arr ); ?> );
337 } );
338 </script>
339 <?php
340 }
341
342 /**
343 * Hide first "Customize_Plugin tab", because we have only one tab here, and need to show only tabs for toolbar
344 * @return void
345 */
346 private function css_fix(){
347 return;
348 ?><style type="text/css">
349 .nav-tabs .nav-tab:first-child{
350 /*display:none; !*flex: It's hide first Tab in toolbar. We have visible toolbar, and by default we can see page tab. But by this hook 'wpbc_toolbar_top_tabs_after' we added own custom tabs. *!*/
351 }
352 </style><?php
353 }
354
355 }
356 add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Customize_Plugin() , '__construct') ); // Executed after creation of Menu
357