[Plugin: WordPress MU Domain Mapping] Problems with custom wp-content directory
-
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/pluginsbut when wp-content is renamed and moved:
Mapped domain = themapped.com
<?php echo plugins_url();?> on themapped.com returns https://themapped.comsTwo 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’);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’);
define( ‘WPMU_PLUGIN_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/library/mu-plugins’ );
define( ‘WPMU_PLUGIN_URL’, ‘https://mymultisite.com/library/mu-plugins’);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/topluginsIt’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/
- The topic ‘[Plugin: WordPress MU Domain Mapping] Problems with custom wp-content directory’ is closed to new replies.