| 28 | * Prevent switching to Twenty Thirteen on old versions |
| 29 | * of WordPress. Switches to the previously activated theme |
| 30 | * or the default theme. |
| 31 | */ |
| 32 | function 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 | } |
| 44 | add_action( 'after_switch_theme', 'twentythirteen_switch_theme', 10, 2 ); |
| 45 | |
| 46 | function 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 | /** |