Convert any page generated by WordPress into HTML with inline styles to be used in newsletters.
- Clone the repo
- run
composer install
from freshly cloned plugin root - Activate the plugin
- Add a filter with path to your newsletter css (defaults to current theme's style.css)
- Create newsletter template (see e.g. below)
- Enjoy your sanity while dealing with HTML newsletters
All you need to do is to start your template file with ob_start();
and end it with echo Sane_HTML_Newsletters::convert( ob_get_clean() );
ob_start();
// Regular WP template goes here
echo Sane_HTML_Newsletters::convert( ob_get_clean() );
Alternatively, you can use shnl_should_auto_convert
filter to determine whether current request's output should be autoconverted
add_filter( 'shnl_should_auto_convert', function( $should_convert ) {
if ( is_page( 'my-newsletter-page' ) )
return true;
return $should_convert;
} );
Use a filter to specify path to desired CSS file:
add_filter( 'shnl_stylesheet_path', function( $css_file_path ) { return 'my/absolute/path/to/newsletter.css' } );
Miss a feature? Pull requests are welcome.
Tijs Verkoyen for his CssToInlineStyles class.