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 ?

Read more here:: How to stop activation addon if the main plugin is not activated

Leave a Reply

Your email address will not be published. Required fields are marked *