WordPress command line PHP

This is a quick overview on running a PHP file via the command line, bootstrapped within the WordPress ecosystem. This sounds like a mouthful, but it’s a fairly straight forward concept. Let’s suppose you have a requirement, where you need to run a PHP script as a one off, or even regularly as a cron job (let’s forgot about WP cron for a moment). The specifc use-case I find arising again and again, is where I need to import data from another source into WordPress. Perhaps the data I’m getting is in a really weird format, from a legacy system, needs to go into a custom system, or a host of other reasons why imports may not already exist for your use-case.… Read the rest

Using Apache environment variables in .htaccess

In a previous post I talked about using environment variables to make your life easier when developing on multiple servers. In this post I will talk about how to use these variables in your .htaccess file.

Why .htaccess?

You may want some rules specific to different servers, maybe you want to hide certain paths on your live server, or perhaps you want to use a different robots.txt file. Below is a rule I’ve used to server a different robots file on a live server.

RewriteCond %{ENV:TESTSERVER} !yes
RewriteCond %{REQUEST_URI} robots.txt
RewriteRule (.*) robots.txt.block
  • Is the environment variable ‘TESTSERVER’ NOT equal to ‘yes’?
Read the rest

Test Data

Making a brand new site is great! You get to start from scratch and completely re-imagine and refresh the design. However this can at times leave you with a problem. The new site looks bare! There’s nothing to look at, you have no idea how it’ll look once editors start using it and populating it with data. This is unbelievably important! You can often be surprised at how many bugs and issues spring up when you can’t thoroughly test your new site with data, text, images, and strange editorial practices.

Some of these you can account for, unfortunately it’s not the editorial practices.… Read the rest

Character Encoding Woes

Recently I’ve been plagued with character encoding issues everywhere I go. Inevitably people just do not plan for special characters on their website. English does not generally use them, so it can often slip the mind of developers. Unfortunately special characters are extremely important and if you do not cater for them your website can look unprofessional or just plain bad. This is especially true if you have a team of editors working on your site to provide content – content copied from word processors/publishing software can unintentionally contain special characters such as curly quotes ( ‘ ’ “ ” ) and long dashes ( — ).… Read the rest