Software Engineering in WordPress, PHP, and Backend Development

Category: Tips (Page 8 of 10)

Various articles covering anything from how to programmatically achieve a certain task to useful ways that I’ve found to manage my time.

How To Unit Test WordPress Settings API Validators

For those who are experienced with the Settings API, you may wish to skip down to the core problem.

How To Unit Test WordPress Settings API Validators

I’m currently building a web application where WordPress is serving as the core framework. I’ve discussed this before and Matt covered this in State of the Word 2012 as something that will become more common as WordPress grows in popularity.

So WordPress doesn’t necessarily have an MVC or MVVM or whatever design pattern, but it offers its own method for how data models, business logic, and other necessary components should be created.

I’m using the Settings API to create a model that represents a user in the application. Essentially, it will wrap the core WordPress user model, but I have to introduce some additional attributes and ultimately create relationships with other models that WordPress doesn’t natively support.

Anyway, I’m writing unit tests for everything that’s going into the application and I hit an interesting point when it came to unit testing the validation functions.

Continue reading

Two Ways To Optimize Adding JavaScript in the WordPress Dashboard

Once you’ve been working on WordPress-based projects for a while, you quickly learn how to properly include stylesheets and JavaScript dependencies for the administrative dashboard or the public-facing aspect of a theme or plugin.

That is, you’re familiar with admin_enqueue_scripts and wp_enqueue_scripts.

And although these two hooks provide a way to segment the way in which scripts are loaded, it’s possible to further optimize how JavaScript dependencies are loaded by only loading them on the page that they are required.

Specifically, there are two ways that you can add JavaScript in WordPress in the dashboard:

Continue reading

Quick Tip: Installing Git On Mac OS X

Install Git on Mac

My favorite Git client for OS X is GitBox – it’s incredibly simple and makes working with git-based repositories really easy.

Still, there are times where I prefer the command line for a couple of things and the various GUI clients come up short. If you’ve not installed the OS X Developer Tools, like Xcode, on your machine, then you’re likely unable to use a command line version of the application that is bundled with your client of choice.

Here’s how to do it:

Continue reading

Organize Your WordPress Installation For Subversion-Based Development

If you’ve done any development on themes, plugins, or the core application itself, then you know that the team uses Subversion for WordPress development. This means that when you checkout the project, you’re either pulling down at least three directories, or you’re pulling down the trunk.

The challenge is figuring out a way to organize your local development environment so that it resembles the staging and production environment rather than what the repository looks like.

But this can be tough if you’re used to working with the trunk, with copying files, or with whatever crazy ways you’ve come up with managing version controlled files.

Here’s the most effective way that I’ve found to organize my installation when using Subversion for WordPress development:

Continue reading

« Older posts Newer posts »

© 2024 Tom McFarlin

Theme by Anders NorenUp ↑