I am a PHP novice, so bear with me if any of my terminology is incorrect.
I have a small PHP file (page_class.php
) that defines some functions and I include this file in the header.php of my theme:
<?php include("page_class.php"); ?>
And these are the contents of page_class.php
:
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
function get_subdomain() {
$page_url = curPageURL();
$parts = split('\.', $_SERVER["SERVER_NAME"]);
return $parts[0];
}
function get_body_class() {
$subdomain = get_subdomain();
if ($subdomain == "keyes") {
$path_parts = split('/', $_SERVER["REQUEST_URI"]);
$clazz = $path_parts[1];
}
else {
$clazz = $subdomain;
}
if ($clazz == "greasemonkey" || $clazz == "wordpress") {
$clazz = "work";
}
if ($clazz == "") {
$clazz = "home";
}
return $clazz;
}
?>
I call get_body_class
in header.php
:
<body class="<?php echo get_body_class(); ?>">
This setup worked in WordPress MU 2.7.1. I recently upgraded to 2.8.6 and it broke. When I visited any page on the blog the screen was blank.
After some investigation I figured out that by changing the function names (I prefixed them with jk_
) it worked again.
I guessed this was a naming conflict, but couldn't find any. I wonder do any PHP or WordPress devs have any idea why this happens.