WordPress at a glance
function is not described

Pelago

Emogrifier::parseCssDeclarationsBlock() private WC 1.0

Parses a CSS declaration block into property name/value pairs.

Example:

The declaration block

"color: #000; font-weight: bold;"

will be parsed into the following array:

"color" => "#000" "font-weight" => "bold"

{} It's a method of the class: Emogrifier{}

No Hooks.

Return

String[]
. the CSS declarations with the property names as array keys and the property values as array values

Usage

// private - for code of main (parent) class only
$result = $this->parseCssDeclarationsBlock( $cssDeclarationsBlock );
$cssDeclarationsBlock(string) (required)
the CSS declarations block without the curly braces, may be empty

Code of Emogrifier::parseCssDeclarationsBlock() WC 5.0.0

<?php
private function parseCssDeclarationsBlock($cssDeclarationsBlock)
{
    if (isset($this->caches[self::CACHE_KEY_CSS_DECLARATIONS_BLOCK][$cssDeclarationsBlock])) {
        return $this->caches[self::CACHE_KEY_CSS_DECLARATIONS_BLOCK][$cssDeclarationsBlock];
    }

    $properties = [];
    foreach (\preg_split('/;(?!base64|charset)/', $cssDeclarationsBlock) as $declaration) {
        $matches = [];
        if (!\preg_match('/^([A-Za-z\\-]+)\\s*:\\s*(.+)$/s', \trim($declaration), $matches)) {
            continue;
        }

        $propertyName = \strtolower($matches[1]);
        $propertyValue = $matches[2];
        $properties[$propertyName] = $propertyValue;
    }
    $this->caches[self::CACHE_KEY_CSS_DECLARATIONS_BLOCK][$cssDeclarationsBlock] = $properties;

    return $properties;
}