diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php
index c6bb637092..51294ec824 100644
|
a
|
b
|
function wp_unschedule_hook( $hook ) { |
| 481 | 481 | /** |
| 482 | 482 | * Retrieve a scheduled event. |
| 483 | 483 | * |
| 484 | | * Retrieve the full event object for a given event. |
| | 484 | * Retrieve the full event object for a given event, if no timestamp is specified the next |
| | 485 | * scheduled event is returned. |
| 485 | 486 | * |
| 486 | 487 | * @since 5.1.0 |
| 487 | 488 | * |
| … |
… |
function wp_unschedule_hook( $hook ) { |
| 493 | 494 | * @return bool|object The event object. False if the event does not exist. |
| 494 | 495 | */ |
| 495 | 496 | function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { |
| 496 | | if ( ! $timestamp ) { |
| 497 | | // Get the next scheduled event. |
| 498 | | $timestamp = wp_next_scheduled( $hook, $args ); |
| 499 | | } |
| 500 | | |
| 501 | 497 | /** |
| 502 | 498 | * Filter to preflight or hijack retrieving a scheduled event. |
| 503 | 499 | * |
| … |
… |
function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { |
| 521 | 517 | return $pre; |
| 522 | 518 | } |
| 523 | 519 | |
| 524 | | $crons = _get_cron_array(); |
| 525 | | $key = md5( serialize( $args ) ); |
| | 520 | if ( null !== $timestamp & ! is_numeric( $timestamp ) ) { |
| | 521 | return false; |
| | 522 | } |
| 526 | 523 | |
| 527 | | if ( ! $timestamp || ! isset( $crons[ $timestamp ] ) ) { |
| 528 | | // No such event. |
| | 524 | $crons = _get_cron_array(); |
| | 525 | if ( empty( $crons ) ) { |
| 529 | 526 | return false; |
| 530 | 527 | } |
| 531 | 528 | |
| 532 | | if ( ! isset( $crons[ $timestamp ][ $hook ] ) || ! isset( $crons[ $timestamp ][ $hook ][ $key ] ) ) { |
| | 529 | $key = md5( serialize( $args ) ); |
| | 530 | |
| | 531 | if ( ! $timestamp ) { |
| | 532 | // Get next event. |
| | 533 | $next = false; |
| | 534 | foreach ( $crons as $timestamp => $cron ) { |
| | 535 | if ( isset( $cron[ $hook ][ $key ] ) ) { |
| | 536 | $next = $timestamp; |
| | 537 | break; |
| | 538 | } |
| | 539 | } |
| | 540 | if ( ! $next ) { |
| | 541 | return false; |
| | 542 | } |
| | 543 | |
| | 544 | $timestamp = $next; |
| | 545 | } elseif ( ! isset( $crons[ $timestamp ][ $hook ][ $key ] ) ) { |
| 533 | 546 | return false; |
| 534 | 547 | } |
| 535 | 548 | |
| … |
… |
function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { |
| 551 | 564 | * Retrieve the next timestamp for an event. |
| 552 | 565 | * |
| 553 | 566 | * @since 2.1.0 |
| 554 | | * @since 5.1.0 {@see 'pre_next_scheduled'} and {@see 'next_scheduled'} filters added. |
| 555 | 567 | * |
| 556 | 568 | * @param string $hook Action hook of the event. |
| 557 | 569 | * @param array $args Optional. Array containing each separate argument to pass to the hook's callback function. |
| … |
… |
function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) { |
| 560 | 572 | * @return false|int The Unix timestamp of the next time the event will occur. False if the event doesn't exist. |
| 561 | 573 | */ |
| 562 | 574 | function wp_next_scheduled( $hook, $args = array() ) { |
| 563 | | /** |
| 564 | | * Filter to preflight or hijack retrieving the next scheduled event timestamp. |
| 565 | | * |
| 566 | | * Returning a non-null value will short-circuit the normal retrieval |
| 567 | | * process, causing the function to return the filtered value instead. |
| 568 | | * |
| 569 | | * Pass the timestamp of the next event if it exists, false if not. |
| 570 | | * |
| 571 | | * @since 5.1.0 |
| 572 | | * |
| 573 | | * @param null|bool $pre Value to return instead. Default null to continue unscheduling the event. |
| 574 | | * @param string $hook Action hook of the event. |
| 575 | | * @param array $args Arguments to pass to the hook's callback function. |
| 576 | | */ |
| 577 | | $pre = apply_filters( 'pre_next_scheduled', null, $hook, $args ); |
| 578 | | if ( null !== $pre ) { |
| 579 | | return $pre; |
| 580 | | } |
| 581 | | |
| 582 | | $crons = _get_cron_array(); |
| 583 | | $key = md5( serialize( $args ) ); |
| 584 | | $next = false; |
| 585 | | |
| 586 | | if ( ! empty( $crons ) ) { |
| 587 | | foreach ( $crons as $timestamp => $cron ) { |
| 588 | | if ( isset( $cron[ $hook ][ $key ] ) ) { |
| 589 | | $next = $timestamp; |
| 590 | | break; |
| 591 | | } |
| 592 | | } |
| | 575 | $next_event = wp_get_scheduled_event( $hook, $args ); |
| | 576 | if ( ! $next_event ) { |
| | 577 | return false; |
| 593 | 578 | } |
| 594 | 579 | |
| 595 | | /** |
| 596 | | * Filter the next scheduled event timestamp. |
| 597 | | * |
| 598 | | * @since 5.1.0 |
| 599 | | * |
| 600 | | * @param int|bool $next The UNIX timestamp when the scheduled event will next occur, or false if not found. |
| 601 | | * @param string $hook Action hook to execute when cron is run. |
| 602 | | * @param array $args Arguments to be passed to the callback function. Used for deduplicating events. |
| 603 | | */ |
| 604 | | return apply_filters( 'next_scheduled', $next, $hook, $args ); |
| | 580 | return $next_event->timestamp; |
| 605 | 581 | } |
| 606 | 582 | |
| 607 | 583 | /** |