public static function recursiveScan($path, $match = '')
{
/**
* Return an array with all matched files from root folder.
*
* @brief get all matched files
* @note Internal recursive use only
*
* @param string $path Folder root
* @param string $match Optional. Regex to apply on file name. For example use '/^.*\.(php)$/i' to get only php file
* @param array &$result Optional. Result array. Empty form first call
*
* @return array
*/
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;
}
}
$result = array();
return _rglob($path, $match, $result);
}