design-system.php
Stores shared design variables and classes, validates style values, tracks their uses, checks revision conflicts, and emits public CSS.
Responsibility#
Stores shared design variables and classes, validates style values, tracks their uses, checks revision conflicts, and emits public CSS.
This is an implementation reference for the released 0.9.13 module. Internal PHP helpers are not a compatibility promise for third-party callers. Prefer the documented REST, Abilities, theme, and filter contracts.
Related modules#
Module constants#
const CANTATA_EDIT_DESIGN_SYSTEM_LIMIT = 500;
These values describe this release. Defined configuration constants and generated identifiers can have different ownership; do not edit stored values directly without following the corresponding workflow.
Literal option and cache keys#
cantata_edit_design_system. These are direct literal keys found in this module; dynamically constructed keys and metadata constants are covered by the storage reference.
WordPress hooks#
| Operation | Hook |
|---|---|
add_action |
wp_enqueue_scripts |
add_action |
rest_api_init |
add_action and add_filter subscribe to a hook; do_action and apply_filters expose a hook. A subscription is not itself a new extension API. Dynamic hook names are not included in this literal inventory.
Function and method reference#
cantata_edit_design_system_empty#
function cantata_edit_design_system_empty(): array
Internal implementation helper in this module. Its name and signature identify the operation and accepted PHP values; it is not a standalone authenticated endpoint.
Source location: includes/design-system.php:19.
cantata_edit_design_system#
function cantata_edit_design_system(): array
The stored design system, checked again on the way out (an invalid store shows as empty rather than half-applied).
Implementation connections: cantata_edit_design_system_empty, cantata_edit_design_system_validate.
Source location: includes/design-system.php:24.
cantata_edit_design_system_rev#
function cantata_edit_design_system_rev( ?array $ds = null ): string
The revision a save must name: a hash of what is stored.
Implementation connections: cantata_edit_design_system.
Source location: includes/design-system.php:34.
cantata_edit_variable_types#
function cantata_edit_variable_types(): array
The property a variable's value is checked against: color, font family or a length.
Source location: includes/design-system.php:39.
cantata_edit_class_style_keys#
function cantata_edit_class_style_keys(): array
The keys a class's styles may have: normal (Desktop), hover, focus and each screen size with its states.
Implementation connections: cantata_edit_visual_attributes.
Source location: includes/design-system.php:44.
cantata_edit_design_system_validate#
function cantata_edit_design_system_validate( array $input )
A design system made valid or refused as a whole, before anything is written: ids of eight lowercase letters or digits, unique; names 1 to 60 characters, unique per kind (case does not count); types and values checked; class styles only through the visual property list. Returns the clean design system or WP_Error naming the item.
Implementation connections: cantata_edit_class_style_keys, cantata_edit_design_system_empty, cantata_edit_normalize_colours, cantata_edit_responsive_declarations, cantata_edit_variable_types.
Source location: includes/design-system.php:53.
cantata_edit_design_system_css#
function cantata_edit_design_system_css( ?array $ds = null ): string
The design system as CSS: the variables on :root, then each class's rules in order, Desktop first, then each size that is on.
Implementation connections: cantata_edit_design_system, cantata_edit_screen_media, cantata_edit_screens, cantata_edit_visual_attributes.
Source location: includes/design-system.php:125.
cantata_edit_design_system_usage#
function cantata_edit_design_system_usage( array $ds ): array
Where each variable and class is used: pages, posts, shared parts and templates (published or not) and saved drafts. [ id => [ count, where: [ titles ] ] ]. Read-only; counts references, not elements.
Source location: includes/design-system.php:185.
cantata_edit_can_design#
function cantata_edit_can_design(): bool
Internal implementation helper in this module. Its name and signature identify the operation and accepted PHP values; it is not a standalone authenticated endpoint.
Implementation connections: cantata_edit_can_dev, cantata_edit_design_system, cantata_edit_design_system_css, cantata_edit_design_system_rev, cantata_edit_design_system_usage, cantata_edit_design_system_validate.
Source location: includes/design-system.php:207.