Ensure compat WP 7+ : enqueue assets for shared blocks - #17
Conversation
…module handling - Updated `enqueue_embedded_block_assets` to accept `view_script_module_ids` and enqueue them correctly. - Modified `get_rendered_block` and `RenderBlockRestController` to include `view_script_module_ids` in the response. - Added methods to capture and manage script module IDs during shared block rendering. - Improved documentation for clarity and consistency.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e377236. Configure here.
| * | ||
| * @return array rendered block data. | ||
| * @psalm-return array{html: string, use_block_types: string[], block_support_styles:string, post_title:string, post_permalink:string} | ||
| * @psalm-return array{html: string, use_block_types: string[], view_script_module_ids: string[], block_support_styles:string, post_title:string, post_permalink:string} |
There was a problem hiding this comment.
Stale cache omits script modules
Medium Severity
get_rendered_block returns site transients as-is, and MULTISITE_SHARED_BLOCKS_CACHE_VERSION stays 1. Existing never-expiring entries have no view_script_module_ids, so the consumer falls back to an empty list. Conditionally enqueued modules captured by the renderer will not load until each cache entry is deleted.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e377236. Configure here.


Note
Medium Risk
Changes front-end asset loading for embedded shared blocks across sites; behavior depends on block registry data and WordPress script-module APIs, with a reflection fallback that could break on internal WP changes.
Overview
Fixes embedded multisite shared blocks missing styles, scripts, and view script modules on consumer sites when the source site uses newer WordPress block registration (handles arrays and
wp_enqueue_script_module).On the source site, the render REST endpoint now records which script modules were enqueued during rendering (including modules only added in render callbacks, e.g. PDF preview) and returns them as
view_script_module_idsalongsideuse_block_types, with stricter string filtering for both lists.On the consumer site, full-display rendering delegates dependency loading to
enqueue_embedded_block_assets, which enqueues all registered style/script/view handles for collected block types plus the captured module IDs, instead of the legacy singlescript/styleproperties. Module enqueue is skipped whenwp_enqueue_script_moduleis unavailable.Module queue inspection uses
get_queue()on WP 6.9+ and falls back to reflection on older versions.Reviewed by Cursor Bugbot for commit e377236. Bugbot is set up for automated code reviews on this repo. Configure here.