Title: WP_Site_Health::maybe_create_scheduled_event
Published: April 1, 2020
Last modified: August 20, 2026

---

# WP_Site_Health::maybe_create_scheduled_event()

## In this article

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

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

Creates a weekly cron event, if one does not already exist.

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

    ```php
    public function maybe_create_scheduled_event() {
    	if ( ! wp_next_scheduled( 'wp_site_health_scheduled_check' ) && ! wp_installing() ) {
    		wp_schedule_event( time() + DAY_IN_SECONDS, 'weekly', 'wp_site_health_scheduled_check' );
    	}
    }
    ```

[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#L3343)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/class-wp-site-health.php#L3343-L3347)

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

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

Checks or sets whether WordPress is in “installation” mode.

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

Retrieves the timestamp of the next scheduled event for the given hook.

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

Schedules a recurring event.

  |

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

[WP_Site_Health](https://developer.wordpress.org/reference/classes/wp_site_health/) constructor.

  |

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

| Version | Description | 
| [5.4.0](https://developer.wordpress.org/reference/since/5.4.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%2Fmaybe_create_scheduled_event%2F)
before being able to contribute a note or feedback.