WP_Upgrader::flatten_dirlist( array $nested_files, string $path = '' )

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


Description Description


Parameters Parameters

$nested_files

(array) (Required) Array of files as returned by WP_Filesystem::dirlist()

$path

(string) (Optional) Relative path to prepend to child nodes. Optional.

Default value: ''


Top ↑

Return Return

(array) $files A flattened array of the $nested_files specified.


Top ↑

Source Source

File: wp-admin/includes/class-wp-upgrader.php

	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 . '/' );

				$files = array_merge( $files, $children );
			}
		}

		return $files;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.9.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.