db__is_all_steps_completed(); return $is_all_steps_completed; } /** * Check whether the Setup Wizard has started and is not yet complete. * * Explicit Setup Wizard requests count as active before the first step has * been saved. Persisted completed steps keep the wizard active while the user * visits another Booking Calendar administration page. A completed or skipped * wizard is not considered in progress. * * @return bool True while an unfinished Setup Wizard is in progress. */ function wpbc_setup_wizard_page__is_in_progress() { if ( wpbc_setup_wizard_page__is_all_steps_completed() ) { return false; } if ( function_exists( 'wpbc_is_setup_wizard_page' ) && wpbc_is_setup_wizard_page() ) { return true; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI context. $setup_context = isset( $_GET['wpbc_setup'] ) && is_scalar( $_GET['wpbc_setup'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI context. ? sanitize_text_field( wp_unslash( $_GET['wpbc_setup'] ) ) : ''; if ( '1' === $setup_context ) { return true; } $steps_is_done = get_bk_option( 'booking_setup_wizard_page_steps_is_done' ); if ( ! is_array( $steps_is_done ) ) { return false; } foreach ( $steps_is_done as $is_step_done ) { if ( ! empty( $is_step_done ) ) { return true; } } return false; } /** * Check whether the current request explicitly targets one Setup Wizard step. * * This read-only request check is intentionally independent from saved wizard * completion state. It lets an authorized user follow an explicit external * setup URL without causing ordinary administration-page visits to reopen the * completed wizard. * * @param string $step_name Expected Setup Wizard step identifier. * * @return bool True when the current URL explicitly requests the step. */ function wpbc_setup_wizard_page__has_explicit_step_context( $step_name ) { $step_name = sanitize_key( (string) $step_name ); if ( '' === $step_name ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI context. $setup_context = isset( $_GET['wpbc_setup'] ) && is_scalar( $_GET['wpbc_setup'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI context. ? sanitize_text_field( wp_unslash( $_GET['wpbc_setup'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI context. $request_step = isset( $_GET['wpbc_setup_step'] ) && is_scalar( $_GET['wpbc_setup_step'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI context. ? sanitize_key( wp_unslash( $_GET['wpbc_setup_step'] ) ) : ''; return '1' === $setup_context && $step_name === $request_step; } /** * Check whether the current request is one explicit external Setup Wizard step. * * The setup context flag prevents ordinary visits to the same administration * page from receiving wizard-only defaults. * * @param string $step_name Expected Setup Wizard step identifier. * * @return bool True when the unfinished wizard explicitly requested the step. */ function wpbc_setup_wizard_page__is_active_step( $step_name ) { $step_name = sanitize_key( (string) $step_name ); if ( '' === $step_name || ! wpbc_setup_wizard_page__is_in_progress() ) { return false; } return wpbc_setup_wizard_page__has_explicit_step_context( $step_name ); } /** * Is user can access Wizard Setup page ? * @return bool */ function wpbc_is_user_can_access_wizard_page() { $is_user_can_access_wizard_page = true; if ( class_exists( 'wpdev_bk_multiuser' ) ) { $real_current_user_id = get_current_user_id(); // Is current user suer booking admin and if this user was simulated log in $is_user_super_admin = apply_bk_filter( 'is_user_super_admin', $real_current_user_id ); if ( ! $is_user_super_admin ) { $is_user_can_access_wizard_page = false; } } return $is_user_can_access_wizard_page; } // ===================================================================================================================== // == Shortcodes Content == // ===================================================================================================================== /** * Get "Booking Form" Shortcode Content * * @param $resource_id * * @return false|string */ function wpbc_setup_wizard_page__get_shortcode_html( $resource_id = 1 , $is_show_only_calendar = false ) { ob_start(); $localized_js_vars_script = wpbc_get_localized_js_vars(); if ( $is_show_only_calendar ) { // Center calendar. ?>