Make WordPress Core


Ignore:
Timestamp:
02/14/2025 07:35:51 PM (4 months ago)
Author:
johnbillion
Message:

Cron API: Introduce the wp_next_scheduled filter which allows overriding the timestamp for the next scheduled event for the given hook.

This change also standardises some descriptions of the timestamp field used in various functions.

Props infosatech, peterwilsoncc

Fixes #52655

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cron.php

    r58975 r59824  
    316316 * Reschedules a recurring event.
    317317 *
    318  * Mainly for internal use, this takes the UTC timestamp of a previously run
     318 * Mainly for internal use, this takes the Unix timestamp (UTC) of a previously run
    319319 * recurring event and reschedules it for its next run.
    320320 *
     
    486486     *
    487487     * @param null|bool|WP_Error $pre       Value to return instead. Default null to continue unscheduling the event.
    488      * @param int                $timestamp Timestamp for when to run the event.
     488     * @param int                $timestamp Unix timestamp (UTC) for when to run the event.
    489489     * @param string             $hook      Action hook, the execution of which will be unscheduled.
    490490     * @param array              $args      Arguments to pass to the hook's callback function.
     
    819819
    820820/**
    821  * Retrieves the next timestamp for an event.
     821 * Retrieves the timestamp of the next scheduled event for the given hook.
    822822 *
    823823 * @since 2.1.0
     
    828828 *                     event, so they should be the same as those used when originally scheduling the event.
    829829 *                     Default empty array.
    830  * @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
     830 * @return int|false The Unix timestamp (UTC) of the next time the event will occur. False if the event doesn't exist.
    831831 */
    832832function wp_next_scheduled( $hook, $args = array() ) {
     
    837837    }
    838838
    839     return $next_event->timestamp;
     839    /**
     840     * Filters the timestamp of the next scheduled event for the given hook.
     841     *
     842     * @since 6.8.0
     843     *
     844     * @param int    $timestamp  Unix timestamp (UTC) for when to next run the event.
     845     * @param object $next_event {
     846     *     An object containing an event's data.
     847     *
     848     *     @type string $hook      Action hook of the event.
     849     *     @type int    $timestamp Unix timestamp (UTC) for when to next run the event.
     850     *     @type string $schedule  How often the event should subsequently recur.
     851     *     @type array  $args      Array containing each separate argument to pass to the hook
     852     *                             callback function.
     853     *     @type int    $interval  Optional. The interval time in seconds for the schedule. Only
     854     *                             present for recurring events.
     855     * }
     856     * @param array  $args       Array containing each separate argument to pass to the hook
     857     *                           callback function.
     858     */
     859    return apply_filters( 'wp_next_scheduled', $next_event->timestamp, $next_event, $hook, $args );
    840860}
    841861
     
    930950     *     }
    931951     * }
    932      * @param string $doing_wp_cron The unix timestamp of the cron lock.
     952     * @param string $doing_wp_cron The Unix timestamp (UTC) of the cron lock.
    933953     */
    934954    $cron_request = apply_filters(
Note: See TracChangeset for help on using the changeset viewer.