A few months ago I posted about how to shorten WordPress Jetpack sharing links. Today, I would like to revisit this topic and provide a cleaner solution that I recently uncovered.
Unlike the previous solution I described, this does not require editing the source of the Jetpack plugin, and thus will persist through plugin updates.
In order to implement this quick fix, you will first need to create a functions.php file in your active theme. If you do not have a custom theme, I would strongly suggest using a child theme, as not doing so will mean losing your modifications if a newer version of your theme is released at a later date.
In short, all that you need to do is hook into the built-in filter provided within the Jetpack source. A filter is a little piece of code that plugin authors (and WordPress core authors) can include to allow users control over some inner functionality. In this case, the filter allows us to tweak what the sharing URL displayed to the end user will look like. If you would like a deeper explanation of content filters and their close cousins, action hooks, the WordPress Codex provides an excellent description of both.
In any event, the fix, shown below, simply returns the wp.me shortened URL for use in all the sharing links. Give it a try and be sure to comment if you found this useful!
NOTE: If you would like additional control over which social networks receive shortlinks and which receive the full permalink, you can use the $social_network value, which contains a string with the name of the network.