WC_Admin::preview_emails()
Preview email template.
Метод класса: WC_Admin{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WC_Admin = new WC_Admin(); $WC_Admin->preview_emails();
Код WC_Admin::preview_emails() WC Admin::preview emails WC 9.8.1
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' ); } $email_preview = wc_get_container()->get( EmailPreview::class ); if ( isset( $_GET['type'] ) ) { $type_param = sanitize_text_field( wp_unslash( $_GET['type'] ) ); try { $email_preview->set_email_type( $type_param ); } catch ( InvalidArgumentException $e ) { wp_die( esc_html__( 'Invalid email type.', 'woocommerce' ), 400 ); } } // Start output buffering to prevent partial renders with PHP notices or warnings. ob_start(); try { $message = $email_preview->render(); $message = $email_preview->ensure_links_open_in_new_tab( $message ); } catch ( Throwable $e ) { ob_end_clean(); wp_die( esc_html__( 'There was an error rendering an email preview.', 'woocommerce' ), 404 ); } ob_end_clean(); // print the preview email. // phpcs:ignore WordPress.Security.EscapeOutput echo $message; // phpcs:enable exit; } }