-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
55 lines (45 loc) · 1.32 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* IMPORTANT: Keep code in this file compatible with PHP 5.2
*/
define('MY_THEME_MIN_PHP', '7.0');
define('MY_THEME_MIN_WP', '5.3');
if (version_compare(PHP_VERSION, MY_THEME_MIN_PHP, '<') ||
version_compare(get_bloginfo('version'), MY_THEME_MIN_WP, '<')
) {
add_action('admin_notices', 'printMyThemeNotice');
deactivateMyTheme();
} else {
require __DIR__.'/vendor/autoload.php';
add_action('after_setup_theme', 'runMyTheme', 2);
}
function runMyTheme()
{
MyTheme()->run();
}
function printMyThemeNotice()
{
echo '<div class="notice notice-error">
<p>'.
sprintf(
esc_html__(
'%1$s theme has been deactivated as it requires PHP >= %2$s and WordPress >= %3$s',
'jentil-theme'
),
'<code>jentil-theme</code>',
'<strong>'.MY_THEME_MIN_PHP.'</strong>',
'<strong>'.MY_THEME_MIN_WP.'</strong>'
).
'</p>
</div>';
}
function deactivateMyTheme()
{
$themes = wp_get_themes(['allowed' => true]);
unset($themes['jentil-theme'], $themes['jentil']);
$theme = reset($themes);
$name = null === key($themes) ? '' : $theme->get_stylesheet();
$parent = $name ? $theme->get_template() : '';
update_option('stylesheet', $name);
update_option('template', $parent);
}