Changeset 55819 for trunk/src/wp-includes/style-engine.php
- Timestamp:
- 05/17/2023 11:56:47 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/style-engine.php
r55719 r55819 12 12 13 13 /** 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. 18 16 * 19 17 * Example usage: 20 18 * 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 * ); 22 24 * 23 25 * Returns: 24 26 * 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 * ) 26 32 * 27 * @access public28 33 * @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/ 29 37 * 30 38 * @param array $block_styles The style object. … … 32 40 * Optional. An array of options. Default empty array. 33 41 * 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. 39 54 * } 40 55 * @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" )`. 43 60 * @type string $classnames Classnames separated by a space. 44 61 * } … … 80 97 * Example usage: 81 98 * 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 ); 84 110 * 85 111 * Returns: … … 94 120 * @type array ...$0 { 95 121 * @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" )`. 97 124 * } 98 125 * } … … 100 127 * Optional. An array of options. Default empty array. 101 128 * 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'. 103 131 * 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. 106 136 * } 107 137 * @return string A string of compiled CSS declarations, or empty string. … … 148 178 * Optional. An array of options. Default empty array. 149 179 * 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. 152 184 * } 153 185 * @return string A compiled CSS string.
Note: See TracChangeset
for help on using the changeset viewer.