WordPress – Plugin & Theme Check for Multisite/WPMU
This is some information you might need when checking whether or not the current WordPress installation is Mulsite or WPMU.
If this is a MU or Multisite WordPress this will be an option available, if it is not, it won’t be there. fileupload_url contains http://domain.tld/files which is used to rewrite the location of the wp-content/blogs.dir/#/files where the # is the blog ID number of the current blog being processed.
get_option('fileupload_url');
The MU / Multisite change to the option upload_path changes the information from wp-content/uploads to wp-content/blogs.dir/#/files where the # is the blog ID number of the current blog being processed.
get_option('upload_path');
When coding your plugin or theme that will access the uploads directory those two options are important to know the distinction between the MultiSite(MU) and single installations of WordPress.
The following bit of code is something to add to your plugin or theme if you need to determine whether or not the theme is Multisite or not. With ComicPress we use it to find the proper directory to load comics into.
function yourtheme_this_is_multsite() { global $wpmu_version; if (function_exists('is_multisite')) if (is_multisite()) return true; if (!empty($wpmu_version)) return true; return false; }
The $wpmu_version was a way in WPMU <= 2.9.2 to determine if it was a WordPress MU install and the is_multisite() || VHOST is a way to determine if it’s a WordPress > 3.0 installation.
For example, with ComicPress we use it to make sure we’re pointing to the right spot to find the comics.
if (comicpress_this_is_multisite()) { $path_to_use = get_option('fileupload_url'); }
Of course we could also do:
$mu_path = get_option('fileupload_url'); if (!empty($mu_path)) $path_to_use = $mu_path;
But it’s not as reliable.
Discussion ¬