Support » Plugin: Networks for WordPress » [Plugin: Networks for WordPress] Bug Fixes

  • I couldn’t really find a way to contact you directly or submit a bug fix, so I guess this will have to do. I have fixes for three issues that I have come across.

    I have an updated .htaccess file that fixes an issue inherent in WordPress that causes url’s to Nested Networks’ Sub-Sites to break. WordPress’ mod-rewrite directives were not setup to handle anything past 1 level of nesting.

    There is also a function to fix an issue within the Networks plugin that causes some of the path information within WordPress to get corrupted when adding Sub-Sites to a Nested Network (like in the example above). This has to do with the $base variable I was talking about in the meeting.

    The final fix is in the networks-admin.php file at line 438, which fixes an issue where a link was hard-coded as http and was causing redirects back to the base https domain.

    Email me at [ redacted, support is via the forums and not email ] for the code. : D

    http://wordpress.org/extend/plugins/networks-for-wordpress/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Dean

    (@ddean)

    Hi Spencer,

    Thanks for the fix! Your email was scrubbed, so all I’ve got is the hard-coded link issue, but I’ll fix that for sure.

    I can’t really do anything with an .htaccess file, besides maybe posting it for others’ reference. If you’d still like to share it, I guess just throw it up on pastebin since email addresses are being scrubbed. :/

    As fare as the $base variable, I am quite confused. It didn’t sound familiar so I did a quick search, and there’s no reference to $base in the plugin. Can you elaborate?

    – David

    Sorry about not elaborating on the $base variable. You are correct in that the plugin does not reference it; however, that is the problem. WordPress uses the variable when creating new blogs for a site. $base is defined in wp-config by default when you enable multisites. But since your plugin allows multiple sites, it needs to update that variable for each site. I noticed the issue when creating sites whose domain/path were a child of another site’s domain/path. The fix is really simple:

    function set_base_var() {
    global $base;

    if ( !is_multisite() )
    return;

    $base = get_current_site()->path;
    }

    add_action( 'muplugins_loaded', 'set_base_var');

    It may be better to use a different action hook, but this one seems to work just fine.

    As for the .htaccess file, it is a pretty simple adjustment as well. All it does is allow the rewrite rules to handle urls to nested sites.

    RewriteEngine On
    RewriteBase /

    # Rule 1
    RewriteRule ^index\.php$ - [L]

    # Rule 2: uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)*files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # Rule 3: add a trailing slash to "/wp-admin"
    # Note: This rule issues and redirect that will subsequently match Rule 5
    RewriteRule ^(([_0-9a-zA-Z-]+/)*)wp-admin$ $1wp-admin/ [R=301,L]

    # Rule 4: do nothing if URL is a file or directory
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Rule 5: strip preceeding path from wp-(content|admin|includes) paths
    # Example: {RewriteBase}sub-site/sub-folder/wp-admin/sites.php --> {RewriteBase}wp-admin/sites.php
    RewriteRule ^([_0-9a-zA-Z-]+/)*(wp-(content|admin|includes).*) $2 [L]

    # Rule 6
    RewriteRule ^([_0-9a-zA-Z-]+/)*(.*\.php)$ $2 [L]

    # Rule 7
    RewriteRule . index.php [L]

    My email is (hopefully): s z b 0 0 1 8 @ a u b u r n . e d u

    Dude. @spencer Bryant… send me your paypal ID. I’m buyin you a beer bro!

    I have been spending hours and hours trying to find a fix that would work for my “sub-subdirectory” site and that worked instantly. If I commented out the “DOMAIN_CURRENT_SITE” line then my theme would disappear, but if I didn’t comment it out then posts and other features wouldn’t show up (or maybe it was vice versa?). This fixed EVERYTHING!

    Thank you!!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Networks for WordPress] Bug Fixes’ is closed to new replies.