PHP and Default Timezones

Just in case anyone else runs into this I thought I’d record it for Google’s sake…

My business website was down. My web host was being non-helpful – “we’re aware there’s a problem and we’re working on it” – so there was nothing I could do but sleep on it and hope the site would be back up in the morning. When it finally came back online, I was faced with dozens of warnings like this:

Warning: strftime() [function.strftime]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/New_York’ for ‘EST/-5.0/no DST’ instead in [file name & line number]

Obviously they’d updated PHP or changed some settings.

Slightly panicked, a quick Google led to a bunch of solutions involving changing php.ini which I do not have access to because the site is on a shared host. I could probably have saved some time by, uh, you know, actually reading the warning.

The solution was to add a call the PHP function date_default_timezone_set() with one of the supported timezones in my config.php:

Oddly enough, the list of supported timezones for America does not include Ottawa, Ontario – the capital of Canada and fourth largest city in the country – but includes the tiny town of Swift Current, Saskatchewan [Pop. 15,000]. Quoi?

WP-Syntax Style Sheet Order Fix

I’m using Ryan McGeary‘s excellent WP-Syntax plugin for syntax highlighting of code in WordPress. [It is now maintained by Steve Zahm.]

Update [7 Apr 2014]: I’m, uh, no longer using Ryan’s WP-Syntax plugin… I switched to Crayon Syntax Highlighter so I could have more control over the layout. The examples below are using Crayon now.

Without the plugin, simply using the <code> tag, code looks like this:

/* Hello World program */

#include <stdio.h>

int main( int argc, char *argv[] ) { printf("Hello World");

return 0; }

With the WP-Syntax plugin, it is formatted to make it much more readable:

One problem with the plugin though is that the CSS style sheet for the plugin is being included after some external Javascript in the head element of the HTML document. This prevents some browsers from loading the CSS in parallel which can delay loading of the page. A good way to catch these kinds of things is to use Google’s Page Speed plugin.

Continue reading

Techozoic Fluid Child Theme CSS

So I’m using Jeremy Clark‘s Techozoic Fluid WordPress theme for this site. Kinda cool, eh?

Update [27 Mar 2017]: I’m now using Raam Dev‘s Independent Publisher as my base theme.

I wanted to modify and minify the style.css file and make a couple of other changes. Given these other changes, I decided the best solution was to make a WordPress child theme. So I followed the instructions and expected that the header would reflect my new style.css file.

Alas, taking a look at the page source, it did not:

So I took a look at themes/techozoic-fluid/header.php, and found the problem on line 76:

It looked like get_template_directory_uri() was returning the main theme’s directory, not the child theme. Sure enough, the docs state:

In the event a child theme is being used, the parent theme directory URI will be returned, not the child theme directory URI

The fix was simple. Changing it to the following grabs the css file from the child theme: