Automattic\WooCommerce\Vendor\Pelago\Emogrifier\HtmlProcessor
HtmlPruner::removeRedundantClassesAfterCssInlined
After CSS has been inlined, there will likely be some classes in class attributes that are no longer referenced by any remaining (uninlinable) CSS. This method removes such classes.
Note that it does not inspect the remaining CSS, but uses information readily available from the CssInliner instance about the CSS rules that could not be inlined.
Метод класса: HtmlPruner{}
Хуков нет.
Возвращает
$this.
Использование
$HtmlPruner = new HtmlPruner(); $HtmlPruner->removeRedundantClassesAfterCssInlined( $cssInliner ): self;
- $cssInliner(CssInliner) (обязательный)
- object instance that performed the CSS inlining.
Код HtmlPruner::removeRedundantClassesAfterCssInlined() HtmlPruner::removeRedundantClassesAfterCssInlined WC 10.4.3
public function removeRedundantClassesAfterCssInlined(CssInliner $cssInliner): self
{
$preg = new Preg();
$classesToKeepAsKeys = [];
foreach ($cssInliner->getMatchingUninlinableSelectors() as $selector) {
$preg->matchAll('/\\.(-?+[_a-zA-Z][\\w\\-]*+)/', $selector, $matches);
$classesToKeepAsKeys += \array_fill_keys($matches[1], true);
}
$this->removeRedundantClasses(\array_keys($classesToKeepAsKeys));
return $this;
}