Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCEmailScratchpadRefresher::was_never_edited │ private │ WC 1.0

Check whether an unpublished email post was never edited by the user.

Prefers the source hash stamped at creation and refresh (content untouched when it still matches); the timestamp fallback only applies to posts without a valid hash, e.g. stray unpublished posts created outside the lazy-creation flow.

Method of the class: WCEmailScratchpadRefresher{}

No Hooks.

Returns

bool. True when the post content was never edited.

Usage

// private - for code of main (parent) class only
$result = $this->was_never_edited( $post ): bool;
$post(WP_Post) (required)
The post to check.

WCEmailScratchpadRefresher::was_never_edited() code WC 11.1.2

private function was_never_edited( \WP_Post $post ): bool {
	$stored_hash = get_post_meta( $post->ID, WCEmailTemplateDivergenceDetector::SOURCE_HASH_META_KEY, true );
	if ( is_string( $stored_hash ) && 1 === preg_match( '/^[0-9a-f]{40}$/', $stored_hash ) ) {
		return sha1( (string) $post->post_content ) === $stored_hash;
	}

	return $post->post_date_gmt === $post->post_modified_gmt;
}