private static function mimemail_compress::get_selector_precedence in Mime Mail 7
Same name and namespace in other branches
- 6 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 223 - Converts CSS styles into inline style attributes.
Class
- mimemail_compress
- Compresses HTML and CSS into combined message.
Code
private static function get_selector_precedence($selector) {
$precedence = 0;
$value = 100;
// Ids: worth 100, classes: worth 10, elements: worth 1.
$search = array(
'\\#',
'\\.',
'',
);
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;
}