Do you want to build a WordPress plugin? Want to improve your development practices? Or are you just curious about the process? You came to the right place..
Here at Premia we live for WordPress Plugin development. Our own product is based around it: We’re the missing link between Github and Woocommerce, for selling your paid WordPress plugins ánd for keeping them up-to-date.
The easy part
We’ve also made it quite easy to get started on a WordPress plugin. Just head over to the Premia homepage, fill in the “Generate plugin template” form and there you go: You have your own WordPress plugin. It doesn’t do much, but you are able to upload it to whatever WordPress website you want to run it on.
Is is that complicated?
If you’re a bit familiar with web development, especially on the PHP side, then it doesn’t have to be that complicated. Although it does depend a bit on what you want to accomplish. Want to show a GIF after every blog post? That’s not so difficult, you basically just need to ‘hook in’ to the ‘the_content’ filter.
Hook into the_content filter? Right..
Yeah. Hook into the_content. WordPress uses a lot of actions and filters. Imagine an action as in ‘opening a door’. You can hook into it, and do something afterwards. So, “when the door opens” -> “play a sound”.
The same goes for filters. Only, we’re literally filtering something there. Imagine putting mud through a filter: The water dissappears and the sand remains. Luckily, we can also use the filter to add stuff. In this case we can show extra content, like a GIF, after each blog post.
We’d use the following code for that:
The HTML that we add to
$content is copied from Giphy: https://giphy.com/gifs/wordpressdotcom-diversity-wordpress-radiate-jTqfCm1C0BV5fFAYvT
That isn’t too difficult, right?
Now, when you generate a plugin template from the Premia homepage, you’ll receive a ZIP file. Open the main PHP file and you’ll see similar code, although structured a bit different – it makes it a bit easier to read.
Do you see the
add_action function there? It’s very similar to the
add_filter in the example above. The only difference with the filtering is that we return something while the action does not return anything. It executed something directly.
A local development environment
Local development; essential for plugin development. It’s like seeing the definitive version of your PDF document each time you hit ‘Save’. Instead of having to print it first.
There’s a lot of options when it comes to local development for WordPress, here’s a couple of options:
- Mamp: https://www.mamp.info/
- Local by Flywheel: https://localwp.com/
- DesktopServer: https://serverpress.com/get-desktopserver/
- XAMPP by Apache: https://www.apachefriends.org/index.html
CodeinWP has a nice round-up of these tools, you can find the article here.
Ready to start selling?
When you’re ready to start making money with your WordPress plugin: We’re here for you! When your plugin is ready, just upload it to Github, setup a Woocommerce store, install Premia and you’re good to go.
To get a glimpse of the full process, from start to finish, check out the video below: