I have encounter a couple of cases with wordpress installs with bluehost where I have experienced errors with my wordpress theme since the uploads folder (wordpress-content/uploads) wasn't present.

Apparently the bluehost cpanel Wordpress installer doesn't create this folder, though HostGator does.

So I have to add code to my theme that inspections for that folder and produces it otherwise.

Do this:

if (!is_dir('path/to/directory')) {

Why not a assistant function such as this:

function makeDir($path)
   $ret = mkdir($path); // use @mkdir if you want to suppress warnings/errors
   return $ret === true || is_dir($path);

It'll return true when the directory was effectively produced or already is available, and false when the directory could not be produced.

Another alternative is:

function makeDir($path)
   return is_dir($path) || mkdir($path);

Something a little more universal because this pops up on the internet. As the particulars tend to be more specific, the title of the real question is more universal.

 * recursively create a long directory path
function createPath($path) {
    if (is_dir($path)) return true;
    $prev_path = substr($path, 0, strrpos($path, '/', -2) + 1 );
    $return = createPath($prev_path);
    return ($return && is_writable($prev_path)) ? mkdir($path) : false;

This can have a path, possibly having a lengthy chain of uncreated sites, and rising one directory until it reaches a current directory. It will endeavour to produce the following directory for the reason that directory, and continue till it's produced all of the sites. It returns true if effective.

Might be enhanced by supplying a preventing level therefore it just fails whether it goes past user folder or something like that by including permissions.