PluginProbe
Hello Plus / trunk
Hello Plus vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / admin / classes / menu / pages / setup-wizard.php

setup-wizard.php in Hello Plus trunk, at modules/admin/classes/menu/pages/setup-wizard.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HelloPlus\Modules\Admin\Classes\Menu\Pages;
4
5 use HelloPlus\Modules\Admin\Module;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 class Setup_Wizard {
12
13 const SETUP_WIZARD_PAGE_SLUG = 'hello-plus-setup-wizard';
14
15 public static function has_site_wizard_been_completed(): bool {
16 static $is_setup_wizard_completed = null;
17
18 if ( ! class_exists( '\Elementor\App\Modules\ImportExport\Processes\Revert' ) ) {
19 return false;
20 }
21
22 if ( ! is_null( $is_setup_wizard_completed ) ) {
23 return $is_setup_wizard_completed;
24 }
25
26 $sessions = \Elementor\App\Modules\ImportExport\Processes\Revert::get_import_sessions();
27
28 if ( ! $sessions ) {
29 return false;
30 }
31
32 $last_session = end( $sessions );
33 $kit_name = $last_session['kit_name'];
34
35 try {
36 /**
37 * @var \HelloPlus\Modules\Admin\Classes\Rest\Onboarding_Settings $onboarding_rest
38 */
39 $onboarding_rest = Module::instance()->get_component( 'Api_Controller' )->get_endpoint( 'onboarding-settings' );
40
41 $kits = $onboarding_rest->get_kits();
42
43 $kit = array_filter( $kits, function ( $k ) use ( $kit_name ) {
44 return $k['manifest']['name'] === $kit_name;
45 } );
46
47 $is_setup_wizard_completed = ! empty( $kit );
48 } catch ( \Exception $e ) {
49 $is_setup_wizard_completed = false;
50 }
51
52 return $is_setup_wizard_completed;
53 }
54
55 public function register_setup_wizard_page( $parent_slug ): void {
56 add_submenu_page(
57 $parent_slug,
58 __( 'Setup Wizard', 'hello-plus' ),
59 __( 'Setup Wizard', 'hello-plus' ),
60 'manage_options',
61 self::SETUP_WIZARD_PAGE_SLUG,
62 [ $this, 'render_setup_wizard_page' ]
63 );
64 }
65
66 public function render_setup_wizard_page(): void {
67 echo '<div id="ehp-admin-onboarding"></div>';
68 }
69 }
70