[wp-trac] [WordPress Trac] #35491: Add a function to check whether a hook is scheduled

WordPress Trac noreply at wordpress.org
Sun Jan 17 16:29:25 UTC 2016


#35491: Add a function to check whether a hook is scheduled
--------------------------------------+------------------
 Reporter:  dlh                       |       Owner:
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  4.5
Component:  Cron API                  |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------

Comment (by dlh):

 Thanks @swissspidy. With [attachment:wp_next_scheduled.diff]: If I
 scheduled `'my_hook'` twice, one with `'foo'` for `$args` and one with
 `false`, and the `'foo'` event was scheduled to occur next, wouldn't
 `wp_next_scheduled( 'my_hook', false )` return the wrong timestamp?

 That aside, to me, passing `false` to `wp_next_scheduled()` adds
 ambiguity. How can I tell whether the author wants to know whether the
 hook is scheduled at all or whether it was scheduled with `$args = false`?

 I could see how returning the timestamp would help in some cases. As you
 noted, though, that makes it tough to distinguish between
 `wp_next_scheduled()`. I could also see a developer thinking the function
 returned all the hook's timestamps, not just the next one. So I still lean
 towards returning `bool`, but I'm open to other ideas.

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


More information about the wp-trac mailing list