The Mess I've Created
For a recent interview, I was given the challenge of creating a WordPress plugin. I had only worked with PHP for about a week and I had just gotten WordPress running locally the day before my interview. (I did tell both of these things to the interviewer.)
I went through the usual phases of my development cycle:
Confidence -> Uncertainty -> Insanity -> Breathe -> Make it Work
I had many challenges, beyond just writing unfamiliar code. I couldn't get my local environment running and under a time crunch, I tried to use a free web host for my testing environment. (I quickly exceeded their allowances).
How I Made It Work
After I was locked out of my second free web host, I knew I had to get my local server running. The WordPress download didn't include any server or database programs, so after a little research I installed Xampp which was very easy to install and use.
Now I could finally breathe and write some code. Or so I thought.
My Not DRY Workflow
My workflow was a frantic, panicked mess. I didn't have time to dig in and properly learn WordPress. I just had to make it work and go.
Here's what I did:
- Write code
- Zip code files
- Upload zip to dashboard
- Install plugin
- Test
- Uninstall plugin
- Repeat
Since I didn't have enough time to fully understand WordPress, my workflow was less than ideal and this is why I am writing you.
Your Suggestions?
So, now that I've made my code work and submitted my project, I'd like to learn how to do it better. What are your experiences developing for WordPress? How can I make my processes more DRY (dryer?)?
Thanks for reading and cross your fingers for me getting this job 🤞.
Top comments (3)
As for your local enviroment i agree with Mike, your best of with local by flywheel for these kind of tasks.
As for your workflow... In your WordPress install there is a folder called wp-content, inside that there is a folder called plugins. Just create a new folder there with the name of your plugin. inside that folder create a php file with the same name. Add your plugin header to that file (developer.wordpress.org/plugins/pl...) and you have a empty working plugin, and you can just write your code there instead of zipping and uploading all the time.
Next you will have to check out the wp plugin api (developer.wordpress.org/plugins/ho...) and you can start hacking away.
If you have more questions let me know... :)
As far as local Wordpress development environments go, I'm a huge fan of Local by Flywheel. It might not let you tweak subtle aspects of the installation, but if all you want to do is spin up a new Wordpress install to develop on, it probably takes all of 30 seconds to configure and it'll handle all the heavy lifting.
If you're venturing further into Wordpress development, IMO the tools made by Roots are the best out there. I typically just use Sage, their 'starter theme,' but they've got a whole ecosystem of tools designed for high-quality development on Wordpress (including some designed specifically for plugin development).
My suggestion is docker...you can easily spin up a dev stack wordpress site locally. While you focus on writing your code and spend less time on wordpress infrastructural setup.