Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return an array from AIOWPSecurity_Utility_File::scan_dir_sort_date() #64

Merged
merged 1 commit into from
Nov 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions all-in-one-wp-security/classes/wp-security-utility-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,24 +417,24 @@ static function get_attachment_id_from_url($attachment_url = '')

/**
* Will return an indexed array of files sorted by last modified timestamp
* @param $dir
* @param string $dir
* @param string $sort (ASC, DESC)
* @return array|bool
* @return array
*/
static function scan_dir_sort_date($dir, $sort='DESC') {
$files = array();
foreach (scandir($dir) as $file) {
$files[$file] = filemtime($dir . '/' . $file);
}

arsort($files);
$files = array_keys($files);
if($sort == 'ASC'){
$files = array_reverse($files);
if ($sort === 'ASC') {
asort($files);
}
else {
arsort($files);
}
return ($files) ? $files : false;
}


return array_keys($files);
}

}