-
Notifications
You must be signed in to change notification settings - Fork 2
Prepare core files
hsehszroc edited this page Aug 16, 2021
·
1 revision
Two core files Config.php and Wizard.php must be updated before the plugin activation.
- Namespace must be replaced with your own plugin namespace.
- Property
Config::$prefix
must be unique for your plugin. If you have implemented codes present in the file tws-admin-onboarding.php in the same way, there there is no need to make changes here. It is recommended to use underscore(_
) as a separator with all lowercase letters.
Do not change the prefix once set. All options, hooks, etc are dependent on this prefix. So, changes made to prefix once set will break your codes and the saved data of the onboarding steps.
This is the default/example onboarding wizard child class that provides its own set of configurations for the onboarding page. Alternatively, you can create your own child class file and pass it to the config instance. The passed child class will be used and the Wizard.php file will be ignored. In order to do so, when instantiating config, pass other parameters as shown below:
// This is the modified version of "tws-admin-onboarding.php" file on line 95-104 to use your own wizard child class:
private function config() {
// Onboarding config file path.
include_once __DIR__ . '/Config.php';
$config = array( '\\' . __NAMESPACE__ . '\\Config', 'get' ); // Beware of the namespace here.
// Only call config if it is on the same namespace.
if ( is_callable( $config ) ) {
$this->config = call_user_func( $config, $this->prefix, 'manage_options', 'path/to/child-class.php', 'Child_ClassName' );
}
}
If you want to use Wizard.php file, then make appropriate changes.
- Namespace must be replaced with your own plugin namespace.
- Method
Onboarding_Wizard::set_title()
will set the onboarding page title. - Method
Onboarding_Wizard::set_logo()
will set the onboarding page logo. - Method
Onboarding_Wizard::set_steps()
will generate onboarding steps. Follow the same pattern to add/edit the onboarding steps. - Methods
Onboarding_Wizard::text_checkbox_view
andOnboarding_Wizard::radio_select_form_view
, displays respective steps field data. Follow the same pattern to add more fields to the step. - Methods
Onboarding_Wizard::text_checkbox_save
andOnboarding_Wizard::radio_select_form_save
saves respective steps field data. Follow the same pattern to save current step fields data. - Method
Onboarding_Wizard::set_dependency()
will set the WordPress plugin as a required plugin for your plugin. For eg. WooCommerce is needed for your plugin to work. It will be displayed as an install option on the onboarding introduction page. If not needed, delete this method. For example, screenshot showing Show Hooks plugin as dependency plugin: - Method
Onboarding_Wizard::set_recommended_plugins()
will set the WordPress plugin as recommended plugins. You can provide your own set of recommended plugins here and they will be installed automatically. If not needed, delete this method. For example on how it looks, screenshot showing 5 recommended plugins (some already active, other enabled for installation):