Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCEmailTemplateSelectiveApplier::migrate_woo_email_content_namespaceprivate staticWC 1.0

Walk the merged tree and rewrite every wp:woo/email-content block to the canonical wp:woocommerce/email-content form. Touches the blockName and the wp-block-woo-email-content CSS class in the block's innerHTML and each innerContent segment. The block's attrs and inner content are otherwise preserved.

Targeted to a single known alias by design — this is not a general alias-migration framework. Add new entries here only when a real deprecated→canonical rename ships and we want it auto-migrated on apply.

Method of the class: WCEmailTemplateSelectiveApplier{}

No Hooks.

Returns

Array. array<string, mixed>>

Usage

$result = WCEmailTemplateSelectiveApplier::migrate_woo_email_content_namespace( $blocks, $migrated ): array;
$blocks(array) (required)
.
$migrated(string[]) (required)
Names of aliases that were rewritten (out param, appended to).

WCEmailTemplateSelectiveApplier::migrate_woo_email_content_namespace() code WC 10.9.1

private static function migrate_woo_email_content_namespace( array $blocks, array &$migrated ): array {
	$out = array();
	foreach ( $blocks as $block ) {
		if ( ! is_array( $block ) ) {
			$out[] = $block;
			continue;
		}

		if ( 'woo/email-content' === ( $block['blockName'] ?? null ) ) {
			$block['blockName'] = 'woocommerce/email-content';

			if ( isset( $block['innerHTML'] ) && is_string( $block['innerHTML'] ) ) {
				$block['innerHTML'] = str_replace(
					'wp-block-woo-email-content',
					'wp-block-woocommerce-email-content',
					$block['innerHTML']
				);
			}

			if ( isset( $block['innerContent'] ) && is_array( $block['innerContent'] ) ) {
				foreach ( $block['innerContent'] as $i => $segment ) {
					if ( is_string( $segment ) ) {
						$block['innerContent'][ $i ] = str_replace(
							'wp-block-woo-email-content',
							'wp-block-woocommerce-email-content',
							$segment
						);
					}
				}
			}

			$migrated[] = 'woo/email-content';
		}//end if

		if ( ! empty( $block['innerBlocks'] ) && is_array( $block['innerBlocks'] ) ) {
			$block['innerBlocks'] = self::migrate_woo_email_content_namespace( $block['innerBlocks'], $migrated );
		}

		$out[] = $block;
	}//end foreach
	return $out;
}