Last active
October 4, 2018 09:29
-
-
Save haet/e2983b006185b5fd915c7124e3cb9f13 to your computer and use it in GitHub Desktop.
Add custom CSS to WP HTML Mail WordPress E-Mails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add custom CSS to WP HTML Mail WordPress E-Mails | |
*/ | |
add_filter( 'haet_mail_modify_styled_mail', function( $email_html ){ | |
$custom_css = ' | |
.container-padding{ | |
padding-left: 60px; | |
padding-right: 0; | |
} | |
h1{ | |
border-bottom: 2px solid black; | |
} | |
'; | |
$custom_mobile_css = ' | |
.container-padding{ | |
padding-left: 10px; | |
padding-right: 10px; | |
} | |
'; | |
$email_html = str_replace( '/**** ADD CSS HERE ****/', $custom_css . '/**** ADD CSS HERE ****/', $email_html ); | |
$email_html = str_replace( '/**** ADD MOBILE CSS HERE ****/', $custom_mobile_css . '/**** ADD MOBILE CSS HERE ****/', $email_html ); | |
return $email_html; | |
}); |
Thanks, that's awesome! Will it make its way into the plugin itself in one of the new updates?
Im confused. In the plugin FAQ it says
You can add your own CSS code for desktop and mobile. Just add this example to your (child-)themes functions.php and customize it:
add_filter( 'haet_mail_css_desktop', function( $css ){ $css .= ' h1{ border-bottom: 2px solid green; } '; return $css; });
However, this does not work and there is no haet_mail_css_desktop
defined in the plugin.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! Thanks for making this available.