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: http://core.svn.wordpress.org/trunk@23837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
816618be68
commit
b78b4965e2
|
@ -596,4 +596,5 @@ require( get_template_directory() . '/inc/custom-header.php' );
|
||||||
/**
|
/**
|
||||||
* Adds back compat handling for WP versions pre-3.6.
|
* 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' );
|
||||||
|
|
|
@ -1,12 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Prevents Twenty Thirteen from running on WordPress versions prior to 3.6.
|
||||||
|
*
|
||||||
|
* Twenty Thirteen is not meant to be backwards compatible, since it relies on
|
||||||
|
* a lot of new functions and markup changes that were introduced in 3.6.
|
||||||
|
*
|
||||||
|
* @package WordPress
|
||||||
|
* @subpackage Twenty_Thirteen
|
||||||
|
* @since Twenty Thirteen 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevent switching to Twenty Thirteen on old versions of WordPress. Switches
|
* Prevent switching to Twenty Thirteen on old versions of WordPress. Switches
|
||||||
* to the previously activated theme or the default theme.
|
* to the previously activated theme or the default theme.
|
||||||
|
*
|
||||||
|
* @since Twenty Thirteen 1.0
|
||||||
|
*
|
||||||
|
* @param string $theme_name
|
||||||
|
* @param WP_Theme $theme
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function twentythirteen_switch_theme( $theme_name, $theme ) {
|
function twentythirteen_switch_theme( $theme_name, $theme ) {
|
||||||
if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '>=' ) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( 'twentythirteen' != $theme->template )
|
if ( 'twentythirteen' != $theme->template )
|
||||||
switch_theme( $theme->template, $theme->stylesheet );
|
switch_theme( $theme->template, $theme->stylesheet );
|
||||||
elseif ( 'twentythirteen' != WP_DEFAULT_THEME )
|
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 );
|
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() {
|
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( '<div class="error"><p>%s</p></div>', $message );
|
printf( '<div class="error"><p>%s</p></div>', $message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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( ' <a href="javascript:history.go(-1);">%s</a>', __( 'Go back.', 'twentythirteen' ) ) );
|
||||||
|
}
|
||||||
|
add_action( 'load-customize.php', 'twentythirteen_customize' );
|
||||||
|
|
Loading…
Reference in New Issue