From 6bbc8d4ce433f95b39c889f64327b84fd3496cf4 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 11 Nov 2011 14:10:54 +0000 Subject: [PATCH] Avoid notice when themes dir is empty or missing. Don't reset current theme in current_theme_info() if there are no themes. Show warning in Right Now if there are no themes. Props azaozz. fixes #19089 git-svn-id: http://svn.automattic.com/wordpress/trunk@19251 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/dashboard.php | 6 +++++- wp-admin/includes/theme.php | 8 ++++++++ wp-includes/theme.php | 9 +++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 889d34299..66eb555c0 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -387,7 +387,11 @@ function wp_dashboard_right_now() { $ct = current_theme_info(); echo "\n\t

"; - if ( !empty($wp_registered_sidebars) ) { + + if ( empty( $ct->stylesheet_dir ) ) { + if ( ! is_multisite() || is_super_admin() ) + echo '' . __('ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.') . ''; + } elseif ( ! empty($wp_registered_sidebars) ) { $sidebars_widgets = wp_get_sidebars_widgets(); $num_widgets = 0; foreach ( (array) $sidebars_widgets as $k => $v ) { diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index f645d4408..7cb5dc4a3 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -16,10 +16,18 @@ function current_theme_info() { $themes = get_themes(); $current_theme = get_current_theme(); + + if ( ! $themes ) { + $ct = new stdClass; + $ct->name = $current_theme; + return $ct; + } + if ( ! isset( $themes[$current_theme] ) ) { delete_option( 'current_theme' ); $current_theme = get_current_theme(); } + $ct = new stdClass; $ct->name = $current_theme; $ct->title = $themes[$current_theme]['Title']; diff --git a/wp-includes/theme.php b/wp-includes/theme.php index bca713427..c76414ac2 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -518,12 +518,13 @@ function get_current_theme() { return $theme; $themes = get_themes(); - $theme_names = array_keys($themes); - $current_template = get_option('template'); - $current_stylesheet = get_option('stylesheet'); - $current_theme = 'Twenty Ten'; + $current_theme = 'Twenty Eleven'; if ( $themes ) { + $theme_names = array_keys( $themes ); + $current_template = get_option( 'template' ); + $current_stylesheet = get_option( 'stylesheet' ); + foreach ( (array) $theme_names as $theme_name ) { if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && $themes[$theme_name]['Template'] == $current_template ) {