brewlabs/sendpress — pull request #40 by mattsnowboard (2013-02-27 08:31:14+00:00)
Title: Add a filter to process HTML email

This is my change to allow people to process the HTML email before sending it. For example, I used this to make all links italicized and have no underline. It could be extended to do a lot with inline styles. This example was tested in gmail.

function fix_sendpress_links($html)
{
$dom = new DomDocument();
$dom->strictErrorChecking = false;
@$dom->loadHtml($html);
$aTags = $dom->getElementsByTagName('a');
foreach ($aTags as $a) {
$style = '';
if ($a->hasAttribute('style')) {
$style = $a->getAttribute('style');
}
$style .= ';font-style: italic; text-decoration: none';
$a->setAttribute('style', $style);
}
$html = $dom->saveHtml();
return $html;
}

add_filter('sendpress_post_render_email', 'fix_sendpress_links');