API / Minn\Theme / StyleSettings

StyleSettings final class

Minn\Theme\StyleSettings · public/minn/src/Minn/Theme/StyleSettings.php · 88 lines

The settings and styles nodes as wp/v2/global-styles reports them: preset lists keyed by the origin that declared them, appearanceTools spelled out as the flags it stands for, and var:preset tokens resolved to the custom properties they name. Pure: a node in, a node out.

Constants and properties

privatePRESET_PATHS = array ( 0 => array ( 0 => 'color', 1 => 'palette', ), 1 => array ( 0 => 'color', 1 => 'gradients', ), 2 => array ( 0 => 'color', 1 => 'duotone', ), 3 => array ( 0 => 'typography', 1 => 'fontSizes', ), 4 => array ( 0 => 'typography', 1 => 'fontFamilies', ), 5 => array ( 0 => 'spacing', 1 => 'spacingSizes', ), 6 => array ( 0 => 'shadow', 1 => 'presets', ), 7 => array ( 0 => 'dimensions', 1 => 'aspectRatios', ), 8 => array ( 0 => 'dimensions', 1 => 'dimensionSizes', ), )

Where a settings node keeps preset lists, at its root and under each block.

privateAPPEARANCE_TOOLS = array ( 'background' => array ( 0 => 'backgroundImage', 1 => 'backgroundSize', 2 => 'gradient', ), 'border' => array ( 0 => 'color', 1 => 'radius', 2 => 'style', 3 => 'width', ), 'color' => array ( 0 => 'link', 1 => 'heading', 2 => 'button', 3 => 'caption', ), 'dimensions' => array ( 0 => 'aspectRatio', 1 => 'height', 2 => 'minHeight', 3 => 'minWidth', 4 => 'width', ), 'position' => array ( 0 => 'sticky', ), 'spacing' => array ( 0 => 'blockGap', 1 => 'margin', 2 => 'padding', ), 'typography' => array ( 0 => 'lineHeight', 1 => 'textColumns', ), )

What appearanceTools switches on, group by group in the order the reference appends the groups it has to add; a group already present keeps its place and gains the flags at its end.

Public

staticnormalize(array $settings, string $origin): array#

A settings node as written (theme.json, a variation, or the site editor's post) with its presets keyed by origin and appearanceTools expanded.

$originstringtheme for a theme's file, custom for the site editor's
staticpresetsByOrigin(array $settings, string $origin): array#

The preset lists, at the root and under each block, keyed by the origin given; nothing else changed.

staticresolved(array $node): array#

Every var:preset|kind|slug token replaced by the custom property it names.

Internals 2

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatepresetsUnder(array $node, string $origin): array#
privatewithAppearanceTools(array $settings): array#

The flag itself goes; a flag the node already sets keeps its value.