Developer Hooks and CSS Variables

Mawu has filters and actions for developers who want to add themes, change the schedule, style the visitor switch or limit who can change settings. This page lists them. All of them are in the free plugin unless marked Pro.

Make your admin screens match Mawu

If you build a plugin, use Mawu’s CSS variables with your normal colour as the fallback. Your screens are then dark from the first paint for anyone on a Mawu theme, and unchanged for everyone else.

background: var(--mawu-surface, #fff);
color: var(--mawu-text, #1d2327);

Available: --mawu-bg, --mawu-surface, --mawu-surface-alt, --mawu-border, --mawu-text, --mawu-text-muted, --mawu-accent and --mawu-link. They are set on <body> only when the person viewing uses a Mawu theme.

Themes

HookTypeWhat it does
mawu_palette_themesfilterAdd or change themes. Each theme is a label plus 12 colours as #rrggbb, with an optional on_accent text colour.
mawu_palette_collectionsfilterGroup themes into collections. Every theme ends up in exactly one collection.
mawu_theme_assetfilterChange the stylesheet Mawu uses for a theme (admin colours, block editor canvas, Classic Editor, login page).
mawu_palette_for_userfilterChange a theme’s colours for one person. Pro’s intensity and OLED black use it.
mawu_selectable_themesfilterLimit which themes a person can pick. An empty answer means no limit, so a list is never empty.

Schedule

HookTypeWhat it does
mawu_schedule_settingsfilterRead or extend a person’s schedule settings.
mawu_schedule_sanitizefilterClean extra schedule fields when the schedule is saved.
mawu_dark_hours_nowfilterDecide whether a person’s schedule is dark right now.
mawu_schedule_window_endfilterWhen the current dark window ends.
mawu_schedule_statusfilterThe status line, for example “Dark now, until 07:00.”
mawu_schedule_summaryfilterThe summary line at the top of the settings page.
mawu_hours_fieldsactionPrint extra fields in the Schedule panel’s form.

Settings page

HookTypeWhat it does
mawu_brand_namefilterThe plugin’s name in the menu and page titles. White-label uses it.
mawu_show_promotionsfilterReturn false to hide the rating note, review links and the Mawu Pro block.
mawu_settings_capabilityfilterThe capability for each part of the settings (see below).
mawu_hub_after_sectionactionPrint your own section after one of the page’s sections.
mawu_hub_preview_argsfilterChange the drawn admin preview and its caption.
mawu_hub_page_sectionsactionPrint a section at the end of the Tools panel.
mawu_quick_switch_availablefilterHide the dark mode button and shortcut for a person or a screen.

Capabilities

mawu_settings_capability receives the capability and a context:

ContextDefaultCovers
hubmanage_optionsThe Mawu page
optionsmanage_optionsSite-wide settings
ratingmanage_optionsThe rating note
use_themereadPicking a theme and the quick switch (on top of editing your own profile)
hoursreadSaving your own schedule
theme_buildermanage_optionsThe theme builder (Pro)

An empty answer falls back to the default.

Export and import

HookTypeWhat it does
mawu_export_datafilterAdd your own settings to the export file.
mawu_import_datafilterRead your settings back on import, and add rows to the preview.
mawu_transfer_labelsfilterReadable names for your settings in the import preview.

Visitor dark mode and the switch

HookTypeWhat it does
mawu_frontend_enabledfilterTurn visitor dark mode off for a request, for example on one section of your site.
mawu_frontend_theme_mapsfilterAdd or change the colour map for a classic theme.
mawu_frontend_image_dimfilterHow much photos dim in dark mode (0.5 to 1). Logos and SVG images are never dimmed.
mawu_frontend_logofilterAn image shown as the logo in dark mode.
mawu_frontend_image_swapfilterExtra light-to-dark image swaps.
mawu_frontend_toggle_stylesfilterAdd a switch design to the Design list.
mawu_frontend_design_iconsfilterThe small drawing for each design in the Design list.
mawu_frontend_switch_markupfilterChange the switch’s classes, style, icons, text and accessible name.
mawu_frontend_switch_settingsfilterClean your own switch settings when they are saved.
mawu_frontend_switch_transfer_fieldsfilterInclude your switch settings in export, import and sync.
mawu_frontend_switch_fieldsactionPrint fields in the Switch group.
mawu_frontend_switch_placeactionPrint a row under the corner and distance fields.
mawu_frontend_extra_fieldsactionPrint fields in the “Never darken and photos” group.
mawu_frontend_groupsactionPrint a whole group in the Frontend panel.
mawu_frontend_preview_toolsactionPrint buttons in the preview toolbar.

Dark versions of images (Pro)

Add data-mawu-dark-src, data-mawu-dark-srcset or data-mawu-dark-poster to an <img> or <video>, or data-mawu-dark-bg to an element with an inline background image. Mawu Pro swaps them while a visitor has dark mode on.

?mawu=dark, ?mawu=light and ?mawu=auto work on any page of the site. They are handled in the browser, so page caches don’t vary.

Pro

HookTypeWhat it does
mawu_effect_packsfilterAdd a seasonal effect pack, with its theme collection, season and script.
mawu_sync_client_ipfilterThe client address settings sync rate-limits by. Use it behind a proxy, and read only a header your own proxy sets.

Questions

Ask in the support forum if you need a hook that isn’t here.

Enjoying Mawu? Rate it on WordPress.org (opens in a new tab)