Issues with nested folder paths in WordPress multisite
-
I’m using a hack described here and here to allow multiple nested folder paths in WordPress Multisite. For example:
https://example.com/site
https://example.com/fr/site
https://example.com/de/siteetc.
This is for the most part working, but I’m having two issues that I’ve singled out to being caused by the sunrise.php file, which has the following contents:
<?php if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) { $current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1); $current_site->domain = $domain = DOMAIN_CURRENT_SITE; $current_site->path = $path = PATH_CURRENT_SITE; if( defined( 'BLOGID_CURRENT_SITE' ) ) $current_site->blog_id = BLOGID_CURRENT_SITE; $url = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); $patharray = (array) explode( '/', trim( $url, '/' )); $blogsearch = ''; if( count( $patharray )){ foreach( $patharray as $pathpart ){ $pathsearch .= '/'. $pathpart; $blogsearch .= $wpdb->prepare(" OR (domain = %s AND path = %s) ", $domain, $pathsearch .'/' ); } } $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *, LENGTH( path ) as pathlen FROM $wpdb->blogs WHERE domain = %s AND path = '/'", $domain, $path) . $blogsearch .'ORDER BY pathlen DESC LIMIT 1'); $blog_id = $current_blog->blog_id; $public = $current_blog->public; $site_id = $current_blog->site_id; $current_site = pu_get_current_site_name( $current_site ); } function pu_get_current_site_name( $current_site ) { global $wpdb; $current_site->site_name = wp_cache_get( $current_site->id . ':current_site_name', "site-options" ); if ( !$current_site->site_name ) { $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) ); if( $current_site->site_name == null ) $current_site->site_name = ucfirst( $current_site->domain ); wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options'); } return $current_site; }
The issues are as follows:
1. I’m not able to switch to visual mode in the editor
2. With WP_DEBUG turned on, I get the following error:NOTICE: wp-includes/functions.php:3828 - Undefined property: stdClass::$blog_id require_once('wp-admin/admin.php'), do_action('admin_init'), call_user_func_array, wp_schedule_update_network_counts, is_main_site
It looks like the some part of the $current_site object isn’t being set up correctly, or something along those lines, but it’s beyond my skill level to solve it. I’m guessing it has to do with the code not being compatible with either WordPress 4.1.1 or newer versions of PHP, as the tutorials are dated.
Any ideas?
- The topic ‘Issues with nested folder paths in WordPress multisite’ is closed to new replies.