So I’m using the WordPress Plugin boilerplate and trying to remove a lite version of my plugin before going ahead with the activation of my new one. But for some reason this code simply does not execute. I have included an example below of what I am trying to do:
class Wp_Content_Calendar_Activator {
/**
* Short Description. (use period)
*
* Long Description.
*
* @since 1.0.0
*/
public static function activate() {
if( is_plugin_active('hello.php') ){
deactivate_plugins('hello.php');
}
}
}
1. The first parameter of
deactivate_plugins()
andis_plugin_active()
functions refers to the basename of a plugin – seeplugin_basename()
.The plugin basename is the path to the plugin file relative to the plugins directory.
So, if your plugin resides in
wp-content/plugins/hello/hello.php
, the plugin basename would behello/hello.php
.Example:
or
2. Make sure the
wp-admin/includes/plugin.php
file has been loaded. It is not always included.3. Terminate WordPress execution – see
wp_die()
.