Posts about theme

Tracking Down Use Of Deprecated WordPress Functions Or Arguments

... this often appears after you've installed or upgraded a new theme or plugin. This message is helpful but really only 50% useful. The PHP file and line number that's being reported isn't where the deprecated function or argument is being used; it's where it's being reported from. Often, even after you've searched through the source code of the new plugin or theme you're still none the wiser about where the troublesome piece of PHP that WordPress is telling you about actually lives. WordPress is a complicated mix of PHP, JavaScript and CSS; there's a lot more going on under the hood than most of us are remotely aware of.

If you've been running your blog or site on WordPress for any period of time, you may well have come across a message about a deprecated function or argument in your PHP log file or across the top of a page on your site. The message might look something like this ...

Notice:  get_bloginfo was called with an argument that is **deprecated** since version 2.2! The siteurl option is deprecated for the family of bloginfo() functions. Use the url option instead. in /var/web/htdocs/site/wp-includes/functions.php on line 2712

... this often appears after you've installed or upgraded a new theme or plugin. This message is helpful but really only 50% useful. The PHP file and line number that's being reported isn't where the deprecated function or argument is being used; it's where it's being reported from. Often, even after you've searched through the source code of the new plugin or theme you're still none the wiser about where the troublesome piece of PHP that WordPress is telling you about actually lives. WordPress is a complicated mix of PHP, JavaScript and CSS; there's a lot more going on under the hood than most of us are remotely aware of.

Thankfully WordPress also helps provide an answer, through an undocumented action hook called deprecated_argument_run; that's undocumented in the WordPress Codex, it is documented in the core WordPress source code, if you know where to look. The clue to unlocking this problem is a comment in wp-includes/functions.php which says There is a hook deprecated_argument_run that will be called that can be used to get the backtrace up to what file and function used the deprecated argument. So here's how to get that backtrace.

Put the following code somewhere on your site, maybe in your theme's functions.php, where it will get called by WordPress. Now I know this seeminly contradicts what I said in an earlier post but this is a temporary piece of debugging code and not a permanent feature of your site; I might just make it a plugin some day though.

[php] add_action ('deprecated_argument_run', 'deprecated_argument_run', 10, 3); [/php]

Now add the hook function that gets called when a deprecated argument is detected.

[php] function deprecated_argument_run ($function, $message, $version) { error_log ('Deprecated Argument Detected'); $trace = debug_backtrace (); foreach ($trace as $frame) { error_log (var_export ($frame, true)); } } [/php]

Reload a page on your site and you'll see a back trace in your PHP error log of precisely where the deprecated argument is being used.

This technique isn't limited to deprecated arguments, there's also action hooks for deprecated functions (deprecated_function_run), deprecated files (deprecated_file_included) and something being incorrectly called (doing_it_wrong_run), all of which can use the same form of back trace technique.

You'll probably need to ensure that WP_DEBUG is enabled in your wp-config.php and don't forget to remove your debug code and disable WP_DEBUG after you've finished.

Revisiting The Online Me (On A Plane)

homage to a certain Mr. Aaron Cope, once again I am in the sky as I write this and starting to think that maybe I will only write blog posts from airplanes from now on.

While sitting in a hotel room about a week or so back, I realised that while vicchi.org has been the home of my blog for years and the current incarnation may have 267 pieces of bloggage tucked away in the bowels of WordPress (that's 268 with this post), the theme has been pretty much static since sometime in 2007. The same goes for my other web presence over at garygale.com.

But back to this blog for a moment. Like a lot of people I started out with a stock WordPress install and theme. Then I went through the discovery of the WordPress theme repository, installing and uninstalling too many plugins, before finally becoming confident enough to start hacking the PHP and CSS of an existing theme into something vaguely approaching what I wanted. And thereby hangs the problem. My theme, which started out as Chandra Maharzan's rather wonderful Cleanr, suffered from the problem that each time the theme was updated I needed to go through the changes and manually apply them to my hacked version. Scalable and fun this is not.

Although I fly a lot these days, I don't fly on internal routes in the US that much and so flying Virgin America, which has onboard wifi, is still something that brings out the childish geek in me. In homage to a certain Mr. Aaron Cope, once again I am in the sky as I write this and starting to think that maybe I will only write blog posts from airplanes from now on.

While sitting in a hotel room about a week or so back, I realised that while vicchi.org has been the home of my blog for years and the current incarnation may have 267 pieces of bloggage tucked away in the bowels of WordPress (that's 268 with this post), the theme has been pretty much static since sometime in 2007. The same goes for my other web presence over at garygale.com.

But back to this blog for a moment. Like a lot of people I started out with a stock WordPress install and theme. Then I went through the discovery of the WordPress theme repository, installing and uninstalling too many plugins, before finally becoming confident enough to start hacking the PHP and CSS of an existing theme into something vaguely approaching what I wanted. And thereby hangs the problem. My theme, which started out as Chandra Maharzan's rather wonderful Cleanr, suffered from the problem that each time the theme was updated I needed to go through the changes and manually apply them to my hacked version. Scalable and fun this is not.

vicchi.org - Screen Grab

Enter the notion of WordPress child themes. These allow you to take an existing WordPress theme and build on top of that theme but without actually modifying or adding to the original theme. You start with just inheriting from the parent theme's CSS and then you can add, adapt and otherwise hack as much or as little of the parent's templates and PHP functions as you need. As you're not actually touching the parent theme at all, any updates to that theme are automagically passed onto the child theme, so the need to keep a hacked theme in line with the original simply goes away.

I still rather liked the clean typography and colour scheme of my version of Cleanr so I was able to easily modify my child theme's CSS to migrate this. I based the child theme on the WordPress Twenty Ten theme but changed the way in which post date formats were displayed, removed the built-in biography display so I could use my own WP Biographia plugin and modified the parent theme's header image display to use my own imagery and to also rotate the images on page refresh.

Putting together a child theme to give my blog a long overdue facelift has been surprisingly easy; to see just how easy, the source code to the originally named Twenty Ten - Vicchi is over on GitHub to download, fork or otherwise hack around.

One web presence down, one to go. Next it was time to give my personal vanity page some facelift attention. The original design for this site was heavily influenced by Christian Heilmann's approach to web technologies. Chris and I worked together at Yahoo! and he taught me so much about how web pages worked. The original version of this site was dynamically generated from RSS feeds fed through Yahoo's YQL. Sadly, the YQL API got ever more flaky over the last few years and I ended up having to transition over to use the SimplePie PHP library just to keep the site up and running. It wasn't the world's fastest loading site but it was nice and dynamic and at the time, that was important, to me at least.

But in keeping with the clean and spare layout of my blog, I'd been intrigued by the less-is-more approach that about.me had taken. But despite having my own page on about.me's site I wanted to host my own under my garygale.com domain.

garygale.com - Screen Grab

A random browse through GitHub yielded The Personal Page, a clean, lightweight home page design that appealed to me. One GitHub fork later, plus a photo of me taken at last year's Geo-Loco conference in San Francisco that I didn't look too appalling in and the new, Personal Page'd version was up and running. Really, it took all of about half an hour and that's including testing and finding a social media icon set that integrated nicely with the look and feel of the site. Of course, the web site's code is also up on GitHub for the aforementioned hacking around.

All of the above verbiage can be boiled down to the simple fact that armed with a little knowledge of CSS, PHP and HTML it's very, very easy to create a new and, I hope, effective web presence, all of which is powered by open source tools and techniques and that, utterly appeals to the grown up geek in me.

Written and posted on Virgin America flight VX837, between Chicago O'Hare and San Francisco International airports, roundabout overhead Maryville, MO (40.347, -94.873)