ACF\Site_Health

Site_Health::log_cli_commandpublicACF 6.8

Logs the first-run timestamp of a WP-CLI command.

Stores an associative array under the event_cli_commands key in the site health option. Each entry maps a full command name (e.g. "acf json import") to the Unix timestamp when it was first executed. Subsequent calls for the same command are no-ops.

Method of the class: Site_Health{}

No Hooks.

Returns

true|false. True if a new entry was written, false if already recorded.

Usage

$Site_Health = new Site_Health();
$Site_Health->log_cli_command( $command ): bool;
$command(string) (required)
The full CLI command name (e.g. "acf json import").

Changelog

Since 6.8 Introduced.

Site_Health::log_cli_command() code ACF 6.8.8

public function log_cli_command( string $command ): bool {
	$site_health = $this->get_site_health();

	if ( ! isset( $site_health['event_cli_commands'] ) || ! is_array( $site_health['event_cli_commands'] ) ) {
		$site_health['event_cli_commands'] = array();
	}

	if ( isset( $site_health['event_cli_commands'][ $command ] ) ) {
		return false;
	}

	$time = time();

	$site_health['event_cli_commands'][ $command ] = $time;
	$site_health['last_updated']                   = $time;

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