Tweak theme validation.

git-svn-id: http://svn.automattic.com/wordpress/trunk@4017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-07-11 22:44:56 +00:00
parent 3761db170b
commit 978fc182da
3 changed files with 19 additions and 29 deletions

View File

@ -1254,30 +1254,6 @@ function edInsertContent(myField, myValue) {
';
}
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');
do_action('switch_theme', 'Default');
return false;
}
if (($stylesheet != 'default') && (!file_exists("$theme_root/$stylesheet/style.css"))) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
return false;
}
return true;
}
function get_broken_themes() {
global $wp_broken_themes;

View File

@ -26,11 +26,6 @@ function get_stylesheet_uri() {
}
function get_template() {
$template = get_settings('template');
if (!file_exists(get_theme_root() . "/$template")) { //works for dirs too
update_option('template', 'default');
update_option('stylesheet', 'default');
}
return apply_filters('template', get_settings('template'));
}
@ -374,4 +369,22 @@ function load_template($file) {
require_once($file);
}
function validate_current_theme() {
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'))) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
return false;
}
return true;
}
?>

View File

@ -200,6 +200,7 @@ $wp_query = new WP_Query();
$wp_rewrite = new WP_Rewrite();
$wp = new WP();
validate_current_theme();
define('TEMPLATEPATH', get_template_directory());
// Load the default text localization domain.