Alexander Dichev Weblog Home
  Блог              
  Времето              
  Панорами              
  Галерия              
  Директория              
  Уебдизайн              
  Контакт              
 
 
Weblog
 

        Уеблог  

Social bookmarks plugin for WordPress

Други статии:
Anti Zombie Kit   «  [ • ]  »   Успешна Нова Година!




How to create Social bookmarks buttons plugin for WordPress

  Download plugin  

Add Me Dichev (Download .ZIP archive)

Bulgarian Български

In this article I will try to give you a short tutorial on how create your own WordPress plugin.

Because the topic of the Social bookmarks networks is very popular, I have chosen to write a plugin, which automatic generates bookmarks buttons after the post body.

Wordpress social bookmarks buttons plugin

After I have collected a long list of social bookmarks websites, I have decided to explain you how to customize it yourself for your blog. Most of the bloggers do not want all of the bookmark buttons to appear after their posts, thats why I will teach you how to remove any of the buttons listed in my plugin or add a new one I have forgotten to add. If you are enough close to PHP, feel free to customize the social bookmarks lists included in the plugin source.

First of all is a 3-step guide on how to install the plugin directly without modifying it. This is for people who want to use all social networks buttons and will not be able to modify the script inside the source of the plugin. To install the plugin in 3 easy steps you need not more than 10 minutes and no PHP experience.

  1. Download the source of the WordPress plugin here:
    Add Me Dichev (Download .ZIP)

  2. Extract the contents of the archive in the plugins folder of your WordPress blog installation:
    /wp-content/plugins/

  3. In the admin of your WordPress blog activate the plugin:
    Plugins » Add Me Dichev » Activate

How to activate the plugin from the admin

List of the supported social networks:
addthis.com, blinkbits.com, blinklist.com, blogmarks.net, blogmemes.net, bluedot.us, bloglines.com, co.mments.com, connotea.org, del.icio.us, de.lirio.us, digg.com, diigo.com, dzone.com, facebook.com, feedmelinks.com, folkd.com, fleck.com, google.com, icio.de, indianpad.com, leonaut.com, linkagogo.com, linkarena.com, linkter.hu, ma.gnolia.com, mister-wong.de, url.com.tw, ask.com, yahoo.com, netscape.com, netvouz.com, newsgator.com, newsvine.com, oneview.de, rawsugar.com, reddit.com, rojo.com, segnalo.alice.it, shadows.com, simpy.com, slashdot.org, smarking.com, sphere.com, spurl.net, startaid.com, stumbleupon.com, tailrank.com, technorati.com, thisnext.com, yigg.de, webnews.de, readme.ru.

Bulgarian social networks:
svejo.net, dao.bg, ping.bg, pipe.bg, web-bg.com, dobavi.com, lubimi.com.




For those of you, which want to make any customization of Add Me Dichev WordPress social bookmarks buttons plugin, read the next lines, follow the steps in the tutorial and learn the structure of the source. It is very simple to understand how it works and to modify it. You do not need to be a PHP guru to add or remove any buttons to you blog post body.

  • Download plugin and extract it.

  • The archive contains README.txt, the folder /images/ with the icons of the buttons and the file addme_dichev.php, who does the most of the job.

  • Open addme_dichev.php in a text editor.

In the beginning of the file you can see the function add_me($content), which the plugin calls on the end of the post body to generate the bookmarks buttons. The idea of this function is to add the URL (the address) and the title of the post to the addresses for submission of a post to the different social bookmarking networks. There are two specific things in this task. The address and the title of every post are different and the same is with the addresses for the submission to the social bookmarks websites. Below you will learn how to handle with this.

Add Me Dichev WordPress social bookmarks buttons plugin source

First we define the global WordPress variable global $post;, it contains the data of every single post. Few lines below we will load from it the current post address and title.

Next there are some settings variables, you can use to make basic changes to the position of the buttons. It is not necessary to edit them. If you do not want making any change, leave them the same or experiment with their values to best suite your design needs.

$my_width is the width in pixels of the block containing the buttons. Its goal is to fix the width of the buttons group, which is located in a <DIV>, if it does not pass to the design of your blog template. It may be in pixels or percents. For example:

$my_width = ´100%´;
or
$my_width = ´450px´;

$my_align is the align of the bookmarks buttons block. It may be left, right or center. For example:

$my_align = ´left´; (for left align)
or
$my_align = ´right´; (for right align)
or
$my_align = ´center´; (for centered align)

There is one option variable available $my_images_folder, it contains the path to the bookmarks icons folder.

$my_images_folder = get_settings(´home´)
. ´/wp-content/plugins/add-me-dichev/images/´;

The specific here is that we use the WordPress get_settings(´home´) to check, where the blog is installed. It returns the path to the blog installation folder (for example: http://dichev.com/blog/) and this case we add it to the icons folder path in the default WordPress plugins folder.

You do not need to change it unless you want to use another location for storing the images of the bookmarks buttons.

With the help of the WordPress functions get_permalink() and get_the_title() we load from the global variable $post the address and the title of the current post, which the visitor is reading and we save the data in our local variables $my_link and $my_title.

$my_link = get_permalink($post->ID); (the address)
$my_title = get_the_title($post->ID); (the title)

As you probably guess $post->ID is the ID of the current post.

And so we are at the main part…
We do a simple check to see, that visitor is really reading a post and not a page or RSS-feed:

if ( !is_feed() && !is_page() ) {

The WordPress functions is_feed() and is_page() return TRUE, if is opened a feed or a post..

If is really a post, finally we begin to save in the variable $content the content, we want to show after the post. In our case this is the source we will generate to display the social bookmarks networks buttons.

Add Me Dichev WordPress social bookmarks buttons plugin source

Every single line represents the source code for a single button. The syntax is very important, so if you add a new buttons, please be sure, that you have copied the code of already working button from the file and modify it according to the other buttons example.

If you like to hide any of the bookmark buttons and not to show it after the post, just comment the line of code for the given button with // before it.

To add a new button to the group, create a line for it following the example of a already working button. Every social bookmarks network has its own convention for submitting an address. In most of the cases it looks like this:

http://domain.com/addpost?url=ADDRESS&title=TITLE

You have to replace the ADDRESS and the TITLE with the address and the title of your current post.

In the beginning of our function we have already load the current post address and title in our local variables $my_link and $my_title, so we can use them on the places of ADDRESS and TITLE in the creation of the submission URL.

http://domain.com/addpost?url=´.$my_link.´&title=´.$my_title.´

We accept that you have written the address (HREF=...) of the network correct. For every new button you have to upload its new image in the icons folder and fill its name (for example: new_button.gif), the TITLE of the link, the ALT and the TITLE of the button image.

The picture below shows what will you get if commenting all the button source lines except the Bulgarian:

Wordpress social bookmarks buttons plugin

This is all. Hope this article was helpful for you…
Wish you good luck!



If you find the plugin and the tutorial useful, please Digg this page!




Тагове: , , , , , ,

Не забравяйте да се абонирате за RSS новини от блога ми:

Subsribe to feeds       Subscribe by Email or IM
Add This! del.icio.us Digg.com StumbleUpon.com Technorati.com   Dao.bg Ping.bg Pipe.bg Svejo.net Web-bg.com




21 коментара към статията:
Philip

1 ]   Philip   (2007-12-30 @ 17:32)


:) Great tutorial!
Many thanks for this wordpress plugin!
I will try to write my own.

Happy holidays!



Nine

2 ]   Nine   (2007-12-30 @ 18:47)


Thank you for this great plugin! It rocks.
…and for joining our community.
It would be great if you could add us to the bookmarklist of your plugin. Thank you! And have a wonderful new 2008!



Dichev

3 ]   Dichev   (2007-12-30 @ 18:52)


Thanks, Nine!
I will add your network with the next plugin update.



Nine

4 ]   Nine   (2008-01-02 @ 16:35)


A wonderful and sucessfull new year 2008 to you, Dichev!
And thank you for adding us!
Greetz from Germany/Italy to Bulgaria, have good time.



Manele

5 ]   Manele   (2008-01-05 @ 18:35)


This is a really cool plugin! Thx!!!



Ripcord

6 ]   Ripcord   (2008-01-09 @ 18:32)


Hey, simple, but great plugin, thanks.

Just one thing, there is a discrepancy between the image path varable and the extracted directory name. You need to change either the variable which is:

../plugins/addme_dichev/images

to read

/plugins/add-me-dichev/images

or change the extracted directory name which is:

add-me-dichev

to read

addme_dichev

thats it!

Thanks again!



Alexander Dichev

7 ]   Alexander Dichev   (2008-01-09 @ 19:17)


:D Many thanks, Ripcord!

I have fixed the path in the plugin source, readme.txt and this tutorial…

Installation instructons are fixed too:
http://wordpress.org/extend/plugins/add-me-dichev/

I think now it is OK.
Thank you again!



Khell

8 ]   Khell   (2008-01-28 @ 17:41)


Great plugin - one problem though that I’m not sure anyone has noticed yet..

When I go to edit a post or make a new post and then submit it I get the following error:

Warning: Cannot modify header information - headers already sent by (output started at /home/REMOVED/public_html/blog/wp-content/plugins/add-me-dichev/addme_dichev.php:113) in /home/REMOVED/public_html/blog/wp-includes/pluggable.php on line 391

Fortunately, this error doesn’t stop the actual post or edit from being sent, it’s just annoying to have to manually browse to the blog again.



Alexander Dichev

9 ]   Alexander Dichev   (2008-01-28 @ 17:54)


Hello @Khell I found the problem and I will fix it in the source.
In this time you can fix it yourself on your site by removing the white spaces after the ?> on the end of addme_dichev.php on line 113. Do not leave any symbol or white space after the php “?>” tag.

Thanks!



Khell

10 ]   Khell   (2008-01-28 @ 18:06)


Hi again,

I just figured that out too. I removed the whole of line 113 though.

Had to get it fixed because it was occurring for comments as well, you see. ;)

Thanks for the quick response and sorry for the double post before.



averagecoder

11 ]   averagecoder   (2008-02-06 @ 7:36)


Hi Alexander, thanks for the update and the info on my website

Cheers :)



M. Bashir Al-Noimi

12 ]   M. Bashir Al-Noimi   (2008-02-13 @ 4:41)


Thanks Alex, it’s cool plug-in.

I want to ask you a tiny question,

I want to make links appear only on extended view of post, because I’m usually using “more” tag, and I don’t want to make links appear in the simple view of post.

How I can do that?



Waffles

13 ]   Waffles   (2008-02-15 @ 4:13)


I’m having a similar issue as the person above. I only want the social bookmarks to appear on the end of an article, I am hiding the article on the main page, only showing the first line. Or if i could get it to appear in the same div as “edit | comments”, that would be awesome. Thanks, great plugin.



Alexander Dichev

14 ]   Alexander Dichev   (2008-02-17 @ 16:15)


Hello @Waffles and @M. Bashir Al-Noimi,
I’m very sorry for the long delay in my answer, but I was not able to respond of comments for some time.

This plugin uses WP plugin API add_filter() action, which is attached to some filter hook, like writing to the database, calling the comments and many other.
You can see all filter hooks here:
http://codex.wordpress.org/Plugin_API/Filter_Reference

On my website I am using my own excerpt for every post and WP does not display the icons when listing the list of posts.

To show them only after the single post experiment by calling the function add_me() (or placing the action of the function) on the desired place somewhere on the end of your theme single.php file.



Waffles

15 ]   Waffles   (2008-02-25 @ 7:58)


Actually your response was really quick, thank you. I couldn’t make it work though, inst there something I could just copy and paste from the plugin php? I’m basically using the default wordpress theme.



manele noi

16 ]   manele noi   (2008-03-10 @ 19:33)


Thanks Alex, it’s cool plug-in.



Bob

17 ]   Bob   (2008-04-10 @ 23:32)


I have the same question as Waffles. How do you make the bookmark icons appear on the end of your posts, but not on the main page, where I only have a summary of the article?



Tom

18 ]   Tom   (2008-04-12 @ 16:49)


I was wondering if this plugin was WordPress 2.5 Compatible, or if it was going to be? I’d very much so like to incorporate it into my site. Thanks!



Alexander Dichev

19 ]   Alexander Dichev   (2008-04-12 @ 22:54)


Yes, @Tom. The plugin is WordPress 2.5 compatible. It is tested under WP 2.5 and it works fine.

@Bob, to make the social bookmark icons appear only after the post and not on the list of the posts, I use the excerpt field on the Edit Post page. I use The Excerpt Reloaded plugin and write my own custom excerpt for every of my blog posts.

There are other WordPress Excerpt-plugins too: Advanced Excerpt, Excerpt Editor and TinyMCE Excerpt.



Tom

20 ]   Tom   (2008-04-12 @ 22:58)


Great! Thanks.



Сергей

21 ]   Сергей   (2008-04-24 @ 14:09)


Спасибо!





Вашият коментар:
(Моля, пишете на Кирилица!)

Текст за разпознаване Моля, въведете 5-те символа от картинката.
Цифри от 0 до 9 и букви от A до F.




 Предвижи се до началото на тази страница. (Горе)      Отиди в началото на този уебсайт.      Добави тази страница в списъка ми с Favorites. (Ctrl+D)



Блог   Времето   Панорами   Галерия   Уебдизайн   Директория   Контакт

© 2008 - Дичев, Александър - България, Варна - Credits -
Panoramas | Gallery | Link popularity | World time | Forecast | Weather | Moon
Home | Sitemap | Blogmap | Dirmap

10 x visitors online online