Automattic\WooCommerce\EmailEditorVendor\Pelago\Emogrifier

CssInliner::copyInlinableCssToStyleAttribute │ private │ WC 1.0

Copies $cssRule into the style attribute of $node.

Note: This method does not check whether $cssRule matches $node.

Метод класса: CssInliner{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->copyInlinableCssToStyleAttribute( $node, $cssRule ): void;
$node(DOMElement) (обязательный)
.
$cssRule *(array{
media: string,
selector: string,
hasUnmatchablePseudo: bool,
declarationsBlock: string,
line: int
}) (обязательный)*
.

Код CssInliner::copyInlinableCssToStyleAttribute() WC 11.3.0

private function copyInlinableCssToStyleAttribute(\DOMElement $node, array $cssRule): void
{
    $declarationsBlock = $cssRule['declarationsBlock'];
    $declarationBlockParser = new DeclarationBlockParser();
    $newStyleDeclarations = $declarationBlockParser->parse($declarationsBlock);
    if ($newStyleDeclarations === []) {
        return;
    }

    // if it has a style attribute, get it, process it, and append (overwrite) new stuff
    if ($node->hasAttribute('style')) {
        // break it up into an associative array
        $oldStyleDeclarations = $declarationBlockParser->parse($node->getAttribute('style'));
    } else {
        $oldStyleDeclarations = [];
    }
    $node->setAttribute(
        'style',
        $this->generateStyleStringFromDeclarationsArrays($oldStyleDeclarations, $newStyleDeclarations)
    );
}