diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 8322d1b556..7d9fa3925c 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -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; diff --git a/wp-includes/theme.php b/wp-includes/theme.php index e29b02175b..7abf80930e 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -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; +} + ?> diff --git a/wp-settings.php b/wp-settings.php index 584bfa4c67..f0b1d44469 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -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.