WordPress MU Domain Mapping Patches
by Annika Backstrom in
misc, on 28 September 2011.
It is tagged
#Programming, #open source, #patches, #WordPress, and #wordpress netwok.
I've been converting a large WordPress Network installation from a dual subdomain+subdirectory setup to a subdirectory+domain mapping configuration using the WordPress MU Domain Mapping plugin. This should allow for more flexibility when we need to break out of our primary domain name, but so far it has required some extra features in the domain mapping plugin.
Domain Mapped siteurl()
Here's the filter I'm using to apply this function to all siteurl()
and home()
calls:
function do_canonical_siteurl( $value, $blog_id ) {
// gotta do the remove/add dance to avoid recursion
remove_filter( 'blog_option_siteurl', __FUNCTION__, 10, 2 );
$url = domain_mapping_siteurl( 'siteurl', $blog_id );
add_filter( 'blog_option_siteurl', __FUNCTION__, 10, 2 );
return $url;
}
add_filter('blog_option_siteurl', 'do_canonical_siteurl', 10, 2);
add_filter('blog_option_home', 'do_canonical_siteurl', 10, 2);
Fixup MUPLUGINDIR Paths
Plugin filters helpfully update the PLUGINDIR
fragment in URLs, but
does not know about MUPLUGINDIR
. This patch makes the filter a bit
more robust.