2

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?

1 Answer 1

9

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');`
}
1
  • Thanks! Makes perfect sense, why else would you need a blog Id. Must have missed it in the reference manual.
    – Luke
    Commented Jul 7, 2011 at 2:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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