Title: wp_make_plugin_file_tree
Published: November 20, 2017
Last modified: April 28, 2025

---

# wp_make_plugin_file_tree( array $plugin_editable_files ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#parameters)󠁿

 `$plugin_editable_files`arrayrequired

List of plugin file paths.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#return)󠁿

 array Tree structure for listing plugin files.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/misc.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/misc.php#L472)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/misc.php#L472-L487)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_make_plugin_file_tree/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_make_plugin_file_tree%2F)
before being able to contribute a note or feedback.