• Hello,

    When wp-content is renamed, MU Domain Mapping does not return the proper plugin url for the mapped domain.

    Quick overview of the problem
    Using the standard wp-content install, things work as expected:
    Mapped domain = themapped.com
    <?php echo plugins_url();?> on themapped.com returns https://themapped.com/wp-content/plugins

    but when wp-content is renamed and moved:
    Mapped domain = themapped.com
    <?php echo plugins_url();?> on themapped.com returns https://themapped.coms

    Two things happen, the letter ‘s’ is appended to themapped.com and the plugin path is not returned.

    Configuration Details
    I’ve been rubbing up on this problem for a few days. I’ve been able to reproduce the error both locally and live across every install tested.

    Let’s assume the default (blog_id=1) domain for the multi-site install = mymultisite.com

    And we want to change wp-content to content, so the defines I declare in wp-config.php are:
    /******* Move WP-Content Directory *******/
    define( ‘WP_CONTENT_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/content’ );
    define( ‘WP_CONTENT_URL’, ‘https://mymultisite.com/content&#8217;);

    We restart the server and everything seems to work, except on the mapped domain, the output of plugins_url() = https://themapped.coms

    So I tried a different way. I kept wp-content and moved the plugin directories to /library. In wp-config.php I declare:
    /******* Define New Location of Plugin Directory *******/
    define( ‘WP_PLUGIN_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/library/plugins’ );
    define( ‘WP_PLUGIN_URL’, ‘https://mymultisite.com/library/plugins&#8217;);
    define( ‘WPMU_PLUGIN_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/library/mu-plugins’ );
    define( ‘WPMU_PLUGIN_URL’, ‘https://mymultisite.com/library/mu-plugins&#8217;);

    The same problem occurs where plugins_url() on mymapped.com returns https://mymapped.coms

    I tried various combinations of moving wp-content and plugins. At least the dang plugins_url() output remained constant! https://mymapped.coms ??

    Other Notes
    The problem isn’t limited to mapped domains, but only mapped domains break. Mapped domains don’t get any path to the plugins directory and get the ‘s’ appended.

    Non mapped domains do not break because the path to the plugins directory is returned as the path for the default domain of the install. That is if mymultisite.com is the default, and subdomain.mymultisite.com is a subsite, then
    plugins_url() on subdomain.mymultisite.com = https://mymultisite.com/correctpath/toplugins

    It’s entirely possible that the fix is minor. Lines 650-653 of domain_mapping.php seems to be a culprit

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

    Thanks for your help!

    https://www.ads-software.com/extend/plugins/wordpress-mu-domain-mapping/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ron Rennick

    (@wpmuguru)

    For the purposes of testing, I just added

    define( 'WP_CONTENT_URL', 'https://mymultisite.com/content');

    to my wp-config.php and

    <?php echo plugins_url();?>

    produces

    https://mymultisite.com/content/plugins

    If you want the URL to be https://mymapped.com/content/plugins then you should have the following in your wp-config.php

    define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content');

    Thread Starter Eyecool

    (@eyecool)

    That does return the correct hostname for subdomains, but mapped domains are still borked.

    <?php echo plugins_url();?>

    on anymapped.com still returns https://anymapped.coms

    I think the culprit might be function domain_mapping_plugins_uri

    Thread Starter Eyecool

    (@eyecool)

    I couldn’t fix the function, but when I comment out the filter, it works as it should.

    if ( defined( 'DOMAIN_MAPPING' ) ) {
    //	add_filter( 'plugins_url', 'domain_mapping_plugins_uri', 1 );
    	add_filter( 'theme_root_uri', 'domain_mapping_themes_uri', 1 );
    	add_filter( 'pre_option_siteurl', 'domain_mapping_siteurl' );

    Could that be it?

    Plugin Author Ron Rennick

    (@wpmuguru)

    Try adding the following to your wp-config

    define( 'PLUGINDIR', 'content/plugins' );

    Thread Starter Eyecool

    (@eyecool)

    Ron, that’s it. Works perfect.

    Earlier I had tried

    define( 'PLUGINDIR', $_SERVER['DOCUMENT_ROOT'] . '/content/plugins' );

    Which didn’t work, and quickly abandoned the idea of using PLUGINSDIR (ticket #18772)

    Summary for posterity
    To move /wp-content to /content define the following in wp-config.php:

    define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/content' );
    define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content');
    define( 'PLUGINDIR', 'content/plugins' );

    Mapped domains will play nice throughout the install and work flawlessly with third party plugins like, Gravity Forms, and Network plugins.

    Wheeew doggie.

    Thanks Ron.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress MU Domain Mapping] Problems with custom wp-content directory’ is closed to new replies.