| 1 | <?php |
| 2 | /** |
| 3 | * Prevent switching to Twenty Thirteen on old versions of WordPress. Switches |
| 4 | * to the previously activated theme or the default theme. |
| 5 | */ |
| 6 | function twentythirteen_switch_theme( $theme_name, $theme ) { |
| 7 | if ( version_compare( $GLOBALS['wp_version'], '3.6', '>=' ) ) |
| 8 | return; |
| 9 | |
| 10 | if ( 'twentythirteen' != $theme->template ) |
| 11 | switch_theme( $theme->template, $theme->stylesheet ); |
| 12 | elseif ( 'twentythirteen' != WP_DEFAULT_THEME ) |
| 13 | switch_theme( WP_DEFAULT_THEME ); |
| 14 | |
| 15 | unset( $_GET['activated'] ); |
| 16 | add_action( 'admin_notices', 'twentythirteen_upgrade_notice' ); |
| 17 | } |
| 18 | add_action( 'after_switch_theme', 'twentythirteen_switch_theme', 10, 2 ); |
| 19 | |
| 20 | function twentythirteen_upgrade_notice() { |
| 21 | $message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.' ), $GLOBALS['wp_version'] ); |
| 22 | printf( '<div class="error"><p>%s</p></div>', $message ); |
| 23 | } |
| 24 | No newline at end of file |