Theming Layer Guide

Data Machine has two theming surfaces because it renders in two different runtimes:

SurfaceRuntimeConsumer
CSS custom propertiesBrowserAdmin UI, frontend widgets, block UIs
BrandTokens PHP filterServer-side PHP/GDImage templates rendered by datamachine/render-image-template

Use CSS custom properties when the browser paints the UI. Use BrandTokens when PHP renders pixels before the browser sees the output.

Pick A Surface

I am building…UseWhy
wp-admin screensCSS custom propertiesBrowser CSS can read --datamachine-* tokens directly.
frontend chat or widgetsCSS custom propertiesSite themes can override or bridge browser tokens.
block-editor or block-rendered UICSS custom propertiesBlocks render in a browser CSS environment.
OG cards or generated imagesBrandTokensGD cannot read CSS variables while rendering server-side.
email-ready generated imagesBrandTokensThe image is rasterized before browser CSS exists.

Do not use a PHP filter to style browser UI. Do not use CSS variables as the only source for GD image templates.

CSS Tokens

Browser-rendered interfaces read tokens from inc/Core/Admin/assets/css/root.css.

Core tokens:

TokenPurpose
--datamachine-text-primaryPrimary text
--datamachine-text-secondarySecondary text
--datamachine-text-mutedMuted text
--datamachine-border-1Primary border
--datamachine-border-2Secondary border
--datamachine-border-dashedStandard dashed border
--datamachine-border-dottedStandard dotted border
--datamachine-bg-lightLight background
--datamachine-bg-lighterLighter background
--datamachine-blueCore blue accent
--datamachine-color-successSuccess state
--datamachine-color-errorError state
--datamachine-color-warningWarning state
--datamachine-color-neutralNeutral state
--datamachine-spacing-xs8px spacing
--datamachine-spacing-sm12px spacing
--datamachine-spacing-md16px spacing
--datamachine-spacing-lg24px spacing
--datamachine-spacing-xl40px spacing
--datamachine-border-radiusShared radius

Themes and plugins can bridge site tokens into Data Machine tokens:

css
:root {
    --datamachine-text-primary: var(--wp--preset--color--foreground);
    --datamachine-text-secondary: var(--wp--preset--color--contrast-2);
    --datamachine-bg-light: var(--wp--preset--color--base-2);
    --datamachine-blue: var(--wp--preset--color--primary);
    --datamachine-border-radius: var(--wp--custom--radius--small);
}

Consumers should read the Data Machine token names, not site-specific names. That keeps Data Machine UI portable across themes.

BrandTokens

Server-side image templates read DataMachineAbilitiesMediaBrandTokens.

GD cannot read CSS variables, web fonts, or browser-computed styles. Templates call BrandTokens::get(), BrandTokens::color(), or BrandTokens::font() and receive plain PHP values.

Core token shape:

KeyPurpose
colors.backgroundDefault light background
colors.background_darkDefault dark background
colors.surfaceCard or panel surface
colors.accentPrimary accent
colors.accent_hoverAccent hover/variant
colors.accent_2Secondary accent
colors.accent_3Tertiary accent
colors.text_primaryPrimary text
colors.text_mutedMuted text
colors.text_inverseText over dark/accent backgrounds
colors.header_bgHeader background
colors.borderBorders and separators
fonts.headingAbsolute path to heading TTF/OTF
fonts.bodyAbsolute path to body TTF/OTF
fonts.brandAbsolute path to brand TTF/OTF
fonts.monoAbsolute path to monospace TTF/OTF
logo_pathAbsolute path to logo image
brand_textBrand name text
site_labelSite or network label

Example bridge:

php
use DataMachineAbilitiesMediaBrandTokens;

add_filter(
    'datamachine/image_template/brand_tokens',
    static function ( array $tokens, string $template_id, $context ): array {
        $tokens['colors']['background']   = '#ffffff';
        $tokens['colors']['accent']       = '#0073aa';
        $tokens['colors']['text_primary'] = '#111111';
        $tokens['brand_text']             = get_bloginfo( 'name' );
        $tokens['logo_path']              = get_stylesheet_directory() . '/assets/logo.png';
        $tokens['fonts']['heading']       = get_stylesheet_directory() . '/assets/fonts/Heading.ttf';

        return $tokens;
    },
    10,
    3
);

$accent = BrandTokens::color( 'accent', 'event_og_card' );

Font paths must point to TTF or OTF files. GD cannot render WOFF2 directly.

Alignment Rules

Data Machine keeps the two surfaces logically aligned, not mechanically identical.

  • New generic browser tokens should have an equivalent BrandTokens value when server-rendered images need the same concept.
  • New BrandTokens values should have an equivalent CSS custom property when browser-rendered UI needs the same concept.
  • Consumer plugins should not redefine a generic token that Data Machine already publishes.
  • Site-specific values should bridge into Data Machine’s token names instead of replacing the token vocabulary.

If a third theming surface appears, consider moving the shared logical token catalog to a generated source. Until then, parallel explicit surfaces are simpler than build-time indirection.