• plugins_url() is supposed to work for plugins or mu-plugins, the code inside it supports both. But the filter inside this plugin forces one, and if it’s an mu-plugin, it breaks all of the URLs.

    Problem code in the plugin itself stems from this:

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

    which calls:

    function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
    	return get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, PLUGINDIR ) - 1 );
    }

    I think this would be better, but I’m not sure if this plugin will get future updates:

    function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
    
    	$siteurl = get_site_url();
    
    	if ( false !== stripos( $full_url, PLUGINDIR ) ) {
    		$full_url = $siteurl . substr( $full_url, stripos( $full_url, PLUGINDIR ) - 1 );
    	} elseif ( false !== stripos( $full_url, MUPLUGINDIR ) ) {
    		$full_url = $siteurl . substr( $full_url, stripos( $full_url, MUPLUGINDIR ) - 1 );
    	}
    
    	return $full_url;
    
    }

    The code above is backwards compatible with WP 3.0+

    • PLUGINDIR was added in 2.1
    • MUPLUGINDIR was added in 2.8
    • get_site_url() was added in 3.0

    Given that the plugin states support for 3.1+, this should be acceptable. Even though the two constants referenced here are deprecated, it at least resolves the issues using the plugin presents for those using mu-plugins files as well.

    https://wordpress.org/plugins/wordpress-mu-domain-mapping/

  • The topic ‘Support for mu-plugins folder, when using plugins_url()’ is closed to new replies.