Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've installed a single site WP. In one of my plugins, I have the following code:

if(is_multisite) {
  $upload_dir = get_upload_dir();
  $_SESSION['root_image_dir'] =  str_replace('\\','/',$upload_dir['basedir']);
  echo 'IS MULTI.'; //<-- this is outputted every time
} else {
  $_SESSION['root_image_dir'] = '';
  echo 'IS NOT MULTI'.$_SESSION['root_image_dir'];
} 

For some reason, the echo statement is triggered every time.

Why is is_multisite not working?.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

If that's the code you have in your plugin, you're writing it wrong. You have if(is_multisite) which is treating the string is_multisite as a constant and evalutation to true. Essentially you're writing if(true) ...

Remember, is_multisite() is a function. You need the parenthesis at the end for PHP to actually evaluate the function. Change your code to the following:

if( is_multisite() ) {
    $upload_dir = get_upload_dir();
    $_SESSION['root_image_dir'] =  str_replace('\\','/',$upload_dir['basedir']);
    echo 'IS MULTI.'; //<-- this is outputted every time
} else {
    $_SESSION['root_image_dir'] = '';
    echo 'IS NOT MULTI'.$_SESSION['root_image_dir'];
} 
share|improve this answer
    
Ah, of course! Thanks :) –  Steven Aug 22 '11 at 6:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.