Ticket #6531: 24050.2.diff
File 24050.2.diff, 2.4 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/plugin.php
179 179 * @param string $plugin Plugin ID 180 180 * @return array List of files relative to the plugin root. 181 181 */ 182 function get_plugin_files( $plugin) {182 function get_plugin_files( $plugin ) { 183 183 $plugin_file = WP_PLUGIN_DIR . '/' . $plugin; 184 $dir = dirname($plugin_file);185 $plugin_files = array( $plugin);186 if ( is_dir( $dir) && $dir != WP_PLUGIN_DIR ) {184 $dir = WP_PLUGIN_DIR . '/' . current( explode( '/', $plugin, 2 ) ); 185 $plugin_files = array( $plugin ); 186 if ( is_dir( $dir ) && $dir != WP_PLUGIN_DIR ) { 187 187 $plugins_dir = @ opendir( $dir ); 188 188 if ( $plugins_dir ) { 189 while ( ($file = readdir( $plugins_dir ) ) !== false ) {190 if ( substr( $file, 0, 1) == '.' )189 while ( ( $file = readdir( $plugins_dir ) ) !== false ) { 190 if ( substr( $file, 0, 1 ) == '.' ) 191 191 continue; 192 192 if ( is_dir( $dir . '/' . $file ) ) { 193 $plugins_subdir = @ opendir( $dir . '/' . $file ); 194 if ( $plugins_subdir ) { 195 while (($subfile = readdir( $plugins_subdir ) ) !== false ) { 196 if ( substr($subfile, 0, 1) == '.' ) 197 continue; 198 $plugin_files[] = plugin_basename("$dir/$file/$subfile"); 199 } 200 @closedir( $plugins_subdir ); 201 } 193 $subfiles = get_plugin_sub_files( $dir . '/' . $file ); 194 $plugin_files = array_merge( $plugin_files, $subfiles ); 202 195 } else { 203 if ( plugin_basename( "$dir/$file") != $plugin )204 $plugin_files[] = plugin_basename( "$dir/$file");196 if ( plugin_basename( "$dir/$file" ) != $plugin ) 197 $plugin_files[] = plugin_basename( "$dir/$file" ); 205 198 } 206 199 } 207 @ closedir( $plugins_dir );200 @ closedir( $plugins_dir ); 208 201 } 209 202 } 203 return $plugin_files; 204 } 210 205 206 function get_plugin_sub_files( $subdir ) { 207 $plugins_subdir = @ opendir( $subdir ); 208 if ( $plugins_subdir ) { 209 $plugin_files = array(); 210 while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) { 211 if ( substr( $subfile, 0, 1 ) == '.' ) 212 continue; 213 if ( is_dir( $subdir . '/' . $subfile ) ) { 214 $subfiles = get_plugin_sub_files( $subdir . '/' . $subfile ); 215 $plugin_files = array_merge( $plugin_files, $subfiles ); 216 } else { 217 $plugin_files[] = plugin_basename( "$subdir/$subfile" ); 218 } 219 } 220 @ closedir( $plugins_subdir ); 221 } 211 222 return $plugin_files; 212 223 } 213 224