Make WordPress Core


Ignore:
Timestamp:
05/03/2024 04:45:20 AM (10 months ago)
Author:
isabel_brison
Message:

Editor: add Style Engine support for nested CSS rules.

Adds support for passing a $rules_group string to wp_style_engine_get_stylesheet_from_css_rules(), so rules can be nested under a media query, layer or other rule.

Props isabel_brison, ramonopoly.
Fixes #61099.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/style-engine/class-wp-style-engine.php

    r57491 r58089  
    365365     *
    366366     * @since 6.1.0
     367     * @since 6.6.0 Added the `$rules_group` parameter.
    367368     *
    368369     * @param string   $store_name       A valid store key.
     
    372373     * @param string[] $css_declarations An associative array of CSS definitions,
    373374     *                                   e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    374      */
    375     public static function store_css_rule( $store_name, $css_selector, $css_declarations ) {
     375     * @param string $rules_group        Optional. A parent CSS selector in the case of nested CSS, or a CSS nested @rule,
     376     *                                   such as `@media (min-width: 80rem)` or `@layer module`.
     377     */
     378    public static function store_css_rule( $store_name, $css_selector, $css_declarations, $rules_group = '' ) {
    376379        if ( empty( $store_name ) || empty( $css_selector ) || empty( $css_declarations ) ) {
    377380            return;
    378381        }
    379         static::get_store( $store_name )->add_rule( $css_selector )->add_declarations( $css_declarations );
     382        static::get_store( $store_name )->add_rule( $css_selector, $rules_group )->add_declarations( $css_declarations );
    380383    }
    381384
Note: See TracChangeset for help on using the changeset viewer.