You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Config.php
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@
29
29
30
30
usestdClass;
31
31
useWP_Error;
32
+
useException;
32
33
useTheWebSolver\Core\Admin\Onboarding\Wizard;
33
34
useTheWebSolver\Core\Admin\Onboarding\Form;
34
35
@@ -85,11 +86,22 @@ final class Config {
85
86
public$form;
86
87
87
88
/**
88
-
* Initializes onboarding wizard.
89
+
* Onboarding instance.
90
+
*
91
+
* @var \TheWebSolver\Core\Admin\Onboarding\Wizard
89
92
*
90
-
* @return object The external child-class onboarding instance if valid, `Onboarding_Wizard` if not.
93
+
* @since 1.1
94
+
*/
95
+
public$onboarding;
96
+
97
+
/**
98
+
* Initializes onboarding wizard.
91
99
*
100
+
* @throws Exception If `Config.php` and `Includes/Wizard.php`
101
+
* file namespace didn't match.
92
102
* @since 1.0
103
+
* @since 1.1 Throws Exception and WP dies.
104
+
* @since 1.1 Sets onboarding property instead of returning it.
93
105
*/
94
106
publicfunctiononboarding() {
95
107
// Prepare and instantiate external child-class, if valid.
@@ -115,13 +127,21 @@ public function onboarding() {
115
127
} else {
116
128
// New shiny wizard creation from internal child-class.
117
129
include_once__DIR__ . '/Includes/Wizard.php';
118
-
$onboarding = newOnboarding_Wizard();
119
-
$onboarding->set_config( $this );
130
+
try {
131
+
if ( class_exists( __NAMESPACE__ . '\\Onboarding_Wizard' ) ) {
132
+
$onboarding = newOnboarding_Wizard();
133
+
$onboarding->set_config( $this );
134
+
} else {
135
+
thrownewException( '<p>Namespace of <b>Config</b> and <b>Wizard</b> class does not match.</p><hr>Set same namespace used on <b>Config.php</b> file in <b>Includes/Wizard.php file</b> to instantiate <code><b><em>Onboarding_Wizard</em></b></code> class.' );
0 commit comments