template_path = dirname( __FILE__ ) . '/mail-templates/';
$this->name = $name;
}
public function add_header( $title, $banner_title, $use_site_logo = false ) {
$header = $this->get_template( 'header.html' );
if ( $use_site_logo ) {
$logo = $this->get_site_logo_url();
} elseif ( ITSEC_Core::is_pro() ) {
$logo = $this->get_image_url( 'pro_logo' );
} else {
$logo = $this->get_image_url( 'logo' );
}
$replacements = array(
'lang' => esc_attr( get_bloginfo( 'language' ) ),
'charset' => esc_attr( get_bloginfo( 'charset' ) ),
'title_tag' => $title,
'banner_title' => $banner_title,
'logo' => $logo,
'title' => $title,
);
$this->add_html( $this->replace_all( $header, $replacements ), 'header' );
}
public function add_footer() {
$footer = '';
if ( ! ITSEC_Core::is_pro() ) {
$callout = $this->get_template( 'pro-callout.html' );
$replacements = array(
'two_factor' => esc_html__( 'Want two-factor authentication, scheduled malware scanning, ticketed support and more?', 'better-wp-security' ),
'get_pro' => esc_html__( 'Get iThemes Security Pro', 'better-wp-security' ),
'why_pro' => sprintf( wp_kses( __( 'Why go Pro? Check out the Free/Pro comparison chart.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://ithemes.com/security/why-go-pro/' ) ),
);
$footer .= $this->replace_all( $callout, $replacements );
} else {
$this->add_divider();
}
$footer .= $this->get_template( 'footer.html' );
$settings = esc_url( self::filter_admin_page_url( ITSEC_Core::get_settings_page_url() ) );
$replacements = array(
'security_resources' => esc_html__( 'Security Resources', 'better-wp-security' ),
'articles' => esc_html__( 'Articles', 'better-wp-security' ),
'articles_content' => sprintf( wp_kses( __( 'Read the latest in WordPress Security news, tips, and updates on iThemes Blog.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://ithemes.com/category/wordpress-security/' ) ),
'tutorials' => esc_html__( 'Tutorials', 'better-wp-security' ),
'tutorials_content' => sprintf( wp_kses( __( 'Make the most of iThemes Security features with our free iThemes Security tutorials.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://ithemes.com/tutorial/category/ithemes-security/' ) ),
'help_and_support' => esc_html__( 'Help & Support', 'better-wp-security' ),
'documentation' => esc_html__( 'Documentation', 'better-wp-security' ),
'documentation_content' => sprintf( wp_kses( __( 'Read iThemes Security documentation and Frequently Asked Questions on the Codex.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'http://ithemes.com/codex/page/IThemes_Security' ) ),
'support' => esc_html__( 'Support', 'better-wp-security' ),
'pro' => esc_html__( 'Pro', 'better-wp-security' ),
'support_content' => sprintf( wp_kses( __( 'Pro customers can contact iThemes Helpdesk for help. Our support team answers questions Monday – Friday, 8am – 5pm (CST).', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://members.ithemes.com/panel/helpdesk.php' ) ),
'security_settings_link' => $settings,
'unsubscribe_link_text' => esc_html__( 'This email was generated by the iThemes Security plugin.', 'better-wp-security' ) . '
' . sprintf( esc_html__( 'To unsubscribe from these updates, visit the %1$sSettings page%2$s in the iThemes Security plugin menu.', 'better-wp-security' ), "", '' ),
'security_guide' => esc_html__( 'Free WordPress Security Guide', 'better-wp-security' ),
'security_guide_content' => sprintf( wp_kses( __( 'Learn simple WordPress security tips — including 3 kinds of security your site needs and 4 best security practices for keeping your WordPress site safe with our free guide.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://ithemes.com/publishing/wordpress-security/' ) ),
);
$this->add_html( $this->replace_all( $footer, $replacements ) );
if ( defined( 'ITSEC_DEBUG' ) && ITSEC_DEBUG ) {
$this->include_debug_info();
}
$this->add_html( $this->get_template( 'close.html' ), 'footer' );
}
public function add_user_footer() {
$link_text = sprintf( esc_html__( 'This email was generated by the iThemes Security plugin on behalf of %s.', 'better-wp-security' ), get_bloginfo( 'name', 'display' ) ) . '
';
$link_text .= sprintf(
esc_html__( 'To unsubscribe from these notifications, please %1$scontact the site administrator%2$s.', 'better-wp-security' ),
'', ''
);
$footer = $this->replace_all( $this->replace_images( $this->get_template( 'footer-user.html' ) ), array(
'unsubscribe_link_text' => $link_text,
) );
$footer .= $this->get_template( 'close.html' );
$this->add_html( $footer, 'user-footer' );
}
public function add_text( $content ) {
$this->add_html( $this->get_text( $content ) );
}
public function get_text( $content ) {
$module = $this->get_template( 'text.html' );
$module = $this->replace( $module, 'content', $content );
return $module;
}
public function add_divider() {
$this->add_html( $this->get_divider() );
}
public function get_divider() {
return $this->get_template( 'divider.html' );
}
public function add_large_text( $content ) {
$this->add_html( $this->get_large_text( $content ) );
}
public function get_large_text( $content ) {
$module = $this->get_template( 'large-text.html' );
$module = $this->replace( $module, 'content', $content );
return $module;
}
public function add_info_box( $content, $icon_type = 'info' ) {
$this->add_html( $this->get_info_box( $content, $icon_type ) );
}
public function get_info_box( $content, $icon_type = 'info' ) {
$icon_url = $this->get_image_url( $icon_type === 'warning' ? 'warning_icon_yellow' : "{$icon_type}_icon" );
$module = $this->get_template( 'info-box.html' );
$module = $this->replace_all( $module, compact( 'content', 'icon_url' ) );
return $module;
}
public function add_details_box( $content ) {
$this->add_html( $this->get_details_box( $content ) );
}
public function get_details_box( $content ) {
$module = $this->get_template( 'details-box.html' );
$module = $this->replace( $module, 'content', $content );
return $module;
}
public function add_large_code( $content ) {
$this->add_html( $this->get_large_code( $content ) );
}
public function get_large_code( $content ) {
$module = $this->get_template( 'large-code.html' );
$module = $this->replace( $module, 'content', $content );
return $module;
}
public function add_section_heading( $content, $icon_type = false ) {
$this->add_html( $this->get_section_heading( $content, $icon_type ) );
}
public function get_section_heading( $content, $icon_type = false ) {
if ( empty( $icon_type ) ) {
$heading = $this->get_template( 'section-heading.html' );
$heading = $this->replace_all( $heading, compact( 'content' ) );
} else {
$icon_url = $this->get_image_url( "icon_{$icon_type}" );
$heading = $this->get_template( 'section-heading-with-icon.html' );
$heading = $this->replace_all( $heading, compact( 'content', 'icon_url' ) );
}
return $heading;
}
public function add_lockouts_summary( $user_count, $host_count ) {
$lockouts = $this->get_template( 'lockouts-summary.html' );
$replacements = array(
'users_text' => esc_html__( 'Users', 'better-wp-security' ),
'hosts_text' => esc_html__( 'Hosts', 'better-wp-security' ),
'user_count' => $user_count,
'host_count' => $host_count,
);
$lockouts = $this->replace_all( $lockouts, $replacements );
$this->add_html( $lockouts, 'lockouts-summary' );
}
public function add_file_change_summary( $added, $removed, $modified ) {
$lockouts = $this->get_template( 'file-change-summary.html' );
$replacements = array(
'added_text' => esc_html_x( 'Added', 'Files added', 'better-wp-security' ),
'removed_text' => esc_html_x( 'Removed', 'Files removed', 'better-wp-security' ),
'modified_text' => esc_html_x( 'Modified', 'Files modified', 'better-wp-security' ),
'added_count' => $added,
'removed_count' => $removed,
'modified_count' => $modified,
);
$lockouts = $this->replace_all( $lockouts, $replacements );
$this->add_html( $lockouts, 'file-change-summary' );
}
public function add_button( $link_text, $href, $style = 'default' ) {
$this->add_html( $this->get_button( $link_text, $href, $style ) );
}
public function get_button( $link_text, $href, $style = 'default' ) {
$module = $this->get_template( 'module-button.html' );
$module = $this->replace_all( $module, array(
'href' => $href,
'link_text' => $link_text,
'bk_color' => 'blue' === $style ? '#0085E0' : '#FFCD08',
'txt_color' => 'blue' === $style ? '#FFFFFF' : '#2E280E',
) );
return $module;
}
public function add_lockouts_table( $lockouts ) {
$entry = $this->get_template( 'lockouts-entry.html' );
$entries = '';
foreach ( $lockouts as $lockout ) {
if ( 'user' === $lockout['type'] ) {
/* translators: 1: Username */
$lockout['description'] = sprintf( wp_kses( __( 'User: %1$s', 'better-wp-security' ), array( 'b' => array() ) ), $lockout['id'] );
} else {
/* translators: 1: Hostname */
$lockout['description'] = sprintf( wp_kses( __( 'Host: %1$s', 'better-wp-security' ), array( 'b' => array() ) ), $lockout['id'] );
}
$entries .= $this->replace_all( $entry, $lockout );
}
$table = $this->get_template( 'lockouts-table.html' );
$replacements = array(
'heading_types' => __( 'Host/User', 'better-wp-security' ),
'heading_until' => __( 'Lockout in Effect Until', 'better-wp-security' ),
'heading_reason' => __( 'Reason', 'better-wp-security' ),
'entries' => $entries,
);
$table = $this->replace_all( $table, $replacements );
$this->add_html( $table, 'lockouts-table' );
}
/**
* Add a generic table.
*
* @param string[] $headers
* @param array[] $entries
* @param bool $large
*/
public function add_table( $headers, $entries, $large = false ) {
$this->add_html( $this->get_table( $headers, $entries, $large ) );
}
public function get_table( $headers, $entries, $large = false ) {
$template = $this->get_template( 'table.html' );
$html = $this->build_table_header( $headers, $large );
foreach ( $entries as $entry ) {
$html .= $this->build_table_row( $entry, count( $headers ), $large );
}
return $this->replace( $template, 'html', $html );
}
/**
* Build the table header.
*
* @param array $headers
* @param bool $large
*
* @return string
*/
private function build_table_header( $headers, $large = false ) {
$html = '