Make WordPress Core

Ticket #39316: plugin.php.patch

File plugin.php.patch, 1.4 KB (added by mattdevelop, 8 years ago)

Here is a patch which can help solving this problem

  • plugin.php

     
    195195        $dir = dirname($plugin_file);
    196196        $plugin_files = array($plugin);
    197197        if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) {
    198                 $plugins_dir = @ opendir( $dir );
    199                 if ( $plugins_dir ) {
    200                         while (($file = readdir( $plugins_dir ) ) !== false ) {
    201                                 if ( substr($file, 0, 1) == '.' )
    202                                         continue;
    203                                 if ( is_dir( $dir . '/' . $file ) ) {
    204                                         $plugins_subdir = @ opendir( $dir . '/' . $file );
    205                                         if ( $plugins_subdir ) {
    206                                                 while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
    207                                                         if ( substr($subfile, 0, 1) == '.' )
    208                                                                 continue;
    209                                                         $plugin_files[] = plugin_basename("$dir/$file/$subfile");
    210                                                 }
    211                                                 @closedir( $plugins_subdir );
    212                                         }
    213                                 } else {
    214                                         if ( plugin_basename("$dir/$file") != $plugin )
    215                                                 $plugin_files[] = plugin_basename("$dir/$file");
    216                                 }
    217                         }
    218                         @closedir( $plugins_dir );
    219                 }
     198        $objects = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::SELF_FIRST );
     199        foreach( $objects as $name => $object ){
     200            if( is_dir( $name ) )
     201                continue;
     202
     203            if ( substr( $name, 0, 1 ) == '.' )
     204                continue;
     205
     206            $plugin_files[] = plugin_basename( $name );
     207        }
    220208        }
    221209
    222210        return $plugin_files;