List broken themes and suggest corrective action.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1829 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-10-24 23:48:51 +00:00
parent 184628f5dc
commit 7cbf843347
3 changed files with 62 additions and 5 deletions

View File

@ -572,6 +572,13 @@ function validate_current_theme() {
return true;
}
function get_broken_themes() {
global $wp_broken_themes;
get_themes();
return $wp_broken_themes;
}
function get_page_templates() {
$themes = get_themes();
$theme = get_current_theme();

View File

@ -99,6 +99,44 @@ $current_stylesheet = $themes[$current_theme]['Stylesheet'];
<?php
}
?>
<?php
// List broken themes, if any.
$broken_themes = get_broken_themes();
if (count($broken_themes)) {
?>
<h2><?php _e('Broken Themes'); ?></h2>
<p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
<table width="100%" cellpadding="3" cellspacing="3">
<tr>
<th><?php _e('Name'); ?></th>
<th><?php _e('Description'); ?></th>
</tr>
<?php
$theme = '';
$theme_names = array_keys($broken_themes);
natcasesort($theme_names);
foreach ($theme_names as $theme_name) {
$title = $broken_themes[$theme_name]['Title'];
$description = $broken_themes[$theme_name]['Description'];
$theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
echo "
<tr $theme>
<td>$title</td>
<td>$description</td>
</tr>";
}
?>
</table>
<?php
}
?>
</div>
<?php

View File

@ -1993,12 +1993,14 @@ function get_theme_data($theme_file) {
function get_themes() {
global $wp_themes;
global $wp_broken_themes;
if (isset($wp_themes)) {
return $wp_themes;
}
$themes = array();
$wp_broken_themes = array();
$theme_loc = 'wp-content/themes';
$theme_root = ABSPATH . $theme_loc;
@ -2007,12 +2009,21 @@ function get_themes() {
if ($themes_dir) {
while(($theme_dir = $themes_dir->read()) !== false) {
if (is_dir($theme_root . '/' . $theme_dir)) {
if ($theme_dir == '.' || $theme_dir == '..') {
continue;
}
$stylish_dir = @ dir($theme_root . '/' . $theme_dir);
$found_stylesheet = false;
while(($theme_file = $stylish_dir->read()) !== false) {
if ( $theme_file == 'style.css' ) {
$theme_files[] = $theme_dir . '/' . $theme_file;
$found_stylesheet = true;
break;
}
}
if (!$found_stylesheet) {
$wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
}
}
}
}
@ -2062,6 +2073,11 @@ function get_themes() {
$template = $theme_data['Template'];
$stylesheet = dirname($theme_file);
if (empty($name)) {
$name = dirname($theme_file);
$title = $name;
}
if (empty($template)) {
if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
$template = dirname($theme_file);
@ -2073,13 +2089,9 @@ function get_themes() {
$template = trim($template);
if (($template != 'default') && (! file_exists("$theme_root/$template/index.php"))) {
$wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
continue;
}
if (empty($name)) {
$name = dirname($theme_file);
$title = $name;
}
$stylesheet_files = array();
if ($stylesheet != 'default') {