WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Domain Mapping
wrong filter plugins_url > domain_mapping_plugins_uri retur (6 posts)

  1. RavanH
    Member
    Posted 3 years ago #

    Hi,

    Finally, I found the cause of a very strange fenomenon some of de users of my plugins have run into:

    When a plugin like XML Sitemap Feed that uses the function plugins_url() is installed in /mu-plugins/ alongside domain_mapping.php, that plugins call to plugins_url() returns an unexpected response. Depending on the input, the result is one letter, usually 'p' or 's'. The weird thing is that this does not happen when the plugin is installed in /plugins/ (activated sitewide or not does not matter)...

    After going through all the relevant WP code I could only conclude it had to be in the filter triggered at the end of plugins_url(). And so I came to WPMU Domain Mapping since that is the only plugin I know and use that uses this filter.

    Specifically, it seems to go wrong in domain_mapping.php at the part substr( $full_url, stripos( $full_url, PLUGINDIR ) - 1 ) on line 612.

    Now what is wrong with that, I don't know but when I either let that function just return $full_url or when I comment out line 620 //add_filter( 'plugins_url', 'domain_mapping_plugins_uri', 1 ); the problem is solved.

    But will disabling this filter cause problems for other plugins using function plugins_url() which are installed in the regular /plugins/ dir?

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

  2. RavanH
    Member
    Posted 3 years ago #

    Ah... it's stripos( $full_url, PLUGINDIR ) that returns FALSE when PLUGINDIR is not part of $full_url.

    I propose a fix:

    // fixes the plugins_url
    function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
    	$pos = stripos( $full_url, PLUGINDIR );
    	if($pos === false)
    		return $full_url;
    	else
    		return get_option( 'siteurl' ) . substr( $full_url, $pos - 1 );
    }
  3. Note the XML sitemap insturctions:

    "WordPress 3+ in Multi Site mode

    Same as above but do a Network Activate to make a XML sitemap available for each site on your network."

    Not stick it in mu-plugins. ;)

  4. RavanH
    Member
    Posted 3 years ago #

    Hi Andrea, Thanks for quoting my own installation instructions :D ... But they are like that exactly because of this issue.

    BTW, do you know what function domain_mapping_plugins_uri() does what function domain_mapping_post_content() does not do already?

  5. lols......

    the devs won't have time to look at this till after 3.1 comes out.

    (and yes I mean devs of domain mapping) Bump it later, so I get it and can remind them?

  6. RavanH
    Member
    Posted 3 years ago #

    I understand. Thanks Andrea :)

    BTW, it can't be very long now. Just upgrading my test install to RC3 :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic