WP_Theme_JSON::get_property_value( array $styles, array $path, array $theme_json = null ): string|array

In this article

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

$stylesarrayrequired
Styles subtree.
$patharrayrequired
Which property to process.
$theme_jsonarrayoptional
Theme JSON array.

Default:null

Return

string|array Style property value.

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

VersionDescription
6.3.0It 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.0Added the $theme_json parameter.
5.9.0Added support for values of array type, which are returned as is.
5.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.