Blogging for Benjamin Plugin

  1. Blogging for Benjamin Competition
  2. Why I'm Grateful to Work on the Web
  3. 24 Pull Requests
  4. Update Downloadable Product's Expiration Date in WooCommere
  5. Get Lost in the Flow and Work for More Than a Salary
  6. Why A Plugin's Popularity Matters
  7. Why You Should (Or Shouldn't) Use Premium Plugins
  8. WooCommerce Terms & Conditions
  9. Only Ship to Continental United States with WooCommerce
  10. Just Talk
  11. Why I Love Jetpack
  12. Making Jetpack Better
  13. Remove Billing Address for Free Virtual Orders in WooCommerce
  14. Notify Admin of Customer Address Change in WooCommerce
  15. Open Your Self Up To New Possibilities
  16. 2013 Resolutions Review
  17. Create a Community
  18. Tips for Starting a Community
  19. The Intent of Goals
  20. Create The Ultimate Invoicing System Using WooCommerce
  21. Change From Address in Ninja Forms
  22. Work With People Who Inspire You
  23. Contact Form 7 & MailPoet Integration
  24. Monotasking
  25. Giving Back to The Community
  26. Adding Fuctionality to Lean Plugins
  27. Choose Stripe For a Payment Gateway
  28. A Dip Into Entrepreneurship
  29. Reward Yourself
  30. Blogging for Benjamin Plugin
  31. Blogging for Benjamin Wrap Up

One of the things I knew I wanted to do when I started this Blogging for Benjamin competition was to easily link users on one of those posts to the original post about the competition. That way users know why there's so many posts in December and about one a month in every other month. So I created a plugin to automatically add a message at the top of each of those posts.

What Does it Do?

Information box

Information box on my blog

This plugin quite simply & elegantly adds an informational message at the top of each post. With some fancy logic to calculate which post it is within the series of posts and displays that and a link to the original blog post that announces the competition.

Why Create a Plugin

There are probably a 1/2 dozen different ways to solve this problem but none of them are as clean as writing a plugin.

Manually Add Content in Post

I could have spent probably just as much time as writing the plugin by manually typing in some text at the top of each post. So time wise it was probably a wash but there are so many other advantages. I can easy change the CSS class across all instances or I can add extra CSS classes or add CSS classes within the content. Or if I ever wanted I could completely turn off this functionality with one click. The extra flexibility a plugin offers here is more than worth the extra brain power to write up a plugin.

Why Not Edit Your Theme?

I probably could have saved some time by coming up with some creative use of the WordPress theme template hierarchy. This, just like writing a plugin, gives the developer a huge amount of flexibility but it doesn't give the developer any power when the time comes to switch themes. Users (including myself) never think they'll have to switch themes but honestly why would you want to lock yourself in? If I wanted to switch themes I wouldn't have to do a thing to make this functionality work.

Share This Functionality

Because I didn't include this functionality in some other theme or post content I have the ability to share this code with others. I put this code up on my GitHub profile and shared with other members of the Blogging For Benjamin competition. I hope that they can use it on their sites so it saves them time. There's also the possibility that they add some extra functionality and if they add some extra functionality and send a pull request to me? Perfect – I'd love to take their work and add it to my site.

Creating Site Specific Plugins

We're always told to separate presentation from logic but how often do we actually take the time to do this? Usually with the deadline of a job there isn't any time to come up with an elegant & flexible solution like this. I know in the past when I felt crushed for time I've thrown functionality like this into a functions.php file or worse I'll put it into the post content or into the theme files. It's actually quite a shame because this little plugin only took me an hour or two to make and now it's as infinitely flexible as I need.

We as developers need to start taking some time out of our day to clearly separate pieces of functionality into specific plugins so we can easy maintain functionality across sites and also so that we maintain a flexible website. It doesn't matter if we think of this up front or after the website is launched. Set aside some time and organize your codebase.

3 thoughts on “Blogging for Benjamin Plugin

  1. We as developers need to start taking some time out of our day to clearly separate pieces of functionality into specific plugins so we can easy maintain functionality across sites and also so that we maintain a flexible website.

    So, so, so very true. Thanks for posting this Patrick!

  2. “There are probably a 1/2 dozen different ways to solve this problem but none of them are as clean as writing a plugin.”

    Very true to a lot of “problems” out there! For me this post in your series is one of the best as it clearly demonstrates a principle with an example plugin. Very well done!

    Keep up the good work, Patrick! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.