Code cleanup: wp-includes/theme.php

git-svn-id: https://develop.svn.wordpress.org/trunk@4392 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2006-10-13 10:33:44 +00:00
parent ef830b334c
commit 852e96e733
1 changed files with 29 additions and 34 deletions

View File

@ -88,8 +88,7 @@ function get_theme_data($theme_file) {
}
function get_themes() {
global $wp_themes;
global $wp_broken_themes;
global $wp_themes, $wp_broken_themes;
if ( isset($wp_themes) )
return $wp_themes;
@ -104,9 +103,8 @@ function get_themes() {
if ( $themes_dir ) {
while ( ($theme_dir = $themes_dir->read()) !== false ) {
if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
continue;
}
$stylish_dir = @ dir($theme_root . '/' . $theme_dir);
$found_stylesheet = false;
while ( ($theme_file = $stylish_dir->read()) !== false ) {
@ -116,20 +114,18 @@ function get_themes() {
break;
}
}
if ( !$found_stylesheet ) {
if ( !$found_stylesheet )
$wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
}
}
}
}
if ( !$themes_dir || !$theme_files ) {
if ( !$themes_dir || !$theme_files )
return $themes;
}
sort($theme_files);
foreach($theme_files as $theme_file) {
foreach ( (array) $theme_files as $theme_file ) {
if ( !is_readable("$theme_root/$theme_file") ) {
$wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
continue;
@ -158,12 +154,11 @@ function get_themes() {
}
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);
} else {
else
continue;
}
}
$template = trim($template);
@ -222,10 +217,10 @@ function get_themes() {
// Resolve theme dependencies.
$theme_names = array_keys($themes);
foreach ($theme_names as $theme_name) {
foreach ( (array) $theme_names as $theme_name ) {
$themes[$theme_name]['Parent Theme'] = '';
if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
foreach ($theme_names as $parent_theme_name) {
foreach ( (array) $theme_names as $parent_theme_name ) {
if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
$themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
break;
@ -256,7 +251,7 @@ function get_current_theme() {
$current_theme = 'WordPress Default';
if ( $themes ) {
foreach ($theme_names as $theme_name) {
foreach ( (array) $theme_names as $theme_name ) {
if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
$themes[$theme_name]['Template'] == $current_template ) {
$current_theme = $themes[$theme_name]['Name'];
@ -395,14 +390,14 @@ function validate_current_theme() {
if ( defined('WP_INSTALLING') )
return true;
if ((get_template() != 'default') && (!file_exists(get_template_directory() . '/index.php'))) {
if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
return false;
}
if ((get_stylesheet() != 'default') && (!file_exists(get_template_directory() . '/style.css'))) {
if ( get_stylesheet() != 'default' && !file_exists(get_template_directory() . '/style.css') ) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');