I took a comment from Beel several months ago and now I use this for my style switcher plugin. Basically it involved changing “home” to “siteurl” in several places. I’m posting the whole thing in case somebody sees an error, but it’s been working fine for me on WordPress 1.2 for several months now.
<?php
// WP Style Switcher
// version 1.2, 2004-03-03
//
// copyright 2004 Alex King
// https://www.alexking.org/software/wordpress/
/*
Plugin Name: WP Style Switcher
Plugin URI: https://www.alexking.org/software/wordpress/
Description: A CSS Style Switcher for WordPress.
Author: Alex King
Author URI: https://www.alexking.org/
*/
// change this to the name of default style you want to use
$wp_style_default = 'Blue Swirly';
function wp_style_cookie($default = "") {
global $wp_style_default;
if (empty($default)) {
$default = $wp_style_default;
}
$expire = time() + 30000000;
$urlinfo = parse_url(get_settings('home'));
$path = $urlinfo['path'];
$domain = $urlinfo['host'];
if (!empty($_GET["wpstyle"])) {
setcookie("wpstyle"
,stripslashes($_GET["wpstyle"])
,$expire
,$path
,$domain
);
header("Location: ".get_settings('home'));
}
else if (empty($_COOKIE["wpstyle"])) {
setcookie("wpstyle"
,$default
,$expire
,$path
,$domain
);
}
}
function wp_stylesheet($default = "") {
global $wp_style_default;
if (empty($default)) {
$default = $wp_style_default;
}
if (!empty($_COOKIE["wpstyle"]) && file_exists('wordpress/wp-style/'.$_COOKIE["wpstyle"].'/style.css')) {
$style = $_COOKIE["wpstyle"];
}
else {
$style = $default;
}
echo get_settings('siteurl').'/wp-style/'.$style.'/style.css';
}
function wp_style_switcher($in_list = 1, $type = "text", $preview = 0) {
$styles = array();
$path = "wordpress/wp-style/";
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (is_dir($path.$file) && file_exists($path.$file.'/style.css') && substr($file, 0, 1) != '.') {
$styles[] = $file;
}
}
}
closedir($handle);
if (count($styles) > 0) {
asort($styles);
reset($styles);
$ss = '<ul id="styleswitcher">'."\n";
foreach ($styles as $style) {
switch ($type) {
case "sample":
if (file_exists('wp-style/'.$style.'/sample.gif')) {
$sample = get_settings('siteurl').'/wp-style/'.$style.'/sample.gif';
}
else {
$sample = get_settings('siteurl').'/wp-style/sample.gif';
}
$display = '<img src="'.$sample.'" alt="'
.htmlspecialchars($style).'" title="Use this Style" />';
break;
default:
$display = htmlspecialchars($style);
break;
}
if ($preview != 0) {
if (file_exists('wp-style/'.$style.'/screenshot.gif')) {
$display .= '
.'/wp-style/'.$style.'/screenshot.gif">Screenshot';
}
}
if (!empty($_COOKIE["wpstyle"]) && $_COOKIE["wpstyle"] == $style) {
$ss .= '
- '.$display.'
'."\n";
}
else {
$ss .= '
.get_settings('home').'/'.get_settings('blogfilename')
.'?wpstyle='.urlencode($style).'">'
.$display.'
'."\n";
}
}
$ss .= '
';
}
if ($in_list == 1) {
$ss = '<li id="style">Style:'.$ss.'
';
}
echo $ss;
}
wp_style_cookie();
?>