Pacifik

A function for adding Facebook, Twitter and Google+ buttons

Jan 13th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. function gk_social_buttons($content) {
  2.     global $post;
  3.     $permalink = get_permalink($post->ID);
  4.     $title = get_the_title();
  5.     if(!is_feed() && !is_home() && !is_page()) {
  6.         $content = $content . '<div class=&quot;gk-social-buttons&quot;>
  7.          
  8.        <a class=&quot;icon-twitter&quot; href=&quot;http://twitter.com/share?text='.$title.'&amp;url='.$permalink.'&quot;
  9.            onclick=&quot;window.open(this.href, \'twitter-share\', \'width=550,height=235\');return false;&quot;>
  10.            <span>Twitter</span>
  11.        </a>  
  12.              
  13.        <a class=&quot;icon-fb&quot; href=&quot;https://www.facebook.com/sharer/sharer.php?u='.$permalink.'&quot;
  14.             onclick=&quot;window.open(this.href, \'facebook-share\',\'width=580,height=296\');return false;&quot;>
  15.            <span>Facebook</span>
  16.        </a>
  17.          
  18.        <a class=&quot;icon-gplus&quot; href=&quot;https://plus.google.com/share?url='.$permalink.'&quot;
  19.           onclick=&quot;window.open(this.href, \'google-plus-share\', \'width=490,height=530\');return false;&quot;>
  20.            <span>Google+</span>
  21.        </a>
  22.    </div>';
  23.     }
  24.     return $content;
  25. }
  26. add_filter('the_content', 'gk_social_buttons');
Add Comment
Please, Sign In to add comment