Quantcast
Channel: WordPress.org Forums » [WordPress MU Domain Mapping] Support
Viewing all articles
Browse latest Browse all 3502

Janis Elsts on "[Plugin: WordPress MU Domain Mapping] domain_mapping_plugins_uri breaks plugins installed in mu-plugins"

$
0
0

Problem:

WordPress MU Domain Mapping maps URLs that point to files in the /wp-content/mu-plugins directory incorrectly. This breaks plugins that are installed in that directory and need to load some JS/CSS dependencies to function.

Cause:

For some inexplicable reason, this plugin attaches two URL mapping callbacks to the plugins_url hook - domain_mapping_plugins_uri and domain_mapping_post_content. The first callback - domain_mapping_plugins_uri - relies on the deprecated PLUGINDIR constant, so it returns the wrong result when the original URL points to wp-content/mu-plugins instead of wp-content/plugins.

Solution:

a) Remove the redundant domain_mapping_plugins_uri filter by deleting this line and the corresponding function:

add_filter( 'plugins_url', 'domain_mapping_plugins_uri', 1 );

b) Add some error checking to domain_mapping_plugins_uri so that it doesn't break URLs that point to a directory other than wp-content/plugins:

function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
	$plugin_dir_pos = stripos( $full_url, PLUGINDIR );

	//Skip URLs that don't point to files in /wp-content/plugins.
	if ( $plugin_dir_pos === false ) {
		return $full_url;
	}

	return get_option( 'siteurl' ) . substr( $full_url, $plugin_dir_pos - 1 );
}

http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/


Viewing all articles
Browse latest Browse all 3502

Trending Articles