The WordPress multisite install is a great thing. Except when you come across something that works not the way you expect.
So, the WordPress multisite installed on example.com with blogs on subdomain basis will give you sites with names like great.example.com and aruberusan.example.com. Of course, we all like nice looking domain names, so you install a mapping plugin and get the domain aruberusan.com map to your aruberusan.example.com and it all just works… So now you happily access your blog at aruberusan.com. Great. Until you run into trouble because internally your blog’s site address is still aruberusan.example.com. And the calls to get_site_url(), home_url(), admin_url() and so on still return you the old original name of your site before mapping, in my case the aruberusan.example.com.
This sucks and I could not find a solution to this weird problem. The only thing that came to mind was to use the actual site URL from the request and recompose the URL manually like this:
$adminurl = get_admin_url($path); $admURL = parse_url($adminurl, PHP_URL_SCHEME) . "://" . $_SERVER["SERVER_NAME"] . parse_url($adminurl, $component = PHP_URL_PATH);
I would not call it a beautiful solution or even a proper one but it works. It is amazing that you cannot get the right URL from anywhere. Oh, and why you need it? Well, if you are going to post to, let’s say, Facebook, for example, with something like the SNAP plugin, you better have the right URL for your site or else…