Revert to default theme if active theme is broken.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-09-16 18:09:32 +00:00
parent 3de41a8e3e
commit df9a953c1d
2 changed files with 25 additions and 1 deletions

View File

@ -675,4 +675,26 @@ function get_current_theme() {
return $current_theme;
}
function validate_current_theme() {
$theme_loc = 'wp-content/themes';
$theme_root = ABSPATH . $theme_loc;
$template = get_settings('template');
$stylesheet = get_settings('stylesheet');
if (($template != 'default') && (! file_exists("$theme_root/$template/index.php"))) {
update_option('template', 'default');
update_option('stylesheet', 'default');
return false;
}
if (($stylesheet != 'default') && (! file_exists("$theme_root/$stylesheet/style.css"))) {
update_option('template', 'default');
update_option('stylesheet', 'default');
return false;
}
return true;
}
?>

View File

@ -28,7 +28,9 @@ if ($user_level < 9)
die (__('Sorry, you must be at least a level 9 user to modify themes.'));
?>
<?php if ( isset($activated) ) : ?>
<?php if ( ! validate_current_theme() ) : ?>
<div class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
<?php elseif ( isset($activated) ) : ?>
<div class="updated"><p><?php _e('New theme activated'); ?></p></div>
<?php endif; ?>