function _rglob($path, $match = '', &$result = array())
{
$files = glob(trailingslashit($path) . '*', GLOB_MARK);
if (false !== $files) {
foreach ($files as $file) {
if (is_dir($file)) {
$continue = apply_filters('wpdk_rglob_find_dir', true, $file);
if ($continue) {
_rglob($file, $match, $result);
}
} elseif (!empty($match)) {
$continue = apply_filters('wpdk_rglob_find_file', true, $file);
if (false == $continue) {
break;
}
$regexp_result = array();
$error = preg_match($match, $file, $regexp_result);
if (0 !== $error || false !== $error) {
$regexp_result = apply_filters('wpdk_rglob_matched', $regexp_result, $file, $match);
if (!empty($regexp_result)) {
$result[] = $regexp_result[0];
}
}
} else {
$result[] = $file;
}
}
return $result;
}
}