Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 135 of 427

WordPress Deals for Black Friday 2016

This is that day of the year where everyone is offering deals for different products and services at a discount. It’s a pretty sweet deal, isn’t it?

It’s also one of those times where a lot of people try to build up affiliate links to make some extra cash along with promoting said products and services. I don’t necessarily think there’s anything wrong with that, but it’s not my style.

So I thought I’d try something new for this Black Friday: Earlier this week, I asked anyone and everyone I knew to share the sales they had going on, so I’ve listed what I’ve found below.

None of the links are affiliate links – they are just responses (or tweets) or emails I’ve received over the past week.

Continue reading

Happy Thanksgiving!

We’re celebrating Thanksgiving in the United States today. If you’re doing the same, Happy Thanksgiving!

Happy Thanksgiving 2016

Meghan did an awesome job with the table – if was left to me, there’d be no photo. :)

If not, I hope your day is going well and that maybe you’ve still got a thing or two or nine for which to be thankful. 🙂

Continue reading

Buffering WordPress Content with PHP

I know: If you’ve been working with WordPress for any amount of time creating themes or plugins, then you’re probably familiar with filters. Even if you’re not really sure how they work, you’ve likely worked with something like the_content.

And by that, you’ve likely written a line of code that looks like this:

It’s enough to work with, too. Usually, this is used whenever you want to modify the content before sending it to the browser to render.

But I recently had to work with it in a somewhat unusual way that required the usual of this filter, a template file, and PHP’s output buffer such that I was buffering WordPress content.

Continue reading

Properly Writing WordPress Plugin Constructors

One of the things that many of us see (and are guilty of abusing) are WordPress plugin constructors.

If you’re using object-oriented programming, you’re likely familiar with constructors. However, the purpose they serve isn’t always clear at least in the world of WordPress.

The definition of a constructor well-defined in Wikipedia:

In class-based object-oriented programming, a constructor (abbreviation: ctor) in a class is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.

But here’s the key thing to notice for anyone working with constructors and object-oriented programming in WordPress plugin development:

It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.

And this is where many of us, and WordPress plugin developers, fail. We abuse constructors for a purpose they are not intended.

Continue reading

Initializing Default WordPress Options

Whenever you’re working on a plugin that’s going to have a decent set of options (and I’m not talking about giving users too much to think about because “decisions, not options,” remember?), it’s wise to initialize default WordPress options.

Default WordPress Options in the Options Table

By that, I mean it’s important to set up an array or whatever data structure you like to use (but WordPress does love its arrays) and prepare them to be saved before the user even interacts with the settings page(s).

Think of it this way:

A user installs a plugin; they’ve yet to select any option; we need to drive the UI elements through input fields, checkboxes, radio buttons, etc., so we have functions that make calls into the database. But where they are they going to get their options?

That’s where this come into play.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑