Usage
PHP
nebula()->last_modified($directory, $last_date, $child)
Parameters
$directory
(Optional) (String) The directory to check
Default: None
$last_date
(Optional) (Integer) The time of the last modified file
Default: None
$child
(Optional) (Boolean) Whether to check the child theme.
Default: false
Additional Notes
This function shouldn’t need to be called manually.
Source File
Located in /libs/Admin/Dashboard.php on line 2335.
No Hooks
This function does not have any filters or actions available. Request one?
PHP
public function last_modified($directory=null, $last_date=0, $child=false){
global $latest_file;
if ( empty($latest_file) ){
$latest_file = array(
'date' => false,
'file' => false,
'path' => false,
);
}
$directory ??= get_template_directory();
$dir = $this->glob_r($directory . '/*');
$skip_files = array('/cache/', '/includes/data/', 'manifest.json', '.bak', '.log', '_log', 'sw.js'); //Files or directories to skip. Be specific!
//Limit the number of files scanned to ensure speedy dashboard load times
$max_files = 750;
$scanned_files = 0;
foreach ( $dir as $file ){
$scanned_files++;
if ( $scanned_files > $max_files ){
break; //Too many files — bail out early
}
if ( is_file($file) ){
$mod_date = filemtime($file);
if ( $mod_date > $last_date && !$this->contains($file, $skip_files) ){ //Does not check against skip_extensions() functions on purpose.
$latest_file['date'] = $mod_date;
$latest_file['file'] = basename($file);
if ( is_child_theme() && $child ){
$latest_file['path'] = 'Child: ';
} elseif ( is_child_theme() && !$child ){
$latest_file['path'] = 'Parent: ';
}
$latest_file['path'] .= str_replace($directory, '', dirname($file)) . '/' . $latest_file['file'];
$last_date = $latest_file['date'];
}
}
}
if ( is_child_theme() && !$child ){
$latest_child_file = $this->last_modified(get_stylesheet_directory(), $latest_file['date'], true);
if ( $latest_child_file['date'] > $latest_file['date'] ){
return $latest_child_file;
}
}
return $latest_file;
}
Override
This function can not be short-circuited with an override filter. Request one?