Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new wpl_iframe_src filter to enable filtering arguments to Likes iframes. #40276

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

georgestephanis
Copy link
Member

@georgestephanis georgestephanis commented Nov 20, 2024

This will enable experimenting with re-introducing slim likeboxes to display likes without gravatars and other future changes. Could also enable testing grounds of new changes before full UI for setting management is built out, or potentially to point more easily to a testing sandbox.

Companion to proposed changes WPCOM-side via phab diff D165404

I used the existing pattern of wpl_ for the filter prefix but I'm 100% fine if it's changed to jetpack_likes_ for a filter prefix or anything else.

Proposed changes:

  • Introduces a new filter in two places.

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

I've been discussing this with @jsnajdr in Slack about the wpcom-side changes. Jetpack-side changes for now are limited to just adding two filters so it is possible to append a slim=1 argument.

Slim mode was added for the Carousel module eleven years ago, and removed again eight years ago via #3585 but the code supporting it has lived on wpcom-side, albeit in a broken state for the past few years. The proposed change wpcom-side rectifies that and lets slim mode work again as a version without gravatars. This PR to Jetpack just makes it possible to filter and append the iframe to add &slim=1 to the fragment so JS picks it up and toggles the mode.

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

Testing instructions:

  • There isn't much to test Jetpack side as this is just adding two instances of a filter.

…o like iframes.

This will enable experimenting with re-introducing `slim` likeboxes to display likes without gravatars and other future changes.  Could also enable testing grounds of new changes before full UI for setting management is built out, or potentially to point more easily to a testing sandbox.

Companion to proposed changes WPCOM-side via phab diff D165404
@georgestephanis georgestephanis added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Likes labels Nov 20, 2024
Copy link
Contributor

github-actions bot commented Nov 20, 2024

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 WordPress.com Simple 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, and enable the update/likes-add-iframe-filter branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/likes-add-iframe-filter
    

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 Nov 20, 2024
Copy link
Contributor

github-actions bot commented Nov 20, 2024

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


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? 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 semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for none scheduled (scheduled code freeze on undefined).

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 would need you to make some changes or provide some more details about your PR. Thank you! label Nov 20, 2024
@georgestephanis
Copy link
Member Author

georgestephanis commented Nov 20, 2024

Setting up the Jetpack CLI tool isn't functional for me currently.

I've tried to follow the directions as best I could, but it seems pnpm is installing a version newer than Jetpack supports currently to generate the changelog message?

~/code/jetpack $ pnpm -v
9.14.2
~/code/jetpack $ pnpm install
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your pnpm version is incompatible with "/Users/georgestephanis/code/jetpack".

Expected version: ^9.3.0 <9.12.0
Got: 9.14.2

This is happening because the package's manifest has an engines.pnpm field specified.
To fix this issue, install the required pnpm version globally.

To install the latest version of pnpm, run "pnpm i -g pnpm".
To check your pnpm version, run "pnpm -v".

I had to do a minor change to package.json locally to get pnpm to install -- `"pnpm": "^9.3.0 <9.15.0"` but it worked.
@georgestephanis
Copy link
Member Author

I've tried to follow the directions as best I could, but it seems pnpm is installing a version newer than Jetpack supports currently to generate the changelog message?

I sorted this locally with the following change --

diff --git a/package.json b/package.json
index 347afccb62..bf8194e99f 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
 	},
 	"engines": {
 		"node": "^22.9.0",
-		"pnpm": "^9.3.0 <9.12.0"
+		"pnpm": "^9.3.0 <9.15.0"
 	},
 	"packageManager": "[email protected]"
 }

Unsure if pnpm needs to have a max version required in package.json?

@simison
Copy link
Member

simison commented Nov 20, 2024

npm i -g [email protected] helped me in a similar situation.

@simison
Copy link
Member

simison commented Nov 20, 2024

What are some other changes that you're looking into with Likes?

It would be important to have a path with these types of settings configurable in the Likes Block.

@georgestephanis
Copy link
Member Author

What are some other changes that you're looking into with Likes?

Just what's outlined in the phab diff. Getting the "slim" mode up and running again, and retooling it to operate as the current full likes block behaves, but without gravatars.

Longer term, I'd like to have to have that potentially available as a setting for the likes button exposed to admins -- whether or not to display gravatars of users who have liked it -- but I'm personally fine with that resolving down the road following any discussion / bikeshedding on whether to include it is finalized.

@@ -448,6 +448,9 @@ function_exists( '\Activitypub\is_activitypub_request' )

$title = esc_html__( 'Like or Reblog', 'jetpack' );

/** This filter is documented in modules/likes/jetpack-likes-master-iframe.php */
$src = apply_filters( 'wpl_iframe_src', $src );
Copy link
Member

Choose a reason for hiding this comment

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

Seems to me that only the likes/master.html iframe needs the slim=1 parameter. On the likes/index.html iframe the parameter has no effect, because the document is just a small and passive placeholder. All the work is done by the master iframe: it loads the likes from REST, decides whether the UI will be slim or not and then replaces the DOM markup in all the managed iframes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had been shuffling some stuff in my testing and thought it was required there as well -- or it wasn't propagating properly without it. I could have been mistaken though.

Copy link
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.

I used the existing pattern of wpl_ for the filter prefix but I'm 100% fine if it's changed to jetpack_likes_ for a filter prefix or anything else.

I think it may be better to switch to the jetpack_ prefix indeed. While wpl is consistent with the rest of the module, it isn't with the rest of Jetpack, and the Plugins team now prefers prefixes to be clear and consistent all across plugins. Since this is a new prefix, we may as well switch to jetpack_likes 👍

@georgestephanis
Copy link
Member Author

Just noting for folks testing this, the way to use this filter is as follows:

add_filter( 'jetpack_likes_iframe_src', function( $src ) { return $src . '&amp;slim=1'; } );

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] Needs Team Review labels Nov 25, 2024
@georgestephanis
Copy link
Member Author

Thanks @jeherve! If this could go out in the December release, so that we can use the filter on production sites when the likes widget changeset merges to accept the slim parameter, it would be very much appreciated.

@jeherve jeherve merged commit 9a5997a into trunk Nov 26, 2024
59 checks passed
@jeherve jeherve deleted the update/likes-add-iframe-filter branch November 26, 2024 15:29
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Nov 26, 2024
@jsnajdr
Copy link
Member

jsnajdr commented Nov 26, 2024

Warning: one might be tempted to add the slim param with add_query_arg:

return add_query_arg( 'slim', '1', $src )

But that won't work because the slim=1 param is added to the hash portion of the src URL (after #), not to the query string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Likes [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants