Make WordPress Core


Ignore:
Timestamp:
01/08/2019 09:48:07 PM (6 years ago)
Author:
peterwilsoncc
Message:

Cron API: Add function and filter to return ready cron jobs.

Add the function wp_get_ready_cron_jobs() to return a modified version of the cron array limited to jobs ready to be run, ie with a timestamp of time() or earlier.

The new function includes the filter pre_get_ready_cron_jobs to allow for custom cron storage systems. This rounds out the functionality added in #32656.

Props Pento for code review.
Fixes #45797.

File:
1 edited

Legend:

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

    r42343 r44483  
    6767}
    6868
    69 if ( false === $crons = _get_cron_array() ) {
     69$crons = wp_get_ready_cron_jobs();
     70if ( empty( $crons ) ) {
    7071    die();
    7172}
    72 
    73 $keys     = array_keys( $crons );
    74 $gmt_time = microtime( true );
    75 
    76 if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
    77     die();
    78 }
    79 
    8073
    8174// The cron lock: a unix timestamp from when the cron was spawned.
Note: See TracChangeset for help on using the changeset viewer.