Well, I’ve done it. I’ve made my first WordPress plugin and it works. Consider this my “Hello World” project, if you will.
In my last post (right below this one) I shared how to add a column that shows the featured image from a post directly in the Post List on the Admin side of things. I thought this was a great way to do this, until I read How To: Build Your Own Functionality Plugin by Eric Dye over at WPDaily.co. In his article, Eric sums up a functionality plugin by saying:
To put it simply, a functionality plugin is a way to separate what you would normally have in a Theme functions.php and place it in your Plugins. All those cool snippets that begin with “function” can be placed here.
So I thought to myself: Hey, I’ve got some stuff in my functions.php file that I want to use with other themes. Let me give this a try. I chose to tackle my function that adds the featured image into the Posts List screen. My original code worked when I plugged it into the framework that Eric shows. If you want to give it a whirl, grab a copy of the code from my last post and use it along with what Eric posted.
Then I decided to re-write the entire thing. I wanted to move the Thumbnail column to the far left side of my Posts lists and I couldn’t figure out how to do that. So I started digging around and found a different way to do this. I’m not going to pretend to completely understand what all the code in my plugin is doing. I’m just starting to learn how to break down PHP and learning what does what. There is a lot of PHP in this plugin that is new to me. Fortunately it works, so I don’t have to know how it works (yet)!
I’ve uploaded the plugin to my GitHub repo. Feel free to take a look at the source code, or to download this plugin and use it for yourself. This is version 0.1, so it’s potentially using outdated methods and might be a giant security hole. So use it at your own risk. I also want to figure out how to add support for this to the Pages list and how to get equally sized images every time.
Download from GitHub