Hacking WordPress: Use the meta_query Luke

WordPress is powerful. It is hard for anyone to deny that fact. It has years of programming and thought put into it so there is no doubt that it is a solid project. Sure, criticize the code as I roll my eyes because everyone criticizes the code. Get past that point and you realize utilizing an existing platform that focuses on users might just be the right thing to do. Battle tested so to speak.

I am writing the Hacking WordPress series to help gather my thoughts on what I am learning each week in the hopes that I can assist a newcomer in the future. This first post is about using meta_query to modify WP_Query. Come on in! The water is warm… sometimes salty.

Continue reading “Hacking WordPress: Use the meta_query Luke”

Radio Buttons With Taxonomies in WordPress

Build a Custom Walker for Radio Buttons With Taxonomies

Stephen Harris did a great tutorial in 2012 with a radio button and taxonomies. I found it a bit complicated for what I was trying to accomplish for the WP Event Calendar Plugin.

I was trying to simply replace the drop down list with radio buttons in meta boxes. The user can select a radio button and be on their way. This cannot be that hard! After doing my due diligence I found an object I could extend: Walker_Category_Checklist.  Walker_Category_Checklist is used to create hierarchical taxonomies in WordPress. I can leverage that to output radio inputs instead.

1. Add a Walker Class and Functions

The walker extends core, changes the input type to radio, and value to the name of the taxonomy. See line 44. The rest is a copy of the core walker functionality.

2. Change Drop Downs Based on Our Taxonomy

Line 61 assists us with wiring the plugin. wp_event_calendar_taxonomy_args() searches for the taxonomy we want radio inputs on and applies the post_categories_meta_box callback. This is necessary so we can pass in our walker in the next step.

3. Getting the Radio Buttons Working With Taxonomies

Line 79, wp_event_calendar_checklist_args(), does a final check that we are the correct taxonomy. It applies our custom walker and we call this with our hooks for the plugin like so:


WordPress has a lot of core classes and functions that can be extended. I found this one by digging through the documentation and feeling uneasy about reinventing the wheel. That’s what led me to Stephen’s article in the first place.

This still allows us to add new terms for the metabox and just extends WordPress’s walker functionality. You can see the full pull request for the WP Event Calendar on GitHub.


Choosing the Right Tool

Ian Baker

At work we get into discussions regarding the best tool for the job. It doesn’t necessarily have to be about programming. These are all good conversations to have, but there is a point where you have to make a decision and it might not be the best decision.

I am beginning to get to a point in my career where it doesn’t matter too much about the language we pick or which cloud service we use. It matters more to me that we are delivering on the customer’s needs and fulfilling our promises.

If you’re anything like me, when I started development, you will start looking at a few things. What is the best programming language? How quickly can I get something done? Do I need to learn Java to understand programming?

I’d encourage you to instead think about the problem. What do you need to solve for your customer? Don’t worry about the database or the code yet. What specific problem are we solving? Are you going to need real-world sensors to communicate with the customer’s manufacturing facility? Do you need to solve an inventory control issue? Do you need to publish product to an online store? Think about the problem first.

Once you have thought about the problem I encourage you to flowchart out what the solution is. It helps sort out the problem for your own sake and is an easy document to give to coworkers to validate an aspect of the problem. Have you notice we didn’t talk about which tool is the best tool to use yet? The only thing discussed was the problem at hand. I didn’t ask you to think about how the data is supposed to be stored, what language to use, what framework, etc, and honestly, it does not matter.

How to pick the right programming language?

Pick what you feel is natural and what you find accomplishes your personal goals. I originally chose PHP early on because it allowed me to create websites that could interact with a database and be dynamic. I continued using PHP until it was no longer capable of a customer’s demand: counting plastic pulleys rolling down a ramp.

For counting the plastic pulleys I chose an Arduino and learned the basics of C and eventually meandered over to Python. When Liturgical Publications had me evaluating the recent mobile application they purchased I made the choice to learn Angular and become more comfortable with Javascript.

I picked the language that I thought was best suited for the job at the time. You need to pick the one that is right for the job instead of debating over the perceived fallacies.

What Would Dad Do?

I am not sure why but I always imagine what my Dad would do. What tool would he use? He would definitely participate in the conversation or debate over a proper tool. In the end, Dad would not care what tool was used, he would only care that the job was done properly. I want to conclude with one of WordPress’s philosophies that highlights this point and am also curious what you think about this matter.

“Many end users of WordPress are non-technically minded. They don’t know what AJAX is, nor do they care about which version of PHP they are using. The average WordPress user simply wants to be able to write without problems or interruption. These are the users that we design the software for as they are ultimately the ones who are going to spend the most time using it for what it was built for.”

Why do we burnout?

We are engineers. You and I love to solve things. They might not be puzzles or even complicated. They just need to have the end result of helping people and we will jump right in and attempt to solve it. Why is that? What makes us stay up all night at a moment’s notice? Does it seem like their is a sign around your head that reads “Will work for compliments”?

Why do we burn out?

Continue reading “Why do we burnout?”

Read when you need to know what you’re doing matters

We all feel under the weather certain days. I do and sometimes cannot put my finger on why.  I blame the absence of things typically: sun, vacation, money, etc. I start to question if what I am doing matters – really MATTERS.

Hi, my name is Chris, and I have imposter syndrome. This gets in my way when I need to know what I am doing makes a difference. I know you feel this way too so let’s reaffirm why you are here. Continue reading “Read when you need to know what you’re doing matters”

Contributing and Releasing Vagrant Hosts Updater 1.0! oops 1.0.1

At LPi we extensively use open source tools in our daily development cycle. One of the tools that I have personally grown to love is vagrant hosts-updater plugin. I reached out the original developer to see how I could help out and ended up becoming a contributor and project maintainer.

Continue reading “Contributing and Releasing Vagrant Hosts Updater 1.0! oops 1.0.1”

A programmer’s guide to being productive everyday

Pomodoro Stack Overflowage
Pomodoro Overflow

I need lists to help me stay productive each day.  I’m sure this isn’t unique to me or the industry but without a list there are some days where I feel too distracted or disoriented.  Sometimes even with a list of things I get distracted! Here are some tools that I started using to help me become more productive everyday.

Continue reading “A programmer’s guide to being productive everyday”

How to Migrate from SVN to Git

You’re still using SVN!?

Jim Blandy trembles as he watches Linus tempt you to come closer. Linus throws his VCS at you with horrible puns such as: ‘Git closer my boy’ and ‘In Git We Trust’.  He appears angelic while you are wondering why Jim ever captivated you in the first place.  Maybe it was the SVN charm?

You start forgetting the SVN commands. Worse, you start confusing Git commands with SVN when talking to friends. No longer will you be the only person answering yes to, “Does anyone use SVN?”. As soon you are done migrating to Git you will be denouncing SVN. You are starting to smile now and begin to think of ways to act like you’ve always ‘Gitted’ before.  SVN? What is that!?

Your smirk drops.

It dawns on you that you have to migrate your code repositories first and you have no idea on how to start.

Continue reading “How to Migrate from SVN to Git”

The Importance of Refactoring Your Database Schema

Programming an application is a pretty daunting task.  There are similarities between all applications but significant differences that require a programmers to work together.  The more I work on “rescue” style projects or help out in the open source world, the more I think that programmers need to sit down and think through the database design.

When it comes to designing a good schema you need to know most of the requirements.  I say most because trying to know all will lead you astray, this is software development after all.  For my Trail Status project I kept the schema small, but when the project starts to grow it can easily adapt into a more well rounded schema design.  Here are the project requirements for data to be stored:

  • Trail state (open/closed)
  • Coordinates to trail
  • Name
  • Translation (if translated from phone call)
  • URL slug

If the table grew to more trails without adapting or refactoring the schema you would be setting yourself up for failure.  What happens when there are more states like permanently closed, open soon, or under maintenance? If I let the data just grow without refactoring the schema I would be adding unnecessary code to try and manage my mistake.

Here is your challenge…

The next time you work on anything: pick a table and try to find a way that the schema design can be refactored.  Kudos if your schema is up to snuff! I know most out there need a good cleansing.