Corrected home URL for subdir installs

If Wordpress is installed in a sub-directory, this will prevent the URL
from being the root of the domain (e.g. example.com/sub/directory/ will
become /sub/directory instead of / ).
This commit is contained in:
James Costian
2012-06-09 18:05:56 -05:00
parent 9e1ecfa4e1
commit 39379742fc

View File

@@ -61,8 +61,8 @@ function roots_root_relative_url($input) {
'!(https?://[^/|"]+)([^"]+)?!', '!(https?://[^/|"]+)([^"]+)?!',
create_function( create_function(
'$matches', '$matches',
// If full URL is home_url("/"), return a slash for relative root // If full URL is home_url("/") and this isn't a subdir install, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === home_url("/")) { return "/";' . 'if (isset($matches[0]) && $matches[0] === home_url("/") && str_replace("http://", "", home_url("/", "http"))==$_SERVER["HTTP_HOST"]) { return "/";' .
// If domain is equal to home_url("/"), then make URL relative // If domain is equal to home_url("/"), then make URL relative
'} elseif (isset($matches[0]) && strpos($matches[0], home_url("/")) !== false) { return $matches[2];' . '} elseif (isset($matches[0]) && strpos($matches[0], home_url("/")) !== false) { return $matches[2];' .
// If domain is not equal to home_url("/"), do not make external link relative // If domain is not equal to home_url("/"), do not make external link relative