From 2b62a4e20abd0f8000834758b8997e8ac038e404 Mon Sep 17 00:00:00 2001 From: Tom McFarlin Date: Mon, 13 May 2013 08:43:08 -0400 Subject: [PATCH] Moving the activation hook calls outside of the class Fixes #42 --- plugin-boilerplate/class-plugin-boilerplate.php | 8 ++------ plugin-boilerplate/plugin-boilerplate.php | 5 +++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin-boilerplate/class-plugin-boilerplate.php b/plugin-boilerplate/class-plugin-boilerplate.php index 9754348..3a8ea2e 100644 --- a/plugin-boilerplate/class-plugin-boilerplate.php +++ b/plugin-boilerplate/class-plugin-boilerplate.php @@ -82,10 +82,6 @@ class PluginName { add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_scripts' ) ); - // Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively. - register_activation_hook( __FILE__, array( $this, 'activate' ) ); - register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); - /* * TODO: * @@ -108,7 +104,7 @@ class PluginName { * * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog */ - public function activate( $network_wide ) { + public static function activate( $network_wide ) { // TODO: Define activation functionality here } @@ -118,7 +114,7 @@ class PluginName { * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog * @since 1.0.0 */ - public function deactivate( $network_wide ) { + public static function deactivate( $network_wide ) { // TODO: Define deactivation functionality here } diff --git a/plugin-boilerplate/plugin-boilerplate.php b/plugin-boilerplate/plugin-boilerplate.php index e1374f9..7eaf541 100644 --- a/plugin-boilerplate/plugin-boilerplate.php +++ b/plugin-boilerplate/plugin-boilerplate.php @@ -48,5 +48,10 @@ if ( ! defined( 'PLUGIN_NAME_VERSION' ) ) { // TODO: replace `class-plugin-boilerplate.php` with the name of the actual plugin's class file require_once( plugin_dir_path( __FILE__ ) . 'class-plugin-boilerplate.php' ); +// Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively. +// TODO: replace PluginName with the name of the plugin defined in `class-plugin-boilerplate.php` +register_activation_hook( __FILE__, array( 'PluginName', 'activate' ) ); +register_deactivation_hook( __FILE__, array( 'PluginName', 'deactivate' ) ); + // TODO: replace PluginName with the name of the plugin defined in `class-plugin-boilerplate.php` PluginName::get_instance(); \ No newline at end of file