Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateDivergenceDetector::is_sha1_hash
Validate that a string is shaped like a SHA-1 hex digest.
_wc_email_template_source_hash is produced by sha1() (40 hex chars), but as persisted post meta it is theoretically reachable from DB migrations, direct update_post_meta or misbehaving extensions. Any non-SHA-1 value would otherwise be compared byte-for-byte against real hashes and always report core_updated_customized, so we short-circuit instead.
Method of the class: WCEmailTemplateDivergenceDetector{}
No Hooks.
Returns
true|false. True when the value is a 40-character hex string.
Usage
$result = WCEmailTemplateDivergenceDetector::is_sha1_hash( $hash ): bool;
- $hash(string) (required)
- Candidate hash value.
WCEmailTemplateDivergenceDetector::is_sha1_hash() WCEmailTemplateDivergenceDetector::is sha1 hash code WC 10.8.1
private static function is_sha1_hash( string $hash ): bool {
return 40 === strlen( $hash ) && ctype_xdigit( $hash );
}