| 1 |
Usage: Instantiate the onboarding as follows: |
| 2 |
|
| 3 |
add_action( 'plugins_loaded', [ $this, 'setup_onboarding' ] ); |
| 4 |
|
| 5 |
public function setup_onboarding(): void { |
| 6 |
$onboarding = new Onboarding(); |
| 7 |
if ( $onboarding::is_onboarding_active( 'burst' ) ) { |
| 8 |
$onboarding->init(); |
| 9 |
} |
| 10 |
} |
| 11 |
|
| 12 |
When a user activated the plugin, or you want to start the onboarding process, you set the optioin update_option( "{$prefix}_start_onboarding", true) |
| 13 |
This option is deleted when the scripts are enqueued, so the onboarding will only run once. |
| 14 |
It might be a good idea to use a transient for any redirect, so in case a plugin is automatically installed, the transient expires after a few minutes. |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
Usually you would want to add a redirect to the settings page as well. |
| 19 |
|
| 20 |
Onboarding_steps should return an array of steps, each step should be an array with the following keys: |
| 21 |
[ |
| 22 |
'id' => 'intro', |
| 23 |
'title' => __( 'Take a minute to configure Burst!', 'burst-statistics' ), |
| 24 |
'subtitle' => __( "In a few steps we'll help you select the best options, and verify if statistics have started tracking.", 'burst-statistics' ), |
| 25 |
'button' => [ |
| 26 |
'id' => 'start', |
| 27 |
'label' => __( 'Start onboarding', 'burst-statistics' ), |
| 28 |
], |
| 29 |
], |
| 30 |
|
| 31 |
The button key can also have an action key. The action key should match an endpoint. |