Wpdai Email Template Styles

Alpha Insights Documentation

Docs Navigation

Filter: wpdai_email_template_styles

Filter the CSS styles used in Alpha Insights email templates before they are output in the <style> tag.

Description

Email templates include inline styles for compatibility with email clients. The plugin builds a string of CSS and outputs it inside a <style type="text/css"> block. This filter receives that CSS string so you can add or override styles (e.g. brand colors, fonts, or layout). The filtered value is escaped with esc_html() when output.

Location

File: includes/emails/wpd-email-template_styles.php

Context: Before the style block is echoed into the email template.

Parameters

Parameter Type Description
$email_styles string The CSS content for the email template (rules and declarations)

Return

Type: string

The (possibly modified) CSS string. Keep valid CSS; the output is escaped for HTML context.

Example Usage

Add brand colors to emails

add_filter( 'wpdai_email_template_styles', 'add_brand_email_styles' );
function add_brand_email_styles( $email_styles ) {
    $extra = '
        .wpd-email-header { background-color: #1a1a2e !important; }
        .wpd-email-button { background-color: #e94560 !important; }
    ';
    return $email_styles . $extra;
}

Override font family

add_filter( 'wpdai_email_template_styles', 'override_email_font' );
function override_email_font( $email_styles ) {
    $email_styles = str_replace( 'font-family: sans-serif', 'font-family: "Helvetica Neue", Helvetica, Arial, sans-serif', $email_styles );
    return $email_styles;
}

Best Practices

  • Use inline-friendly CSS; many email clients strip or ignore external stylesheets.
  • Append or replace specific rules rather than stripping required layout styles.
  • Do not include user-controlled or unsanitized input in the CSS string.

Got A Question?

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Alpha Insights

Alpha Insights

The World's Most Advanced WooCommerce Profit Reporting Engine

5/5 – Trustpilot

Alpha Insights