| 597 | | |
| 598 | | while ( ($theme_dir = readdir($themes_dir)) !== false ) { |
| 599 | | if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { |
| 600 | | if ( $theme_dir[0] == '.' || $theme_dir == 'CVS' ) |
| 601 | | continue; |
| 602 | | |
| 603 | | $stylish_dir = @opendir($theme_root . '/' . $theme_dir); |
| 604 | | $found_stylesheet = false; |
| 605 | | |
| 606 | | while ( ($theme_file = readdir($stylish_dir)) !== false ) { |
| 607 | | if ( $theme_file == 'style.css' ) { |
| 608 | | $theme_files[$theme_dir] = array( 'theme_file' => $theme_dir . '/' . $theme_file, 'theme_root' => $theme_root ); |
| 609 | | $found_stylesheet = true; |
| 610 | | break; |
| 611 | | } |
| | 595 | foreach ( $dirs as $dir ) { |
| | 596 | if ( is_dir( $theme_root . '/' . $dir ) && ( $dir[0] == '.' || $dir == 'CVS' ) ) |
| | 597 | continue; |
| | 598 | if ( file_exists( $theme_root . '/' . $dir . '/style.css' ) ) { |
| | 599 | // wp-content/themes/a-single-theme |
| | 600 | // wp-content/themes is $theme_root, a-single-theme is $dir |
| | 601 | $found_themes[ $dir ] = array( |
| | 602 | 'theme_file' => $dir . '/style.css', |
| | 603 | 'theme_root' => $theme_root, |
| | 604 | ); |
| | 605 | } else { |
| | 606 | $found_theme = false; |
| | 607 | // wp-content/themes/a-folder-of-themes/* |
| | 608 | // wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs |
| | 609 | $sub_dirs = @ scandir( $theme_root . '/' . $dir ); |
| | 610 | if ( ! $sub_dirs ) |
| | 611 | false; |
| | 612 | foreach ( $sub_dirs as $sub_dir ) { |
| | 613 | if ( is_dir( $theme_root . '/' . $dir . '/' . $sub_dir ) && ( $sub_dir[0] == '.' || $sub_dir == 'CVS' ) ) |
| | 614 | continue; |
| | 615 | if ( ! file_exists( $theme_root . '/' . $dir . '/' . $sub_dir . '/style.css' ) ) |
| | 616 | continue; |
| | 617 | $found_themes[ $dir . '/' . $sub_dir ] = array( |
| | 618 | 'theme_file' => $dir . '/' . $sub_dir . '/style.css', |
| | 619 | 'theme_root' => $theme_root, |
| | 620 | ); |
| | 621 | $found_theme = true; |
| 613 | | @closedir($stylish_dir); |
| 614 | | |
| 615 | | if ( !$found_stylesheet ) { // look for themes in that dir |
| 616 | | $subdir = "$theme_root/$theme_dir"; |
| 617 | | $subdir_name = $theme_dir; |
| 618 | | $theme_subdirs = @opendir( $subdir ); |
| 619 | | |
| 620 | | $found_subdir_themes = false; |
| 621 | | while ( ($theme_subdir = readdir($theme_subdirs)) !== false ) { |
| 622 | | if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) { |
| 623 | | if ( $theme_subdir[0] == '.' || $theme_subdir == 'CVS' ) |
| 624 | | continue; |
| 625 | | |
| 626 | | $stylish_dir = @opendir($subdir . '/' . $theme_subdir); |
| 627 | | $found_stylesheet = false; |
| 628 | | |
| 629 | | while ( ($theme_file = readdir($stylish_dir)) !== false ) { |
| 630 | | if ( $theme_file == 'style.css' ) { |
| 631 | | $theme_files["$theme_dir/$theme_subdir"] = array( 'theme_file' => $subdir_name . '/' . $theme_subdir . '/' . $theme_file, 'theme_root' => $theme_root ); |
| 632 | | $found_stylesheet = true; |
| 633 | | $found_subdir_themes = true; |
| 634 | | break; |
| 635 | | } |
| 636 | | } |
| 637 | | @closedir($stylish_dir); |
| 638 | | } |
| 639 | | } |
| 640 | | @closedir($theme_subdirs); |
| 641 | | if ( !$found_subdir_themes ) |
| 642 | | $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); |
| | 623 | // Never mind the above, it's just a theme missing a style.css. |
| | 624 | if ( ! $found_theme ) { |
| | 625 | $wp_broken_themes[ $dir ] = array( |
| | 626 | 'Name' => $dir, |
| | 627 | 'Title' => $dir, |
| | 628 | 'Description' => __( 'Stylesheet is missing.' ), |
| | 629 | ); |