I often use the following code on my WordPress builds in order to help prevent invalid links being added:
// add http:// if necessary
function addHttp($url) {
if(substr($url, 0, 4) == 'www.') {
$url = 'http://' . $url;
}
return $url;
}
But this won't work should anyone add a link that does include a 'http://' but doesn't include a 'www.' in there too.
Does anyone know how I can modify my script to cater for this?