WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Domain Mapping
domain_mapping_plugins_uri breaks plugins installed in mu-plugins (3 posts)

  1. Janis Elsts
    Member
    Posted 1 year ago #

    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/

  2. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 1 year ago #

    Thanks for reporting that - It's on my list to fix.

  3. ejbliss
    Member
    Posted 4 months ago #

    Thanks for the save Janis.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.