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.

Метод класса: WCEmailScratchpadRefresher{}

Хуков нет.

Возвращает

bool. True when the post content was never edited.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->was_never_edited( $post ): bool;
$post(WP_Post) (обязательный)
The post to check.

Код WCEmailScratchpadRefresher::was_never_edited() WC 11.2.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;
}