1 <?php |
|
2 /** |
|
3 * Twenty Seventeen back compat functionality |
|
4 * |
|
5 * Prevents Twenty Seventeen from running on WordPress versions prior to 4.7, |
|
6 * since this theme is not meant to be backward compatible beyond that and |
|
7 * relies on many newer functions and markup changes introduced in 4.7. |
|
8 * |
|
9 * @package WordPress |
|
10 * @subpackage Twenty_Seventeen |
|
11 * @since Twenty Seventeen 1.0 |
|
12 */ |
|
13 |
|
14 /** |
|
15 * Prevent switching to Twenty Seventeen on old versions of WordPress. |
|
16 * |
|
17 * Switches to the default theme. |
|
18 * |
|
19 * @since Twenty Seventeen 1.0 |
|
20 */ |
|
21 function twentyseventeen_switch_theme() { |
|
22 switch_theme( WP_DEFAULT_THEME ); |
|
23 unset( $_GET['activated'] ); |
|
24 add_action( 'admin_notices', 'twentyseventeen_upgrade_notice' ); |
|
25 } |
|
26 add_action( 'after_switch_theme', 'twentyseventeen_switch_theme' ); |
|
27 |
|
28 /** |
|
29 * Adds a message for unsuccessful theme switch. |
|
30 * |
|
31 * Prints an update nag after an unsuccessful attempt to switch to |
|
32 * Twenty Seventeen on WordPress versions prior to 4.7. |
|
33 * |
|
34 * @since Twenty Seventeen 1.0 |
|
35 * |
|
36 * @global string $wp_version WordPress version. |
|
37 */ |
|
38 function twentyseventeen_upgrade_notice() { |
|
39 $message = sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ); |
|
40 printf( '<div class="error"><p>%s</p></div>', $message ); |
|
41 } |
|
42 |
|
43 /** |
|
44 * Prevents the Customizer from being loaded on WordPress versions prior to 4.7. |
|
45 * |
|
46 * @since Twenty Seventeen 1.0 |
|
47 * |
|
48 * @global string $wp_version WordPress version. |
|
49 */ |
|
50 function twentyseventeen_customize() { |
|
51 wp_die( sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ), '', array( |
|
52 'back_link' => true, |
|
53 ) ); |
|
54 } |
|
55 add_action( 'load-customize.php', 'twentyseventeen_customize' ); |
|
56 |
|
57 /** |
|
58 * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7. |
|
59 * |
|
60 * @since Twenty Seventeen 1.0 |
|
61 * |
|
62 * @global string $wp_version WordPress version. |
|
63 */ |
|
64 function twentyseventeen_preview() { |
|
65 if ( isset( $_GET['preview'] ) ) { |
|
66 wp_die( sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ) ); |
|
67 } |
|
68 } |
|
69 add_action( 'template_redirect', 'twentyseventeen_preview' ); |
|