Repository navigation
Commit 105e176
* test(layers): add Layer API contract tests and RFC draft
Pin down how layers behave today, so the Layer API refactor (#2290) can
move core layer types onto a registry and prove nothing changed:
- Editor: the data each core type starts with, the add-on menu and
creator path, media-type gating, settings-panel selection, and the
window globals add-ons use.
- Player: which manager gets each layer, add-on managers, validation,
and the shared front-end registry and queue.
- Image block: which saved layers reach the browser, and how the image
renderer draws hotspot and woo layers.
Tests marked "current behaviour" pin what the refactor intends to
change on purpose.
Also add the RFC draft (docs/rfcs/layer-api.md) with the audit of every
reader of saved layers, and keep /docs/ out of the release package.
Refs #2291
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(layers): keep GoDAM Central out of the Layer API RFC
The Layer API EPIC covers the plugin only. Central adopts the API from
the plugin once it lands, so drop the open question about Central's
player and say so in the RFC's scope.
Refs #2291
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ci: run unit tests on PRs into the Layer API base branch
Every Layer API PR (#2290) targets feature/layer-api, which neither the
JS nor the PHP unit-test workflow listed, so those PRs got no unit
tests. Remove the entries once feature/layer-api is merged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(layers): mark the Layer API RFC accepted
Accepted as written. D1 now separates the keys GoDAM manages (id,
type, name, displayTime) from shared keys a layer type may give its
own default (duration, allow_skip, custom_css, trigger, watchDepth),
which core types already rely on.
Refs #2291
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit afa0664)
* feat(layers): add the Layer API editor registry
Add a layer type registry the editor and add-ons share (#2292):
- `godam-layers` script (`window.godam.layers`, `@godam/layers`): a
`godam/layers` wp-data store with registerLayerType(),
unregisterLayerType() and the `godam.layers.registerLayerType` filter.
- Core layer types (CTA, Hotspot, Form, Poll, Ad) register through it,
with metadata in assets/src/layers/<type>/layer.json. Form plugins are
variations of the Form type; Form's save check is its validate().
- The add menu, settings panel, layer list, header, timeline, save
validation and image gating read the registry. Removes
utils/layerTypes.js and the allowedLayerTypes allowlist.
- Add-on types from the old hooks (godam_video_editor_layer_options and
friends) are bridged into the registry, so godam-for-woo is unchanged.
- `window.godam.layerEditor` (`godam-layer-editor` handle) gives add-on
panels useLayer() / useLayerAttributes() and the shared controls.
- A saved layer whose type isn't registered stays in the list with a
warning and opens a "needs an add-on" notice instead of the CTA
editor (RFC D2).
Timeline chips for Marketo and HubSpot form layers now name the form
plugin; they showed "Gravity Forms" before.
Refs #2292
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(layers): register form providers as Form layer variations
Each of the 12 form plugins is now one registerLayerVariation( 'form', … )
call carrying its title, icon, availability, panel, form-ID field and
settings URL, replacing the FormLayerComponentType table. Add-ons can
register their own provider; one without a panel supplies getForms() and
getFormHtml( id ) and gets a shared FormProviderPanel. A form layer whose
provider isn't registered shows a notice instead of an error.
Adds registerLayerVariation, unregisterLayerVariation,
getLayerVariationByName and getUnavailableReason to the registry. A
variation registered before its type is kept and added later.
Editor only; the player and PHP parts move to #2294 and #2295.
Refs #2293
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(layers): run video and image layers on one front-end runtime
Adds the Layer API front-end runtime (#2294): registerLayerRuntime( name,
{ validate, mount, supports, usesIconFont, variations } ) on
window.godam.layers, plus a layer host that mounts each saved layer and
forwards player events (onReady, onTimeUpdate, onPause, onEnded, onPlay,
onResize, onFullscreenChange, onReplay, destroy) to the handlers mount()
returns. ctx.api gives pause, play, seek, show, hide, track and
isSuppressed.
- LayersManager and render-image-frame both mount through the host and no
longer branch on layer type names.
- CTA, Form, Poll and Hotspot are core runtimes; CTA, Form and Poll share
one FormLayerManager, which now takes a per-type behaviour.
- The 12 form providers register their front-end part as Form variations:
availability, "submitted" detection and analytics label. This replaces
LayerValidator, FORM_TYPES and hasConfirmationMessage.
- Hover-preview suppression covers every runtime, including layers from
GoDAMAPI.createLayer() (RFC D5), which now mount on the same host.
- window.godamLayerRegistry is a shim over the new registry, and still
drains window.godamLayerRegistryQueue. The window store workaround is
gone, and godam-for-woo's manager runs unchanged on video and images.
- An unregistered type is logged once and skipped (RFC D2).
Refs #2294
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(layers): register layer types in PHP and render them through callbacks
Adds the PHP half of the Layer API (#2295):
- godam_register_layer_type( $path_or_metadata, $args ) on a new godam_init
action, reading layer.json, with the godam_layer_type_metadata filter, and
godam_register_layer_variation() / godam_get_layer_type() /
godam_render_layer().
- render_callback( $layer, $instance_id, $context ) prints a layer's
container. The core CTA, Form, Poll and Hotspot types carry the markup the
player template printed inline, so godam-player.php loops over
godam_render_layer() with no layer type names. Add-on output goes through
wp_kses_post() unless the type sets supports.rawHtml (RFC D3).
- The 12 form providers register their PHP part as Form variations: render
callback and is_available. godamPluginDependencies is now built from each
type's and provider's is_available.
- godam/image sends the layers whose type supports images and has something
to draw (should_render), instead of hard-coding hotspot and woo.
- The ad tag is requested for layers whose type supports adTag. Typeless
layers no longer warn there.
- A type with no PHP registration still renders through the old
godam_player_render_layer action, and the Woo layer is registered as a
legacy type until #2296 moves godam-for-woo over.
Sanitizing on save, localizing PHP metadata to the editor and per-page
script loading follow in a second PR for #2295.
Refs #2295
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(layers): clean layers on save, and load layer scripts only where used
Second part of #2295:
- Saving rtgodam_meta cleans each layer against its type's declared
attributes (RFC D3, Layer_Sanitizer). Add-on types are strict: declared
values are sanitized by type and format (plain, html, url, color), a wrong
type falls back to the default, and undeclared keys are dropped. Core
types stay lenient (keep_undeclared_attributes) until their layer.json
lists every attribute: they keep undeclared keys, mismatched values and
HTML (escaped at render) as saved. Unregistered types are kept unchanged.
- Attributes marked "private": true are left out of the player's
data-options and the image block's layer data.
- layer.json editorScript and viewScript ("file:./…" or a handle) are
registered as scripts. Editor scripts load in the video editor; a view
script loads only when a layer of its type renders. A new
godam-layer-runtime script handle exposes the front-end runtime registry
for add-on view scripts.
- The video editor gets each PHP-registered type's metadata and
availability (godamVideoEditorConfig.layerTypes / layerAvailability), and
registerLayerType() fills in that metadata, so an add-on can register by
name. The videoData *Active form flags now come from the registry.
Refs #2295
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(layers): deprecate the old add-on layer hooks behind shims
Part of #2296. The hooks the Layer API replaces keep working, fed into the
registry, and log a deprecation notice. They are deprecated since 2.7.0 and
removed in 2.9.0:
- PHP: godam_video_editor_layer_options and
godam_video_editor_layer_components (apply_filters_deprecated), and
godam_player_render_layer (do_action_deprecated).
- JS: window.godamLayerComponents, window.godamLayerCreators,
window.godamVideoEditorActions and
window.godamLayerRegistry.registerLayerType(), each logging one console
notice per page.
So godam-for-woo can register its own `woo` type:
- The legacy `woo` registration runs late on godam_init, after add-ons.
- The editor accepts the `woo` name without a namespace, because saved
layers use it.
- Panels get a useMediaType() hook.
- The analytics page reads add-on icons from layer types registered through
the API.
Refs #2296
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(layers): add the Layer API developer guide
docs/layer-api.md, for add-on developers (#2297):
- how a layer type fits together
- a quick-start countdown layer plugin
- the layer.json reference
- the PHP, editor and front-end runtime references
- form providers
- the saved data shape and analytics
- moving from the deprecated hooks
- troubleshooting
Refs #2297
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(layers): give each core layer type its own folder, built like core blocks
GoDAM's core layer types now follow the structure an add-on layer type
uses, the way Gutenberg's block-library holds each core block:
assets/src/layers/<type>/
layer.json metadata, with "viewScript": "file:./view.js"
<type>.php render callback + godam_register_layer_type()
editor.js registerLayerType() settings
edit.js the settings panel (moved from pages/video-editor)
view.js registerLayerRuntime() (moved from godam-player/layers)
A new `layers` webpack config builds each view.js (with its
view.asset.php) into assets/build/layers/<type>/ and copies layer.json and
the PHP beside it. Core_Layer_Types loads each type from the build, falling
back to the source when the plugin isn't built.
- View scripts load only on pages that show that layer type (Gutenberg
viewScript behaviour), instead of being bundled into the player and image
scripts. The image script drops from 33 KB to 16.5 KB.
- The block editor and the Elementor and WPBakery editors, which draw
layers without the page rendering them, enqueue the view scripts up front.
- The shared FormLayerManager behind CTA, Form and Poll stays in the
player bundle. The views only add their layers to it.
- whenLayerRuntime() lets a player or image mount a layer whose view script
loads after it started (deferred or delayed JS).
- The registry only registers built file: scripts (with an *.asset.php),
sets their translations, and prefixes core handles with godam-layer-.
- assets/src/layers is left out of the release; it ships from
assets/build/layers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(layers): note why the core layer loader includes variable paths
PHPCS (WordPressVIPMinimum) flags both includes. Each path is built by the
plugin: the core loader from its layer folder and fixed type list, the
registry from a registered layer.json's built *.asset.php.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(layers): give layer.json stylesheets and translations, like block.json
- Support `style`, `viewStyle` and `editorStyle` (a handle or `file:./x.css`,
string or array). `file:` styles register with their path and `-rtl.css`
twin; `style` + `viewStyle` load wherever view scripts do, `style` +
`editorStyle` with the editor scripts, and image types' view styles reach
the block editor canvas through `enqueue_block_assets`.
- Translate `title`, `description` and variation strings with the type's
`textdomain` and gettext context, as core does for block.json, falling back
to the same string without a context. The editor prefers these over the
untranslated layer.json strings its script imports.
- Point script translations at GoDAM's languages folder only for GoDAM's own
layer.json files; add-ons use WordPress's default lookup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(blocks): register the player styles on init so they reach the editor canvas
The block editor collects its canvas styles before `admin_enqueue_scripts`,
where `godam-player-wrapper-style` was registered. `godam-player-style`
(tied to godam/image with wp_enqueue_block_style) had an unregistered
dependency there, so WordPress dropped it, and with it every stylesheet that
depends on it. The Woo product-hotspot popup rendered unstyled in the
godam/image preview: its product image filled the canvas.
Register both handles on `init` through GoDAM_Player::register_player_styles().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Date the Layer API deprecations to 2.8.0
develop is at 2.8.0 and 2.7.0 is already released, so the Layer API ships
in 2.8.0. The old add-on hooks are deprecated since 2.8.0 and removed two
minor releases later, in 2.10.0. Updates the PHP and JS notices, the
developer guide and the tests that assert the notice text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fix four Layer API review findings
- Image hotspots drawn twice: when the hotspot view script registers
after an image frame rendered, the host calls the shared onReady once
per late layer. onReady now redraws into a fresh wrapper and removes
the previous one, and destroy() clears it.
- Form layers that couldn't be saved: FormProviderPanel saved the form
ID under `form_id` when a provider set no idField, but the save check
only read idField. Both now use getFormIdField().
- The `color` attribute format let extra CSS through, e.g.
`rgb(0);position:fixed)`. It now uses rtgodam_sanitize_css_color().
- Variation icons: any string was drawn as an <img>, so a Dashicon name
such as the guide's `icon: 'feedback'` was a broken image. Variations
now split `icon` / `iconUrl` the way layer types do.
The Jest asset mock now returns a URL-shaped path, as the build does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address PR #2345 review feedback
- Form save check: a layer whose form provider isn't registered (its
add-on is inactive) no longer blocks saving the attachment; a layer
without form_type is checked as the default provider, as PHP reads it.
- Late form scripts: the Form view registers the core providers before
its runtime, so layers waiting for the runtime pass validate. Layers
whose variation registers later (an add-on provider) are mounted then,
through the new whenLayerRuntimeVariation().
- custom_css: saved as written again, as on develop. wp_strip_all_tags()
cut CSS at any `<` (`@media (width<=600px)`, `content: "<"`); only
`</style` is removed now.
- An add-on's validate() or usesIconFont() that throws is logged and
treated as false, so the other layers still mount.
- Variation attributes are compared by value in the editor and runtime,
so array or object values match saved layers.
- FormProviderPanel doesn't fetch a preview for an unavailable provider.
- The godam_player_render_layer deprecation is reported before output
buffering, so a WP_DEBUG notice isn't printed into the layer markup.
- phpcs:ignore for the runtime script's asset include.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Import Layer API classes and load core layers from RTGODAM_PATH
- Layer_Type_Registry (and REST_API\Jetpack in the form providers) is
imported with `use` instead of written as a fully qualified name.
- The core layer files (ad, cta, form, hotspot, poll) find their
layer.json and class-form-providers.php through
Core_Layer_Types::get_layers_dir(), built on RTGODAM_PATH, instead of
__DIR__. get_layers_dir() now returns the folder register() is loading
from, so a type's PHP, layer.json and the view.js it names come from
the same build or source folder.
- untrailingslashit() stub for the PHPUnit run.
Add-on examples in docs/layer-api.md and layer-functions.php keep
__DIR__, which is right for code that lives in another plugin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Mark the form providers include as reviewed for VIP PHPCS
rtBot flagged WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
on the require_once added in 08a8401. The path is the plugin's own
core layer folder (RTGODAM_PATH based) plus a fixed filename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: KMchaudhary <kuldipkumar.chaudhary@rtcamp.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d10b364 commit 105e176
144 files changed
Lines changed: 12170 additions & 2129 deletions
File tree
- assets/src
- blocks/godam-image
- js
- godam-image-layers
- godam-layers
- runtime
- godam-player
- api
- layers
- managers
- layers
- utils
- layers
- ad
- cta
- form
- hotspot
- poll
- bin/jest
- docs
- rfcs
- inc
- classes
- layers
- rest-api
- shortcodes
- helpers
- templates
- pages
- video-editor
- components
- forms
- layers
- timeline
- config
- layers
- redux/slice
- utils
- tests
- fixtures/layers
- acme-countdown
- build
- built-core
- js
- php
- stubs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
86 | 81 | | |
87 | 82 | | |
88 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
114 | | - | |
115 | | - | |
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
| |||
148 | 145 | | |
149 | 146 | | |
150 | 147 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 148 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
169 | 172 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
249 | 188 | | |
250 | | - | |
251 | | - | |
252 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
253 | 199 | | |
254 | 200 | | |
255 | 201 | | |
256 | 202 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 203 | + | |
265 | 204 | | |
266 | 205 | | |
267 | 206 | | |
| |||
274 | 213 | | |
275 | 214 | | |
276 | 215 | | |
277 | | - | |
| 216 | + | |
278 | 217 | | |
279 | 218 | | |
280 | | - | |
281 | | - | |
| 219 | + | |
| 220 | + | |
282 | 221 | | |
283 | 222 | | |
284 | 223 | | |
| |||
313 | 252 | | |
314 | 253 | | |
315 | 254 | | |
316 | | - | |
| 255 | + | |
317 | 256 | | |
318 | 257 | | |
319 | 258 | | |
| |||
0 commit comments