Changeset 44693 for trunk/src/wp-includes/cron.php
- Timestamp:
- 01/23/2019 11:07:39 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/cron.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cron.php
r44483 r44693 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 … … 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. … … 515 511 * Although not passed to a callback, these arguments are used to uniquely identify the 516 512 * event. 517 * @param int $timestamp Unix timestamp (UTC) of theevent.513 * @param int|null $timestamp Unix timestamp (UTC) of the event. Null to retrieve next scheduled event. 518 514 */ 519 515 $pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp ); … … 522 518 } 523 519 520 if ( null !== $timestamp && ! is_numeric( $timestamp ) ) { 521 return false; 522 } 523 524 524 $crons = _get_cron_array(); 525 $key = md5( serialize( $args ) ); 526 527 if ( ! $timestamp || ! isset( $crons[ $timestamp ] ) ) { 528 // No such event. 529 return false; 530 } 531 532 if ( ! isset( $crons[ $timestamp ][ $hook ] ) || ! isset( $crons[ $timestamp ][ $hook ][ $key ] ) ) { 525 if ( empty( $crons ) ) { 526 return false; 527 } 528 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 } … … 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. … … 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 } 593 } 594 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 ); 575 $next_event = wp_get_scheduled_event( $hook, $args ); 576 if ( ! $next_event ) { 577 return false; 578 } 579 580 return $next_event->timestamp; 605 581 } 606 582
Note: See TracChangeset
for help on using the changeset viewer.