Software Engineering in Web Development, Backend Services, and More

Category: Notes (Page 36 of 50)

Notes on programming-related problems that I’ve encountered while working on various projects.

Strip Hidden ASCII Characters

Late last week, I was working on a project that was responsible for reading the contents of a CSV, parsing the information, and then inserting it into the WordPress database.

But I hit a snag (as we so often do, right?): The first few rows of the CSV were working fine, but a number of the rows were failing to import.

The thing is, there appeared to be no rhyme or reason. I made sure the CSV was a raw text file and even saved a new version of the file using a raw editor twice to make sure any, um, ‘stray’ characters were being removed.

Unfortunately, it didn’t work so rather than spend time trying to reformat the entire file, I ended up writing a small regex to strip hidden ASCII characters form the incoming information.

Continue reading

What’s The Proper Way To Instantiate a WordPress Plugin?

When it comes to plugin development – be it either widgets or plugins – there are several different ways in which we can instantiate a WordPress plugin.

Unfortunately, you’re likely to get a different answer depending on who you ask, or what you read.

Case in point: According to the WordPress Codex, instantiating a WordPress widget is done like this:

add_action( 'widgets_init', create_function( '', 'register_widget( "foo_widget" );' ) );

But I know several people who are adamantly against using create_function.

Though I personally don’t have a problem with it, I’m always interested in hearing others’ approach to how they do it and why.

So in this post, I thought I’d lay out the various ways to instantiate a WordPress plugin, pros and cons of each, but also ask each of you what your favorite method is and why.

Continue reading

Resolving WordPress jQuery Errors

One of the biggest problems with writing and maintaining themes and/or plugins in WordPress is the frustration that comes with having to track down JavaScript errors.

Pippin Williamson has discussed this extensively on his blog, we’ve covered it on WP Daily, and I’ve talked about this once before here.

But since I’ve seen this issue crop up several times since, I wanted to offer some additional thoughts on this particular topic that has stemmed from the recent discussions.

Continue reading

Quick Tip: Delete a Git Tag

As much as I love GitBox, it doesn’t actually provide the ability to delete tags from within the interface:

GitBox and The WordPress Plugin Boilerplate

GitBox and The WordPress Plugin Boilerplate

Sad, right?

Occasionally, there are times in which I need to remove a tag because I need to go back and make some final adjustments to a commit prior to pushing to my current branch (which is usually just `master` anyway).

This means that I need to hop over into Terminal to issue a few git commands in order to delete a Git tag from the command line.

Continue reading

WordPress Refactoring: Refining Plugin Functions

Whenever it comes to writing code – be it starting a new project or working with an existing system – there are a lot of developers that aim to write clean, maintainable code.

It’s a challenge for sure, but it’s not impossible. Even if you’re responsible for simply introducing a new function into an existing system, there’s an opportunity to leave the place a little better than you found it.

Granted, trying to refactor a larger system too much can have serious unintended consequences, so I don’t necessarily advocate doing that, but if you have the opportunity to break a one larger function into several smaller, more focused functions, then I think the opportunity should be taken.

I recently had a chance to do a bit of WordPress refactoring in the context of a commissioned plugin I am working on, and wanted to share the process that I followed for doing so.

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑