WP_Style_Engine_CSS_Rules_Store::add_rule() – Gets a WP_Style_Engine_CSS_Rule object by its selector.

You appear to be a bot. Output may be restricted

Description

Gets a WP_Style_Engine_CSS_Rule object by its selector.

If the rule does not exist, it will be created.

Usage

$WP_Style_Engine_CSS_Rule|void = WP_Style_Engine_CSS_Rules_Store::add_rule( $selector );

Parameters

$selector
( string ) required – The CSS selector.

Returns

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

Source

File name: wordpress/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php


Lines:

1 to 16 of 16
  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 ];
  }
 

 View on GitHub View on Trac