WP_Style_Engine_CSS_Rules_Store::add_rule()publicWP 6.1.0

Gets a WP_Style_Engine_CSS_Rule object by its selector. If the rule does not exist, it will be created.

Метод класса: WP_Style_Engine_CSS_Rules_Store{}

Хуков нет.

Возвращает

WP_Style_Engine_CSS_Rule|null. Returns a WP_Style_Engine_CSS_Rule object, or null if the selector is empty.

Использование

$WP_Style_Engine_CSS_Rules_Store = new WP_Style_Engine_CSS_Rules_Store();
$WP_Style_Engine_CSS_Rules_Store->add_rule( $selector );
$selector(строка) (обязательный)
The CSS selector.

Список изменений

С версии 6.1.0 Введена.

Код WP_Style_Engine_CSS_Rules_Store::add_rule() WP 6.1.1

public function add_rule( $selector ) {
	$selector = trim( $selector );

	// Bail early if there is no selector.
	if ( empty( $selector ) ) {
		return;
	}

	// Create the rule if it doesn't exist.
	if ( empty( $this->rules[ $selector ] ) ) {
		$this->rules[ $selector ] = new WP_Style_Engine_CSS_Rule( $selector );
	}

	return $this->rules[ $selector ];
}