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.

In the functions.php of my plugin I've added the following code:

function relativePathForUploads( $fileinfo )
{
    global $blog_id;
    $path = get_blog_option($blog_id,'siteurl');

    $fileinfo['url'] = str_replace($path,'',$fileinfo['url']);

    return $fileinfo;
}

add_filter('wp_handle_upload', 'relativePathForUploads');

But in the error log I get the following message:

PHP Fatal error:  Call to undefined function get_blog_option()

Do I need to include something before I'm able to call get_blog_option? If so, what?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I think that function is only available in multisite mode. Try:

if(is_multisite()){
  $path = get_blog_option($blog_id,'siteurl');
}else{
  $path = get_option('siteurl');`
}
share|improve this answer
    
Thanks! Makes perfect sense, why else would you need a blog Id. Must have missed it in the reference manual. –  Luke Jul 7 '11 at 2:52

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.