WooCommerce Code Reference

AtRuleSet extends RuleSet
in package
implements AtRule

This class represents rule sets for generic at-rules which are not covered by specific classes, i.e., not `@import`, `@charset` or `@media`.

A common example for this is @font-face.

Interfaces, Classes and Traits

AtRule

Table of Contents

$aRules  : array<string, array<int<0, max>, Rule>>
the rules in this rule set, using the property name as the key, with potentially multiple rules per property name.
$sArgs  : string
$sType  : string
__construct()  : mixed
__toString()  : string
addComments()  : void
addRule()  : void
atRuleArgs()  : string
atRuleName()  : string
getComments()  : array<string, Comment>
getRules()  : array<int, Rule>
Returns all rules matching the given rule name
getRulesAssoc()  : array<string, Rule>
Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys. This method exists mainly for backwards-compatibility and is really only partially useful.
removeAllRules()  : mixed
removeMatchingRules()  : mixed
Removes rules by property name or search pattern.
removeRule()  : mixed
Removes a `Rule` from this `RuleSet` by identity.
render()  : string
setComments()  : void
setRules()  : void
Overrides all the rules of this set.
renderRules()  : string

Properties

Methods

getRules()

Returns all rules matching the given rule name

public getRules([Rule|string|null $mRule = null ]) : array<int, Rule>
Parameters
$mRule : Rule|string|null = null

Pattern to search for. If null, returns all rules. If the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. Passing a Rule for this parameter is deprecated in version 8.9.0, and will not work from v9.0. Call getRules($rule->getRule()) instead.

Tags
example

$oRuleSet->getRules('font') // returns array(0 => $oRule, …) or array().

example

$oRuleSet->getRules('font-') //returns an array of all rules either beginning with font- or matching font.

Return values
array<int, Rule>

getRulesAssoc()

Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys. This method exists mainly for backwards-compatibility and is really only partially useful.

public getRulesAssoc([Rule|string|null $mRule = null ]) : array<string, Rule>

Note: This method loses some information: Calling this (with an argument of background-) on a declaration block like { background-color: green; background-color; rgba(0, 127, 0, 0.7); } will only yield an associative array containing the rgba-valued rule while getRules() would yield an indexed array containing both.

Parameters
$mRule : Rule|string|null = null

$mRule Pattern to search for. If null, returns all rules. If the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. Passing a Rule for this parameter is deprecated in version 8.9.0, and will not work from v9.0. Call getRulesAssoc($rule->getRule()) instead.

Return values
array<string, Rule>

removeMatchingRules()

Removes rules by property name or search pattern.

public removeMatchingRules(string $searchPattern) : mixed
Parameters
$searchPattern : string

pattern to remove. If the pattern ends in a dash, all rules starting with the pattern are removed as well as one matching the pattern with the dash excluded.

Return values
mixed

removeRule()

Removes a `Rule` from this `RuleSet` by identity.

public removeRule(Rule|string|null $mRule) : mixed
Parameters
$mRule : Rule|string|null

Rule to remove. Passing a string or null is deprecated in version 8.9.0, and will no longer work from v9.0. Use removeMatchingRules() or removeAllRules() instead.

Return values
mixed