Advertisement
Digitalraindrops

jw share this code

Jul 21st, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. /* Add Share This to functions.php */
  2. set_time_limit(20);
  3. ini_set("memory_limit","128M");
  4.  
  5. function jw_share_this_links($content) {
  6.     $id = get_the_ID();
  7.     $title = get_the_title($id);
  8.     $url = get_permalink($id);
  9.     //get image path
  10.     $img_path = get_template_directory_uri() .'/images/';
  11.     $content .= "\n";
  12.     $content .= "<div class=\"jwsharethis\">\n";
  13.     $content .= "Share this: \n";
  14.     $content .= "<br />\n";
  15.     $content .= "<a href=\"mailto:?subject=" . rawurlencode($title) . "&amp;body=" . rawurlencode($url) . "\">\n";
  16.     $content .= "<img src=\"" .$img_path. 'email.png' ."\" alt=\"Share this page via Email\" />\n";
  17.     $content .= "</a>\n";
  18.     $content .= "<a target=\"_blank\" href=\"http://www.stumbleupon.com/submit?url=" . urlencode($url) . "&amp;title=" . urlencode($title) . "\">\n";
  19.     $content .= "<img src=\"" .$img_path .'su.png' ."\" alt=\"Share this page via Stumble Upon\" />\n";
  20.     $content .= "</a>\n";
  21.     $content .= "<a target=\"_blank\" href=\"http://digg.com/submit?url=" . urlencode($url) . "&amp;title=" . urlencode($title) . "\">\n";
  22.     $content .= "<img src=\"" .$img_path .'digg.png' ."\" alt=\"Share this page via Digg this\" />\n";
  23.     $content .= "</a>\n";
  24.     $content .= "<a target=\"_blank\" href=\"http://www.facebook.com/sharer.php?u=" . urlencode($url) . "&amp;t=" . urlencode($title) . "\">\n";
  25.     $content .= "<img src=\"" .$img_path .'fb.png' ."\" alt=\"Share this page via Facebook\" />\n";
  26.     $content .= "</a>\n";
  27. //  $content .= "<a target=\"_blank\" href=\"http://twitter.com/home?status=I+like+" . urlencode($url) . "&amp;title=" . urlencode($title) . "\">\n";
  28.     $content .= "<a target=\"_blank\" href=\"http://twitter.com/intent/tweet?text=I+like+" . urlencode($url) . "&amp;title=" . urlencode($title) . "\">\n";
  29.     $content .= "<img src=\"" .$img_path .'twitter.png' ."\" alt=\"Share this page via Twitter\" />\n";
  30.     $content .= "</a>\n";
  31.     $content .= "</div>\n";
  32.     return $content;
  33. }
  34. add_filter('the_content', 'jw_share_this_links');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement