Automattic\WooCommerce\Vendor\Sabberworm\CSS\RuleSet

DeclarationBlock::createShorthandPropertiespublicWC 1.0

Deprecated since since 8.7.0, will be removed without substitution in version 9.0 in #511. It is no longer supported and may be removed in future releases. It is recommended to replace this function with the same one.

Method of the class: DeclarationBlock{}

No Hooks.

Returns

null. Nothing (null).

Usage

$DeclarationBlock = new DeclarationBlock();
$DeclarationBlock->createShorthandProperties( $aProperties, $sShorthand );
$aProperties(array) (required)
.
$sShorthand(string) (required)
.

Changelog

Deprecated Since 8.7.0 , will be removed without substitution in version 9.0 in #511

DeclarationBlock::createShorthandProperties() code WC 10.5.0

public function createShorthandProperties(array $aProperties, $sShorthand)
{
    $aRules = $this->getRulesAssoc();
    $oRule = null;
    $aNewValues = [];
    foreach ($aProperties as $sProperty) {
        if (!isset($aRules[$sProperty])) {
            continue;
        }
        $oRule = $aRules[$sProperty];
        if (!$oRule->getIsImportant()) {
            $mRuleValue = $oRule->getValue();
            $aValues = [];
            if (!$mRuleValue instanceof RuleValueList) {
                $aValues[] = $mRuleValue;
            } else {
                $aValues = $mRuleValue->getListComponents();
            }
            foreach ($aValues as $mValue) {
                $aNewValues[] = $mValue;
            }
            $this->removeRule($sProperty);
        }
    }
    if ($aNewValues !== [] && $oRule instanceof Rule) {
        $oNewRule = new Rule($sShorthand, $oRule->getLineNo(), $oRule->getColNo());
        foreach ($aNewValues as $mValue) {
            $oNewRule->addValue($mValue);
        }
        $this->addRule($oNewRule);
    }
}