[wp-trac] [WordPress Trac] #6531: Recursively search for files in theme and plugin editors

WordPress Trac noreply at wordpress.org
Thu Mar 9 20:43:02 UTC 2017


#6531: Recursively search for files in theme and plugin editors
--------------------------------------+-----------------------------
 Reporter:  torbens                   |       Owner:  chsxf
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  Future Release
Component:  Themes                    |     Version:  2.5
 Severity:  minor                     |  Resolution:
 Keywords:  theme-editor needs-patch  |     Focuses:  administration
--------------------------------------+-----------------------------

Comment (by WraithKenny):

 The patches on the ticket address the scanning of plugin files. For
 Themes, it's easier, and if we can't just bump up the depth (for whatever
 reason), maybe we could put filters and let themes "grant access" to its
 own deeper files.
 {{{
 foreach ( $file_types as $type ) {
         switch ( $type ) {
                 case 'php':
                         $allowed_files += $theme->get_files( 'php',
 apply_filters('wp_theme_scandir_depth', 1, $type, $stylesheet ) );
                         $has_templates = ! empty( $allowed_files );
                         break;
                 case 'css':
                         $style_files = $theme->get_files( 'css',
 apply_filters('wp_theme_scandir_depth', 0, $type, $stylesheet ) );
                         $allowed_files['style.css'] =
 $style_files['style.css'];
                         $allowed_files += $style_files;
                         break;
                 default:
                         $allowed_files += $theme->get_files( $type,
 apply_filters('wp_theme_scandir_depth', 0, $type, $stylesheet ) );
                         break;
         }
 }
 }}}

 This would at least allow themes (TwentyEighteen, for example) to do
 {{{
 add_filter( 'wp_theme_scandir_depth', function( $depth, $type, $theme ) {
         if ('twentyeighteen' == $theme && 'css' == $type)
                 return 2;
         return $depth;
 },10,3 );
 }}}

 This would be useful for plugins that enhance the theme editor, such that
 they no longer have to completely rewrite the entire `theme-editor.php`
 file. (example:
 https://github.com/unFocus/Scripts-n-Styles/blob/master/includes/theme-
 editor-page.php)

 I've also rewrote the entire `plugin-editor.php` to use the patch on this
 ticket https://github.com/unFocus/Scripts-n-Styles/blob/master/includes
 /plugin-editor-page.php (Currently in '''4.0.0-alpha''', not in the public
 release.)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/6531#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list