You can use site_url()
or get_site_url()
. Depending on your install and setup, you could as well use network_site_url()
– which is what I would prefer as it falls back to site_url()
internally if it is no multisite setup.
The site_url( $path, $scheme );
function also takes two arguments:
- The
$path
can be used to append a path to the URl in case you need to point somewhere custom. - Omit the second one, as it’s the
scheme
(http/s) and will be set automatically – only use it if you want to force a scheme.
Note: You might want to make your switch
a bit more fail save:
switch ( $foo )
{
case 'bar' :
return 'I am bar';
break;
case default :
case 'baz' :
return 'I am baz';
break;
}
Having a default
will save you from failing when none of the conditions are met – with language you might want to use American English. Also you can return
immediately as there is nothing which shall happen with the switch
result afterwards.