Are you interested in creating a WordPress plugin?
This article is all about how I learned to build my first plugin. My hope is that it will inspire you to create your own and provide the necessary resources to learn how.
So, why did I decide to create a publicly available plugin?
There were a number of reasons: I wanted to improve my skills as a developer, give back to the WordPress community, and challenge myself.
But the primary event that kicked off this whole endeavor was when a client came to me asking, “Is there a plugin that will let me sort my WooCommerce products on the backend by the amount in stock?” I did some searching, and when I couldn’t find a plugin that did this, I decided to build it.
How I Learned To Build A Plugin
1. Learning The Basics Of PHP
If you want to build a WordPress plugin, you need to know the basics of PHP. You don’t need to be a PHP expert, but you do need to know your way around the code a bit.
The primary way I learned PHP was by customizing WordPress themes for clients. Perhaps you have been working with WordPress enough that you too have picked up these basic PHP skills.
If you haven’t, you can learn PHP for free through Codecademy.
In fact, I took this course about two years ago just to brush up on my PHP skills.
So, even if you have been working with PHP in WordPress, I would still give Codecademy a try. It’s definitely worth the time.
2. A Plugin Tutorial
When I’m learning something new, I like to follow a tutorial (at least in the beginning).
A great tutorial for learning how to build a WordPress plugin is Tom McFarlin’s Introduction to Plugin Development available through tutsplus.com. It isn’t a free tutorial (you’ll need to subscribe to tutsplus), but it is definitely worth it. Tom is one of the top WordPress developers and has built numerous plugins. So without a doubt, he knows his stuff.
One of the primary reasons I decided to take this course before jumping into plugin development was so I could learn the best practices involved in building a plugin.
When it comes to plugin development, following best practices is incredibly important.
3. Make Your First Plugin Simple
When I started brainstorming what my actual plugin would do, I started coming up with all these extravagant ideas.
However, the more extravagant the idea, the more complex it is. And the harder it is to build. For your first plugin, you’ll want to keep it as simple as possible.
Let’s look at the plugin I built as an example. It does one thing and one thing only: it lets a user sort WooCommerce products by stock amount.
From a functionality standpoint, it is extremely simple. I don’t have to worry about creating any settings pages for the plugin, or work with any code that’s too complex.
In fact, you could probably even go simpler for your own plugin. One of the simplest plugins I know is one that will let users add their Google analytics code to their blog.
Obviously, it’s already been done, but for your first plugin, it’s not a bad place to start.
4. Learn Git And SVN
Basically, they track any changes that are made to files in a directory and allow you revert to other versions or see what changes have been made.
I like using Git as I build my plugins to track changes I make.
If you plan to release your plugin on the WordPress directory, you’ll also want to know SVN as that is what they use to track versions.
Now, I found Git much easier to learn than SVN.
So I recommend you do the following:
Take this free course from Udacity: How to Use Git and Github. It will teach you the basics of version control.
Then, once you have a basic understanding of Git, check out SVN and how to use it with the WordPress Plugin directory. The WordPress.org website has a great article on how to use Subversion.
5. Look At The Code Of Other Plugins
Finally, play with the code of other plugins.
Luckily for us, the WordPress plugin directory has thousands upon thousands of well written plugins that you can download and dissect and learn from.
Look at some of the plugins you like the most. Check out the code. Try breaking and fixing it. See if you can understand everything it does.
And if you are adventurous, try rebuilding it.
I did this with a few plugins I liked just to get a feel for how the plugins are coded.
Final Thoughts On Building WordPress Plugins
It is immensely satisfying when you build your first plugin. You’ve found a problem and built a solution for it.
And, if you can then get it onto the WordPress Plugin directory, the moment your plugin goes live, it is incredibly exciting. When mine went live, I shared it with everyone I knew.
If you’ve thought of building a plugin, stop thinking about it, and start building.
I’ve talked with many plugin developers and always ask them what’s the one piece of advice they have for those considering developing a plugin. And they all say this: just go out there and do it.
The post Want To Create A WordPress Plugin? Here’s What You Should Know appeared first on Torque.