author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:30:03 +0200 | |
changeset 10 | 372f2766ea20 |
parent 7 | cf61fcea0001 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Twenty Thirteen back compat functionality |
|
4 |
* |
|
5 |
* Prevents Twenty Thirteen from running on WordPress versions prior to 3.6, |
|
6 |
* since this theme is not meant to be backward compatible and relies on |
|
7 |
* many new functions and markup changes introduced in 3.6. |
|
8 |
* |
|
9 |
* @package WordPress |
|
10 |
* @subpackage Twenty_Thirteen |
|
11 |
* @since Twenty Thirteen 1.0 |
|
12 |
*/ |
|
13 |
||
14 |
/** |
|
15 |
* Prevent switching to Twenty Thirteen on old versions of WordPress. |
|
16 |
* |
|
17 |
* Switches to the default theme. |
|
18 |
* |
|
19 |
* @since Twenty Thirteen 1.0 |
|
20 |
*/ |
|
21 |
function twentythirteen_switch_theme() { |
|
22 |
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME ); |
|
23 |
unset( $_GET['activated'] ); |
|
24 |
add_action( 'admin_notices', 'twentythirteen_upgrade_notice' ); |
|
25 |
} |
|
26 |
add_action( 'after_switch_theme', 'twentythirteen_switch_theme' ); |
|
27 |
||
28 |
/** |
|
29 |
* Add message for unsuccessful theme switch. |
|
30 |
* |
|
31 |
* Prints an update nag after an unsuccessful attempt to switch to |
|
32 |
* Twenty Thirteen on WordPress versions prior to 3.6. |
|
33 |
* |
|
34 |
* @since Twenty Thirteen 1.0 |
|
35 |
*/ |
|
36 |
function twentythirteen_upgrade_notice() { |
|
37 |
$message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentythirteen' ), $GLOBALS['wp_version'] ); |
|
38 |
printf( '<div class="error"><p>%s</p></div>', $message ); |
|
39 |
} |
|
40 |
||
41 |
/** |
|
5 | 42 |
* Prevent the Customizer from being loaded on WordPress versions prior to 3.6. |
0 | 43 |
* |
44 |
* @since Twenty Thirteen 1.0 |
|
45 |
*/ |
|
46 |
function twentythirteen_customize() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
wp_die( |
10 | 48 |
sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentythirteen' ), $GLOBALS['wp_version'] ), |
49 |
'', |
|
50 |
array( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
'back_link' => true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
); |
0 | 54 |
} |
55 |
add_action( 'load-customize.php', 'twentythirteen_customize' ); |
|
56 |
||
57 |
/** |
|
58 |
* Prevent the Theme Preview from being loaded on WordPress versions prior to 3.4. |
|
59 |
* |
|
60 |
* @since Twenty Thirteen 1.0 |
|
61 |
*/ |
|
62 |
function twentythirteen_preview() { |
|
63 |
if ( isset( $_GET['preview'] ) ) { |
|
64 |
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'] ) ); |
|
65 |
} |
|
66 |
} |
|
67 |
add_action( 'template_redirect', 'twentythirteen_preview' ); |