WC_Settings_Emails::email_notification_setting_block_emailspublicWC 1.0

Creates the React mount point for listing of block based emails.

Method of the class: WC_Settings_Emails{}

No Hooks.

Returns

null. Nothing (null).

Usage

$WC_Settings_Emails = new WC_Settings_Emails();
$WC_Settings_Emails->email_notification_setting_block_emails();

WC_Settings_Emails::email_notification_setting_block_emails() code WC 10.9.4

<?php
public function email_notification_setting_block_emails() {
	$desc_help_text = sprintf(
		/* translators: %1$s: Link to WP Mail Logging plugin, %2$s: Link to Email FAQ support page. */
		__( 'To ensure your store&rsquo;s notifications arrive in your and your customers&rsquo; inboxes, we recommend connecting your email address to your domain and setting up a dedicated SMTP server. If something doesn&rsquo;t seem to be sending correctly, install the <a href="%1$s">WP Mail Logging Plugin</a> or check the <a href="%2$s">Email FAQ page</a>.', 'woocommerce' ),
		'https://wordpress.org/plugins/wp-mail-logging/',
		'https://woocommerce.com/document/email-faq'
	);
	$email_post_manager   = WCTransactionalEmailPostsManager::get_instance();
	$emails               = WC()->mailer()->get_emails();
	$email_types          = array();
	$post_id_for_template = null;
	foreach ( $emails as $email_key => $email ) {
		$post_id     = $email_post_manager->get_email_template_post_id( $email->id );
		$sync_config = WCEmailTemplateSyncRegistry::get_email_sync_config( $email->id );
		// `current_version` is the canonical version core ships right now;
		// the list view's "Review update" cell and RSM-141's editor banner
		// gate on `merchant_reviewed_version < current_version` so a row
		// stays customized but stops showing the indicator once the
		// merchant has reviewed this release.
		$current_version = is_array( $sync_config ) ? (string) ( $sync_config['version'] ?? '' ) : '';

		// Project the template-sync meta directly onto the slotfill payload
		// so the RSM-145 `_list_viewed` aggregate event can compute
		// `eligible_count` immediately on mount without waiting for the
		// REST enrichment in `useTransactionalEmails` to resolve. REST
		// enrichment still runs and overrides these values once it lands —
		// both sources read from the same post meta, so they always agree.
		$template_status  = $post_id ? (string) get_post_meta( $post_id, WCEmailTemplateDivergenceDetector::STATUS_META_KEY, true ) : '';
		$template_version = $post_id ? (string) get_post_meta( $post_id, WCEmailTemplateDivergenceDetector::VERSION_META_KEY, true ) : '';
		$was_backfilled   = $post_id ? (bool) get_post_meta( $post_id, WCEmailTemplateDivergenceDetector::BACKFILLED_META_KEY, true ) : false;

		$email_types[] = array(
			'title'            => $email->get_title(),
			'description'      => $email->get_description(),
			'id'               => $email->id,
			'email_key'        => strtolower( $email_key ),
			'post_id'          => $post_id,
			'enabled'          => $email->is_enabled(),
			'manual'           => $email->is_manual(),
			'current_version'  => '' !== $current_version ? $current_version : null,
			'template_status'  => '' !== $template_status ? $template_status : null,
			'template_version' => '' !== $template_version ? $template_version : null,
			'was_backfilled'   => $was_backfilled,
			'recipients'       => array(
				'to'  => $email->is_customer_email() ? __( 'Customers', 'woocommerce' ) : $email->get_recipient(),
				'cc'  => $email->get_cc_recipient(),
				'bcc' => $email->get_bcc_recipient(),
			),
		);

		// Store the first valid post ID we find.
		if ( ! $post_id_for_template && $post_id ) {
			$post_id_for_template = $post_id;
		}
	}
	// Create URL for email editor template mode.
	$edit_template_url = null;
	if ( $post_id_for_template ) {
		$email_template_id = get_stylesheet() . '//' . WooEmailTemplate::TEMPLATE_SLUG;
		$edit_template_url = admin_url( 'post.php?post=' . $post_id_for_template . '&action=edit&template=' . $email_template_id );
	}

	?>
	<div
		id="wc_settings_email_listing_slotfill" class="wc-settings-prevent-change-event woocommerce-email-listing-listview"
		data-email-types="<?php echo esc_attr( wp_json_encode( $email_types ) ); ?>"
		data-edit-template-url="<?php echo esc_attr( $edit_template_url ); ?>"
	>
		<div style="
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 12px;
		height: 40px;
		width: 100%;
		">
			<h3> <?php esc_html_e( 'Loading&hellip;', 'woocommerce' ); ?>  </h3>
		</div>
	</div>
	<div>
		<p><?php echo wp_kses_post( wpautop( wptexturize( $desc_help_text ) ) ); ?></p>
	</div>
	<?php
}