WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Domain Mapping
WordPress MU Domain Mapping and mu-plugins wrong URLs (3 posts)

  1. davoscript
    Member
    Posted 2 years ago #

    Hello valued developers!

    First of all, thanks for this awesome plugin, I mean it, it actually help people around the world to create not just online networks, but jobs and better webs! :D

    So, yasterday I installed Front-end Editor plugin as a mu-plugin in my network to find out that it wasn't working because the URLs for the JS and CSS needed files inside the plugin were wrong (very wrong, http://wordpress.org/support/topic/plugin-front-end-editor-frontend-editor-and-wordpress-mu-domain-mapping-plugins?replies=2#post-2610913), after some research and some thoughts (http://davoscript.com/2012/02/07/front-end-editor-and-wordpress-mu-domain-mapping-plugins/) shared with Scribu, Front-end Editor author, I came to check MU Domain Mapping's code and found what I think is a small bug:

    domain_mapping.php Line #656

    // 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 );
    }

    PLUGINDIR (which seems to be deprecated) stores "wp-content/plugins" so the match will fail it the passed URL in the $full_url variable contains "wp-content/mu-plugins" instead, I replaced it with:

    // fixes the plugins_url
    function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
      if ( false !== strpos($full_url, 'wp-content/mu-plugins') )
        $mapped_url = get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, 'wp-content/mu-plugins' ) - 1 );
      else
        $mapped_url = get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, 'wp-content/plugins' ) - 1 );
      return $mapped_url;
    }

    You can check the whole article I wront about this issue here: http://davoscript.com/2012/02/08/wordpress-mu-domain-mapping-plugin-and-multisite-mu-plugins/

    As I state in my website, this is not an official fix, that's why I'm showing you this so you can actually tell if this is the propper way to fix the issue and help other people too.

    Thanks again for your time and effort.

    Best regards,
    David.

    http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/

  2. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    Thanks for the tip on the mu-plugins substitution :)

    Using those hard-coded strings will work fine for you as long as you are using the default directory structure, but we can't change the plugin to use the hard-coded strings instead of the constants. Doing that would break the plugin for anyone who has a custom wp-content, plugins or mu-plugins directory.

  3. davoscript
    Member
    Posted 2 years ago #

    You are super-right, I actually was trying to generate the right URL with functions from the API, but then I tried this and I was like "ok , perfect" but was too sleepy anyway.. haha.

    The problem that I see is that you can't do something like grab the whole URL and substr the "home ulr" because they are different:

    In the plugin_url filter you recieve:
    http://subdomain.mynetwork.com/wp-content/mu-plugins/plugin-A/file.js

    But all the functions I've tried to get wordpress URLs use the mapped domain instead, like:
    http://mapped-domain.com/wp-content

    This makes it hard to substr the first part of the URL :(

    Anyway, I'll be updating this thread if I have more luck.

    Thanks a lot for your time Ron, I don't know if you realize, but sharing some lines with you guys, code rockstarts! is just amazing! :D

    Regards!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic