How and why I created a plugin called Business Matchup
One of the things that I have noticed is that it is sometimes tricky to sit and write content that you want to share and have people engage. The main issue that gets brought up most of the time is that it takes too much time. So first, you sit down and think about what you want to share. Then, there’s the planning, proof-reading, deleting, starting over, and the eventual moment of pushing publish and calling it a day.
So, I began to think of a way that you could generate some content. It had to be simple, but not so simple that it would be short and not be very engaging content. It needed to be simple and help empower you to sit for only a few minutes to make 3 or 4 decisions and then walk away. Then, I stumbled onto an idea while talking with my friend Glenn.
What if there was a way to create a poll that you could then share with your friends, followers, current customers, and potential customers that allowed them to share their voice with you in a fun and unintrusive way? So, we started to think of ways to engage with people in our community, and there it was. Other businesses and which ones we liked the most.
It was a perfect starting point to the content generation concept that had been at the back of my mind. By the way, this is also the moment where I chose to challenge myself, level up my coding abilities, and pursue the goal of not only writing a new plugin. Of course, I’ve done that a few times already. But to have this be the first plugin, I submit for approval to WordPress.org.
Planning for development
Now that I knew what I wanted to do, it was time to develop the rules of my new challenge.
- Security: This plugin needs to be above the WordPress coding standards and pass multiple security checks.
- Code with Collaborators in mind: This codebase needs to be Open Source, and it needs to be readable by humans who may want to extend or add features.
- Pass Peer Review: The WordPress plugin will be reviewed upon submission by the WordPress plugin team.
- Clear and Helpful Documentation: Just because I know how to use it doesn’t mean everyone else does. Help users understand how to get started and how to use this plugin.
- Five For The Future (#5FTF): This will be a collaborative project, so why not reach out to others and invite them to participate and give back to the community in the process!
Now that all of the planning is out of the way. I was ready to begin working on the first step of the process and create the public repository for the code to reside in during development on GitHub. Welcome to the world, Yelp Polls.
Wait, Yelp Polls? Yeah… we’ll get to that later but follow along with me for a moment.
How can I start coding from a known good spot and ensure that my code is secure before it goes out into the wild? I could enforce local coding standards within my editor and follow best practices. But, that’s boring, and I already do that. Next! What about integrating security and linting services to validate the published codebase to see if it can pass more than just the WordPress standards?
I did some looking around, and I settled on one that I can run locally in my terminal that would help me identify security issues within the dependencies my plugin might end up using. The other service I found was free for open source projects provides linting services using more coding standards that are much more critical.
Getting set up with Snyk was pretty straightforward, and it allowed me to safely scan my project on my local machine before I submitted the code to the repository on GitHub. After that was in place, I used the WordPress plugin scaffold within WP CLI to start creating the new plugin quickly.
I wrote a few simple functions and then pushed the code to the repository. It was now time to integrate the Codacy service with the GitHub repository and get the first nightmare of issues to resolve and fix. This was when I knew I was on the right track if I was trying to challenge myself. Right out of the gate, I had issues to resolve that came from some code I didn’t write and some code that I did.
After a few moments of triaging and addressing these new issues with the code, I continued coding and got back to work.
Code With Collaborators In Mind
One of the bad habits I struggle with is that I generally neglect to document my classes and functions in personal projects like this. And this is one thing that can’t happen here, and I need to identify the types of variables they will be using and what you can expect to get out of them. Just because I know what is happening here doesn’t mean that someone else will.
It was a quick moment to write out the documentation blocks, and the plugin was well on its way. Up ahead was one of my favorite days at WebDevStudios, Five For The Future! Throughout the week, we are all going on about our routines. While working through our various projects. Within our various meetings, we would be asking each other what we were thinking about doing. I mentioned that I had this plugin I was working on and could use some help with the styling and design for the content pages.
Christina Workman said she would be happy to help out with that, and help she did! With her help, the cards that the business locations were going to be placed into were now using Grid CSS and were mobile responsive. In addition, Christina’s help allowed me to focus on the API integration with the Yelp API service and StrawPoll.
By the end of the day on February 25th, the plugin was working, and the code was passing almost all of the linting on Codacy without any issues. So you caught that, too, right? Almost.
Yeah, this is where I ran into an issue that I still can’t resolve at the moment. So I put the case to our entire engineering team here at WebDevStudios, and we all came to the same conclusion. You can’t satisfy this linting rule pattern because you have to include, require, include_once, or require_once your autoloader for PHP to know where to load your classes from if they are in other files.
I left the note regarding the issue as a comment in my plugin and left it at that. Case closed. Or, so I thought.
Pass Peer Review
As the day came to a close, I was pretty confident in the state of the plugin, and I was excited to submit it to the WordPress plugin review team. However, before I do, I should go back through the plugin guidelines and ensure that I didn’t overlook anything.
There it was, the one item I had overlooked, and this one was going to require me to rename the plugin. I was pretty annoyed by this revelation, and I blamed myself for not catching it sooner. Outlined in the plugin guidelines is rule number 17. It stared back at me as if I owed it money. I can’t prefix my plugin with the word Yelp because that’s a trademarked name.
I spent the weekend kicking around various name ideas that conveyed what you could do with the plugin while still being fun and inviting. Then, after I settled on the new name, I had to back through the plugin code and replace all of the areas where I had used Yelp Polls so that I was following best practices and helping keep things identified.
The following week was pretty rough. I misunderstood what the plugin review team had wanted me to correct initially and changed the prefixes of my function names a few times. Once the changes were completed and submitted, I got another email. This one pointed at the comment I left in the plugin regarding that linting rule that I couldn’t resolve. Yeah, that comment. Their discovery of that comment started that conversation again, and this time it was with the WordPress plugin review team. We had a few back and forth emails about the issue, and I was given some methods to try, but none of them resolved the problem with the Codacy linter.
Finally, I made the swap I was trying to avoid and swapped my autoloader out for the simple option and went with using Composer. Using the Composer autoloader allowed me to use a PSR-4 based autoloader, follow best practices, and clearly define the classes I wanted my plugin to load. This also meant that I needed to refactor the plugin. I mean, I might as well since I’m already ripping things out here.
Code refactored and another resubmission to the review team. My confidence was starting to shake that this would pass review. Another email comes in a few hours later. The review team still sees the problem in my code and not the new composer autoloader. I go back through the code on GitHub. No, this is using the composer method. I checked the zip file in the release using the link I sent the review team, and no, that is also definitely using the new composer method. I asked them to check again and send them the link, and I can see from their reply and screenshot that they do not see the updated code. I bumped the version of the plugin once more and made a new release. My email inbox goes silent.
The weekend passes, and the plugin review team still has no word back. So, I direct my attention back to my work, press on, and refresh my inbox every once in a while as I go on about my day Monday.
March 21, 2022. An email notification pops up just before my morning team meeting. It says, “Business Matchup has been approved!” My jaw drops, and I can barely contain my excitement as I join the zoom meeting. Talk about perfect timing! This Friday is 5FTF!
That brings us up to today. It’s Five For The Future, and I published my first plugin to the WordPress plugin repository, and I met the challenge I put before myself. It just shows how good it feels to set a goal for yourself, persevere, and push yourself on to be successful at it. Yeah, the bar was a bit higher than usual. Yeah, I struggled a bit here and there. At the end of it all, though, I can see just how much I learned and grew through that process.
In the next blog, I’ll share what I struggled with when writing a readme file, showing documentation to users, and the steps I took to deliver on the goal I set for myself regarding that documentation.
You can find the new plugin on WordPress today using the name Business Matchup, and if you do happen to check that out, you will also see the link to the documentation.
Contribute often, dream big, and push hard for those goals that you set for yourself. You can do this. I did.