-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions.php
55 lines (46 loc) · 1.3 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('JENTIL_MIN_PHP', '7.0');
define('JENTIL_MIN_WP', '5.3');
if (version_compare(PHP_VERSION, JENTIL_MIN_PHP, '<') ||
version_compare(get_bloginfo('version'), JENTIL_MIN_WP, '<')
) {
add_action('admin_notices', 'printJentilNotice');
deactivateJentil();
} else {
add_action('after_setup_theme', 'runJentil', 0);
}
function runJentil()
{
$file = __DIR__.'/vendor/autoload.php';
file_exists($file) && require $file;
Jentil()->run();
}
function printJentilNotice()
{
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'
),
'<code>jentil</code>',
'<strong>'.JENTIL_MIN_PHP.'</strong>',
'<strong>'.JENTIL_MIN_WP.'</strong>'
).
'</p>
</div>';
}
function deactivateJentil()
{
$themes = wp_get_themes(['allowed' => true]);
unset($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);
}