WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана


Emogrifier::parseCssRules() private WC 1.0

Extracts and parses the individual rules from a CSS string.

{} Это метод класса: Emogrifier{}

Хуков нет.


Строку[][][]. A 2-entry array with the key "inlinable" containing rules which can be inlined as style attributes and the key "uninlinable" containing rules which cannot. Each value is an array of string sub-arrays with the keys "media" (the media query string, e.g. "@media screen and (max-width: 480px)", or an empty string if not from a @media rule), "selector" (the CSS selector, e.g., "*" or "header h1"), "hasUnmatchablePseudo" (true if that selector contains pseudo-elements or dynamic pseudo-classes such that the declarations cannot be applied inline), "declarationsBlock" (the semicolon-separated CSS declarations for that selector, e.g., "color: red; height: 4px;"), and "line" (the line number e.g. 42)


// private - только в коде основоного (родительского) класса
$result = $this->parseCssRules( $css );
$css(строка) (обязательный)
a string of raw CSS code with comments removed

Код Emogrifier::parseCssRules() WC 5.4.1

private function parseCssRules($css)
    $cssKey = \md5($css);
    if (!isset($this->caches[self::CACHE_KEY_CSS][$cssKey])) {
        $matches = $this->getCssRuleMatches($css);

        $cssRules = [
            'inlinable' => [],
            'uninlinable' => [],
        /** @var string[][] $matches */
        /** @var string[] $cssRule */
        foreach ($matches as $key => $cssRule) {
            $cssDeclaration = \trim($cssRule['declarations']);
            if ($cssDeclaration === '') {

            foreach (\explode(',', $cssRule['selectors']) as $selector) {
                // don't process pseudo-elements and behavioral (dynamic) pseudo-classes;
                // only allow structural pseudo-classes
                $hasPseudoElement = \strpos($selector, '::') !== false;
                $hasUnsupportedPseudoClass = (bool)\preg_match(
                    '/:(?!' . self::PSEUDO_CLASS_MATCHER . ')[\\w\\-]/i',
                $hasUnmatchablePseudo = $hasPseudoElement || $hasUnsupportedPseudoClass;

                $parsedCssRule = [
                    'media' => $cssRule['media'],
                    'selector' => \trim($selector),
                    'hasUnmatchablePseudo' => $hasUnmatchablePseudo,
                    'declarationsBlock' => $cssDeclaration,
                    // keep track of where it appears in the file, since order is important
                    'line' => $key,
                $ruleType = ($cssRule['media'] === '' && !$hasUnmatchablePseudo) ? 'inlinable' : 'uninlinable';
                $cssRules[$ruleType][] = $parsedCssRule;

        \usort($cssRules['inlinable'], [$this, 'sortBySelectorPrecedence']);

        $this->caches[self::CACHE_KEY_CSS][$cssKey] = $cssRules;

    return $this->caches[self::CACHE_KEY_CSS][$cssKey];