[wp-trac] [WordPress Trac] #27087: wp_schedule_event will not accept class hook
WordPress Trac
noreply at wordpress.org
Mon Feb 10 20:00:36 UTC 2014
#27087: wp_schedule_event will not accept class hook
--------------------------+-----------------------------
Reporter: jonshipman | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Cron API | Version: 3.8.1
Severity: normal | Resolution: invalid
Keywords: | Focuses: administration
--------------------------+-----------------------------
Changes (by TobiasBg):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Old description:
> wp_schedule_event will not accept array() for the hook (must be string).
> As such, wp_schedule_event( time(), 'daily', array($this,'hook') ); will
> not work, however, moving the hook method outside of the class will work
> as the $hook is no longer an array.
New description:
`wp_schedule_event` will not accept array() for the hook (must be string).
As such, `wp_schedule_event( time(), 'daily', array($this,'hook') );` will
not work, however, moving the hook method outside of the class will work
as the `$hook` is no longer an array.
--
Comment:
You are mixing up "hook" and "callback" here.
`wp_schedule_event` indeed requires a string as the "hook", in the sense
of plugin action hook. You can then attach a "callback" (usually a
function or class method) to that action hook:
{{{
wp_schedule_event( time(), 'daily', 'my_unique_plugin_event_hook' );
add_action( 'my_unique_plugin_event_hook', array( $this,'hook' ) );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27087#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list