From d8b58a167d9e51af90f03681c0cdd0da14bda4af Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Thu, 28 Mar 2013 06:45:56 +0000 Subject: [PATCH] Twenty Thirteen: better back compat handling by moving version compare before the include to avoid loading the file altogether. Also prevent Customizer views. Props obenland, closes #23819. git-svn-id: https://develop.svn.wordpress.org/trunk@23837 602fd350-edb4-49c9-b593-d223f7449a82 --- .../themes/twentythirteen/functions.php | 3 +- .../themes/twentythirteen/inc/back-compat.php | 44 ++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/wp-content/themes/twentythirteen/functions.php b/wp-content/themes/twentythirteen/functions.php index a2a467a13b..9b191b98b6 100644 --- a/wp-content/themes/twentythirteen/functions.php +++ b/wp-content/themes/twentythirteen/functions.php @@ -596,4 +596,5 @@ require( get_template_directory() . '/inc/custom-header.php' ); /** * Adds back compat handling for WP versions pre-3.6. */ -require( get_template_directory() . '/inc/back-compat.php' ); +if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) ) + require( get_template_directory() . '/inc/back-compat.php' ); diff --git a/wp-content/themes/twentythirteen/inc/back-compat.php b/wp-content/themes/twentythirteen/inc/back-compat.php index 4a324b088e..4cc691109a 100644 --- a/wp-content/themes/twentythirteen/inc/back-compat.php +++ b/wp-content/themes/twentythirteen/inc/back-compat.php @@ -1,12 +1,26 @@ =' ) ) - return; - if ( 'twentythirteen' != $theme->template ) switch_theme( $theme->template, $theme->stylesheet ); elseif ( 'twentythirteen' != WP_DEFAULT_THEME ) @@ -17,7 +31,27 @@ function twentythirteen_switch_theme( $theme_name, $theme ) { } add_action( 'after_switch_theme', 'twentythirteen_switch_theme', 10, 2 ); +/** + * Prints an update nag after an unsuccessful attempt to switch to + * Twenty Thirteen on WordPress versions prior to 3.6. + * + * @since Twenty Thirteen 1.0 + * + * @return void + */ function twentythirteen_upgrade_notice() { - $message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.' ), $GLOBALS['wp_version'] ); + $message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentythirteen' ), $GLOBALS['wp_version'] ); printf( '

%s

', $message ); -} \ No newline at end of file +} + +/** + * Prevents the Customizer from being loaded on WordPress versions prior to 3.6. + * + * @since Twenty Thirteen 1.0 + * + * @return void + */ +function twentythirteen_customize() { + wp_die( sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentythirteen' ), $GLOBALS['wp_version'] ) . sprintf( ' %s', __( 'Go back.', 'twentythirteen' ) ) ); +} +add_action( 'load-customize.php', 'twentythirteen_customize' );