Answer the question
In order to leave comments, you need to log in
Worpdress: register_activation_hook not seeing function inside class?
I started my attempts to write plugins in the OOP style in WP, but immediately ran into a problem - I can't call the function of the same class in the register_activation_hook in the constructor of the initiating class.
Here's what I'm trying to do:
class ModulesInit {
public function __construct() {
register_activation_hook( __FILE__, array( $this, 'modules_activate' ) );
}
private function modules_activate) {
die('ok');
}
}
It's not clear at all, I read about calls from the class, and as I understand it, everything should work when called from the class - register_activation_hook( __FILE__, array( $this, 'YOUR_METHOD_NAME' ) ); but no(
Everything works in the constructor, but the hook does not see the function. Tell me what am I doing wrong?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question