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

        Дичев Уеблог  

Social bookmarks plugin for WordPress

Публикувано на 2007-12-27 в категория Уеб дизайн, SEO.

« 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!




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

Subsribe to feeds Не забравяйте да се абонирате за RSS новини от блога ми.

Add This! del.icio.us Digg.com StumbleUpon.com Technorati.com   Dao.bg Ping.bg Pipe.bg Svejo.net Web-bg.com




32 коментара към статията:
Gravatar Icon

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


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

Happy holidays!



Gravatar Icon

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!



Gravatar Icon

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


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



Gravatar Icon

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.



Gravatar Icon

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


This is a really cool plugin! Thx!!!



Gravatar Icon

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!



Gravatar Icon

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!



Gravatar Icon

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.



Gravatar Icon

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!



Gravatar Icon

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.



Gravatar Icon

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


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

Cheers :)



Gravatar Icon

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?



Gravatar Icon

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.



Gravatar Icon

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.



Gravatar Icon

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.



Gravatar Icon

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


Thanks Alex, it??s cool plug-in.



Gravatar Icon

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?



Gravatar Icon

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!



Gravatar Icon

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.



Gravatar Icon

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


Great! Thanks.



Gravatar Icon

21 ]   ??????????   (2008-04-24 @ 14:09)


????????????!



Gravatar Icon

22 ]   Assad   (2008-06-10 @ 9:50)


You have my many thanks for such a nice plugin. I was searching for individual bookmark icons quite sometime and luckily you published yours. I prefer to have such structure rather than window popup used by AddThis or ShareThis.

To my surprise, not only you’ve come with easy to use instruction, but also the codes used passed the HTML validation wonderfully, where the others failed miserably. (Now you know, why I give you my many thanks.) - Except that it conflicted with other plugins. Nonetheless, I chose yours (perhaps I’m going to create a post on this…).

As the plugin uses global variable $post as its mechanism, I cannot control the location of it. Sorry, I’m not an expert, when it comes to PHP language. I need to display it somewhere after my post, before the comment starts. Is it possible to do so? I’m very glad, if you take some time to look at it. Perhaps we can have a deal on this.

All I need is to integrate it the way I want it.



Gravatar Icon

23 ]   Alexander Dichev   (2008-06-10 @ 12:28)


I know about the positioning and I have to find some time to search for any solution. Few other guys have asked me the same thing.

Why don’t you try to play with the third parameter of the function add_filter('the_content', 'add_me', 1097); and change it to any other digit. This is the sequence the function is executed in regards to the other functions.

What’s the conflict with the other plugins? Can you tell me more? I want to investigate it…



Gravatar Icon

24 ]   jocuri   (2008-06-10 @ 18:15)


Keep up the good work! 10q



Gravatar Icon

25 ]   Assad   (2008-06-10 @ 19:34)


Thanks for the suggestion. However, I regret to say that I do not understand it. Can you briefly tell me what the code is all about and where & when to use it?

It is not entirely a conflict though. Previously, I used Homepage Excerpts plugin from DailyBlogTips. Everything was okay until the moment I activated yours. The DBT’s plugins seems to include the buttons in the excerpts whereas it should not, making it look awful. Regardless, I implemented another plugin for excerpts to overcome this as I badly need these bookmark buttons.



Gravatar Icon

26 ]   Alexander Dichev   (2008-06-10 @ 20:07)


Dear @Assad, as I’ve mentioned above I am using add_fiter() to execute the function, which writes the bookmark buttons.

I am not experienced WP-developer and I am not sure is there any better solution to do this. add_filter('the_content', 'add_me', 1097); is the way to call my function add_me() to modify the content of the post, writing to it’s end the bookmarks code.

I have read the WordPress Codex and found this easy way to implement the functionality I’ve needed. To change the way I need time to read again the possible solutions to call the plugin on the desired place.

If you are interested how it works, read this.

When I find some time I will release new more customizable version.

Edit: Congratulations! The buttons after your posts look great.



Gravatar Icon

27 ]   Assad   (2008-06-10 @ 21:53)


No problem and thanks for the link. It helps me to start with something. For the time being, I’m studying it and trying to have basic ideas on how to work with it. I will let you know if I found the solution.

I am aware as your plugin is made for general use. I find it a waste of time if you are about to make it fully customizable for its users. Perhaps your support is far more important than customizations.

p/s: Thanks. I hope you like it. Too bad I don\’t have the time to make a complete list. :)



Gravatar Icon

28 ]   Philix   (2008-07-23 @ 15:04)


Thanks this is exactly what i am looking for.



Gravatar Icon

29 ]   EgitimTUBE   (2008-08-07 @ 22:53)


Thanks. Very good.



Gravatar Icon

30 ]   shakira   (2008-11-24 @ 8:48)


Social bookmarking sites allow web surfers to save, catalog, and share interesting pages they find online. The Sociable plugin for Word Press appends links for your readers to use those sites to the end of each of your blog??s posts, increasing your potential audience. I started noticing that more and more hits we??re being referred to the blog from muti.co.za the African flavored social bookmarking site so have been playing around with it a bit.



Gravatar Icon

31 ]   Thiet ke website   (2009-02-08 @ 14:33)


Thanks a lot for sharing this plugin. I love it??s functionality.

Have a good day.



Gravatar Icon

32 ]   Nelya   (2009-05-27 @ 23:41)


Про дело Мартыновых слышали?? Такой бред вообще… Моё мнение - судебный произвол…





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

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




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



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

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

11 x visitors online online