PluginProbe
Booking Calendar / 10.15.6
Booking Calendar v10.15.6
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-setup / setup__page.php

setup__page.php in Booking Calendar 10.15.6, at includes/page-setup/setup__page.php

362 lines 19.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * @package: AJX_Setup_Wizard Page
4 * @category: Initial setup and plugin customization
5 * Author: wpdevelop, oplugins
6 * Version: 1.0
7 * @modified 2024-06-28
8 */
9 // FixIn: 10.2.0.1.
10 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
12 /**
13 * == How to add a new step ? ==
14 *
15 * 1. Create and include (bellow) a new files:
16 * require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/form_structure__tpl.php' );
17 * require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/form_structure__action.php' );
18 *
19 * 2) ../includes/page-setup/setup_steps.php
20 * - Add a new step structure in init_steps_data()
21 *
22 * 3)../includes/page-setup/setup_ajax.php
23 * - Add validation option 'save_and_continue__form_structure' in wpbc_setup_wizard_page__request_rules_structure()
24 * - Add save action in ajax_WPBC_AJX_SETUP_WIZARD_PAGE :
25 * case 'save_and_continue__form_structure': $
26 * if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
27 * $cleaned_data = wpbc_template__form_structure__action_validate_data( $_POST['all_ajx_params']['step_data'] );
28 * wpbc_setup__update__form_structure( $cleaned_data );
29 * }
30 * $setup_steps->db__set_step_as_completed( 'form_structure' );
31 * break;
32 * - Optional. Add loading booking form:
33 * switch ( $cleaned_request_params['current_step'] ) {
34 * case 'form_structure':
35 * 4) ../includes/page-setup/setup_templates.php
36 * - Add loading template in function wpbc_template__stp_wiz__main_content() {
37 * case 'form_structure':
38 * template__main_section = wp.template( 'wpbc_stp_wiz__template__form_structure' );
39 * break;
40 * - include template in function hook__load_templates_at_footer( $page ):
41 * wpbc_stp_wiz__template__form_structure();
42 */
43
44
45 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_templates.php' );
46 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/01.welcome__tpl.php' );
47
48 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/02.general_info__tpl.php' );
49 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/02.general_info__action.php' );
50
51 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/03.date_time_formats__tpl.php' );
52 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/03.date_time_formats__action.php' );
53
54 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/04.bookings_types__tpl.php' );
55 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/04.bookings_types__action.php' );
56
57 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/05.form_structure__tpl.php' );
58 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/05.form_structure__action.php' );
59
60 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/06.cal_availability__tpl.php' );
61 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/06.cal_availability__action.php' );
62
63 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/07.color_theme__tpl.php' );
64 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/07.color_theme__action.php' );
65
66 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/08.optional_other_settings__tpl.php' );
67 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/08.optional_other_settings__action.php' );
68
69 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/09.wizard_publish__tpl.php' );
70 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/09.wizard_publish__action.php' );
71
72 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/10.get_started__tpl.php' );
73 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/10.get_started__action.php' );
74
75 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_steps.php' );
76 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_ajax.php' );
77 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_support.php' );
78
79 /** Show Content
80 * Update Content
81 * Define Slug
82 * Define where to show
83 */
84 class WPBC_Page_AJX_Setup_Wizard extends WPBC_Page_Structure {
85
86 private $is_full_screen = true;
87
88 public function __construct() {
89
90 parent::__construct();
91
92 add_filter( 'admin_body_class', array( $this, 'add_loading_classes' ) );
93 }
94
95
96 public function in_page() {
97 return 'wpbc-setup';
98 }
99
100
101 public function tabs() {
102
103 $tabs = array();
104 $tabs[ 'step_01' ] = array(
105 'left_navigation__default_view_mode' => 'none', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
106 'title' => __( 'Setup', 'booking' ) // Title of TAB
107 , 'hint' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
108 , 'page_title' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page
109 , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
110 , 'position' => '' // 'left' || 'right' || ''
111 , 'css_classes' => '' // CSS class(es)
112 , 'icon' => '' // Icon - link to the real PNG img
113 , 'font_icon' => 'wpbc_icn_donut_large' //'wpbc_icn_free_cancellation' // CSS definition of forn Icon
114 , 'default' => true // Is this tab activated by default or not: true || false.
115 , 'disabled' => false // Is this tab disbaled: true || false.
116 , 'hided' => false // Is this tab hided: true || false.
117 , 'subtabs' => array()
118 );
119
120 $subtabs = array();
121 $subtabs['path_setup'] = array(
122 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
123 , 'title' => __( 'Setup', 'booking' ) // Title of TAB
124 , 'page_title'=> false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page
125 , 'hint' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
126 , 'link' => '#path_setup' // link
127 , 'position' => '' // 'left' || 'right' || ''
128 , 'css_classes' => '' // CSS class(es)
129 //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
130 //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon
131 , 'default' => true // Is this sub tab activated by default or not: true || false.
132 , 'disabled' => false // Is this sub tab deactivated: true || false.
133 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
134 , 'content' => 'content' // Function to load as content of this TAB
135 , 'is_use_navigation_path' => array(
136 'path' => array(
137 'go_back_to_dashboard' => array(
138 'title' => __('Go to Dashboard','booking'),
139 'hint' => __('Go back to the Dashboard','booking'),
140 'icon' => 'wpbc_icn_navigate_before',
141 'url' => wpbc_get_bookings_url(), //wpbc_get_settings_url(),
142 'attr' => array( 'style' => 'border-right: 1px solid #0000001a; margin-right: 10px;padding-right: 25px;' .
143 ( !$this->is_full_screen ? 'display:none;' : '' ) ),
144 'class' => 'wpbc_full_screen_mode_buttons'
145 ),
146 // 'go_back_separtor' => array( 'tag' => '|' ), //array( 'tag' => '>' ),
147 'setup' => array(
148 'title' => __('Setup','booking'),
149 'hint' => __('Initial Setup','booking'),
150 'icon' => 'wpbc_icn_donut_large wpbc_spin wpbc_animation_pause', // -> wpbc_setup_wizard_page_reload_button__spin_start( ... )
151 'attr' => array( 'style' => 'pointer-events: none;', 'id' => 'wpbc_initial_setup_top_menu_item' ),
152 'url' => '',
153 'tag' => 'div',
154 'class' => 'nav-tab-active'
155 ),
156 // 'next_all' => array( 'tag' => '>' ),
157 // 'intro' => array(
158 // 'title' => __('Step','booking') . ' ' . wpbc_setup_wizard_page__get_active_step() . ' / ' .wpbc_setup_wizard_page__get_total_steps(),
159 // 'hint' => __('General Settings','booking'),
160 // 'icon' => 'wpbc_icn_layers outlined_flag',//'wpbc_icn_adjust',
161 // 'url' => wpbc_get_setup_wizard_page_url() . '&tab=step_01',
162 // //'attr' => array()
163 // //'tag' => 'a',
164 // 'class' => 'nav-tab-active'
165 // ),
166 'wpbc__container_place__steps_for_timeline' => array(
167 'title' => '',
168 'hint' => '',
169 'icon' => '',
170 'action' => '',
171 'attr' => array( 'style' => '' ),
172 'tag' => 'div',
173 'class' => 'wpbc__container_place__steps_for_timeline'
174 ),
175 'full_screen' => array(
176 'title' => '',//__('Full Screen','booking'),
177 'hint' => __('Full Screen','booking'),
178 'icon' => 'wpbc-bi-arrows-fullscreen 0wpbc_icn_zoom_out_map 0wpbc_icn_open_in_full',
179 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();",
180 'attr' => array( 'style' => 'margin-left:auto;' . ( $this->is_full_screen ? 'display:none;' : '' ) ),
181 //'tag' => 'a',
182 'class' => 'wpbc_full_screen_mode_buttons'
183 ),
184 'full_screen_exit' => array(
185 'title' => '',
186 'hint' => __('Exit Full Screen','booking'),
187 'icon' => 'wpbc-bi-arrows-angle-contract 0wpbc_icn_zoom_in_map 0wpbc_icn_close_fullscreen',
188 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();",
189 'attr' => array( 'style' => 'margin-left:auto;' . ( !$this->is_full_screen ? 'display:none;' : '' ) ),
190 //'tag' => 'a',
191 'class' => 'wpbc_full_screen_mode_buttons'
192 )
193 )
194 )
195 );
196 $tabs[ 'step_01' ][ 'subtabs' ] = $subtabs;
197
198 return $tabs;
199 }
200
201
202 public function content() {
203
204 do_action( 'wpbc_hook_settings_page_header', 'page_booking_setup_wizard'); // Define Notices Section and show some static messages, if needed.
205
206 // -------------------------------------------------------------------------------------------------------------
207 // Check MultiUser params
208 // -------------------------------------------------------------------------------------------------------------
209 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
210 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
211
212
213 // -------------------------------------------------------------------------------------------------------------
214 // Get and escape request parameters
215 // -------------------------------------------------------------------------------------------------------------
216 $escaped_request_params_arr = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default();
217
218
219 // -------------------------------------------------------------------------------------------------------------
220 // Main Submit Form (if needed ?)
221 // -------------------------------------------------------------------------------------------------------------
222 $submit_form_name = 'wpbc_setup_wizard_page_form'; // Define form name
223 ?><form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" >
224 <?php
225 // N o n c e field, and key for checking S u b m i t
226 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
227 ?><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
228
229 ?></form><?php
230
231 // -------------------------------------------------------------------------------------------------------------
232 // JS :: Tooltips, Popover, Datepicker
233 // -------------------------------------------------------------------------------------------------------------
234 wpbc_js_for_bookings_page();
235
236 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
237
238 ?><div class="wpbc_page_publish_notice_section"><?php
239 // This is required for submit of Embed shortcodes into New or Existing pages !
240 do_action( 'wpbc_hook_settings_page_before_content_table', 'resources' ); // Define Notices Section and show some static messages, if needed
241 ?></div><?php
242 // -------------------------------------------------------------------------------------------------------------
243 // == Content ==
244 // -------------------------------------------------------------------------------------------------------------
245 $this->show__main_container( $escaped_request_params_arr );
246
247 //wpbc_show_wpbc_footer(); // Rating
248
249 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_setup_wizard' );
250 }
251
252
253 private function show__main_container( $escaped_request_params_arr ) {
254
255 wpbc_clear_div();
256 ?>
257 <span class="metabox-holder">
258 <div id="ajx_nonce_calendar_section"></div>
259 <div class="wpbc_setup_wizard_page_container" wpbc_loaded="first_time">
260 <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php esc_html_e( 'Loading', 'booking' ); ?>...</span></div>
261 </div>
262 </span>
263 <?php
264
265 wpbc_clear_div();
266
267 ?><script type="text/javascript"><?php
268 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
269 echo wpbc_jq_ready_start();
270 if( $this->is_full_screen ) {
271 ?>
272 jQuery( '.wpbc_ui__top_nav__btn_full_screen,.wpbc_ui__top_nav__btn_normal_screen' ).toggleClass( 'wpbc_ui__hide' );
273 wpbc_check_full_screen_mode();
274 <?php
275 }
276 ?>
277
278 // Set Security - Nonce for Ajax - Listing
279 _wpbc_settings.set_param__secure( 'nonce', '<?php echo esc_js( wp_create_nonce( 'wpbc_setup_wizard_page_ajx' . '_wpbcnonce' ) ); ?>' );
280 _wpbc_settings.set_param__secure( 'user_id', '<?php echo esc_js( wpbc_get_current_user_id() ); ?>' );
281 _wpbc_settings.set_param__secure( 'locale', '<?php echo esc_js( get_user_locale() ); ?>' );
282
283 // Set other parameters
284 _wpbc_settings.set_param__other( 'container__main_content', '.wpbc_setup_wizard_page_container' );
285
286 // Send Ajax and then show content
287 wpbc_ajx__setup_wizard_page__send_request_with_params( <?php echo wp_json_encode( $escaped_request_params_arr ); ?> );
288 <?php
289 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
290 echo wpbc_jq_ready_end();
291 ?></script><?php
292
293 /**
294 * JS Examples of showing specific Step:
295 * wpbc_ajx__setup_wizard_page__send_request_with_params( { 'current_step':'optional_other_settings' } );
296 *
297 * wpbc_ajx__setup_wizard_page__send_request_with_params( { 'current_step':'general_info' } );
298 */
299 }
300
301
302 /**
303 * Set the admin full screen class
304 *
305 * @param bool $classes Body classes.
306 * @return array
307 */
308 public function add_loading_classes( $classes ) {
309
310 if ( ( wpbc_is_setup_wizard_page() ) && ( $this->is_full_screen ) ) {
311 $classes .= ' wpbc_admin_full_screen';
312 }
313
314 return $classes;
315 }
316 }
317 add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Setup_Wizard() , '__construct') ); // Executed after creation of Menu
318
319
320 /**
321 * Make Setup Status Reset or Complete from URL
322 *
323 * @return bool
324 */
325 function wpbc_setup_wizard_page__force_in_get() {
326
327 // Se it as DONE
328 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
329 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'completed' === $_REQUEST['wpbc_setup_wizard'] ) {
330
331 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
332 $setup_steps->db__set_all_steps_as( true );
333
334 return true;
335 }
336
337 // Reset
338 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
339 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'reset' === $_REQUEST['wpbc_setup_wizard'] ) {
340
341 // -------------------------------------------------------------------------------------------------------------
342 // == Request == -> $_REQUEST['all_ajx_params']['page_num'], $_REQUEST['all_ajx_params']['page_items_count'], ...
343 // -------------------------------------------------------------------------------------------------------------
344 $user_request = new WPBC_AJX__REQUEST( array(
345 'db_option_name' => 'booking_setup_wizard_page_request_params',
346 'user_id' => wpbc_get_current_user_id(),
347 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure()
348 )
349 );
350 // Delete from DB
351 $is_reseted = $user_request->user_request_params__db_delete();
352
353 // Clear All Steps Mark as Undone
354 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
355 $setup_steps->db__set_all_steps_as( false );
356
357 return true;
358 }
359
360 return false;
361 }
362 add_action( 'init', 'wpbc_setup_wizard_page__force_in_get' );