From efdcdfdf361a9e8b41bc6e2530b9542f14551972 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Fri, 30 Mar 2012 15:13:12 +0000 Subject: [PATCH] Avoid fatal errors in check_theme_switched() if we fail to get a WP_Theme object for the old theme. Fixes #20334. git-svn-id: https://develop.svn.wordpress.org/trunk@20330 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/theme.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 8bfdd74a52..14311b2686 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1555,7 +1555,13 @@ add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); function check_theme_switched() { if ( $stylesheet = get_option( 'theme_switched' ) ) { $old_theme = wp_get_theme( $stylesheet ); - do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme ); + + // If we can't find the old theme then fallback to passing the raw data to the action like we did pre-3.4 + if ( $old_theme ) + do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme ); + else + do_action( 'after_switch_theme', $stylesheet ); + update_option( 'theme_switched', false ); } }