Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCEmailTemplateSyncBackfill::classifyprivate staticWC 1.0

Classify a post into one of the three backfill cases.

Pure function: given identical inputs, always returns the same case.

Method of the class: WCEmailTemplateSyncBackfill{}

No Hooks.

Returns

String. One of self::CASE_A, self::CASE_B, self::CASE_C.

Usage

$result = WCEmailTemplateSyncBackfill::classify( $row, $current_core_hash ): string;
$row(stdClass) (required)
Row with post_content, post_date, post_modified, post_date_gmt, post_modified_gmt.
$current_core_hash(string) (required)
sha1() of the canonical core render for the post's email.

WCEmailTemplateSyncBackfill::classify() code WC 10.9.4

private static function classify( \stdClass $row, string $current_core_hash ): string {
	$current_post_hash = sha1( (string) ( $row->post_content ?? '' ) );

	if ( $current_post_hash === $current_core_hash ) {
		return self::CASE_A;
	}

	return self::was_never_edited( $row ) ? self::CASE_B : self::CASE_C;
}