WordPress.org

Make WordPress Core

Changeset 24411


Ignore:
Timestamp:
06/06/2013 12:22:09 AM (5 years ago)
Author:
lancewillett
Message:

Twenty Thirteen: improve backward compatibility escape hatch for pre-3.6 versions:

  • Switch to the built-in method of providing a back link in wp_die() for the Customizer
  • Use WP_DEFAULT_THEME for both arguments during theme switching to simplify the logic
  • Prevent the 3.3 and earlier theme preview action gracefully

Props obenland for patches, fixes #24441.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentythirteen/inc/back-compat.php

    r24307 r24411  
    1414/**
    1515 * Prevent switching to Twenty Thirteen on old versions of WordPress. Switches
    16  * to the previously activated theme or the default theme.
     16 * to the default theme.
    1717 *
    1818 * @since Twenty Thirteen 1.0
    1919 *
    20  * @param string $theme_name The theme name.
    21  * @param WP_Theme $theme The theme object.
    2220 * @return void
    2321 */
    24 function twentythirteen_switch_theme( $theme_name, $theme ) {
    25     if ( 'twentythirteen' != $theme->get_template() )
    26         switch_theme( $theme->get_template(), $theme->get_stylesheet() );
    27     elseif ( 'twentythirteen' != WP_DEFAULT_THEME )
    28         switch_theme( WP_DEFAULT_THEME );
    29 
     22function twentythirteen_switch_theme() {
     23    switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
    3024    unset( $_GET['activated'] );
    3125    add_action( 'admin_notices', 'twentythirteen_upgrade_notice' );
    3226}
    33 add_action( 'after_switch_theme', 'twentythirteen_switch_theme', 10, 2 );
     27add_action( 'after_switch_theme', 'twentythirteen_switch_theme' );
    3428
    3529/**
     
    5448 */
    5549function twentythirteen_customize() {
    56     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' ) ) );
     50    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'] ), '', array(
     51        'back_link' => true,
     52    ) );
    5753}
    5854add_action( 'load-customize.php', 'twentythirteen_customize' );
     55
     56/**
     57 * Prevents the Theme Preview from being loaded on WordPress versions prior to 3.4.
     58 *
     59 * @since Twenty Thirteen 1.0
     60 *
     61 * @return void
     62 */
     63function twentythirteen_preview() {
     64    if ( isset( $_GET['preview'] ) ) {
     65        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'] ) );
     66    }
     67}
     68add_action( 'template_redirect', 'twentythirteen_preview' );
Note: See TracChangeset for help on using the changeset viewer.