I have an question about register_activation_hook in construct.
I have read, that this should be possible, but I don't know, currently nothing will be written to the error_log (for debugging).
Look here, the author say it should work http://www.plulz.com/how-to-create-a-plugin-for-wordpress
Here's my code
<?php
abstract class LW_Capability{
const NAME = 'Capability';
public function __construct(){
register_activation_hook(
__FILE__,
array(
$this,
'activate'
)
);
register_deactivation_hook(
__FILE__,
array(
$this,
'deactivate'
)
);
}
public function activate(){
error_log('LW_Capability->activate');
}
public function deactivate(){
error_log('LW_Capability->deactivate');
}
}
class CapabilityEditRessource extends LW_Capability{
const NAME = 'EditRessource';
}
?>
What do I do wrong? If I add an "die('parent')" to the LW_Capability, it will die. The Plugin can't be activated then (WP Blocks because of output).
Anyone here who does somthing similar?
Would be happy to hear from you.
Regards, Oli
register_activation_hook(
__FILE__,
array(
$this,
'activate'
)
);
register_deactivation_hook(
__FILE__,
array(
$this,
'deactivate'
)
);
could just be used in the main-file of the plugin ^^
I modifyed it to
register_activation_hook(
__FILE__,
array(
$MyPluginInstance,
'activate'
)
);
register_deactivation_hook(
__FILE__,
array(
$MyPluginInstance,
'deactivate'
)
);
And this functions calls manually the register / unregister-functions of the capability-class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With