[Plugin: Jetpack by WordPress.com] Support for sharing_permalink filter inconsistent
-
I have a page that uses a custom URL via the rewrite rules, and what I noticed was that the Jetpack Sharing code was using the URL for my page (returned from get_permalink) and not the rewritten URL I was expecting.
I found the hooks for sharing_permalink, but it appears that it’s not being implemented consistently in the latest Jetpack release.
Specifically, I’m looking at code like this in:
jetpack/modules/sharedaddy/sharing-sources.phpif ( $this->smart == 'smart' ) return '<div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&counturl=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) ) . '&count=horizontal&text=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . ': " style="width:97px; height:20px;"></iframe></div>'; else return $this->get_link( get_permalink( $post->ID ), _x( 'Twitter', 'share to', 'jetpack' ), __( 'Click to share on Twitter', 'jetpack' ), 'share=twitter' );
In the first case above, you see that apply_filters( ‘sharing_permalink’, …) is called for the “url” query string variable for tweet_button.html, but not for the “counturl” query string variable in the same URL. That means for my case, the counturl address is different than what’s being shared, so my counts will always show as zero.
In the second case (where $this->smart != ‘smart’) the get_link() function is called in the else statement using get_permalink() directly and not using the filter at all.
It’s worse in the Facebook portion of that same code file, too:
public function get_display( $post ) { if ( $this->share_type == 'share' ) { return '<div class="facebook_button"><a name="fb_share" rel="nofollow" type="button" share_url="' . apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) . '" href="http://www.facebook.com/sharer.php?u=' . rawurlencode( get_permalink( $post->ID ) ) . '&t=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '">'.__( 'Share' , 'jetpack' ).'</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>'; } else if ( $this->share_type == 'like' ) { $url = 'http://www.facebook.com/plugins/like.php?href=' . rawurlencode( get_permalink( $post->ID ) ) . '&layout=button_count&show_faces=false&action=like&colorscheme=light&height=21';
You’ll see here that if the share type is ‘share’, the code uses the sharing_permalink filter, but if the share type is ‘like’, it uses the get_permalink() function instead.
I’m making changes to the version installed in my hosted instance of WordPress to work for me, but if this isn’t fixed in future versions of Jetpack, I’ll have to keep re-applying it each time.
Thanks,
– Kris
- The topic ‘[Plugin: Jetpack by WordPress.com] Support for sharing_permalink filter inconsistent’ is closed to new replies.