PHP version is 5.2.11 returns...
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
Function is below...
function get_dirs($path = '.') {
$dirs = array();
foreach (new DirectoryIterator($path) as $file) { //this is line 462
if ($file->isDir() && !$file->isDot()) {
$dirs[] = $file->getFilename();
}
}
return $dirs;
}
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...
example, the theme in this case was installed at: http://site.com/testing123/wp-content/themes/mytheme
However, I'm expecting this: http://site.com/wp-content/themes/mytheme
AND SO...
My path function fails since it does not take into consideration that it could be installed under a virtual directory.
How could i account for this scenario in my feeding of this function?
$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->isDir() && !$file->isDot()) {
$dirs[] = $file->getFilename();
}
}
return $dirs;
}