Automattic\WooCommerce\Vendor\Sabberworm\CSS\CSSList
CSSList::removeDeclarationBlockBySelector
Removes a declaration block from the CSS list if it matches all given selectors.
Method of the class: CSSList{}
No Hooks.
Returns
null. Nothing (null).
Usage
$CSSList = new CSSList(); $CSSList->removeDeclarationBlockBySelector( $mSelector, $bRemoveAll );
- $mSelector(required)
- .
- $bRemoveAll(true|false)
- whether to stop at the first declaration block found or remove all blocks.
Default:false
CSSList::removeDeclarationBlockBySelector() CSSList::removeDeclarationBlockBySelector code WC 10.7.0
public function removeDeclarationBlockBySelector($mSelector, $bRemoveAll = false)
{
if ($mSelector instanceof DeclarationBlock) {
$mSelector = $mSelector->getSelectors();
}
if (!is_array($mSelector)) {
$mSelector = explode(',', $mSelector);
}
foreach ($mSelector as $iKey => &$mSel) {
if (!($mSel instanceof Selector)) {
if (!Selector::isValid($mSel)) {
throw new UnexpectedTokenException(
"Selector did not match '" . Selector::SELECTOR_VALIDATION_RX . "'.",
$mSel,
"custom"
);
}
$mSel = new Selector($mSel);
}
}
foreach ($this->aContents as $iKey => $mItem) {
if (!($mItem instanceof DeclarationBlock)) {
continue;
}
if ($mItem->getSelectors() == $mSelector) {
unset($this->aContents[$iKey]);
if (!$bRemoveAll) {
return;
}
}
}
}