On this page
wp_print_plugin_file_tree( array|string $tree, string $label = '', int $level = 2, int $size = 1, int $index = 1 )
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Outputs the formatted file list for the plugin file editor.
Parameters
$treearray|string Required-
List of file/folder paths, or filename.
$labelstring Optional-
Name of file or folder to print.
Default:
'' $levelint Optional-
The aria-level for the current iteration.
Default:
2 $sizeint Optional-
The aria-setsize for the current iteration.
Default:
1 $indexint Optional-
The aria-posinset for the current iteration.
Default:
1
Source
File: wp-admin/includes/misc.php. View all references
function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $index = 1 ) {
global $file, $plugin;
if ( is_array( $tree ) ) {
$index = 0;
$size = count( $tree );
foreach ( $tree as $label => $plugin_file ) :
$index++;
if ( ! is_array( $plugin_file ) ) {
wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );
continue;
}
?>
<li role="treeitem" aria-expanded="true" tabindex="-1"
aria-level="<?php echo esc_attr( $level ); ?>"
aria-setsize="<?php echo esc_attr( $size ); ?>"
aria-posinset="<?php echo esc_attr( $index ); ?>">
<span class="folder-label"><?php echo esc_html( $label ); ?> <span class="screen-reader-text"><?php _e( 'folder' ); ?></span><span aria-hidden="true" class="icon"></span></span>
<ul role="group" class="tree-folder"><?php wp_print_plugin_file_tree( $plugin_file, '', $level + 1, $index, $size ); ?></ul>
</li>
<?php
endforeach;
} else {
$url = add_query_arg(
array(
'file' => rawurlencode( $tree ),
'plugin' => rawurlencode( $plugin ),
),
self_admin_url( 'plugin-editor.php' )
);
?>
<li role="none" class="<?php echo esc_attr( $file === $tree ? 'current-file' : '' ); ?>">
<a role="treeitem" tabindex="<?php echo esc_attr( $file === $tree ? '0' : '-1' ); ?>"
href="<?php echo esc_url( $url ); ?>"
aria-level="<?php echo esc_attr( $level ); ?>"
aria-setsize="<?php echo esc_attr( $size ); ?>"
aria-posinset="<?php echo esc_attr( $index ); ?>">
<?php
if ( $file === $tree ) {
echo '<span class="notice notice-info">' . esc_html( $label ) . '</span>';
} else {
echo esc_html( $label );
}
?>
</a>
</li>
<?php
}
}
Related
Uses
| Uses | Description |
|---|---|
| self_admin_url() wp-includes/link-template.php | Retrieves the URL to the admin area for either the current site or the network depending on context. |
| wp_print_plugin_file_tree() wp-admin/includes/misc.php | Outputs the formatted file list for the plugin file editor. |
| _e() wp-includes/l10n.php | Displays translated text. |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| esc_html() wp-includes/formatting.php | Escaping for HTML blocks. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
Used By
| Used By | Description |
|---|---|
| wp_print_plugin_file_tree() wp-admin/includes/misc.php | Outputs the formatted file list for the plugin file editor. |
Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_print_plugin_file_tree