Automattic\WooCommerce\Internal\EmailEditor

Integration::render_block_email_preview_page │ public │ WC 1.0

Render the listing Preview page for an email without a published post.

Mirrors the preview_woocommerce_mail admin page pattern: a nonce-gated query-param handler that echoes the full preview HTML document. Used by the settings listing's Preview action for emails whose rendering source is the file template (no post, or an unpublished draft).

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$Integration = new Integration();
$Integration->render_block_email_preview_page(): void;

Код Integration::render_block_email_preview_page() WC 11.3.0

public function render_block_email_preview_page(): void {
	if ( ! isset( $_GET['preview_woo_block_email'] ) ) {
		return;
	}

	// Verifies the `_wpnonce` query arg that `wp_nonce_url()` appended to
	// the listing payload's preview URL; dies when missing or invalid.
	check_admin_referer( 'preview-woo-block-email' );

	if ( ! current_user_can( 'manage_woocommerce' ) ) {
		wp_die( esc_html__( 'You do not have permission to preview emails.', 'woocommerce' ) );
	}

	$email_type = isset( $_GET['email_id'] ) ? sanitize_text_field( wp_unslash( $_GET['email_id'] ) ) : '';

	try {
		$preview = $this->render_preview_html_for_email_type( $email_type );
	} catch ( \InvalidArgumentException $e ) {
		wp_die( esc_html__( 'This email cannot be previewed.', 'woocommerce' ) );
	}

	echo $preview['html']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Full HTML document produced by the email renderer; escaping would break it.
	exit;
}