I would like to create a common abstract class to use for every WordPress plugin that I develop. As a part of the class' initiation process, I would like to fire the activation hook which calls an abstract method that will be defined by the child's class.
For example:
abstract class AbstractPlugin extends WP_Plugin {
public function init() {
register_activation_hook( __FILE__, array( $this, 'on_activation' ) );
register_deactivation_hook( __FILE__, array( $this, 'on_deactivation' ) );
}
public abstract function on_activation();
public abstract function on_deactivation();
}
However, the first argument in register_activation_hook
should be the path to the file in which the child's class is defined, which is unknown, and even if it is known, it doesn't work.
Is there any way to get around this issue?