Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 35 of 49)

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

How To Enable SSL in MAMP

In my developer toolbox post, I’ve covered that I prefer to use to MAMP for local development. For the most part, the default settings (or some variation thereof) work just fine; however, if you end up needing to do some work on a secure site, then you’ll need enable SSL in MAMP.

On production-level servers, you’ll need to have purchased an SSL certificate; however, MAMP makes it trivially easy to setup a certificate in your development environment.

Continue reading

Adding a Custom Post Type To An Existing Menu

Up until this point, I’ve never worked on a project or done any type of work that required a custom post type to be added to an existing menu in the WordPress dashboard.

For the most part, I’m generally of the mindset that custom post types should:

  • Exist as top level menus
  • Should be added at the bottom of the WordPress dashboard menu

This mentality is primarily motivated by the fact that I see the core WordPress menu options as first-class citizens in the dashboard, custom post types as being second-class citizens.

That’s just a rule of thumb, though. There are always exceptions.

But there are also times where custom post types could be treated as, say, third-class citizens where they should be integrated with an existing menu be it a core menu or another custom post type menu.

Luckily, it’s trivially easy to add a custom post type as a menu item to an existing menu.

Continue reading

Displaying a Plugin Activation Message in WordPress

There have been times through out several projects where I’ve wanted to display a plugin activation message (or deactivation message).

WordPress makes it relatively easy to do this using two functions:

But here’s the the thing: These two functions may not work as you expect if you’re writing your plugins using object-oriented practices.

So I thought I’d share how I go about displaying a plugin activation message in hopes that it not only helps you in your future projects, but in hopes that you guys could offer up your own code review as well.

Continue reading

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

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑