This is the final part on the subject of creating a WordPress plugin (read part 1 and part 2). We’ll be modifying our original function, that outputs social bookmark links after each post, so that it works with our new options page.
So first we need to modify our display function. At present it just echos out the markup, however we need it to do the following
- Put the markup into a variable
- Check which option is set
- If you should attach the links to the content, and the content isn’t empty, append the links variable created in point 1
- Else, if the content is empty (therefore the function has been called directly), echo the links variable
- Else, just return the original content without any links attached
Okay so let’s look at this step by step.
1. Put the markup in a variable
Before we were just echoing the markup, now it needs to go into a variable. This also means we need to alter our template tags for the permalink and post title, as the ones in use before would echo the content out, but we want to just return it so that it’s in the variable. So to do this we can use
[sourcecode language="php"] $sblinks = ‘








Great finish to a great series. Thanks again Sarah, these posts have really opened the door for me on plugin development.
I have a wordpress blog, and I didnt know it can be enhanced in so many ways..Thanks a lot!
It is a good article,thanks for your sharing.
It is good information!
thanx sarah!
very clear and informative.
will try it on my site
does it also work with WP 3.1 ?