Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/rinatkhaziev/sane-html-newsletters/archive/refs/heads/master.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Sane HTML Newsletters (working title)
Description
Convert any page generated by WordPress into HTML with inline styles to be used in newsletters.
Installation
- Clone the repo
- run
composer installfrom 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
Example
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' } );
Todo
Developers
Miss a feature? Pull requests are welcome.
Props
Tijs Verkoyen for his CssToInlineStyles class.