Skip to content

Conversation

@jeherve
Copy link
Member

@jeherve jeherve commented Jan 23, 2026

See #46671

Proposed changes:

Minify the Likes stylesheet and use it in self-hosted environments.

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

  • N/A

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

  • No

Testing instructions:

  • Start with a site connected to WordPress.com, where the Likes module is active.
  • In your site's wp-config.php file, ensure that SCRIPT_DEBUG is set to false.
  • Go to the frontend of your site and view a post with likes enabled.
  • View source
  • You should see the inline likes css, minified.
  • Now update wp-config.php to set SCRIPT_DEBUG to true.
  • Reload the page.
  • You should see the inline likes css, not minified.

Add the likes module CSS to the webpack CSS config so it gets minified
for production. Update both likes.php and the Like block to use
Assets::get_file_url_for_environment to serve the minified version
when SCRIPT_DEBUG is false.

Follows the pattern established for subscriptions in #44546.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

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 update/minify-likes-css branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/minify-likes-css

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 added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Jan 23, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 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 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!


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: February 3, 2026
    • Code freeze: February 3, 2026

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR wires the Likes module CSS into the CSS webpack pipeline so it can be minified and then enqueued conditionally based on the environment, similar to the recent Subscriptions work. It also updates the Likes module and Like block to use the new minified asset and adds a corresponding changelog entry.

Changes:

  • Add modules/likes/style.css to the CSS webpack config (weirdRtlEntries) to build _inc/build/likes/style.min.css and RTL variants.
  • Update the Likes module (modules/likes.php) to enqueue the minified Likes stylesheet via Assets::get_file_url_for_environment() and use the same helper for the queuehandler script.
  • Update the Like block (extensions/blocks/like/like.php) to use the new minified Likes stylesheet URL and adjust its handling of style path metadata, and add a Jetpack changelog entry describing the enhancement.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
projects/plugins/jetpack/tools/webpack.config.css.js Adds a weirdRtlEntries entry so modules/likes/style.css is built to _inc/build/likes/style.min.css (and RTL) and picked up by the existing CSS build pipeline.
projects/plugins/jetpack/modules/likes.php Switches frontend Likes CSS and JS enqueues to use Assets::get_file_url_for_environment() and the new _inc/build/likes/style.min.css asset, but currently misuses the CSS URL as the path metadata.
projects/plugins/jetpack/extensions/blocks/like/like.php Updates the Like block to use the new minified Likes CSS/JS URLs in the non-WPCOM branch, but also sets the path metadata to a URL instead of a filesystem path.
projects/plugins/jetpack/changelog/update-minify-likes-css Adds a changelog entry summarizing the new minified Likes CSS build and enqueue behavior, following the existing changelog conventions.

'modules/likes/style.css'
);
wp_enqueue_style( 'jetpack_likes', $style_url, array(), JETPACK__VERSION );
wp_style_add_data( 'jetpack_likes', 'path', $style_url );
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

wp_style_add_data( 'jetpack_likes', 'path', $style_url ); is passing a URL as the path value, but WordPress expects this metadata to be a filesystem path (used for inlining via wp_maybe_inline_styles()), and elsewhere in the codebase we consistently pass real paths via plugin_dir_path( __FILE__ ) or similar. This will at best cause unnecessary file-fetching over HTTP (and can fail outright when URL wrappers are disabled), and it’s also a regression from the previous implementation that used plugin_dir_path( __FILE__ ) . 'likes/style.css'. Please change this to pass an actual filesystem path corresponding to the selected CSS file (minified vs non-minified depending on SCRIPT_DEBUG), while keeping $style_url as the enqueued URL.

Suggested change
wp_style_add_data( 'jetpack_likes', 'path', $style_url );
$style_path = plugin_dir_path( JETPACK__PLUGIN_FILE ) . (
( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
? 'modules/likes/style.css'
: '_inc/build/likes/style.min.css'
);
wp_style_add_data( 'jetpack_likes', 'path', $style_path );

Copilot uses AI. Check for mistakes.
'_inc/build/likes/style.min.css',
'modules/likes/style.css'
);
$style_path = $style_url;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

In the non-WPCOM branch, $style_path is set to $style_url, so when we later call wp_style_add_data( 'jetpack_likes', 'path', $style_path ); the path metadata is a URL instead of a filesystem path. Core expects a real path here for inlining (see usage in other modules where we use plugin_dir_path( __FILE__ )), so this can break or degrade CSS inlining and is a regression from the previous implementation that used a true file path. Please keep $style_url as the URL for wp_enqueue_style(), but compute $style_path as the corresponding filesystem path (minified vs non-minified depending on environment), similar to how the WPCOM branch uses WP_CONTENT_DIR.

Suggested change
$style_path = $style_url;
$style_path = JETPACK__PLUGIN_DIR . ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'modules/likes/style.css' : '_inc/build/likes/style.min.css' );

Copilot uses AI. Check for mistakes.
The 'path' metadata for wp_style_add_data expects a filesystem path
for CSS inlining, not a URL. Compute the correct path based on
SCRIPT_DEBUG to point to either the minified or non-minified file.
Use the existing filter for consistency with the rest of the codebase.
Copilot AI review requested due to automatic review settings January 23, 2026 17:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@jp-launch-control
Copy link

jp-launch-control bot commented Jan 23, 2026

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/likes.php 101/250 (40.40%) -1.51% 9 💔
projects/plugins/jetpack/extensions/blocks/like/like.php 0/83 (0.00%) 0.00% 3 ❤️‍🩹

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@jeherve jeherve added I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Jan 23, 2026
@jeherve jeherve requested review from a team and sgomes January 23, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Like Enhancement [Feature] Likes [Focus] Performance I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] Needs Review This PR is ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants