Fatal error: Uncaught exception 'RuntimeException'
<p>PHP version is 5.2.11 returns...</p>

<p>Fatal error: Uncaught exception 'RuntimeException' with message 'DirectoryIterator::__construct(/home/test/test.com/wp-content/themes/mytheme/images) [directoryiterator.--construct]: failed to open dir: No such file or directory' in /home/test/test.com/testing123/wp-content/themes/mytheme/functions.php:462 Stack trace: #0 /home/test/test.com/testing123/wp-content/themes/mytheme/functions.php(462): DirectoryIterator->__construct('/home/test/wie...') #1 /home/test/test.com/testing123/wp-content/themes/mytheme/functions.php(31): get_dirs('/home/test/wie...') #2 /home/test/test.com/testing123/wp-settings.php(717): include('/home/test/wie...') #3 /home/test/test.com/testing123/wp-config.php(76): require_once('/home/test/wie...') #4 /home/test/test.com/testing123/wp-load.php(30): require_once('/home/test/wie...') #5 /home/test/test.com/testing123 in /home/test/test.com/testing123/wp-content/themes/mytheme/functions.php on line 462</p>

<p>Function is below...</p>

<pre><code>function get_dirs($path = '.') {
$dirs = array();
foreach (new DirectoryIterator($path) as $file) {  //this is line 462
    if ($file-&gt;isDir() &amp;&amp; !$file-&gt;isDot()) {
        $dirs[] = $file-&gt;getFilename();
    }
}

return $dirs;
</code></pre>

<p>}</p>

<p>UPDATE: The problem here I've found is that the theme was installed under a virtual directory off the main URL. My scripts are expecting that the theme is installed off the main root url...</p>

<p>example, the theme in this case was installed at: <a href="http://site.com/testing123/wp-content/themes/mytheme" rel="nofollow">http://site.com/testing123/wp-content/themes/mytheme</a></p>

<p>However, I'm expecting this: <a href="http://site.com/wp-content/themes/mytheme" rel="nofollow">http://site.com/wp-content/themes/mytheme</a></p>

<p>AND SO...</p>

<p>My path function fails since it does not take into consideration that it could be installed under a virtual directory.</p>

<p>How could i account for this scenario in my feeding of this function?</p>

<pre><code>$mydir = get_dirs($_SERVER['DOCUMENT_ROOT'].'/wp-content/themes/mytheme/images');

function get_dirs($path = '.') {
$dirs = array();
foreach (new DirectoryIterator($path) as $file) {
    if ($file-&gt;isDir() &amp;&amp; !$file-&gt;isDot()) {
        $dirs[] = $file-&gt;getFilename();
    }
}

return $dirs;
</code></pre>

<p>}</p>
