348 | | $stylesheet_dir = @ dir("$theme_root/$stylesheet"); |
349 | | if ( $stylesheet_dir ) { |
350 | | while ( ($file = $stylesheet_dir->read()) !== false ) { |
351 | | if ( !preg_match('|^\.+$|', $file) ) { |
352 | | if ( preg_match('|\.css$|', $file) ) |
353 | | $stylesheet_files[] = "$theme_root/$stylesheet/$file"; |
354 | | elseif ( preg_match('|\.php$|', $file) ) |
355 | | $template_files[] = "$theme_root/$stylesheet/$file"; |
356 | | } |
357 | | } |
358 | | @ $stylesheet_dir->close(); |
359 | | } |
360 | | |
361 | | $template_dir = @ dir("$template_directory"); |
362 | | if ( $template_dir ) { |
363 | | while ( ($file = $template_dir->read()) !== false ) { |
364 | | if ( preg_match('|^\.+$|', $file) ) |
365 | | continue; |
366 | | if ( preg_match('|\.php$|', $file) ) { |
367 | | $template_files[] = "$template_directory/$file"; |
368 | | } elseif ( is_dir("$template_directory/$file") ) { |
369 | | $template_subdir = @ dir("$template_directory/$file"); |
370 | | if ( !$template_subdir ) |
371 | | continue; |
372 | | while ( ($subfile = $template_subdir->read()) !== false ) { |
373 | | if ( preg_match('|^\.+$|', $subfile) ) |
374 | | continue; |
375 | | if ( preg_match('|\.php$|', $subfile) ) |
376 | | $template_files[] = "$template_directory/$file/$subfile"; |
377 | | } |
378 | | @ $template_subdir->close(); |
379 | | } |
380 | | } |
381 | | @ $template_dir->close(); |
382 | | } |
383 | | |
384 | | //Make unique and remove duplicates when stylesheet and template are the same i.e. most themes |
| 351 | // Make unique and remove duplicates when stylesheet and template are the same (i.e. most themes) |
| 435 | * Recursively loop through a theme's subdirectories and add PHP files to an array |
| 436 | * |
| 437 | * @since ... |
| 438 | * |
| 439 | * @param string $dir The current directory to loop through |
| 440 | * @param string $match The regular expression to match for file type(s) |
| 441 | * @param array $ignore A list of files/directories to ignore |
| 442 | * @return array Paths of all theme PHP files. |
| 443 | */ |
| 444 | function _get_theme_files( $dir, $match = '|\.php$|', $ignore = array( '.', '..', '.svn', '.git' ) ) { |
| 445 | |
| 446 | $the_files = array(); |
| 447 | |
| 448 | $the_subdir = @ opendir("$dir"); |
| 449 | while ( false !== ( $the_file = readdir( $the_subdir ) ) ) { |
| 450 | // Skip the ignored files |
| 451 | if ( !in_array( $the_file, $ignore ) ) { |
| 452 | // If we're looking at a directory, loop back for a second pass, otherwise handle the file |
| 453 | if ( is_dir( "$dir/$the_file" ) ) { |
| 454 | $inner_files = _get_theme_files( "$dir/$the_file", $match ); |
| 455 | if ( is_array($inner_files) ) $the_files = array_merge( $the_files, $inner_files ); |
| 456 | } else { |
| 457 | // if it's a matching file type, add it to the list, otherwise skip it |
| 458 | if ( preg_match( $match, $the_file) ) |
| 459 | $the_files[] = "$dir/$the_file"; |
| 460 | else |
| 461 | continue; |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | @ closedir($the_subdir); |
| 466 | |
| 467 | return $the_files; |
| 468 | } |
| 469 | |
| 470 | /** |