07-26-2023, 06:28 PM
A common way to assign the register_activation_hook is using a static method of a class. This ensures that your plugin activation function name won't collide with other plugins.
class Foo_Plugin
{
public static function plugin_activation() {
// activation logic
}
}
This function needs to be public and not private. A mistake is easily made though, so this could be a reason for your problems when getting this kind of error.
You would then register the activation with this code in the main plugin file.
register_activation_hook( __FILE__, array( 'Foo_Plugin', 'plugin_activation' ) );
class Foo_Plugin
{
public static function plugin_activation() {
// activation logic
}
}
This function needs to be public and not private. A mistake is easily made though, so this could be a reason for your problems when getting this kind of error.
You would then register the activation with this code in the main plugin file.
register_activation_hook( __FILE__, array( 'Foo_Plugin', 'plugin_activation' ) );