Make WordPress Core

Changeset 55819


Ignore:
Timestamp:
05/17/2023 11:56:47 AM (11 months ago)
Author:
SergeyBiryukov
Message:

Docs: Improve Style Engine DocBlocks per the documentation standards.

Follow-up to [54156], [55719], [55733].

See #57840.

Location:
trunk/src/wp-includes
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r55725 r55819  
    30173017 *
    30183018 * @param array $options {
    3019  *     Optional. An array of options to pass to wp_style_engine_get_stylesheet_from_context(). Default empty array.
    3020  *
    3021  *     @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
    3022  *     @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
     3019 *     Optional. An array of options to pass to wp_style_engine_get_stylesheet_from_context().
     3020 *     Default empty array.
     3021 *
     3022 *     @type bool $optimize Whether to optimize the CSS output, e.g., combine rules.
     3023 *                          Default false.
     3024 *     @type bool $prettify Whether to add new lines and indents to output.
     3025 *                          Default to whether the `SCRIPT_DEBUG` constant is defined.
    30233026 * }
    30243027 */
  • trunk/src/wp-includes/style-engine.php

    r55719 r55819  
    1212
    1313/**
    14  * Global public interface method to generate styles from a single style object, e.g.,
    15  * the value of a block's attributes.style object or the top level styles in theme.json.
    16  * See: https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#styles and
    17  * https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/
     14 * Global public interface method to generate styles from a single style object,
     15 * e.g. the value of a block's attributes.style object or the top level styles in theme.json.
    1816 *
    1917 * Example usage:
    2018 *
    21  *     $styles = wp_style_engine_get_styles( array( 'color' => array( 'text' => '#cccccc' ) ) );
     19 *     $styles = wp_style_engine_get_styles(
     20 *         array(
     21 *             'color' => array( 'text' => '#cccccc' ),
     22 *         )
     23 *     );
    2224 *
    2325 * Returns:
    2426 *
    25  *     array( 'css' => 'color: #cccccc', 'declarations' => array( 'color' => '#cccccc' ), 'classnames' => 'has-color' )
     27 *     array(
     28 *         'css'          => 'color: #cccccc',
     29 *         'declarations' => array( 'color' => '#cccccc' ),
     30 *         'classnames'   => 'has-color',
     31 *     )
    2632 *
    27  * @access public
    2833 * @since 6.1.0
     34 *
     35 * @see https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/#styles
     36 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/
    2937 *
    3038 * @param array $block_styles The style object.
     
    3240 *     Optional. An array of options. Default empty array.
    3341 *
    34  *     @type string|null $context                    An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is `null`.
    35  *                                                   When set, the style engine will attempt to store the CSS rules, where a selector is also passed.
    36  *     @type bool        $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values. Default `false`.
    37  *     @type string      $selector                   Optional. When a selector is passed, the value of `$css` in the return value will comprise a full CSS rule `$selector { ...$css_declarations }`,
    38  *                                                   otherwise, the value will be a concatenated string of CSS declarations.
     42 *     @type string|null $context                    An identifier describing the origin of the style object,
     43 *                                                   e.g. 'block-supports' or 'global-styles'. Default null.
     44 *                                                   When set, the style engine will attempt to store the CSS rules,
     45 *                                                   where a selector is also passed.
     46 *     @type bool        $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
     47 *                                                   e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
     48 *                                                   to `var( --wp--preset--* )` values. Default false.
     49 *     @type string      $selector                   Optional. When a selector is passed,
     50 *                                                   the value of `$css` in the return value will comprise
     51 *                                                   a full CSS rule `$selector { ...$css_declarations }`,
     52 *                                                   otherwise, the value will be a concatenated string
     53 *                                                   of CSS declarations.
    3954 * }
    4055 * @return array {
    41  *     @type string   $css          A CSS ruleset or declarations block formatted to be placed in an HTML `style` attribute or tag.
    42  *     @type string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     56 *     @type string   $css          A CSS ruleset or declarations block
     57 *                                  formatted to be placed in an HTML `style` attribute or tag.
     58 *     @type string[] $declarations An associative array of CSS definitions,
     59 *                                  e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    4360 *     @type string   $classnames   Classnames separated by a space.
    4461 * }
     
    8097 * Example usage:
    8198 *
    82  *     $css_rules = array( array( 'selector' => '.elephant-are-cool', 'declarations' => array( 'color' => 'gray', 'width' => '3em' ) ) );
    83  *     $css       = wp_style_engine_get_stylesheet_from_css_rules( $css_rules );
     99 *     $css_rules = array(
     100 *         array(
     101 *             'selector'     => '.elephant-are-cool',
     102 *             'declarations' => array(
     103 *                 'color' => 'gray',
     104 *                 'width' => '3em',
     105 *             ),
     106 *         ),
     107 *     );
     108 *
     109 *     $css = wp_style_engine_get_stylesheet_from_css_rules( $css_rules );
    84110 *
    85111 * Returns:
     
    94120 *     @type array ...$0 {
    95121 *         @type string   $selector     A CSS selector.
    96  *         @type string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     122 *         @type string[] $declarations An associative array of CSS definitions,
     123 *                                      e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    97124 *     }
    98125 * }
     
    100127 *     Optional. An array of options. Default empty array.
    101128 *
    102  *     @type string|null $context  An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
     129 *     @type string|null $context  An identifier describing the origin of the style object,
     130 *                                 e.g. 'block-supports' or 'global-styles'. Default 'block-supports'.
    103131 *                                 When set, the style engine will attempt to store the CSS rules.
    104  *     @type bool        $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
    105  *     @type bool        $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
     132 *     @type bool        $optimize Whether to optimize the CSS output, e.g. combine rules.
     133 *                                 Default false.
     134 *     @type bool        $prettify Whether to add new lines and indents to output.
     135 *                                 Defaults to whether the `SCRIPT_DEBUG` constant is defined.
    106136 * }
    107137 * @return string A string of compiled CSS declarations, or empty string.
     
    148178 *     Optional. An array of options. Default empty array.
    149179 *
    150  *     @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
    151  *     @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
     180 *     @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
     181 *                          Default false.
     182 *     @type bool $prettify Whether to add new lines and indents to output.
     183 *                          Defaults to whether the `SCRIPT_DEBUG` constant is defined.
    152184 * }
    153185 * @return string A compiled CSS string.
  • trunk/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php

    r55734 r55819  
    3131     *
    3232     * If a `$declarations` array is passed, it will be used to populate
    33      * the initial $declarations prop of the object by calling add_declarations().
     33     * the initial `$declarations` prop of the object by calling add_declarations().
    3434     *
    3535     * @since 6.1.0
    3636     *
    37      * @param string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     37     * @param string[] $declarations Optional. An associative array of CSS definitions,
     38     *                               e.g. `array( "$property" => "$value", "$property" => "$value" )`.
     39     *                               Default empty array.
    3840     */
    3941    public function __construct( $declarations = array() ) {
     
    103105     * @since 6.1.0
    104106     *
    105      * @param string[] $properties An array of properties.
     107     * @param string[] $properties Optional. An array of properties. Default empty array.
    106108     * @return WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods.
    107109     */
     
    131133     * @param string $property The CSS property.
    132134     * @param string $value    The value to be filtered.
    133      * @param string $spacer   The spacer between the colon and the value. Defaults to an empty string.
     135     * @param string $spacer   Optional. The spacer between the colon and the value.
     136     *                         Default empty string.
    134137     * @return string The filtered declaration or an empty string.
    135138     */
     
    147150     * @since 6.1.0
    148151     *
    149      * @param bool $should_prettify Whether to add spacing, new lines and indents.
    150      * @param int  $indent_count    The number of tab indents to apply to the rule. Applies if `prettify` is `true`.
     152     * @param bool $should_prettify Optional. Whether to add spacing, new lines and indents.
     153     *                              Default false.
     154     * @param int  $indent_count    Optional. The number of tab indents to apply to the rule.
     155     *                              Applies if `prettify` is `true`. Default 0.
    151156     * @return string The CSS declarations.
    152157     */
     
    165170            }
    166171        }
     172
    167173        return rtrim( $declarations_output );
    168174    }
  • trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php

    r55733 r55819  
    3737
    3838    /**
    39      * Constructor
     39     * Constructor.
    4040     *
    4141     * @since 6.1.0
    4242     *
    43      * @param string                                    $selector     The CSS selector.
    44      * @param string[]|WP_Style_Engine_CSS_Declarations $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`,
     43     * @param string                                    $selector     Optional. The CSS selector. Default empty string.
     44     * @param string[]|WP_Style_Engine_CSS_Declarations $declarations Optional. An associative array of CSS definitions,
     45     *                                                                e.g. `array( "$property" => "$value", "$property" => "$value" )`,
    4546     *                                                                or a WP_Style_Engine_CSS_Declarations object.
     47     *                                                                Default empty array.
    4648     */
    4749    public function __construct( $selector = '', $declarations = array() ) {
     
    6870     * @since 6.1.0
    6971     *
    70      * @param array|WP_Style_Engine_CSS_Declarations $declarations An array of declarations (property => value pairs),
    71      *                                                             or a WP_Style_Engine_CSS_Declarations object.
     72     * @param string[]|WP_Style_Engine_CSS_Declarations $declarations An array of declarations (property => value pairs),
     73     *                                                                or a WP_Style_Engine_CSS_Declarations object.
    7274     * @return WP_Style_Engine_CSS_Rule Returns the object to allow chaining of methods.
    7375     */
     
    115117     * @since 6.1.0
    116118     *
    117      * @param bool $should_prettify Whether to add spacing, new lines and indents.
    118      * @param int  $indent_count    The number of tab indents to apply to the rule. Applies if `prettify` is `true`.
     119     * @param bool $should_prettify Optional. Whether to add spacing, new lines and indents.
     120     *                              Default false.
     121     * @param int  $indent_count    Optional. The number of tab indents to apply to the rule.
     122     *                              Applies if `prettify` is `true`. Default 0.
    119123     * @return string
    120124     */
  • trunk/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php

    r55733 r55819  
    124124     *
    125125     * @param string $selector The CSS selector.
    126      * @return WP_Style_Engine_CSS_Rule|void Returns a WP_Style_Engine_CSS_Rule object, or void if the selector is empty.
     126     * @return WP_Style_Engine_CSS_Rule|void Returns a WP_Style_Engine_CSS_Rule object,
     127     *                                       or void if the selector is empty.
    127128     */
    128129    public function add_rule( $selector ) {
  • trunk/src/wp-includes/style-engine/class-wp-style-engine-processor.php

    r55733 r55819  
    6060     * @since 6.1.0
    6161     *
    62      * @param WP_Style_Engine_CSS_Rule|WP_Style_Engine_CSS_Rule[] $css_rules A single, or an array of, WP_Style_Engine_CSS_Rule objects from a store or otherwise.
     62     * @param WP_Style_Engine_CSS_Rule|WP_Style_Engine_CSS_Rule[] $css_rules A single, or an array of,
     63     *                                                                       WP_Style_Engine_CSS_Rule objects
     64     *                                                                       from a store or otherwise.
    6365     * @return WP_Style_Engine_Processor Returns the object to allow chaining methods.
    6466     */
     
    8890     *     Optional. An array of options. Default empty array.
    8991     *
    90      *     @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
    91      *     @type bool $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
     92     *     @type bool $optimize Whether to optimize the CSS output, e.g. combine rules.
     93     *                          Default false.
     94     *     @type bool $prettify Whether to add new lines and indents to output.
     95     *                          Defaults to whether the `SCRIPT_DEBUG` constant is defined.
    9296     * }
    9397     * @return string The computed CSS.
  • trunk/src/wp-includes/style-engine/class-wp-style-engine.php

    r55733 r55819  
    1111 * The main class integrating all other WP_Style_Engine_* classes.
    1212 *
    13  * The Style Engine aims to provide a consistent API for rendering styling for blocks across both client-side and server-side applications.
     13 * The Style Engine aims to provide a consistent API for rendering styling for blocks
     14 * across both client-side and server-side applications.
    1415 *
    1516 * This class is final and should not be extended.
    16  * This class is for internal Core usage and is not supposed to be used by extenders (plugins and/or themes).
    17  * This is a low-level API that may need to do breaking changes. Please, use wp_style_engine_get_styles() instead.
     17 *
     18 * This class is for internal Core usage and is not supposed to be used by extenders
     19 * (plugins and/or themes). This is a low-level API that may need to do breaking changes.
     20 * Please, use wp_style_engine_get_styles() instead.
    1821 *
    1922 * @access private
     
    2528     * Style definitions that contain the instructions to
    2629     * parse/output valid Gutenberg styles from a block's attributes.
    27      * For every style definition, the follow properties are valid:
    28      *  - classnames    => (array) an array of classnames to be returned for block styles. The key is a classname or pattern.
    29      *                    A value of `true` means the classname should be applied always. Otherwise, a valid CSS property (string)
    30      *                    to match the incoming value, e.g., "color" to match var:preset|color|somePresetSlug.
    31      *  - css_vars      => (array) an array of key value pairs used to generate CSS var values. The key is a CSS var pattern, whose `$slug` fragment will be replaced with a preset slug.
    32      *                    The value should be a valid CSS property (string) to match the incoming value, e.g., "color" to match var:preset|color|somePresetSlug.
    33      *  - property_keys => (array) array of keys whose values represent a valid CSS property, e.g., "margin" or "border".
    34      *  - path          => (array) a path that accesses the corresponding style value in the block style object.
    35      *  - value_func    => (string) the name of a function to generate a CSS definition array for a particular style object. The output of this function should be `array( "$property" => "$value", ... )`.
     30     *
     31     * For every style definition, the following properties are valid:
     32     *
     33     *  - classnames    => (array) An array of classnames to be returned for block styles.
     34     *                     The key is a classname or pattern.
     35     *                     A value of `true` means the classname should be applied always.
     36     *                     Otherwise, a valid CSS property (string) to match the incoming value,
     37     *                     e.g. "color" to match var:preset|color|somePresetSlug.
     38     *  - css_vars      => (array) An array of key value pairs used to generate CSS var values.
     39     *                     The key is a CSS var pattern, whose `$slug` fragment will be replaced with a preset slug.
     40     *                     The value should be a valid CSS property (string) to match the incoming value,
     41     *                     e.g. "color" to match var:preset|color|somePresetSlug.
     42     *  - property_keys => (array) An array of keys whose values represent a valid CSS property,
     43     *                     e.g. "margin" or "border".
     44     *  - path          => (array) A path that accesses the corresponding style value in the block style object.
     45     *  - value_func    => (string) The name of a function to generate a CSS definition array
     46     *                     for a particular style object. The output of this function should be
     47     *                     `array( "$property" => "$value", ... )`.
    3648     *
    3749     * @since 6.1.0
     
    228240
    229241    /**
    230      * Util: Extracts the slug in kebab case from a preset string, e.g., `heavenly-blue` from `var:preset|color|heavenlyBlue`.
     242     * Util: Extracts the slug in kebab case from a preset string,
     243     * e.g. `heavenly-blue` from `var:preset|color|heavenlyBlue`.
    231244     *
    232245     * @since 6.1.0
    233246     *
    234247     * @param string $style_value  A single CSS preset value.
    235      * @param string $property_key The CSS property that is the second element of the preset string. Used for matching.
     248     * @param string $property_key The CSS property that is the second element of the preset string.
     249     *                             Used for matching.
    236250     * @return string The slug, or empty string if not found.
    237251     */
    238252    protected static function get_slug_from_preset_value( $style_value, $property_key ) {
    239         if ( is_string( $style_value ) && is_string( $property_key ) && str_contains( $style_value, "var:preset|{$property_key}|" ) ) {
     253        if ( is_string( $style_value ) && is_string( $property_key )
     254            && str_contains( $style_value, "var:preset|{$property_key}|" )
     255        ) {
    240256            $index_to_splice = strrpos( $style_value, '|' ) + 1;
    241257            return _wp_to_kebab_case( substr( $style_value, $index_to_splice ) );
     
    245261
    246262    /**
    247      * Util: Generates a CSS var string, e.g., `var(--wp--preset--color--background)` from a preset string such as `var:preset|space|50`.
     263     * Util: Generates a CSS var string, e.g. `var(--wp--preset--color--background)`
     264     * from a preset string such as `var:preset|space|50`.
    248265     *
    249266     * @since 6.1.0
    250267     *
    251268     * @param string   $style_value  A single CSS preset value.
    252      * @param string[] $css_vars     An associate array of CSS var patterns used to generate the var string.
     269     * @param string[] $css_vars     An associate array of CSS var patterns
     270     *                               used to generate the var string.
    253271     * @return string The CSS var, or an empty string if no match for slug found.
    254272     */
     
    285303     *
    286304     * @param string   $store_name       A valid store key.
    287      * @param string   $css_selector     When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
    288      * @param string[] $css_declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     305     * @param string   $css_selector     When a selector is passed, the function will return
     306     *                                   a full CSS rule `$selector { ...rules }`
     307     *                                   otherwise a concatenated string of properties and values.
     308     * @param string[] $css_declarations An associative array of CSS definitions,
     309     *                                   e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    289310     */
    290311    public static function store_css_rule( $store_name, $css_selector, $css_declarations ) {
     
    309330    /**
    310331     * Returns classnames and CSS based on the values in a styles object.
     332     *
    311333     * Return values are parsed based on the instructions in BLOCK_STYLE_DEFINITIONS_METADATA.
    312334     *
     
    317339     *     Optional. An array of options. Default empty array.
    318340     *
    319      *     @type bool        $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values. Default false.
    320      *     @type string      $selector                   Optional. When a selector is passed, the value of `$css` in the return value will comprise a full CSS rule `$selector { ...$css_declarations }`,
    321      *                                                   otherwise, the value will be a concatenated string of CSS declarations.
     341     *     @type bool        $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
     342     *                                                   e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
     343     *                                                   to `var( --wp--preset--* )` values. Default false.
     344     *     @type string      $selector                   Optional. When a selector is passed,
     345     *                                                   the value of `$css` in the return value will comprise
     346     *                                                   a full CSS rule `$selector { ...$css_declarations }`,
     347     *                                                   otherwise, the value will be a concatenated string
     348     *                                                   of CSS declarations.
    322349     * }
    323350     * @return array {
    324351     *     @type string[] $classnames   Array of class names.
    325      *     @type string[] $declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     352     *     @type string[] $declarations An associative array of CSS definitions,
     353     *                                  e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    326354     * }
    327355     */
     
    356384
    357385    /**
    358      * Returns classnames, and generates classname(s) from a CSS preset property pattern, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`.
    359      *
    360      * @since 6.1.0
    361      *
    362      * @param string $style_value      A single raw style value or CSS preset property from the `$block_styles` array.
     386     * Returns classnames, and generates classname(s) from a CSS preset property pattern,
     387     * e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`.
     388     *
     389     * @since 6.1.0
     390     *
     391     * @param string $style_value      A single raw style value or CSS preset property
     392     *                                 from the `$block_styles` array.
    363393     * @param array  $style_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA.
    364394     * @return string[] An array of CSS classnames, or empty array if there are none.
     
    403433     *     Optional. An array of options. Default empty array.
    404434     *
    405      *     @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g.,
    406      *                                            `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values.
    407      *                                            Default false.
     435     *     @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
     436     *                                            e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
     437     *                                            to `var( --wp--preset--* )` values. Default false.
    408438     * }
    409      * @return string[] An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     439     * @return string[] An associative array of CSS definitions, e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    410440     */
    411441    protected static function get_css_declarations( $style_value, $style_definition, $options = array() ) {
     
    481511     *
    482512     * @param array $style_value                    A single raw style value from `$block_styles` array.
    483      * @param array $individual_property_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA representing an individual property of a CSS property, e.g., 'top' in 'border-top'.
     513     * @param array $individual_property_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA
     514     *                                              representing an individual property of a CSS property,
     515     *                                              e.g. 'top' in 'border-top'.
    484516     * @param array $options                        {
    485517     *     Optional. An array of options. Default empty array.
    486518     *
    487      *     @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to `var( --wp--preset--* )` values. Default false.
     519     *     @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns,
     520     *                                            e.g. `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`,
     521     *                                            to `var( --wp--preset--* )` values. Default false.
    488522     * }
    489      * @return string[] An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
     523     * @return string[] An associative array of CSS definitions, e.g. `array( "$property" => "$value", "$property" => "$value" )`.
    490524     */
    491525    protected static function get_individual_property_css_declarations( $style_value, $individual_property_definition, $options = array() ) {
     
    495529
    496530        /*
    497          * The first item in $individual_property_definition['path'] array tells us the style property, e.g., "border".
    498          * We use this to get a corresponding CSS style definition such as "color" or "width" from the same group.
    499          * The second item in $individual_property_definition['path'] array refers to the individual property marker, e.g., "top".
     531         * The first item in $individual_property_definition['path'] array
     532         * tells us the style property, e.g. "border". We use this to get a corresponding
     533         * CSS style definition such as "color" or "width" from the same group.
     534         *
     535         * The second item in $individual_property_definition['path'] array
     536         * refers to the individual property marker, e.g. "top".
    500537         */
    501538        $definition_group_key    = $individual_property_definition['path'][0];
     
    515552            if ( $style_definition && isset( $style_definition['property_keys']['individual'] ) ) {
    516553                // Set a CSS var if there is a valid preset value.
    517                 if ( is_string( $value ) && str_contains( $value, 'var:' ) && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] ) ) {
     554                if ( is_string( $value ) && str_contains( $value, 'var:' )
     555                    && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] )
     556                ) {
    518557                    $value = static::get_css_var_value( $value, $individual_property_definition['css_vars'] );
    519558                }
    520                 $individual_css_property                      = sprintf( $style_definition['property_keys']['individual'], $individual_property_key );
     559
     560                $individual_css_property = sprintf( $style_definition['property_keys']['individual'], $individual_property_key );
     561
    521562                $css_declarations[ $individual_css_property ] = $value;
    522563            }
     
    530571     * @since 6.1.0
    531572     *
    532      * @param string[] $css_declarations An associative array of CSS definitions, e.g., `array( "$property" => "$value", "$property" => "$value" )`.
    533      * @param string   $css_selector     When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
     573     * @param string[] $css_declarations An associative array of CSS definitions,
     574     *                                   e.g. `array( "$property" => "$value", "$property" => "$value" )`.
     575     * @param string   $css_selector     When a selector is passed, the function will return
     576     *                                   a full CSS rule `$selector { ...rules }`,
     577     *                                   otherwise a concatenated string of properties and values.
    534578     * @return string A compiled CSS string.
    535579     */
     
    554598     * @since 6.1.0
    555599     *
    556      * @param WP_Style_Engine_CSS_Rule[] $css_rules An array of WP_Style_Engine_CSS_Rule objects from a store or otherwise.
     600     * @param WP_Style_Engine_CSS_Rule[] $css_rules An array of WP_Style_Engine_CSS_Rule objects
     601     *                                              from a store or otherwise.
    557602     * @param array                      $options   {
    558603     *     Optional. An array of options. Default empty array.
    559604     *
    560      *     @type string|null $context  An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
     605     *     @type string|null $context  An identifier describing the origin of the style object,
     606     *                                 e.g. 'block-supports' or 'global-styles'. Default 'block-supports'.
    561607     *                                 When set, the style engine will attempt to store the CSS rules.
    562      *     @type bool        $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
    563      *     @type bool        $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
     608     *     @type bool        $optimize Whether to optimize the CSS output, e.g. combine rules.
     609     *                                 Default false.
     610     *     @type bool        $prettify Whether to add new lines and indents to output.
     611     *                                 Defaults to whether the `SCRIPT_DEBUG` constant is defined.
    564612     * }
    565613     * @return string A compiled stylesheet from stored CSS rules.
Note: See TracChangeset for help on using the changeset viewer.