wp-cron callback function types in OOP plugin
-
So I’m writing a plugin where all the core functionality is OOP.
This works fine for hooks and actions where the function is actually an instance method:
global $wpdb; require_once('includes/category_subscriptions_class.php'); $cat_sub = new CategorySubscriptions($wpdb); register_activation_hook(__FILE__,array($cat_sub,'category_subscriptions_install')); add_action( 'edit_user_profile', array($cat_sub, 'show_profile_fields') );
But it seems like I have to actually add my cron callback functions directly into the global namespace if wordpress is going to be able to execute them.
I can’t pass in an instance or static method hook, it looks like I can only pass in a string and that’d mean I have to have the function live in the global namespace.
I understand why you can’t pass in an instance method hook – it’s not like you can serialize an instantiated object safely, especially one that changes. It would be nice to use a static method as a hook, though.
Thanks for your thoughts in advance – really, I just want to confirm whether or not a wp-cron callback function has to live in the global namespace or not. Thanks!
- The topic ‘wp-cron callback function types in OOP plugin’ is closed to new replies.