19
Jan 11

My First Open Source Project

As I wrote in the previous post, one of my New Year’s resolution for 2011 is to write at least one blog post per week. Unfortunately, it’s not something I can simply mark as “done” until the end of the year. But another item on that list was to publish my first open source project, and that’s what I decided to do today. One of the projects I’m working on (a WordPress site) needed a sidebar widget that looked like a calendar, with each cell being a month showing how many posts were published on that month. Since I couldn’t find a plugin with that functionality, I decided to write my own. After I finished writing the plugin for the project, I realized that it was fairly simple to make it more generic and publish as a WP plugin.

Writing a WordPress plugin is quite simple. There are a few things you need to do to make it a sidebar widget (basically you just have to extend the WP_Widget class and implement a few functions) but nothing too complicated. I also took the opportunity to learn how to use AJAX inside a WP plugin, since I didn’t want to refresh the whole page when changing years in the calendar.

So there you go: today I’m publishing my first open source project, a WordPress plugin called Month Calendar. The source is available at GitHub, and the plugin is also published on WordPress Plugin Directory. It’s an important milestone to me, and it was a fun pet project. I learned a few things while making it, and now I feel ready to write a couple more complex plugins I’ve been planning. You can see the plugin working on the sidebar of this blog, if you’re curious.

Fun fact: the hardest part in the development process was to publish the plugin to the WordPress Directory, since I use Git and WP forces you to use a SVN repository. But after playing with Git’s SVN bridge for a while, I found an elegant solution. Since it’s not trivial as I thought it would be, I’ll write a blog post tomorrow detailing the whole process.

Tags: , , , , , , ,

5 comments

  1. I haven’t used the plugin yet but looks really nice. Willing to know how the process works from git to svn. Keep it up ;)

  2. Hi!

    Thank you for this great wp plugin. I installed, appears in the theme section correctly and I can pull it to the sidebar area too. It appears on the site, post numbers and month are okay, but it doesnt work right with pagination of the years. Simply nothing happens, when I try to change year.. :S

    I put the 1.8.6 jquery in my header and also had to move your css into the theme folder.

    Please help me, really need this feature.. :)

    Thank you in advance
    Peter

    • Rodrigo Sieiro

      Hello Peter!

      This is probably related to jquery or jquery-ui loading.

      The plugin automatically loads jquery and jquery-ui if it detects that they’re not loaded, but some problem may have prevented them from loading. You can check this using Firebug on Firefox or Developer Tools in Chrome/Safari. Try to look at the page source to see if both jquery and jquery-ui are loading, and also look at the console to see if you’re seeing any javascript errors.

      If you see any error, send the message to me and I’ll try to find a solution for you.

  3. Translation (français > anglais)
    Hello,
    I would like to display in your calendar my future articles, not just those of the past. Where should I make the change in the code.
    thank you

    • Rodrigo Sieiro

      Hi clodius!

      Check the SQL query in line 174 of month-calendar.php. You must remove the “post_date” clause and add the status for future posts (it only shows published posts by default).

Leave a comment