OK so I finally added a twitter plugin to this blog, see how long it lasts 😉
Template Override updated!
Ive got round to finally updating my css overide plugin. It now remembers any themes css! So if you are always swapping themes the plugin will remember the css snippet for each individual theme 🙂
Its been tested on 2.7.1 and latest 2.8
The latest version in svn trunk even uses the new 2.8 codepress syntax highlighting!
An email from wordpress!
Today I uploaded v1.0.1 of garland-revisited to the wordpress site, a few minutes later i got an email from wordpress.org!
Trying to pull in wp-config.php or wp-load.php directly is a bad idea. The actual location of those files can be in a nearly infinite number of locations, so trying to reference them directly is guaranteed to break in at least some of the cases.
The code in question is in css.php, the file is requested out of wordpress to provide the custom css, but css.php has to use the wordpress database to find out your custom colours etc..
[php]require( ‘../../../wp-load.php’ );[/php]
The code itself works with a default install of wordpress, but a few people out there might define a different folder for wp-content/themes.. so after som hefty google-fu I found this http://planetozh.com/blog/2008/07/what-plugin-coders-must-know-about-wordpress-26/
[php]$rootPath = dirname(__FILE__);
$rootPathArray = explode("/",$rootPath);
$numDirs = count($rootPathArray);
for ($i=1; $i<=$numDirs; $i++) {
$path = implode("/", $rootPathArray);
if (file_exists($path.’/wp-load.php’)) {
require_once($path.’/wp-load.php’);
break;
} elseif (file_exists($path.’/wp-config.php’)) {
require_once($path.’/wp-config.php’);
break;
}
array_pop($rootPathArray);
}[/php]
This snippet walks back through the dirs until it hits either wp-load or wp-config, I have tested it on a local copy it works fine, so the next version will inlude the fix.
EDIT:
I forgot to follow this post up woth the actual fix from the wordpress guys 😉
css.php is the file i want to call from outside wordpress, but it needs to be wp-config.php loaded first, so the following code is added to the functions.php:
[php]add_filter(‘query_vars’, ‘add_my_var’);
function add_my_var($public_query_vars) {
$public_query_vars[] = ‘garland_css’;
return $public_query_vars;
}
add_action(‘template_redirect’, ‘my_var_output’);
function my_var_output() {
$myvalue=get_query_var(‘garland_css’);
if ($myvalue) {
include(‘css.php’);
exit; // this stops WordPress entirely
}
}[/php]
now i can call the css file from a wordpress url like:
[code]http://myblogurl.com/index.php?garland_css=1[/code]
Motorbike…nearly
I’m saving up for a VFR400 .. got about 500 euros to go 🙂
Happy birthday – Poppy!
For a loving daughter, wherever you are i hope you had a ‘special’ day 🙂
I wish there was some way of seeing you, you are always in my thoughts and dreams and maybe one day you will see this. XXX