<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[41851] trunk/src/wp-admin: File Editors: Display list of theme/plugin files in scrollable directory tree.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/41851">41851</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/41851","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-10-13 02:38:19 +0000 (Fri, 13 Oct 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>File Editors: Display list of theme/plugin files in scrollable directory tree.

Props WraithKenny, afercia, melchoyce, westonruter.
Amends <a href="https://core.trac.wordpress.org/changeset/41721">[41721]</a>.
Fixes <a href="https://core.trac.wordpress.org/ticket/24048">#24048</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscommoncss">trunk/src/wp-admin/css/common.css</a></li>
<li><a href="#trunksrcwpadminincludesmiscphp">trunk/src/wp-admin/includes/misc.php</a></li>
<li><a href="#trunksrcwpadminjsthemeplugineditorjs">trunk/src/wp-admin/js/theme-plugin-editor.js</a></li>
<li><a href="#trunksrcwpadminplugineditorphp">trunk/src/wp-admin/plugin-editor.php</a></li>
<li><a href="#trunksrcwpadminthemeeditorphp">trunk/src/wp-admin/theme-editor.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscommoncss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/common.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/common.css 2017-10-13 02:09:42 UTC (rev 41850)
+++ trunk/src/wp-admin/css/common.css   2017-10-13 02:38:19 UTC (rev 41851)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1466,17 +1466,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .wrap #templateside .notice {
</span><span class="cx" style="display: block; padding: 0 10px">        display: block;
</span><span class="cx" style="display: block; padding: 0 10px">        margin: 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        padding: 5px 12px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ padding: 5px 8px;
</ins><span class="cx" style="display: block; padding: 0 10px">         font-weight: 600;
</span><span class="cx" style="display: block; padding: 0 10px">        text-decoration: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> .wrap #templateside span.notice {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-  margin-left: -12px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ margin-left: -12px;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> #templateside li.notice a {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-  padding: 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ padding: 0;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /* Update icon. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3036,11 +3036,135 @@
</span><span class="cx" style="display: block; padding: 0 10px">        width: 97%;
</span><span class="cx" style="display: block; padding: 0 10px">        height: calc( 100vh - 280px );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#templateside {
-       margin-top: 31px;
-       overflow: scroll;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+#templateside > h2 {
+       padding-top: 6px;
+       padding-bottom: 6px;
+       margin: 0;
+       border-bottom: solid 1px #ccc;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#templateside ol,
+#templateside ul {
+       margin: .5em 0;
+       padding: 0;
+}
+#templateside > ul {
+       margin-top: 0;
+       overflow: auto;
+       padding: 2px;
+       height: calc(100vh - 280px);
+}
+#templateside ul ul {
+       padding-left: 12px;
+}
+
+/*
+ * Styles for Theme and Plugin editors.
+ */
+
+/* Hide collapsed items. */
+[role="treeitem"][aria-expanded="false"] > ul {
+       display: none;
+}
+
+/* Use arrow dashicons for folder states, but hide from screen readers. */
+[role="treeitem"] span[aria-hidden] {
+       display: inline;
+       font-family: dashicons;
+       font-size: 20px;
+       position: absolute;
+       pointer-events: none;
+}
+[role="treeitem"][aria-expanded="false"] > .folder-label .icon:after {
+       content: "\f139";
+}
+[role="treeitem"][aria-expanded="true"] > .folder-label .icon:after {
+       content: "\f140";
+}
+[role="treeitem"] .folder-label {
+       display: block;
+       padding: 3px 3px 3px 12px;
+       cursor: pointer;
+}
+
+/* Remove outline, and create our own focus and hover styles */
+[role="treeitem"] {
+       outline: 0;
+}
+[role="treeitem"] .folder-label.focus {
+       color: #124964;
+       box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8);
+}
+[role="treeitem"].hover,
+[role="treeitem"] .folder-label.hover {
+       background-color: #DDDDDD;
+}
+
+.tree-folder {
+       margin: 0;
+       position: relative;
+}
+[role="treeitem"] li {
+       position: relative;
+}
+
+/* Styles for folder indicators/depth */
+.tree-folder .tree-folder::after {
+       content: ' ';
+       display: block;
+       position: absolute;
+       left: 2px;
+       border-left: 1px solid #ccc;
+       top: -13px;
+       bottom: 10px;
+}
+.tree-folder > li::before {
+       content: ' ';
+       position: absolute;
+       display: block;
+       border-left: 1px solid #ccc;
+       left: 2px;
+       top: -5px;
+       height: 18px;
+       width: 7px;
+       border-bottom: 1px solid #ccc;
+}
+.tree-folder > li::after {
+       content: ' ';
+       position: absolute;
+       display: block;
+       border-left: 1px solid #ccc;
+       left: 2px;
+       bottom: -7px;
+       top: 0;
+}
+
+/* current-file needs to adjustment for .notice styles */
+#templateside .current-file {
+       margin: -4px 0 -2px;
+}
+.tree-folder > .current-file::before {
+       left: 4px;
+       height: 15px;
+       width: 6px;
+       border-left: none;
+       top: 3px;
+}
+.tree-folder > .current-file::after {
+       bottom: -4px;
+       height: 7px;
+       left: 2px;
+       top: auto;
+}
+
+/* Lines shouldn't continue on last item */
+.tree-folder > li:last-child::after,
+.tree-folder li:last-child > .tree-folder::after {
+       display: none;
+}
+
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #theme-plugin-editor-label {
</span><span class="cx" style="display: block; padding: 0 10px">        display: inline-block;
</span><span class="cx" style="display: block; padding: 0 10px">        margin-bottom: 1em;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3090,7 +3214,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        word-wrap: break-word;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#templateside h2,
</del><span class="cx" style="display: block; padding: 0 10px"> #postcustomstuff p.submit {
</span><span class="cx" style="display: block; padding: 0 10px">        margin: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3099,12 +3222,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        margin: 1em 0 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#templateside ol,
-#templateside ul {
-       margin: .5em 0;
-       padding: 0;
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> #templateside li {
</span><span class="cx" style="display: block; padding: 0 10px">        margin: 4px 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3653,6 +3770,35 @@
</span><span class="cx" style="display: block; padding: 0 10px">                width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        #templateside ul ul {
+               padding-left: 1.5em;
+       }
+       [role="treeitem"] .folder-label {
+               display: block;
+               padding: 5px;
+       }
+       .tree-folder > li::before,
+       .tree-folder > li::after,
+       .tree-folder .tree-folder::after {
+               left: -8px;
+       }
+       .tree-folder > li::before {
+               top: 0px;
+               height: 13px;
+       }
+       .tree-folder > .current-file::before {
+               left: -5px;
+               top: 7px;
+               width: 4px;
+       }
+       .tree-folder > .current-file::after {
+               height: 9px;
+               left: -8px;
+       }
+       .wrap #templateside span.notice {
+               margin-left: -14px;
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         .fileedit-sub .alignright {
</span><span class="cx" style="display: block; padding: 0 10px">                margin-top: 15px;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre></div>
<a id="trunksrcwpadminincludesmiscphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/misc.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/misc.php      2017-10-13 02:09:42 UTC (rev 41850)
+++ trunk/src/wp-admin/includes/misc.php        2017-10-13 02:38:19 UTC (rev 41851)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -270,6 +270,178 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Makes a tree structure for the Theme Editor's file list.
+ *
+ * @since 4.9.0
+ * @access private
+ *
+ * @param array $allowed_files List of theme file paths.
+ * @return array Tree structure for listing theme files.
+ */
+function wp_make_theme_file_tree( $allowed_files ) {
+       $tree_list = array();
+       foreach ( $allowed_files as $file_name => $absolute_filename ) {
+               $list = explode( '/', $file_name );
+               $last_dir = &$tree_list;
+               foreach ( $list as $dir ) {
+                       $last_dir =& $last_dir[ $dir ];
+               }
+               $last_dir = $file_name;
+       }
+       return $tree_list;
+}
+
+/**
+ * Outputs the formatted file list for the Theme Editor.
+ *
+ * @since 4.9.0
+ * @access private
+ *
+ * @param array|string $tree  List of file/folder paths, or filename.
+ * @param int          $level The aria-level for the current iteration.
+ * @param int          $size  The aria-setsize for the current iteration.
+ * @param int          $index The aria-posinset for the current iteration.
+ */
+function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
+       global $relative_file, $stylesheet;
+
+       if ( is_array( $tree ) ) {
+               $index = 0;
+               $size = count( $tree );
+               foreach ( $tree as $label => $theme_file ) :
+                       $index++;
+                       if ( ! is_array( $theme_file ) ) {
+                               wp_print_theme_file_tree( $theme_file, $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_theme_file_tree( $theme_file, $level + 1, $index, $size ); ?></ul>
+                       </li>
+                       <?php
+               endforeach;
+       } else {
+               $filename = $tree;
+               $url = add_query_arg(
+                       array(
+                               'file' => rawurlencode( $tree ),
+                               'theme' => rawurlencode( $stylesheet ),
+                       ),
+                       admin_url( 'theme-editor.php' )
+               );
+               ?>
+               <li role="none" class="<?php echo esc_attr( $relative_file === $filename ? 'current-file' : '' ); ?>">
+                       <a role="treeitem" tabindex="<?php echo esc_attr( $relative_file === $filename ? '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
+                               $file_description = esc_html( get_file_description( $filename ) );
+                               if ( $file_description !== $filename && basename( $filename ) !== $file_description ) {
+                                       $file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
+                               }
+
+                               if ( $relative_file === $filename ) {
+                                       echo '<span class="notice notice-info">' . $file_description . '</span>';
+                               } else {
+                                       echo $file_description;
+                               }
+                               ?>
+                       </a>
+               </li>
+               <?php
+       }
+}
+
+/**
+ * Makes a tree structure for the Plugin Editor's file list.
+ *
+ * @since 4.9.0
+ * @access private
+ *
+ * @param string $plugin_editable_files List of plugin file paths.
+ * @return array Tree structure for listing plugin files.
+ */
+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;
+}
+
+/**
+ * Outputs the formatted file list for the Plugin Editor.
+ *
+ * @since 4.9.0
+ * @access private
+ *
+ * @param array|string $tree  List of file/folder paths, or filename.
+ * @param string       $label Name of file or folder to print.
+ * @param int          $level The aria-level for the current iteration.
+ * @param int          $size  The aria-setsize for the current iteration.
+ * @param int          $index The aria-posinset for the current iteration.
+ */
+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 ),
+                       ),
+                       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
+       }
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Flushes rewrite rules if siteurl, home or page_on_front changed.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.1.0
</span></span></pre></div>
<a id="trunksrcwpadminjsthemeplugineditorjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/theme-plugin-editor.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/theme-plugin-editor.js      2017-10-13 02:09:42 UTC (rev 41850)
+++ trunk/src/wp-admin/js/theme-plugin-editor.js        2017-10-13 02:38:19 UTC (rev 41851)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,8 +6,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> wp.themePluginEditor = (function( $ ) {
</span><span class="cx" style="display: block; padding: 0 10px">        'use strict';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        var component, TreeLinks;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        var component = {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ component = {
</ins><span class="cx" style="display: block; padding: 0 10px">                 l10n: {
</span><span class="cx" style="display: block; padding: 0 10px">                        lintError: {
</span><span class="cx" style="display: block; padding: 0 10px">                                singular: '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,6 +67,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        } );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $( component.initFileBrowser );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $( window ).on( 'beforeunload', function() {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( component.dirty ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return component.l10n.saveAlert;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,11 +89,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        pointer: component.themeOrPlugin + '_editor_notice'
</span><span class="cx" style="display: block; padding: 0 10px">                });
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // hide modal
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Hide modal.
</ins><span class="cx" style="display: block; padding: 0 10px">                 component.warning.remove();
</span><span class="cx" style="display: block; padding: 0 10px">                $( 'body' ).removeClass( 'modal-open' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // return focus - is this a trap?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Return focus - is this a trap?
</ins><span class="cx" style="display: block; padding: 0 10px">                 component.instance.codemirror.focus();
</span><span class="cx" style="display: block; padding: 0 10px">        };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -148,7 +151,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        component.removeNotice( component.lastSaveNoticeCode );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                request.done( function ( response ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         request.done( function( response ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         component.lastSaveNoticeCode = 'file_saved';
</span><span class="cx" style="display: block; padding: 0 10px">                        component.addNotice({
</span><span class="cx" style="display: block; padding: 0 10px">                                code: component.lastSaveNoticeCode,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -159,7 +162,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        component.dirty = false;
</span><span class="cx" style="display: block; padding: 0 10px">                } );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                request.fail( function ( response ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         request.fail( function( response ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         var notice = $.extend(
</span><span class="cx" style="display: block; padding: 0 10px">                                {
</span><span class="cx" style="display: block; padding: 0 10px">                                        code: 'save_error',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -350,5 +353,583 @@
</span><span class="cx" style="display: block; padding: 0 10px">                component.instance = editor;
</span><span class="cx" style="display: block; padding: 0 10px">        };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Initialization of the file browser's folder states.
+        *
+        * @since 4.9.0
+        * @returns {void}
+        */
+       component.initFileBrowser = function initFileBrowser() {
+
+               var $templateside = $( '#templateside' );
+
+               // Collapse all folders.
+               $templateside.find( '[role="group"]' ).parent().attr( 'aria-expanded', false );
+
+               // Expand ancestors to the current file.
+               $templateside.find( '.notice' ).parents( '[aria-expanded]' ).attr( 'aria-expanded', true );
+
+               // Find Tree elements and enhance them.
+               $templateside.find( '[role="tree"]' ).each( function() {
+                       var treeLinks = new TreeLinks( this );
+                       treeLinks.init();
+               } );
+
+               // Scroll the current file into view.
+               $templateside.find( '.current-file' ).each( function() {
+                       this.scrollIntoView( false );
+               } );
+       };
+
+       /* jshint ignore:start */
+       /* jscs:disable */
+       /* eslint-disable */
+
+       /**
+        * Creates a new TreeitemLink.
+        *
+        * @since 4.9.0
+        * @class
+        * @private
+        * @see {@link https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-2/treeview-2b.html|W3C Treeview Example}
+        * @license W3C-20150513
+        */
+       var TreeitemLink = (function () {
+               /**
+                *   This content is licensed according to the W3C Software License at
+                *   https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
+                *
+                *   File:   TreeitemLink.js
+                *
+                *   Desc:   Treeitem widget that implements ARIA Authoring Practices
+                *           for a tree being used as a file viewer
+                *
+                *   Author: Jon Gunderson, Ku Ja Eun and Nicholas Hoyt
+                */
+
+               /**
+                *   @constructor
+                *
+                *   @desc
+                *       Treeitem object for representing the state and user interactions for a
+                *       treeItem widget
+                *
+                *   @param node
+                *       An element with the role=tree attribute
+                */
+
+               var TreeitemLink = function (node, treeObj, group) {
+
+                       // Check whether node is a DOM element
+                       if (typeof node !== 'object') {
+                               return;
+                       }
+
+                       node.tabIndex = -1;
+                       this.tree = treeObj;
+                       this.groupTreeitem = group;
+                       this.domNode = node;
+                       this.label = node.textContent.trim();
+                       this.stopDefaultClick = false;
+
+                       if (node.getAttribute('aria-label')) {
+                               this.label = node.getAttribute('aria-label').trim();
+                       }
+
+                       this.isExpandable = false;
+                       this.isVisible = false;
+                       this.inGroup = false;
+
+                       if (group) {
+                               this.inGroup = true;
+                       }
+
+                       var elem = node.firstElementChild;
+
+                       while (elem) {
+
+                               if (elem.tagName.toLowerCase() == 'ul') {
+                                       elem.setAttribute('role', 'group');
+                                       this.isExpandable = true;
+                                       break;
+                               }
+
+                               elem = elem.nextElementSibling;
+                       }
+
+                       this.keyCode = Object.freeze({
+                               RETURN: 13,
+                               SPACE: 32,
+                               PAGEUP: 33,
+                               PAGEDOWN: 34,
+                               END: 35,
+                               HOME: 36,
+                               LEFT: 37,
+                               UP: 38,
+                               RIGHT: 39,
+                               DOWN: 40
+                       });
+               };
+
+               TreeitemLink.prototype.init = function () {
+                       this.domNode.tabIndex = -1;
+
+                       if (!this.domNode.getAttribute('role')) {
+                               this.domNode.setAttribute('role', 'treeitem');
+                       }
+
+                       this.domNode.addEventListener('keydown', this.handleKeydown.bind(this));
+                       this.domNode.addEventListener('click', this.handleClick.bind(this));
+                       this.domNode.addEventListener('focus', this.handleFocus.bind(this));
+                       this.domNode.addEventListener('blur', this.handleBlur.bind(this));
+
+                       if (this.isExpandable) {
+                               this.domNode.firstElementChild.addEventListener('mouseover', this.handleMouseOver.bind(this));
+                               this.domNode.firstElementChild.addEventListener('mouseout', this.handleMouseOut.bind(this));
+                       }
+                       else {
+                               this.domNode.addEventListener('mouseover', this.handleMouseOver.bind(this));
+                               this.domNode.addEventListener('mouseout', this.handleMouseOut.bind(this));
+                       }
+               };
+
+               TreeitemLink.prototype.isExpanded = function () {
+
+                       if (this.isExpandable) {
+                               return this.domNode.getAttribute('aria-expanded') === 'true';
+                       }
+
+                       return false;
+
+               };
+
+               /* EVENT HANDLERS */
+
+               TreeitemLink.prototype.handleKeydown = function (event) {
+                       var tgt = event.currentTarget,
+                               flag = false,
+                               _char = event.key,
+                               clickEvent;
+
+                       function isPrintableCharacter(str) {
+                               return str.length === 1 && str.match(/\S/);
+                       }
+
+                       function printableCharacter(item) {
+                               if (_char == '*') {
+                                       item.tree.expandAllSiblingItems(item);
+                                       flag = true;
+                               }
+                               else {
+                                       if (isPrintableCharacter(_char)) {
+                                               item.tree.setFocusByFirstCharacter(item, _char);
+                                               flag = true;
+                                       }
+                               }
+                       }
+
+                       this.stopDefaultClick = false;
+
+                       if (event.altKey || event.ctrlKey || event.metaKey) {
+                               return;
+                       }
+
+                       if (event.shift) {
+                               if (event.keyCode == this.keyCode.SPACE || event.keyCode == this.keyCode.RETURN) {
+                                       event.stopPropagation();
+                                       this.stopDefaultClick = true;
+                               }
+                               else {
+                                       if (isPrintableCharacter(_char)) {
+                                               printableCharacter(this);
+                                       }
+                               }
+                       }
+                       else {
+                               switch (event.keyCode) {
+                                       case this.keyCode.SPACE:
+                                       case this.keyCode.RETURN:
+                                               if (this.isExpandable) {
+                                                       if (this.isExpanded()) {
+                                                               this.tree.collapseTreeitem(this);
+                                                       }
+                                                       else {
+                                                               this.tree.expandTreeitem(this);
+                                                       }
+                                                       flag = true;
+                                               }
+                                               else {
+                                                       event.stopPropagation();
+                                                       this.stopDefaultClick = true;
+                                               }
+                                               break;
+
+                                       case this.keyCode.UP:
+                                               this.tree.setFocusToPreviousItem(this);
+                                               flag = true;
+                                               break;
+
+                                       case this.keyCode.DOWN:
+                                               this.tree.setFocusToNextItem(this);
+                                               flag = true;
+                                               break;
+
+                                       case this.keyCode.RIGHT:
+                                               if (this.isExpandable) {
+                                                       if (this.isExpanded()) {
+                                                               this.tree.setFocusToNextItem(this);
+                                                       }
+                                                       else {
+                                                               this.tree.expandTreeitem(this);
+                                                       }
+                                               }
+                                               flag = true;
+                                               break;
+
+                                       case this.keyCode.LEFT:
+                                               if (this.isExpandable && this.isExpanded()) {
+                                                       this.tree.collapseTreeitem(this);
+                                                       flag = true;
+                                               }
+                                               else {
+                                                       if (this.inGroup) {
+                                                               this.tree.setFocusToParentItem(this);
+                                                               flag = true;
+                                                       }
+                                               }
+                                               break;
+
+                                       case this.keyCode.HOME:
+                                               this.tree.setFocusToFirstItem();
+                                               flag = true;
+                                               break;
+
+                                       case this.keyCode.END:
+                                               this.tree.setFocusToLastItem();
+                                               flag = true;
+                                               break;
+
+                                       default:
+                                               if (isPrintableCharacter(_char)) {
+                                                       printableCharacter(this);
+                                               }
+                                               break;
+                               }
+                       }
+
+                       if (flag) {
+                               event.stopPropagation();
+                               event.preventDefault();
+                       }
+               };
+
+               TreeitemLink.prototype.handleClick = function (event) {
+
+                       // only process click events that directly happened on this treeitem
+                       if (event.target !== this.domNode && event.target !== this.domNode.firstElementChild) {
+                               return;
+                       }
+
+                       if (this.isExpandable) {
+                               if (this.isExpanded()) {
+                                       this.tree.collapseTreeitem(this);
+                               }
+                               else {
+                                       this.tree.expandTreeitem(this);
+                               }
+                               event.stopPropagation();
+                       }
+               };
+
+               TreeitemLink.prototype.handleFocus = function (event) {
+                       var node = this.domNode;
+                       if (this.isExpandable) {
+                               node = node.firstElementChild;
+                       }
+                       node.classList.add('focus');
+               };
+
+               TreeitemLink.prototype.handleBlur = function (event) {
+                       var node = this.domNode;
+                       if (this.isExpandable) {
+                               node = node.firstElementChild;
+                       }
+                       node.classList.remove('focus');
+               };
+
+               TreeitemLink.prototype.handleMouseOver = function (event) {
+                       event.currentTarget.classList.add('hover');
+               };
+
+               TreeitemLink.prototype.handleMouseOut = function (event) {
+                       event.currentTarget.classList.remove('hover');
+               };
+
+               return TreeitemLink;
+       })();
+
+       /**
+        * Creates a new TreeLinks.
+        *
+        * @since 4.9.0
+        * @class
+        * @private
+        * @see {@link https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-2/treeview-2b.html|W3C Treeview Example}
+        * @license W3C-20150513
+        */
+       TreeLinks = (function () {
+               /*
+                *   This content is licensed according to the W3C Software License at
+                *   https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
+                *
+                *   File:   TreeLinks.js
+                *
+                *   Desc:   Tree widget that implements ARIA Authoring Practices
+                *           for a tree being used as a file viewer
+                *
+                *   Author: Jon Gunderson, Ku Ja Eun and Nicholas Hoyt
+                */
+
+               /*
+                *   @constructor
+                *
+                *   @desc
+                *       Tree item object for representing the state and user interactions for a
+                *       tree widget
+                *
+                *   @param node
+                *       An element with the role=tree attribute
+                */
+
+               var TreeLinks = function (node) {
+                       // Check whether node is a DOM element
+                       if (typeof node !== 'object') {
+                               return;
+                       }
+
+                       this.domNode = node;
+
+                       this.treeitems = [];
+                       this.firstChars = [];
+
+                       this.firstTreeitem = null;
+                       this.lastTreeitem = null;
+
+               };
+
+               TreeLinks.prototype.init = function () {
+
+                       function findTreeitems(node, tree, group) {
+
+                               var elem = node.firstElementChild;
+                               var ti = group;
+
+                               while (elem) {
+
+                                       if ((elem.tagName.toLowerCase() === 'li' && elem.firstElementChild.tagName.toLowerCase() === 'span') || elem.tagName.toLowerCase() === 'a') {
+                                               ti = new TreeitemLink(elem, tree, group);
+                                               ti.init();
+                                               tree.treeitems.push(ti);
+                                               tree.firstChars.push(ti.label.substring(0, 1).toLowerCase());
+                                       }
+
+                                       if (elem.firstElementChild) {
+                                               findTreeitems(elem, tree, ti);
+                                       }
+
+                                       elem = elem.nextElementSibling;
+                               }
+                       }
+
+                       // initialize pop up menus
+                       if (!this.domNode.getAttribute('role')) {
+                               this.domNode.setAttribute('role', 'tree');
+                       }
+
+                       findTreeitems(this.domNode, this, false);
+
+                       this.updateVisibleTreeitems();
+
+                       this.firstTreeitem.domNode.tabIndex = 0;
+
+               };
+
+               TreeLinks.prototype.setFocusToItem = function (treeitem) {
+
+                       for (var i = 0; i < this.treeitems.length; i++) {
+                               var ti = this.treeitems[i];
+
+                               if (ti === treeitem) {
+                                       ti.domNode.tabIndex = 0;
+                                       ti.domNode.focus();
+                               }
+                               else {
+                                       ti.domNode.tabIndex = -1;
+                               }
+                       }
+
+               };
+
+               TreeLinks.prototype.setFocusToNextItem = function (currentItem) {
+
+                       var nextItem = false;
+
+                       for (var i = (this.treeitems.length - 1); i >= 0; i--) {
+                               var ti = this.treeitems[i];
+                               if (ti === currentItem) {
+                                       break;
+                               }
+                               if (ti.isVisible) {
+                                       nextItem = ti;
+                               }
+                       }
+
+                       if (nextItem) {
+                               this.setFocusToItem(nextItem);
+                       }
+
+               };
+
+               TreeLinks.prototype.setFocusToPreviousItem = function (currentItem) {
+
+                       var prevItem = false;
+
+                       for (var i = 0; i < this.treeitems.length; i++) {
+                               var ti = this.treeitems[i];
+                               if (ti === currentItem) {
+                                       break;
+                               }
+                               if (ti.isVisible) {
+                                       prevItem = ti;
+                               }
+                       }
+
+                       if (prevItem) {
+                               this.setFocusToItem(prevItem);
+                       }
+               };
+
+               TreeLinks.prototype.setFocusToParentItem = function (currentItem) {
+
+                       if (currentItem.groupTreeitem) {
+                               this.setFocusToItem(currentItem.groupTreeitem);
+                       }
+               };
+
+               TreeLinks.prototype.setFocusToFirstItem = function () {
+                       this.setFocusToItem(this.firstTreeitem);
+               };
+
+               TreeLinks.prototype.setFocusToLastItem = function () {
+                       this.setFocusToItem(this.lastTreeitem);
+               };
+
+               TreeLinks.prototype.expandTreeitem = function (currentItem) {
+
+                       if (currentItem.isExpandable) {
+                               currentItem.domNode.setAttribute('aria-expanded', true);
+                               this.updateVisibleTreeitems();
+                       }
+
+               };
+
+               TreeLinks.prototype.expandAllSiblingItems = function (currentItem) {
+                       for (var i = 0; i < this.treeitems.length; i++) {
+                               var ti = this.treeitems[i];
+
+                               if ((ti.groupTreeitem === currentItem.groupTreeitem) && ti.isExpandable) {
+                                       this.expandTreeitem(ti);
+                               }
+                       }
+
+               };
+
+               TreeLinks.prototype.collapseTreeitem = function (currentItem) {
+
+                       var groupTreeitem = false;
+
+                       if (currentItem.isExpanded()) {
+                               groupTreeitem = currentItem;
+                       }
+                       else {
+                               groupTreeitem = currentItem.groupTreeitem;
+                       }
+
+                       if (groupTreeitem) {
+                               groupTreeitem.domNode.setAttribute('aria-expanded', false);
+                               this.updateVisibleTreeitems();
+                               this.setFocusToItem(groupTreeitem);
+                       }
+
+               };
+
+               TreeLinks.prototype.updateVisibleTreeitems = function () {
+
+                       this.firstTreeitem = this.treeitems[0];
+
+                       for (var i = 0; i < this.treeitems.length; i++) {
+                               var ti = this.treeitems[i];
+
+                               var parent = ti.domNode.parentNode;
+
+                               ti.isVisible = true;
+
+                               while (parent && (parent !== this.domNode)) {
+
+                                       if (parent.getAttribute('aria-expanded') == 'false') {
+                                               ti.isVisible = false;
+                                       }
+                                       parent = parent.parentNode;
+                               }
+
+                               if (ti.isVisible) {
+                                       this.lastTreeitem = ti;
+                               }
+                       }
+
+               };
+
+               TreeLinks.prototype.setFocusByFirstCharacter = function (currentItem, _char) {
+                       var start, index;
+                       _char = _char.toLowerCase();
+
+                       // Get start index for search based on position of currentItem
+                       start = this.treeitems.indexOf(currentItem) + 1;
+                       if (start === this.treeitems.length) {
+                               start = 0;
+                       }
+
+                       // Check remaining slots in the menu
+                       index = this.getIndexFirstChars(start, _char);
+
+                       // If not found in remaining slots, check from beginning
+                       if (index === -1) {
+                               index = this.getIndexFirstChars(0, _char);
+                       }
+
+                       // If match was found...
+                       if (index > -1) {
+                               this.setFocusToItem(this.treeitems[index]);
+                       }
+               };
+
+               TreeLinks.prototype.getIndexFirstChars = function (startIndex, _char) {
+                       for (var i = startIndex; i < this.firstChars.length; i++) {
+                               if (this.treeitems[i].isVisible) {
+                                       if (_char === this.firstChars[i]) {
+                                               return i;
+                                       }
+                               }
+                       }
+                       return -1;
+               };
+
+               return TreeLinks;
+       })();
+
+       /* jshint ignore:end */
+       /* jscs:enable */
+       /* eslint-enable */
+
</ins><span class="cx" style="display: block; padding: 0 10px">         return component;
</span><span class="cx" style="display: block; padding: 0 10px"> })( jQuery );
</span></span></pre></div>
<a id="trunksrcwpadminplugineditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/plugin-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/plugin-editor.php      2017-10-13 02:09:42 UTC (rev 41850)
+++ trunk/src/wp-admin/plugin-editor.php        2017-10-13 02:38:19 UTC (rev 41851)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -231,7 +231,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> <div id="templateside">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <h2><?php _e( 'Plugin Files' ); ?></h2>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <h2 id="plugin-files-label"><?php _e( 'Plugin Files' ); ?></h2>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <?php
</span><span class="cx" style="display: block; padding: 0 10px">        $plugin_editable_files = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -241,12 +241,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px">        ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <ul>
-       <?php foreach ( $plugin_editable_files as $plugin_file ) : ?>
-               <li class="<?php echo esc_attr( $file === $plugin_file ? 'notice notice-info' : '' ); ?>">
-                       <a href="plugin-editor.php?file=<?php echo urlencode( $plugin_file ); ?>&amp;plugin=<?php echo urlencode( $plugin ); ?>"><?php echo esc_html( preg_replace( '#^.+?/#', '', $plugin_file ) ); ?></a>
-               </li>
-       <?php endforeach; ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <ul role="tree" aria-labelledby="plugin-files-label">
+       <li role="treeitem" tabindex="-1" aria-expanded="true"
+               aria-level="1"
+               aria-posinset="1"
+               aria-setsize="1">
+               <ul role="group" style="padding-left: 0;">
+                       <?php wp_print_plugin_file_tree( wp_make_plugin_file_tree( $plugin_editable_files ) ); ?>
+               </ul>
</ins><span class="cx" style="display: block; padding: 0 10px">         </ul>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> <form name="template" id="template" action="plugin-editor.php" method="post">
</span></span></pre></div>
<a id="trunksrcwpadminthemeeditorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/theme-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/theme-editor.php       2017-10-13 02:09:42 UTC (rev 41850)
+++ trunk/src/wp-admin/theme-editor.php 2017-10-13 02:38:19 UTC (rev 41851)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,6 +89,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Move functions.php and style.css to the top.
+if ( isset( $allowed_files['functions.php'] ) ) {
+       $allowed_files = array( 'functions.php' => $allowed_files['functions.php'] ) + $allowed_files;
+}
+if ( isset( $allowed_files['style.css'] ) ) {
+       $allowed_files = array( 'style.css' => $allowed_files['style.css'] ) + $allowed_files;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">        $relative_file = 'style.css';
</span><span class="cx" style="display: block; padding: 0 10px">        $file = $allowed_files['style.css'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -205,63 +213,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $theme->errors() )
</span><span class="cx" style="display: block; padding: 0 10px">        echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>';
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <div id="templateside">
-<?php
-if ( $allowed_files ) :
-       $previous_file_type = '';
-
-       foreach ( $allowed_files as $filename => $absolute_filename ) :
-               $file_type = substr( $filename, strrpos( $filename, '.' ) );
-
-               if ( $file_type !== $previous_file_type ) {
-                       if ( '' !== $previous_file_type ) {
-                               echo "\t</ul>\n";
-                       }
-
-                       switch ( $file_type ) {
-                               case '.php':
-                                       if ( $has_templates || $theme->parent() ) :
-                                               echo "\t<h2>" . __( 'Templates' ) . "</h2>\n";
-                                               if ( $theme->parent() ) {
-                                                       echo '<p class="howto">' . sprintf( __( 'This child theme inherits templates from a parent theme, %s.' ),
-                                                               sprintf( '<a href="%s">%s</a>',
-                                                                       self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ),
-                                                                       $theme->parent()->display( 'Name' )
-                                                               )
-                                                       ) . "</p>\n";
-                                               }
-                                       endif;
-                                       break;
-                               case '.css':
-                                       echo "\t<h2>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h2>\n";
-                                       break;
-                               default:
-                                       /* translators: %s: file extension */
-                                       echo "\t<h2>" . sprintf( __( '%s files' ), $file_type ) . "</h2>\n";
-                                       break;
-                       }
-
-                       echo "\t<ul>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<div id="templateside">
+       <h2 id="theme-files-label"><?php _e( 'Theme Files' ); ?></h2>
+       <?php
+       if ( $has_templates || $theme->parent() ) :
+               if ( $theme->parent() ) {
+                       /* translators: %s: link to edit parent theme */
+                       echo '<p class="howto">' . sprintf( __( 'This child theme inherits templates from a parent theme, %s.' ),
+                               sprintf( '<a href="%s">%s</a>',
+                                       self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ),
+                                       $theme->parent()->display( 'Name' )
+                               )
+                       ) . "</p>\n";
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        endif;
+       ?>
+       <ul role="tree" aria-labelledby="theme-files-label">
+               <li role="treeitem" tabindex="-1" aria-expanded="true"
+                       aria-level="1"
+                       aria-posinset="1"
+                       aria-setsize="1">
+                       <ul role="group" style="padding-left: 0;">
+                               <?php wp_print_theme_file_tree( wp_make_theme_file_tree( $allowed_files ) ); ?>
+                       </ul>
+               </li>
+       </ul>
+</div>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $file_description = esc_html( get_file_description( $filename ) );
-               if ( $filename !== basename( $absolute_filename ) || $file_description !== $filename ) {
-                       $file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
-               }
-
-               if ( $absolute_filename === $file ) {
-                       $file_description = '<span class="notice notice-info">' . $file_description . '</span>';
-               }
-
-               $previous_file_type = $file_type;
-?>
-               <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&amp;theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li>
-<?php
-       endforeach;
-?>
-</ul>
-<?php endif; ?>
-</div>
</del><span class="cx" style="display: block; padding: 0 10px"> <?php if ( $error ) :
</span><span class="cx" style="display: block; padding: 0 10px">        echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
</span><span class="cx" style="display: block; padding: 0 10px"> else : ?>
</span></span></pre>
</div>
</div>

</body>
</html>