Skip to content

Instantly share code, notes, and snippets.

@shanejones
Last active June 26, 2019 14:13
Show Gist options
  • Save shanejones/c34b711c3b02cd91d2ea24aa3c0c7df0 to your computer and use it in GitHub Desktop.
Save shanejones/c34b711c3b02cd91d2ea24aa3c0c7df0 to your computer and use it in GitHub Desktop.
Replaces any bloated social plugins with a simpler version. Replace images with SVG or anything else.
<?php
/**
* Replaces the old social sharing shortcode with a lightweight, no dependecy version
*
* @return void
*/
function under2_social_buttons(){
$id = get_the_ID();
$permalink = get_the_permalink( $id );
$title = get_the_title( $id );
$facebook_link = 'http://www.facebook.com/sharer.php?u=' . $permalink;
$pinterest_link = 'javascript:void((function()%7Bvar%20e=document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'//assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e)%7D)());';
$twitter_link = 'http://twitter.com/share?url=' . $permalink . '&text=' . urlencode($title);
$linkedin_link = 'http://www.linkedin.com/shareArticle?mini=true&url='. $permalink;
$social_sharing = '
<div class="und2-social">
<h2>Share this...</h2>
<div class="icons">
<a href="' . $facebook_link . '" rel="nofollow" class="facebook"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAP1BMVEUAAAA8W5s8W5s8W5s8W5s8W5s8W5s8W5s8W5s8W5szVJdDYZ9IZqKFmcHP1+fi5/Hp7PT2+Pv///9Yc6qpt9RTU1cBAAAACXRSTlMAEUdqiqrH5SiwarMbAAABvklEQVR4AaWXVxbcIAxFRRMS7mX/aw1zMtXxMzjcM7+6g56bRAhjnQ8cMxy8s4ZuIS5E/SGyE6rEONZT2Jmq8qiQ6IsKWP4kOrrCBC3CQhAbtYJoCeC0Ek+neK0mnGUZ9AZsqv8fEG71n/KvkIOFtanr/6IHLH1hIijvh3GalwfT0RClHGAa5vXF0qMgcQBpW9Y3c69HfKkBHddLQTSFAwzrtUB9IcF9zeAMMnI4AOhg2TNDBx8KBvXd9BQM6YG+OKYgWhAsfVKEzQJXEszd9YPNRUGvEIbXIGVeAkUZZAQ8Rt2Qg18+FyFz3ogDEXTLemBCIXjU/4ExgRdLqBTsCaTIbYJI8VwwHwXDTcG0LEuLQLfM8xTLsGV6vSdIKennWcgoErAiXjksW1JIpNAmYPJtgkCuTeDJtgkcmdgkECJuEUQi8i2CkAXSIrCU4WoB+Li5/xd4/GmrEwgej6oEAX/e6wRCT1y9AMxZXBaAS/BEIhRkgECKY97wBHyTyoNqelI3qga9BdMRw43DNpnQVp/xLesC2LhA/hDhupUJY3zpEMXNUS4VQQhTVEQvVIexnv+tvrnBy3P7f+7/QoA/cJuAjla2veIAAAAASUVORK5CYII=" alt="Facebook Icon"></a>
<a href="' . $pinterest_link . '" rel="nofollow" class="pinterest"><img src=" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAVFBMVEUAAADLICfLICfLICfLICfLICfLICfLICfLICfLICfLICfLICfKGyLJFBvPLzXXUljkiIzwu7343d777e70zM7rqavfdXrTQEb////++PjbYmfomJsLNXFyAAAADHRSTlMAGC5tjKvG3OxN/ws9jdShAAADHElEQVR4AaVX29azKgxsPZsmeIYW3/89d9XINoj9cP1z1UVNnJkEDI8rPJM0y4uyqsoiz9L6+biFJM0rEKiKNImNfqUFBFGkz6jwEi5RZX+mOIdLlOnrV/gzhz9R/CBRlxCBqr6kD5HIwvEZRCMPGZHDDRSv+++XyCP144IYH+pALBGCWrD+OqEW9S/P4dC0XT980Y+TNkSnaiY/DERSbf8+YOgapLCRIQMI2uHtozN0ZcPLE0BmfAfw0Z4V1TNMgOzwDmMClBSCBEi/L9EBBiik3vs/B+vmVut2Gt1SF6JQSP3DLnmyijaAcaa2wslyKUQCArt/fUOEiESEa1k7Xm9EhtpXQK3ziwAJjLXWACEgzpxY2JB5ClAx1ZkQyMz9qqVv1ZKNM2g6avh2cRUg0OEXrJv1AFLHFI5IPAt6RxMn0coGAc1WDEtHE4QF1DiWpDf2rocIgCb+KUzIzgoGhZsZk4Jm5KIqBLJnDbnYiKxyYgIdIa6kmDhr+BgEh0K20bgrwI5LvlHhRehPJpSP8lzEhlD1TJXXuAX7UyGrRxVMsPwakX0VDG4naA8eqCGQwJfADywSFLIt7BybKBNIE3tXhXZlwgq4dlxGaaIoI3b/98G4JnAKZgLYd4Mso2ik2T1N7ZIH8KiACS7rDrlsZessp247fXrXye7fTrZyDdJF5tAMb+3af/UTcQzs51RsZ36e0eCSslsON4Wsz1cAiTxQuFDuQfzCWENLvHZ2eodiCmcKLPUbTIhrOLbuZPCPtATOLnDzk/1opC/QdG7ZP1SlBraa22WRPc5az1cfhurlf1ikV+y7A7e3VOAdq7AfhiMCqo8f732hk9B4hDjvG8IG48WgFKRAetjaeZLxnaLwjHIeMEz3TcAV2TG0iFdz1qsACURtSRAYZkUgUT45XIpgEILqmMGnn7QiBA+JHPNCUI3V2jYGQnNeGjGoIq3AqFE1B/iHYZmNjAcbKDP4HO7fWrL71wUPdQUxkP4LJEWE/OTnrTHzSNy/OT5/psj914dTlBfksyT29lyLHBxds/eRSOrt9s/3/+Qq+j9jX7EP8jhDHQAAAABJRU5ErkJggg==" alt="Pinterest Icon"></a>
<a href="' . $twitter_link . '" rel="nofollow" class="twitter"><img src=" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAQlBMVEUAAAAtquEtquEtquEtquEtquEtquEtquEtquEtquEtquEmqOAhpuBJtuab1/HZ8Pru+f3///9cvuh6yu05r+O54/bxyEXkAAAAC3RSTlMAGC5ykK7I5lH/C44Acx4AAAI7SURBVHgBpZfRwuQQDIVbikYClPd/1e3uXPy/VLV2vus5Z+IoieWOVchNaXOi1Sb3dZlCSGWgwWgp3qqt1NBFy/WV3MAt5tmCy68WdiRfFTyiB0XsBl5g9tvy4SWyr9/gNaoXhIIJtJ3+f4aaXz9jY/nDNM1erAamMWI+QB7kRACIOIjBmgc1gXMO6OPx42TWTgEEF8j5EFMM3hEgUXbISmgKOApy/RHTh3hgyTWUtoRmC9GlCsj06Ydweh3ED4Vufs0cTsuGeFD+VYI99QJ+IJ9Oh99BUE0N9QiVfU2SG6SQCZsCGkLBdicVNzjxjpAl0NWDZl8x5fQheoeEHQOesVgENIRfq80FLwYH8SMl7zctxerrg8HGLpJCPnGGBqo9iOTrUdOIzAz0oluD9IBDaDBLcxIxpzEBYGgAGNKQSg8GlOcy5AZ8HznR4cVAQwvlMF4BN1DAKM7HwSYy9KUjkY+3+orAUexTZgeYka8GG+9Joxg99frTat46BEC4IJZFA4dyjWl4EzWXooQLSOXgFtHRTY8WHT3lMNKzFq0b6Um5HunQ1xvLOls+8uE7AfhC0GPjw4GrqUPNhNBF8OaK5Hxgi68Z8WFQWk3TyrOvIf7ThupzIYI7RH/AQEIo+cQBEuGbOctqYOBfKcIQs343ZIH4csyTXw+aDPWfM94gyNlXh1Vf6CcH9s1+8eRh+TOEnhyyL9jNPJW/LmPWocUmlmdWeWNhmPweu2/6qt7tMoPYP6//z/t/F3fqPwVojBwC3QYnAAAAAElFTkSuQmCC" alt="Twitter Icon"></a>
<a href="' . $linkedin_link . '" rel="nofollow" class="linkedin"><img src=" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAARVBMVEUAAAABc7IBc7IAc7IBc7IBc7IBc7IBc7IBc7IBc7L///8AbK4AcLFcps42kMIihb3I4e/1+fwQe7dysdXl8fijzOOFvNrBvh4OAAAACnRSTlMAxqv/ZdwyE4rs5cIsYAAAAgRJREFUeNqll9uSgyAMQAPhDqJa9f8/daetbhYXKdDzhjMck5g2AHdoJQxn0lrJuBFKQxNKcIsJlhkFlWjBMAsTumq7xFus+aig7XmkKL+e40dYIQglsQIrbsPHSgxkMVgNz6XBkegphMEmeCH/rjooPAjee6xCJN9f4hu/xBixSmFVpoDhsTrnpuibCkkF8Lt7McfQUAZKICyze7NVCay+BhDdwbq0hKBlr8DqtAXCeKYwhZZmYIhtRSSkfvUQEfb5mUD0WIm6NrEfhyEuvqGhKQNq5Wz8IeQeSwBtkfAH4bIIPuDylGdyUIjEcDAGDMu5WIIfH9O6rtMe/4Uh0hJM7s3DYxjdQfSP2R1s1/oYMLeCc9e4O2IaUwMHjkTICebN/WVKm5QBK0SQZffpZ5CtgjkJwYKtEMzbvq3uZPDVAiqc98t0LrdEUJHC+iq8z/9UbamItHjit9yfhQT+URAPwZATsKSRQlEQcwIO4juBAfWdQIC2XwkUAPtGIGmu9wkMAKhOAY1o1iegySL6BDRYtO0WKHhhegUcgELoENAZRfQJDPzCcgJ3I5iXQJP1kkTMDxZ8Qg+ogoQojDY8COkD0XVQJXjXUZlgcEUzbEDq0m2l+9ZiOvMnhG0/ZqcoVpG+ggLaUBCFm2O/gtPrSwp5E3z19VkrctBuoaGF8/Z/3v/hhh9jt07sIy+oJAAAAABJRU5ErkJggg==" alt="Twitter Icon"></a>
</div>
</div>';
return $social_sharing;
} add_shortcode('und2-social-sharing', 'under2_social_buttons');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment