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
// Allow outputting fallback gap styles for flex and grid layout types when block gap support isn't available.
if ( ! $has_block_gap_support && 'flex' !== $layout_definition_key && 'grid' !== $layout_definition_key ) {
continue;
}
$class_name = isset( $layout_definition['className'] ) ? $layout_definition['className'] : false;
$spacing_rules = isset( $layout_definition['spacingStyles'] ) ? $layout_definition['spacingStyles'] : array();
if (
! empty( $class_name ) &&
! empty( $spacing_rules )
) {
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 ) {
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.