How it works
The blocks
| Block | Kind | Source |
|---|---|---|
glidepress/slider |
Static: markup and options saved in the post | src/blocks/slider/ |
glidepress/slide |
Static | src/blocks/slide/ |
glidepress/query (Query Slides) |
Dynamic: rendered per request | src/blocks/query/, includes/QuerySlides.php |
glidepress/overlay (Fixed Content) |
Static | src/blocks/overlay/ |
jw/slider, jw/slide |
1.x names, hidden, kept so old posts parse | src/blocks/legacy/ |
From editor to page
- Editor (
edit.js): the sidebar writes block attributes. Every change goes throughcorrect()(corrections.js), which adds what a change implies (a fade pins one slide on screen, autoplay brings back the pause button). It only runs on an author's change, never when a post opens. - Save (
save.js): attributes become markup, CSS custom properties and adata-swiper-configJSON attribute. This output is a contract with every post already published (see Block validity). - Render (PHP, per request): passes over the saved markup add what shouldn't be
frozen into a post:
Render.php: translations of the saved English labels, theglidepress_slider_configfilter, layout variables, video postersSlides.php: image loading hints, responsive background images, slide links, shape dividersPreload.php: the preload link for the first slider's opening imageQuerySlides.php: one copy of the template slide per postKses.php: keeps a slider intact when an author withoutunfiltered_htmlsaves
- Browser (
view.js): readsdata-swiper-config, rebuilds it from an allowlist (config.js), and builds Swiper once the slider nears the screen.
The front-end script
view.js decides whether and when to build, and keeps the list of things to undo
when a slider is taken down. Everything else is a small module with its own tests:
- Pure decisions:
loop.js,peek.js,device.js,autoplay-state.js,dom.js - Wiring with Swiper:
overflow-runtime.js(peeking edges),autoplay-control.js(pause button and holds),media.js(pausing video),keyboard-owner.js(which slider gets the arrow keys),nearby.js(loading the next images) - Optional features, each loaded only by the sliders that need them, from
build/blocks/slider/features/: transitions (effects.js),thumbnails.js,marquee.js(the ticker),hash.js(links to slides),track.js(wide-screen peeking loops)
features.js works out which features a slider needs and loads their scripts before
building it. Their URLs come from Plugin::feature_urls().
Trust
data-swiper-config lives in post content, so it is only as trustworthy as the least
trusted person who can edit the post. config.js therefore rebuilds the options key by
key from an allowlist instead of handing parsed JSON to Swiper. A new option must be
added there. Every numeric range and colour fallback lives in schema.js, which the
editor, save.js and config.js all read.
Editor preview
The editor doesn't run Swiper (it would fight React for the DOM). The slides are a CSS
grid that canvas.js pages through. Live preview posts the block's markup to
POST /glidepress/v1/preview (Preview.php), which renders it the way the page would
and shows the result in a same-origin frame running the real front-end script.
Strings
The front-end script never loads @wordpress/i18n: that would add two render-blocking
scripts to every page with a slider. Plugin::view_strings() prints its translated
strings inline, and strings.js holds the English fallbacks; a new front-end string
goes in both. Editor strings use __() as usual, and every file that calls it must be
mapped to its bundle in bin/i18n-map.json.