Title: WP_Site_Health::get_test_scheduled_events
Published: May 7, 2019
Last modified: August 20, 2026

---

# WP_Site_Health::get_test_scheduled_events(): array

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#wp--skip-link--target)

Tests if scheduled events run as intended.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#description)󠁿

If scheduled events are not running, this may indicate something with WP_Cron is
not working as intended, or that there are orphaned events hanging around from older
code.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#return)󠁿

 array The test results.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#source)󠁿

    ```php
    public function get_test_scheduled_events() {
    	$result = array(
    		'label'       => __( 'Scheduled events are running' ),
    		'status'      => 'good',
    		'badge'       => array(
    			'label' => __( 'Performance' ),
    			'color' => 'blue',
    		),
    		'description' => sprintf(
    			'<p>%s</p>',
    			__( 'Scheduled events are what periodically looks for updates to plugins, themes and WordPress itself. It is also what makes sure scheduled posts are published on time. It may also be used by various plugins to make sure that planned actions are executed.' )
    		),
    		'actions'     => '',
    		'test'        => 'scheduled_events',
    	);

    	$this->wp_schedule_test_init();

    	if ( is_wp_error( $this->has_missed_cron() ) ) {
    		$result['status'] = 'critical';

    		$result['label'] = __( 'It was not possible to check your scheduled events' );

    		$result['description'] = sprintf(
    			'<p>%s</p>',
    			sprintf(
    				/* translators: %s: The error message returned while from the cron scheduler. */
    				__( 'While trying to test your site&#8217;s scheduled events, the following error was returned: %s' ),
    				$this->has_missed_cron()->get_error_message()
    			)
    		);
    	} elseif ( $this->has_missed_cron() ) {
    		$result['status'] = 'recommended';

    		$result['label'] = __( 'A scheduled event has failed' );

    		$result['description'] = sprintf(
    			'<p>%s</p>',
    			sprintf(
    				/* translators: %s: The name of the failed cron event. */
    				__( 'The scheduled event, %s, failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.' ),
    				$this->last_missed_cron
    			)
    		);
    	} elseif ( $this->has_late_cron() ) {
    		$result['status'] = 'recommended';

    		$result['label'] = __( 'A scheduled event is late' );

    		$result['description'] = sprintf(
    			'<p>%s</p>',
    			sprintf(
    				/* translators: %s: The name of the late cron event. */
    				__( 'The scheduled event, %s, is late to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.' ),
    				$this->last_late_cron
    			)
    		);
    	}

    	return $result;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-site-health.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/class-wp-site-health.php#L1667)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-site-health.php#L1667-L1727)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Site_Health::has_late_cron()](https://developer.wordpress.org/reference/classes/wp_site_health/has_late_cron/)`wp-admin/includes/class-wp-site-health.php` |

Checks if any scheduled tasks are late.

  | 
| [WP_Site_Health::wp_schedule_test_init()](https://developer.wordpress.org/reference/classes/wp_site_health/wp_schedule_test_init/)`wp-admin/includes/class-wp-site-health.php` |

Initiates the WP_Cron schedule test cases.

  | 
| [WP_Site_Health::has_missed_cron()](https://developer.wordpress.org/reference/classes/wp_site_health/has_missed_cron/)`wp-admin/includes/class-wp-site-health.php` |

Checks if any scheduled tasks have been missed.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_scheduled_events/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_site_health%2Fget_test_scheduled_events%2F)
before being able to contribute a note or feedback.