WordPress at Your Fingertips
function is not described

WP_Upgrader::flatten_dirlist() protected WP 4.9.0

Flatten the results of WP_Filesystem_Base::dirlist() for iterating over.

{} It's a method of the class: WP_Upgrader{}

No Hooks.

Return

Array. A flattened array of the $nested_files specified.

Usage

// protected - for code of main (parent) or child class
$result = $this->flatten_dirlist( $nested_files, $path );
$nested_files(array) (required)
Array of files as returned by WP_Filesystem_Base::dirlist().
$path(string)
Relative path to prepend to child nodes. Optional.
Default: ''

Changelog

Since 4.9.0 Introduced.

Code of WP_Upgrader::flatten_dirlist() WP 5.8.2

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;
}