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?.

link|improve this question

71% accept rate
feedback

1 Answer

up vote 3 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'];
} 
link|improve this answer
Ah, of course! Thanks :) – Steven Aug 22 '11 at 6:31
feedback

Your Answer

 
or
required, but never shown

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