Customize Subscription Options Plugin For WordPress

Subscription Options is a very useful wordpress plugin that enables you to share your blog content over email, RSS feed, twitter, facebook etc. It provides excellent flexibility in the form of choosing the right kind of icon and associate the required URL with the icon. See a snapshot below.

Subscription Options Default

Rather than copy-pasting standalone snippets of code for each service eg twitter, it is extremely easy to rather let this plugin do the job for you. You can than just add it as a widget in your sidebar. An additional benefit is that it is very simple to enhance some code in the plugin php file and use it on your blog.

As an example, lets see how to add an [Add To Delicious] button for this plugin and have it available with rest of the icons.

All you need to do the following --

Step 1

Look for the following code in your plugin file named suboptions.php( located in wp-content/plugins/subscription-options folder )


if ( $facebook_url )
echo '<a target="_blank" title="Subscribe via Facebook" alt="Subscribe via Facebook" href="'.$facebook_url.'"><img style="border: 0px none; width: '.$size.'px; height: '.$size.'px; " src="'.get_bloginfo('wpurl').'/'.PLUGINDIR.'/subscription-options/images/facebook_icon_'.$facebook_col.'.png"/> </a>';

This is the code which displays the facebook icon and associates it with a URL. We will add our new code just below this one. Notice the echo command above

Step 2

  • Lets say your blog’s URL is http://www.yourblog.com.
  • To display the delicious icon, you would need a delicious logo image file. Lets call that file delicious_icon.png.
  • This file needs to be uploaded to your site.
  • For our case, lets assume it is available as images/delicious_icon.png on your blog.
  • Note -- To keep things simple, choose an image with exactly the same dimensions as other icons of the plugin. This will help us to avoid any formatting tags for the image and use it as is. For example if the icon image for facebook as available in the plugin is 50px*50px -- use the same dimension image here.

Step 3

  • Lets assume that the URL that you want to bookmark is the home page of your blog itself -- http://www.yourblog.com.
  • To keep the things simple, we will use the URL string of your home page rather than using any wordpress functions to extract the home page URL.

Step 4

We are almost set now. We will just take a variable in which the homepage URL is stored. We will than invoke our own echo function that will display the icon and also link it to the desired URL. To set the perspective,  If we want to say bookmark a URL XYZ to delicious, the desired URL should be “http://www.delicious.com?url=XYZ”. In our case, we need to replace XYZ by our blog’s homepage URL

Enough of description, lets look at the code snippet



$del_url = "http://www.yourblog.com";
echo '<a target="_blank" title="Add To Delicious" alt="Add To Delicious" href="http://www.delicious.com?url=' . urlencode($del_url) . '" ><img border="0" alt="Add To Delicious" src="http://www.yourblog.com/images/delicious_icon.png" /></a>';

Isnt this simple? All we are doing is putting the URL to be bookmarked in a variable and concatenating it with the final URL( after doing the required URL encoding ). The final output will show an additional icon adjacent to the existing plugin icons with the desired link action. Notice the last icon in the snapshot below.

Delicious icone added to subscription options plugin

Using this method, you can add/remove newer icons and their associated URLs in this plugin. If you are and advanced user, you might also like to use some additional wordpress APIs to build the URL dynamicaly rather than using a hardcoded string as above( to be covered later 🙂 ).

Let us know if you found this useful by sharing the thoughts in the comments section.






Inficone runs on the Genesis Framework

Genesis Framework
Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!
Follow On Twitter
Follow On Facebook
Follow Using RSS
Follow Using Email
Tweet This Post
Share Post On Facebook
Digg This Post
Stumble Upon

Comments

  1. Thanks Tom for your appreciation. Glad that you found the article useful. Hope that it helps fellow users to extract more from the fantastic plugin.

  2. Hi Shivam, great post!

    Thank you for considering the use of my plugin as a basis for this kind of custom development, and thanks too for sharing your lessons with the world.

    You’re absolutely right that it’s pretty simple to make these changes, but quite often that will require novice users have clear step-by-step instructions – which you’ve definitely provided here!

    All the best,
    Tom

Speak Your Mind

*

This blog is kept spam free by WP-SpamFree.