Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 107 of 428

Adding Featured Mobile Images via CMB2

The other day, I shared how to add your WordPress plugin to Packagist. In the post, I mention that I did this with a recent project though I didn’t go into any detail about it. In short, the purpose of the plugin is to make it easy to add featured mobile images to WordPress.

For those who are familiar with CMB2, then you know it’s often used as a way (if not the way) for many developers to incorporate custom meta boxes into WordPress. And for the requirements on a project, I needed to introduce the ability to have a mobile featured imaged.

So to gain experience with creating a CMB2-based plugin and to learn how to use Packagist, I thought I’d use the project as an opportunity to do both.

Continue reading

Adding Your WordPress Plugin To Packagist

When you start adding your WordPress plugins to GitHub, one of the next things you’re likely going to want to do is make it easy for other developers to begin incorporating those packages into their composer.json file.

That is, they don’t have to download your plugin, include it in your project, watch for updates, or anything like that. Instead, they add the file then run:

$ composer update

…whenever they are ready to get the latest version of your work.

But simply contributing your work to GitHub is not enough. You have to submit your WordPress plugin to Packagist (of course, this works with other projects, too, but that’s outside the scope of this blog, really).

And here’s how to do it.

Continue reading

WordPress Plugins I Use (As Of 2017)

A couple of weeks ago, an international WordPress-friend of mine, Thorsten Frommnen, tweeted the following asking what WordPress plugins I use (and others use) right now:

https://twitter.com/thorstenfrommen/status/873711220611846144

You’d have to click-through to see the whole thread. I’ve wanted to follow-up with the post for a little while now and just now have the chance.

For what it’s worth, I don’t know if it’s all that interesting to cover all the plugins that I have running. Admittedly, it’s not many (and no, it’s not because I get into the too-many-plugins-slow-down-a-site-debate), but it’s because I just don’t use that many to run this site.

With that said, here’s a rundown of the WordPress plugins I use, why, and where you can get ’em.

Continue reading

Simple Autoloader for WordPress Projects

Earlier this year, I gave a talk at WordCamp Atlanta about Namespaces and Autoloading.

These are two topics that, even though we can’t often use some of the native features of PHP7+ in our work, I think that many of us should be using in our plugin development.

Sometimes though, I think the problem is that developers lack the time, resources, or experience to know where to start understanding autoloaders let alone write their own.

And I want to fix that.

For some time now, I’ve been using a very simple autoloader in my projects. It’s served me well, but I think it could it be more powerful and I think it’s something that others could easily use in their projects, too.

So I’ve started a repository that offers a simple autoloader for WordPress. No, it’s not for WordPress core nor is it meant to be used with themes, but it’s for those who want to begin using autoloading in their WordPress plugins and similar projects.

Continue reading

WordPress Queries with IN Clauses (Who Knew)?

A little over a year ago, I wrote a post on how to use WP_Meta_Query whenever you have a set of keys you want to use to help pull back information from the database.

What about the case, though, when you have a number of different keys that would result in creating a really long array for the WP_Meta_Query class? For example, what if you had to loop through a collection of data before even setting up the query?

On some level, it might feel that like the natural thing to do would be to:

  1. iterate through the collection of keys,
  2. dynamically build up the results,
  3. combine them into a single result set,
  4. then work with whatever you’re given.

But doesn’t that sound a bit cumbersome (let alone slow)?

When it comes to using the WordPress API, I do what I can to stick to it before talking, say, directly to the database but there are also times where it makes sense to write a raw query than to write some type of clever code just to get the WordPress API to work. Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑