Returns the style property for the given path.
Description
It also converts references to a path to the value stored at that location, e.g.
{ "ref": "style.color.background" } => "#fff".
Parameters
$styles
arrayrequired- Styles subtree.
$path
arrayrequired- Which property to process.
$theme_json
arrayoptional- Theme JSON array.
Default:
null
Source
if ( ! empty( $outer ) && ! empty( $inner ) ) {
$selectors_scoped[] = $outer . ' ' . $inner;
} elseif ( empty( $outer ) ) {
$selectors_scoped[] = $inner;
} elseif ( empty( $inner ) ) {
$selectors_scoped[] = $outer;
}
}
}
$result = implode( ', ', $selectors_scoped );
return $result;
}
/**
* Scopes the selectors for a given style node.
*
* This includes the primary selector, i.e. `$node['selector']`, as well as any custom
* selectors for features and subfeatures, e.g. `$node['selectors']['border']` etc.
*
* @since 6.6.0
*
* @param string $scope Selector to scope to.
* @param array $node Style node with selectors to scope.
* @return array Node with updated selectors.
*/
protected static function scope_style_node_selectors( $scope, $node ) {
$node['selector'] = static::scope_selector( $scope, $node['selector'] );
if ( empty( $node['selectors'] ) ) {
return $node;
}
foreach ( $node['selectors'] as $feature => $selector ) {
if ( is_string( $selector ) ) {
$node['selectors'][ $feature ] = static::scope_selector( $scope, $selector );
}
if ( is_array( $selector ) ) {
foreach ( $selector as $subfeature => $subfeature_selector ) {
$node['selectors'][ $feature ][ $subfeature ] = static::scope_selector( $scope, $subfeature_selector );
}
}
}
return $node;
Changelog
Version | Description |
---|---|
6.3.0 | It no longer converts the internal format "var:preset|color|secondary " to the standard form "–wp–preset–color–secondary".This is already done by the sanitize method, so every property will be in the standard form. |
6.1.0 | Added the $theme_json parameter. |
5.9.0 | Added support for values of array type, which are returned as is. |
5.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.