Skip to content

Subscriptions: register filesystem path for inline-style support#47988

Open
dd32 wants to merge 1 commit intoAutomattic:trunkfrom
dd32:fix/subscriptions-inline-styles-path
Open

Subscriptions: register filesystem path for inline-style support#47988
dd32 wants to merge 1 commit intoAutomattic:trunkfrom
dd32:fix/subscriptions-inline-styles-path

Conversation

@dd32
Copy link
Copy Markdown
Member

@dd32 dd32 commented Apr 8, 2026

Fixes a regression introduced in #44546 (Jetpack 14.9).

Summary

Jetpack_Subscriptions_Widget::enqueue_style() registers the path style data using the URL returned by Assets::get_file_url_for_environment(). However, wp_maybe_inline_styles() requires a filesystem path so it can file_get_contents() the stylesheet. Passing a URL triggers a _doing_it_wrong notice from core:

Notice: Function wp_maybe_inline_styles was called incorrectly. Unable to read the "path" key with value "https://example.org/wp-content/plugins/jetpack/modules/subscriptions/subscriptions.css" for stylesheet "jetpack-subscriptions". Please see Debugging in WordPress for more information. (This message was added in version 7.0.0.) in wp-includes/functions.php on line 6173

Assets::get_file_url_for_environment() always returns a URL (it ends in plugins_url(...)), so it should not be used as the value for the path style data.

Proposed changes

  • Use JETPACK__PLUGIN_DIR to compute an absolute filesystem path for the stylesheet, gated by the jetpack_should_use_minified_assets filter.
  • Mirrors the pattern adopted for the Likes module in Likes: add minified build for CSS #46750 / modules/likes.php.
  • The enqueue URL is unchanged — only the value passed to wp_style_add_data( ..., 'path', ... ) changes.

See also #44532 (the original performance report that #44546 was responding to).

Testing instructions

  • Start with a site connected to WordPress.com, where the Subscriptions module is active, and WP_DEBUG enabled.
  • Install and activate the Twenty Ten theme and the Classic Widgets plugin.
  • Add the Subscriptions widget to a sidebar.
  • Load the front end of the site.
  • Before this patch: the _doing_it_wrong notice for jetpack-subscriptions appears in the debug log / on screen.
  • After this patch: the notice is gone, and the stylesheet is eligible for inlining via wp_maybe_inline_styles().
  • Repeat with SCRIPT_DEBUG enabled (which causes jetpack_should_use_minified_assets to return false) and confirm the unminified modules/subscriptions/subscriptions.css path resolves correctly.

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

No.


🤖 Generated with Claude Code (Opus 4.6).

PR Automattic#44546 added `wp_style_add_data( 'jetpack-subscriptions', 'path', $path )`
where `$path` is the URL returned by `Assets::get_file_url_for_environment()`.
But `wp_maybe_inline_styles()` requires a filesystem path so it can read the
file with `file_get_contents()`. Passing a URL triggers a `_doing_it_wrong`
notice from core for the `jetpack-subscriptions` stylesheet.

Mirror the pattern used by the Likes module (Automattic#46750): resolve the absolute
filesystem path via `JETPACK__PLUGIN_DIR` and the
`jetpack_should_use_minified_assets` filter.
@github-actions github-actions bot added [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

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 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 🤖



Jetpack plugin:

No scheduled milestone found for this plugin.

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

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Apr 8, 2026
@dd32 dd32 requested a review from jeherve April 8, 2026 01:57
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@jeherve jeherve added Bug When a feature is broken and / or not performing as intended [Status] Ready to Merge Go ahead, you can push that green button! [Pri] Normal and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] Ready to Merge Go ahead, you can push that green button!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants