So the ‘activate_plugin’ was a typo in the question. But even so, as a friendly reminder (for all of us), activate_plugin()
is an existing function in WordPress. And you should use unique prefix in your custom functions (that are defined in the global scope):
function my_plugin_activate_plugin() {
...
}
register_activation_hook( __FILE__, 'my_plugin_activate_plugin' );
The Problem and Its Solution
The error/warning in the logs which says function 'activate_booker' not found or invalid function name
happens because you’re using a namespace in your file and you failed to properly reference to the callback function in your namespace:
// Incorrect - These are referencing to global functions.
register_activation_hook( __FILE__, 'activate_booker' );
register_deactivation_hook( __FILE__, 'deactivate_booker' );
// Correct syntax when referencing to namespace functions.
register_activation_hook( __FILE__, 'Booker\activate_booker' );
register_deactivation_hook( __FILE__, 'Booker\deactivate_booker' );
// Or use the __NAMESPACE__ constant.
register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_booker' );
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_booker' );
Note though, unless a fatal error was encountered, the plugin would still be activated/deactivated; it’s just that the activation/deactivation callback wouldn’t be called.
And here’s a good article which talks about using PHP namespaces in WordPress.