How to stop activation addon if the main plugin is not activated
I´m writing an addon. I would like in the install function to stop the activation if the main plugin is inactive.
class MyAddon {
public function __construct(){
register_activation_hook( __FILE__, array( $this, 'install' ) );
}
public function install(){
if ( is_plugin_inactive( 'MainPlugin.php' ) ){
//The addon has to be inactive
// Notice for admin to prevent to active the main plugin before.
}
}
}
How can I do this ?
Topic deactivated-plugin installation plugin-development Wordpress
Category Web