List broken themes and suggest corrective action.
git-svn-id: https://develop.svn.wordpress.org/trunk@1829 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4b81c51c9b
commit
d3f7d9e4c8
@ -572,6 +572,13 @@ function validate_current_theme() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_broken_themes() {
|
||||||
|
global $wp_broken_themes;
|
||||||
|
|
||||||
|
get_themes();
|
||||||
|
return $wp_broken_themes;
|
||||||
|
}
|
||||||
|
|
||||||
function get_page_templates() {
|
function get_page_templates() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
$theme = get_current_theme();
|
$theme = get_current_theme();
|
||||||
|
@ -99,6 +99,44 @@ $current_stylesheet = $themes[$current_theme]['Stylesheet'];
|
|||||||
<?php
|
<?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>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -1993,12 +1993,14 @@ function get_theme_data($theme_file) {
|
|||||||
|
|
||||||
function get_themes() {
|
function get_themes() {
|
||||||
global $wp_themes;
|
global $wp_themes;
|
||||||
|
global $wp_broken_themes;
|
||||||
|
|
||||||
if (isset($wp_themes)) {
|
if (isset($wp_themes)) {
|
||||||
return $wp_themes;
|
return $wp_themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
$themes = array();
|
$themes = array();
|
||||||
|
$wp_broken_themes = array();
|
||||||
$theme_loc = 'wp-content/themes';
|
$theme_loc = 'wp-content/themes';
|
||||||
$theme_root = ABSPATH . $theme_loc;
|
$theme_root = ABSPATH . $theme_loc;
|
||||||
|
|
||||||
@ -2007,12 +2009,21 @@ function get_themes() {
|
|||||||
if ($themes_dir) {
|
if ($themes_dir) {
|
||||||
while(($theme_dir = $themes_dir->read()) !== false) {
|
while(($theme_dir = $themes_dir->read()) !== false) {
|
||||||
if (is_dir($theme_root . '/' . $theme_dir)) {
|
if (is_dir($theme_root . '/' . $theme_dir)) {
|
||||||
|
if ($theme_dir == '.' || $theme_dir == '..') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$stylish_dir = @ dir($theme_root . '/' . $theme_dir);
|
$stylish_dir = @ dir($theme_root . '/' . $theme_dir);
|
||||||
|
$found_stylesheet = false;
|
||||||
while(($theme_file = $stylish_dir->read()) !== false) {
|
while(($theme_file = $stylish_dir->read()) !== false) {
|
||||||
if ( $theme_file == 'style.css' ) {
|
if ( $theme_file == 'style.css' ) {
|
||||||
$theme_files[] = $theme_dir . '/' . $theme_file;
|
$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'];
|
$template = $theme_data['Template'];
|
||||||
$stylesheet = dirname($theme_file);
|
$stylesheet = dirname($theme_file);
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$name = dirname($theme_file);
|
||||||
|
$title = $name;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($template)) {
|
if (empty($template)) {
|
||||||
if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
|
if (file_exists(dirname("$theme_root/$theme_file/index.php"))) {
|
||||||
$template = dirname($theme_file);
|
$template = dirname($theme_file);
|
||||||
@ -2073,14 +2089,10 @@ function get_themes() {
|
|||||||
$template = trim($template);
|
$template = trim($template);
|
||||||
|
|
||||||
if (($template != 'default') && (! file_exists("$theme_root/$template/index.php"))) {
|
if (($template != 'default') && (! file_exists("$theme_root/$template/index.php"))) {
|
||||||
|
$wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($name)) {
|
|
||||||
$name = dirname($theme_file);
|
|
||||||
$title = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stylesheet_files = array();
|
$stylesheet_files = array();
|
||||||
if ($stylesheet != 'default') {
|
if ($stylesheet != 'default') {
|
||||||
$stylesheet_dir = @ dir("$theme_root/$stylesheet");
|
$stylesheet_dir = @ dir("$theme_root/$stylesheet");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user