ACF\Site_Health

Site_Health::update_site_health_datapublicACF 6.3

Stores debug data in the ACF site health option.

Method of the class: Site_Health{}

No Hooks.

Returns

true|false.

Usage

$Site_Health = new Site_Health();
$Site_Health->update_site_health_data( $data ): bool;
$data(array)
Data to update with (optional).
Default: array()

Changelog

Since 6.3 Introduced.

Site_Health::update_site_health_data() code ACF 6.8.8

public function update_site_health_data( array $data = array() ): bool {
	if ( wp_doing_cron() ) {
		// Bootstrap wp-admin, as WP_Cron doesn't do this for us.
		require_once trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php';
	}

	$site_health = $this->get_site_health();
	$values      = ! empty( $data ) ? $data : $this->get_site_health_values();
	$updated     = array();

	if ( ! empty( $values ) ) {
		foreach ( $values as $key => $value ) {
			$updated[ $key ] = $value['debug'] ?? $value['value'];
		}
	}

	foreach ( $site_health as $key => $value ) {
		// Preserve event_* keys for activation tracking.
		if ( 'event_' === substr( $key, 0, 6 ) ) {
			$updated[ $key ] = $value;
			continue;
		}

		// Preserve AI usage data.
		if ( 'ai_usage' === $key ) {
			$updated[ $key ] = $value;
			continue;
		}
	}

	$this->maybe_log_first_registered_block( $site_health, $updated );

	$updated['last_updated'] = time();

	return $this->update_site_health( $updated );
}