mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2024-12-22 11:53:53 +02:00
Create functions for activation and deactivation hooks.
Moving the activation and deactivation hooks into its own functions, makes so we dont have to include class-plugin-name-deactivator and class-plugin-name-activator on every page load.
This commit is contained in:
parent
3c47bc0b5a
commit
e015b9cd7c
1 changed files with 12 additions and 7 deletions
|
@ -32,19 +32,24 @@ if ( ! defined( 'WPINC' ) ) {
|
|||
|
||||
/**
|
||||
* The code that runs during plugin activation.
|
||||
* This action is documented in includes/class-plugin-name-activator.php
|
||||
*/
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-activator.php';
|
||||
function activate_plugin_name() {
|
||||
require_once __DIR__ . 'includes/class-plugin-name-activator.php';
|
||||
Plugin_Name_Activator::activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* The code that runs during plugin deactivation.
|
||||
* This action is documented in includes/class-plugin-name-deactivator.php
|
||||
*/
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin-name-deactivator.php';
|
||||
function deactivate_plugin_name() {
|
||||
require_once __DIR__ . 'includes/class-plugin-name-deactivator.php';
|
||||
Plugin_Name_Deactivator::deactivate();
|
||||
}
|
||||
|
||||
/** This action is documented in includes/class-plugin-name-activator.php */
|
||||
register_activation_hook( __FILE__, array( 'Plugin_Name_Activator', 'activate' ) );
|
||||
|
||||
/** This action is documented in includes/class-plugin-name-deactivator.php */
|
||||
register_deactivation_hook( __FILE__, array( 'Plugin_Name_Deactivator', 'deactivate' ) );
|
||||
register_activation_hook( __FILE__, 'activate_plugin_name' );
|
||||
register_deactivation_hook( __FILE__, 'deactivate_plugin_name' );
|
||||
|
||||
/**
|
||||
* The core plugin class that is used to define internationalization,
|
||||
|
|
Loading…
Reference in a new issue