This little hack are for other WordPress users like myself whom enjoy cruft free linking as per RFC2396 and use:
<a href="/path/to/somewhere/">local link</a>
… or indeed:
<a href="//somedomain.tld/path/to/elsewhere/">external link</a>
… with abandon. Trouble is for users whom come to read your site via Atom feeds of whatever, such links will break. However, fear no more… as this the hack to fix this up is quite trivial.
Hunt down ./wp-includes/functions-formatting.php and find the function convert_chars(), looking for this:
// Just a little XHTML help
$content = str_replace('<br>', '<br />', $content);
$content = str_replace('<hr>', '<hr />', $content);
return $content;
}
… and replace with:
// Just a little XHTML help
$content = str_replace('<br>', '<br />', $content);
$content = str_replace('<hr>', '<hr />', $content);
// Sort out those absolute path & network location URIs
$absolutist_uri_scheme = 'http'.(($_SERVER['HTTPS']=='on')?'s':'');
$moral_relativism = array('/href=\"\/\//',
'/href=\"\//');
$total_absolutism = array('href="'.$absolutist_uri_scheme.'://',
'href="'.$absolutist_uri_scheme.'://'.$_SERVER['HTTP_HOST'].'/');
$content = preg_replace($moral_relativism, $total_absolutism, $content);
return $content;
}
The hack should be HTTPS aware, for those of you hosting your blog on an SSL enabled site and all those damned morally relative tree-huggin’ hippy links shall get a good kick in the nuts and be blasted with draconian total absolutism, henceforth making Blogosphere™ a much better place for all, where no children will have to endure another 404! ;)