Skip to content

Commit

Permalink
Merge pull request #64 from chesio/fix-return-value
Browse files Browse the repository at this point in the history
Always return an array from AIOWPSecurity_Utility_File::scan_dir_sort_date()
  • Loading branch information
Arsenal21 authored Nov 16, 2016
2 parents f5c1fbc + 7f9e629 commit c173668
Showing 1 changed file with 9 additions and 9 deletions.
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);
}

}

0 comments on commit c173668

Please sign in to comment.