{"id":1358,"date":"2012-08-01T22:24:32","date_gmt":"2012-08-02T05:24:32","guid":{"rendered":"http:\/\/www.harperkingsley.net\/blog\/?p=1358"},"modified":"2023-10-17T23:38:10","modified_gmt":"2023-10-18T06:38:10","slug":"tweetbutton","status":"publish","type":"post","link":"https:\/\/harperkingsley.net\/blog\/tweetbutton\/","title":{"rendered":"Adding Shortlinks to WordPress Tweet Button Through Jetpack plugin"},"content":{"rendered":"<p>[maj update=&#8221;02\/08\/12&#8243;]Totally got Jossed, now the Twitter links look worse than ever. Hopefully they fix that in the next update. Sorries!<\/p>\n<p>This is the old way to fix your posts.[\/maj]<\/p>\n<p>Okay, so I changed up my Twitter button on Jetpack so I could use a short link and add &#8220;Via HarperKingsley0&#8221; my Twitter name. Took me about two minutes once I found out what I needed to do.<\/p>\n<p>Go to Plugins =&gt; Installed Plugins =&gt; Jetpack =&gt; Edit =&gt; modules\/sharedaddy.php =&gt; sharing-service.php. It should look like this &#8220;jetpack\/modules\/sharedaddy\/sharing-service.php.&#8221;<!--more--><\/p>\n<p>Just click the code and run a Find for &#8220;Twitter&#8221; then scroll down until you find the code you need to change. Replace the &#8220;get_permalink&#8221; with &#8220;wpme_get_shortlink&#8221; and add &#8220;via=USERNAME&amp;amp;&#8221; after the frame address. Like this:<\/p>\n<blockquote><p>&lt;iframe allowtransparency=&#8221;true&#8221; frameborder=&#8221;0&#8243; scrolling=&#8221;no&#8221; src=&#8221;http:\/\/platform.twitter.com\/widgets\/tweet_button.html?<span style=\"color: #ff6600;\">via=HarperKingsley0&amp;amp;<\/span>url=&#8217; . rawurlencode( apply_filters( &#8216;sharing_permalink&#8217;, <span style=\"color: #ff6600;\">wpme_get_shortlink<\/span>( $post-&gt;ID ), $post-&gt;ID, $this-&gt;id ) ) . &#8216;&amp;amp;counturl=&#8217; . rawurlencode( str_replace( &#8216;https:\/\/&#8217;, &#8216;http:\/\/&#8217;, <span style=\"color: #ff6600;\">wpme_get_shortlink<\/span>( $post-&gt;ID ) ) ) . &#8216;&amp;amp;count=horizontal&amp;amp;text=&#8217; . rawurlencode( apply_filters( &#8216;sharing_post_title&#8217;, $post-&gt;post_title, $post-&gt;ID, $this-&gt;id ) ) . &#8216;: &#8221; style=&#8221;width:97px; height:20px;&#8221;&gt;&lt;\/iframe&gt;&lt;\/div&gt;&#8217;;<br \/>\nelse<br \/>\nreturn $this-&gt;get_link( <span style=\"color: #ff6600;\">wpme_get_shortlink<\/span>( $post-&gt;ID ), _x( &#8216;Twitter&#8217;, &#8216;share to&#8217;, &#8216;jetpack&#8217; ), __( &#8216;Click to share on Twitter&#8217;, &#8216;jetpack&#8217; ), &#8216;share=twitter&#8217; );<br \/>\n}<\/p>\n<p>public function process_request( $post, array $post_data ) {<br \/>\n$post_title = apply_filters( &#8216;sharing_post_title&#8217;, $post-&gt;post_title, $post-&gt;ID, $this-&gt;id );<br \/>\n$post_link = apply_filters( &#8216;sharing_permalink&#8217;, get_permalink( $post-&gt;ID ), $post-&gt;ID, $this-&gt;id );<\/p><\/blockquote>\n<p>The only problem is that I don&#8217;t think my Tweet numbers are showing up correctly. Anyone know how to fix it and keep my short link and Twitter showing?<\/p>\n<p>[ Found the Twitter user name info at <a title=\"Gregory A McMullen\" href=\"http:\/\/gregoryamcmullen.com\/coding\/adding-username-to-jetpack-sharedaddy\" target=\"_blank\" rel=\"noopener\">Gregory A McMullen&#8217;s<\/a> site and the short link info at <a title=\"Skip's Stuff\" href=\"http:\/\/skipsloan.com\/wordpress-wp-me-shortlinks-in-tweets-using-jetpack-1-5\/\" target=\"_blank\" rel=\"noopener\">Skip&#8217;s Stuff<\/a>. I discovered both through a Google search; I have no affiliation with either. ]<\/p>\n<p>[maj update=&#8221;02\/08\/12&#8243;]Here&#8217;s the way the Jetpack code&#8217;s been changed. Anyone know a viable workaround? I still want to use my short link and now my Via is automagically screwed up (I&#8217;m on default mode right now and the via installed is supposed to be my blog, but it looks weird.):<\/p>\n<blockquote><p>function sharing_twitter_via( $post ) {<br \/>\n\/\/ Default &#8216;via&#8217; is always us.<br \/>\n$via = preg_replace( &#8216;\/(https?:\\\/\\\/)|(\\.)|(\\\/)\/i&#8217;, &#8221;, home_url() );<\/p>\n<p>\/\/ Allow themes to customize the via<br \/>\nreturn apply_filters( &#8216;sharing_twitter_via&#8217;, $via, $post-&gt;ID );<br \/>\n}<\/p>\n<p>public function get_display( $post ) {<br \/>\n$via = $this-&gt;sharing_twitter_via( $post );<\/p>\n<p>if ( $via ) {<br \/>\n$via = sprintf( &#8216;&amp;via=%1$s&#8217;, rawurlencode( $via ) );<br \/>\n} else {<br \/>\n$via = &#8221;;<br \/>\n}<br \/>\nif ( $this-&gt;smart ) {<br \/>\nreturn &#8216;&lt;div&gt;&lt;iframe allowtransparency=&#8221;true&#8221; frameborder=&#8221;0&#8243; scrolling=&#8221;no&#8221; src=&#8221;&#8216; . esc_url( &#8216;http:\/\/platform.twitter.com\/widgets\/tweet_button.html?via=HarperKingsley0&amp;amp;url=&#8217; . rawurlencode( apply_filters( &#8216;sharing_permalink&#8217;, get_permalink( $post-&gt;ID ), $post-&gt;ID, $this-&gt;id ) ) . &#8216;&amp;counturl=&#8217; . rawurlencode( str_replace( &#8216;https:\/\/&#8217;, &#8216;http:\/\/&#8217;, get_permalink( $post-&gt;ID ) ) ) . &#8216;&amp;count=horizontal&amp;text=&#8217; . rawurlencode( $post-&gt;post_title . &#8216;:&#8217; ) . $via ) . &#8216;&#8221; style=&#8221;width:101px; height:20px;&#8221;&gt;&lt;\/iframe&gt;&lt;\/div&gt;&#8217;;<br \/>\n} else {<br \/>\nif ( &#8216;icon-text&#8217; == $this-&gt;button_style || &#8216;text&#8217; == $this-&gt;button_style )<br \/>\nsharing_register_post_for_share_counts( $post-&gt;ID );<br \/>\nreturn $this-&gt;get_link( get_permalink( $post-&gt;ID ), _x( &#8216;Twitter&#8217;, &#8216;share to&#8217;, &#8216;jetpack&#8217; ), __( &#8216;Click to share on Twitter&#8217;, &#8216;jetpack&#8217; ), &#8216;share=twitter&#8217;, &#8216;sharing-twitter-&#8216; . $post-&gt;ID );<br \/>\n}<br \/>\n}<\/p>\n<p>public function process_request( $post, array $post_data ) {<br \/>\n$post_title = $post-&gt;post_title;<br \/>\n$post_link = apply_filters( &#8216;sharing_permalink&#8217;, get_permalink( $post-&gt;ID ), $post-&gt;ID, $this-&gt;id );<\/p>\n<p>if ( function_exists( &#8216;mb_stripos&#8217; ) ) {<br \/>\n$strlen = &#8216;mb_strlen&#8217;;<br \/>\n$substr = &#8216;mb_substr&#8217;;<br \/>\n} else {<br \/>\n$strlen = &#8216;strlen&#8217;;<br \/>\n$substr = &#8216;substr&#8217;;<br \/>\n}<\/p>\n<p>$via = $this-&gt;sharing_twitter_via( $post );<br \/>\nif ( $via ) {<br \/>\n$related = false;<br \/>\n$sig\u00a0\u00a0\u00a0\u00a0 = &#8221; via @$via&#8221;;<br \/>\n} else {<br \/>\n$via\u00a0\u00a0\u00a0\u00a0 = false;<br \/>\n$related = false;<br \/>\n$sig\u00a0\u00a0\u00a0\u00a0 = &#8221;;<br \/>\n}[\/maj]<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>[maj update=&#8221;02\/08\/12&#8243;]Totally got Jossed, now the Twitter links look worse than ever. Hopefully they fix that in the next update. Sorries! This is the old way to fix your posts.[\/maj] Okay, so I changed up my Twitter button on Jetpack so I could use a short link and add &#8220;Via HarperKingsley0&#8221; my Twitter name. Took&hellip;<\/p>\n <a href=\"https:\/\/harperkingsley.net\/blog\/tweetbutton\/\" title=\"Adding Shortlinks to WordPress Tweet Button Through Jetpack plugin\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">Adding Shortlinks to WordPress Tweet Button Through Jetpack plugin<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"Layout":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[55],"tags":[792],"class_list":["entry","author-harperkingsley0-0","has-more-link","post-1358","post","type-post","status-publish","format-standard","category-real-life","tag-wordpress"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2pPoL-lU","jetpack-related-posts":[{"id":5516,"url":"https:\/\/harperkingsley.net\/blog\/looks-like-twitter-is-currently-down\/","url_meta":{"origin":1358,"position":0},"title":"Looks like Twitter is currently down","author":"Harper Kingsley","date":"May 9, 2022","format":false,"excerpt":"Looks like Twitter is currently down. I thought I'd gotten in trouble and been suspended or something, but the whole site is down. I hope the data is secure. That this is just some kind of DDoS attack. EDIT: My Twitter feed is still showing up in my Jetpack Twitter\u2026","rel":"","context":"With 1 comment","block_context":{"text":"With 1 comment","link":"https:\/\/harperkingsley.net\/blog\/looks-like-twitter-is-currently-down\/#comments"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2022\/05\/2022-05-09_twitterdown.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2022\/05\/2022-05-09_twitterdown.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2022\/05\/2022-05-09_twitterdown.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2022\/05\/2022-05-09_twitterdown.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2022\/05\/2022-05-09_twitterdown.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2022\/05\/2022-05-09_twitterdown.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":6887,"url":"https:\/\/harperkingsley.net\/blog\/test-7\/","url_meta":{"origin":1358,"position":1},"title":"Test","author":"Harper Kingsley","date":"March 3, 2025","format":false,"excerpt":"Is Jetpack down? No stats. Bad post in my email box. Very sus due to the post topic.","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6911,"url":"https:\/\/harperkingsley.net\/blog\/i-am-reconnected\/","url_meta":{"origin":1358,"position":2},"title":"I am reconnected(?)","author":"Harper Kingsley","date":"April 28, 2025","format":false,"excerpt":"I've been having Jetpack issues, and I think I've fixed the problem! There are several posts that I previously tried to send by email that never went through. So... sad for those missing and presumed dead posts. But, moving on... Have you seen the movie \"Companion\"? It's really good. If\u2026","rel":"","context":"With 1 comment","block_context":{"text":"With 1 comment","link":"https:\/\/harperkingsley.net\/blog\/i-am-reconnected\/#comments"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5523,"url":"https:\/\/harperkingsley.net\/blog\/internal-links-opening-in-a-new-tab-doh\/","url_meta":{"origin":1358,"position":3},"title":"Internal links opening in a new tab, d&#8217;oh","author":"Harper Kingsley","date":"May 11, 2022","format":false,"excerpt":"I did not want to add a plugin to have external links open in a new tab (links to Patreon, Ko-fi, Twitter, etc.) so I added the \"base target=\"_blank\" HTML to my Wordpress header. So now, external links open in new tabs, which is what I wanted, but internal links\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5337,"url":"https:\/\/harperkingsley.net\/blog\/thoughts-on-things-writing-stuff-bits-and-bobs\/","url_meta":{"origin":1358,"position":4},"title":"Thoughts on Things; Writing stuff; Bits and Bobs","author":"Harper Kingsley","date":"June 2, 2021","format":false,"excerpt":"Thoughts on Things So... There's been a lot of Florida Man incidents in the news lately. Like, Florida Man recently kicked an iguana to death then claimed Stand Your Ground laws in court. https:\/\/twitter.com\/HarperKingsley0\/status\/1400140467207999488?s=20 Or, Florida Man recently took his 10-year old son on a paintball drive-by that resulted in\u2026","rel":"","context":"In \"Bits and Bobs\"","block_context":{"text":"Bits and Bobs","link":"https:\/\/harperkingsley.net\/blog\/tag\/bits-and-bobs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5714,"url":"https:\/\/harperkingsley.net\/blog\/everyday-nonsense\/","url_meta":{"origin":1358,"position":5},"title":"Everyday nonsense","author":"Harper Kingsley","date":"January 13, 2023","format":false,"excerpt":"I've been using my old bluetooth keyboard with my phone to post on twitter and to write this post. I bought it so long ago that I'm not quite sure when I got it, but it was cheap and the little deer on the silicone skin appealed to me. I\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2023\/01\/image0-2.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2023\/01\/image0-2.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2023\/01\/image0-2.jpeg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/harperkingsley.net\/blog\/wp-content\/uploads\/2023\/01\/image0-2.jpeg?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/posts\/1358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/comments?post=1358"}],"version-history":[{"count":1,"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/posts\/1358\/revisions"}],"predecessor-version":[{"id":6415,"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/posts\/1358\/revisions\/6415"}],"wp:attachment":[{"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/media?parent=1358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/categories?post=1358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harperkingsley.net\/blog\/wp-json\/wp\/v2\/tags?post=1358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}