Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 317 of 428

How To Enforce Adding a Single Widget in WordPress

For a recent project, I needed to introduce functionality that added a widgetized area to the header of the blog, but only allowed a single instance of a specific widget to be added: the “Search” widget.

Since the dashboard for the widgetized areas are driven the by jQuery and jQuery UI libraries, the implementation is almost completely written in JavaScript, and although I know there may be some criticisms about only allowing a certain type of widget in a widgetized area, here’s how you can enforce adding a single widget in WordPress.

Continue reading

A Reference of WordPress Utility Functions

Comments are closed. Please leave comments on the original post.

One of the nicest things about Twitter is being able to curate who you want to follow, listen to, and engage with as far as your interests are concerned. Truth be told, I wouldn’t know half the people that I saw at WordCamp or that I’ve done interviews or hangouts with were it not for first meeting them on Twitter.

On top of that, being able to answer other people’s questions, chat with others who are far more experienced or who offer alternative ideas, or who provide useful resources is an big plus.

No complaints on something like that, right?

Case in point: Paul Underwood is someone that’s often sharing a lot of great material – not long ago, he shared a great post on a number of useful WordPress utility functions.

Continue reading

Save Time with WordPress Shortcuts

Comments on this post have been closed. Please leave your comments on the original article!

Earlier this week, I had the pleasure of being featured on the ManageWP blog with some other fantastic writers, developers, designers, and bloggers all of whom opted to share their favorite WordPress shortcuts, tools, and tricks for getting their work done faster.

Overall, there were 28 people who were featured all of whom had some great things to say.

Continue reading

Get An Input Element’s Type with jQuery

In a recent project, I’ve been working with large groups of input elements, and the course of action that’s taken depends on the type of element that raises the event.

Since so much of the project uses jQuery, I opted to write an extremely simple plugin that makes it easy to get an input’s type by calling a function on said element.

Continue reading

Some Thoughts on Design Patterns in WordPress

A few months ago, I did a series of articles on Design Patterns in WordPress that was meant to provide an introduction to object-oriented design patterns, and how they can be used when developing projects on top of WordPress.

When it comes to working with WordPress, code is normally written one of two ways:

  1. Procedural
  2. Object-oriented

For procedural programming, think of `functions.php` in theme development, and for object-oriented think of plugins. This isn’t to say that procedural programming isn’t used in plugins – it often is (case in point: Markdown Code For WordPress) – but so are object-oriented techniques (see the WordPress Plugin Boilerplate).

In short, decide patterns exist for a reason: They are proven solutions to common problems that appear in software development.

Yes, they may have to be tweaked a bit for a given situation, but the definition, structure, and so on remains the same. The thing is, I don’t often see many design patterns used throughout WordPress product development.

To be clear, I’m not talking about WordPress core, I’m talking about products built on top of WordPress. Perhaps I’ve just not done enough digging or paid enough attention to some of the work that’s out there, but I think if we – as developers – spent time working on implementing design patterns in our work, projects could have much more longevity rather than devolving into spaghetti code that’s so often found in WordPress work.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑