I am converting a creat_function to function for PHP 8.0. I just need a fresh pair of eyes on this. I can not see where the '}' issue is. Does anyone see it? Otherwise the code should work correct?
function roots_root_relative_url($input) {
$output = preg_replace_callback(
'!(https?://[^/|"]+)([^"]+)?!',
function($matches){
// if full URL is site_url, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
// if domain is equal to site_url, then make URL relative
'} elseif (isset($matches[0]) && strpos($matches[0], site_url()) !== false) { return $matches[2];' .
// if domain is not equal to site_url, do not make external link relative
'} else { return $matches[0]; };'
} **< OFFENDING BRACKET**
$input
);
return $output;
}
I removed the '}' but then I get "Parse error: syntax error, unexpected '$input' (T_VARIABLE) in directory on line 56" What in the world am I missing???