[wp-trac] [WordPress Trac] #41095: wp_schedule_single_event should support any callable

WordPress Trac noreply at wordpress.org
Mon Jun 19 06:32:49 UTC 2017


#41095: wp_schedule_single_event should support any callable
-----------------------------+----------------------
 Reporter:  dan.rossiter     |       Owner:
     Type:  feature request  |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  Cron API         |     Version:
 Severity:  normal           |  Resolution:  invalid
 Keywords:                   |     Focuses:
-----------------------------+----------------------
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 This is a remarkably common misconception of how the CRON system actually
 works, but this is supported already.

 `wp_schedule_single_event()` does not accept a callable at all, it accept
 an action name. Often the hook specified is the same as the function being
 called, which doesn't help people realise what's actually being specified.

 `wp_schedule_single_event( time() + 3600, 'my_plugin_func' );` does not
 work, it doesn't do anything without an additional `add_action()`.

 It's used like this:
 {{{
 wp_schedule_single_event( time() + 3600, 'my_plugin_function_hook_name',
 array( $arg1, $arg2, $arg3) );

 add_action( 'my_plugin_function_hook_name', function( $arg1, $arg2, $arg3
 ) {
     // I'm running in a CRON request!
 }, 10, 3 );

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41095#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list