Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 174 of 428

Using PHP CodeSniffer with Atom

Using PHP CodeSniffer is one of those tools that is part of my workflow that I find utterly invaluable. I haven’t always used it, though.

Don’t get me wrong: If you’ve read this blog for any length of time, you know I’m big on Coding Standards. But when it came to the PHP CodeSniffer, there was an extended period I had gone before I installed it.

Why, though?

Simply put, it was because I didn’t know it existed, at least not for WordPress. When I discovered there was a ruleset for WordPress (and WordPress VIP), it became something that I believe should be a necessary tool in every WordPress developer’s toolbox.

Depending on your IDE, you may or may not be able to install a plugin or an extension that will automatically monitor your code while you’re writing.

I made the change to Atom some time ago, which I’ll share more about momentarily, and it has excellent support for incorporating PHP CodeSniffer into your workflow.

Continue reading

Praise in Public, Reprimand in Private

“Praise in public, reprimand in private” is a phrase that I heard years ago (and I can’t remember who I actually heard say it first), but it was one of those things that stuck with me.

When you hear phrases like that, I think we often consider things like parenting, leadership, managing a team, or something similar. But do you ever think about it in terms of blogging, tweeting, or what we share online?

For anyone who works online the majority of the day and is engaged in some form of social media, I think we’re used to seeing people both praise and critique others be it via tweets, blog comments, and so on.

And sure, there’s something to be said for “calling people out” for whatever reason, but I think there’s something to be said for also handling some of that stuff privately.

Continue reading

Sharing GPL Code and Its Ethics

“Sharing GPL Code” sounds like such a loaded title because the topic is forever hot. But hang with me because the purpose of this post has nothing to do with actually arguing for or against the GPL or code around it.

I know the simple answer is that all GPL code, by very nature of its license, it’s available for sharing, but there’s another aspect that plays into this I want to discuss.

Sharing GPL Code

Sharing GPL Code can be more about collaborating on code, right?

 

And that’s this:

What is the ethics of sharing the code for a project that you’ve built for someone else even if it maintains the GPL?

For the most part, I think it’s fine. But when you’re running a business and you’re building solutions for clients, there’s a little more to it.

At least, that’s my experience.

Continue reading

Detecting Copy and Paste in JavaScript

Detecting copy and paste in JavaScript is not something that’s new to web development. How you do it may vary, though, depending on the set of tools you’re using.

Cut and Paste in JavaScript

Cut and paste, not cut and tape. And not like this.

Given I focus primarily on WordPress, the majority of the JavaScript I write uses jQuery. And though there are a number of ways you can go about doing this (which I’ll talk about later), some of them are deprecated (though they still work).

Anyway, so I was specifically looking for a way to handle the case where a user pastes content into a field using keyboard shortcuts.

Continue reading

The Right Hook To Initialize WordPress Plugins

When I first started working on WordPress plugin development, I used to obsess over the right hook to initialize WordPress plugins. That is, I thought there was one hook that would sit above all other hooks and prevent me from needing to go looking through the Codex or other source code to find the right one.

But that’s not the case.

To be clear, this isn’t to say that there aren’t some strategies and some hooks that work better than others in many, many cases, but there are times where whatever you’re used to using isn’t going to work. This depends on how you’re structuring your plugin, and I’ll talk more about that in a moment, but there’s isn’t one hook to rule them all when you want to initialize your WordPress plugins.

Initialize WordPress Plugins

By now, you likely know the whole deal about the one ring, right?

Instead, you’ve got to find the one that suits your needs best for the functionality you’re introducing.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑