Repository navigation
Fix: Video Block Preview in WP Bakery - #2130
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Resolve the analytics tracking concern and clarify or implement the audio autoplay scope.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes WPBakery inline-editor video previews by preloading GoDAM player assets.
Changes:
- Adds an inline-editor asset preload hook.
- Enqueues player scripts, styles, and the selected skin.
File summaries
| File | Summary | Findings |
|---|---|---|
inc/classes/shortcodes/class-godam-player.php |
Adds WPBakery editor asset preloading. | Moderate: Avoid preloading analytics in builder previews or add an opt-out. Nit: Address the linked issue’s audio autoplay requirement or narrow the issue scope. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
missing_composer_json_file | The "/vendor" directory using composer exists, but "composer.json" file is missing. |
📁 readme.txt (2 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 assets/build/blocks/godam-gallery-v2/render.php (2 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
15 |
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound | Global variables defined by a theme/plugin should start with the theme/plugin prefix. Found: "$inner_block_video_ids". |
23 |
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound | Global variables defined by a theme/plugin should start with the theme/plugin prefix. Found: "$inner_block_video_ids". |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/09/17/demo-post-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-page-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/09/17/demo-post-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-page-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
Code review — correctness + cleanup (medium effort)Editor-only, additive change; mechanism is sound. Two things worth addressing before merge. 1.
So analytics is not skipped, and every preview play/scrub in the editor sends real view/engagement events to the SaaS endpoint — corrupting the video's stats. Before this PR the player never initialized in the editor, so nothing fired; the fix reintroduces the player and wires up tracking with it. Note the GoDAM Image element's 2. Skin lookup is copy-pasted from The settings read + 🤖 Generated with Claude Code |
This reverts commit f769066.
Issue
Fixes #1590
Root Cause
The
godam_videoshortcode renders a static poster placeholder plus a hiddenvideothat video.js turns into the real player once godam-player-frontend-script runs. WPBakery's inline editor injects a freshly-added element via AJAX but never injects the newly-enqueued script into the running preview — so on a page that had no player before, the script was absent and the video stayed frozen on its poster (or the loading placeholder with no poster). A full reload re-rendered the shortcode in content with the script present, which is why the live player only appeared after refresh.Fix
Added preload_wpbakery_editor_assets() to class-godam-player.php, hooked on wp_enqueue_scripts (priority 20) and guarded by vc_is_inline(). It enqueues the player script, styles, and active skin up front in the inline editor. The JS side already watches for builder-injected markup (isBuilderPreview() + MutationObserver → initializePendingVideos()), so now a just-added video initializes right away. This mirrors the existing GoDAM Image element's fix for the same WPBakery quirk. Editor-only — the published front end is untouched.
Demo
Before
Screen.Recording.2026-09-17.at.11.46.00.AM.mov
After
after.mov