Skip to content

Fix: Ensure player styles are correctly enqueued for image shortcode - #2121

Merged
KMchaudhary merged 4 commits into
mainfrom
hotfix/image-video-block-style-qneueue-conflicts
Sep 15, 2026
Merged

KMchaudhary merged 4 commits into
mainfrom
hotfix/image-video-block-style-qneueue-conflicts

Conversation

@KMchaudhary

@KMchaudhary KMchaudhary commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

This pull request addresses a CSS dependency issue that could cause incorrect video sizing when both image and video blocks or shortcodes are present on a page. The changes ensure that the godam-player-wrapper-style (which contains the aspect-ratio and poster rules) is always loaded as a dependency for the player and image components, regardless of registration order. This prevents missing styles and layout issues.

Dependency and style loading improvements:

  • In class-blocks.php, the godam-player-style block style now explicitly declares a dependency on godam-player-wrapper-style, ensuring the wrapper CSS is always loaded, even if style registration order varies between classic and block themes.
  • In class-godam-image.php, both the preload_wpbakery_editor_assets and render methods now explicitly enqueue godam-player-wrapper-style alongside godam-player-style and godam-image-style, guaranteeing that the required aspect-ratio and poster rules are present for shortcodes as well as blocks. [1] [2]
Screenshot 2026-09-14 at 7 42 32 PM
Screen.Recording.2026-09-15.at.10.39.39.AM.mov

Ensure the godam-player-wrapper-style will always enque regardless of godam-player-style style was enqued by image or video block
Copilot AI balanced review requested due to automatic review settings September 14, 2026 14:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The style dependency is consistently applied across the affected block, shortcode, and editor paths.

Pull request overview

Ensures player wrapper CSS loads reliably for image blocks and shortcodes, preventing video sizing issues caused by style registration order.

Changes:

  • Adds wrapper CSS as a player-style dependency for image blocks.
  • Explicitly enqueues wrapper CSS for image shortcode and WPBakery paths.
File summaries
File Description
inc/classes/class-blocks.php Declares the wrapper stylesheet dependency.
inc/classes/shortcodes/class-godam-image.php Enqueues wrapper styles for shortcode rendering.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
16 0 16

⚠️ Warnings (16)

📁 composer.json (1 warning)
📍 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/15/hello-world/ (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/sample-page/ (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/15/hello-world/ (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/sample-page/ (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

@subodhr258

subodhr258 commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Reviewed. Correct fix, verified end to end. I traced the mechanism against WP core and the plugin boot order, and the diagnosis and the fix both hold.

Why the fix is right

  • On a classic theme, core's wp_common_block_scripts_and_styles is hooked on wp_enqueue_scripts (priority 10) and registered before any plugin loads, so it runs first in that batch and fires enqueue_block_assets. That runs the wp_enqueue_block_style( 'godam/image', ... ) callback, which registers godam-player-style first. Player::register_scripts() runs later in the same priority-10 batch, so its wp_register_style( 'godam-player-style', ..., array( 'godam-player-wrapper-style' ) ) is a silent no-op and the wrapper dep was dropped pre-fix. Declaring deps at the block-style site closes the gap. Diagnosis is accurate.
  • godam-player-wrapper-style is registered by Player::register_scripts(), and GoDAM_Player boots unconditionally in class-plugin.php, so on both the front end (wp_enqueue_scripts) and admin (admin_enqueue_scripts) the dependency always resolves at print time. No risk of the new hard dep silently dropping godam-player-style.
  • Build target assets/build/css/godam-player-wrapper.css is present. The block-theme path (on-demand assets) registers via render_block with the same deps, so it is covered too.

Two small, non-blocking notes

  1. The explicit wp_enqueue_style( 'godam-player-wrapper-style' ) added in both class-godam-image.php methods is now redundant: after this change every registration site of godam-player-style declares the wrapper dep, so enqueuing godam-player-style alone pulls the wrapper in. It is harmless defense-in-depth and the rationale is documented, so keep it if you want the margin; just flagging that removing those two lines would change nothing.
  2. Worth a small PHPUnit test that runs the enqueue hooks and asserts godam-player-style carries godam-player-wrapper-style in its registered deps. The race is subtle enough that a guard test would catch a future re-registration or hook-order regression cheaply.

LGTM.

@subodhr258 subodhr258 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Fix verified end to end against WP core and the plugin boot order; the wrapper dependency now resolves at print time in both classic and block themes. The two notes on the review comment are optional and non-blocking.

subodhr258
subodhr258 previously approved these changes Sep 14, 2026
… builds

This will solves the woo layers not rendering if godam image, and video blocks exist on same page with woo layers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The frontend shortcode path may enqueue wrapper styles after wp_head, so the promised sizing CSS is not guaranteed.

Review details

Suppressed comments (1)

inc/classes/shortcodes/class-godam-image.php:149

  • This enqueue is still inside render(), which normally runs while the_content is rendered after wp_head; the only earlier preload returns unless vc_is_inline() is true. On a normal frontend [godam_image] shortcode, godam-player-wrapper-style can therefore be queued too late to be printed, so this does not guarantee the promised sizing CSS. Register/enqueue this handle on an earlier frontend hook (or explicitly arrange a footer-safe output path) for pages that can contain the shortcode.
		wp_enqueue_style( 'godam-player-wrapper-style' );
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

subodhr258
subodhr258 previously approved these changes Sep 15, 2026

@subodhr258 subodhr258 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the post-approval commit e198496 (layer-registry.js). This is a separate fix from the CSS enqueue work: it moves the layer registry into a shared window store so every godam-player bundle reads the same registrations, instead of each entry bundle keeping a private module-scoped registry. That correctly fixes Woo hotspots not rendering when a godam/image and a godam/video block share a page (before this, only the bundle that drained godamLayerRegistryQueue populated its own copy, and the other bundle's getLayerManager() read an empty registry).

Checked:

  • Every accessor now routes through getStore(); nothing still points at the old module-scoped object.
  • The render gate (layersManager -> getLayerManager() -> new customManagerClass) reads the shared store, so the fix reaches the real code path, not just registration.
  • No in-repo addLayerRegistryHook callers, so sharing the hooks array does not cause double-firing.
  • assets/build/ is gitignored, so the src-only change is correct.

Approving. Two non-blocking follow-ups:

  1. Please update the PR title/description. They still describe only the CSS enqueue change, not this layer-registry fix, which is the larger part now.
  2. Minor/latent: __godamLayerRegistryStore is an unversioned key, so it is shared across bundle versions that co-load during an upgrade (old cached bundle + newly served bundle on the same page). No issue today since the store shape is stable; worth namespacing the key by version if that shape ever changes.

On the Copilot note about class-godam-image.php enqueuing the wrapper style inside render(): styles enqueued during the_content are printed in the footer, so the CSS is still applied, and all three styles there share the same timing. Fine as is; an earlier frontend hook would only remove a possible brief layout shift.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The explicit shortcode stylesheet enqueues described by the PR are absent, leaving the fix incomplete.

Review details

Suppressed comments (1)

inc/classes/class-blocks.php:84

  • The shortcode portion described in this PR is not present in the submitted changes: class-godam-image.php still has both preload_wpbakery_editor_assets() and render() enqueue only godam-image-style and godam-player-style. This block-style dependency does not itself add the explicit wrapper enqueue for shortcode paths, so a pre-registered godam-player-style without this dependency can still leave the shortcode without the wrapper CSS; add the two shortcode enqueues (or include the equivalent change) before relying on this fix.
					'deps'   => array( 'godam-player-wrapper-style' ),
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

Copilot AI review requested due to automatic review settings September 15, 2026 06:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The shortcode style paths remain uncovered, and the cross-bundle registry behavior needs documentation and testing.

Review details

Suppressed comments (2)

assets/src/js/godam-player/utils/layer-registry.js:19

  • This hunk changes cross-bundle add-on registration semantics by introducing a window-persistent global store, but neither the PR description nor the v2.2.2 changelog mentions this behavior. It is a separate runtime change from the stylesheet dependency fix and can affect every custom-layer add-on; please split it into a focused PR or document and test the mixed-bundle load-order contract before merging.
const STORE_KEY = '__godamLayerRegistryStore';

inc/classes/class-blocks.php:84

  • This dependency is applied only to the godam/image block-style registration. The shortcode enqueue paths in inc/classes/shortcodes/class-godam-image.php still enqueue godam-player-style without godam-player-wrapper-style, so the shortcode half of the stated fix is not present; in a shortcode-only or builder path that does not run this block-style callback, the aspect-ratio/poster CSS is still not guaranteed. Please add the wrapper enqueue to both preload_wpbakery_editor_assets() and render() (or otherwise make the shared registration cover those paths).
					'deps'   => array( 'godam-player-wrapper-style' ),
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.

@subodhr258 subodhr258 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Reviewed both changes end to end and the fix is correct.

class-blocks.php Declaring godam-player-wrapper-style as a dep of the godam/image block's godam-player-style registration correctly mirrors the canonical registration in class-godam-player.php. On a page carrying both a godam/video and a godam/image block, enqueue_block_assets registered godam-player-style first on classic themes, so the canonical wp_register_style() (which carries the wrapper dep) became a silent no-op and the wrapper CSS was dropped, leaving the video poster at its natural oversized height. Declaring the same dep in both places makes it registration-order independent. The wrapper handle is registered unconditionally by the always-booted player shortcode class, so it resolves at print time, and WordPress drops an unregistered dep silently, so there is no regression risk.

layer-registry.js Moving the store to a window-backed singleton is the right fix and at the right altitude. The player build and the image-layers build each carry their own module copy of this file; with a module-local store, if the image build won the init race the Woo manager registered into the image build's store while the player's own getLayerManager() read an empty store, so Woo hotspots never rendered on the video. Routing every accessor through getStore() makes all copies read and write one shared store regardless of bundle load order. The non-browser fallback is fine, and nothing depends on the old store reference.

Non-blocking notes:

  1. The PR description still documents the class-godam-image.php enqueue approach, which was reverted in "Remove redundant player wrapper style enqueue in GoDAM Image shortcode". Please update the description to the current two-part fix (block-style dep plus shared registry store) so the squash-merge record is accurate.
  2. "Run PHPCS inspection" is red because the action hit the GitHub API rate limit (x-ratelimit-remaining: 0) and aborted before scanning, not because of a violation. PHPCS is clean locally on both files. Re-run that job to get it green before merging.
  3. Optional: consider a "Fix:" changelog line for v2.2.2, since the oversized poster and the missing Woo hotspots are user visible.

@KMchaudhary
KMchaudhary merged commit 172852f into main Sep 15, 2026
11 of 12 checks passed
@KMchaudhary
KMchaudhary deleted the hotfix/image-video-block-style-qneueue-conflicts branch September 15, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants