WP_Site_Health::has_missed_cron() WordPress Method

The WP_Site_Health::has_missed_cron() function is used to check if the site has missed its scheduled cron job. This can be used to help troubleshoot issues with the site not running properly.

WP_Site_Health::has_missed_cron() #

Check if any scheduled tasks have been missed.


Description

Returns a boolean value of true if a scheduled task has been missed and ends processing.

If the list of crons is an instance of WP_Error, returns the instance instead of a boolean value.


Top ↑

Return

(bool|WP_Error) True if a cron was missed, false if not. WP_Error if the cron is set to that.


Top ↑

Source

File: wp-admin/includes/class-wp-site-health.php

	public function has_missed_cron() {
		if ( is_wp_error( $this->crons ) ) {
			return $this->crons;
		}

		foreach ( $this->crons as $id => $cron ) {
			if ( ( $cron->time - time() ) < $this->timeout_missed_cron ) {
				$this->last_missed_cron = $cron->hook;
				return true;
			}
		}

		return false;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.