PluginProbe
Booking Calendar / 10.10.2
Booking Calendar v10.10.2
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 / includes / page-setup / setup__page.php

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

377 lines 20.1 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 // add_action( 'wpbc_page_show_left_navigation_custom', array( $this, 'left_navigation_custom__settings_all' ) );
95 }
96
97
98 public function in_page() {
99 return 'wpbc-setup';
100 }
101
102
103 public function tabs() {
104
105 $tabs = array();
106 $tabs[ 'step_01' ] = array(
107 'title' => __( 'Setup', 'booking' ) // Title of TAB
108 , 'hint' => __( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
109 , 'page_title' => __( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page
110 , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
111 , 'position' => '' // 'left' || 'right' || ''
112 , 'css_classes' => '' // CSS class(es)
113 , 'icon' => '' // Icon - link to the real PNG img
114 , 'font_icon' => 'wpbc_icn_donut_large' //'wpbc_icn_free_cancellation' // CSS definition of forn Icon
115 , 'default' => true // Is this tab activated by default or not: true || false.
116 , 'disabled' => false // Is this tab disbaled: true || false.
117 , 'hided' => false // Is this tab hided: true || false.
118 , 'subtabs' => array()
119 );
120
121 $subtabs = array();
122 $subtabs['path_setup'] = array(
123 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
124 , 'title' => __( 'Setup', 'booking' ) // Title of TAB
125 , 'page_title'=> __( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page
126 , 'hint' => __( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
127 , 'link' => '#path_setup' // link
128 , 'position' => '' // 'left' || 'right' || ''
129 , 'css_classes' => '' // CSS class(es)
130 //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
131 //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon
132 , 'header_font_icon' => 'wpbc_icn_donut_large' // CSS definition of Font Icon // FixIn: 9.6.1.4.
133 , 'default' => true // Is this sub tab activated by default or not: true || false.
134 , 'disabled' => false // Is this sub tab deactivated: true || false.
135 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
136 , 'content' => 'content' // Function to load as content of this TAB
137 //, 'is_use_left_navigation' => true // == Show $tabs[ 'step_01' ]['title'] -> "Setup" Menu at left side instead of Old top menu (which is hidden in setup_page.css .wpbc_top_tabs_sub_menu{...}, in case if we do not use navigation path, e.g. $tabs[ 'step_01' ]['subtabs']['path_setup'][ 'is_use_navigation_path'] = false;
138 //, 'is_use_left_navigation_custom' => true // == Usually used Together with 'is_use_left_navigation': true, and defined CUSTOM left menu, instead of submenu. Need to use add_action( 'wpbc_page_show_left_navigation_custom', array( $this, 'left_navigation_custom__settings_all' ) ); in constructor and custom func: left_navigation_custom__settings_all
139 , 'show_checked_icon' => false
140 , 'is_use_navigation_path' => array(
141 'path' => array(
142 'go_back_to_dashboard' => array(
143 'title' => __('Go to Dashboard','booking'),
144 'hint' => __('Go back to the Dashboard','booking'),
145 'icon' => 'wpbc_icn_navigate_before',
146 'url' => wpbc_get_bookings_url(), //wpbc_get_settings_url(),
147 'attr' => array( 'style' => 'border-right: 1px solid #0000001a; margin-right: 10px;padding-right: 25px;' .
148 ( !$this->is_full_screen ? 'display:none;' : '' ) ),
149 'class' => 'wpbc_full_screen_mode_buttons'
150 ),
151 // 'go_back_separtor' => array( 'tag' => '|' ), //array( 'tag' => '>' ),
152 'setup' => array(
153 'title' => __('Setup','booking'),
154 'hint' => __('Initial Setup','booking'),
155 'icon' => 'wpbc_icn_donut_large wpbc_spin wpbc_animation_pause', // -> wpbc_setup_wizard_page_reload_button__spin_start( ... )
156 'attr' => array( 'style' => 'pointer-events: none;', 'id' => 'wpbc_initial_setup_top_menu_item' ),
157 'url' => '',
158 'tag' => 'div',
159 'class' => 'nav-tab-active'
160 ),
161 // 'next_all' => array( 'tag' => '>' ),
162 // 'intro' => array(
163 // 'title' => __('Step','booking') . ' ' . wpbc_setup_wizard_page__get_active_step() . ' / ' .wpbc_setup_wizard_page__get_total_steps(),
164 // 'hint' => __('General Settings','booking'),
165 // 'icon' => 'wpbc_icn_layers outlined_flag',//'wpbc_icn_adjust',
166 // 'url' => wpbc_get_setup_wizard_page_url() . '&tab=step_01',
167 // //'attr' => array()
168 // //'tag' => 'a',
169 // 'class' => 'nav-tab-active'
170 // ),
171 'wpbc__container_place__steps_for_timeline' => array(
172 'title' => '',
173 'hint' => '',
174 'icon' => '',
175 'action' => '',
176 'attr' => array( 'style' => '' ),
177 'tag' => 'div',
178 'class' => 'wpbc__container_place__steps_for_timeline'
179 ),
180 'full_screen' => array(
181 'title' => '',//__('Full Screen','booking'),
182 'hint' => __('Full Screen','booking'),
183 'icon' => 'wpbc-bi-arrows-fullscreen 0wpbc_icn_zoom_out_map 0wpbc_icn_open_in_full',
184 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();",
185 'attr' => array( 'style' => 'margin-left:auto;' . ( $this->is_full_screen ? 'display:none;' : '' ) ),
186 //'tag' => 'a',
187 'class' => 'wpbc_full_screen_mode_buttons'
188 ),
189 'full_screen_exit' => array(
190 'title' => '',
191 'hint' => __('Exit Full Screen','booking'),
192 'icon' => 'wpbc-bi-arrows-angle-contract 0wpbc_icn_zoom_in_map 0wpbc_icn_close_fullscreen',
193 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();",
194 'attr' => array( 'style' => 'margin-left:auto;' . ( !$this->is_full_screen ? 'display:none;' : '' ) ),
195 //'tag' => 'a',
196 'class' => 'wpbc_full_screen_mode_buttons'
197 )
198 )
199 )
200 );
201 $tabs[ 'step_01' ][ 'subtabs' ] = $subtabs;
202
203 return $tabs;
204 }
205
206
207 public function content() {
208
209 do_action( 'wpbc_hook_settings_page_header', 'page_booking_setup_wizard'); // Define Notices Section and show some static messages, if needed.
210
211 // -------------------------------------------------------------------------------------------------------------
212 // Check MultiUser params
213 // -------------------------------------------------------------------------------------------------------------
214 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
215 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
216
217
218 // -------------------------------------------------------------------------------------------------------------
219 // Get and escape request parameters
220 // -------------------------------------------------------------------------------------------------------------
221 $escaped_request_params_arr = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default();
222
223
224 // -------------------------------------------------------------------------------------------------------------
225 // Main Submit Form (if needed ?)
226 // -------------------------------------------------------------------------------------------------------------
227 $submit_form_name = 'wpbc_setup_wizard_page_form'; // Define form name
228 ?><form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" >
229 <?php
230 // N o n c e field, and key for checking S u b m i t
231 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
232 ?><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
233
234 ?></form><?php
235
236 // -------------------------------------------------------------------------------------------------------------
237 // JS :: Tooltips, Popover, Datepicker
238 // -------------------------------------------------------------------------------------------------------------
239 wpbc_js_for_bookings_page();
240
241 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
242
243 ?><div class="wpbc_page_publish_notice_section"><?php
244 // This is required for submit of Embed shortcodes into New or Existing pages !
245 do_action( 'wpbc_hook_settings_page_before_content_table', 'resources' ); // Define Notices Section and show some static messages, if needed
246 ?></div><?php
247 // -------------------------------------------------------------------------------------------------------------
248 // == Content ==
249 // -------------------------------------------------------------------------------------------------------------
250 $this->show__main_container( $escaped_request_params_arr );
251
252 //wpbc_show_wpbc_footer(); // Rating
253
254 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_setup_wizard' );
255 }
256
257
258 private function show__main_container( $escaped_request_params_arr ) {
259
260 wpbc_clear_div();
261 ?>
262 <span class="metabox-holder">
263 <div id="ajx_nonce_calendar_section"></div>
264 <div class="wpbc_setup_wizard_page_container" wpbc_loaded="first_time">
265 <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php esc_html_e( 'Loading', 'booking' ); ?>...</span></div>
266 </div>
267 </span>
268 <?php
269
270 wpbc_clear_div();
271
272 ?><script type="text/javascript"><?php
273 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
274 echo wpbc_jq_ready_start();
275 ?>
276
277 // Set Security - Nonce for Ajax - Listing
278 _wpbc_settings.set_param__secure( 'nonce', '<?php echo esc_js( wp_create_nonce( 'wpbc_setup_wizard_page_ajx' . '_wpbcnonce' ) ); ?>' );
279 _wpbc_settings.set_param__secure( 'user_id', '<?php echo esc_js( wpbc_get_current_user_id() ); ?>' );
280 _wpbc_settings.set_param__secure( 'locale', '<?php echo esc_js( get_user_locale() ); ?>' );
281
282 // Set other parameters
283 _wpbc_settings.set_param__other( 'container__main_content', '.wpbc_setup_wizard_page_container' );
284
285 // Send Ajax and then show content
286 wpbc_ajx__setup_wizard_page__send_request_with_params( <?php echo wp_json_encode( $escaped_request_params_arr ); ?> );
287
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
318 /**
319 * Show custom tabs for Toolbar at . - . R i g h t . s i d e.
320 *
321 * @param string $menu_in_page_tag - active page
322 *
323 public function left_navigation_custom__settings_all( $menu_in_page_tag ) {
324
325 if ( $this->in_page() == $menu_in_page_tag ) {
326
327 wpbc_page_show_left_navigation_custom__settings_all();
328 }
329 }
330 */
331 }
332 add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Setup_Wizard() , '__construct') ); // Executed after creation of Menu
333
334
335 /**
336 * Make Setup Status Reset or Complete from URL
337 *
338 * @return bool
339 */
340 function wpbc_setup_wizard_page__force_in_get() {
341
342 // Se it as DONE
343 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
344 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'completed' === $_REQUEST['wpbc_setup_wizard'] ) {
345
346 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
347 $setup_steps->db__set_all_steps_as( true );
348
349 return true;
350 }
351
352 // Reset
353 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
354 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'reset' === $_REQUEST['wpbc_setup_wizard'] ) {
355
356 // -------------------------------------------------------------------------------------------------------------
357 // == Request == -> $_REQUEST['all_ajx_params']['page_num'], $_REQUEST['all_ajx_params']['page_items_count'], ...
358 // -------------------------------------------------------------------------------------------------------------
359 $user_request = new WPBC_AJX__REQUEST( array(
360 'db_option_name' => 'booking_setup_wizard_page_request_params',
361 'user_id' => wpbc_get_current_user_id(),
362 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure()
363 )
364 );
365 // Delete from DB
366 $is_reseted = $user_request->user_request_params__db_delete();
367
368 // Clear All Steps Mark as Undone
369 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
370 $setup_steps->db__set_all_steps_as( false );
371
372 return true;
373 }
374
375 return false;
376 }
377 add_action( 'init', 'wpbc_setup_wizard_page__force_in_get' );