get_html_preview_message( $mail->get_message() ); exit; } /** * Get the message to be rendered in the preview. * * @since 1.11.1 * @since 1.15.0 Added filterable `$allowed_html` and `$allowed_protocols` to `wp_kses()`. * * @param string $message Email log message. * * @return string */ private function get_html_preview_message( $message ) { // Strip and comment tags. $message = preg_replace( '/]*>(.*?)<\/xml>/is', '', $message ); $message = preg_replace( '//', '', $message ); $allowed_html = wp_kses_allowed_html( 'post' ); $allowed_html['style'][''] = true; /** * Filters the allowed HTML in the email HTML preview. * * @since 1.15.0 * * @param string[] $allowed_html Array of allowed HTML. * @param string $message Email message. */ $allowed_html = apply_filters( 'wp_mail_logging_allowed_html_email_html_preview', $allowed_html, $message ); /** * Filters the allowed protocols in the email HTML preview. * * @since 1.15.0 * * @param string[] $allowed_protocols Array of allowed protocols. * @param string $message Email message. */ $allowed_protocols = apply_filters( 'wp_mail_logging_allowed_protocols_email_html_preview', wp_allowed_protocols(), $message ); return wp_kses( $message, $allowed_html, $allowed_protocols ); } /** * Only add hooks here that are invoked after `current_screen` action hook. * * @since 1.11.0 * * @return void */ public function screen_hooks() { add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); add_action( 'wp_mail_logging_email_logs_tab_display_before', [ $this, 'product_education_email_failure' ] ); add_action( 'wp_mail_logging_email_logs_tab_display_after', [ $this, 'product_education_wp_mail_smtp' ] ); add_filter( 'admin_body_class', [ $this, 'add_admin_body_class' ] ); add_action( 'wp_mail_logging_admin_tab_content', [ $this, 'display_tab_content' ] ); add_filter( 'wp_mail_logging_jquery_confirm_localized_strings', [ $this, 'jquery_confirm_localized_string' ] ); } /** * Enqueue scripts in Email Logs tab. * * @since 1.11.0 * * @return void * * @throws \Exception */ public function enqueue_scripts() { $assets_url = WPML_Init::getInstance()->getService( 'plugin' )->get_assets_url(); $plugin_meta = WPML_Init::getInstance()->getService( 'plugin-meta' ); if ( empty( $plugin_meta['version'] ) ) { return; } $min = ''; if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) { $min = '.min'; } wp_enqueue_script( 'wp-mail-logging-admin-logs', $assets_url . "/js/wp-mail-logging-admin-logs{$min}.js", [ 'jquery' ], $plugin_meta['version'] ); /** * Filters the strings to be localized and used in JS. * * @param string $data Data to be localized. * * @since 1.11.0 */ $filtered_localized_strings = apply_filters( 'wp_mail_logging_admin_logs_localize_strings', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ), ] ); wp_localize_script( 'wp-mail-logging-admin-logs', 'wp_mail_logging_admin_logs', $filtered_localized_strings ); // Enqueue Lity. wp_enqueue_script( 'wp-mail-logging-admin-lity', $plugin_meta['uri'] . "lib/lity/lity.min.js", [], '2.4.1', true ); wp_enqueue_style( 'wp-mail-logging-admin-lity', $plugin_meta['uri'] . "lib/lity/lity.min.css", [], '2.4.1' ); } /** * Display product education for email failures. * * Only display this product education if the current page has email logs with errors. * * @since 1.11.0 * * @return void */ public function product_education_email_failure() { if ( empty( $this->get_current_logs_with_errors() ) ) { return; } /** @var WPML_ProductEducation $productEducation */ $productEducation = WPML_Init::getInstance()->getService( 'productEducation' ); if ( $productEducation->is_banner_dismissed( self::BANNER_TOP_ID ) ) { return; } $content = '
'; $content .= '

' . esc_html__( "To solve email delivery issues, install WP Mail SMTP (free) - trusted by over 3,000,00 sites!", 'wp-mail-logging' ) . '

'; $content .= '

' . esc_html__( "Use the one-click install and setup wizard to fix your emails in minutes.", 'wp-mail-logging' ) . '

'; $content .= '
'; WPML_ProductEducation::create_banner( self::BANNER_TOP_ID, esc_html__( 'Heads up! WP Mail Logging has detected a problem sending emails.', 'wp-mail-logging' ), $content, [ 'url' => SMTPTab::get_url(), 'label' => esc_html__( 'Install WP Mail SMTP', 'wp-mail-logging' ), ] ); } /** * Returns an array containing the current logs in the page with errors. * * @since 1.11.0 * * @return array */ private function get_current_logs_with_errors() { if ( ! is_null( $this->current_logs_with_errors ) ) { return $this->current_logs_with_errors; } if ( ! $this->emailLogList->has_items() ) { $this->current_logs_with_errors = []; return []; } $this->current_logs_with_errors = array_filter( $this->emailLogList->items, function( $log ) { return ! empty( $log['error'] ); } ); return $this->current_logs_with_errors; } /** * Display product education about WP Mail SMTP if there's no logs with errors in the page. * * @since 1.11.0 * * @return void */ public function product_education_wp_mail_smtp() { /** @var WPML_ProductEducation $productEducation */ $productEducation = WPML_Init::getInstance()->getService( 'productEducation' ); if ( $productEducation->is_banner_dismissed( self::BANNER_BOTTOM_ID ) ) { return; } if ( ! empty( $this->get_current_logs_with_errors() ) && ! $productEducation->is_banner_dismissed( self::BANNER_TOP_ID ) ) { return; } $features = [ [ 'filename' => 'archive', 'label' => __( 'Email Logs', 'wp-mail-logging' ), 'list' => [ __( 'See delivery status', 'wp-mail-logging' ), __( 'Resend emails', 'wp-mail-logging' ), __( 'View original email content', 'wp-mail-logging' ), ], ], [ 'filename' => 'single', 'label' => __( 'Individual Log', 'wp-mail-logging' ), 'list' => [ __( 'Review technical details', 'wp-mail-logging' ), __( 'Track open and click data', 'wp-mail-logging' ), __( 'Download sent attachments', 'wp-mail-logging' ), ], ], [ 'filename' => 'reports', 'label' => __( 'Email Reports', 'wp-mail-logging' ), 'list' => [ __( 'Generate deliverability charts', 'wp-mail-logging' ), __( 'Review open & click statistics', 'wp-mail-logging' ), __( 'Get weekly email summary', 'wp-mail-logging' ), ], ], ]; ob_start(); ?>

WP Mail SMTP Pro offers advanced email logging, failed email alerts, backup connections, email reports, email tracking, and much more!', 'wp-mail-logging' ), esc_url( WPML_Utils::get_utm_url( 'https://wpmailsmtp.com/', 'general' ) ) ), [ 'a' => [ 'target' => [], 'href' => [], ], 'strong' => [], ] ) ?>

getService( 'plugin' )->get_assets_url(); foreach ( $features as $feature ) { ?>
" data-lity data-lity-desc=""> " alt="">
    %s', esc_html( $list ) ); } ?>
WPML_Utils::get_utm_url( 'https://wpmailsmtp.com/pricing/', 'Get WP Mail SMTP Pro' ), 'label' => __( 'Get WP Mail SMTP Pro', 'wp-mail-logging' ), 'target' => '_blank', ] ); } /** * Display the Email Logs tab content. * * @since 1.11.0 * * @return void */ public function display_tab_content() { // Admin notices display after the first heading tag. echo '

' . esc_html__( 'Email Logs', 'wp-mail-logging' ) . '

'; $this->emailLogList = WPML_Init::getInstance()->getService('emailLogList'); $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : false; $this->emailLogList->prepare_items( $search ); /** * Fires before displaying the email logs content. * * @since 1.11.0 * * @param WPML_Email_Log_List $emailLogList Email Log List object. */ do_action( 'wp_mail_logging_email_logs_tab_display_before', $this->emailLogList ); $this->emailLogList->display_notices(); $this->single_log_modal(); $this->display_table(); /** * Fires after displaying the email logs content. * * @since 1.11.0 * * @param WPML_Email_Log_List $emailLogList Email Log List object. */ do_action( 'wp_mail_logging_email_logs_tab_display_after', $this->emailLogList ); } /** * Modal template for showing single log details. * * @since 1.11.0 * * @return void */ private function single_log_modal() { global $wp_version; ?>
    getService('supported-mail-renderer-formats') as $key => $format ) { $active_class = WPML_Init::getInstance()->getService( 'plugin' )->getSetting( 'preferred-mail-format' ) === $format ? 'wp-mail-logging-active-format' : ''; ?>
emailLogList->search_box( __( 'Search', 'wp-mail-logging' ), 's' ); $this->emailLogList->views(); $this->emailLogList->display(); ?>