Skip to content

Commit

Permalink
Introduce new wpl_iframe_src filter to enable filtering arguments t…
Browse files Browse the repository at this point in the history
…o Likes iframes. (#40276)

* Introduce new `wpl_iframe_src` filter to enable filtering arguments to 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

* Add changelog.

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.

* Update projects/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php

Co-authored-by: Jeremy Herve <jeremy@jeremy.hu>

* Update filter names to new patterns

---------

Co-authored-by: Jeremy Herve <jeremy@jeremy.hu>
  • Loading branch information
georgestephanis and jeherve authored Nov 26, 2024
1 parent 96c342b commit 9a5997a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Likes: Add a filter to the iframe url to enable future expansion and modularity.
3 changes: 3 additions & 0 deletions projects/plugins/jetpack/modules/likes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( 'jetpack_likes_iframe_src', $src );

$html = "<div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='$wrapper' data-src='$src' data-name='$name' data-title='$title'>";
$html .= $headline;
$html .= "<div class='likes-widget-placeholder post-likes-widget-placeholder' style='height: 55px;'><span class='button'><span>" . esc_html__( 'Like', 'jetpack' ) . '</span></span> <span class="loading">' . esc_html__( 'Loading...', 'jetpack' ) . '</span></div>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ function jetpack_likes_master_iframe() {
$new_layout
);

/**
* Filters the Likes iframe src, if any parameters need to be overridden or tracked.
*
* @module likes
*
* @since $$next-version$$
*
* @param string URL to https://widgets.wp.com/ with various arguments appended to the get string and fragment.
*/
$src = apply_filters( 'jetpack_likes_iframe_src', $src );

if ( $new_layout ) {
// The span content is replaced by queuehandler when showOtherGravatars is called.
$likers_text = wp_kses( '<span>%d</span>', array( 'span' => array() ) );
Expand Down

0 comments on commit 9a5997a

Please sign in to comment.