Skip to content

Conversation

@dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Oct 30, 2025

Note

The builds atop of and targets #45714.

Allow omitting assets from the endpoint return by handle. Helpful for omitting problematic plugins or those already provided by the client. Omissions must occur on the captured HTML, as unregistering the assets would lead to also omitting assets that declare them as dependencies. E.g. unregistering react may cause a plugin's script to be discarded from the printed scripts due to the missing react dependency.

This will be used by the GutenbergKit mobile app editor to retrieve plugin assets only. GutenbergKit includes Gutenberg's @wordpress modules in its own bundle and does not need to fetch these assets.

An example request is https://[site_domain]/?rest_route=/wpcom/v2/editor-assets?exclude=core,gutenberg.

Proposed changes:

  • Add exclude parameter for listing plugins to exclude.
  • Add special "core" exclusion keyword for excluding WordPress core-provided block editor assets (i.e., the @wordpress modules used by the block editor).
  • Filter HTML styles and scripts return values with DOMDocument for consistent results.
  • Manually filter conditional comments with regex, as DOMDocument cannot recognize the HTML within them E.g., <!--[if lt IE 8]>[script_or_link]<![endif]-->.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

p1761568270564209-slack-C08UN8YN6KW

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

No

Testing instructions:

See wordpress-mobile/GutenbergKit#209.

Additionally, one can perform API Console or curl requests to the endpoint with and without the exclude parameter to test and observe the results.

@dcalhoun dcalhoun added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] In Progress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Oct 30, 2025
@dcalhoun dcalhoun changed the title feat Filter editor assets endpoint with exclude parameter Oct 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

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), and enable the feat/filter-editor-assets-endpoint branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack feat/filter-editor-assets-endpoint

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
Copy link
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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: November 4, 2025
    • Code freeze: November 3, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control
Copy link

jp-launch-control bot commented Oct 30, 2025

Code Coverage Summary

No summary data is available for parent commit bae3fa2, so cannot calculate coverage changes. 😴

If that commit is a feature branch rather than a trunk commit, this is expected. Otherwise, this should be updated once coverage for bae3fa2 is available.

Full summary · PHP report · JS report

These keys are explicitly set in the callback passed to
`with_absolute_urls()` a few lines above.
Comment on lines +247 to +249
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset -- Keys are guaranteed by callback above
'scripts' => $html['scripts'],
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset -- Keys are guaranteed by callback above
Copy link
Member Author

Choose a reason for hiding this comment

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

These values are inaccessible to Phan due to the opaque callback passed to with_absolute_urls. That callback explicitly defines these keys,.

* @param array $exclude_rules Array of exclusion rules.
* @return string The filtered HTML content.
*/
private function filter_conditional_comments( $html, $tag_name, $url_attribute, $exclude_rules ) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This function's complexity and usage of regex is unfortunate, but necessary as DOMDocument cannot access the HTML tags within the conditional HTML comment.

@dcalhoun dcalhoun marked this pull request as ready for review October 31, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

2 participants