Gets preset values keyed by slugs based on settings and metadata.
Description
$settings = array(
'typography' => array(
'fontFamilies' => array(
array(
'slug' => 'sansSerif',
'fontFamily' => '"Helvetica Neue", sans-serif',
),
array(
'slug' => 'serif',
'colors' => 'Georgia, serif',
)
),
),
);
$meta = array(
'path' => array( 'typography', 'fontFamilies' ),
'value_key' => 'fontFamily',
);
$values_by_slug = get_settings_values_by_slug();
// $values_by_slug === array(
// 'sans-serif' => '"Helvetica Neue", sans-serif',
// 'serif' => 'Georgia, serif',
// );
Parameters
$settings
arrayrequired- Settings to process.
$preset_metadata
arrayrequired- One of the PRESETS_METADATA values.
$origins
string[]required- List of origins to process.
Source
) {
foreach ( $spacing_rules as $spacing_rule ) {
$declarations = array();
if (
isset( $spacing_rule['selector'] ) &&
preg_match( $layout_selector_pattern, $spacing_rule['selector'] ) &&
! empty( $spacing_rule['rules'] )
) {
// Iterate over each of the styling rules and substitute non-string values such as `null` with the real `blockGap` value.
foreach ( $spacing_rule['rules'] as $css_property => $css_value ) {
$current_css_value = is_string( $css_value ) ? $css_value : $block_gap_value;
if ( static::is_safe_css_declaration( $css_property, $current_css_value ) ) {
$declarations[] = array(
'name' => $css_property,
'value' => $current_css_value,
);
}
}
if ( ! $has_block_gap_support ) {
// For fallback gap styles, use lower specificity, to ensure styles do not unintentionally override theme styles.
$format = static::ROOT_BLOCK_SELECTOR === $selector ? ':where(.%2$s%3$s)' : ':where(%1$s.%2$s%3$s)';
$layout_selector = sprintf(
$format,
$selector,
$class_name,
$spacing_rule['selector']
);
} else {
$format = static::ROOT_BLOCK_SELECTOR === $selector ? ':root :where(.%2$s)%3$s' : ':root :where(%1$s-%2$s)%3$s';
$layout_selector = sprintf(
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.