WC_Admin::preview_emails()publicWC 1.0

Preview email template.

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

Хуки из метода

Возвращает

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

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

$WC_Admin = new WC_Admin();
$WC_Admin->preview_emails();

Код WC_Admin::preview_emails() WC 8.7.0

public function preview_emails() {

	if ( isset( $_GET['preview_woocommerce_mail'] ) ) {
		if ( ! ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'preview-mail' ) ) ) {
			die( 'Security check' );
		}

		// load the mailer class.
		$mailer = WC()->mailer();

		// get the preview email subject.
		$email_heading = __( 'HTML email template', 'woocommerce' );

		// get the preview email content.
		ob_start();
		include __DIR__ . '/views/html-email-template-preview.php';
		$message = ob_get_clean();

		// create a new email.
		$email = new WC_Email();

		// wrap the content with the email template and then add styles.
		$message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );

		// print the preview email.
		// phpcs:ignore WordPress.Security.EscapeOutput
		echo $message;
		// phpcs:enable
		exit;
	}
}