dragonwing at dragonu.net
Sun Sep 23 10:27:42 GMT 2007
From what I've read of the WP Cron code, you want to use
wp_clear_scheduled_hook unless you want to remove all instances of the
scheduled event. wp_unschedule_event is good if you screw up and
constantly add the same event over and over again. It is better to use
wp_unschedule_event, than iterating over wp_clear_scheduled_hook. At
least in my opinion with the very little I've used of it.
I would agree that it would be useful to know that you have to create a
hook before using some of the functions. The only way I was finally able
to get my plugin to work was finding some awesome guy online that wrote
about the troubles and journey he had with trying to schedule an event.
> Clearly these need to be documented, since everybody gets them wrong...
> If you schedule any event, even a recurring one, wp_unschedule_event
> will get rid of it. Completely. Even recurrances.
> If you schedule the same event twice, wp_clear_scheduled_hook will get
> rid of both of them. It's also somewhat simpler to use (no need to get
> timestamp of next scheduled event).
> This is because a recurring event only actually exists once: The next
> time. When it runs, it's rescheduled for the next event just before it
> actually executes. That's how recurring events work.
> In short, you probably always want to use wp_clear_scheduled_hook to
> get rid of an event. The only reason you ever want to use
> wp_unschedule_event is if you have a complex set of events and want to
> be certain that you get rid of get the exact one you want to get rid
> On 9/22/07, Matt <speedboxer at gmail.com> wrote:
>> On 9/22/07, Omry Yadan <omry at yadan.net> wrote:
>>> without know ANYTHING about the API, I am guessing that you need to use
>>> wp_unschedule_event, and that
>>> wp_clear_scheduled_hook is used internally to notify listeners of
>>> unschedule events.
>> I tried it out by checking if wp_next_scheduled_event was the cron. It turns
>> out that you should you wp_clear_scheduled_hook if you want to completely
>> get rid of a recursive cron. I think wp_unschedule_event just unschedules
>> the next time it's supposed to run, but it will continue to run after that
>> one that's been "skipped".
>> Matt (speedboxer at gmail.com)
>> http://mattsblog.ca/ | http://livemp.net/
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers