function mimemail_compress_clean_message in Mime Mail 6
Same name and namespace in other branches
- 7 modules/mimemail_compress/mimemail_compress.inc \mimemail_compress_clean_message()
Separate CSS from HTML for processing.
1 call to mimemail_compress_clean_message()
- mimemail_compress_mail_post_process in modules/
mimemail_compress/ mimemail_compress.module - Implements hook_mail_post_process().
File
- modules/
mimemail_compress/ mimemail_compress.inc, line 13 - Converts CSS styles into inline style attributes.
Code
function mimemail_compress_clean_message($message) {
$parts = array();
preg_match('|(<style[^>]+)>(.*)</style>|mis', $message, $matches);
$css = str_replace('<!--', '', $matches[2]);
$css = str_replace('-->', '', $css);
$css = preg_replace('|\\{|', "\n{\n", $css);
$css = preg_replace('|\\}|', "\n}\n", $css);
$html = str_replace($matches[0], '', $message);
$parts = array(
'html' => $html,
'css' => $css,
);
return $parts;
}