WP_Style_Engine::get_individual_property_css_declarations( array $style_value, array $individual_property_definition, array $options = array() ): string[]
- Since
- 6.1.0
- Source
wp-includes/style-engine/class-wp-style-engine.php:679
Description
Example:
"$style_property-$individual_feature: $value;" Which could represent the following:
"border-{top|right|bottom|left}-{color|width|style}: {value};" or:
"border-image-{outset|source|width|repeat|slice}: {value};"Compatibility
- WordPress
- since 6.1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$style_valuearray- A single raw style value from
$block_stylesarray. $individual_property_definitionarray- A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA representing an individual property of a CSS property, e.g. 'top' in 'border-top'.
$optionsarrayoptional- An array of options. Default empty array.Default:
array()$convert_vars_to_classnamesbooldefault: falseWhether to skip converting incoming CSS var patterns, e.g.var:preset|<PRESET_TYPE>|<PRESET_SLUG>, tovar( --wp--preset--* )values.
Return value
string[]- An associative array of CSS definitions, e.g.
array( "$property" => "$value", "$property" => "$value" ).
Performance profile
How much work a call to WP_Style_Engine::get_individual_property_css_declarations() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Light
- Scaling
- Scales with input
- Instructions
- 6–23
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 65.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Style_Engine::get_individual_property_css_declarations() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 6–23 | none |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 65 | 6–23 | 13 | |
| 8.5 | 65 | 6–23 | 13 | |
| 8.4 | 65 | 6–23 | 13 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 68 | 6–23 | 13 | |
| 8.2 | 68 | 6–23 | 13 | |
| 8.1 | 68 | 6–23 | 13 | |
| 7.4 | 68 | 6–23 | 13 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 3
- _wp_array_get()Accesses an array in depth based on a path of keys.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- static::get_css_var_value()
Source code
protected static function get_individual_property_css_declarations( $style_value, $individual_property_definition, $options = array() ) { if ( ! is_array( $style_value ) || empty( $style_value ) || empty( $individual_property_definition['path'] ) ) { return array(); } /* * The first item in $individual_property_definition['path'] array * tells us the style property, e.g. "border". We use this to get a corresponding * CSS style definition such as "color" or "width" from the same group. * * The second item in $individual_property_definition['path'] array * refers to the individual property marker, e.g. "top". */ $definition_group_key = $individual_property_definition['path'][0]; $individual_property_key = $individual_property_definition['path'][1]; $should_skip_css_vars = isset( $options['convert_vars_to_classnames'] ) && true === $options['convert_vars_to_classnames']; $css_declarations = array(); foreach ( $style_value as $css_property => $value ) { if ( empty( $value ) ) { continue; } // Build a path to the individual rules in definitions. $style_definition_path = array( $definition_group_key, $css_property ); $style_definition = _wp_array_get( static::BLOCK_STYLE_DEFINITIONS_METADATA, $style_definition_path, null ); if ( $style_definition && isset( $style_definition['property_keys']['individual'] ) ) { // Set a CSS var if there is a valid preset value. if ( is_string( $value ) && str_contains( $value, 'var:' ) && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] ) ) { $value = static::get_css_var_value( $value, $individual_property_definition['css_vars'] ); } $individual_css_property = sprintf( $style_definition['property_keys']['individual'], $individual_property_key ); $css_declarations[ $individual_css_property ] = $value; } } return $css_declarations; }Changelog
Introduced in 6.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/style-engine/class-wp-style-engine.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.