Skip to content

Data, APIs, and persistence

How brand and theme data are stored

Appearance (brand name and logos)

  • Endpoint: GET and POST /wp-json/fleekdash/v1/settings/appearance. Response includes at least: logo, dark_logo, brand_name (and possibly other keys such as enable_animations, enable_shadows, enable_rounded_corners if re-enabled in the UI).

  • On load: The Appearance page fetches this data and populates the form. On success, it can set window.FleekDash.appearanceSettings and dispatch fleekdash:appearanceSettingsChanged so the sidebar and other consumers update the brand name and logos without a full reload.

  • On save: POST sends the current form values; on success, the same global update is applied and a success toast is shown. On failure, an error toast is shown.

Themes and palettes

  • Themes list: From the WordPress bridge themes API (e.g. themesAPI.list()), used by useThemesQuery(). Returns available themes (bundled and custom) with metadata and palette references.

  • Theme detail: themesAPI.get(themeId) used by useThemeQuery(themeId) returns a single theme with its palettes. Each palette has id, name, description, source (bundled/custom/synced), modes (e.g. light, dark) with color variables. Palettes are merged with preset definitions (e.g. from palette-presets) and filtered (e.g. auto-generated variables removed) for editing.

  • Active theme settings: useActiveThemeSettings() loads the backend's active theme and palette (and optionally other settings). This is the source of truth for "current theme" and "current palette" shown in the drawer and on the Appearance summary.

  • Apply theme / update palette: Mutations such as useApplyTheme, useUpdatePalette, useCreatePalette, useDeletePalette (and corresponding API calls) persist theme selection and palette changes. On success, the query client invalidates theme/palette queries so the UI and Appearance page stay in sync.

  • Palette sync: Optional palette sync with WordPress (e.g. themesAPI.paletteSync.get()) for syncing a palette to a WordPress theme key; used when you see "Synced" or "WP: …" in the UI.

Caching: Theme list and detail use React Query with a sensible stale time (e.g. 5 minutes for list). Palette list may use staleTime: 0 and refetchOnMount: "always" so the drawer always gets fresh data when opened.

Benefit: Backend is the single source of truth; frontend stays in sync via APIs and cache invalidation; global appearance (brand + logos) and theme/palette are consistent for all users.