Automattic\WooCommerce\Vendor\Pelago\Emogrifier\Css
CssDocument::isValidAtRuleToRender
Tests if a CSS rule is an at-rule that should be passed though and copied to a <style> element unmodified:
@charsetrules are discarded - only UTF-8 is supported -falseis returned;@importrules are passed through only if they satisfy the specification ("user agents must ignore any '@import' rule that occurs inside a block or after any non-ignored statement other than an '@charset' or an '@import' rule");@mediarules are processed separately to see if their nested rules apply -falseis returned;@font-facerules are checked for validity - they must contain both asrcandfont-familyproperty;- other at-rules are assumed to be valid and treated as a black box -
trueis returned.
Method of the class: CssDocument{}
No Hooks.
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->isValidAtRuleToRender( $rule ): bool;
- $rule(CssRenderable) (required)
- .
CssDocument::isValidAtRuleToRender() CssDocument::isValidAtRuleToRender code WC 10.4.3
private function isValidAtRuleToRender(CssRenderable $rule): bool
{
if ($rule instanceof CssCharset) {
return false;
}
if ($rule instanceof CssImport) {
return $this->isImportRuleAllowed;
}
$this->isImportRuleAllowed = false;
if (!$rule instanceof CssAtRule) {
return false;
}
switch ($rule->atRuleName()) {
case 'media':
$result = false;
break;
case 'font-face':
$result = $rule instanceof CssRuleSet
&& $rule->getRules('font-family') !== []
&& $rule->getRules('src') !== [];
break;
default:
$result = true;
}
return $result;
}