My First Plugin For WordPress – A Nice and Simple Start
As I have mentioned before, I wanted to contibute to the development of PHP Based Open Source CMSes. I decided to start with Plugin Development for WordPress. A large and nice Documentation on WordPress itself, Very large number of Tutorials on other sources on web and a supa-large and an always ready-to-help community were important factors that influenced in my decision.
As I started to understand basic structure of the Plugins, I wanted a simple idea to work upon.
As an amauteur blogger, I always had this nick to know about how my posts are doing amongst my Readers(which are infact very less But Still). I picked upon this idea and made a head start. First thinking what Exactly would I need, and then Researching and asking questions on forums on what exactly is available to me(hooks,filters,functions) from WordPress were my first steps.
After this, it was time to code. ! A fresh copy of WordPress installed. The basic Plugin Structure is basically A Plugin PHP File that actually contains functions that actually do some work and Secondly a PHP file to create an options page for the same. Screenshots and other stuff are later ones.
After my brief research amongst the various sources mentioned above, I had understood that I needed to store a simple Counter for each post/page in the wp_post_meta table in the WordPress Database. The functions ‘get_post_meta’, ‘set_post_meta’ and the various useful parameters and the return values made it quite nice to work with. Playing with those functions, I finally got my algorithm and coded the Main PHP file with all the functions, actions and hooks.
After this was the second PHP file for the admin menu. The main options that I wanted to include in the Admin page were :
- It will show the table with post-names, post-author-name and post-meta(post_views for that post)
- It will provide an option to the admin to re-initiate the post/page views of any post/page to ‘1’.
After this was done, I worked on making it look more like a WordPress thing.
And It was done. I finalized the Read-Me file and Uploaded it to Git. and then sent the Plugin for review to WordPress. Within a few hours(36-48 Hrs), I got the mail confirmation that my Plugin was accepted and it contained a link to my svn(Subversion) repository. I uploaded my plugin there and all was done. Within a few minutes from there, the link showed my Plugin.
It was a nice head start for me in WordPress development. Lets see what I can do in future. Hopefully, I will come up with a better and more useful plugin than this soon.
Till then, Bbye. !! 🙂