WordPress.org

Make WordPress Core

Ticket #23819: 23819.diff

File 23819.diff, 1.4 KB (added by kovshenin, 9 years ago)
  • wp-content/themes/twentythirteen/functions.php

     
    2525 */
    2626
    2727/**
     28 * Prevent switching to Twenty Thirteen on old versions
     29 * of WordPress. Switches to the previously activated theme
     30 * or the default theme.
     31 */
     32function twentythirteen_switch_theme( $theme_name, $theme ) {
     33        if ( version_compare( $GLOBALS['wp_version'], '3.6', '>=' ) )
     34                return;
     35
     36        if ( 'twentythirteen' != $theme->template )
     37                switch_theme( $theme->template, $theme->stylesheet );
     38        elseif ( 'twentythirteen' != WP_DEFAULT_THEME )
     39                switch_theme( WP_DEFAULT_THEME );
     40
     41        unset( $_GET['activated'] );
     42        add_action( 'admin_notices', 'twentythirteen_upgrade_notice' );
     43}
     44add_action( 'after_switch_theme', 'twentythirteen_switch_theme', 10, 2 );
     45
     46function twentythirteen_upgrade_notice() {
     47        $message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.' ), $GLOBALS['wp_version'] );
     48        printf( '<div class="error"><p>%s</p></div>', esc_html( $message ) );
     49}
     50
     51/**
    2852 * Sets up the content width value based on the theme's design.
    2953 * @see twentythirteen_content_width() for template-specific adjustments.
    3054 */