Skip to content

WP Build Polyfills: force-replace boot and theme on WP 7.0 - #50309

Closed
retrofox wants to merge 3 commits into
trunkfrom
fix/wp-build-polyfills-boot-initmodules-wp-7
Closed

retrofox wants to merge 3 commits into
trunkfrom
fix/wp-build-polyfills-boot-initmodules-wp-7

Conversation

@retrofox

@retrofox retrofox commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

  • Force-replace @wordpress/boot on WP < 7.1 when Gutenberg is inactive or older than 23.5.0.
    Core 7.0 ships a boot module whose initSinglePage() ignores initModules, so wp-build page init hooks never run even though templates pass them through.
  • Force-replace wp-theme under the same guard.
    Core 7.0 only exports privateApis from wp.theme; polyfill boot imports public ThemeProvider, which is undefined without the polyfill theme.
  • Premium Analytics: hook ensure_script_data() on jetpack-premium-analytics-wp-admin_init so JetpackScriptData is emitted on the wp-admin integrated dashboard page.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • pnpm jetpack test php packages/wp-build-polyfills — 24 tests pass.
  • On WP 7.0 with Gutenberg deactivated:
    • Open wp-admin/admin.php?page=jetpack-premium-analytics-wp-admin.
    • Confirm the dashboard loads without React errors.
    • Confirm @jetpack-premium-analytics/init runs (init modules register, widgets render).
    • In Network, confirm @wordpress/boot and wp-theme load from jetpack-wp-build-polyfills/build/…, not /wp-includes/.
  • On WP 7.0 with Gutenberg 23.5.0+ active, confirm polyfills are not force-replaced (Gutenberg boot/theme win).
  • On WP >= 7.1, confirm force-replace does not apply and core handles remain in use.

Made with Cursor

Core 7.0 boot ignores wp-build initModules and wp-theme hides ThemeProvider
behind privateApis, breaking wp-build dashboards without Gutenberg 23.5+.
Also emit JetpackScriptData on the Premium Analytics wp-admin page.

Co-authored-by: Cursor <cursoragent@cursor.com>
@retrofox
retrofox requested a review from a team July 8, 2026 08:57
@retrofox
retrofox requested a review from a team as a code owner July 8, 2026 08:57
@retrofox retrofox added the [Status] Needs Review This PR is ready for review. label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the fix/wp-build-polyfills-boot-initmodules-wp-7 branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/wp-build-polyfills-boot-initmodules-wp-7
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/wp-build-polyfills-boot-initmodules-wp-7

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@retrofox
retrofox requested a review from dhasilva July 8, 2026 09:00
@retrofox retrofox self-assigned this Jul 8, 2026
Extract is_script_module_registered() with a Phan suppress for
WP_Script_Modules::get_registered(), which exists in WP 6.9+ but is
not yet in the static-analysis stubs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jp-launch-control

jp-launch-control Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/wp-build-polyfills/src/class-wp-build-polyfills.php 114/126 (90.48%) -0.43% 3 ❤️‍🩹
projects/packages/premium-analytics/src/class-analytics.php 4/62 (6.45%) -0.11% 1 ❤️‍🩹

Full summary · PHP report · JS report

Nikschavan
Nikschavan previously approved these changes Jul 8, 2026

@Nikschavan Nikschavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for this!

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants