wp_make_plugin_file_tree()WP 4.9.0

Makes a tree structure for the plugin file editor's file list.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

Array. Tree structure for listing plugin files.

Usage

wp_make_plugin_file_tree( $plugin_editable_files );
$plugin_editable_files(array) (required)
List of plugin file paths.

Changelog

Since 4.9.0 Introduced.

wp_make_plugin_file_tree() code WP 6.6.2

function wp_make_plugin_file_tree( $plugin_editable_files ) {
	$tree_list = array();

	foreach ( $plugin_editable_files as $plugin_file ) {
		$list     = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
		$last_dir = &$tree_list;

		foreach ( $list as $dir ) {
			$last_dir =& $last_dir[ $dir ];
		}

		$last_dir = $plugin_file;
	}

	return $tree_list;
}