Found this useful? Love this post

WordPress Jetpack sharing module stripping HTTPS for Twitter button count

[Updated 30 Jan 2013] I’m currently using the Jetpack plugin for WordPress 2.x.x and running my site on HTTPS. I noticed that in the sharing module of the Jetpack plugin it seems to strip out HTTPS for when it’s getting the &counturl parameter for the iframe, but weirdly no-where else. Not sure why it’s doing this (I’m sure there is a reason, but it was unhelpful in my case as it wasn’t obeying my sites protocol).

[UPDATED for 2.1 +]

On line 372 of ./jetpack/modules/sharedaddy/sharing-sources.php

'&counturl=' . rawurlencode(  get_permalink( $post->ID ) )

Replace this section with:

'&counturl=' . rawurlencode(  $share_url )

The entire line of 372 with the fix applied:

return '<div><iframe allowtransparency="true" frameborder="0" scrolling="no" src="' . esc_url( $this->http() . '://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( $share_url ) . '&counturl=' . rawurlencode( $share_url ) . '&count=horizontal&text=' . rawurlencode( $post->post_title . ':' ) . $via ) . '" style="width:101px; height:20px;"></iframe></div>';

[Fix for versions prior to 2.1]

On line 372 of ./jetpack/modules/sharedaddy/sharing-sources.php

'&counturl=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) )

I simply removed the str_replace resulting in:

 '&counturl=' . rawurlencode( get_permalink( $post->ID ) )

The entire of line 372 with the str_replace removed:

return '<div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="' . esc_url( $this->http() . '://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( $share_url ) . '&counturl;=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) ) . '&count=horizontal&text;=' . rawurlencode( $post->post_title . ':' ) . $via ) . '" style="width:101px; height:20px;"></div>'

Subscribe

You'll only get 1 email per month containing new posts (I hate spam as much as you!). You can opt out at anytime.

Categories

Leave a Reply

Your email address will not be published. Required fields are marked *

Preview Comment

css.php