WordPress.org

Support

Support » Plugins and Hacks » domain_mapping_plugins_uri breaks plugins installed in mu-plugins

domain_mapping_plugins_uri breaks plugins installed in mu-plugins

  • 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 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘domain_mapping_plugins_uri breaks plugins installed in mu-plugins’ is closed to new replies.