private static function mimemail_compress::get_selector_precedence in Mime Mail 6
Same name and namespace in other branches
- 7 modules/mimemail_compress/mimemail_compress.inc \mimemail_compress::get_selector_precedence()
1 call to mimemail_compress::get_selector_precedence()
- mimemail_compress::sort_selector_precedence in modules/
mimemail_compress/ mimemail_compress.inc
File
- modules/
mimemail_compress/ mimemail_compress.inc, line 174 - Converts CSS styles into inline style attributes.
Class
- mimemail_compress
- Compress HTML and CSS into combined message.
Code
private static function get_selector_precedence($selector) {
$precedence = 0;
$value = 100;
$search = array(
'\\#',
'\\.',
'',
);
// ids: worth 100, classes: worth 10, elements: worth 1
foreach ($search as $s) {
if (trim($selector == '')) {
break;
}
$num = 0;
$selector = preg_replace('/' . $s . '\\w+/', '', $selector, -1, $num);
$precedence += $value * $num;
$value /= 10;
}
return $precedence;
}