Thematic – functions.php problem

I have been playing with thematic, a theme framework for WordPress. In particular I’ve been making ‘murkymatic‘ which is a child theme based upon thematic. The source for this is up at google code (I don’t yet know how to package a release for non-svn downloads I’m afraid, or how to tag a particular revision as being a particular version, if you know, please tell me).

On to the point…. I’ve been having trouble with the following bit of code snippet. The idea is to refer to variant.css, if that file exists. If it doesn’t exist, there is to be a comment telling anyone who hacks the code to create variant.css for their own style declarations.

The reason for doing this is that I do not want variant.css to be part of the distribution, I want to customise without having to maintain a separate version of ‘murkymatic’. I want it to be coded in (so that people who use the template don’t have to modify the core files to make changes) – this will make updates easier.

Unfortunately the code seems to default to thinking the file does not exist – but when I view source and copy the contents of $variantfile into the address bar, it gives me variant.css (which does exist).

function childtheme_variantcss() { 
     /* This is to reference a variant style sheet, should one be provided */
     $variantfile = get_bloginfo('stylesheet_directory') . '/variant.css';
     if (file_exists($variantfile)) {
          ?><link rel="stylesheet" type="text/css" href="<?php echo $variantfile; ?>" /><?php
     else {
          ?><!-- Create <?php echo $variantfile; ?> for your own customisations  --> <?php

It’s rather befuddling. The bug is to do with file_exists() – but looking at the source for this page (assuming I haven’t changed themes at some point) gives this: &lt;!-- Create for your own customisations --&gt; – and copying into the address bar shows it is an existing file, containing just /* My customisations for murkymatic */

Would there be a downside to simply linking to the stylesheet if it doesn’t exist?

Whilst I’m posting on the topic, one other thing I want to do with this code is to have a function which looks at the google code repository to see if the theme is out of date (for tagged releases, not for individual revisions), and if so to put an informational message on the WP dashboard. I have no idea how to do this though, and I’d be grateful for pointers (I’d like to see that in thematic too)!

About Murk

I'm interested in a range of things, from science and computers, to history and creative stuff. I'm leaving a lot out. My problem is time. As a result,, flits around from topic to topic as my interest is piqued. It's all tagged though - so it should be easy to find other posts of mine on similar topics - do give the RSS feed a try, and I welcome, nay, I crave comments on articles.

2 thoughts on “Thematic – functions.php problem

  1. Would there be a downside to simply linking to the stylesheet if it doesn’t exist?

    Potentially a lot of wasted return trips on high-traffic sites to get 404s. I think I’d try to avoid it, but that’s probably OCDish.

    Have you singled out the file_exists function on your host to see if it works outside of WordPress and the theme stuff? If so maybe the bloginfo combined with the /variant.css isn’t coming up with the correct path? Probably teaching you to suck eggs.

    Regarding the theme update checker, I’d hold off on that because I think it’s going in to core.

Leave a Reply