Flattens the results of WP_Filesystem_Base::dirlist() for iterating over.
Parameters
$nested_files
arrayrequired- Array of files as returned by WP_Filesystem_Base::dirlist().
$path
stringoptional- Relative path to prepend to child nodes. Optional.
Default:
''
Source
protected function flatten_dirlist( $nested_files, $path = '' ) {
$files = array();
foreach ( $nested_files as $name => $details ) {
$files[ $path . $name ] = $details;
// Append children recursively.
if ( ! empty( $details['files'] ) ) {
$children = $this->flatten_dirlist( $details['files'], $path . $name . '/' );
// Merge keeping possible numeric keys, which array_merge() will reindex from 0..n.
$files = $files + $children;
}
}
return $files;
}
Changelog
Version | Description |
---|---|
4.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.