Automattic\WooCommerce\Internal\EmailEditor

Integration::update_preview_post_template_html_datapublicWC 1.0

Filter email preview data used when previewing the email in new tab.

Method of the class: Integration{}

No Hooks.

Returns

String. The updated preview HTML with placeholders replaced.

Usage

$Integration = new Integration();
$Integration->update_preview_post_template_html_data( $data );
$data(string) (required)
The preview HTML string.

Integration::update_preview_post_template_html_data() code WC 10.7.0

public function update_preview_post_template_html_data( $data ) {
	// return early if the data does not contain the placeholder meaning it's already been processed.
	if ( ! str_contains( (string) $data, BlockEmailRenderer::WOO_EMAIL_CONTENT_PLACEHOLDER ) ) {
		return $data;
	}

	// phpcs:disable WordPress.Security.NonceVerification.Recommended
	// Nonce verification is disabled here because the preview action doesn't modify data,
	// and the check caused issues with the 'Preview in new tab' feature due to context changes.
	$type_param = isset( $_GET['woo_email'] ) ? sanitize_text_field( wp_unslash( $_GET['woo_email'] ) ) : '';

	// check for post id (preview id) in the request.
	$post_id = isset( $_REQUEST['preview_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['preview_id'] ) ) : '';

	// phpcs:enable
	return $this->update_email_preview_data( $data, $type_param, $post_id );
}