Question

right now, i use global variable $table_prefix to differ whether i work on WP or WPMU. I need this global for my plugin. But is there any better way to check whether your pluggin is working on wp or wpmu ?

any suggestion will be great

Was it helpful?

Solution

In WPMU a global variable named wpmu_version should be set.

OTHER TIPS

for my checks I use a function I found

// from http://frumph.net/wordpress/wordpress-plugin-theme-check-for-multisitewpmu/
        // check for multisite. Returns boolean
        function check_this_is_multsite() {
            global $wpmu_version;
            if (function_exists('is_multisite')){
                if (is_multisite()) {
                    return true;
                }
                if (!empty($wpmu_version)){
                    return true;
                }
            }
            return false;
        }

use it like this

if(check_this_is_multsite()){
    // is on wpmu
} else {
    // is on single
}

You could define a constant:

e.g.

define('ENVIRONMENT', 'WP');

define('ENVIRONMENT', 'WPMU');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top