Posts tagged as "php"

Customising WordPress Without Modifying Core, Theme Or Plugin Files

A standard WordPress install is incredibly powerful and flexible. For a lot of people, WordPress out of the box plus one of the stock WordPress themes is enough. But the possibilities for customization are endless; you can add plugins and other themes. Sometimes these do just what you want. Sometimes you need to ... tweak WordPress.

A very high proportion of the customization advice you'll find on the web starts with these lines ... add the following to the end of your theme's functions.php or even worse, advises that you modify the source code of your theme or your plugins. This is bad for many reasons:

  • Editing your theme's functions.php makes theme specific customizations; change your theme and your customizations will no longer get loaded.
  • When your theme and plugins get updated you'll find all your careful hand crafted customizations get overwritten and lost.
  • A lot of theme and plugin authors won't offer support for changes you might have made to the source code.
  • Your customizations might work; but you might also inadvertently make some other changes which will stop things working.

WordPress doesn't yet support a way for site specific customizations to be made and loaded without touching theme, plugin or core files; that's why I wrote WP Customizer and that's what this plugin is for. When WordPress does support such a way, this plugin will thankfully be obsolete.

Tracking Down Use Of Deprecated WordPress Functions Or Arguments

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.

Revisiting The Online Me (On A Plane)

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.

WP Biographia Is But A Quarter Of The Way To WP Mappa

In a way, this was all Matt Whatsit's fault; he writes very profane and very funny blog posts and reading his recent The Five Stages Of P****d Wife (which you should read if you haven't already, err, read it) made me laugh, hell, it made me ROFL and LMAO at the same time but it also made me think, though not necessarily about wives or drunkenness ...

Now background reading and general swotting up on a topic is all very well but to really learn how to do something you just have to roll your sleeves up and do it yourself. Though it's probably stretching a comparison too far, you don't learn to drive a car through reading the highway code; you actually get behind the wheel (preferably under supervision) and ... drive. You don't learn about what food tastes good from a recipe book; you ... taste the stuff yourself.

And so it is with writing code and using new and unfamiliar APIs. It was definitely the case with my recent (reacquaintance of, and) foray into JavaScript and the addition of support for Nokia's Ovi Maps API to the Mapstraction project, with the added benefit of having to teach myself how to move from my (by now very dated) knowledge of version and revision control under CVS to git.