How To Integrate Social Media Buttons with Your Blog

How To Integrate 11 Popular Social Media Network Sharing Buttons onto Your Blog

Posted in Identity & Branding, Web Design/Development, Wordpress | One Comment

People are increasingly loving the capabilities of Social Media, its main benefits, being the opportunity to meet and communicate with new people to generally congregate or share ideas and resources. The code snippet below is a snippet code for a bigger project I’m working on presently, but the code snippets below will enable you to echo up to 11 popular social media network vote/share buttons on your blog.  Just insert this php class object into your functions.php WordPress file. In fact I highly recommend creating a new php file called social-media-buttons.php or whatever name you wish and include this file in your functions.php with:


include('social-media-share.php'); // assuming this file is in the same directory as your functions.php

Then in this new file, paste the code below:

<?php

// Social Media Buttons Class Object

class smbuttons

{

function gb_delicious() { // Delicious

echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><script type="text/javascript" src="http://delicious-button.googlecode.com/files/jquery.delicious-button-1.0.min.js"></script>';

echo '<a class="delicious-button" href="http://delicious.com/save" data-button="{ url:\''. get_permalink($post->ID) .'\' ,title:\''. get_the_title($post->title) .'\'}">Save on Delicious</a>';

}

function gb_designbump() { // DesignBump

echo "<script type=\"text/javascript\">url_site='". get_permalink($post->ID) ."'; </script><script src=\"http://designbump.com/sites/all/modules/drigg_external/js/button.js\" type=\"text/javascript\"></script>";

}

function gb_digg(){ // Digg

echo "<script type=\"text/javascript\">(function() {var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0]; s.type = 'text/javascript';

s.async = true; s.src = 'http://widgets.digg.com/buttons.js'; s1.parentNode.insertBefore(s, s1); })(); </script>";

echo '<a class="DiggThisButton DiggMedium" href="http://digg.com/submit?url='. get_permalink($post->ID) .'"></a>';

}

function gb_fbLike() { // Facebook Like

echo '<iframe src="http://www.facebook.com/plugins/like.php?href='. get_permalink($post->ID) .'&amp;layout=box_count&amp;show_faces=true&amp;width=45&amp;action=like&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:45px; height:65px;" allowTransparency="true"></iframe>';

}

function gb_fbShare() { // Facebook Share

echo "<script>var fbShare = { url: '". get_permalink($post->ID) ."', size: 'large', badge_text: 'C0C0C0', badge_color: '3b5998', google_analytics: 'true' }</script> <script src=\"http://widgets.fbshare.me/files/fbshare.js\"></script>";

}

function gb_buzz() { // Google Buzz

echo '<a title="Post to Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-message="'. get_the_title($post->title) .'" data-button-style="normal-count" data-locale="en_GB" data-url="'. get_permalink($post->ID) .'"></a> <script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script>';

}

function gb_retweet() { // Retweet Tweetmeme

echo "<script type=\"text/javascript\"> tweetmeme_source = 'graphicbeacon'; tweetmeme_service = 'bit.ly'; tweetmeme_url = '". get_permalink($post->ID) ."'; </script>";

echo '<script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script>';

}

function gb_twitter() { // Retweet Twitter

echo '<a href="http://twitter.com/share" class="twitter-share-button" data-url="'. get_permalink($post->ID) .'" data-text="'. get_the_title($post->title) .'" data-count="vertical" data-via="graphicbeacon">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';

}

function gb_reddit() { // Reddit

echo '<script type="text/javascript">reddit_url = "'. get_permalink($post->ID) .'"; reddit_title = "'. get_the_title($post->title) .'"; reddit_newwindow=\'1\';</script> <script type="text/javascript" src="http://reddit.com/static/button/button2.js"></script>';

}

function gb_sphinn() { // Sphinn

echo '<script type="text/javascript">submit_url = "'. get_permalink($post->ID) .'";</script> <script type="text/javascript" src="http://sphinn.com/evb/buttons.php?b=lg"></script>';

}

function gb_stumbleupon() { // Stumbleupon

echo '<script src="http://www.stumbleupon.com/hostedbadge.php?s=5&r='. get_permalink($post->ID) .'"></script>';
}

}

?>

The code above contains the buttons for 11 Popular Social Media Networks namely Delicious, Designbump, Digg, Facebook Like, Facebook Share, Google Buzz, Retweet, Twitter, Reddit, Sphinn and Stumbleupon. To echo this our onto your blog, you need to firstly create a variable, holding your class object like this:

$smbuttons = new smbuttons();

Then simply use any of the lines below to echo out which button you want:

// Delicious

$smbuttons->delicious();

// Designbump

$smbuttons->gb_designbump();

// Digg

$smbuttons->gb_digg();

// Facebook Like

$smbuttons->gb_fbLike();

// Facebook Share

$smbuttons->gb_fbShare();

// Google Buzz

$smbuttons->gb_buzz();

// Retweet

$smbuttons->gb_retweet();

// Twitter Official

$smbuttons->gb_twitter();

// Reddit

$smbuttons->gb_reddit();

// Sphinn

$smbuttons->gb_sphinn();

To learn more about how to use WordPress, why not consider these solutions:



One Comment to “How To Integrate 11 Popular Social Media Network Sharing Buttons onto Your Blog”


Recommended

Expert Help with WordPress
Learn how you can market your business on Twitter
Get the Book now! Use 25% discount code 'november25'
Hostgator - Cheap and Reliable Web Hosting - WordPress friendly

Incoming Tweets